Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp807168imm; Mon, 21 May 2018 14:52:30 -0700 (PDT) X-Google-Smtp-Source: AB8JxZouDPK91MnKiZTgrj419cozZmFTgDK54H4VMQGDRwR1Zl5eM08OLE8ursvstaQ4hYU4JM1/ X-Received: by 2002:a62:cf43:: with SMTP id b64-v6mr21450794pfg.248.1526939550281; Mon, 21 May 2018 14:52:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526939550; cv=none; d=google.com; s=arc-20160816; b=RBXyEgrGh9rDn8c9wI8XRXZIOjS+rTDGEPQTgdKGI5TL4JooDz0dP4pSzoWJp0xvsM 1Qw441w2GSl/lCSQEeWDkTUSpX/+Syt4GjqW6CeAQ5QqW5NNfokEsJ772YkCRc0yQNY+ p7/5LZsCDGl7px69vJPE2b08BPvdp6Vr/SCSVutegZ015zFutAXn5C93Royt63z+K+Vg OE2pCEk4xexSxktn+OCSFEBTnCGc7su3wNk5SJNMN5Eaj4bMySkyPMYRq1IQ5q8nmuv7 AC8A6mFXi9QCSHd11M0Nmz9M0WEpG9O5PxSoyP4xqcnWHL4zMLINoOQU7k3aDCGgweyM YQpg== 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=a3Zy4pJVhRV44sXgbNAn5lV+1tZEHKFzDa6HyDWXjqg=; b=D7pLXKIXN2fsfE+3g7+WjGpDz/IRhjcXL90IUrKVsAGpZIgnWehibPbjn8SHicQns+ aPvd2A8eDklTLZFYwTC/UEeOiBRXaft3t8dAVvk0hD/3XzYuFwATajGKO1b4imotJnDG hkaG0vvjLIx9eFN5zgz7ftbKoYFWcIHuzTLOKeprYGydEPdU4Ri8wkW7RfYCDuzZgbbA nIf5thnSLKs4E+w+SYmm+7yk6ZvAAv4nzjWxCfbxRk88L+4So/Q+4arX/1fVHhRkSMEz f8ft8gX1szU52K16Pu6gsz6wvKAT85bBopwfAkljPNqdv7dIc0pOwBYc+MtDEURgLHA/ 20xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xbLTIoVb; 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 2-v6si15129788pfk.287.2018.05.21.14.52.15; Mon, 21 May 2018 14:52:30 -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=xbLTIoVb; 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 S932183AbeEUVvo (ORCPT + 99 others); Mon, 21 May 2018 17:51:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:37688 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751553AbeEUVWs (ORCPT ); Mon, 21 May 2018 17:22:48 -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 77DA12075C; Mon, 21 May 2018 21:22:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526937768; bh=jIyp96FArB3XQuTaWiOIjp7AnLXbRhgD3fOxAtvWu3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xbLTIoVbAfMy6nPXfkfLjNEjN0JmhraWND8H8f8d5f5QEF6aoDAOEPDypAOWo3I8y rqZEw3Qb5OqvWRUvIobyvzD8sSaLdTNULm06lZYlLmzP2rYUrSpIYAFZ0eZcN2DGPE WVnBgX/CLdcdN6xSH00YSHfulf9BcgZwbwhlL+e8= 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 019/110] hwmon: (k10temp) Fix reading critical temperature register Date: Mon, 21 May 2018 23:11:16 +0200 Message-Id: <20180521210505.567817304@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 40626a1bf657eef557fcee9e1b8ef5b4f5b56dcd upstream. The HTC (Hardware Temperature Control) register has moved for recent chips. Cc: stable@vger.kernel.org # v4.16+ Tested-by: Gabriel Craciunescu Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/k10temp.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -63,10 +63,12 @@ static DEFINE_MUTEX(nb_smu_ind_mutex); #define NB_CAP_HTC 0x00000400 /* - * For F15h M60h, functionality of REG_REPORTED_TEMPERATURE - * has been moved to D0F0xBC_xD820_0CA4 [Reported Temperature - * Control] + * For F15h M60h and M70h, REG_HARDWARE_THERMAL_CONTROL + * and REG_REPORTED_TEMPERATURE have been moved to + * D0F0xBC_xD820_0C64 [Hardware Temperature Control] + * D0F0xBC_xD820_0CA4 [Reported Temperature Control] */ +#define F15H_M60H_HARDWARE_TEMP_CTRL_OFFSET 0xd8200c64 #define F15H_M60H_REPORTED_TEMP_CTRL_OFFSET 0xd8200ca4 /* F17h M01h Access througn SMN */ @@ -74,6 +76,7 @@ static DEFINE_MUTEX(nb_smu_ind_mutex); struct k10temp_data { struct pci_dev *pdev; + void (*read_htcreg)(struct pci_dev *pdev, u32 *regval); void (*read_tempreg)(struct pci_dev *pdev, u32 *regval); int temp_offset; u32 temp_adjust_mask; @@ -98,6 +101,11 @@ static const struct tctl_offset tctl_off { 0x17, "AMD Ryzen Threadripper 1910", 10000 }, }; +static void read_htcreg_pci(struct pci_dev *pdev, u32 *regval) +{ + pci_read_config_dword(pdev, REG_HARDWARE_THERMAL_CONTROL, regval); +} + static void read_tempreg_pci(struct pci_dev *pdev, u32 *regval) { pci_read_config_dword(pdev, REG_REPORTED_TEMPERATURE, regval); @@ -114,6 +122,12 @@ static void amd_nb_index_read(struct pci mutex_unlock(&nb_smu_ind_mutex); } +static void read_htcreg_nb_f15(struct pci_dev *pdev, u32 *regval) +{ + amd_nb_index_read(pdev, PCI_DEVFN(0, 0), 0xb8, + F15H_M60H_HARDWARE_TEMP_CTRL_OFFSET, regval); +} + static void read_tempreg_nb_f15(struct pci_dev *pdev, u32 *regval) { amd_nb_index_read(pdev, PCI_DEVFN(0, 0), 0xb8, @@ -160,8 +174,7 @@ static ssize_t show_temp_crit(struct dev u32 regval; int value; - pci_read_config_dword(data->pdev, - REG_HARDWARE_THERMAL_CONTROL, ®val); + data->read_htcreg(data->pdev, ®val); value = ((regval >> 16) & 0x7f) * 500 + 52000; if (show_hyst) value -= ((regval >> 24) & 0xf) * 500; @@ -181,13 +194,18 @@ static umode_t k10temp_is_visible(struct struct pci_dev *pdev = data->pdev; if (index >= 2) { - u32 reg_caps, reg_htc; + u32 reg; + + if (!data->read_htcreg) + return 0; pci_read_config_dword(pdev, REG_NORTHBRIDGE_CAPABILITIES, - ®_caps); - pci_read_config_dword(pdev, REG_HARDWARE_THERMAL_CONTROL, - ®_htc); - if (!(reg_caps & NB_CAP_HTC) || !(reg_htc & HTC_ENABLE)) + ®); + if (!(reg & NB_CAP_HTC)) + return 0; + + data->read_htcreg(data->pdev, ®); + if (!(reg & HTC_ENABLE)) return 0; } return attr->mode; @@ -268,11 +286,13 @@ static int k10temp_probe(struct pci_dev if (boot_cpu_data.x86 == 0x15 && (boot_cpu_data.x86_model == 0x60 || boot_cpu_data.x86_model == 0x70)) { + data->read_htcreg = read_htcreg_nb_f15; data->read_tempreg = read_tempreg_nb_f15; } else if (boot_cpu_data.x86 == 0x17) { data->temp_adjust_mask = 0x80000; data->read_tempreg = read_tempreg_nb_f17; } else { + data->read_htcreg = read_htcreg_pci; data->read_tempreg = read_tempreg_pci; }