Message ID | 1730705521-23081-5-git-send-email-shawn.lin@rock-chips.com (mailing list archive) |
---|---|
State | Handled Elsewhere, archived |
Headers | show |
Series | Initial support for RK3576 UFS controller | expand |
Hi Shawn,
kernel test robot noticed the following build warnings:
[auto build test WARNING on jejb-scsi/for-next]
[also build test WARNING on robh/for-next linus/master v6.12-rc6]
[cannot apply to mkp-scsi/for-next next-20241104]
[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/Shawn-Lin/dt-bindings-ufs-Document-Rockchip-UFS-host-controller/20241104-191810
base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
patch link: https://lore.kernel.org/r/1730705521-23081-5-git-send-email-shawn.lin%40rock-chips.com
patch subject: [PATCH v4 4/7] pmdomain: core: Introduce dev_pm_genpd_rpm_always_on()
config: x86_64-buildonly-randconfig-003-20241104 (https://download.01.org/0day-ci/archive/20241105/202411050203.kPDzy0bS-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241105/202411050203.kPDzy0bS-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411050203.kPDzy0bS-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/pmdomain/core.c: In function 'genpd_power_off':
>> drivers/pmdomain/core.c:893:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
893 | if (!pm_runtime_suspended(pdd->dev) ||
| ^~
drivers/pmdomain/core.c:898:25: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
898 | if (to_gpd_data(pdd)->rpm_always_on)
| ^~
vim +/if +893 drivers/pmdomain/core.c
29e47e2173349e drivers/base/power/domain.c Ulf Hansson 2015-09-02 837
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 838 /**
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 839 * genpd_power_off - Remove power from a given PM domain.
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 840 * @genpd: PM domain to power down.
3c64649d1cf9f3 drivers/base/power/domain.c Ulf Hansson 2017-02-17 841 * @one_dev_on: If invoked from genpd's ->runtime_suspend|resume() callback, the
3c64649d1cf9f3 drivers/base/power/domain.c Ulf Hansson 2017-02-17 842 * RPM status of the releated device is in an intermediate state, not yet turned
3c64649d1cf9f3 drivers/base/power/domain.c Ulf Hansson 2017-02-17 843 * into RPM_SUSPENDED. This means genpd_power_off() must allow one device to not
3c64649d1cf9f3 drivers/base/power/domain.c Ulf Hansson 2017-02-17 844 * be RPM_SUSPENDED, while it tries to power off the PM domain.
763663c9715f5f drivers/base/power/domain.c Yang Yingliang 2021-05-12 845 * @depth: nesting count for lockdep.
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 846 *
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 847 * If all of the @genpd's devices have been suspended and all of its subdomains
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 848 * have been powered down, remove power from @genpd.
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 849 */
2da835452a0875 drivers/base/power/domain.c Ulf Hansson 2017-02-17 850 static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
2da835452a0875 drivers/base/power/domain.c Ulf Hansson 2017-02-17 851 unsigned int depth)
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 852 {
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 853 struct pm_domain_data *pdd;
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 854 struct gpd_link *link;
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 855 unsigned int not_suspended = 0;
f63816e43d9044 drivers/base/power/domain.c Ulf Hansson 2020-09-24 856 int ret;
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 857
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 858 /*
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 859 * Do not try to power off the domain in the following situations:
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 860 * (1) The domain is already in the "power off" state.
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 861 * (2) System suspend is in progress.
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 862 */
41e2c8e0060db2 drivers/base/power/domain.c Ulf Hansson 2017-03-20 863 if (!genpd_status_on(genpd) || genpd->prepared_count > 0)
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 864 return 0;
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 865
ffaa42e8a40b7f drivers/base/power/domain.c Ulf Hansson 2017-03-20 866 /*
ffaa42e8a40b7f drivers/base/power/domain.c Ulf Hansson 2017-03-20 867 * Abort power off for the PM domain in the following situations:
ffaa42e8a40b7f drivers/base/power/domain.c Ulf Hansson 2017-03-20 868 * (1) The domain is configured as always on.
ffaa42e8a40b7f drivers/base/power/domain.c Ulf Hansson 2017-03-20 869 * (2) When the domain has a subdomain being powered on.
ffaa42e8a40b7f drivers/base/power/domain.c Ulf Hansson 2017-03-20 870 */
ed61e18a4b4e44 drivers/base/power/domain.c Leonard Crestez 2019-04-30 871 if (genpd_is_always_on(genpd) ||
ed61e18a4b4e44 drivers/base/power/domain.c Leonard Crestez 2019-04-30 872 genpd_is_rpm_always_on(genpd) ||
ed61e18a4b4e44 drivers/base/power/domain.c Leonard Crestez 2019-04-30 873 atomic_read(&genpd->sd_count) > 0)
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 874 return -EBUSY;
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 875
e7d90cfac5510f drivers/base/power/domain.c Ulf Hansson 2022-02-17 876 /*
e7d90cfac5510f drivers/base/power/domain.c Ulf Hansson 2022-02-17 877 * The children must be in their deepest (powered-off) states to allow
e7d90cfac5510f drivers/base/power/domain.c Ulf Hansson 2022-02-17 878 * the parent to be powered off. Note that, there's no need for
e7d90cfac5510f drivers/base/power/domain.c Ulf Hansson 2022-02-17 879 * additional locking, as powering on a child, requires the parent's
e7d90cfac5510f drivers/base/power/domain.c Ulf Hansson 2022-02-17 880 * lock to be acquired first.
e7d90cfac5510f drivers/base/power/domain.c Ulf Hansson 2022-02-17 881 */
e7d90cfac5510f drivers/base/power/domain.c Ulf Hansson 2022-02-17 882 list_for_each_entry(link, &genpd->parent_links, parent_node) {
e7d90cfac5510f drivers/base/power/domain.c Ulf Hansson 2022-02-17 883 struct generic_pm_domain *child = link->child;
e7d90cfac5510f drivers/base/power/domain.c Ulf Hansson 2022-02-17 884 if (child->state_idx < child->state_count - 1)
e7d90cfac5510f drivers/base/power/domain.c Ulf Hansson 2022-02-17 885 return -EBUSY;
e7d90cfac5510f drivers/base/power/domain.c Ulf Hansson 2022-02-17 886 }
e7d90cfac5510f drivers/base/power/domain.c Ulf Hansson 2022-02-17 887
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 888 list_for_each_entry(pdd, &genpd->dev_list, list_node) {
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 889 /*
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 890 * Do not allow PM domain to be powered off, when an IRQ safe
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 891 * device is part of a non-IRQ safe domain.
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 892 */
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 @893 if (!pm_runtime_suspended(pdd->dev) ||
7a02444b8fc25a drivers/base/power/domain.c Ulf Hansson 2022-05-11 894 irq_safe_dev_in_sleep_domain(pdd->dev, genpd))
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 895 not_suspended++;
f0f6da10152fb8 drivers/pmdomain/core.c Ulf Hansson 2024-11-04 896
f0f6da10152fb8 drivers/pmdomain/core.c Ulf Hansson 2024-11-04 897 /* The device may need its PM domain to stay powered on. */
f0f6da10152fb8 drivers/pmdomain/core.c Ulf Hansson 2024-11-04 898 if (to_gpd_data(pdd)->rpm_always_on)
f0f6da10152fb8 drivers/pmdomain/core.c Ulf Hansson 2024-11-04 899 return -EBUSY;
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 900 }
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 901
3c64649d1cf9f3 drivers/base/power/domain.c Ulf Hansson 2017-02-17 902 if (not_suspended > 1 || (not_suspended == 1 && !one_dev_on))
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 903 return -EBUSY;
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 904
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 905 if (genpd->gov && genpd->gov->power_down_ok) {
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 906 if (!genpd->gov->power_down_ok(&genpd->domain))
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 907 return -EAGAIN;
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 908 }
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 909
2c9b7f8772033c drivers/base/power/domain.c Ulf Hansson 2018-10-03 910 /* Default to shallowest state. */
2c9b7f8772033c drivers/base/power/domain.c Ulf Hansson 2018-10-03 911 if (!genpd->gov)
2c9b7f8772033c drivers/base/power/domain.c Ulf Hansson 2018-10-03 912 genpd->state_idx = 0;
2c9b7f8772033c drivers/base/power/domain.c Ulf Hansson 2018-10-03 913
f63816e43d9044 drivers/base/power/domain.c Ulf Hansson 2020-09-24 914 /* Don't power off, if a child domain is waiting to power on. */
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 915 if (atomic_read(&genpd->sd_count) > 0)
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 916 return -EBUSY;
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 917
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 918 ret = _genpd_power_off(genpd, true);
c6a113b52302ad drivers/base/power/domain.c Lina Iyer 2020-10-15 919 if (ret) {
c6a113b52302ad drivers/base/power/domain.c Lina Iyer 2020-10-15 920 genpd->states[genpd->state_idx].rejected++;
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 921 return ret;
c6a113b52302ad drivers/base/power/domain.c Lina Iyer 2020-10-15 922 }
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 923
49f618e1b669ef drivers/base/power/domain.c Ulf Hansson 2020-09-24 924 genpd->status = GENPD_STATE_OFF;
afece3ab9a3640 drivers/base/power/domain.c Thara Gopinath 2017-07-14 925 genpd_update_accounting(genpd);
c6a113b52302ad drivers/base/power/domain.c Lina Iyer 2020-10-15 926 genpd->states[genpd->state_idx].usage++;
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 927
8d87ae48ced2df drivers/base/power/domain.c Kees Cook 2020-07-08 928 list_for_each_entry(link, &genpd->child_links, child_node) {
8d87ae48ced2df drivers/base/power/domain.c Kees Cook 2020-07-08 929 genpd_sd_counter_dec(link->parent);
8d87ae48ced2df drivers/base/power/domain.c Kees Cook 2020-07-08 930 genpd_lock_nested(link->parent, depth + 1);
8d87ae48ced2df drivers/base/power/domain.c Kees Cook 2020-07-08 931 genpd_power_off(link->parent, false, depth + 1);
8d87ae48ced2df drivers/base/power/domain.c Kees Cook 2020-07-08 932 genpd_unlock(link->parent);
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 933 }
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 934
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 935 return 0;
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 936 }
1f8728b7adc4c2 drivers/base/power/domain.c Ulf Hansson 2017-02-17 937
Hi Shawn, kernel test robot noticed the following build warnings: [auto build test WARNING on jejb-scsi/for-next] [also build test WARNING on robh/for-next linus/master v6.12-rc6] [cannot apply to mkp-scsi/for-next next-20241104] [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/Shawn-Lin/dt-bindings-ufs-Document-Rockchip-UFS-host-controller/20241104-191810 base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next patch link: https://lore.kernel.org/r/1730705521-23081-5-git-send-email-shawn.lin%40rock-chips.com patch subject: [PATCH v4 4/7] pmdomain: core: Introduce dev_pm_genpd_rpm_always_on() config: x86_64-buildonly-randconfig-002-20241104 (https://download.01.org/0day-ci/archive/20241105/202411050317.abJatSkD-lkp@intel.com/config) compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241105/202411050317.abJatSkD-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202411050317.abJatSkD-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from drivers/pmdomain/core.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:21: In file included from include/linux/mm.h:2213: include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_" | ~~~~~~~~~~~ ^ ~~~ >> drivers/pmdomain/core.c:898:4: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation] 898 | if (to_gpd_data(pdd)->rpm_always_on) | ^ drivers/pmdomain/core.c:893:3: note: previous statement is here 893 | if (!pm_runtime_suspended(pdd->dev) || | ^ 2 warnings generated. vim +/if +898 drivers/pmdomain/core.c 837 838 /** 839 * genpd_power_off - Remove power from a given PM domain. 840 * @genpd: PM domain to power down. 841 * @one_dev_on: If invoked from genpd's ->runtime_suspend|resume() callback, the 842 * RPM status of the releated device is in an intermediate state, not yet turned 843 * into RPM_SUSPENDED. This means genpd_power_off() must allow one device to not 844 * be RPM_SUSPENDED, while it tries to power off the PM domain. 845 * @depth: nesting count for lockdep. 846 * 847 * If all of the @genpd's devices have been suspended and all of its subdomains 848 * have been powered down, remove power from @genpd. 849 */ 850 static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, 851 unsigned int depth) 852 { 853 struct pm_domain_data *pdd; 854 struct gpd_link *link; 855 unsigned int not_suspended = 0; 856 int ret; 857 858 /* 859 * Do not try to power off the domain in the following situations: 860 * (1) The domain is already in the "power off" state. 861 * (2) System suspend is in progress. 862 */ 863 if (!genpd_status_on(genpd) || genpd->prepared_count > 0) 864 return 0; 865 866 /* 867 * Abort power off for the PM domain in the following situations: 868 * (1) The domain is configured as always on. 869 * (2) When the domain has a subdomain being powered on. 870 */ 871 if (genpd_is_always_on(genpd) || 872 genpd_is_rpm_always_on(genpd) || 873 atomic_read(&genpd->sd_count) > 0) 874 return -EBUSY; 875 876 /* 877 * The children must be in their deepest (powered-off) states to allow 878 * the parent to be powered off. Note that, there's no need for 879 * additional locking, as powering on a child, requires the parent's 880 * lock to be acquired first. 881 */ 882 list_for_each_entry(link, &genpd->parent_links, parent_node) { 883 struct generic_pm_domain *child = link->child; 884 if (child->state_idx < child->state_count - 1) 885 return -EBUSY; 886 } 887 888 list_for_each_entry(pdd, &genpd->dev_list, list_node) { 889 /* 890 * Do not allow PM domain to be powered off, when an IRQ safe 891 * device is part of a non-IRQ safe domain. 892 */ 893 if (!pm_runtime_suspended(pdd->dev) || 894 irq_safe_dev_in_sleep_domain(pdd->dev, genpd)) 895 not_suspended++; 896 897 /* The device may need its PM domain to stay powered on. */ > 898 if (to_gpd_data(pdd)->rpm_always_on) 899 return -EBUSY; 900 } 901 902 if (not_suspended > 1 || (not_suspended == 1 && !one_dev_on)) 903 return -EBUSY; 904 905 if (genpd->gov && genpd->gov->power_down_ok) { 906 if (!genpd->gov->power_down_ok(&genpd->domain)) 907 return -EAGAIN; 908 } 909 910 /* Default to shallowest state. */ 911 if (!genpd->gov) 912 genpd->state_idx = 0; 913 914 /* Don't power off, if a child domain is waiting to power on. */ 915 if (atomic_read(&genpd->sd_count) > 0) 916 return -EBUSY; 917 918 ret = _genpd_power_off(genpd, true); 919 if (ret) { 920 genpd->states[genpd->state_idx].rejected++; 921 return ret; 922 } 923 924 genpd->status = GENPD_STATE_OFF; 925 genpd_update_accounting(genpd); 926 genpd->states[genpd->state_idx].usage++; 927 928 list_for_each_entry(link, &genpd->child_links, child_node) { 929 genpd_sd_counter_dec(link->parent); 930 genpd_lock_nested(link->parent, depth + 1); 931 genpd_power_off(link->parent, false, depth + 1); 932 genpd_unlock(link->parent); 933 } 934 935 return 0; 936 } 937
Hi Shawn, kernel test robot noticed the following build warnings: https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Shawn-Lin/dt-bindings-ufs-Document-Rockchip-UFS-host-controller/20241104-191810 base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next patch link: https://lore.kernel.org/r/1730705521-23081-5-git-send-email-shawn.lin%40rock-chips.com patch subject: [PATCH v4 4/7] pmdomain: core: Introduce dev_pm_genpd_rpm_always_on() config: loongarch-randconfig-r073-20241107 (https://download.01.org/0day-ci/archive/20241108/202411080432.5dWP6wRt-lkp@intel.com/config) compiler: loongarch64-linux-gcc (GCC) 14.2.0 If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org> | Closes: https://lore.kernel.org/r/202411080432.5dWP6wRt-lkp@intel.com/ New smatch warnings: drivers/pmdomain/core.c:898 genpd_power_off() warn: curly braces intended? vim +898 drivers/pmdomain/core.c 2da835452a08758 drivers/base/power/domain.c Ulf Hansson 2017-02-17 850 static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, 2da835452a08758 drivers/base/power/domain.c Ulf Hansson 2017-02-17 851 unsigned int depth) 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 852 { 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 853 struct pm_domain_data *pdd; 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 854 struct gpd_link *link; 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 855 unsigned int not_suspended = 0; f63816e43d90442 drivers/base/power/domain.c Ulf Hansson 2020-09-24 856 int ret; 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 857 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 858 /* 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 859 * Do not try to power off the domain in the following situations: 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 860 * (1) The domain is already in the "power off" state. 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 861 * (2) System suspend is in progress. 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 862 */ 41e2c8e0060db25 drivers/base/power/domain.c Ulf Hansson 2017-03-20 863 if (!genpd_status_on(genpd) || genpd->prepared_count > 0) 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 864 return 0; 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 865 ffaa42e8a40b7f1 drivers/base/power/domain.c Ulf Hansson 2017-03-20 866 /* ffaa42e8a40b7f1 drivers/base/power/domain.c Ulf Hansson 2017-03-20 867 * Abort power off for the PM domain in the following situations: ffaa42e8a40b7f1 drivers/base/power/domain.c Ulf Hansson 2017-03-20 868 * (1) The domain is configured as always on. ffaa42e8a40b7f1 drivers/base/power/domain.c Ulf Hansson 2017-03-20 869 * (2) When the domain has a subdomain being powered on. ffaa42e8a40b7f1 drivers/base/power/domain.c Ulf Hansson 2017-03-20 870 */ ed61e18a4b4e445 drivers/base/power/domain.c Leonard Crestez 2019-04-30 871 if (genpd_is_always_on(genpd) || ed61e18a4b4e445 drivers/base/power/domain.c Leonard Crestez 2019-04-30 872 genpd_is_rpm_always_on(genpd) || ed61e18a4b4e445 drivers/base/power/domain.c Leonard Crestez 2019-04-30 873 atomic_read(&genpd->sd_count) > 0) 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 874 return -EBUSY; 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 875 e7d90cfac5510f8 drivers/base/power/domain.c Ulf Hansson 2022-02-17 876 /* e7d90cfac5510f8 drivers/base/power/domain.c Ulf Hansson 2022-02-17 877 * The children must be in their deepest (powered-off) states to allow e7d90cfac5510f8 drivers/base/power/domain.c Ulf Hansson 2022-02-17 878 * the parent to be powered off. Note that, there's no need for e7d90cfac5510f8 drivers/base/power/domain.c Ulf Hansson 2022-02-17 879 * additional locking, as powering on a child, requires the parent's e7d90cfac5510f8 drivers/base/power/domain.c Ulf Hansson 2022-02-17 880 * lock to be acquired first. e7d90cfac5510f8 drivers/base/power/domain.c Ulf Hansson 2022-02-17 881 */ e7d90cfac5510f8 drivers/base/power/domain.c Ulf Hansson 2022-02-17 882 list_for_each_entry(link, &genpd->parent_links, parent_node) { e7d90cfac5510f8 drivers/base/power/domain.c Ulf Hansson 2022-02-17 883 struct generic_pm_domain *child = link->child; e7d90cfac5510f8 drivers/base/power/domain.c Ulf Hansson 2022-02-17 884 if (child->state_idx < child->state_count - 1) e7d90cfac5510f8 drivers/base/power/domain.c Ulf Hansson 2022-02-17 885 return -EBUSY; e7d90cfac5510f8 drivers/base/power/domain.c Ulf Hansson 2022-02-17 886 } e7d90cfac5510f8 drivers/base/power/domain.c Ulf Hansson 2022-02-17 887 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 888 list_for_each_entry(pdd, &genpd->dev_list, list_node) { 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 889 /* 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 890 * Do not allow PM domain to be powered off, when an IRQ safe 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 891 * device is part of a non-IRQ safe domain. 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 892 */ 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 893 if (!pm_runtime_suspended(pdd->dev) || 7a02444b8fc25ac drivers/base/power/domain.c Ulf Hansson 2022-05-11 894 irq_safe_dev_in_sleep_domain(pdd->dev, genpd)) { 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 895 not_suspended++; f0f6da10152fb8f drivers/pmdomain/core.c Ulf Hansson 2024-11-04 896 f0f6da10152fb8f drivers/pmdomain/core.c Ulf Hansson 2024-11-04 897 /* The device may need its PM domain to stay powered on. */ f0f6da10152fb8f drivers/pmdomain/core.c Ulf Hansson 2024-11-04 @898 if (to_gpd_data(pdd)->rpm_always_on) f0f6da10152fb8f drivers/pmdomain/core.c Ulf Hansson 2024-11-04 899 return -EBUSY; } 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 900 } 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 901 3c64649d1cf9f32 drivers/base/power/domain.c Ulf Hansson 2017-02-17 902 if (not_suspended > 1 || (not_suspended == 1 && !one_dev_on)) 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 903 return -EBUSY; 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 904 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 905 if (genpd->gov && genpd->gov->power_down_ok) { 1f8728b7adc4c2b drivers/base/power/domain.c Ulf Hansson 2017-02-17 906 if (!genpd->gov->power_down_ok(&genpd->domain))
diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index 5ede0f7..02bb5c8 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -692,6 +692,36 @@ bool dev_pm_genpd_get_hwmode(struct device *dev) } EXPORT_SYMBOL_GPL(dev_pm_genpd_get_hwmode); +/** + * dev_pm_genpd_rpm_always_on() - Control if the PM domain can be powered off. + * + * @dev: Device for which the PM domain may need to stay on for. + * @on: Value to set or unset for the condition. + * + * For some usecases a consumer driver requires its device to remain power-on + * from the PM domain perspective during runtime. This function allows the + * behaviour to be dynamically controlled for a device attached to a genpd. + * + * It is assumed that the users guarantee that the genpd wouldn't be detached + * while this routine is getting called. + * + * Return: Returns 0 on success and negative error values on failures. + */ +int dev_pm_genpd_rpm_always_on(struct device *dev, bool on) +{ + struct generic_pm_domain *genpd; + + genpd = dev_to_genpd_safe(dev); + if (!genpd) + return -ENODEV; + + genpd_lock(genpd); + dev_gpd_data(dev)->rpm_always_on = on; + genpd_unlock(genpd); + + return 0; +} + static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed) { unsigned int state_idx = genpd->state_idx; @@ -863,6 +893,10 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, if (!pm_runtime_suspended(pdd->dev) || irq_safe_dev_in_sleep_domain(pdd->dev, genpd)) not_suspended++; + + /* The device may need its PM domain to stay powered on. */ + if (to_gpd_data(pdd)->rpm_always_on) + return -EBUSY; } if (not_suspended > 1 || (not_suspended == 1 && !one_dev_on)) diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index b637ec1..30186ad 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -245,6 +245,7 @@ struct generic_pm_domain_data { unsigned int default_pstate; unsigned int rpm_pstate; bool hw_mode; + bool rpm_always_on; void *data; }; @@ -277,6 +278,7 @@ ktime_t dev_pm_genpd_get_next_hrtimer(struct device *dev); void dev_pm_genpd_synced_poweroff(struct device *dev); int dev_pm_genpd_set_hwmode(struct device *dev, bool enable); bool dev_pm_genpd_get_hwmode(struct device *dev); +int dev_pm_genpd_rpm_always_on(struct device *dev, bool on); extern struct dev_power_governor simple_qos_governor; extern struct dev_power_governor pm_domain_always_on_gov; @@ -360,6 +362,11 @@ static inline bool dev_pm_genpd_get_hwmode(struct device *dev) return false; } +static inline int dev_pm_genpd_rpm_always_on(struct device *dev, bool on) +{ + return -EOPNOTSUPP; +} + #define simple_qos_governor (*(struct dev_power_governor *)(NULL)) #define pm_domain_always_on_gov (*(struct dev_power_governor *)(NULL)) #endif