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

hwmon: (fam15h_power) Add bit masking for tdp_limit

Add bit masking to read ApmTdpLimit precisely

Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com>
Acked-by: Borislav Petkov <bp@suse.de>
Acked-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Gioh Kim and committed by
Guenter Roeck
60dee3ca 6220f4eb

+9 -1
+9 -1
drivers/hwmon/fam15h_power.c
··· 90 90 pci_bus_read_config_dword(f4->bus, PCI_DEVFN(PCI_SLOT(f4->devfn), 5), 91 91 REG_TDP_LIMIT3, &val); 92 92 93 - tdp_limit = val >> 16; 93 + /* 94 + * On Carrizo and later platforms, ApmTdpLimit bit field 95 + * is extended to 16:31 from 16:28. 96 + */ 97 + if (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model >= 0x60) 98 + tdp_limit = val >> 16; 99 + else 100 + tdp_limit = (val >> 16) & 0x1fff; 101 + 94 102 curr_pwr_watts = ((u64)(tdp_limit + 95 103 data->base_tdp)) << running_avg_range; 96 104 curr_pwr_watts -= running_avg_capture;