public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: javi.merino@arm.com
Cc: linux-pm@vger.kernel.org
Subject: re: thermal: introduce the Power Allocator governor
Date: Sat, 21 Nov 2015 13:42:54 +0300	[thread overview]
Message-ID: <20151121104254.GA10268@mwanda> (raw)

Hello Javi Merino,

The patch 6b775e870c56: "thermal: introduce the Power Allocator
governor" from Mar 2, 2015, leads to the following static checker
warning:

	drivers/thermal/power_allocator.c:304 divvy_up_power()
	warn: should 'req_power[i] * power_range' be a 64 bit type?

drivers/thermal/power_allocator.c
   288  static void divvy_up_power(u32 *req_power, u32 *max_power, int num_actors,
   289                             u32 total_req_power, u32 power_range,
   290                             u32 *granted_power, u32 *extra_actor_power)
   291  {
   292          u32 extra_power, capped_extra_power;
   293          int i;
   294  
   295          /*
   296           * Prevent division by 0 if none of the actors request power.
   297           */
   298          if (!total_req_power)
   299                  total_req_power = 1;
   300  
   301          capped_extra_power = 0;
   302          extra_power = 0;
   303          for (i = 0; i < num_actors; i++) {
   304                  u64 req_range = req_power[i] * power_range;

Both req_power[i] and power_range are u32 so the high bits of req_range
are not used.

   305  
   306                  granted_power[i] = DIV_ROUND_CLOSEST_ULL(req_range,
   307                                                           total_req_power);
   308  
   309                  if (granted_power[i] > max_power[i]) {
   310                          extra_power += granted_power[i] - max_power[i];
   311                          granted_power[i] = max_power[i];
   312                  }
   313  
   314                  extra_actor_power[i] = max_power[i] - granted_power[i];
   315                  capped_extra_power += extra_actor_power[i];
   316          }

regards,
dan carpenter

             reply	other threads:[~2015-11-21 10:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-21 10:42 Dan Carpenter [this message]
2015-11-23 11:23 ` [PATCH] thermal: power_allocator: req_range multiplication should be a 64 bit type Javi Merino

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=20151121104254.GA10268@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=javi.merino@arm.com \
    --cc=linux-pm@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox