Skip to contentSkip to conversation

hwmon: (fam15h_power) Add bit masking for tdp_limit

PATCH Applied Gioh Kim 4 participants 6 messages Jan 27, 2016 – Jan 28, 2016

Subsystems (2)
lore
Share & tools
lore

Gioh Kim

author
#0 lore raw

PATCH 1/1 hwmon: (fam15h_power) Add bit masking for tdp_limit

Add bit masking to read ApmTdpLimit precisely

---
 drivers/hwmon/fam15h_power.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/hwmon/fam15h_power.c +9 -1
index f77eb97..4f695d8 100644
@@ -90,7 +90,15 @@ static ssize_t show_power(struct device *dev,
 	pci_bus_read_config_dword(f4->bus, PCI_DEVFN(PCI_SLOT(f4->devfn), 5),
 				  REG_TDP_LIMIT3, &val);
 
-	tdp_limit = val >> 16;
+	/*
+	 * On Carrizo and later platforms, ApmTdpLimit bit field
+	 * is extended to 16:31 from 16:28.
+	 */
+	if (boot_cpu_data.x86 = 0x15 && boot_cpu_data.x86_model >= 0x60)
+		tdp_limit = val >> 16;
+	else
+		tdp_limit = (val >> 16) & 0x1fff;
+
 	curr_pwr_watts = ((u64)(tdp_limit +
 				data->base_tdp)) << running_avg_range;
 	curr_pwr_watts -= running_avg_capture;
Signature · 7 lines
2.5.0


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Gioh Kim

Add bit masking to read ApmTdpLimit precisely

---
 drivers/hwmon/fam15h_power.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/hwmon/fam15h_power.c +2 -1
index f77eb97..4f695d8 100644
@@ -90,7 +90,15 @@ static ssize_t show_power(struct device *dev,
 	pci_bus_read_config_dword(f4->bus, PCI_DEVFN(PCI_SLOT(f4->devfn), 5),
 				  REG_TDP_LIMIT3, &val);
 
-	tdp_limit = val >> 16;
+	/*
+	 * On Carrizo and later platforms, ApmTdpLimit bit field

drivers/hwmon/fam15h_power.c static ssize_t show_power(struct device *dev, · line 104

Quoted 10 lines
drivers/hwmon/fam15h_power.c +7 -0
+	 * is extended to 16:31 from 16:28.
+	 */
+	if (boot_cpu_data.x86 = 0x15 && boot_cpu_data.x86_model >= 0x60)
+		tdp_limit = val >> 16;
+	else
+		tdp_limit = (val >> 16) & 0x1fff;
+
 	curr_pwr_watts = ((u64)(tdp_limit +
 				data->base_tdp)) << running_avg_range;
 	curr_pwr_watts -= running_avg_capture;

Btw, Rui, you could consider unifying the code under a single

	if (boot_cpu_data.x86 = 0x15 && boot_cpu_data.x86_model >= 0x60) {
		...

	else
		...

as with this patch you'll have two of those checks. Unified might be better readable but that is for another patch.

Thanks.

Signature · 9 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
maintainer
#2 lore raw
Quoted 35 lines · Borislav Petkov
Quoted 19 lines · Gioh Kim

Add bit masking to read ApmTdpLimit precisely

---
 drivers/hwmon/fam15h_power.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/hwmon/fam15h_power.c +2 -1
index f77eb97..4f695d8 100644
@@ -90,7 +90,15 @@ static ssize_t show_power(struct device *dev,
 	pci_bus_read_config_dword(f4->bus, PCI_DEVFN(PCI_SLOT(f4->devfn), 5),
 				  REG_TDP_LIMIT3, &val);
 
-	tdp_limit = val >> 16;
+	/*
+	 * On Carrizo and later platforms, ApmTdpLimit bit field

drivers/hwmon/fam15h_power.c static ssize_t show_power(struct device *dev, · line 104

Quoted 10 lines
drivers/hwmon/fam15h_power.c +7 -0
+	 * is extended to 16:31 from 16:28.
+	 */
+	if (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model >= 0x60)
+		tdp_limit = val >> 16;
+	else
+		tdp_limit = (val >> 16) & 0x1fff;
+
 	curr_pwr_watts = ((u64)(tdp_limit +
 				data->base_tdp)) << running_avg_range;
 	curr_pwr_watts -= running_avg_capture;

Btw, Rui, you could consider unifying the code under a single

Quoted 9 lines
	if (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model >= 0x60) {
		...

	else
		...

as with this patch you'll have two of those checks. Unified might be better readable but that is for another patch.

Make sence, I will do that. :-)

Thanks,
Rui

author
#3 lore raw
Quoted 41 lines · Huang Rui
Quoted 40 lines · Borislav Petkov
Quoted 19 lines · Gioh Kim

Add bit masking to read ApmTdpLimit precisely

---
  drivers/hwmon/fam15h_power.c | 10 +++++++++-
  1 file changed, 9 insertions(+), 1 deletion(-)
drivers/hwmon/fam15h_power.c +2 -1
index f77eb97..4f695d8 100644
@@ -90,7 +90,15 @@ static ssize_t show_power(struct device *dev,
  	pci_bus_read_config_dword(f4->bus, PCI_DEVFN(PCI_SLOT(f4->devfn), 5),
  				  REG_TDP_LIMIT3, &val);
 
-	tdp_limit = val >> 16;
+	/*
+	 * On Carrizo and later platforms, ApmTdpLimit bit field

drivers/hwmon/fam15h_power.c static ssize_t show_power(struct device *dev, · line 104

Quoted 10 lines
drivers/hwmon/fam15h_power.c +7 -0
+	 * is extended to 16:31 from 16:28.
+	 */
+	if (boot_cpu_data.x86 = 0x15 && boot_cpu_data.x86_model >= 0x60)
+		tdp_limit = val >> 16;
+	else
+		tdp_limit = (val >> 16) & 0x1fff;
+
  	curr_pwr_watts = ((u64)(tdp_limit +
  				data->base_tdp)) << running_avg_range;
  	curr_pwr_watts -= running_avg_capture;

Btw, Rui, you could consider unifying the code under a single

	if (boot_cpu_data.x86 = 0x15 && boot_cpu_data.x86_model >= 0x60) {
		...

	else
		...
Quoted 7 lines
Quoted 3 lines

as with this patch you'll have two of those checks. Unified might be better readable but that is for another patch.

Make sence, I will do that. :-)

Thanks,
Rui

Agree. It'll be better.
Thank you.

Signature · 8 lines
Best regards,
Gi-Oh Kim


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
maintainer Acked-by on v1 1/1
#4 lore raw
In reply to Gioh Kim
Quoted 3 lines · Gioh Kim

Add bit masking to read ApmTdpLimit precisely

Looks good for me too.

Quoted 28 lines
---
 drivers/hwmon/fam15h_power.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/hwmon/fam15h_power.c +9 -1
index f77eb97..4f695d8 100644
@@ -90,7 +90,15 @@ static ssize_t show_power(struct device *dev,
 	pci_bus_read_config_dword(f4->bus, PCI_DEVFN(PCI_SLOT(f4->devfn), 5),
 				  REG_TDP_LIMIT3, &val);
 
-	tdp_limit = val >> 16;
+	/*
+	 * On Carrizo and later platforms, ApmTdpLimit bit field
+	 * is extended to 16:31 from 16:28.
+	 */
+	if (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model >= 0x60)
+		tdp_limit = val >> 16;
+	else
+		tdp_limit = (val >> 16) & 0x1fff;
+
 	curr_pwr_watts = ((u64)(tdp_limit +
 				data->base_tdp)) << running_avg_range;
 	curr_pwr_watts -= running_avg_capture;
Signature · 1 line
2.5.0