From: Leonard Crestez <leonard.crestez@nxp.com>
To: Chanwoo Choi <cw00.choi@samsung.com>,
Matthias Kaehlcke <mka@chromium.org>,
MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: "Artur Świgoń" <a.swigon@partner.samsung.com>,
"Abel Vesa" <abel.vesa@nxp.com>,
"Saravana Kannan" <saravanak@google.com>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"Viresh Kumar" <viresh.kumar@linaro.org>,
dl-linux-imx <linux-imx@nxp.com>,
"Krzysztof Kozlowski" <krzk@kernel.org>,
"Kyungmin Park" <kyungmin.park@samsung.com>,
"Alexandre Bailon" <abailon@baylibre.com>,
"Georgi Djakov" <georgi.djakov@linaro.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"Jacky Bai" <ping.bai@nxp.com>
Subject: Re: [PATCH v9 7/8] PM / devfreq: Add PM QoS support
Date: Thu, 31 Oct 2019 13:21:22 +0000 [thread overview]
Message-ID: <VI1PR04MB7023B93005D2319BD30424FDEE630@VI1PR04MB7023.eurprd04.prod.outlook.com> (raw)
In-Reply-To: 67149311-a716-b175-ee19-fdde3a40b28a@samsung.com
On 31.10.2019 04:55, Chanwoo Choi wrote:
> Hi Leonard,
>
> It looks good to me. Thanks for your effort.
> But, I have one minor comment related to 'over 80 char'.
>
> In the devfreq_dev_release(), please edit this line
> as following to protect the over 80 char on one line
> if there are no specific reason.
>
> dev_warn(dev->parent,
> "Failed to remove DEV_PM_QOS_MAX_FREQUENCY notifier: %d\n",
> err);
>
> dev_warn(dev->parent,
> "Failed to remove DEV_PM_QOS_MIN_FREQUENCY notifier: %d\n",
> err);
>
>
> If you edit them, feel free to add my reviewed-by tag:
Still didn't find in 80 chars so I shrunk "DEV_PM_QOS_MIN_FREQUENCY to
"min_freq" instead. Same for PATCH 8/8
> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
>
>
> On 19. 10. 3. 오전 4:25, Leonard Crestez wrote:
>> Register notifiers with the PM QoS framework in order to respond to
>> requests for DEV_PM_QOS_MIN_FREQUENCY and DEV_PM_QOS_MAX_FREQUENCY.
>>
>> No notifiers are added by this patch but PM QoS constraints can be
>> imposed externally (for example from other devices).
>>
>> Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
>> ---
>> drivers/devfreq/devfreq.c | 78 +++++++++++++++++++++++++++++++++++++++
>> include/linux/devfreq.h | 5 +++
>> 2 files changed, 83 insertions(+)
>>
>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>> index 2d63692903ff..46f699b84a22 100644
>> --- a/drivers/devfreq/devfreq.c
>> +++ b/drivers/devfreq/devfreq.c
>> @@ -22,15 +22,18 @@
>> #include <linux/platform_device.h>
>> #include <linux/list.h>
>> #include <linux/printk.h>
>> #include <linux/hrtimer.h>
>> #include <linux/of.h>
>> +#include <linux/pm_qos.h>
>> #include "governor.h"
>>
>> #define CREATE_TRACE_POINTS
>> #include <trace/events/devfreq.h>
>>
>> +#define HZ_PER_KHZ 1000
>> +
>> static struct class *devfreq_class;
>>
>> /*
>> * devfreq core provides delayed work based load monitoring helper
>> * functions. Governors can use these or can implement their own
>> @@ -109,10 +112,11 @@ static unsigned long find_available_max_freq(struct devfreq *devfreq)
>> static void get_freq_range(struct devfreq *devfreq,
>> unsigned long *min_freq,
>> unsigned long *max_freq)
>> {
>> unsigned long *freq_table = devfreq->profile->freq_table;
>> + s32 qos_min_freq, qos_max_freq;
>>
>> lockdep_assert_held(&devfreq->lock);
>>
>> /*
>> * Initialize minimum/maximum frequency from freq table.
>> @@ -125,10 +129,20 @@ static void get_freq_range(struct devfreq *devfreq,
>> } else {
>> *min_freq = freq_table[devfreq->profile->max_state - 1];
>> *max_freq = freq_table[0];
>> }
>>
>> + /* Apply constraints from PM QoS */
>> + qos_min_freq = dev_pm_qos_read_value(devfreq->dev.parent,
>> + DEV_PM_QOS_MIN_FREQUENCY);
>> + qos_max_freq = dev_pm_qos_read_value(devfreq->dev.parent,
>> + DEV_PM_QOS_MAX_FREQUENCY);
>> + *min_freq = max(*min_freq, (unsigned long)HZ_PER_KHZ * qos_min_freq);
>> + if (qos_max_freq != PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE)
>> + *max_freq = min(*max_freq,
>> + (unsigned long)HZ_PER_KHZ * qos_max_freq);
>> +
>> /* Apply constraints from sysfs */
>> *min_freq = max(*min_freq, devfreq->min_freq);
>> *max_freq = min(*max_freq, devfreq->max_freq);
>>
>> /* Apply constraints from OPP interface */
>> @@ -608,24 +622,75 @@ static int devfreq_notifier_call(struct notifier_block *nb, unsigned long type,
>> err);
>>
>> return NOTIFY_OK;
>> }
>>
>> +/**
>> + * qos_notifier_call() - Common handler for QoS constraints.
>> + * @devfreq: the devfreq instance.
>> + */
>> +static int qos_notifier_call(struct devfreq *devfreq)
>> +{
>> + int err;
>> +
>> + mutex_lock(&devfreq->lock);
>> + err = update_devfreq(devfreq);
>> + mutex_unlock(&devfreq->lock);
>> + if (err)
>> + dev_err(devfreq->dev.parent,
>> + "failed to update frequency from PM QoS (%d)\n",
>> + err);
>> +
>> + return NOTIFY_OK;
>> +}
>> +
>> +/**
>> + * qos_min_notifier_call() - Callback for QoS min_freq changes.
>> + * @nb: Should be devfreq->nb_min
>> + */
>> +static int qos_min_notifier_call(struct notifier_block *nb,
>> + unsigned long val, void *ptr)
>> +{
>> + return qos_notifier_call(container_of(nb, struct devfreq, nb_min));
>> +}
>> +
>> +/**
>> + * qos_max_notifier_call() - Callback for QoS max_freq changes.
>> + * @nb: Should be devfreq->nb_max
>> + */
>> +static int qos_max_notifier_call(struct notifier_block *nb,
>> + unsigned long val, void *ptr)
>> +{
>> + return qos_notifier_call(container_of(nb, struct devfreq, nb_max));
>> +}
>> +
>> /**
>> * devfreq_dev_release() - Callback for struct device to release the device.
>> * @dev: the devfreq device
>> *
>> * Remove devfreq from the list and release its resources.
>> */
>> static void devfreq_dev_release(struct device *dev)
>> {
>> struct devfreq *devfreq = to_devfreq(dev);
>> + int err;
>>
>> mutex_lock(&devfreq_list_lock);
>> list_del(&devfreq->node);
>> mutex_unlock(&devfreq_list_lock);
>>
>> + err = dev_pm_qos_remove_notifier(devfreq->dev.parent, &devfreq->nb_max,
>> + DEV_PM_QOS_MAX_FREQUENCY);
>> + if (err)
>> + dev_warn(dev->parent, "Failed to remove DEV_PM_QOS_MAX_FREQUENCY notifier: %d\n",
>> + err);
>
> Please edit this line as following to protect the over 80 char
> on one line if there are no specific reason.
>
> dev_warn(dev->parent,
> "Failed to remove DEV_PM_QOS_MAX_FREQUENCY notifier: %d\n",
> err);
>
>
>> + err = dev_pm_qos_remove_notifier(devfreq->dev.parent, &devfreq->nb_min,
>> + DEV_PM_QOS_MIN_FREQUENCY);
>> + if (err)
>> + dev_warn(dev->parent, "Failed to remove DEV_PM_QOS_MIN_FREQUENCY notifier: %d\n",
>> + err);
>> +
>
> Please edit this line as following to protect the over 80 char
> on one line if there are no specific reason.
>
>
> dev_warn(dev->parent,
> "Failed to remove DEV_PM_QOS_MIN_FREQUENCY notifier: %d\n",
> err);
>
>
>> if (devfreq->profile->exit)
>> devfreq->profile->exit(devfreq->dev.parent);
>>
>> kfree(devfreq->time_in_state);
>> kfree(devfreq->trans_table);
>> @@ -735,10 +800,22 @@ struct devfreq *devfreq_add_device(struct device *dev,
>> if (err) {
>> put_device(&devfreq->dev);
>> goto err_out;
>> }
>>
>> + devfreq->nb_min.notifier_call = qos_min_notifier_call;
>> + err = dev_pm_qos_add_notifier(devfreq->dev.parent, &devfreq->nb_min,
>> + DEV_PM_QOS_MIN_FREQUENCY);
>> + if (err)
>> + goto err_devfreq;
>> +
>> + devfreq->nb_max.notifier_call = qos_max_notifier_call;
>> + err = dev_pm_qos_add_notifier(devfreq->dev.parent, &devfreq->nb_max,
>> + DEV_PM_QOS_MAX_FREQUENCY);
>> + if (err)
>> + goto err_devfreq;
>> +
>> mutex_lock(&devfreq_list_lock);
>>
>> governor = try_then_request_governor(devfreq->governor_name);
>> if (IS_ERR(governor)) {
>> dev_err(dev, "%s: Unable to find governor for the device\n",
>> @@ -762,10 +839,11 @@ struct devfreq *devfreq_add_device(struct device *dev,
>>
>> return devfreq;
>>
>> err_init:
>> mutex_unlock(&devfreq_list_lock);
>> +err_devfreq:
>> devfreq_remove_device(devfreq);
>> return ERR_PTR(err);
>>
>> err_dev:
>> /*
>> diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
>> index 2bae9ed3c783..8b92ccbd1962 100644
>> --- a/include/linux/devfreq.h
>> +++ b/include/linux/devfreq.h
>> @@ -134,10 +134,12 @@ struct devfreq_dev_profile {
>> * @total_trans: Number of devfreq transitions
>> * @trans_table: Statistics of devfreq transitions
>> * @time_in_state: Statistics of devfreq states
>> * @last_stat_updated: The last time stat updated
>> * @transition_notifier_list: list head of DEVFREQ_TRANSITION_NOTIFIER notifier
>> + * @nb_min: Notifier block for DEV_PM_QOS_MIN_FREQUENCY
>> + * @nb_max: Notifier block for DEV_PM_QOS_MAX_FREQUENCY
>> *
>> * This structure stores the devfreq information for a give device.
>> *
>> * Note that when a governor accesses entries in struct devfreq in its
>> * functions except for the context of callbacks defined in struct
>> @@ -176,10 +178,13 @@ struct devfreq {
>> unsigned int *trans_table;
>> unsigned long *time_in_state;
>> unsigned long last_stat_updated;
>>
>> struct srcu_notifier_head transition_notifier_list;
>> +
>> + struct notifier_block nb_min;
>> + struct notifier_block nb_max;
>> };
>>
>> struct devfreq_freqs {
>> unsigned long old;
>> unsigned long new;
>>
>
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-10-31 13:21 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-02 19:25 [PATCH v9 0/8] PM / devfreq: Add dev_pm_qos support Leonard Crestez
2019-10-02 19:25 ` [PATCH v9 1/8] PM / devfreq: Don't fail devfreq_dev_release if not in list Leonard Crestez
2019-10-02 19:25 ` [PATCH v9 2/8] PM / devfreq: Fix devfreq_notifier_call returning errno Leonard Crestez
2019-10-02 21:24 ` Matthias Kaehlcke
2019-10-02 23:47 ` Leonard Crestez
2019-10-31 2:29 ` Chanwoo Choi
2019-10-02 19:25 ` [PATCH v9 3/8] PM / devfreq: Set scaling_max_freq to max on OPP notifier error Leonard Crestez
2019-10-02 21:33 ` Matthias Kaehlcke
2019-10-31 2:21 ` Chanwoo Choi
2019-10-02 19:25 ` [PATCH v9 4/8] PM / devfreq: Move more initialization before registration Leonard Crestez
2019-10-31 3:15 ` Chanwoo Choi
2019-10-31 13:31 ` Leonard Crestez
2019-11-01 8:31 ` Chanwoo Choi
2019-11-01 14:36 ` Leonard Crestez
2019-10-02 19:25 ` [PATCH v9 5/8] PM / devfreq: Don't take lock in devfreq_add_device Leonard Crestez
2019-10-02 19:25 ` [PATCH v9 6/8] PM / devfreq: Introduce get_freq_range helper Leonard Crestez
2019-10-03 18:19 ` Matthias Kaehlcke
2019-10-03 19:16 ` Leonard Crestez
2019-10-03 19:36 ` Matthias Kaehlcke
2019-10-11 18:29 ` Matthias Kaehlcke
2019-10-31 2:44 ` Chanwoo Choi
2019-10-31 2:42 ` Chanwoo Choi
2019-10-31 13:12 ` Leonard Crestez
2019-10-02 19:25 ` [PATCH v9 7/8] PM / devfreq: Add PM QoS support Leonard Crestez
2019-10-02 22:22 ` Matthias Kaehlcke
2019-10-04 17:04 ` Matthias Kaehlcke
2019-10-31 3:01 ` Chanwoo Choi
2019-10-31 13:21 ` Leonard Crestez [this message]
2019-10-02 19:25 ` [PATCH v9 8/8] PM / devfreq: Use PM QoS for sysfs min/max_freq Leonard Crestez
2019-10-04 17:05 ` Matthias Kaehlcke
2019-10-31 3:10 ` Chanwoo Choi
2019-10-23 14:06 ` [PATCH v9 0/8] PM / devfreq: Add dev_pm_qos support Leonard Crestez
2019-10-23 16:34 ` Matthias Kaehlcke
2019-10-24 16:21 ` Leonard Crestez
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=VI1PR04MB7023B93005D2319BD30424FDEE630@VI1PR04MB7023.eurprd04.prod.outlook.com \
--to=leonard.crestez@nxp.com \
--cc=a.swigon@partner.samsung.com \
--cc=abailon@baylibre.com \
--cc=abel.vesa@nxp.com \
--cc=cw00.choi@samsung.com \
--cc=georgi.djakov@linaro.org \
--cc=krzk@kernel.org \
--cc=kyungmin.park@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-pm@vger.kernel.org \
--cc=mka@chromium.org \
--cc=myungjoo.ham@samsung.com \
--cc=ping.bai@nxp.com \
--cc=saravanak@google.com \
--cc=viresh.kumar@linaro.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;
as well as URLs for NNTP newsgroup(s).