Skip to contentSkip to conversation

thermal: intel: int340x: Read DDR data rate for Nova Lake

PATCH Applied Srinivas Pandruvada 2 participants 3 messages Feb 23 – Mar 9 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: intel: int340x: Read DDR data rate for Nova Lake

Add support for reading DDR data rate from PCI config offset. The register details are:
CFG Offset : 0xE0
Bits : 11:2

DDR Data rate is in 33.33 MTPS units.

---
 .../int340x_thermal/processor_thermal_rfim.c     | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c +16 -0
index 314fbc1f490f..2e834a175471 100644
@@ -402,6 +402,11 @@ static ssize_t rfi_restriction_show(struct device *dev,
 	return sysfs_emit(buf, "%llu\n", resp);
 }
 
+ /* ddr_data_rate */
+static const struct mmio_reg nvl_ddr_data_rate_reg = { 1, 0xE0, 10, 0x3FF, 2};
+
+static const struct mmio_reg *ddr_data_rate_reg;
+
 static ssize_t ddr_data_rate_show(struct device *dev,
 				  struct device_attribute *attr,
 				  char *buf)
@@ -410,10 +415,20 @@ static ssize_t ddr_data_rate_show(struct device *dev,
 	u64 resp;
 	int ret;
 
+	if (ddr_data_rate_reg) {
+		u16 reg_val;
+
+		pci_read_config_word(to_pci_dev(dev), ddr_data_rate_reg->offset, &reg_val);
+		resp = (reg_val >> ddr_data_rate_reg->shift) & ddr_data_rate_reg->mask;
+		resp = (resp * 3333) / 100;
+		goto ret_resp;
+	}
+
 	ret = processor_thermal_send_mbox_read_cmd(to_pci_dev(dev), id, &resp);
 	if (ret)
 		return ret;
 
+ret_resp:
 	return sysfs_emit(buf, "%llu\n", resp);
 }
 
