From patchwork Tue Jan 21 02:30:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 11343043 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 30E0B92A for ; Tue, 21 Jan 2020 02:30:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0F45F24125 for ; Tue, 21 Jan 2020 02:30:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jhRBqmGW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728921AbgAUCai (ORCPT ); Mon, 20 Jan 2020 21:30:38 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:36322 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726890AbgAUCai (ORCPT ); Mon, 20 Jan 2020 21:30:38 -0500 Received: by mail-pl1-f193.google.com with SMTP id a6so655194plm.3; Mon, 20 Jan 2020 18:30:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=nsYKoT1BpY0kUNRQePG66qpdiEA4oi0keuUWKmcNOtI=; b=jhRBqmGW1xtgmUKcHugKxEGxLlWOlem2RDuiZSGEqU1r55YLB8bDC459bdovaUb1Er F6z2KdOcwJSv9x9+sKOEFM1lNgVIWfkQhsl/XoyowJcr3EfnmCWux2FNk6KjHWZztSYR UYsaCKEogJZv3//b8W7pVkBfNeFM0qPvNrLu6qrTfHkbE6yz4rKJ9e6dziYJE6vC5MDh kG9DRmTN/uuQ0BBrPqdJukXG25UwUx+l2bcHryO41szwGl9j8wHFQTqFj7wsPQ3GcpFj osHyMgsZ+9ExAXofWRwnrgaOfx8oRuLbI5dUy1TIcmvM3oGKqycb5LZNrInDvRNfiRD8 9mxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=nsYKoT1BpY0kUNRQePG66qpdiEA4oi0keuUWKmcNOtI=; b=BxW/AXGTZ4DLwXHJLclT6VQ8Dfxf40ElmKWgH+d2/1SyIH2p2imHMpqZFIGUCTheLQ hKmnWubU3c1MXZgYGYoy/aXLZaYnyLT/Vb8It4qEopz5OEz8SNYo1/9JcL19KEXyC4gd CTxxNQfNuzoeKUJKM1oX5gRyTeS6FaXlYJdkfHtYz7XCZlfmqqqOqeGQaLqSVpAca3/6 IiXfqrxe+bBFbO+4Ex0QMt6fNJ9pK8ymVabONETUX21w2Pdf6E5bQiGPoVQ2kyxCLxem SCBoeogcz+D9IxPadvcQ0Dl97TvcQuzrCtwnzO5Rcm5FM531OQSj3knJu4S8SNz2uKSL EUHQ== X-Gm-Message-State: APjAAAVbzHjkU/YZGjyy/NupTJb9j6AUfNBV6xI2UPYr/Xl72qhR43vG Yg0fvb6AvvRcjG5+svYK+OG284ey X-Google-Smtp-Source: APXvYqxISNary6tTU/LmG524YDQnM6JO9UU0gNEyDyrVaQh+lxsme2pAabDfHldryk4LfPx8Gp5xkw== X-Received: by 2002:a17:90a:804a:: with SMTP id e10mr2583574pjw.41.1579573837651; Mon, 20 Jan 2020 18:30:37 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id n4sm38310219pgg.88.2020.01.20.18.30.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Jan 2020 18:30:37 -0800 (PST) From: Guenter Roeck To: linux-hwmon@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Clemens Ladisch , Jean Delvare , Brad Campbell , =?utf-8?q?Ondrej_=C4=8Cerman?= , Bernhard Gebetsberger , Holger Kiehl , Michael Larabel , Jonathan McDowell , Ken Moffat , Sebastian Reichel , Darren Salt , Guenter Roeck Subject: [PATCH v3 1/5] hwmon: (k10temp) Use bitops Date: Mon, 20 Jan 2020 18:30:23 -0800 Message-Id: <20200121023027.2081-2-linux@roeck-us.net> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200121023027.2081-1-linux@roeck-us.net> References: <20200121023027.2081-1-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Using bitops makes bit masks and shifts easier to read. Tested-by: Brad Campbell Tested-by: Bernhard Gebetsberger Tested-by: Holger Kiehl Tested-by: Michael Larabel Tested-by: Jonathan McDowell Tested-by: Ken Moffat Tested-by: Darren Salt Signed-off-by: Guenter Roeck --- drivers/hwmon/k10temp.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index 5c1dddde193c..8807d7da68db 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -5,6 +5,7 @@ * Copyright (c) 2009 Clemens Ladisch */ +#include #include #include #include @@ -31,22 +32,22 @@ static DEFINE_MUTEX(nb_smu_ind_mutex); #endif /* CPUID function 0x80000001, ebx */ -#define CPUID_PKGTYPE_MASK 0xf0000000 +#define CPUID_PKGTYPE_MASK GENMASK(31, 28) #define CPUID_PKGTYPE_F 0x00000000 #define CPUID_PKGTYPE_AM2R2_AM3 0x10000000 /* DRAM controller (PCI function 2) */ #define REG_DCT0_CONFIG_HIGH 0x094 -#define DDR3_MODE 0x00000100 +#define DDR3_MODE BIT(8) /* miscellaneous (PCI function 3) */ #define REG_HARDWARE_THERMAL_CONTROL 0x64 -#define HTC_ENABLE 0x00000001 +#define HTC_ENABLE BIT(0) #define REG_REPORTED_TEMPERATURE 0xa4 #define REG_NORTHBRIDGE_CAPABILITIES 0xe8 -#define NB_CAP_HTC 0x00000400 +#define NB_CAP_HTC BIT(10) /* * For F15h M60h and M70h, REG_HARDWARE_THERMAL_CONTROL @@ -60,6 +61,9 @@ static DEFINE_MUTEX(nb_smu_ind_mutex); /* F17h M01h Access througn SMN */ #define F17H_M01H_REPORTED_TEMP_CTRL_OFFSET 0x00059800 +#define CUR_TEMP_SHIFT 21 +#define CUR_TEMP_RANGE_SEL_MASK BIT(19) + struct k10temp_data { struct pci_dev *pdev; void (*read_htcreg)(struct pci_dev *pdev, u32 *regval); @@ -129,7 +133,7 @@ static unsigned int get_raw_temp(struct k10temp_data *data) u32 regval; data->read_tempreg(data->pdev, ®val); - temp = (regval >> 21) * 125; + temp = (regval >> CUR_TEMP_SHIFT) * 125; if (regval & data->temp_adjust_mask) temp -= 49000; return temp; @@ -312,7 +316,7 @@ static int k10temp_probe(struct pci_dev *pdev, data->read_htcreg = read_htcreg_nb_f15; data->read_tempreg = read_tempreg_nb_f15; } else if (boot_cpu_data.x86 == 0x17 || boot_cpu_data.x86 == 0x18) { - data->temp_adjust_mask = 0x80000; + data->temp_adjust_mask = CUR_TEMP_RANGE_SEL_MASK; data->read_tempreg = read_tempreg_nb_f17; data->show_tdie = true; } else { From patchwork Tue Jan 21 02:30:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 11343051 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 68F3692A for ; Tue, 21 Jan 2020 02:30:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 318D32465A for ; Tue, 21 Jan 2020 02:30:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UWr6M2vv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729043AbgAUCak (ORCPT ); Mon, 20 Jan 2020 21:30:40 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:36737 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726890AbgAUCak (ORCPT ); Mon, 20 Jan 2020 21:30:40 -0500 Received: by mail-pg1-f195.google.com with SMTP id k3so638922pgc.3; Mon, 20 Jan 2020 18:30:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=2TWeVdE7IiqXKwtqthavTGOK3VlPsF519h/qxKiwBH8=; b=UWr6M2vvnvogn67/lqEIk6nI3ETzsojv9QYOPYczZOB1zP322OYsEgG2SVrPYY5mej ZrPcaQiK2BjC3YUrwkwOB5tgPeggZdKqFMDOX5SONBdAWtVHd27or73BCSw4pbnx6naJ eux/dJ1gcl3dtOr1sMJfz1gCDWh+6oIqGcDyLr8JCH3Kipii8BmunWoLQMtRMqshey4q OuYQc2TFrTFoStVWKlWWORNl4G0Axt9d2r4jNQA/zxe/qD0x/eT7SrG7SI4z81F/9yY6 fpYJUZnt9b6RfH47n1XggP0wFycqA9Apbix8AAPpfCI6Fw2U4OSP6G0FYuEjBZaHHauT cEaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=2TWeVdE7IiqXKwtqthavTGOK3VlPsF519h/qxKiwBH8=; b=NasKvTUDiV6vTrIaeDCf/9KDmSeEGp5rXMHpu+mSI5qPVScZomYKaLUgJ69M7xPfvi Kc/IwP9m8HWXVXIvj7X/Hymwax3gQN0EYgl/qE1ZH3tLVdI4lq+DXmjB+0lE/rbfpgpe cKRSjhi9YGUbvf6nvSSooIq2+tbk4b6XNXB18IdibgL4d0uwKXnLptVVu8Dl2KXOQiCk rdXD4YT7NjAwJDcwDfDlPjwsg0qQMGfTDrw6Ohbmgr6ReLw5r/IKxMBi7UNrpRJN1LHJ mB4bxqyo+e0EL/WcnA344hW7WuAPcvN0IC62FgieeY+wrpuEEbenzIdiQYxqfIzapCqJ dVww== X-Gm-Message-State: APjAAAXLcCoq65+cb+MuXyW5gaNBKsBXe8okNtMKrH9B2wLnay0VxXoC +kgCifyKAfx6Qg0baH1irSQimdrD X-Google-Smtp-Source: APXvYqy2tO9VVNmNY4ECfNWMq/TIvWfh72QjB0FqxWDD+4MbXHGbqbeYPuhs4IGBsEZCZckN9WEXGA== X-Received: by 2002:aa7:8181:: with SMTP id g1mr2253068pfi.215.1579573839061; Mon, 20 Jan 2020 18:30:39 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id l2sm763160pjt.31.2020.01.20.18.30.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Jan 2020 18:30:38 -0800 (PST) From: Guenter Roeck To: linux-hwmon@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Clemens Ladisch , Jean Delvare , Brad Campbell , =?utf-8?q?Ondrej_=C4=8Cerman?= , Bernhard Gebetsberger , Holger Kiehl , Michael Larabel , Jonathan McDowell , Ken Moffat , Sebastian Reichel , Darren Salt , Guenter Roeck Subject: [PATCH v3 2/5] hmon: (k10temp) Convert to use devm_hwmon_device_register_with_info Date: Mon, 20 Jan 2020 18:30:24 -0800 Message-Id: <20200121023027.2081-3-linux@roeck-us.net> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200121023027.2081-1-linux@roeck-us.net> References: <20200121023027.2081-1-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Convert driver to use devm_hwmon_device_register_with_info to simplify the code and to reduce its size. Old size (x86_64): text data bss dec hex filename 8247 4488 64 12799 31ff drivers/hwmon/k10temp.o New size: text data bss dec hex filename 6778 2792 64 9634 25a2 drivers/hwmon/k10temp.o Tested-by: Brad Campbell Tested-by: Bernhard Gebetsberger Tested-by: Holger Kiehl Tested-by: Michael Larabel Tested-by: Jonathan McDowell Tested-by: Ken Moffat Tested-by: Darren Salt Signed-off-by: Guenter Roeck --- drivers/hwmon/k10temp.c | 213 +++++++++++++++++++++------------------- 1 file changed, 112 insertions(+), 101 deletions(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index 8807d7da68db..c45f6498a59b 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -1,14 +1,15 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * k10temp.c - AMD Family 10h/11h/12h/14h/15h/16h processor hardware monitoring + * k10temp.c - AMD Family 10h/11h/12h/14h/15h/16h/17h + * processor hardware monitoring * * Copyright (c) 2009 Clemens Ladisch + * Copyright (c) 2020 Guenter Roeck */ #include #include #include -#include #include #include #include @@ -127,10 +128,10 @@ static void read_tempreg_nb_f17(struct pci_dev *pdev, u32 *regval) F17H_M01H_REPORTED_TEMP_CTRL_OFFSET, regval); } -static unsigned int get_raw_temp(struct k10temp_data *data) +static long get_raw_temp(struct k10temp_data *data) { - unsigned int temp; u32 regval; + long temp; data->read_tempreg(data->pdev, ®val); temp = (regval >> CUR_TEMP_SHIFT) * 125; @@ -139,118 +140,108 @@ static unsigned int get_raw_temp(struct k10temp_data *data) return temp; } -static ssize_t temp1_input_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct k10temp_data *data = dev_get_drvdata(dev); - unsigned int temp = get_raw_temp(data); - - if (temp > data->temp_offset) - temp -= data->temp_offset; - else - temp = 0; - - return sprintf(buf, "%u\n", temp); -} - -static ssize_t temp2_input_show(struct device *dev, - struct device_attribute *devattr, char *buf) -{ - struct k10temp_data *data = dev_get_drvdata(dev); - unsigned int temp = get_raw_temp(data); - - return sprintf(buf, "%u\n", temp); -} - -static ssize_t temp_label_show(struct device *dev, - struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - - return sprintf(buf, "%s\n", attr->index ? "Tctl" : "Tdie"); -} +const char *k10temp_temp_label[] = { + "Tdie", + "Tctl", +}; -static ssize_t temp1_max_show(struct device *dev, - struct device_attribute *attr, char *buf) +static int k10temp_read_labels(struct device *dev, + enum hwmon_sensor_types type, + u32 attr, int channel, const char **str) { - return sprintf(buf, "%d\n", 70 * 1000); + *str = k10temp_temp_label[channel]; + return 0; } -static ssize_t temp_crit_show(struct device *dev, - struct device_attribute *devattr, char *buf) +static int k10temp_read(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long *val) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct k10temp_data *data = dev_get_drvdata(dev); - int show_hyst = attr->index; u32 regval; - int value; - data->read_htcreg(data->pdev, ®val); - value = ((regval >> 16) & 0x7f) * 500 + 52000; - if (show_hyst) - value -= ((regval >> 24) & 0xf) * 500; - return sprintf(buf, "%d\n", value); + switch (attr) { + case hwmon_temp_input: + switch (channel) { + case 0: /* Tdie */ + *val = get_raw_temp(data) - data->temp_offset; + if (*val < 0) + *val = 0; + break; + case 1: /* Tctl */ + *val = get_raw_temp(data); + if (*val < 0) + *val = 0; + break; + default: + return -EOPNOTSUPP; + } + break; + case hwmon_temp_max: + *val = 70 * 1000; + break; + case hwmon_temp_crit: + data->read_htcreg(data->pdev, ®val); + *val = ((regval >> 16) & 0x7f) * 500 + 52000; + break; + case hwmon_temp_crit_hyst: + data->read_htcreg(data->pdev, ®val); + *val = (((regval >> 16) & 0x7f) + - ((regval >> 24) & 0xf)) * 500 + 52000; + break; + default: + return -EOPNOTSUPP; + } + return 0; } -static DEVICE_ATTR_RO(temp1_input); -static DEVICE_ATTR_RO(temp1_max); -static SENSOR_DEVICE_ATTR_RO(temp1_crit, temp_crit, 0); -static SENSOR_DEVICE_ATTR_RO(temp1_crit_hyst, temp_crit, 1); - -static SENSOR_DEVICE_ATTR_RO(temp1_label, temp_label, 0); -static DEVICE_ATTR_RO(temp2_input); -static SENSOR_DEVICE_ATTR_RO(temp2_label, temp_label, 1); - -static umode_t k10temp_is_visible(struct kobject *kobj, - struct attribute *attr, int index) +static umode_t k10temp_is_visible(const void *_data, + enum hwmon_sensor_types type, + u32 attr, int channel) { - struct device *dev = container_of(kobj, struct device, kobj); - struct k10temp_data *data = dev_get_drvdata(dev); + const struct k10temp_data *data = _data; struct pci_dev *pdev = data->pdev; u32 reg; - switch (index) { - case 0 ... 1: /* temp1_input, temp1_max */ - default: - break; - case 2 ... 3: /* temp1_crit, temp1_crit_hyst */ - if (!data->read_htcreg) - return 0; - - pci_read_config_dword(pdev, REG_NORTHBRIDGE_CAPABILITIES, - ®); - if (!(reg & NB_CAP_HTC)) - return 0; - - data->read_htcreg(data->pdev, ®); - if (!(reg & HTC_ENABLE)) - return 0; - break; - case 4 ... 6: /* temp1_label, temp2_input, temp2_label */ - if (!data->show_tdie) + switch (type) { + case hwmon_temp: + switch (attr) { + case hwmon_temp_input: + if (channel && !data->show_tdie) + return 0; + break; + case hwmon_temp_max: + if (channel) + return 0; + break; + case hwmon_temp_crit: + case hwmon_temp_crit_hyst: + if (channel || !data->read_htcreg) + return 0; + + pci_read_config_dword(pdev, + REG_NORTHBRIDGE_CAPABILITIES, + ®); + if (!(reg & NB_CAP_HTC)) + return 0; + + data->read_htcreg(data->pdev, ®); + if (!(reg & HTC_ENABLE)) + return 0; + break; + case hwmon_temp_label: + if (!data->show_tdie) + return 0; + break; + default: return 0; + } break; + default: + return 0; } - return attr->mode; + return 0444; } -static struct attribute *k10temp_attrs[] = { - &dev_attr_temp1_input.attr, - &dev_attr_temp1_max.attr, - &sensor_dev_attr_temp1_crit.dev_attr.attr, - &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, - &sensor_dev_attr_temp1_label.dev_attr.attr, - &dev_attr_temp2_input.attr, - &sensor_dev_attr_temp2_label.dev_attr.attr, - NULL -}; - -static const struct attribute_group k10temp_group = { - .attrs = k10temp_attrs, - .is_visible = k10temp_is_visible, -}; -__ATTRIBUTE_GROUPS(k10temp); - static bool has_erratum_319(struct pci_dev *pdev) { u32 pkg_type, reg_dram_cfg; @@ -285,8 +276,27 @@ static bool has_erratum_319(struct pci_dev *pdev) (boot_cpu_data.x86_model == 4 && boot_cpu_data.x86_stepping <= 2); } -static int k10temp_probe(struct pci_dev *pdev, - const struct pci_device_id *id) +static const struct hwmon_channel_info *k10temp_info[] = { + HWMON_CHANNEL_INFO(temp, + HWMON_T_INPUT | HWMON_T_MAX | + HWMON_T_CRIT | HWMON_T_CRIT_HYST | + HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL), + NULL +}; + +static const struct hwmon_ops k10temp_hwmon_ops = { + .is_visible = k10temp_is_visible, + .read = k10temp_read, + .read_string = k10temp_read_labels, +}; + +static const struct hwmon_chip_info k10temp_chip_info = { + .ops = &k10temp_hwmon_ops, + .info = k10temp_info, +}; + +static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id) { int unreliable = has_erratum_319(pdev); struct device *dev = &pdev->dev; @@ -334,8 +344,9 @@ static int k10temp_probe(struct pci_dev *pdev, } } - hwmon_dev = devm_hwmon_device_register_with_groups(dev, "k10temp", data, - k10temp_groups); + hwmon_dev = devm_hwmon_device_register_with_info(dev, "k10temp", data, + &k10temp_chip_info, + NULL); return PTR_ERR_OR_ZERO(hwmon_dev); } From patchwork Tue Jan 21 02:30:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 11343045 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A27392A for ; Tue, 21 Jan 2020 02:30:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F82024653 for ; Tue, 21 Jan 2020 02:30:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CuN7tAkv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729076AbgAUCao (ORCPT ); Mon, 20 Jan 2020 21:30:44 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35732 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726890AbgAUCan (ORCPT ); Mon, 20 Jan 2020 21:30:43 -0500 Received: by mail-pf1-f196.google.com with SMTP id i23so682247pfo.2; Mon, 20 Jan 2020 18:30:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=VxnzGBrXJdc5++MOR2PqTgd6vfK8aKrNf+LXo8LzP7Q=; b=CuN7tAkvF69MjbBbO/7wkB6L/LvGQYHD5+0UK8jbCJWc+xDxOQnQFEY2QarMSr3RTZ rMEOKMoZv5eD22/AQsxDqxyqDwtRrZ/xzdAEPX9FurWrS1wR5kQuqnbFLgm+tNsAMuIp WWr1WHok7xVfg7jg7VKrm6uo9HvGySIuZEXLvCrwOnd5PmmmvsW2+vPyPH/l47r0I4NX p0GHf2m5qdI/sAjUNk4qwsSa8nbKTo5QYRM/CeZheQ71oXi8dbTpGD+8mIweiwLN8CS2 JcCB5FpuzmBS3t8nv8T2acvRnAxTrp5ZJfUssHDCvC7i6Ike2XZVwq8ZQKrCQWzSp2su aQow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=VxnzGBrXJdc5++MOR2PqTgd6vfK8aKrNf+LXo8LzP7Q=; b=cx0E3v0mWBBl+0xfpJc0e/CGWi4yd2fxs3Iil1QzeNvXrhrSN92M0hDawjzx8ht/SQ FXZVk75DS9JoHn6pVqCB+NudvZHLmluBDt0ogs4/5r22/w9rytj3irVid2/sov4Ee6Cu F+bUWBMqIasH5buxboYI5ylLdZziTAyeGBFxM/P10svHpvbylfHuyfHQGFt+zTnE3wTR VUezxQPkZOreCiQX3YQwdkbk4y9ufhbsBHsJ1f7/EabJU8wh/LT1hVPV9+6rhJum4hdW AN5DgMgnW5AfpAsoAwY9UmXgWjcO7KaxPLwiVN93X7lsK/L1eKGA+CawEvm0sgVlnjPr QKzg== X-Gm-Message-State: APjAAAVUL/E9uLksuKS0CUH6OZH/913OVb3ESUSmm5/Mh1xopco8Syo0 C/XQK2IR9vAc8fqdfjiOxBw0kbbE X-Google-Smtp-Source: APXvYqzSmaj2Dytxc2KGcbld/0cFQJlV4FAPUWc1PHXVqCkpgf32TwglJ+o/g4+mu7JGYZnFuvkm8Q== X-Received: by 2002:a62:5214:: with SMTP id g20mr2197850pfb.101.1579573843040; Mon, 20 Jan 2020 18:30:43 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id y14sm40211391pfe.147.2020.01.20.18.30.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Jan 2020 18:30:39 -0800 (PST) From: Guenter Roeck To: linux-hwmon@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Clemens Ladisch , Jean Delvare , Brad Campbell , =?utf-8?q?Ondrej_=C4=8Cerman?= , Bernhard Gebetsberger , Holger Kiehl , Michael Larabel , Jonathan McDowell , Ken Moffat , Sebastian Reichel , Darren Salt , Guenter Roeck Subject: [PATCH v3 3/5] hwmon: (k10temp) Report temperatures per CPU die Date: Mon, 20 Jan 2020 18:30:25 -0800 Message-Id: <20200121023027.2081-4-linux@roeck-us.net> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200121023027.2081-1-linux@roeck-us.net> References: <20200121023027.2081-1-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Zen2 reports reporting temperatures per CPU die (called Core Complex Dies, or CCD, by AMD). Add support for it to the k10temp driver. Tested-by: Brad Campbell Tested-by: Bernhard Gebetsberger Tested-by: Holger Kiehl Tested-by: Michael Larabel Tested-by: Jonathan McDowell Tested-by: Ken Moffat Tested-by: Darren Salt Signed-off-by: Guenter Roeck --- drivers/hwmon/k10temp.c | 80 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index c45f6498a59b..0af096b061fa 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -5,6 +5,12 @@ * * Copyright (c) 2009 Clemens Ladisch * Copyright (c) 2020 Guenter Roeck + * + * Implementation notes: + * - CCD1 and CCD2 register address information as well as the calculation to + * convert raw register values is from https://github.com/ocerman/zenpower. + * The information is not confirmed from chip datasheets, but experiments + * suggest that it provides reasonable temperature values. */ #include @@ -61,6 +67,8 @@ static DEFINE_MUTEX(nb_smu_ind_mutex); /* F17h M01h Access througn SMN */ #define F17H_M01H_REPORTED_TEMP_CTRL_OFFSET 0x00059800 +#define F17H_M70H_CCD1_TEMP 0x00059954 +#define F17H_M70H_CCD2_TEMP 0x00059958 #define CUR_TEMP_SHIFT 21 #define CUR_TEMP_RANGE_SEL_MASK BIT(19) @@ -72,6 +80,8 @@ struct k10temp_data { int temp_offset; u32 temp_adjust_mask; bool show_tdie; + bool show_tccd1; + bool show_tccd2; }; struct tctl_offset { @@ -143,6 +153,8 @@ static long get_raw_temp(struct k10temp_data *data) const char *k10temp_temp_label[] = { "Tdie", "Tctl", + "Tccd1", + "Tccd2", }; static int k10temp_read_labels(struct device *dev, @@ -172,6 +184,16 @@ static int k10temp_read(struct device *dev, enum hwmon_sensor_types type, if (*val < 0) *val = 0; break; + case 2: /* Tccd1 */ + amd_smn_read(amd_pci_dev_to_node_id(data->pdev), + F17H_M70H_CCD1_TEMP, ®val); + *val = (regval & 0xfff) * 125 - 305000; + break; + case 3: /* Tccd2 */ + amd_smn_read(amd_pci_dev_to_node_id(data->pdev), + F17H_M70H_CCD2_TEMP, ®val); + *val = (regval & 0xfff) * 125 - 305000; + break; default: return -EOPNOTSUPP; } @@ -206,8 +228,24 @@ static umode_t k10temp_is_visible(const void *_data, case hwmon_temp: switch (attr) { case hwmon_temp_input: - if (channel && !data->show_tdie) + switch (channel) { + case 0: /* Tdie, or Tctl if we don't show it */ + break; + case 1: /* Tctl */ + if (!data->show_tdie) + return 0; + break; + case 2: /* Tccd1 */ + if (!data->show_tccd1) + return 0; + break; + case 3: /* Tccd2 */ + if (!data->show_tccd2) + return 0; + break; + default: return 0; + } break; case hwmon_temp_max: if (channel) @@ -229,8 +267,24 @@ static umode_t k10temp_is_visible(const void *_data, return 0; break; case hwmon_temp_label: + /* No labels if we don't show the die temperature */ if (!data->show_tdie) return 0; + switch (channel) { + case 0: /* Tdie */ + case 1: /* Tctl */ + break; + case 2: /* Tccd1 */ + if (!data->show_tccd1) + return 0; + break; + case 3: /* Tccd2 */ + if (!data->show_tccd2) + return 0; + break; + default: + return 0; + } break; default: return 0; @@ -281,6 +335,8 @@ static const struct hwmon_channel_info *k10temp_info[] = { HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_CRIT | HWMON_T_CRIT_HYST | HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL), NULL }; @@ -326,9 +382,31 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id) data->read_htcreg = read_htcreg_nb_f15; data->read_tempreg = read_tempreg_nb_f15; } else if (boot_cpu_data.x86 == 0x17 || boot_cpu_data.x86 == 0x18) { + u32 regval; + data->temp_adjust_mask = CUR_TEMP_RANGE_SEL_MASK; data->read_tempreg = read_tempreg_nb_f17; data->show_tdie = true; + + switch (boot_cpu_data.x86_model) { + case 0x1: /* Zen */ + case 0x8: /* Zen+ */ + case 0x11: /* Zen APU */ + case 0x18: /* Zen+ APU */ + break; + case 0x31: /* Zen2 Threadripper */ + case 0x71: /* Zen2 */ + amd_smn_read(amd_pci_dev_to_node_id(pdev), + F17H_M70H_CCD1_TEMP, ®val); + if (regval & 0xfff) + data->show_tccd1 = true; + + amd_smn_read(amd_pci_dev_to_node_id(pdev), + F17H_M70H_CCD2_TEMP, ®val); + if (regval & 0xfff) + data->show_tccd2 = true; + break; + } } else { data->read_htcreg = read_htcreg_pci; data->read_tempreg = read_tempreg_pci; From patchwork Tue Jan 21 02:30:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 11343047 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9802813BD for ; Tue, 21 Jan 2020 02:30:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6C75D22522 for ; Tue, 21 Jan 2020 02:30:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y1SV4NLR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729096AbgAUCaq (ORCPT ); Mon, 20 Jan 2020 21:30:46 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:33549 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729085AbgAUCap (ORCPT ); Mon, 20 Jan 2020 21:30:45 -0500 Received: by mail-pj1-f68.google.com with SMTP id u63so452779pjb.0; Mon, 20 Jan 2020 18:30:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=WBGBPvZkCWv9VV7L5miBPO2jWL4ZTKAoVpomC1UU0r8=; b=Y1SV4NLRBOAoFXDozFDYf3FKKyR67R/DS4X5fg/E7ZjW+1LXvlC1dpqmEu18e7kBzy XyucjoXU6DmldG86fF1eHPW+dfIhcZK94R1t3d6aaNp8AJ3Xv5FYnBWF3YhIClvuIkHa ofwoV+Nwh20VMz/kKpLkOo5oPw32oR0XlMjcvq3ENtWc405+yZieum+TcuFazdXSeGS7 4LoHgAyj9I6kvdN1BxiKdvUwZrbd1KuzC3c731lac9VhhhDJrXWB464YUCgVOlYD0EGW n60pIFJYdDrXq2Ca+d3NmAlcR6RcQGih7y77RXUr161VTVwzIXcqa1n8nm/NudwfvIkx oWGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=WBGBPvZkCWv9VV7L5miBPO2jWL4ZTKAoVpomC1UU0r8=; b=Yu0hieFNLc0/AArIY0n176xHAWEGTIWcs5Y3NpGFbNXg69tJfYo/9H9YB4e/i+eTVz i1QIOIcPJPAxdPTILPF+7CWlGZCUwrt99rD+5StltkivzakQ8Tlua/S9SXyO+2sTMMVx sOUTSU+VjKUfAz3U8+tTqbV0sbSW1HjfC1ogqq4Is+r8y8pyUq3PUnCG1tvG3G6W+tLi S1fGoxvMZyNf2Nk1xQ3clFvlQ9DrZ7GEkj+lSIE56bQtD725nMDI7ljXQg3qP9V5VPY4 KERRdgG13VzzZRHSo4hJFrhCt0iFIifG7cSRZgkxo4Xy0T8p0cG6ILd9bn870iRBuiOR QxBg== X-Gm-Message-State: APjAAAVOC2ikZpjjbnHB1IeqaWE7CFiOksBJl6yhKHYS715IusJgDV0g 4hdbRZTooItJeQz0zrVb4A9H+KY7 X-Google-Smtp-Source: APXvYqwPlZQB8ImO3clx6RkYjziJ7/rRb3Mzodh8bLW7e3Becq0tXXNBLp8pasINNA1JbaTW7DiYBw== X-Received: by 2002:a17:90a:1ae9:: with SMTP id p96mr2661429pjp.8.1579573844461; Mon, 20 Jan 2020 18:30:44 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b1sm801921pjw.4.2020.01.20.18.30.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Jan 2020 18:30:44 -0800 (PST) From: Guenter Roeck To: linux-hwmon@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Clemens Ladisch , Jean Delvare , Brad Campbell , =?utf-8?q?Ondrej_=C4=8Cerman?= , Bernhard Gebetsberger , Holger Kiehl , Michael Larabel , Jonathan McDowell , Ken Moffat , Sebastian Reichel , Darren Salt , Guenter Roeck Subject: [PATCH v3 4/5] hwmon: (k10temp) Show core and SoC current and voltages on Ryzen CPUs Date: Mon, 20 Jan 2020 18:30:26 -0800 Message-Id: <20200121023027.2081-5-linux@roeck-us.net> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200121023027.2081-1-linux@roeck-us.net> References: <20200121023027.2081-1-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Ryzen CPUs report core and SoC voltages and currents. Add support for it to the k10temp driver. For the time being, only report voltages and currents for Ryzen CPUs. Threadripper and EPYC appear to use a different mechanism. Tested-by: Brad Campbell Tested-by: Bernhard Gebetsberger Tested-by: Holger Kiehl Tested-by: Michael Larabel Tested-by: Jonathan McDowell Tested-by: Ken Moffat Tested-by: Darren Salt Signed-off-by: Guenter Roeck --- drivers/hwmon/k10temp.c | 128 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index 0af096b061fa..9e8b1c1bcbbd 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -11,6 +11,15 @@ * convert raw register values is from https://github.com/ocerman/zenpower. * The information is not confirmed from chip datasheets, but experiments * suggest that it provides reasonable temperature values. + * - Register addresses to read chip voltage and current is also from + * https://github.com/ocerman/zenpower, and not confirmed from chip + * datasheets. Experiments suggest that reported current and voltage + * information is reasonable. + * - It is unknown if the mechanism to read CCD1/CCD2 temperature as well as + * current and voltage information works on higher-end Ryzen CPUs. + * Information reported by Windows tools suggests that additional sensors + * (both temperature and voltage/current) are supported, but their register + * location is currently unknown. */ #include @@ -70,6 +79,10 @@ static DEFINE_MUTEX(nb_smu_ind_mutex); #define F17H_M70H_CCD1_TEMP 0x00059954 #define F17H_M70H_CCD2_TEMP 0x00059958 +#define F17H_M01H_SVI 0x0005A000 +#define F17H_M01H_SVI_TEL_PLANE0 (F17H_M01H_SVI + 0xc) +#define F17H_M01H_SVI_TEL_PLANE1 (F17H_M01H_SVI + 0x10) + #define CUR_TEMP_SHIFT 21 #define CUR_TEMP_RANGE_SEL_MASK BIT(19) @@ -82,6 +95,9 @@ struct k10temp_data { bool show_tdie; bool show_tccd1; bool show_tccd2; + u32 svi_addr[2]; + bool show_current; + int cfactor[2]; }; struct tctl_offset { @@ -99,6 +115,16 @@ static const struct tctl_offset tctl_offset_table[] = { { 0x17, "AMD Ryzen Threadripper 29", 27000 }, /* 29{20,50,70,90}[W]X */ }; +static bool is_threadripper(void) +{ + return strstr(boot_cpu_data.x86_model_id, "Threadripper"); +} + +static bool is_epyc(void) +{ + return strstr(boot_cpu_data.x86_model_id, "EPYC"); +} + static void read_htcreg_pci(struct pci_dev *pdev, u32 *regval) { pci_read_config_dword(pdev, REG_HARDWARE_THERMAL_CONTROL, regval); @@ -157,16 +183,76 @@ const char *k10temp_temp_label[] = { "Tccd2", }; +const char *k10temp_in_label[] = { + "Vcore", + "Vsoc", +}; + +const char *k10temp_curr_label[] = { + "Icore", + "Isoc", +}; + static int k10temp_read_labels(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, const char **str) { - *str = k10temp_temp_label[channel]; + switch (type) { + case hwmon_temp: + *str = k10temp_temp_label[channel]; + break; + case hwmon_in: + *str = k10temp_in_label[channel]; + break; + case hwmon_curr: + *str = k10temp_curr_label[channel]; + break; + default: + return -EOPNOTSUPP; + } return 0; } -static int k10temp_read(struct device *dev, enum hwmon_sensor_types type, - u32 attr, int channel, long *val) +static int k10temp_read_curr(struct device *dev, u32 attr, int channel, + long *val) +{ + struct k10temp_data *data = dev_get_drvdata(dev); + u32 regval; + + switch (attr) { + case hwmon_curr_input: + amd_smn_read(amd_pci_dev_to_node_id(data->pdev), + data->svi_addr[channel], ®val); + *val = DIV_ROUND_CLOSEST(data->cfactor[channel] * + (regval & 0xff), + 1000); + break; + default: + return -EOPNOTSUPP; + } + return 0; +} + +static int k10temp_read_in(struct device *dev, u32 attr, int channel, long *val) +{ + struct k10temp_data *data = dev_get_drvdata(dev); + u32 regval; + + switch (attr) { + case hwmon_in_input: + amd_smn_read(amd_pci_dev_to_node_id(data->pdev), + data->svi_addr[channel], ®val); + regval = (regval >> 16) & 0xff; + *val = DIV_ROUND_CLOSEST(155000 - regval * 625, 100); + break; + default: + return -EOPNOTSUPP; + } + return 0; +} + +static int k10temp_read_temp(struct device *dev, u32 attr, int channel, + long *val) { struct k10temp_data *data = dev_get_drvdata(dev); u32 regval; @@ -216,6 +302,21 @@ static int k10temp_read(struct device *dev, enum hwmon_sensor_types type, return 0; } +static int k10temp_read(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long *val) +{ + switch (type) { + case hwmon_temp: + return k10temp_read_temp(dev, attr, channel, val); + case hwmon_in: + return k10temp_read_in(dev, attr, channel, val); + case hwmon_curr: + return k10temp_read_curr(dev, attr, channel, val); + default: + return -EOPNOTSUPP; + } +} + static umode_t k10temp_is_visible(const void *_data, enum hwmon_sensor_types type, u32 attr, int channel) @@ -290,6 +391,11 @@ static umode_t k10temp_is_visible(const void *_data, return 0; } break; + case hwmon_in: + case hwmon_curr: + if (!data->show_current) + return 0; + break; default: return 0; } @@ -338,6 +444,12 @@ static const struct hwmon_channel_info *k10temp_info[] = { HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL), + HWMON_CHANNEL_INFO(in, + HWMON_I_INPUT | HWMON_I_LABEL, + HWMON_I_INPUT | HWMON_I_LABEL), + HWMON_CHANNEL_INFO(curr, + HWMON_C_INPUT | HWMON_C_LABEL, + HWMON_C_INPUT | HWMON_C_LABEL), NULL }; @@ -393,9 +505,19 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id) case 0x8: /* Zen+ */ case 0x11: /* Zen APU */ case 0x18: /* Zen+ APU */ + data->show_current = !is_threadripper() && !is_epyc(); + data->svi_addr[0] = F17H_M01H_SVI_TEL_PLANE0; + data->svi_addr[1] = F17H_M01H_SVI_TEL_PLANE1; + data->cfactor[0] = 1039211; /* core */ + data->cfactor[1] = 360772; /* SoC */ break; case 0x31: /* Zen2 Threadripper */ case 0x71: /* Zen2 */ + data->show_current = !is_threadripper() && !is_epyc(); + data->cfactor[0] = 658823; /* core */ + data->cfactor[1] = 294300; /* SoC */ + data->svi_addr[0] = F17H_M01H_SVI_TEL_PLANE1; + data->svi_addr[1] = F17H_M01H_SVI_TEL_PLANE0; amd_smn_read(amd_pci_dev_to_node_id(pdev), F17H_M70H_CCD1_TEMP, ®val); if (regval & 0xfff) From patchwork Tue Jan 21 02:30:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 11343049 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2E6A13BD for ; Tue, 21 Jan 2020 02:30:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A139724656 for ; Tue, 21 Jan 2020 02:30:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eBPXNp3S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729085AbgAUCat (ORCPT ); Mon, 20 Jan 2020 21:30:49 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35735 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726890AbgAUCaq (ORCPT ); Mon, 20 Jan 2020 21:30:46 -0500 Received: by mail-pf1-f196.google.com with SMTP id i23so682302pfo.2; Mon, 20 Jan 2020 18:30:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=15Ev+vhTYmEGrxqjsxkzwNHnzWlaEO3FV3/3cfAruV8=; b=eBPXNp3S203JS4dGarOV3mfwZ6vV2RF8OYLGYHZYIlw19Fkn3LZdHSfQo4gUqqb0Uj TDkkhge6Cd5/mSOw/p23s0c7ZCzp9PYOJm5/OiO0yUGwmttr5X0VRRC6Z2KboyXj9QX7 wUnBQruiZT03frAsBZtfpJf5wN2qnyVapXXBa0MlRWAzrJ8OFEyg9Q7oUyNsA5zO6TxM U5R9zrE3Av34TzLgUIgPliezWPVg1yPOBvEHvx+WeF19WrnNM7U9Ea1coQ6u2MIDbpE/ nKcHhGi5z/K7lS725x5NfAizb8hgS9geLKrsCV/OhYMKM1Z5pwZJMgGWQt3ajA6LTQTA QqJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=15Ev+vhTYmEGrxqjsxkzwNHnzWlaEO3FV3/3cfAruV8=; b=EQqWlhRfcr5JstVyEuliFM4++yME22B1LPUcxMQ6EwCUlO7RpYXZEprPhefzuw/vcv YZTJEO7994xQp3Z0dwdw7d0DwWl3AMQD+TM05p1cdzgMgKc0ynOHrMahWPwuEwfLUzk9 1ifffgcdMLStfN8lh+dPUesooBP0tpli3a+Yp2snH28GX7PgOJOppbam2Zu5vx0z+eaW J/NmNgo5mEgPkM2O6fiGis/N0exwvkmPYFSaxlqDFssN0sc58dPiRJBTN4idfgzC8LvQ WsBdaVuLY18cm7LdXLmCTksI0ZuhKL9PiEzMH2m977+YJCx+1hIOP4Tf1+uRMzdju1iJ yaBA== X-Gm-Message-State: APjAAAV4FWVPVUg6FET5R+BEluPGbG22/mSgEU9K9HwiN+PFcBhTtQLj AQxgpXmHP/gCSsOgOR0SPIJtfbjr X-Google-Smtp-Source: APXvYqzvaq+qKUe1377GVvmrk9hGDVCMRXbBlCMFtDcES3exf/pfY7RNXElmdI3YrvQmLgTWpQIa9g== X-Received: by 2002:a63:9d4e:: with SMTP id i75mr2855098pgd.231.1579573845746; Mon, 20 Jan 2020 18:30:45 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e1sm41055426pfl.98.2020.01.20.18.30.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Jan 2020 18:30:45 -0800 (PST) From: Guenter Roeck To: linux-hwmon@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Clemens Ladisch , Jean Delvare , Brad Campbell , =?utf-8?q?Ondrej_=C4=8Cerman?= , Bernhard Gebetsberger , Holger Kiehl , Michael Larabel , Jonathan McDowell , Ken Moffat , Sebastian Reichel , Darren Salt , Guenter Roeck Subject: [PATCH v3 5/5] hwmon: (k10temp) Don't show temperature limits on Ryzen (Zen) CPUs Date: Mon, 20 Jan 2020 18:30:27 -0800 Message-Id: <20200121023027.2081-6-linux@roeck-us.net> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200121023027.2081-1-linux@roeck-us.net> References: <20200121023027.2081-1-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org The maximum Tdie or Tctl is not published for Ryzen CPUs. What is known, however, is that the traditional value of 70 degrees C is no longer correct. Displaying it is meaningless, confusing, and wrong. Stop doing it. Tested-by: Brad Campbell Tested-by: Holger Kiehl Tested-by: Michael Larabel Tested-by: Jonathan McDowell Tested-by: Ken Moffat Signed-off-by: Guenter Roeck --- drivers/hwmon/k10temp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index 9e8b1c1bcbbd..6076a84cb3ae 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -349,7 +349,7 @@ static umode_t k10temp_is_visible(const void *_data, } break; case hwmon_temp_max: - if (channel) + if (channel || data->show_tdie) return 0; break; case hwmon_temp_crit: