Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp806733imm; Mon, 21 May 2018 14:52:00 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrLZvnUhJrxPKIueQMbpjFCpW4SPveQ6Fg39qzoUi4Mo1UoPZjX9p3zHb3CpBLZqz57KyZ5 X-Received: by 2002:a63:2485:: with SMTP id k127-v6mr16923935pgk.434.1526939519962; Mon, 21 May 2018 14:51:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526939519; cv=none; d=google.com; s=arc-20160816; b=BCvam3fLAFwyW0I/8j76XPWiK5fwdwpobc5sMnWMYXuS/kSGlG0RLgLO6lDSj/V5pZ h9IBIbaRLaypFAds14XknEVF5pC4Zg73tGAXjpUqsC7ccjFpHSM2oxtAWX5vPsG4hVUN NfaULLHvImfTrJraDIc06Z2PhFgZAInoQmt0TDVO/ufHO1ic+ExHRnSrLmsZ/mioJE2h vo/rDSV7vXBUgmlWzp4340EENUU3kSyaCp0Z44P+BsVGeZwTOHO+75XAOPQGdkmL68Fo bhuqq6Nf8Fb4JK8Q803b3vdF9MwweqcsvXz0Pbi0TJzq70dCbPwaMimv8Vy22NZnDEIu VT7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=id7i4Zn53uZdjAfMEkOclnchlFoWEYALAD1jRP4ns10=; b=txku+0BCu7rZ7FX63sNQ6rMhFOPVqfOLvUPqg4YsajiAY3ArB6cCYzB0GyiXVc31KZ URlR0O0jcGkpPMj8ac73Tao5KYIZ+Lsim/YNcaAKD3PFges1vPMzGe4Ce57wbv1kn/Xy qiVDmWQnhkFG28OxUl87PJnjfzbSkIxgSB9K5x5v/gTbfGFuRAkKKW7ndBRkD/Jjgulq 5X+B5g9laEKb9RP90lSKVAC1RW6i5v39ZsvWTkoO/b/CqOA+7CQ52md8VtlcL9WSU77P GcqAak9z0do+59gAugLhcQ7/+tlMU5DiP9yktb93W6JA7gD0fKPRtbP2v/xA5Ipb2Wvj vLcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=t83VfbfW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j12-v6si11651750pgf.222.2018.05.21.14.51.45; Mon, 21 May 2018 14:51:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=t83VfbfW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932089AbeEUVXC (ORCPT + 99 others); Mon, 21 May 2018 17:23:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:37748 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754077AbeEUVWy (ORCPT ); Mon, 21 May 2018 17:22:54 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D87CA20853; Mon, 21 May 2018 21:22:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526937773; bh=xCnFjP3Cl9PvSqGtnkUcxldCsPZMLxg/Fui55L+JrpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t83VfbfWxO4jN/vrpOYgPf2PGu6paH3vm/S5k/a2zcwcdaYazb9olmXqx5+YTq82K J+NOwZEEBS19sXmZOQ8RYf1vroM6Jrc+tbiVacOTm1CE6c4vNIVaWlnGw+Ev6bGM+t qXLlOvxVPSzp3Wul8vPELOhIuh441ly+duu9IAfU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gabriel Craciunescu , Guenter Roeck Subject: [PATCH 4.16 020/110] hwmon: (k10temp) Use API function to access System Management Network Date: Mon, 21 May 2018 23:11:17 +0200 Message-Id: <20180521210505.656961106@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180521210503.823249477@linuxfoundation.org> References: <20180521210503.823249477@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guenter Roeck commit 3b031622f598481970400519bd5abc2a16708282 upstream. The SMN (System Management Network) on Family 17h AMD CPUs is also accessed from other drivers, specifically EDAC. Accessing it directly is racy. On top of that, accessing the SMN through root bridge 00:00 is wrong on multi-die CPUs and may result in reading the temperature from the wrong die. Use available API functions to fix the problem. For this to work, add dependency on AMD_NB. Also change the Raven Ridge PCI device ID to point to Data Fabric Function 3, since this ID is used by the API functions to find the CPU node. Cc: stable@vger.kernel.org # v4.16+ Tested-by: Gabriel Craciunescu Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/Kconfig | 2 +- drivers/hwmon/k10temp.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -272,7 +272,7 @@ config SENSORS_K8TEMP config SENSORS_K10TEMP tristate "AMD Family 10h+ temperature sensor" - depends on X86 && PCI + depends on X86 && PCI && AMD_NB help If you say yes here you get support for the temperature sensor(s) inside your CPU. Supported are later revisions of --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -23,6 +23,7 @@ #include #include #include +#include #include MODULE_DESCRIPTION("AMD Family 10h+ CPU core temperature monitor"); @@ -40,8 +41,8 @@ static DEFINE_MUTEX(nb_smu_ind_mutex); #define PCI_DEVICE_ID_AMD_17H_DF_F3 0x1463 #endif -#ifndef PCI_DEVICE_ID_AMD_17H_RR_NB -#define PCI_DEVICE_ID_AMD_17H_RR_NB 0x15d0 +#ifndef PCI_DEVICE_ID_AMD_17H_M10H_DF_F3 +#define PCI_DEVICE_ID_AMD_17H_M10H_DF_F3 0x15eb #endif /* CPUID function 0x80000001, ebx */ @@ -136,8 +137,8 @@ static void read_tempreg_nb_f15(struct p static void read_tempreg_nb_f17(struct pci_dev *pdev, u32 *regval) { - amd_nb_index_read(pdev, PCI_DEVFN(0, 0), 0x60, - F17H_M01H_REPORTED_TEMP_CTRL_OFFSET, regval); + amd_smn_read(amd_pci_dev_to_node_id(pdev), + F17H_M01H_REPORTED_TEMP_CTRL_OFFSET, regval); } static ssize_t temp1_input_show(struct device *dev, @@ -322,7 +323,7 @@ static const struct pci_device_id k10tem { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) }, { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) }, { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) }, - { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_RR_NB) }, + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_M10H_DF_F3) }, {} }; MODULE_DEVICE_TABLE(pci, k10temp_id_table);