Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (fam15h_power) Add ratio of Tsample to the PTSC period

This patch adds a member (cpu_pwr_sample_ratio) of fam15h_power_data,
that represents the ratio of compute unit power accumulator sample
period to the PTSC counter period.

Tsample: compute unit power accumulator sample period
Tref: the performance timestamp counter period
PTSC: performance timestamp counter

Signed-off-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Huang Rui and committed by
Guenter Roeck
1ed32160 5aeb5d20

+15 -1
+15 -1
drivers/hwmon/fam15h_power.c
··· 46 46 unsigned int tdp_to_watts; 47 47 unsigned int base_tdp; 48 48 unsigned int processor_pwr_watts; 49 + unsigned int cpu_pwr_sample_ratio; 49 50 }; 50 51 51 52 static ssize_t show_power(struct device *dev, ··· 189 188 static void fam15h_power_init_data(struct pci_dev *f4, 190 189 struct fam15h_power_data *data) 191 190 { 192 - u32 val; 191 + u32 val, eax, ebx, ecx, edx; 193 192 u64 tmp; 194 193 195 194 pci_read_config_dword(f4, REG_PROCESSOR_TDP, &val); ··· 210 209 211 210 /* convert to microWatt */ 212 211 data->processor_pwr_watts = (tmp * 15625) >> 10; 212 + 213 + cpuid(0x80000007, &eax, &ebx, &ecx, &edx); 214 + 215 + /* CPUID Fn8000_0007:EDX[12] indicates to support accumulated power */ 216 + if (!(edx & BIT(12))) 217 + return; 218 + 219 + /* 220 + * determine the ratio of the compute unit power accumulator 221 + * sample period to the PTSC counter period by executing CPUID 222 + * Fn8000_0007:ECX 223 + */ 224 + data->cpu_pwr_sample_ratio = ecx; 213 225 } 214 226 215 227 static int fam15h_power_probe(struct pci_dev *pdev,