linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: (k10temp): Check range scale when CUR_TEMP register is read-write
@ 2023-04-13 21:39 Babu Moger
  2023-04-16 14:35 ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: Babu Moger @ 2023-04-13 21:39 UTC (permalink / raw)
  To: clemens, jdelvare, linux
  Cc: linux-hwmon, linux-kernel, babu.moger, Baski.Kannan, yannick.hemery

From: Babu Moger <Babu.Moger@amd.com>

Spec says, when CUR_TEMP_TJ_SEL == 3 and CUR_TEMP_RANGE_SEL == 0,
it should use RangeUnadjusted is 0, which is (CurTmp*0.125 -49) C. The
CUR_TEMP register is read-write when CUR_TEMP_TJ_SEL == 3 (bit 17-16).

Add the check to detect it.

Sensors command's output before the patch.
$sensors
 k10temp-pci-00c3
 Adapter: PCI adapter
 Tctl:         +76.6°C <- Wrong value
 Tccd1:        +26.5°C
 Tccd2:        +27.5°C
 Tccd3:        +27.2°C
 Tccd4:        +27.5°C
 Tccd5:        +26.0°C
 Tccd6:        +26.2°C
 Tccd7:        +25.0°C
 Tccd8:        +26.5°C

Sensors command's output after the patch.
$sensors
 k10temp-pci-00c3
 Adapter: PCI adapter
 Tctl:         +28.8°C <- corrected value
 Tccd1:        +27.5°C
 Tccd2:        +28.5°C
 Tccd3:        +28.5°C
 Tccd4:        +28.5°C
 Tccd5:        +27.0°C
 Tccd6:        +27.5°C
 Tccd7:        +27.0°C
 Tccd8:        +27.5°C

Signed-off-by: Babu Moger <babu.moger@amd.com>
---
 drivers/hwmon/k10temp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c
index 5a9d47a229e4..be8bbb1c3a02 100644
--- a/drivers/hwmon/k10temp.c
+++ b/drivers/hwmon/k10temp.c
@@ -75,6 +75,7 @@ static DEFINE_MUTEX(nb_smu_ind_mutex);
 
 #define ZEN_CUR_TEMP_SHIFT			21
 #define ZEN_CUR_TEMP_RANGE_SEL_MASK		BIT(19)
+#define ZEN_CUR_TEMP_TJ_SEL_MASK		GENMASK(17, 16)
 
 struct k10temp_data {
 	struct pci_dev *pdev;
@@ -155,7 +156,8 @@ static long get_raw_temp(struct k10temp_data *data)
 
 	data->read_tempreg(data->pdev, &regval);
 	temp = (regval >> ZEN_CUR_TEMP_SHIFT) * 125;
-	if (regval & data->temp_adjust_mask)
+	if ((regval & data->temp_adjust_mask) ||
+	    (regval & ZEN_CUR_TEMP_TJ_SEL_MASK) == ZEN_CUR_TEMP_TJ_SEL_MASK)
 		temp -= 49000;
 	return temp;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] hwmon: (k10temp): Check range scale when CUR_TEMP register is read-write
  2023-04-13 21:39 [PATCH] hwmon: (k10temp): Check range scale when CUR_TEMP register is read-write Babu Moger
@ 2023-04-16 14:35 ` Guenter Roeck
  2023-04-17 14:00   ` Moger, Babu
  0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2023-04-16 14:35 UTC (permalink / raw)
  To: Babu Moger
  Cc: clemens, jdelvare, linux-hwmon, linux-kernel, Baski.Kannan,
	yannick.hemery

