mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chia-Hao Liu <a0921444212@gmail.com>
To: lukasz.luba@arm.com
Cc: rafael@kernel.org, daniel.lezcano@linaro.org,
	rui.zhang@intel.com, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Chia-Hao Liu <a0921444212@gmail.com>
Subject: [PATCH 2/2] drivers: thermal: fix zero weighted request power
Date: Wed, 29 May 2024 21:52:47 +0800	[thread overview]
Message-ID: <20240529135247.12737-1-a0921444212@gmail.com> (raw)

When the product of weight and req_power is less than 1024,
the `frac_to_int()` macro causes the weighted_req_power to
become zero, it will cause granted_power to be zero.
To address issue, I add a check:
If the weight is less than 1024, frac_to_int() is not applied
to avoid setting the weighted_req_power to zero.

Signed-off-by: Chia-Hao Liu <a0921444212@gmail.com>
---
 drivers/thermal/gov_power_allocator.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
index 336b48745..c878cbb62 100644
--- a/drivers/thermal/gov_power_allocator.c
+++ b/drivers/thermal/gov_power_allocator.c
@@ -434,10 +434,10 @@ static void allocate_power(struct thermal_zone_device *tz, int control_temp)
 		else
 			weight = instance->weight;
         
-        if (weight < 1024) 
-		    pa->weighted_req_power = weight * pa->req_power;
+		if (weight < 1024)
+			pa->weighted_req_power = weight * pa->req_power;
 		else
-            pa->weighted_req_power = frac_to_int(weight * pa->req_power);
+			pa->weighted_req_power = frac_to_int(weight * pa->req_power);
 
 		ret = cdev->ops->state2power(cdev, instance->lower,
 					     &pa->max_power);
-- 
2.34.1


                 reply	other threads:[~2024-05-29 13:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240529135247.12737-1-a0921444212@gmail.com \
    --to=a0921444212@gmail.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®