Received: by 10.192.165.148 with SMTP id m20csp231873imm; Thu, 26 Apr 2018 20:15:01 -0700 (PDT) X-Google-Smtp-Source: AB8JxZola1h+qia/Q9dWfXuNmFyDlnaeMXL4BEmBDiPS0U+KirAxn1llsPAmSpGjotHEVUzS7uJ7 X-Received: by 10.98.161.17 with SMTP id b17mr283330pff.132.1524798901438; Thu, 26 Apr 2018 20:15:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524798901; cv=none; d=google.com; s=arc-20160816; b=toqpXQfnJA5Q84/MkFavs/52s7JH20HTC7ild5jDgrLgF4IL7qXGXifx4KX/5ph0tx 9IwUDCH5HgMrY1ejNsspgxHeFHoMWGah8vgtjV7sQiO+noTPJm9nVZe6I1XLNqO0gdkT Wu5i8SPiDw+ejMhfWtS9Wei+qpNJ1txIzkxlVfvwAjFkR/M7xuOJlN5LuwTHjqzCgwiJ KL6VR47NB4j+4pNYqjPiYRiGPcaTrnIf2MqN6tYgzgmNkfL+FcppKaupS/ZclhCFjS8r dWSlcXklYqkhsqXcu9d+GO8UPC7Op9Cx84v0bYo99eNuft2nm5dDcjOkK/fROK/+i1MX JhYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=V3s4Y+q2dI1eTF4K15O0kZAYobhGLgbBfwYxEIjRI0Y=; b=Ypo2x+qGH5R22YA9shU7WqzUz7QW4PvNGFLctI7f9ej0kcVLjgj3y5KiD69jEt1R3T VqN3WazqF/1ejM6xf2GOOUHkP5Ck8SIS0fy2+FtYxlyI1Hhz2dLJt3jADBAZdYi+cvh/ Wxvw/oTCIwHGlgmeTKB039LWq5PhWjVpTNOsQkTslAqkuky61ZUJTj/MDSiTEH+MNZuT 7WMmEa+AP3ZBwlQtK0F513Z3p2q5Sjww6J+Oup8b85p5iqVAWMLF9h7AP3Ab5/FYNnQJ EI8nF+5jBY8sVCVkm+t1iP/lvpW6jlw8QkamoaOCeUPggLJUL2J3XEqagAlsuNj+d1qj uv5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@roeck-us.net header.s=default header.b=3w8oERmP; 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 p15-v6si365140pgf.358.2018.04.26.20.14.47; Thu, 26 Apr 2018 20:15:01 -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=fail header.i=@roeck-us.net header.s=default header.b=3w8oERmP; 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 S1757397AbeD0DNO (ORCPT + 99 others); Thu, 26 Apr 2018 23:13:14 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:53260 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757286AbeD0DNM (ORCPT ); Thu, 26 Apr 2018 23:13:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender: Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=V3s4Y+q2dI1eTF4K15O0kZAYobhGLgbBfwYxEIjRI0Y=; b=3w8oERmPcGjqY7LCt8CYWuUS4t kk/DoIcvqgedNf2aSnqx9FmQCVmxSEkrfwl8Cq7GD5+nCD3aGKL9n8T0J5prwiVrelvPQwj9AQ1/q qf34WPi0Zny8AT4634kH2bBT7RvlogDlHZD/jo60XJSr7N814J/Id0kbmQlshJjxuDiMU26rQ0FLd y67GLpWqh/ciwYIIe/+vrdoL6zQS/VwI7GKRTTQ/D4lKboMgn3hx8vCutw2GesgnSq7o0OvkSmF4/ SYWLZFNRDRTCBcMdAjuA4ECYmWi2kMP3CFwqvm+hAuh2uNUFm019cgYWa77m+rWg9J47dkWHdYjU4 bzgcDpjg==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:49460 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.89) (envelope-from ) id 1fBtos-000E5f-L6; Fri, 27 Apr 2018 03:13:11 +0000 From: Guenter Roeck To: Clemens Ladisch Cc: Jean Delvare , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Brian Woods , Guenter Roeck Subject: [PATCH 1/2] hwmon: (k10temp) Fix reading critical temperature register Date: Thu, 26 Apr 2018 20:13:08 -0700 Message-Id: <1524798789-2239-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The HTC (Hardware Temperature Control) register has moved for recent chips. Signed-off-by: Guenter Roeck --- Compile tested only. drivers/hwmon/k10temp.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index d2cc55e21374..b06bb1f90853 100644 --- 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_offset_table[] = { { 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_dev *pdev, unsigned int devfn, 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, @@ -181,13 +195,18 @@ static umode_t k10temp_is_visible(struct kobject *kobj, 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 +287,13 @@ static int k10temp_probe(struct pci_dev *pdev, 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; } -- 2.7.4