Allow genpd providers to power off domains on sync state
Subsystems (9)
v2 cover Allow genpd providers to power off domains on sync state
There have been already a couple of tries to make the genpd "disable unused" late initcall skip the powering off of domains that might be needed until later on (i.e. until some consumer probes). The conclusion was that the provider could return -EBUSY from the power_off callback until the provider's sync state has been reached. This patch series tries to provide a proof-of-concept that is working on Qualcomm platforms.
I've been doing extensive testing on SM8450, but I've also spinned this on my X13s (SC8280XP). Both patches that add the sync state callback to the SC8280XP and SM8450 are here to provide context. Once we agree on the form, I intend to add the sync state callback to all gdsc providers.
Currently, some of the gdsc providers might not reach sync state due to list of consumers not probing yet (or at all). The sync state can be enforced by writing 1 to the state_synced sysfs attribute of the provider, thanks to Saravana's commit [1] which has been already merged.
[1] https://lore.kernel.org/r/[email protected]
V1 of this patchset was here:
https://lore.kernel.org/all/[email protected]/
Changes since v1:
* Added the qcom_cc sync state callback which calls in turn the gdsc one
* dropped extra semicolon from pm_domain.h
Abel Vesa (5):
PM: domains: Allow power off queuing from providers
soc: qcom: rpmhpd: Do proper power off when state synced
clk: qcom: gdsc: Avoid actual power off until sync state
clk: qcom: Add sync state callback to all SC8280XP providers
clk: qcom: Add sync state callback to all SM8450 providers
drivers/base/power/domain.c | 3 ++- drivers/clk/qcom/camcc-sm8450.c | 1 + drivers/clk/qcom/common.c | 19 +++++++++++++++++++ drivers/clk/qcom/common.h | 2 ++ drivers/clk/qcom/dispcc-sc8280xp.c | 1 + drivers/clk/qcom/dispcc-sm8450.c | 1 + drivers/clk/qcom/gcc-sc8280xp.c | 1 + drivers/clk/qcom/gcc-sm8450.c | 1 + drivers/clk/qcom/gdsc.c | 26 ++++++++++++++++++++++++++ drivers/clk/qcom/gdsc.h | 6 ++++++ drivers/clk/qcom/gpucc-sc8280xp.c | 1 + drivers/soc/qcom/rpmhpd.c | 19 +++++++------------ include/linux/pm_domain.h | 6 ++++++ 13 files changed, 74 insertions(+), 13 deletions(-)
Signature · 1 line
2.34.1
RFC PATCH v2 1/5 PM: domains: Allow power off queuing from providers
In some cases, the providers might choose to refuse powering off some domains until all of the consumer have had a chance to probe, that is, until sync state callback has been called. Such providers might choose to disable such domains on their on, from the sync state callback. So, in order to do that, they need a way to queue up a power off request. Since the generic genpd already has such API, make that available to those providers.
--- drivers/base/power/domain.c | 3 ++- include/linux/pm_domain.h | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/base/power/domain.c +2 -1
@@ -649,10 +649,11 @@ static int _genpd_power_off(struct generic_pm_domain *genpd, bool timed)* Queue up the execution of genpd_power_off() unless it's already been done * before. */ -static void genpd_queue_power_off_work (struct generic_pm_domain *genpd) +void genpd_queue_power_off_work (struct generic_pm_domain *genpd) {queue_work (pm_wq, &genpd->power_off_work); } +EXPORT_SYMBOL_GPL (genpd_queue_power_off_work);/** * genpd_power_off - Remove power from a given PM domain.
include/linux/pm_domain.h +6 -0
@@ -231,6 +231,7 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,int pm_genpd_init (struct generic_pm_domain *genpd,struct dev_power_governor *gov,bool is_off);int pm_genpd_remove (struct generic_pm_domain *genpd); +void genpd_queue_power_off_work (struct generic_pm_domain *genpd);int dev_pm_genpd_set_performance_state (struct device *dev,unsigned int state);int dev_pm_genpd_add_notifier (struct device *dev,struct notifier_block *nb);int dev_pm_genpd_remove_notifier (struct device *dev);
@@ -278,6 +279,11 @@ static inline int pm_genpd_remove(struct generic_pm_domain *genpd)return -EOPNOTSUPP ; } +void genpd_queue_power_off_work (struct generic_pm_domain *genpd) +{ +return -EOPNOTSUPP ; +} +static inline int dev_pm_genpd_set_performance_state (struct device *dev,unsigned int state) {
Signature · 1 line
2.34.1
kernel test robot
build botRe: [RFC PATCH v2 1/5] PM: domains: Allow power off queuing from providers
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in…
Hi Abel,
[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on clk/clk-next]
[also build test WARNING on rafael-pm/linux-next linus/master pavel-leds/for-next v6.3-rc3 next-20230320] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Abel-Vesa/PM-domains-Allow-power-off-queuing-from-providers/20230320-214327 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next patch link: https://lore.kernel.org/r/20230320134217.1685781-2-abel.vesa%40linaro.org patch subject: [RFC PATCH v2 1/5] PM: domains: Allow power off queuing from providers config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230321/[email protected]/config) compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/fef66120c9d99388e95560573d2e0c92c7a547c8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Abel-Vesa/PM-domains-Allow-power-off-queuing-from-providers/20230320-214327 git checkout fef66120c9d99388e95560573d2e0c92c7a547c8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/base/power/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from drivers/base/power/clock_ops.c:18:
>> include/linux/pm_domain.h:282:6: warning: no previous prototype for 'genpd_queue_power_off_work' [-Wmissing-prototypes]
282 | void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/pm_domain.h: In function 'genpd_queue_power_off_work':
include/linux/pm_domain.h:284:16: error: 'return' with a value, in function returning void [-Werror=return-type]
284 | return -EOPNOTSUPP;
| ^ include/linux/pm_domain.h:282:6: note: declared here
282 | void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/genpd_queue_power_off_work +282 include/linux/pm_domain.h
281
> 282 void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
283 {
284 return -EOPNOTSUPP;
285 }
286
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
kernel test robot
build botRe: [RFC PATCH v2 1/5] PM: domains: Allow power off queuing from providers
In reply to Abel Vesa[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in…
Hi Abel,
[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on clk/clk-next]
[also build test WARNING on rafael-pm/linux-next linus/master v6.3-rc3 next-20230320] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Abel-Vesa/PM-domains-Allow-power-off-queuing-from-providers/20230320-214327 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next patch link: https://lore.kernel.org/r/20230320134217.1685781-2-abel.vesa%40linaro.org patch subject: [RFC PATCH v2 1/5] PM: domains: Allow power off queuing from providers config: arm-randconfig-r036-20230319 (https://download.01.org/0day-ci/archive/20230321/[email protected]/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/intel-lab-lkp/linux/commit/fef66120c9d99388e95560573d2e0c92c7a547c8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Abel-Vesa/PM-domains-Allow-power-off-queuing-from-providers/20230320-214327 git checkout fef66120c9d99388e95560573d2e0c92c7a547c8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/char/tpm/ drivers/opp/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from drivers/opp/core.c:18:
include/linux/pm_domain.h:284:2: error: void function 'genpd_queue_power_off_work' should not return a value [-Wreturn-type]
return -EOPNOTSUPP;
^ ~~~~~~~~~~~
>> include/linux/pm_domain.h:282:6: warning: no previous prototype for function 'genpd_queue_power_off_work' [-Wmissing-prototypes]
void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
^
include/linux/pm_domain.h:282:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
^
static
In file included from drivers/opp/core.c:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:97:11: warning: array index 3 is past the end of the array (that has type 'unsigned long[2]') [-Warray-bounds]
return (set->sig[3] | set->sig[2] |
^ ~
arch/arm/include/asm/signal.h:17:2: note: array 'sig' declared here
unsigned long sig[_NSIG_WORDS];
^
In file included from drivers/opp/core.c:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:97:25: warning: array index 2 is past the end of the array (that has type 'unsigned long[2]') [-Warray-bounds]
return (set->sig[3] | set->sig[2] |
^ ~
arch/arm/include/asm/signal.h:17:2: note: array 'sig' declared here
unsigned long sig[_NSIG_WORDS];
^
In file included from drivers/opp/core.c:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:113:11: warning: array index 3 is past the end of the array (that has type 'const unsigned long[2]') [-Warray-bounds]
return (set1->sig[3] == set2->sig[3]) &&
^ ~
arch/arm/include/asm/signal.h:17:2: note: array 'sig' declared here
unsigned long sig[_NSIG_WORDS];
^
In file included from drivers/opp/core.c:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:113:27: warning: array index 3 is past the end of the array (that has type 'const unsigned long[2]') [-Warray-bounds]
return (set1->sig[3] == set2->sig[3]) &&
^ ~
arch/arm/include/asm/signal.h:17:2: note: array 'sig' declared here
unsigned long sig[_NSIG_WORDS];
^
In file included from drivers/opp/core.c:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:114:5: warning: array index 2 is past the end of the array (that has type 'const unsigned long[2]') [-Warray-bounds]
(set1->sig[2] == set2->sig[2]) &&
^ ~
arch/arm/include/asm/signal.h:17:2: note: array 'sig' declared here
unsigned long sig[_NSIG_WORDS];
^
In file included from drivers/opp/core.c:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:114:21: warning: array index 2 is past the end of the array (that has type 'const unsigned long[2]') [-Warray-bounds]
(set1->sig[2] == set2->sig[2]) &&
^ ~ arch/arm/include/asm/signal.h:17:2: note: array 'sig' declared here
--
In file included from drivers/opp/of.c:17:
include/linux/pm_domain.h:284:2: error: void function 'genpd_queue_power_off_work' should not return a value [-Wreturn-type]
return -EOPNOTSUPP;
^ ~~~~~~~~~~~
>> include/linux/pm_domain.h:282:6: warning: no previous prototype for function 'genpd_queue_power_off_work' [-Wmissing-prototypes]
void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
^ include/linux/pm_domain.h:282:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
^
static
1 warning and 1 error generated.
vim +/genpd_queue_power_off_work +282 include/linux/pm_domain.h
281
> 282 void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
283 {
284 return -EOPNOTSUPP;
285 }
286
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
kernel test robot
build botRe: [RFC PATCH v2 1/5] PM: domains: Allow power off queuing from providers
In reply to Abel Vesa[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in…
Hi Abel,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on clk/clk-next]
[also build test ERROR on rafael-pm/linux-next linus/master pavel-leds/for-next v6.3-rc3 next-20230320] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Abel-Vesa/PM-domains-Allow-power-off-queuing-from-providers/20230320-214327 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next patch link: https://lore.kernel.org/r/20230320134217.1685781-2-abel.vesa%40linaro.org patch subject: [RFC PATCH v2 1/5] PM: domains: Allow power off queuing from providers config: i386-randconfig-a004-20230320 (https://download.01.org/0day-ci/archive/20230321/[email protected]/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/fef66120c9d99388e95560573d2e0c92c7a547c8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Abel-Vesa/PM-domains-Allow-power-off-queuing-from-providers/20230320-214327 git checkout fef66120c9d99388e95560573d2e0c92c7a547c8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from drivers/base/platform.c:25:
>> include/linux/pm_domain.h:284:2: error: void function 'genpd_queue_power_off_work' should not return a value [-Wreturn-type]
return -EOPNOTSUPP;
^ ~~~~~~~~~~~
include/linux/pm_domain.h:282:6: warning: no previous prototype for function 'genpd_queue_power_off_work' [-Wmissing-prototypes]
void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
^ include/linux/pm_domain.h:282:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
^
static
1 warning and 1 error generated.
--
In file included from drivers/acpi/device_pm.c:19:
>> include/linux/pm_domain.h:284:2: error: void function 'genpd_queue_power_off_work' should not return a value [-Wreturn-type]
return -EOPNOTSUPP;
^ ~~~~~~~~~~~
include/linux/pm_domain.h:282:6: warning: no previous prototype for function 'genpd_queue_power_off_work' [-Wmissing-prototypes]
void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
^
include/linux/pm_domain.h:282:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
^
static
In file included from drivers/acpi/device_pm.c:21:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:97:11: warning: array index 3 is past the end of the array (which contains 2 elements) [-Warray-bounds]
return (set->sig[3] | set->sig[2] |
^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
unsigned long sig[_NSIG_WORDS];
^
In file included from drivers/acpi/device_pm.c:21:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:97:25: warning: array index 2 is past the end of the array (which contains 2 elements) [-Warray-bounds]
return (set->sig[3] | set->sig[2] |
^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
unsigned long sig[_NSIG_WORDS];
^
In file included from drivers/acpi/device_pm.c:21:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:113:11: warning: array index 3 is past the end of the array (which contains 2 elements) [-Warray-bounds]
return (set1->sig[3] == set2->sig[3]) &&
^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
unsigned long sig[_NSIG_WORDS];
^
In file included from drivers/acpi/device_pm.c:21:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:113:27: warning: array index 3 is past the end of the array (which contains 2 elements) [-Warray-bounds]
return (set1->sig[3] == set2->sig[3]) &&
^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
unsigned long sig[_NSIG_WORDS];
^
In file included from drivers/acpi/device_pm.c:21:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:114:5: warning: array index 2 is past the end of the array (which contains 2 elements) [-Warray-bounds]
(set1->sig[2] == set2->sig[2]) &&
^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
unsigned long sig[_NSIG_WORDS];
^
In file included from drivers/acpi/device_pm.c:21:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:114:21: warning: array index 2 is past the end of the array (which contains 2 elements) [-Warray-bounds]
(set1->sig[2] == set2->sig[2]) &&
^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
unsigned long sig[_NSIG_WORDS];
^ In file included from drivers/acpi/device_pm.c:21:
vim +/genpd_queue_power_off_work +284 include/linux/pm_domain.h
281
282 void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
283 {
> 284 return -EOPNOTSUPP;
285 }
286
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Re: [RFC PATCH v2 1/5] PM: domains: Allow power off queuing from providers
In reply to Abel VesaQuoted 3 lines · Abel Vesa
In some cases, the providers might choose to refuse powering off some domains until all of the consumer have had a chance to probe, that is,
/s/consumer/consumers
Quoted 2 lines
until sync state callback has been called. Such providers might choose to disable such domains on their on, from the sync state callback. So,
/s/their on/their own
Quoted 15 lines
in order to do that, they need a way to queue up a power off request. Since the generic genpd already has such API, make that available to those providers.
Signed-off-by Abel Vesa <[email protected]>--- drivers/base/power/domain.c | 3 ++- include/linux/pm_domain.h | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-)drivers/base/power/domain.c +0
-0
drivers/base/power/domain.c static int _genpd_power_off(struct generic_pm_domain *genpd, bool timed) · line 652
Quoted 4 lines
drivers/base/power/domain.c +0
-1@@ -649,10 +649,11 @@ static int _genpd_power_off(struct generic_pm_domain *genpd, bool timed)* Queue up the execution of genpd_power_off() unless it's already been done * before. */ -static void genpd_queue_power_off_work (struct generic_pm_domain *genpd)
Please add a function description - and make sure to state that its external use is explicitly intended for being called from genpd providers ->sync_state callbacks.
drivers/base/power/domain.c static int _genpd_power_off(struct generic_pm_domain *genpd, bool timed) · line 652
Quoted 1 line
drivers/base/power/domain.c +1
-0+void genpd_queue_power_off_work (struct generic_pm_domain *genpd)
As this becomes an exported function, we should also conform to genpd's function naming rules, which is to use the "pm_genpd_*" prefix.
While renaming it, perhaps it's sufficient with "pm_genpd_queue_power_off" or maybe even better "pm_genpd_sync_state", what do you think?
Quoted 32 lines
drivers/base/power/domain.c +1
-0{queue_work (pm_wq, &genpd->power_off_work); } +EXPORT_SYMBOL_GPL (genpd_queue_power_off_work);/** * genpd_power_off - Remove power from a given PM domain. include/linux/pm_domain.h +6
-1@@ -231,6 +231,7 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,int pm_genpd_init (struct generic_pm_domain *genpd,struct dev_power_governor *gov,bool is_off);int pm_genpd_remove (struct generic_pm_domain *genpd); +void genpd_queue_power_off_work (struct generic_pm_domain *genpd);int dev_pm_genpd_set_performance_state (struct device *dev,unsigned int state);int dev_pm_genpd_add_notifier (struct device *dev,struct notifier_block *nb);int dev_pm_genpd_remove_notifier (struct device *dev);@@ -278,6 +279,11 @@ static inline int pm_genpd_remove(struct generic_pm_domain *genpd)return -EOPNOTSUPP ; } +void genpd_queue_power_off_work (struct generic_pm_domain *genpd) +{ +return -EOPNOTSUPP ; +} +static inline int dev_pm_genpd_set_performance_state (struct device *dev,unsigned int state) { --
Quoted 2 lines
2.34.1
Other than the minor things above, the approach looks reasonable to me!
Kind regards
Uffe
RFC PATCH v2 2/5 soc: qcom: rpmhpd: Do proper power off when state synced
In reply to Abel VesaInstead of aggregating different corner values on sync state callback, call the genpd API for queuing up the power off. This will also mark the domain as powered off in the debugfs genpd summary. Also, until sync state has been reached, return busy on power off request, in order to allow genpd core to know that the actual domain hasn't been powered of from the "disable unused" late initcall.
--- drivers/soc/qcom/rpmhpd.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/soc/qcom/rpmhpd.c +7 -12
@@ -649,8 +649,12 @@ static int rpmhpd_power_off(struct generic_pm_domain *domain)mutex_lock (&rpmhpd_lock); ret =rpmhpd_aggregate_corner (pd,0 ); -if (!ret) - pd->enabled = false; +if (!ret) { +if (!pd->state_synced) + ret = -EBUSY ; +else + pd->enabled = false; + }mutex_unlock (&rpmhpd_lock);
@@ -810,10 +814,8 @@ static void rpmhpd_sync_state(struct device *dev) {const struct rpmhpd_desc *desc =of_device_get_match_data (dev);struct rpmhpd **rpmhpds = desc->rpmhpds; -unsigned int corner;struct rpmhpd *pd;unsigned int i; -int ret;mutex_lock (&rpmhpd_lock);for (i =0 ; i < desc->num_pds; i++) {
@@ -822,14 +824,7 @@ static void rpmhpd_sync_state(struct device *dev)continue ; pd->state_synced = true; -if (pd->enabled) - corner =max (pd->corner, pd->enable_corner); -else - corner =0 ; - - ret =rpmhpd_aggregate_corner (pd, corner); -if (ret) -dev_err (dev,"failed to sync %s\n" , pd->res_name); +genpd_queue_power_off_work (&pd->pd); }mutex_unlock (&rpmhpd_lock); }
Signature · 1 line
2.34.1
RFC PATCH v2 3/5 clk: qcom: gdsc: Avoid actual power off until sync state
In reply to Abel VesaIn case there is a sync state callback registered for a provider, do not actually power off any gdsc for that provider until sync state has been reached and return busy instead. Since the qcom_cc is private, add a helper that returns the gdsc_desc based on the device of the provider. Finally, add the generic gdsc sync state callback to be used by the platform specific providers.
--- drivers/clk/qcom/common.c | 19 +++++++++++++++++++ drivers/clk/qcom/common.h | 2 ++ drivers/clk/qcom/gdsc.c | 26 ++++++++++++++++++++++++++ drivers/clk/qcom/gdsc.h | 6 ++++++ 4 files changed, 53 insertions(+)
drivers/clk/qcom/common.c +19 -0
@@ -20,6 +20,7 @@struct qcom_cc {struct qcom_reset_controller reset;struct clk_regmap **rclks; +struct gdsc_desc *scd;size_t num_rclks; };
@@ -234,6 +235,13 @@ static struct clk_hw *qcom_cc_clk_hw_get(struct of_phandle_args *clkspec,return cc->rclks[idx] ? &cc->rclks[idx]->hw :NULL ; } +struct gdsc_desc *qcom_cc_get_gdsc_desc (struct device *dev) +{ +struct qcom_cc *cc =dev_get_drvdata (dev); + +return cc->scd; +} +int qcom_cc_really_probe (struct platform_device *pdev,const struct qcom_cc_desc *desc,struct regmap *regmap) {
@@ -251,6 +259,8 @@ int qcom_cc_really_probe(struct platform_device *pdev,if (!cc)return -ENOMEM ; +dev_set_drvdata (dev, cc); + reset = &cc->reset; reset->rcdev.of_node = dev->of_node; reset->rcdev.ops = &qcom_reset_ops;
@@ -267,6 +277,9 @@ int qcom_cc_really_probe(struct platform_device *pdev, scd =devm_kzalloc (dev,sizeof (*scd),GFP_KERNEL );if (!scd)return -ENOMEM ; + + cc->scd = scd; + scd->dev = dev; scd->scs = desc->gdscs; scd->num = desc->num_gdscs;
@@ -319,6 +332,12 @@ int qcom_cc_probe(struct platform_device *pdev, const struct qcom_cc_desc *desc) }EXPORT_SYMBOL_GPL (qcom_cc_probe); +void qcom_cc_sync_state (struct device *dev) +{ +gdsc_sync_state (dev); +} +EXPORT_SYMBOL_GPL (qcom_cc_sync_state); +int qcom_cc_probe_by_index (struct platform_device *pdev,int index,const struct qcom_cc_desc *desc) {
drivers/clk/qcom/common.h +2 -0
@@ -61,9 +61,11 @@ extern struct regmap *qcom_cc_map(struct platform_device *pdev,extern int qcom_cc_really_probe (struct platform_device *pdev,const struct qcom_cc_desc *desc,struct regmap *regmap); +extern struct gdsc_desc *qcom_cc_get_gdsc_desc (struct device *dev);extern int qcom_cc_probe (struct platform_device *pdev,const struct qcom_cc_desc *desc);extern int qcom_cc_probe_by_index (struct platform_device *pdev,int index,const struct qcom_cc_desc *desc); +extern void qcom_cc_sync_state (struct device *dev);#endif
drivers/clk/qcom/gdsc.c +26 -0
@@ -15,6 +15,8 @@#include <linux/regulator/consumer.h> #include <linux/reset-controller.h> #include <linux/slab.h> + +#include "common.h" #include "gdsc.h" #define PWR_ON_MASK BIT(31)
@@ -319,6 +321,9 @@ static int gdsc_disable(struct generic_pm_domain *domain)struct gdsc *sc =domain_to_gdsc (domain);int ret; +if (!sc->state_synced) +return -EBUSY ; +if (sc->pwrsts ==PWRSTS_ON )return gdsc_assert_reset (sc);
@@ -365,6 +370,7 @@ static int gdsc_disable(struct generic_pm_domain *domain)static int gdsc_init (struct gdsc *sc) { +struct device *dev = sc->dev;u32 mask, val;int on, ret;
@@ -452,6 +458,9 @@ static int gdsc_init(struct gdsc *sc)if (!sc->pd.power_on) sc->pd.power_on = gdsc_enable; +if (!dev_has_sync_state (dev)) + sc->state_synced = true; + ret =pm_genpd_init (&sc->pd,NULL , !on);if (ret) goto err_disable_supply;
@@ -496,6 +505,7 @@ int gdsc_register(struct gdsc_desc *desc,for (i =0 ; i < num; i++) {if (!scs[i])continue ; + scs[i]->dev = dev; scs[i]->regmap = regmap; scs[i]->rcdev = rcdev; ret =gdsc_init (scs[i]);
@@ -536,6 +546,22 @@ void gdsc_unregister(struct gdsc_desc *desc)of_genpd_del_provider (dev->of_node); } +void gdsc_sync_state (struct device *dev) +{ +struct gdsc_desc *scd =qcom_cc_get_gdsc_desc (dev); +struct gdsc **scs = scd->scs; +size_t num = scd->num; +int i; + +for (i =0 ; i < num; i++) { +if (!scs[i]) +continue ; + + scs[i]->state_synced = true; +genpd_queue_power_off_work (&scs[i]->pd); + } +} +/* * On SDM845+ the GPU GX domain is *almost* entirely controlled by the GMU * running in the CX domain so the CPU doesn't need to know anything about the
drivers/clk/qcom/gdsc.h +6 -0
@@ -35,6 +35,7 @@ struct gdsc {struct generic_pm_domain pd;struct generic_pm_domain *parent;struct regmap *regmap; +struct device *dev;unsigned int gdscr;unsigned int collapse_ctrl;unsigned int collapse_mask;
@@ -73,6 +74,8 @@ struct gdsc {const char *supply;struct regulator *rsupply; + +bool state_synced; };struct gdsc_desc {
@@ -86,6 +89,7 @@ int gdsc_register(struct gdsc_desc *desc, struct reset_controller_dev *, struct regmap *);void gdsc_unregister (struct gdsc_desc *desc);int gdsc_gx_do_nothing_enable (struct generic_pm_domain *domain); +void gdsc_sync_state (struct device *dev);#else static inline int gdsc_register(struct gdsc_desc *desc, struct reset_controller_dev *rcdev,
@@ -94,6 +98,8 @@ static inline int gdsc_register(struct gdsc_desc *desc,return -ENOSYS ; } +static inline void gdsc_sync_state (struct device *dev) { } +static inline void gdsc_unregister (struct gdsc_desc *desc) {};#endif /* CONFIG_QCOM_GDSC */ #endif /* __QCOM_GDSC_H__ */
Signature · 1 line
2.34.1
RFC PATCH v2 4/5 clk: qcom: Add sync state callback to all SC8280XP providers
In reply to Abel VesaNow that we have support for sync state delayed disabling of unused power domains and a provided generic gdsc sync state callback, add it to all the providers related to the SC8280XP platform.
--- drivers/clk/qcom/dispcc-sc8280xp.c | 1 + drivers/clk/qcom/gcc-sc8280xp.c | 1 + drivers/clk/qcom/gpucc-sc8280xp.c | 1 + 3 files changed, 3 insertions(+)
drivers/clk/qcom/dispcc-sc8280xp.c +1 -0
@@ -3199,6 +3199,7 @@ static struct platform_driver disp_cc_sc8280xp_driver = { .driver = { .name = "disp_cc-sc8280xp", .of_match_table = disp_cc_sc8280xp_match_table, + .sync_state = qcom_cc_sync_state, }, };
drivers/clk/qcom/gcc-sc8280xp.c +1 -0
@@ -7441,6 +7441,7 @@ static struct platform_driver gcc_sc8280xp_driver = { .driver = { .name = "gcc-sc8280xp", .of_match_table = gcc_sc8280xp_match_table, + .sync_state = qcom_cc_sync_state, }, };
drivers/clk/qcom/gpucc-sc8280xp.c +1 -0
@@ -453,6 +453,7 @@ static struct platform_driver gpu_cc_sc8280xp_driver = { .driver = { .name = "gpu_cc-sc8280xp", .of_match_table = gpu_cc_sc8280xp_match_table, + .sync_state = qcom_cc_sync_state, }, };module_platform_driver (gpu_cc_sc8280xp_driver);
Signature · 1 line
2.34.1
RFC PATCH v2 5/5 clk: qcom: Add sync state callback to all SM8450 providers
In reply to Abel VesaNow that we have support for sync state delayed disabling of unused power domains and a provided generic gdsc sync state callback, add it to all the providers related to the SM8450 platform.
--- drivers/clk/qcom/camcc-sm8450.c | 1 + drivers/clk/qcom/dispcc-sm8450.c | 1 + drivers/clk/qcom/gcc-sm8450.c | 1 + 3 files changed, 3 insertions(+)
drivers/clk/qcom/camcc-sm8450.c +1 -0
@@ -2847,6 +2847,7 @@ static struct platform_driver cam_cc_sm8450_driver = { .driver = { .name = "camcc-sm8450", .of_match_table = cam_cc_sm8450_match_table, + .sync_state = qcom_cc_sync_state, }, };
drivers/clk/qcom/dispcc-sm8450.c +1 -0
@@ -1803,6 +1803,7 @@ static struct platform_driver disp_cc_sm8450_driver = { .driver = { .name = "disp_cc-sm8450", .of_match_table = disp_cc_sm8450_match_table, + .sync_state = qcom_cc_sync_state, }, };
drivers/clk/qcom/gcc-sm8450.c +1 -0
@@ -3262,6 +3262,7 @@ static struct platform_driver gcc_sm8450_driver = { .driver = { .name = "gcc-sm8450", .of_match_table = gcc_sm8450_match_table, + .sync_state = qcom_cc_sync_state, }, };
Signature · 1 line
2.34.1
Quoted 34 lines · Abel Vesa
There have been already a couple of tries to make the genpd "disable unused" late initcall skip the powering off of domains that might be needed until later on (i.e. until some consumer probes). The conclusion was that the provider could return
-EBUSYfrom thepower_offcallback until the provider's sync state has been reached. This patch series tries to provide a proof-of-concept that is working on Qualcomm platforms.I've been doing extensive testing on SM8450, but I've also spinned this on my X13s (SC8280XP). Both patches that add the sync state callback to the SC8280XP and SM8450 are here to provide context. Once we agree on the form, I intend to add the sync state callback to all gdsc providers.
Currently, some of the gdsc providers might not reach sync state due to list of consumers not probing yet (or at all). The sync state can be enforced by writing 1 to the
state_syncedsysfs attribute of the provider, thanks to Saravana's commit [1] which has been already merged.[1] https://lore.kernel.org/r/[email protected]
V1 of this patchset was here:
https://lore.kernel.org/all/[email protected]/Changes since v1:
* Added theqcom_ccsync state callback which calls in turn the gdsc one
* dropped extra semicolon frompm_domain.hAbel Vesa (5):
PM: domains: Allow power off queuing from providers
soc: qcom: rpmhpd: Do proper power off when state synced
clk: qcom: gdsc: Avoid actual power off until sync state
clk: qcom: Add sync state callback to all SC8280XP providers
clk: qcom: Add sync state callback to all SM8450 providers
Quoted 15 lines
drivers/base/power/domain.c | 3 ++- drivers/clk/qcom/camcc-sm8450.c | 1 + drivers/clk/qcom/common.c | 19 +++++++++++++++++++ drivers/clk/qcom/common.h | 2 ++ drivers/clk/qcom/dispcc-sc8280xp.c | 1 + drivers/clk/qcom/dispcc-sm8450.c | 1 + drivers/clk/qcom/gcc-sc8280xp.c | 1 + drivers/clk/qcom/gcc-sm8450.c | 1 + drivers/clk/qcom/gdsc.c | 26 ++++++++++++++++++++++++++ drivers/clk/qcom/gdsc.h | 6 ++++++ drivers/clk/qcom/gpucc-sc8280xp.c | 1 + drivers/soc/qcom/rpmhpd.c | 19 +++++++------------ include/linux/pm_domain.h | 6 ++++++ 13 files changed, 74 insertions(+), 13 deletions(-)
Besides the minor comments on patch1, this looks good to me! So, feel free to add:
Kind regards
Uffe