lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230610205357.5658-1-Baski.Kannan@amd.com>
Date:   Sat, 10 Jun 2023 15:53:57 -0500
From:   Baskaran Kannan <Baski.Kannan@....com>
To:     <Mario.Limonciello@....com>, <babu.moger@....com>,
        <baski.kannan@....com>, <clemens@...isch.de>, <jdelvare@...e.com>,
        <linux@...ck-us.net>, <linux-hwmon@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
CC:     Baskaran Kannan <bakannan@....com>,
        Baskaran Kannan <Baski.Kannan@....com>
Subject: [PATCH] Enable AMD3255 Proc to show negative temperature

From: Baskaran Kannan <bakannan@....com>

Signed-off-by: Baskaran Kannan <Baski.Kannan@....com>
---
 drivers/hwmon/k10temp.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c
index 489ad0b1bc74..a79aac0596e5 100644
--- a/drivers/hwmon/k10temp.c
+++ b/drivers/hwmon/k10temp.c
@@ -77,6 +77,12 @@ static DEFINE_MUTEX(nb_smu_ind_mutex);
 #define ZEN_CUR_TEMP_RANGE_SEL_MASK		BIT(19)
 #define ZEN_CUR_TEMP_TJ_SEL_MASK		GENMASK(17, 16)
 
+/* 
+ * AMD's Industrial processor 3255 supports temperature from -40 deg to 105 deg Celsius.
+ * Do not round off to zero for negative Tctl or Tdie values.
+ */
+#define AMD_I3255_STR				"3255"
+
 struct k10temp_data {
 	struct pci_dev *pdev;
 	void (*read_htcreg)(struct pci_dev *pdev, u32 *regval);
@@ -86,6 +92,7 @@ struct k10temp_data {
 	u32 show_temp;
 	bool is_zen;
 	u32 ccd_offset;
+	bool disp_negative; /*Flag set for AMD i3255. Family 17h, Model 0x0-0xf */
 };
 
 #define TCTL_BIT	0
@@ -204,9 +211,15 @@ static int k10temp_read_temp(struct device *dev, u32 attr, int channel,
 		switch (channel) {
 		case 0:		/* Tctl */
 			*val = get_raw_temp(data);
+			if (*val < 0 && (data->disp_negative == false) ){
+				*val = 0;
+			}
 			break;
 		case 1:		/* Tdie */
 			*val = get_raw_temp(data) - data->temp_offset;
+			if (*val < 0 && (data->disp_negative == false) ){
+				*val = 0;
+			}
 			break;
 		case 2 ... 13:		/* Tccd{1-12} */
 			amd_smn_read(amd_pci_dev_to_node_id(data->pdev),
@@ -401,6 +414,11 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	data->pdev = pdev;
 	data->show_temp |= BIT(TCTL_BIT);	/* Always show Tctl */
 
+	if (boot_cpu_data.x86 == 0x17 &&
+		strstr(boot_cpu_data.x86_model_id, AMD_I3255_STR)) {
+		data->disp_negative = true;
+	}
+
 	if (boot_cpu_data.x86 == 0x15 &&
 	    ((boot_cpu_data.x86_model & 0xf0) == 0x60 ||
 	     (boot_cpu_data.x86_model & 0xf0) == 0x70)) {
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