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

hwmon: (acpi_power_meter) Fix the fake power alarm reporting

We encountered a problem that a fake power alarm is reported to
user on the platform unsupported notifications at the second step
below:
1> Query 'power1_alarm' attribute when the power capping occurs.
2> Query 'power1_alarm' attribute when the power capping is over
and the current average power is less then power cap value.

The root cause is that the resource->power_alarm is set to true
at the first step. And power meter use this old value to show
the power alarm state instead of the current the comparison value.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Link: https://lore.kernel.org/r/20250220030832.2976-1-lihuisong@huawei.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Huisong Li and committed by
Guenter Roeck
0ea62738 9fee7d19

+6 -2
+6 -2
drivers/hwmon/acpi_power_meter.c
··· 437 437 ret = update_cap(resource); 438 438 if (ret) 439 439 return ret; 440 + resource->power_alarm = resource->power > resource->cap; 441 + val = resource->power_alarm; 442 + } else { 443 + val = resource->power_alarm || 444 + resource->power > resource->cap; 445 + resource->power_alarm = resource->power > resource->cap; 440 446 } 441 - val = resource->power_alarm || resource->power > resource->cap; 442 - resource->power_alarm = resource->power > resource->cap; 443 447 break; 444 448 case 7: 445 449 case 8: