Commit 4165684b authored by Huisong Li's avatar Huisong Li Committed by Lifeng Zheng
Browse files

hwmon: (acpi_power_meter) Fix the fake power alarm reporting

mainline inclusion
from mainline-v6.14-rc1
commit 0ea627381eb527a0ebd262c690c3992085b87ff4
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBVB4K
CVE: NA

Reference: https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0ea627381eb527a0ebd262c690c3992085b87ff4



---------------------------------------------------------------------

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: default avatarHuisong Li <lihuisong@huawei.com>
Link: https://lore.kernel.org/r/20250220030832.2976-1-lihuisong@huawei.com


Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarXinghai Cen <cenxinghai@h-partners.com>
parent 1528c91e
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -437,9 +437,13 @@ static ssize_t show_val(struct device *dev,
			ret = update_cap(resource);
			if (ret)
				return ret;
		}
		val = resource->power_alarm || resource->power > resource->cap;
			resource->power_alarm = resource->power > resource->cap;
			val = resource->power_alarm;
		} else {
			val = resource->power_alarm ||
				 resource->power > resource->cap;
			resource->power_alarm = resource->power > resource->cap;
		}
		break;
	case 7:
	case 8: