Skip to contentSkip to conversation

Enable AMD3255 Proc to show negative temperature

PATCH Superseded Baskaran Kannan 3 participants 4 messages Jun 10, 2023 1 message not in the archive

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Enable AMD3255 Proc to show negative temperature

From: Baskaran Kannan <[email protected]>

---
 drivers/hwmon/k10temp.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/hwmon/k10temp.c +18 -0
index 489ad0b1bc74..a79aac0596e5 100644
@@ -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)) {
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 3 lines · Baskaran Kannan

From: Baskaran Kannan <[email protected]>

Please resubmit and either make the changes you were asked to make, or explain why you did not follow them.

Guenter

Quoted 57 lines
---
  drivers/hwmon/k10temp.c | 18 ++++++++++++++++++
  1 file changed, 18 insertions(+)
drivers/hwmon/k10temp.c +18 -0
index 489ad0b1bc74..a79aac0596e5 100644
@@ -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)) {

A message that is not in the archive (sent off-list or not yet received): CY5PR12MB6432BF5EE9EAA15750FE4D778456A@CY5PR12MB6432.namprd12.prod.outlook.com

maintainer
#3 lore raw
Quoted 6 lines · Baski

[AMD Official Use Only - General]

Hmm.. Somehow the commit message was not included in the signoff email. Checking now.
Sorry for the spam.

That is not the only change you were asked to make. Commit description, version, change log, unnecessary (), direct use of boolean instead of comparing it against false, unnecessary {}, missing space between ( and { is just what comes into mind immediately.

Oh, and also:

The subject needs to be "hwmon: (k10temp) Enable AMD3255 Processor to show negative temperature" or similar.

Guenter

Quoted 19 lines

-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of Guenter Roeck
Sent: Saturday, June 10, 2023 3:59 PM
To: Kannan, Baski <[email protected]>; Limonciello, Mario <[email protected]>; Moger, Babu <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: Kannan, Baski <[email protected]>
Subject: Re: [PATCH] Enable AMD3255 Proc to show negative temperature

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 3 lines · Baskaran Kannan

From: Baskaran Kannan <[email protected]>

Please resubmit and either make the changes you were asked to make, or explain why you did not follow them.

Guenter

#4 lore raw
In reply to Guenter Roeck
Quoted 8 lines · Guenter Roeck
Quoted 3 lines · Baskaran Kannan

From: Baskaran Kannan <[email protected]>

Please resubmit and either make the changes you were asked to make, or explain why you did not follow them.

I don't know if anyone asked you to change the Subject: line, but you should look at the output of

$ git log  --oneline dirvers/hwmon/

to see appropriate Subject: lines.

thanks.

Signature · 1 line
~Randy