Message ID | 20230308230931.27261-5-semen.protsenko@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | soc: samsung: pm_domains: Add Exynos850 support | expand |
Hi Sam,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on krzk/for-next]
[also build test WARNING on robh/for-next krzk-dt/for-next linus/master v6.3-rc1 next-20230308]
[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/Sam-Protsenko/dt-bindings-power-pd-samsung-Add-Exynos850-support/20230309-071202
base: https://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux.git for-next
patch link: https://lore.kernel.org/r/20230308230931.27261-5-semen.protsenko%40linaro.org
patch subject: [PATCH 4/6] soc: samsung: pm_domains: Implement proper I/O operations
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230309/202303090824.TjEOnQJ8-lkp@intel.com/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/2dabd70f9264ef6cd044de6c3cbd3d83bfef8442
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Sam-Protsenko/dt-bindings-power-pd-samsung-Add-Exynos850-support/20230309-071202
git checkout 2dabd70f9264ef6cd044de6c3cbd3d83bfef8442
# 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/soc/samsung/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303090824.TjEOnQJ8-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/soc/samsung/pm_domains.c: In function 'exynos_pd_power':
>> drivers/soc/samsung/pm_domains.c:74:23: warning: variable 'base' set but not used [-Wunused-but-set-variable]
74 | void __iomem *base;
| ^~~~
vim +/base +74 drivers/soc/samsung/pm_domains.c
2dabd70f9264ef drivers/soc/samsung/pm_domains.c Sam Protsenko 2023-03-08 70
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 71 static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 72 {
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 73 struct exynos_pm_domain *pd;
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 @74 void __iomem *base;
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 75 u32 timeout, pwr;
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 76 char *op;
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 77
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 78 pd = container_of(domain, struct exynos_pm_domain, pd);
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 79 base = pd->base;
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 80
c028e175713698 drivers/soc/samsung/pm_domains.c Krzysztof Kozlowski 2016-05-10 81 pwr = power_on ? pd->local_pwr_cfg : 0;
2dabd70f9264ef drivers/soc/samsung/pm_domains.c Sam Protsenko 2023-03-08 82 exynos_pd_write_conf(pd, pwr);
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 83
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 84 /* Wait max 1ms */
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 85 timeout = 10;
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 86
2dabd70f9264ef drivers/soc/samsung/pm_domains.c Sam Protsenko 2023-03-08 87 while (exynos_pd_read_status(pd) != pwr) {
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 88 if (!timeout) {
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 89 op = (power_on) ? "enable" : "disable";
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 90 pr_err("Power domain %s %s failed\n", domain->name, op);
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 91 return -ETIMEDOUT;
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 92 }
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 93 timeout--;
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 94 cpu_relax();
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 95 usleep_range(80, 100);
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 96 }
c760569d0e9c06 arch/arm/mach-exynos/pm_domains.c Prathyush K 2014-07-11 97
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 98 return 0;
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 99 }
91cfbd4ee0875f arch/arm/mach-exynos/pm_domains.c Thomas Abraham 2012-01-27 100
diff --git a/drivers/soc/samsung/pm_domains.c b/drivers/soc/samsung/pm_domains.c index 522a43005a5a..dd1ec3541e11 100644 --- a/drivers/soc/samsung/pm_domains.c +++ b/drivers/soc/samsung/pm_domains.c @@ -18,6 +18,10 @@ #include <linux/of_platform.h> #include <linux/pm_runtime.h> +/* Register offsets inside Power Domain area in PMU */ +#define EXYNOS_PD_CONF 0x0 +#define EXYNOS_PD_STATUS 0x4 + struct exynos_pm_domain_config { /* Value for LOCAL_PWR_CFG and STATUS fields for each domain */ u32 local_pwr_cfg; @@ -33,6 +37,37 @@ struct exynos_pm_domain { u32 local_pwr_cfg; }; +static void exynos_pd_write(struct exynos_pm_domain *pd, unsigned int reg, + unsigned int mask, unsigned int val) +{ + u32 v; + + v = readl_relaxed(pd->base + reg); + v = (v & ~mask) | val; + writel_relaxed(v, pd->base + reg); +} + +static void exynos_pd_read(struct exynos_pm_domain *pd, unsigned int reg, + unsigned int *val) +{ + *val = readl_relaxed(pd->base + reg); +} + +static unsigned int exynos_pd_read_status(struct exynos_pm_domain *pd) +{ + unsigned int val; + + exynos_pd_read(pd, EXYNOS_PD_STATUS, &val); + val &= pd->local_pwr_cfg; + + return val; +} + +static void exynos_pd_write_conf(struct exynos_pm_domain *pd, u32 val) +{ + exynos_pd_write(pd, EXYNOS_PD_CONF, pd->local_pwr_cfg, val); +} + static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on) { struct exynos_pm_domain *pd; @@ -44,12 +79,12 @@ static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on) base = pd->base; pwr = power_on ? pd->local_pwr_cfg : 0; - writel_relaxed(pwr, base); + exynos_pd_write_conf(pd, pwr); /* Wait max 1ms */ timeout = 10; - while ((readl_relaxed(base + 0x4) & pd->local_pwr_cfg) != pwr) { + while (exynos_pd_read_status(pd) != pwr) { if (!timeout) { op = (power_on) ? "enable" : "disable"; pr_err("Power domain %s %s failed\n", domain->name, op); @@ -135,8 +170,7 @@ static int exynos_pd_probe(struct platform_device *pdev) pd->pd.power_off = exynos_pd_power_off; pd->pd.power_on = exynos_pd_power_on; - on = readl_relaxed(pd->base + 0x4) & pd->local_pwr_cfg; - + on = exynos_pd_read_status(pd); pm_genpd_init(&pd->pd, NULL, !on); ret = of_genpd_add_provider_simple(np, &pd->pd);
Instead of doing in-place readl()/writel() calls fed with magic numbers, provide dedicated read/write functions which implement proper register accesses: - Get rid of magic numbers by introducing actual constants for PD registers - Rework the write function to perform a RMW operation, as PD registers have some bits markes as "Reserved" in TRM, which shouldn't be changed - Add helper functions for reading the STATUS reg and writing CONFIGURATION reg, to make user code more neat and clean New functions are designed in such a way that it's easy to rework those further on top of regmap API. Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org> --- drivers/soc/samsung/pm_domains.c | 42 +++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-)