All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean Pihet <jean.pihet@newoldbits.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: markgross@thegnar.org,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Linux PM mailing list <linux-pm@lists.linux-foundation.org>,
	linux-omap@vger.kernel.org, Jean Pihet <j-pihet@ti.com>
Subject: Re: [PATCH 07/15] PM QoS: add a global notification mechanism for the device constraints
Date: Tue, 16 Aug 2011 11:58:38 +0200	[thread overview]
Message-ID: <CAORVsuUNxCN7+KZnpJT5Urd07cB+raX6e23ah_9Mp8M07SAyLw__39425.1238358722$1313488882$gmane$org@mail.gmail.com> (raw)
In-Reply-To: <201108142350.42260.rjw@sisk.pl>

Hi Rafael,

2011/8/14 Rafael J. Wysocki <rjw@sisk.pl>:
> Hi,
>
> There is some code duplication in this patch that should better be
> avoided (details below).
>
> On Thursday, August 11, 2011, jean.pihet@newoldbits.com wrote:
>> From: Jean Pihet <j-pihet@ti.com>
>>
>> Add a global notification chain that gets called upon changes to the
>> aggregated constraint value for any device.
>> The notification callbacks are passing the full constraint request data
>> in order for the callees to have access to it. The current use is for the
>> platform low-level code to access the target device of the constraint.
>>
...

>
> The following code:
>
>> +     /*
>> +      * Update constraints list and call the per-device callbacks if needed
>> +      */
>> +     ret = pm_qos_update_target(dev->power.constraints,
>> +                                &req->node, PM_QOS_ADD_REQ, value);
>> +
>> +     if (ret) {
>> +             /* Call the global callbacks if needed */
>> +             curr_value = pm_qos_read_value(req->dev->power.constraints);
>> +             blocking_notifier_call_chain(&dev_pm_notifiers,
>> +                                          (unsigned long)curr_value,
>> +                                          req);
>> +     }
>
> is used in dev_pm_qos_update_request() and dev_pm_qos_remove_request()
> with the only difference being the command given to pm_qos_update_target().
> This asks for a common function, eg. dev_pm_qos_update_target(), containing
> that code that will be called by all of them (and, apparently, by
> dev_pm_qos_constraints_destroy()).
Ok that makes the code cleaner.

>
> ...
>> @@ -250,9 +329,18 @@ void dev_pm_qos_constraints_destroy(struct device *dev)
>>                        * Update constraints list and call the per-device
>>                        * callbacks if needed
>>                        */
>> -                     pm_qos_update_target(req->dev->power.constraints,
>> -                                          &req->node, PM_QOS_REMOVE_REQ,
>> -                                          PM_QOS_DEFAULT_VALUE);
>> +                     ret |= pm_qos_update_target(req->dev->power.constraints,
>> +                                                 &req->node,
>> +                                                 PM_QOS_REMOVE_REQ,
>> +                                                 PM_QOS_DEFAULT_VALUE);
>
> I'm not sure why you're using the binary or operator here.  Shouldn't that be
> a simple assignment?
>
>> +
>> +             if (ret) {
>> +                     /* Call the global callbacks if needed */
>> +                     curr_value = dev->power.constraints->default_value;
>> +                     blocking_notifier_call_chain(&dev_pm_notifiers,
>> +                                                  (unsigned long)curr_value,
>> +                                                  req);
>> +             }
In the sake of optimization I had a single return value that
aggregates the return values of the calls target_value and calls the
global notifier callbacks _only once_.

As you suggested it is better to use the common update code, which
makes the code cleaner but also removes this optimization.

>>
>>               kfree(dev->power.constraints->notifiers);
>>               kfree(dev->power.constraints);
>
> Thanks,
> Rafael
>

