lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210126104001.20361-4-lukasz.luba@arm.com>
Date:   Tue, 26 Jan 2021 10:40:01 +0000
From:   Lukasz Luba <lukasz.luba@....com>
To:     linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org
Cc:     vireshk@...nel.org, rafael@...nel.org, daniel.lezcano@...aro.org,
        Dietmar.Eggemann@....com, lukasz.luba@....com, amitk@...nel.org,
        rui.zhang@...el.com, cw00.choi@...sung.com,
        myungjoo.ham@...sung.com, kyungmin.park@...sung.com
Subject: [RFC][PATCH 3/3] thermal: power_allocator: get proper max power limited by user

Use new API interface to get the maximum power of the cooling device. This
is needed to properly allocate and split the total power budget. The
allowed limit is taken from supported cooling device and then checked with
limits set in DT. The final state value is used for asking for the related
power value the cooling device.

Signed-off-by: Lukasz Luba <lukasz.luba@....com>
---
 drivers/thermal/gov_power_allocator.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
index 92acae53df49..ec33fba5a358 100644
--- a/drivers/thermal/gov_power_allocator.c
+++ b/drivers/thermal/gov_power_allocator.c
@@ -308,6 +308,20 @@ power_actor_set_power(struct thermal_cooling_device *cdev,
 	return 0;
 }
 
+static int
+power_actor_get_max_power(struct thermal_cooling_device *cdev,
+			  struct thermal_instance *instance, u32 *max_power)
+{
+	unsigned long min_state = 0;
+
+	if (cdev->ops->get_user_min_state)
+		cdev->ops->get_user_min_state(cdev, &min_state);
+
+	min_state = max(instance->lower, min_state);
+
+	return cdev->ops->state2power(cdev, min_state, max_power);
+}
+
 /**
  * divvy_up_power() - divvy the allocated power between the actors
  * @req_power:	each actor's requested power
@@ -455,8 +469,7 @@ static int allocate_power(struct thermal_zone_device *tz,
 
 		weighted_req_power[i] = frac_to_int(weight * req_power[i]);
 
-		if (cdev->ops->state2power(cdev, instance->lower,
-					   &max_power[i]))
+		if (power_actor_get_max_power(cdev, instance, &max_power[i]))
 			continue;
 
 		total_req_power += req_power[i];
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