[v8,0/6] PM / devfreq: Add dev_pm_qos support
mbox series

Message ID cover.1569319738.git.leonard.crestez@nxp.com
Headers show
Series
  • PM / devfreq: Add dev_pm_qos support
Related show

Message

Leonard Crestez Sept. 24, 2019, 10:11 a.m. UTC
Add dev_pm_qos notifiers to devfreq core in order to support frequency
limits via dev_pm_qos_add_request.

Unlike the rest of devfreq the dev_pm_qos frequency is measured in Khz,
this is consistent with current dev_pm_qos usage for cpufreq and
allows frequencies above 2Ghz (pm_qos expresses limits as s32).

Like with cpufreq the handling of min_freq/max_freq is moved to the
dev_pm_qos mechanism. Constraints from userspace are no longer clamped on
store, instead all values can be written and we only check against OPPs in a
new devfreq_get_freq_range function. This is consistent with the design of
dev_pm_qos.

Notifiers from pm_qos are executed under a single global dev_pm_qos_mtx and
need to take devfreq->lock. Notifier registration takes the same dev_pm_qos_mtx
so in order to prevent lockdep warnings it must be done outside devfreq->lock.
Current devfreq_add_device does all initialization under devfreq->lock and that
needs to be relaxed.

---
Changes since v7:
* Only #define HZ_PER_KHZ in patch where it's used.
* Drop devfreq_ prefix for some internal functions.
* Improve qos update error message.
* Remove some unnecessary comments.
* Collect reviews
Link to v7: https://patchwork.kernel.org/cover/11157649/

Changes since v6:
* Don't return errno from devfreq_qos_notifier_call, return NOTIFY_DONE
and print the error.
* More spelling and punctuation nits
Link to v6: https://patchwork.kernel.org/cover/11157201/

Changes since v5:
* Drop patches which are not strictly related to PM QoS.
* Add a comment explaining why devfreq_add_device needs two cleanup paths.
* Remove {} for single line.
* Rename {min,max}_freq_req to user_{min,max}_freq_req
* Collect reviews
Link to v5: https://patchwork.kernel.org/cover/11149497/

Sorry for forgetting to properly label v5. I know this is inside the
merge window but review would still be appreciated.

Changes since v4:
* Move more devfreq_add_device init ahead of device_register.
* Make devfreq_dev_release cleanup devices not yet in devfreq_list. This is
simpler than previous attempt to add to devfreq_list sonner.
* Take devfreq->lock in trans_stat_show
* Register dev_pm_opp notifier on devfreq parent dev (which has OPPs)
Link to v4: https://patchwork.kernel.org/cover/11114657/

Changes since v4:
* Move more devfreq_add_device init ahead of device_register.
* Make devfreq_dev_release cleanup devices not yet in devfreq_list. This is
simpler than previous attempt to add to devfreq_list sonner.
* Take devfreq->lock in trans_stat_show
* Register dev_pm_opp notifier on devfreq parent dev (which has OPPs)
Like to v4: https://patchwork.kernel.org/cover/11114657/

Changes since v3:
* Cleanup locking and error-handling in devfreq_add_device
* Register notifiers after device registration but before governor start
* Keep the initialization of min_req/max_req ahead of device_register
because it's used for sysfs handling
* Use HZ_PER_KHZ instead of 1000
* Add kernel-doc comments
* Move OPP notifier to core
Link to v3: https://patchwork.kernel.org/cover/11104061/

Changes since v2:
* Handle sysfs via dev_pm_qos (in separate patch)
* Add locking to {min,max}_freq_show
* Fix checkpatch issues (long lines etc)
Link to v2: https://patchwork.kernel.org/patch/11084279/

Changes since v1:
* Add doxygen comments for min_nb/max_nb
* Remove notifiers on error/cleanup paths. Keep gotos simple by relying on
dev_pm_qos_remove_notifier ignoring notifiers which were not added.
Link to v1: https://patchwork.kernel.org/patch/11078475/

Leonard Crestez (6):
  PM / devfreq: Don't fail devfreq_dev_release if not in list
  PM / devfreq: Move more initialization before registration
  PM / devfreq: Don't take lock in devfreq_add_device
  PM / devfreq: Introduce get_freq_range helper
  PM / devfreq: Add PM QoS support
  PM / devfreq: Use PM QoS for sysfs min/max_freq

 drivers/devfreq/devfreq.c | 268 +++++++++++++++++++++++++-------------
 include/linux/devfreq.h   |  14 +-
 2 files changed, 191 insertions(+), 91 deletions(-)

