Skip to content

Commit 82be725

Browse files
committed
hwmon: (k10temp) Enable AMD3255 Proc to show negative temperature
JIRA: https://issues.redhat.com/browse/RHEL-104300 commit e146503 Author: Baskaran Kannan <Baski.Kannan@amd.com> Date: Thu Jul 27 11:21:59 2023 -0500 hwmon: (k10temp) Enable AMD3255 Proc to show negative temperature Industrial processor i3255 supports temperatures -40 deg celcius to 105 deg Celcius. The current implementation of k10temp_read_temp rounds off any negative temperatures to '0'. To fix this, the following changes have been made. A flag 'disp_negative' is added to struct k10temp_data to support AMD i3255 processors. Flag 'disp_negative' is set if 3255 processor is found during k10temp_probe. Flag 'disp_negative' is used to determine whether to round off negative temperatures to '0' in k10temp_read_temp. Signed-off-by: Baskaran Kannan <Baski.Kannan@amd.com> Link: https://lore.kernel.org/r/20230727162159.1056136-1-Baski.Kannan@amd.com Fixes: aef17ca ("hwmon: (k10temp) Only apply temperature offset if result is positive") Cc: stable@vger.kernel.org [groeck: Fixed multi-line comment] Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: David Arcari <darcari@redhat.com>
1 parent f197184 commit 82be725

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

drivers/hwmon/k10temp.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ static DEFINE_MUTEX(nb_smu_ind_mutex);
7777
#define ZEN_CUR_TEMP_RANGE_SEL_MASK BIT(19)
7878
#define ZEN_CUR_TEMP_TJ_SEL_MASK GENMASK(17, 16)
7979

80+
/*
81+
* AMD's Industrial processor 3255 supports temperature from -40 deg to 105 deg Celsius.
82+
* Use the model name to identify 3255 CPUs and set a flag to display negative temperature.
83+
* Do not round off to zero for negative Tctl or Tdie values if the flag is set
84+
*/
85+
#define AMD_I3255_STR "3255"
86+
8087
struct k10temp_data {
8188
struct pci_dev *pdev;
8289
void (*read_htcreg)(struct pci_dev *pdev, u32 *regval);
@@ -86,6 +93,7 @@ struct k10temp_data {
8693
u32 show_temp;
8794
bool is_zen;
8895
u32 ccd_offset;
96+
bool disp_negative;
8997
};
9098

9199
#define TCTL_BIT 0
@@ -211,12 +219,12 @@ static int k10temp_read_temp(struct device *dev, u32 attr, int channel,
211219
switch (channel) {
212220
case 0: /* Tctl */
213221
*val = get_raw_temp(data);
214-
if (*val < 0)
222+
if (*val < 0 && !data->disp_negative)
215223
*val = 0;
216224
break;
217225
case 1: /* Tdie */
218226
*val = get_raw_temp(data) - data->temp_offset;
219-
if (*val < 0)
227+
if (*val < 0 && !data->disp_negative)
220228
*val = 0;
221229
break;
222230
case 2 ... 13: /* Tccd{1-12} */
@@ -428,6 +436,11 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
428436
data->pdev = pdev;
429437
data->show_temp |= BIT(TCTL_BIT); /* Always show Tctl */
430438

439+
if (boot_cpu_data.x86 == 0x17 &&
440+
strstr(boot_cpu_data.x86_model_id, AMD_I3255_STR)) {
441+
data->disp_negative = true;
442+
}
443+
431444
if (boot_cpu_data.x86 == 0x15 &&
432445
((boot_cpu_data.x86_model & 0xf0) == 0x60 ||
433446
(boot_cpu_data.x86_model & 0xf0) == 0x70)) {

0 commit comments

Comments
 (0)