EDP: fix run time warnings
Sivaram Nair [Thu, 4 Jul 2013 07:31:11 +0000 (10:31 +0300)]
Fixing warnings issued by EDP governors due to incorrect power budget
math.

Bug 1313928

Change-Id: If1c9cf5c6df66ed4f2cc8a1b9399d4c57b2c7a64
Signed-off-by: Sivaram Nair <sivaramn@nvidia.com>
Reviewed-on: http://git-master/r/245106
(cherry picked from commit 6870474b775573f8a060afff99fca3bb171ec12c)
Reviewed-on: http://git-master/r/250633
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

drivers/edp/edp_fair.c
drivers/edp/edp_overage.c

index 582a4bb..d21e87f 100644 (file)
@@ -34,34 +34,24 @@ static unsigned int approvable_req(struct edp_client *c, unsigned int net)
        return edp_promotion_point(c, step);
 }
 
-static unsigned int net_e0(struct edp_client *client)
-{
-       struct edp_client *c;
-       unsigned int net = 0;
-
-       list_for_each_entry(c, &client->manager->clients, link)
-               net += e0_level(c);
-
-       return net;
-}
-
 static struct edp_client *throttle_pledge(struct edp_client *client,
                unsigned int required, unsigned int net,
                unsigned int *pledged)
 {
        struct edp_manager *m = client->manager;
-       unsigned int deficit = required - m->remaining;
        struct edp_client *c;
        unsigned int step;
+       unsigned int fair;
 
        *pledged = m->remaining;
 
        list_for_each_entry_reverse(c, &m->clients, link) {
-               if (c == client || cur_level(c) <= e0_level(c))
+               fair = c->manager->max * e0_level(c) / net;
+               if (c == client || cur_level(c) <= fair)
                        continue;
 
-               step = (deficit * e0_level(c) + net - 1) / net;
-               c->gwt = edp_throttling_point(c, step ?: 1);
+               step = min(cur_level(c) - fair, required - *pledged);
+               c->gwt = edp_throttling_point(c, step);
                *pledged += cur_level(c) - c->states[c->gwt];
                if (*pledged >= required)
                        break;
@@ -102,7 +92,7 @@ static void throttle(struct edp_client *client)
        unsigned int required;
        unsigned int net;
 
-       net = net_e0(client);
+       net = e0_current_sum(m);
        if (!net) {
                WARN_ON(1);
                return;
index fe25df7..2dc1c2e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2012-2013, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -51,7 +51,11 @@ static unsigned int approvable_req(struct edp_client *c,
        if (req_index(c) >= c->e0_index)
                return req_index(c);
 
-       tot_overage  = net_overage + cur_overage(c) + c->manager->remaining;
+       tot_overage = net_overage + c->manager->remaining;
+       if (cur_overage(c))
+               tot_overage += cur_overage(c);
+       else
+               tot_overage -= e0_level(c) - cur_level(c);
        tot_max = net_max + c->states[0];
        fair_level = tot_overage * c->states[0] / tot_max + e0_level(c);
        step = max(fair_level, cur_level(c) + c->manager->remaining) -