Comments

Chanwoo Choi Sept. 25, 2019, 1:44 a.m. UTC | #1
Hi Leonard,

Basically, I think that these series are very important.

But, you better to send the next version patch
after finishing the review/discussion on previous version.

I reviewed the v7 and then you replied your comment.
It is OK. But, you just send v8 without waiting my comment
from your reply. It is not efficient discussion method.

If we finish the review of some point in the v7,
it doesn't need to discuss the same comment on v8. 

Please wait the reply for review. I think that
it can save the our time for the review and contribution.


On 19. 9. 24. 오후 7:11, Leonard Crestez wrote:
> Add dev_pm_qos notifiers to devfreq core in order to support frequency
> limits via dev_pm_qos_add_request.
> 
> Unlike the rest of devfreq the dev_pm_qos frequency is measured in Khz,
> this is consistent with current dev_pm_qos usage for cpufreq and
> allows frequencies above 2Ghz (pm_qos expresses limits as s32).
> 
> Like with cpufreq the handling of min_freq/max_freq is moved to the
> dev_pm_qos mechanism. Constraints from userspace are no longer clamped on
> store, instead all values can be written and we only check against OPPs in a
> new devfreq_get_freq_range function. This is consistent with the design of
> dev_pm_qos.
> 
> Notifiers from pm_qos are executed under a single global dev_pm_qos_mtx and
> need to take devfreq->lock. Notifier registration takes the same dev_pm_qos_mtx
> so in order to prevent lockdep warnings it must be done outside devfreq->lock.
> Current devfreq_add_device does all initialization under devfreq->lock and that
> needs to be relaxed.
> 
> ---
> Changes since v7:
> * Only #define HZ_PER_KHZ in patch where it's used.
> * Drop devfreq_ prefix for some internal functions.
> * Improve qos update error message.
> * Remove some unnecessary comments.
> * Collect reviews
> Link to v7: https://patchwork.kernel.org/cover/11157649/
> 
> Changes since v6:
> * Don't return errno from devfreq_qos_notifier_call, return NOTIFY_DONE
> and print the error.
> * More spelling and punctuation nits
> Link to v6: https://patchwork.kernel.org/cover/11157201/
> 
> Changes since v5:
> * Drop patches which are not strictly related to PM QoS.
> * Add a comment explaining why devfreq_add_device needs two cleanup paths.
> * Remove {} for single line.
> * Rename {min,max}_freq_req to user_{min,max}_freq_req
> * Collect reviews
> Link to v5: https://patchwork.kernel.org/cover/11149497/
> 
> Sorry for forgetting to properly label v5. I know this is inside the
> merge window but review would still be appreciated.
> 
> Changes since v4:
> * Move more devfreq_add_device init ahead of device_register.
> * Make devfreq_dev_release cleanup devices not yet in devfreq_list. This is
> simpler than previous attempt to add to devfreq_list sonner.
> * Take devfreq->lock in trans_stat_show
> * Register dev_pm_opp notifier on devfreq parent dev (which has OPPs)
> Link to v4: https://patchwork.kernel.org/cover/11114657/
> 
> Changes since v4:
> * Move more devfreq_add_device init ahead of device_register.
> * Make devfreq_dev_release cleanup devices not yet in devfreq_list. This is
> simpler than previous attempt to add to devfreq_list sonner.
> * Take devfreq->lock in trans_stat_show
> * Register dev_pm_opp notifier on devfreq parent dev (which has OPPs)
> Like to v4: https://patchwork.kernel.org/cover/11114657/
> 
> Changes since v3:
> * Cleanup locking and error-handling in devfreq_add_device
> * Register notifiers after device registration but before governor start
> * Keep the initialization of min_req/max_req ahead of device_register
> because it's used for sysfs handling
> * Use HZ_PER_KHZ instead of 1000
> * Add kernel-doc comments
> * Move OPP notifier to core
> Link to v3: https://patchwork.kernel.org/cover/11104061/
> 
> Changes since v2:
> * Handle sysfs via dev_pm_qos (in separate patch)
> * Add locking to {min,max}_freq_show
> * Fix checkpatch issues (long lines etc)
> Link to v2: https://patchwork.kernel.org/patch/11084279/
> 
> Changes since v1:
> * Add doxygen comments for min_nb/max_nb
> * Remove notifiers on error/cleanup paths. Keep gotos simple by relying on
> dev_pm_qos_remove_notifier ignoring notifiers which were not added.
> Link to v1: https://patchwork.kernel.org/patch/11078475/
> 
> Leonard Crestez (6):
>   PM / devfreq: Don't fail devfreq_dev_release if not in list
>   PM / devfreq: Move more initialization before registration
>   PM / devfreq: Don't take lock in devfreq_add_device
>   PM / devfreq: Introduce get_freq_range helper
>   PM / devfreq: Add PM QoS support
>   PM / devfreq: Use PM QoS for sysfs min/max_freq
> 
>  drivers/devfreq/devfreq.c | 268 +++++++++++++++++++++++++-------------
>  include/linux/devfreq.h   |  14 +-
>  2 files changed, 191 insertions(+), 91 deletions(-)
>
Leonard Crestez Sept. 25, 2019, 7:37 p.m. UTC | #2
On 25.09.2019 04:40, Chanwoo Choi wrote:
> Hi Leonard,
> 
> Basically, I think that these series are very important.
> 
> But, you better to send the next version patch
> after finishing the review/discussion on previous version.
> 
> I reviewed the v7 and then you replied your comment.
> It is OK. But, you just send v8 without waiting my comment
> from your reply. It is not efficient discussion method.
> 
> If we finish the review of some point in the v7,
> it doesn't need to discuss the same comment on v8.
> 
> Please wait the reply for review. I think that
> it can save the our time for the review and contribution.

