All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Luba <lukasz.luba@arm.com>
To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Cc: vireshk@kernel.org, rafael@kernel.org, daniel.lezcano@linaro.org,
	Dietmar.Eggemann@arm.com, lukasz.luba@arm.com, amitk@kernel.org,
	rui.zhang@intel.com, cw00.choi@samsung.com,
	myungjoo.ham@samsung.com, kyungmin.park@samsung.com
Subject: [RFC][PATCH 3/3] thermal: power_allocator: get proper max power limited by user
Date: Tue, 26 Jan 2021 10:40:01 +0000	[thread overview]
Message-ID: <20210126104001.20361-4-lukasz.luba@arm.com> (raw)
In-Reply-To: <20210126104001.20361-1-lukasz.luba@arm.com>

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@arm.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


  parent reply	other threads:[~2021-01-26 11:53 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-26 10:39 [RFC][PATCH 0/3] New thermal interface allowing IPA to get max power Lukasz Luba
2021-01-26 10:39 ` [RFC][PATCH 1/3] PM /devfreq: add user frequency limits into devfreq struct Lukasz Luba
2021-02-03 10:11   ` Chanwoo Choi
2021-02-03 10:21     ` Lukasz Luba
2021-02-11 11:07       ` Lukasz Luba
2021-02-11 22:27         ` Lukasz Luba
2021-02-15 15:00           ` Chanwoo Choi
2021-02-16 10:41             ` Lukasz Luba
2021-02-24  8:04               ` Chanwoo Choi
2021-01-26 10:40 ` [RFC][PATCH 2/3] thermal: devfreq_cooling: add new callback to get user limit for min state Lukasz Luba
2021-01-26 10:40 ` Lukasz Luba [this message]
2021-01-27  9:15 ` [RFC][PATCH 0/3] New thermal interface allowing IPA to get max power Viresh Kumar
2021-01-27 10:11   ` Lukasz Luba
2021-01-27 10:13     ` Viresh Kumar
2021-02-01 11:23 ` Lukasz Luba
2021-02-01 14:21   ` Daniel Lezcano
2021-02-01 16:37     ` Lukasz Luba
2021-02-02  9:31   ` Chanwoo Choi
2021-02-02  9:56     ` Lukasz Luba
2021-02-01 14:19 ` Rafael J. Wysocki
2021-02-01 16:37   ` Lukasz Luba
2021-02-22 10:22 ` Daniel Lezcano
2021-02-22 12:10   ` Lukasz Luba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210126104001.20361-4-lukasz.luba@arm.com \
    --to=lukasz.luba@arm.com \
    --cc=Dietmar.Eggemann@arm.com \
    --cc=amitk@kernel.org \
    --cc=cw00.choi@samsung.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=vireshk@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.