@@ -461,6 +476,7 @@ int proc_thermal_rfim_add(struct pci_dev *pdev, struct proc_thermal_device *proc
 		case PCI_DEVICE_ID_INTEL_NVL_H_THERMAL:
 		case PCI_DEVICE_ID_INTEL_NVL_S_THERMAL:
 			dlvr_mmio_regs_table = nvl_dlvr_mmio_regs;
+			ddr_data_rate_reg = &nvl_ddr_data_rate_reg;
 			break;
 		default:
 			dlvr_mmio_regs_table = dlvr_mmio_regs;
Signature · 1 line
2.52.0
maintainer Applied
#1 lore raw
Quoted 51 lines · Srinivas Pandruvada

Add support for reading DDR data rate from PCI config offset. The register details are:
CFG Offset : 0xE0
Bits : 11:2

DDR Data rate is in 33.33 MTPS units.

---
 .../int340x_thermal/processor_thermal_rfim.c     | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c +15 -0
index 314fbc1f490f..2e834a175471 100644
@@ -402,6 +402,11 @@ static ssize_t rfi_restriction_show(struct device *dev,
        return sysfs_emit(buf, "%llu\n", resp);
 }
 
+ /* ddr_data_rate */
+static const struct mmio_reg nvl_ddr_data_rate_reg = { 1, 0xE0, 10, 0x3FF, 2};
+
+static const struct mmio_reg *ddr_data_rate_reg;
+
 static ssize_t ddr_data_rate_show(struct device *dev,
                                  struct device_attribute *attr,
                                  char *buf)
@@ -410,10 +415,20 @@ static ssize_t ddr_data_rate_show(struct device *dev,
        u64 resp;
        int ret;
 
+       if (ddr_data_rate_reg) {
+               u16 reg_val;
+
+               pci_read_config_word(to_pci_dev(dev), ddr_data_rate_reg->offset, &reg_val);
+               resp = (reg_val >> ddr_data_rate_reg->shift) & ddr_data_rate_reg->mask;
+               resp = (resp * 3333) / 100;
+               goto ret_resp;
+       }
+
        ret = processor_thermal_send_mbox_read_cmd(to_pci_dev(dev), id, &resp);
        if (ret)
                return ret;
 
+ret_resp:
        return sysfs_emit(buf, "%llu\n", resp);
 }
 

drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c int proc_thermal_rfim_add(struct pci_dev *pdev, struct proc_thermal_device *proc

Quoted 8 lines
drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c +1 -1
@@ -461,6 +476,7 @@ int proc_thermal_rfim_add(struct pci_dev *pdev, struct proc_thermal_device *proc
                case PCI_DEVICE_ID_INTEL_NVL_H_THERMAL:
                case PCI_DEVICE_ID_INTEL_NVL_S_THERMAL:
                        dlvr_mmio_regs_table = nvl_dlvr_mmio_regs;
+                       ddr_data_rate_reg = &nvl_ddr_data_rate_reg;
                        break;
                default:
                        dlvr_mmio_regs_table = dlvr_mmio_regs;
--

Applied as 7.1 material, but I rearranged it to avoid using goto and declare local vars where they are needed, please see:

https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/patch/?id=6d3e2ce6f10107c2e5870e9dce7c2e1d03a6be72

#2 lore raw
Quoted 64 lines · Rafael J. Wysocki
Quoted 62 lines · Srinivas Pandruvada

Add support for reading DDR data rate from PCI config offset. The register details are:
CFG Offset : 0xE0
Bits       : 11:2

DDR Data rate is in 33.33 MTPS units.

Signed-off-by: Srinivas Pandruvada <[email protected]>
---
 .../int340x_thermal/processor_thermal_rfim.c     | 16
++++++++++++++++

 1 file changed, 16 insertions(+)

diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c index 314fbc1f490f..2e834a175471 100644
---
a/drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c
+++
b/drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c

drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c +5 -0
@@ -402,6 +402,11 @@ static ssize_t rfi_restriction_show(struct
 device *dev,
         return sysfs_emit(buf, "%llu\n", resp);
  }
 
+ /* ddr_data_rate */
+static const struct mmio_reg nvl_ddr_data_rate_reg = { 1, 0xE0,
 10, 0x3FF, 2};
+
+static const struct mmio_reg *ddr_data_rate_reg;
+
  static ssize_t ddr_data_rate_show(struct device *dev,

                                  struct device_attribute *attr, char *buf)

drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c +10 -0
@@ -410,10 +415,20 @@ static ssize_t ddr_data_rate_show(struct
 device *dev,
         u64 resp;
         int ret;
 
+       if (ddr_data_rate_reg) {
+               u16 reg_val;
+
+               pci_read_config_word(to_pci_dev(dev),
 ddr_data_rate_reg->offset, &reg_val);
+               resp = (reg_val >> ddr_data_rate_reg->shift) &
 ddr_data_rate_reg->mask;
+               resp = (resp * 3333) / 100;
+               goto ret_resp;
+       }
+
         ret = processor_thermal_send_mbox_read_cmd(to_pci_dev(dev),
 id, &resp);
         if (ret)
                 return ret;
 
+ret_resp:

        return sysfs_emit(buf, "%llu\n", resp);
 }

Quoted 13 lines
Quoted 10 lines
(quoted diff) +0 -0
@@ -461,6 +476,7 @@ int proc_thermal_rfim_add(struct pci_dev *pdev,

struct proc_thermal_device *proc
                case PCI_DEVICE_ID_INTEL_NVL_H_THERMAL:
                case PCI_DEVICE_ID_INTEL_NVL_S_THERMAL:
                        dlvr_mmio_regs_table = nvl_dlvr_mmio_regs; +                       ddr_data_rate_reg = &nvl_ddr_data_rate_reg; break;
                default:
                        dlvr_mmio_regs_table = dlvr_mmio_regs; --

Applied as 7.1 material, but I rearranged it to avoid using goto and declare local vars where they are needed, please see:

Looks good.

Thanks,
Srinivas

Quoted 2 lines

https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/patch/?id=6d3e2ce6f10107c2e5870e9dce7c2e1d03a6be72