linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PM / OPP: discard duplicate OPP additions
@ 2014-05-13  7:41 [Chander Kashyap
  2014-05-13  8:22 ` Viresh Kumar
                   ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: [Chander Kashyap @ 2014-05-13  7:41 UTC (permalink / raw)
  To: linux-pm, linux-kernel
  Cc: rjw, pavel, len.brown, gregkh, viresh.kumar, Chander Kashyap,
	Inderpal Singh

From: Chander Kashyap <k.chander@samsung.com>

It may be possible to unregister and re-register the cpufreq driver.
One such example is arm big-little IKS cpufreq driver. While
re-registering the driver, same OPPs may get added again.

This patch detects the duplicacy and discards them.

Signed-off-by: Chander Kashyap <k.chander@samsung.com>
Signed-off-by: Inderpal Singh <inderpal.s@samsung.com>
---
 drivers/base/power/opp.c |   28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 2553867..2e803a9 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -443,23 +443,33 @@ int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt)
 	new_opp->u_volt = u_volt;
 	new_opp->available = true;
 
-	/* Insert new OPP in order of increasing frequency */
+	/*
+	 * Insert new OPP in order of increasing frequency
+	 * and discard if already present
+	 */
 	head = &dev_opp->opp_list;
 	list_for_each_entry_rcu(opp, &dev_opp->opp_list, node) {
-		if (new_opp->rate < opp->rate)
+		if (new_opp->rate <= opp->rate)
 			break;
 		else
 			head = &opp->node;
 	}
 
-	list_add_rcu(&new_opp->node, head);
-	mutex_unlock(&dev_opp_list_lock);
+	if (new_opp->rate != opp->rate) {
+		list_add_rcu(&new_opp->node, head);
+		mutex_unlock(&dev_opp_list_lock);
+
+		/*
+		 * Notify the changes in the availability of the operable
+		 * frequency/voltage list.
+		 */
+		srcu_notifier_call_chain(&dev_opp->head,
+						OPP_EVENT_ADD, new_opp);
+	} else {
+		mutex_unlock(&dev_opp_list_lock);
+		kfree(new_opp);
+	}
 
-	/*
-	 * Notify the changes in the availability of the operable
-	 * frequency/voltage list.
-	 */
-	srcu_notifier_call_chain(&dev_opp->head, OPP_EVENT_ADD, new_opp);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_add);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 31+ messages in thread
* Re: [PATCH v2] PM / OPP: discard duplicate OPP additions
@ 2014-05-16  8:24 Viresh Kumar
  2014-05-16  8:42 ` Chander Kashyap
  0 siblings, 1 reply; 31+ messages in thread
From: Viresh Kumar @ 2014-05-16  8:24 UTC (permalink / raw)
  To: Chander Kashyap
  Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List,
	Nishanth Menon, Rafael J. Wysocki, Pavel Machek, Brown, Len,
	Greg Kroah-Hartman, Chander Kashyap, Inderpal Singh

On 16 May 2014 13:43, Chander Kashyap <chander.kashyap@linaro.org> wrote:
> From: Chander Kashyap <k.chander@samsung.com>
>
> It may be possible to unregister and re-register the cpufreq driver.
> One such example is arm big-little IKS cpufreq driver. While
> re-registering the driver, same OPPs may get added again.
>
> This patch detects the duplicacy and discards them.

Diff looks fine but not the log ofcourse. It doesn't have anything to do with
big LITTLE.. Its just a patch to avoid addition of duplicate OPPs..

Also fix spelling mistakes in log..

And subject should be:
PM / OPP: discard duplicate OPPs

^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [PATCH v2] PM / OPP: discard duplicate OPP additions
@ 2014-05-16  8:47 Viresh Kumar
  0 siblings, 0 replies; 31+ messages in thread
From: Viresh Kumar @ 2014-05-16  8:47 UTC (permalink / raw)
  To: Chander Kashyap
  Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List,
	Nishanth Menon, Rafael J. Wysocki, Pavel Machek, Brown, Len,
	Greg Kroah-Hartman, Chander Kashyap, Inderpal Singh

On 16 May 2014 14:12, Chander Kashyap <chander.kashyap@linaro.org> wrote:
> On 16 May 2014 13:54, Viresh Kumar <viresh.kumar@linaro.org> wrote:
>> On 16 May 2014 13:43, Chander Kashyap <chander.kashyap@linaro.org> wrote:
>>> From: Chander Kashyap <k.chander@samsung.com>
>>>
>>> It may be possible to unregister and re-register the cpufreq driver.
>>> One such example is arm big-little IKS cpufreq driver. While
>>> re-registering the driver, same OPPs may get added again.
>>>
>>> This patch detects the duplicacy and discards them.
>>
>> Diff looks fine but not the log ofcourse. It doesn't have anything to do with
>> big LITTLE.. Its just a patch to avoid addition of duplicate OPPs..
>>
>
> Big little reference is provided as an example. Nothing much

What I am saying is: "This is not a problem of re-registering drivers
but adding duplicate OPPs and that's what we should emphasize
on in the log". Your log is all focused on how to get re-registering
of a driver working.

>> Also fix spelling mistakes in log..
>>
>> And subject should be:
>> PM / OPP: discard duplicate OPPs
>
> Duplicates are discarded during OPP addition, and subject line indicates that.

I am asking to improve it. Replace:

PM / OPP: discard duplicate OPP additions

with

PM / OPP: discard duplicate OPPs

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2014-05-17 17:29 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-13  7:41 [PATCH] PM / OPP: discard duplicate OPP additions [Chander Kashyap
2014-05-13  8:22 ` Viresh Kumar
2014-05-13 10:30   ` Sudeep Holla
2014-05-13 11:05     ` Viresh Kumar
2014-05-13 11:37       ` Sudeep Holla
2014-05-13 11:57       ` Chander Kashyap
2014-05-13 13:02         ` Sudeep Holla
2014-05-13 13:41   ` Nishanth Menon
2014-05-13 13:23 ` Nishanth Menon
2014-05-14  9:31   ` Chander Kashyap
2014-05-14 11:08     ` Viresh Kumar
2014-05-14 14:27       ` Nishanth Menon
2014-05-15  8:25         ` Chander Kashyap
2014-05-15  8:27           ` Viresh Kumar
2014-05-15  8:46             ` Chander Kashyap
2014-05-15  8:55               ` Viresh Kumar
2014-05-16  8:13                 ` [PATCH v2] " Chander Kashyap
2014-05-14 15:02 ` [PATCH] " Pavel Machek
2014-05-15  3:57   ` Viresh Kumar
     [not found]     ` <CAOqmu80j2q6hQLThVt60QkjqcZTXwJ6ddwDLvqBEW1ejrVh_hw@mail.gmail.com>
2014-05-15  4:36       ` Viresh Kumar
2014-05-15  4:52         ` Inderpal Singh
2014-05-15  5:04           ` Viresh Kumar
2014-05-15  5:30             ` Inderpal Singh
2014-05-15  5:37               ` Viresh Kumar
2014-05-15  5:46                 ` Inderpal Singh
2014-05-15  6:01                   ` Viresh Kumar
2014-05-15  6:10                     ` Inderpal Singh
2014-05-17 17:29             ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2014-05-16  8:24 [PATCH v2] " Viresh Kumar
2014-05-16  8:42 ` Chander Kashyap
2014-05-16  8:47 Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).