Regards,
Jean

  parent reply	other threads:[~2011-08-16  9:58 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-11 15:06 [PATCH v4 00/15] PM QoS: add a per-device latency constraints class jean.pihet
2011-08-11 15:06 ` [PATCH 01/15] PM QoS: move and rename the implementation files jean.pihet
2011-08-13  2:47   ` mark gross
2011-08-13  2:47   ` mark gross
2011-08-11 15:06 ` jean.pihet
2011-08-11 15:06 ` [PATCH 02/15] PM QoS: minor clean-ups jean.pihet
2011-08-13  2:48   ` mark gross
2011-08-13  2:48   ` mark gross
2011-08-11 15:06 ` jean.pihet
2011-08-11 15:06 ` [PATCH 03/15] PM QoS: code re-organization jean.pihet
2011-08-11 15:06 ` jean.pihet
2011-08-13  2:50   ` mark gross
2011-08-13  2:50   ` mark gross
2011-08-11 15:06 ` [PATCH 04/15] PM QoS: re-organize data structs jean.pihet
2011-08-13  2:56   ` mark gross
2011-08-13 20:58     ` Rafael J. Wysocki
2011-08-14  8:29       ` Jean Pihet
2011-08-14  8:29       ` Jean Pihet
2011-08-14 13:34         ` Rafael J. Wysocki
2011-08-14 13:34         ` Rafael J. Wysocki
2011-08-13 20:58     ` Rafael J. Wysocki
2011-08-13  2:56   ` mark gross
2011-08-11 15:06 ` jean.pihet
2011-08-11 15:06 ` [PATCH 05/15] PM QoS: generalize and export the constraints management code jean.pihet
2011-08-11 15:06 ` jean.pihet
2011-08-13  3:09   ` mark gross
2011-08-13 20:34     ` Rafael J. Wysocki
2011-08-14  8:25       ` Jean Pihet
2011-08-14 13:37         ` Rafael J. Wysocki
2011-08-16  4:08           ` mark gross
2011-08-16  4:08           ` mark gross
2011-08-16  6:44             ` Jean Pihet
2011-08-16 17:45               ` mark gross
2011-08-16 18:01                 ` Rafael J. Wysocki
2011-08-16 18:01                 ` Rafael J. Wysocki
2011-08-16 17:45               ` mark gross
2011-08-16  6:44             ` Jean Pihet
2011-08-14 13:37         ` Rafael J. Wysocki
2011-08-14  8:25       ` Jean Pihet
2011-08-13 20:34     ` Rafael J. Wysocki
2011-08-13  3:09   ` mark gross
2011-08-11 15:06 ` [PATCH 06/15] PM QoS: implement the per-device PM QoS constraints jean.pihet
2011-08-13  3:16   ` mark gross
2011-08-13  3:16   ` mark gross
2011-08-13 21:08   ` Rafael J. Wysocki
2011-08-14  8:50     ` Jean Pihet
2011-08-14 13:51       ` Rafael J. Wysocki
2011-08-14 13:51       ` Rafael J. Wysocki
2011-08-14  8:50     ` Jean Pihet
2011-08-13 21:08   ` Rafael J. Wysocki
2011-08-11 15:06 ` jean.pihet
2011-08-11 15:06 ` [PATCH 07/15] PM QoS: add a global notification mechanism for the device constraints jean.pihet
2011-08-11 15:06 ` jean.pihet
2011-08-14 21:50   ` Rafael J. Wysocki
2011-08-16  9:58     ` Jean Pihet
2011-08-16  9:58     ` Jean Pihet [this message]
2011-08-14 21:50   ` Rafael J. Wysocki
2011-08-11 15:06 ` [PATCH 08/15] OMAP: convert I2C driver to PM QoS for latency constraints jean.pihet
2011-08-11 15:06 ` jean.pihet
2011-08-11 15:06 ` [PATCH 09/15] OMAP: PM: create a PM layer plugin for per-device constraints jean.pihet
2011-08-11 15:06 ` jean.pihet
2011-08-11 15:06 ` [PATCH 10/15] OMAP2+: powerdomain: control power domains next state jean.pihet
2011-08-11 15:06 ` jean.pihet
2011-08-11 15:06 ` [PATCH 11/15] OMAP3: powerdomain data: add wake-up latency figures jean.pihet
2011-08-11 15:06 ` jean.pihet
2011-08-11 15:06 ` [PATCH 12/15] OMAP4: " jean.pihet
2011-08-11 15:06 ` jean.pihet
2011-08-11 15:06 ` [PATCH 13/15] OMAP2+: omap_hwmod: manage the wake-up latency constraints jean.pihet
2011-08-11 15:06 ` jean.pihet
2011-08-11 15:06 ` [PATCH 14/15] OMAP: PM CONSTRAINTS: implement the devices " jean.pihet
2011-08-11 15:06 ` jean.pihet
2011-08-11 15:06 ` [PATCH 15/15] OMAP2+: cpuidle only influences the MPU state jean.pihet
2011-08-11 15:06 ` jean.pihet
2011-08-12  8:02 ` [PATCH v4 00/15] PM QoS: add a per-device latency constraints class Rafael J. Wysocki
2011-08-12 11:56   ` Jean Pihet
2011-08-12 21:56     ` Rafael J. Wysocki
2011-08-12 21:56     ` Rafael J. Wysocki
2011-08-14  8:51       ` Jean Pihet
2011-08-14  8:51       ` Jean Pihet
2011-08-14 13:53         ` Rafael J. Wysocki
2011-08-14 13:53         ` Rafael J. Wysocki
2011-08-12 11:56   ` Jean Pihet
2011-08-12  8:02 ` Rafael J. Wysocki
2011-08-16 13:43 [PATCH v5 00/15] PM QoS: add a per-device latency constraints framework jean.pihet
2011-08-16 13:43 ` [PATCH 07/15] PM QoS: add a global notification mechanism for the device constraints jean.pihet
2011-08-16 13:43 ` jean.pihet
2011-08-16 21:44   ` Rafael J. Wysocki
2011-08-16 21:44   ` Rafael J. Wysocki

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='CAORVsuUNxCN7+KZnpJT5Urd07cB+raX6e23ah_9Mp8M07SAyLw__39425.1238358722$1313488882$gmane$org@mail.gmail.com' \
    --to=jean.pihet@newoldbits.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=j-pihet@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=markgross@thegnar.org \
    --cc=rjw@sisk.pl \
    /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.