From: Chanwoo Choi <cw00.choi@samsung.com>
To: Leonard Crestez <leonard.crestez@nxp.com>,
MyungJoo Ham <myungjoo.ham@samsung.com>,
Kyungmin Park <kyungmin.park@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,
"Viresh Kumar" <viresh.kumar@linaro.org>,
"Krzysztof Kozlowski" <krzk@kernel.org>,
"Alexandre Bailon" <abailon@baylibre.com>,
"Georgi Djakov" <georgi.djakov@linaro.org>,
linux-arm-kernel@lists.infradead.org,
"Jacky Bai" <ping.bai@nxp.com>
Subject: Re: [PATCH 8/8] PM / devfreq: Move opp notifier registration to core
Date: Tue, 1 Oct 2019 06:49:27 +0900 [thread overview]
Message-ID: <efdec5cf-c434-0b53-93c2-d39d5f264fae@samsung.com> (raw)
In-Reply-To: <974c2bd6d6e622e47c85af65a200b4079d25002b.1568764439.git.leonard.crestez@nxp.com>
On 19. 9. 18. 오전 9:18, Leonard Crestez wrote:
> An opp notifier can be registered by devfreq in order to respond to OPPs
> being enabled or disabled at runtime (for example by thermal). This is
> currently handled explicitly by drivers.
>
> Move notifier handling to devfreq_add_device because this shouldn't be
> hardware-specific.
>
> Handling this inside the core also takes less code.
>
> Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
> ---
> drivers/devfreq/devfreq.c | 84 +++---------------------------------
> drivers/devfreq/exynos-bus.c | 7 ---
> drivers/devfreq/rk3399_dmc.c | 6 ---
> include/linux/devfreq.h | 8 ----
> 4 files changed, 6 insertions(+), 99 deletions(-)
>
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 7977bad93949..b9177430ae8f 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -663,10 +663,11 @@ static void devfreq_dev_release(struct device *dev)
>
> mutex_lock(&devfreq_list_lock);
> list_del(&devfreq->node);
> mutex_unlock(&devfreq_list_lock);
>
> + dev_pm_opp_unregister_notifier(devfreq->dev.parent, &devfreq->nb);
> dev_pm_qos_remove_notifier(devfreq->dev.parent, &devfreq->nb_max,
> DEV_PM_QOS_MAX_FREQUENCY);
> dev_pm_qos_remove_notifier(devfreq->dev.parent, &devfreq->nb_min,
> DEV_PM_QOS_MIN_FREQUENCY);
>
> @@ -728,11 +729,10 @@ struct devfreq *devfreq_add_device(struct device *dev,
> devfreq->profile = profile;
> strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
> devfreq->previous_freq = profile->initial_freq;
> devfreq->last_status.current_frequency = profile->initial_freq;
> devfreq->data = data;
> - devfreq->nb.notifier_call = devfreq_notifier_call;
>
> if (!devfreq->profile->max_state && !devfreq->profile->freq_table) {
> err = set_freq_table(devfreq);
> if (err < 0)
> goto err_dev;
> @@ -810,10 +810,15 @@ struct devfreq *devfreq_add_device(struct device *dev,
> err = dev_pm_qos_add_notifier(devfreq->dev.parent, &devfreq->nb_max,
> DEV_PM_QOS_MAX_FREQUENCY);
> if (err)
> goto err_devfreq;
>
> + devfreq->nb.notifier_call = devfreq_notifier_call;
> + err = dev_pm_opp_register_notifier(devfreq->dev.parent, &devfreq->nb);
> + 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",
> @@ -1624,87 +1629,10 @@ struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
>
> return opp;
> }
> EXPORT_SYMBOL(devfreq_recommended_opp);
>
> -/**
> - * devfreq_register_opp_notifier() - Helper function to get devfreq notified
> - * for any changes in the OPP availability
> - * changes
> - * @dev: The devfreq user device. (parent of devfreq)
> - * @devfreq: The devfreq object.
> - */
> -int devfreq_register_opp_notifier(struct device *dev, struct devfreq *devfreq)
> -{
> - return dev_pm_opp_register_notifier(dev, &devfreq->nb);
> -}
> -EXPORT_SYMBOL(devfreq_register_opp_notifier);
> -
> -/**
> - * devfreq_unregister_opp_notifier() - Helper function to stop getting devfreq
> - * notified for any changes in the OPP
> - * availability changes anymore.
> - * @dev: The devfreq user device. (parent of devfreq)
> - * @devfreq: The devfreq object.
> - *
> - * At exit() callback of devfreq_dev_profile, this must be included if
> - * devfreq_recommended_opp is used.
> - */
> -int devfreq_unregister_opp_notifier(struct device *dev, struct devfreq *devfreq)
> -{
> - return dev_pm_opp_unregister_notifier(dev, &devfreq->nb);
> -}
> -EXPORT_SYMBOL(devfreq_unregister_opp_notifier);
> -
> -static void devm_devfreq_opp_release(struct device *dev, void *res)
> -{
> - devfreq_unregister_opp_notifier(dev, *(struct devfreq **)res);
> -}
> -
> -/**
> - * devm_devfreq_register_opp_notifier() - Resource-managed
> - * devfreq_register_opp_notifier()
> - * @dev: The devfreq user device. (parent of devfreq)
> - * @devfreq: The devfreq object.
> - */
> -int devm_devfreq_register_opp_notifier(struct device *dev,
> - struct devfreq *devfreq)
> -{
> - struct devfreq **ptr;
> - int ret;
> -
> - ptr = devres_alloc(devm_devfreq_opp_release, sizeof(*ptr), GFP_KERNEL);
> - if (!ptr)
> - return -ENOMEM;
> -
> - ret = devfreq_register_opp_notifier(dev, devfreq);
> - if (ret) {
> - devres_free(ptr);
> - return ret;
> - }
> -
> - *ptr = devfreq;
> - devres_add(dev, ptr);
> -
> - return 0;
> -}
> -EXPORT_SYMBOL(devm_devfreq_register_opp_notifier);
> -
> -/**
> - * devm_devfreq_unregister_opp_notifier() - Resource-managed
> - * devfreq_unregister_opp_notifier()
> - * @dev: The devfreq user device. (parent of devfreq)
> - * @devfreq: The devfreq object.
> - */
> -void devm_devfreq_unregister_opp_notifier(struct device *dev,
> - struct devfreq *devfreq)
> -{
> - WARN_ON(devres_release(dev, devm_devfreq_opp_release,
> - devm_devfreq_dev_match, devfreq));
> -}
> -EXPORT_SYMBOL(devm_devfreq_unregister_opp_notifier);
> -
> /**
> * devfreq_register_notifier() - Register a driver with devfreq
> * @devfreq: The devfreq object.
> * @nb: The notifier block to register.
> * @list: DEVFREQ_TRANSITION_NOTIFIER.
> diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
> index c832673273a2..29f422469960 100644
> --- a/drivers/devfreq/exynos-bus.c
> +++ b/drivers/devfreq/exynos-bus.c
> @@ -356,17 +356,10 @@ static int exynos_bus_probe(struct platform_device *pdev)
> dev_err(dev, "failed to add devfreq device\n");
> ret = PTR_ERR(bus->devfreq);
> goto err;
> }
>
> - /* Register opp_notifier to catch the change of OPP */
> - ret = devm_devfreq_register_opp_notifier(dev, bus->devfreq);
> - if (ret < 0) {
> - dev_err(dev, "failed to register opp notifier\n");
> - goto err;
> - }
> -
> /*
> * Enable devfreq-event to get raw data which is used to determine
> * current bus load.
> */
> ret = exynos_bus_enable_edev(bus);
> diff --git a/drivers/devfreq/rk3399_dmc.c b/drivers/devfreq/rk3399_dmc.c
> index 2e65d7279d79..f660d2031e8a 100644
> --- a/drivers/devfreq/rk3399_dmc.c
> +++ b/drivers/devfreq/rk3399_dmc.c
> @@ -454,12 +454,10 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
> if (IS_ERR(data->devfreq)) {
> ret = PTR_ERR(data->devfreq);
> goto err_free_opp;
> }
>
> - devm_devfreq_register_opp_notifier(dev, data->devfreq);
> -
> data->dev = dev;
> platform_set_drvdata(pdev, data);
>
> return 0;
>
> @@ -470,14 +468,10 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
>
> static int rk3399_dmcfreq_remove(struct platform_device *pdev)
> {
> struct rk3399_dmcfreq *dmcfreq = dev_get_drvdata(&pdev->dev);
>
> - /*
> - * Before remove the opp table we need to unregister the opp notifier.
> - */
> - devm_devfreq_unregister_opp_notifier(dmcfreq->dev, dmcfreq->devfreq);
> dev_pm_opp_of_remove_table(dmcfreq->dev);
>
> return 0;
> }
>
> diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
> index 4b5cc80abbe3..bf6ebfbc1e8a 100644
> --- a/include/linux/devfreq.h
> +++ b/include/linux/devfreq.h
> @@ -220,18 +220,10 @@ extern void devfreq_resume(void);
> extern int update_devfreq(struct devfreq *devfreq);
>
> /* Helper functions for devfreq user device driver with OPP. */
> extern struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
> unsigned long *freq, u32 flags);
> -extern int devfreq_register_opp_notifier(struct device *dev,
> - struct devfreq *devfreq);
> -extern int devfreq_unregister_opp_notifier(struct device *dev,
> - struct devfreq *devfreq);
> -extern int devm_devfreq_register_opp_notifier(struct device *dev,
> - struct devfreq *devfreq);
> -extern void devm_devfreq_unregister_opp_notifier(struct device *dev,
> - struct devfreq *devfreq);
> extern int devfreq_register_notifier(struct devfreq *devfreq,
> struct notifier_block *nb,
> unsigned int list);
> extern int devfreq_unregister_notifier(struct devfreq *devfreq,
> struct notifier_block *nb,
>
It looks good to me.
But, this patch don't remove the inline functions in devfreq.h.
- devfreq_register_opp_notifier
- devfreq_unregister_opp_notifier
- devm_devfreq_register_opp_notifier
- devm_devfreq_unregister_opp_notifier
--
Best Regards,
Chanwoo Choi
Samsung Electronics
_______________________________________________
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-09-30 21:44 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-18 0:18 [PATCH 0/8] PM / devfreq: Add dev_pm_qos support Leonard Crestez
2019-09-18 0:18 ` [PATCH 1/8] PM / devfreq: Lock devfreq in trans_stat_show Leonard Crestez
2019-09-18 21:28 ` Matthias Kaehlcke
2019-09-19 18:42 ` Leonard Crestez
2019-09-19 19:25 ` Matthias Kaehlcke
2019-09-18 0:18 ` [PATCH 2/8] PM / devfreq: Don't fail devfreq_dev_release if not in list Leonard Crestez
2019-09-18 21:41 ` Matthias Kaehlcke
2019-09-18 0:18 ` [PATCH 3/8] PM / devfreq: Move more initialization before registration Leonard Crestez
2019-09-18 23:29 ` Matthias Kaehlcke
2019-09-19 0:14 ` Matthias Kaehlcke
2019-09-19 18:52 ` Leonard Crestez
2019-09-19 19:16 ` Matthias Kaehlcke
2019-09-18 0:18 ` [PATCH 4/8] PM / devfreq: Don't take lock in devfreq_add_device Leonard Crestez
2019-09-19 0:20 ` Matthias Kaehlcke
2019-09-18 0:18 ` [PATCH 5/8] PM / devfreq: Introduce devfreq_get_freq_range Leonard Crestez
2019-09-19 18:07 ` Matthias Kaehlcke
2019-09-18 0:18 ` [PATCH 6/8] PM / devfreq: Add dev_pm_qos support Leonard Crestez
2019-09-19 19:12 ` Matthias Kaehlcke
2019-09-18 0:18 ` [PATCH 7/8] PM / devfreq: Use dev_pm_qos for sysfs min/max_freq Leonard Crestez
2019-09-19 19:59 ` Matthias Kaehlcke
2019-09-20 13:50 ` Leonard Crestez
2019-09-18 0:18 ` [PATCH 8/8] PM / devfreq: Move opp notifier registration to core Leonard Crestez
2019-09-30 21:49 ` Chanwoo Choi [this message]
2019-10-01 15:14 ` 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=efdec5cf-c434-0b53-93c2-d39d5f264fae@samsung.com \
--to=cw00.choi@samsung.com \
--cc=a.swigon@partner.samsung.com \
--cc=abailon@baylibre.com \
--cc=abel.vesa@nxp.com \
--cc=georgi.djakov@linaro.org \
--cc=krzk@kernel.org \
--cc=kyungmin.park@samsung.com \
--cc=leonard.crestez@nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@vger.kernel.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).