On Thu, Apr 13, 2023 at 04:39:58PM -0500, Babu Moger wrote:
> From: Babu Moger <Babu.Moger@amd.com>
> 
> Spec says, when CUR_TEMP_TJ_SEL == 3 and CUR_TEMP_RANGE_SEL == 0,
> it should use RangeUnadjusted is 0, which is (CurTmp*0.125 -49) C. The
> CUR_TEMP register is read-write when CUR_TEMP_TJ_SEL == 3 (bit 17-16).
> 
> Add the check to detect it.
> 
> Sensors command's output before the patch.
> $sensors
>  k10temp-pci-00c3
>  Adapter: PCI adapter
>  Tctl:         +76.6°C <- Wrong value
>  Tccd1:        +26.5°C
>  Tccd2:        +27.5°C
>  Tccd3:        +27.2°C
>  Tccd4:        +27.5°C
>  Tccd5:        +26.0°C
>  Tccd6:        +26.2°C
>  Tccd7:        +25.0°C
>  Tccd8:        +26.5°C
> 
> Sensors command's output after the patch.
> $sensors
>  k10temp-pci-00c3
>  Adapter: PCI adapter
>  Tctl:         +28.8°C <- corrected value
>  Tccd1:        +27.5°C
>  Tccd2:        +28.5°C
>  Tccd3:        +28.5°C
>  Tccd4:        +28.5°C
>  Tccd5:        +27.0°C
>  Tccd6:        +27.5°C
>  Tccd7:        +27.0°C
>  Tccd8:        +27.5°C
> 
> Signed-off-by: Babu Moger <babu.moger@amd.com>

Applied. Please update your e-mail address configuration to avoid the
following checkpatch message.

CHECK: From:/Signed-off-by: email comments mismatch: 'From: Babu Moger <Babu.Moger@amd.com>' != 'Signed-off-by: Babu Moger <babu.moger@amd.com>'

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] hwmon: (k10temp): Check range scale when CUR_TEMP register is read-write
  2023-04-16 14:35 ` Guenter Roeck
@ 2023-04-17 14:00   ` Moger, Babu
  0 siblings, 0 replies; 3+ messages in thread
From: Moger, Babu @ 2023-04-17 14:00 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: clemens, jdelvare, linux-hwmon, linux-kernel, Baski.Kannan,
	yannick.hemery



On 4/16/23 09:35, Guenter Roeck wrote:
> On Thu, Apr 13, 2023 at 04:39:58PM -0500, Babu Moger wrote:
>> From: Babu Moger <Babu.Moger@amd.com>
>>
>> Spec says, when CUR_TEMP_TJ_SEL == 3 and CUR_TEMP_RANGE_SEL == 0,
>> it should use RangeUnadjusted is 0, which is (CurTmp*0.125 -49) C. The
>> CUR_TEMP register is read-write when CUR_TEMP_TJ_SEL == 3 (bit 17-16).
>>
>> Add the check to detect it.
>>
>> Sensors command's output before the patch.
>> $sensors
>>  k10temp-pci-00c3
>>  Adapter: PCI adapter
>>  Tctl:         +76.6°C <- Wrong value
>>  Tccd1:        +26.5°C
>>  Tccd2:        +27.5°C
>>  Tccd3:        +27.2°C
>>  Tccd4:        +27.5°C
>>  Tccd5:        +26.0°C
>>  Tccd6:        +26.2°C
>>  Tccd7:        +25.0°C
>>  Tccd8:        +26.5°C
>>
>> Sensors command's output after the patch.
>> $sensors
>>  k10temp-pci-00c3
>>  Adapter: PCI adapter
>>  Tctl:         +28.8°C <- corrected value
>>  Tccd1:        +27.5°C
>>  Tccd2:        +28.5°C
>>  Tccd3:        +28.5°C
>>  Tccd4:        +28.5°C
>>  Tccd5:        +27.0°C
>>  Tccd6:        +27.5°C
>>  Tccd7:        +27.0°C
>>  Tccd8:        +27.5°C
>>
>> Signed-off-by: Babu Moger <babu.moger@amd.com>
> 
> Applied. Please update your e-mail address configuration to avoid the
> following checkpatch message.
Thank you.

> 
> CHECK: From:/Signed-off-by: email comments mismatch: 'From: Babu Moger <Babu.Moger@amd.com>' != 'Signed-off-by: Babu Moger <babu.moger@amd.com>'

Sure. Will update.

> 
> Thanks,
> Guenter

-- 
Thanks
Babu Moger

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-17 14:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13 21:39 [PATCH] hwmon: (k10temp): Check range scale when CUR_TEMP register is read-write Babu Moger
2023-04-16 14:35 ` Guenter Roeck
2023-04-17 14:00   ` Moger, Babu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).