Skip to content

Commit c2c8ab1

Browse files
committed
Merge branches 'thermal-core' and 'thermal-intel' into linux-next
* thermal-core: thermal: sysfs: Use str_enabled_disabled() helper in mode_show() thermal: core: Replace sprintf() in thermal_bind_cdev_to_trip() * thermal-intel: thermal: intel: int340x: Read DDR data rate for Nova Lake
3 parents bf9591a + 2dc1b0d + 6d3e2ce commit c2c8ab1

3 files changed

Lines changed: 24 additions & 10 deletions

File tree

drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,17 +402,31 @@ static ssize_t rfi_restriction_show(struct device *dev,
402402
return sysfs_emit(buf, "%llu\n", resp);
403403
}
404404

405+
/* ddr_data_rate */
406+
static const struct mmio_reg nvl_ddr_data_rate_reg = { 1, 0xE0, 10, 0x3FF, 2};
407+
408+
static const struct mmio_reg *ddr_data_rate_reg;
409+
405410
static ssize_t ddr_data_rate_show(struct device *dev,
406411
struct device_attribute *attr,
407412
char *buf)
408413
{
409-
u16 id = 0x0107;
410414
u64 resp;
411-
int ret;
412415

413-
ret = processor_thermal_send_mbox_read_cmd(to_pci_dev(dev), id, &resp);
414-
if (ret)
415-
return ret;
416+
if (ddr_data_rate_reg) {
417+
u16 reg_val;
418+
419+
pci_read_config_word(to_pci_dev(dev), ddr_data_rate_reg->offset, &reg_val);
420+
resp = (reg_val >> ddr_data_rate_reg->shift) & ddr_data_rate_reg->mask;
421+
resp = (resp * 3333) / 100;
422+
} else {
423+
const u16 id = 0x0107;
424+
int ret;
425+
426+
ret = processor_thermal_send_mbox_read_cmd(to_pci_dev(dev), id, &resp);
427+
if (ret)
428+
return ret;
429+
}
416430

417431
return sysfs_emit(buf, "%llu\n", resp);
418432
}
@@ -461,6 +475,7 @@ int proc_thermal_rfim_add(struct pci_dev *pdev, struct proc_thermal_device *proc
461475
case PCI_DEVICE_ID_INTEL_NVL_H_THERMAL:
462476
case PCI_DEVICE_ID_INTEL_NVL_S_THERMAL:
463477
dlvr_mmio_regs_table = nvl_dlvr_mmio_regs;
478+
ddr_data_rate_reg = &nvl_ddr_data_rate_reg;
464479
break;
465480
default:
466481
dlvr_mmio_regs_table = dlvr_mmio_regs;

drivers/thermal/thermal_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ static int thermal_bind_cdev_to_trip(struct thermal_zone_device *tz,
861861
goto free_mem;
862862

863863
dev->id = result;
864-
sprintf(dev->name, "cdev%d", dev->id);
864+
snprintf(dev->name, sizeof(dev->name), "cdev%d", dev->id);
865865
result =
866866
sysfs_create_link(&tz->device.kobj, &cdev->device.kobj, dev->name);
867867
if (result)

drivers/thermal/thermal_sysfs.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/err.h>
1919
#include <linux/slab.h>
2020
#include <linux/string.h>
21+
#include <linux/string_choices.h>
2122
#include <linux/jiffies.h>
2223

2324
#include "thermal_core.h"
@@ -56,10 +57,8 @@ mode_show(struct device *dev, struct device_attribute *attr, char *buf)
5657

5758
guard(thermal_zone)(tz);
5859

59-
if (tz->mode == THERMAL_DEVICE_ENABLED)
60-
return sysfs_emit(buf, "enabled\n");
61-
62-
return sysfs_emit(buf, "disabled\n");
60+
return sysfs_emit(buf, "%s\n",
61+
str_enabled_disabled(tz->mode == THERMAL_DEVICE_ENABLED));
6362
}
6463

6564
static ssize_t

0 commit comments

Comments
 (0)