Sorry.

I already incorporated a large number of the changes in v7 so I thought 
I'd post the new version already.

> On 19. 9. 24. 오후 7:11, Leonard Crestez wrote:
>> Add dev_pm_qos notifiers to devfreq core in order to support frequency
>> limits via dev_pm_qos_add_request.
>>
>> Unlike the rest of devfreq the dev_pm_qos frequency is measured in Khz,
>> this is consistent with current dev_pm_qos usage for cpufreq and
>> allows frequencies above 2Ghz (pm_qos expresses limits as s32).
>>
>> Like with cpufreq the handling of min_freq/max_freq is moved to the
>> dev_pm_qos mechanism. Constraints from userspace are no longer clamped on
>> store, instead all values can be written and we only check against OPPs in a
>> new devfreq_get_freq_range function. This is consistent with the design of
>> dev_pm_qos.
>>
>> Notifiers from pm_qos are executed under a single global dev_pm_qos_mtx and
>> need to take devfreq->lock. Notifier registration takes the same dev_pm_qos_mtx
>> so in order to prevent lockdep warnings it must be done outside devfreq->lock.
>> Current devfreq_add_device does all initialization under devfreq->lock and that
>> needs to be relaxed.
>>
>> ---
>> Changes since v7:
>> * Only #define HZ_PER_KHZ in patch where it's used.
>> * Drop devfreq_ prefix for some internal functions.
>> * Improve qos update error message.
>> * Remove some unnecessary comments.
>> * Collect reviews
>> Link to v7: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fcover%2F11157649%2F&data=02%7C01%7Cleonard.crestez%40nxp.com%7Cb4e87dc885c64c7fe83d08d741594dcb%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637049724139242058&sdata=mbxGHSFiLylBMcuoA4ABoyClJq0ELiZtr9QytMnPT7w%3D&reserved=0
>>
>> Changes since v6:
>> * Don't return errno from devfreq_qos_notifier_call, return NOTIFY_DONE
>> and print the error.
>> * More spelling and punctuation nits
>> Link to v6: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fcover%2F11157201%2F&data=02%7C01%7Cleonard.crestez%40nxp.com%7Cb4e87dc885c64c7fe83d08d741594dcb%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637049724139242058&sdata=ry1hAJ8Gb5zmefVDRMOup5E2agQ8lrha4MxU66kN27U%3D&reserved=0
>>
>> Changes since v5:
>> * Drop patches which are not strictly related to PM QoS.
>> * Add a comment explaining why devfreq_add_device needs two cleanup paths.
>> * Remove {} for single line.
>> * Rename {min,max}_freq_req to user_{min,max}_freq_req
>> * Collect reviews
>> Link to v5: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fcover%2F11149497%2F&data=02%7C01%7Cleonard.crestez%40nxp.com%7Cb4e87dc885c64c7fe83d08d741594dcb%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637049724139242058&sdata=ShneYomxXC1gUt5hU4agsZH%2FLfsHvxO%2FiaCNDGKsv94%3D&reserved=0
>>
>> Sorry for forgetting to properly label v5. I know this is inside the
>> merge window but review would still be appreciated.
>>
>> Changes since v4:
>> * Move more devfreq_add_device init ahead of device_register.
>> * Make devfreq_dev_release cleanup devices not yet in devfreq_list. This is
>> simpler than previous attempt to add to devfreq_list sonner.
>> * Take devfreq->lock in trans_stat_show
>> * Register dev_pm_opp notifier on devfreq parent dev (which has OPPs)
>> Link to v4: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fcover%2F11114657%2F&data=02%7C01%7Cleonard.crestez%40nxp.com%7Cb4e87dc885c64c7fe83d08d741594dcb%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637049724139242058&sdata=n3f%2Fd86jzWTG005SPrikbUOg%2FaGpf7LMZRoVrwybqSk%3D&reserved=0
>>
>> Changes since v4:
>> * Move more devfreq_add_device init ahead of device_register.
>> * Make devfreq_dev_release cleanup devices not yet in devfreq_list. This is
>> simpler than previous attempt to add to devfreq_list sonner.
>> * Take devfreq->lock in trans_stat_show
>> * Register dev_pm_opp notifier on devfreq parent dev (which has OPPs)
>> Like to v4: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fcover%2F11114657%2F&data=02%7C01%7Cleonard.crestez%40nxp.com%7Cb4e87dc885c64c7fe83d08d741594dcb%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637049724139242058&sdata=n3f%2Fd86jzWTG005SPrikbUOg%2FaGpf7LMZRoVrwybqSk%3D&reserved=0
>>
>> Changes since v3:
>> * Cleanup locking and error-handling in devfreq_add_device
>> * Register notifiers after device registration but before governor start
>> * Keep the initialization of min_req/max_req ahead of device_register
>> because it's used for sysfs handling
>> * Use HZ_PER_KHZ instead of 1000
>> * Add kernel-doc comments
>> * Move OPP notifier to core
>> Link to v3: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fcover%2F11104061%2F&data=02%7C01%7Cleonard.crestez%40nxp.com%7Cb4e87dc885c64c7fe83d08d741594dcb%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637049724139242058&sdata=XXzabOjV26KBso7j7BC%2BGTdIiKxiFUNmf3P5q1vXgbs%3D&reserved=0
>>
>> Changes since v2:
>> * Handle sysfs via dev_pm_qos (in separate patch)
>> * Add locking to {min,max}_freq_show
>> * Fix checkpatch issues (long lines etc)
>> Link to v2: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fpatch%2F11084279%2F&data=02%7C01%7Cleonard.crestez%40nxp.com%7Cb4e87dc885c64c7fe83d08d741594dcb%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637049724139242058&sdata=3CB%2FD82NoBKd%2FAREWaI%2FTl9uIPLXxz6e%2Fhzd3msRGcw%3D&reserved=0
>>
>> Changes since v1:
>> * Add doxygen comments for min_nb/max_nb
>> * Remove notifiers on error/cleanup paths. Keep gotos simple by relying on
>> dev_pm_qos_remove_notifier ignoring notifiers which were not added.
>> Link to v1: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fpatch%2F11078475%2F&data=02%7C01%7Cleonard.crestez%40nxp.com%7Cb4e87dc885c64c7fe83d08d741594dcb%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637049724139242058&sdata=tqOV6t0KUvFtUWxHrzAwVozZ4sKrylmuvdtiFSW3FV4%3D&reserved=0
>>
>> Leonard Crestez (6):
>>    PM / devfreq: Don't fail devfreq_dev_release if not in list
>>    PM / devfreq: Move more initialization before registration
>>    PM / devfreq: Don't take lock in devfreq_add_device
>>    PM / devfreq: Introduce get_freq_range helper
>>    PM / devfreq: Add PM QoS support
>>    PM / devfreq: Use PM QoS for sysfs min/max_freq
>>
>>   drivers/devfreq/devfreq.c | 268 +++++++++++++++++++++++++-------------
>>   include/linux/devfreq.h   |  14 +-
>>   2 files changed, 191 insertions(+), 91 deletions(-)
>>
>