mmc: sdhci-omap: Add Support for Suspend/Resume
Subsystems (3)
PATCH 1/1 mmc: sdhci-omap: Add Support for Suspend/Resume
Add power management ops which save and restore the driver context and facilitate a system suspend and resume.
--- drivers/mmc/host/sdhci-omap.c | 59 +++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
drivers/mmc/host/sdhci-omap.c +59 -0
@@ -108,6 +108,11 @@ struct sdhci_omap_host {struct pinctrl *pinctrl;struct pinctrl_state **pinctrl_state;bool is_tuning; +/* Omap specific context save */ +u32 con; +u32 hctl; +u32 sysctl; +u32 capa; };static void sdhci_omap_start_clock (struct sdhci_omap_host *omap_host);
@@ -1233,11 +1238,65 @@ static int sdhci_omap_remove(struct platform_device *pdev)return 0 ; } +static void sdhci_omap_context_save (struct sdhci_omap_host *omap_host) +{ + omap_host->con =sdhci_omap_readl (omap_host,SDHCI_OMAP_CON ); + omap_host->hctl =sdhci_omap_readl (omap_host,SDHCI_OMAP_HCTL ); + omap_host->sysctl =sdhci_omap_readl (omap_host,SDHCI_OMAP_SYSCTL ); + omap_host->capa =sdhci_omap_readl (omap_host,SDHCI_OMAP_CAPA ); +} + +static void sdhci_omap_context_restore (struct sdhci_omap_host *omap_host) +{ +sdhci_omap_writel (omap_host,SDHCI_OMAP_CON , omap_host->con); +sdhci_omap_writel (omap_host,SDHCI_OMAP_HCTL , omap_host->hctl); +sdhci_omap_writel (omap_host,SDHCI_OMAP_SYSCTL , omap_host->sysctl); +sdhci_omap_writel (omap_host,SDHCI_OMAP_CAPA , omap_host->capa); +} + +static int __maybe_unused sdhci_omap_suspend (struct device *dev) +{ +struct sdhci_host *host =dev_get_drvdata (dev); +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct sdhci_omap_host *omap_host =sdhci_pltfm_priv (pltfm_host); + +sdhci_suspend_host (host); + +sdhci_omap_context_save (omap_host); + +pinctrl_pm_select_idle_state (dev); + +pm_runtime_put_sync (dev); + +return 0 ; +} + +static int __maybe_unused sdhci_omap_resume (struct device *dev) +{ +struct sdhci_host *host =dev_get_drvdata (dev); +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct sdhci_omap_host *omap_host =sdhci_pltfm_priv (pltfm_host); + +pm_runtime_get_sync (dev); + +pinctrl_pm_select_default_state (dev); + +sdhci_omap_context_restore (omap_host); + +sdhci_resume_host (host); + +return 0 ; +} + +static SIMPLE_DEV_PM_OPS(sdhci_omap_dev_pm_ops, sdhci_omap_suspend, + sdhci_omap_resume); +static struct platform_driver sdhci_omap_driver = { .probe = sdhci_omap_probe, .remove = sdhci_omap_remove, .driver = { .name ="sdhci-omap" , + .pm = &sdhci_omap_dev_pm_ops, .of_match_table = omap_sdhci_match, }, };
Signature · 1 line
2.19.2
Hi Faiz,
Quoted 13 lines · Faiz Abbas
Add power management ops which save and restore the driver context and facilitate a system suspend and resume.
Signed-off-by Faiz Abbas <[email protected]>--- drivers/mmc/host/sdhci-omap.c | 59 +++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)drivers/mmc/host/sdhci-omap.c +0
-0
drivers/mmc/host/sdhci-omap.c struct sdhci_omap_host { · line 115
Quoted 8 lines
drivers/mmc/host/sdhci-omap.c +5
-0@@ -108,6 +108,11 @@ struct sdhci_omap_host {struct pinctrl *pinctrl;struct pinctrl_state **pinctrl_state;bool is_tuning; +/* Omap specific context save */ +u32 con; +u32 hctl; +u32 sysctl; +u32 capa;
Except CON register which is specific to OMAP, others are SDHCI registers. Shouldn't the save and restore of these registers be in sdhci.c? Doesn't set_ios() already take care of configuring HCTL, SYSCTL etc..?
Thanks
Kishon
Quoted 70 lines
drivers/mmc/host/sdhci-omap.c +54
-0};static void sdhci_omap_start_clock (struct sdhci_omap_host *omap_host);@@ -1233,11 +1238,65 @@ static int sdhci_omap_remove(struct platform_device *pdev)return 0 ; } +static void sdhci_omap_context_save (struct sdhci_omap_host *omap_host) +{ + omap_host->con =sdhci_omap_readl (omap_host,SDHCI_OMAP_CON ); + omap_host->hctl =sdhci_omap_readl (omap_host,SDHCI_OMAP_HCTL ); + omap_host->sysctl =sdhci_omap_readl (omap_host,SDHCI_OMAP_SYSCTL ); + omap_host->capa =sdhci_omap_readl (omap_host,SDHCI_OMAP_CAPA ); +} + +static void sdhci_omap_context_restore (struct sdhci_omap_host *omap_host) +{ +sdhci_omap_writel (omap_host,SDHCI_OMAP_CON , omap_host->con); +sdhci_omap_writel (omap_host,SDHCI_OMAP_HCTL , omap_host->hctl); +sdhci_omap_writel (omap_host,SDHCI_OMAP_SYSCTL , omap_host->sysctl); +sdhci_omap_writel (omap_host,SDHCI_OMAP_CAPA , omap_host->capa); +} + +static int __maybe_unused sdhci_omap_suspend (struct device *dev) +{ +struct sdhci_host *host =dev_get_drvdata (dev); +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct sdhci_omap_host *omap_host =sdhci_pltfm_priv (pltfm_host); + +sdhci_suspend_host (host); + +sdhci_omap_context_save (omap_host); + +pinctrl_pm_select_idle_state (dev); + +pm_runtime_put_sync (dev); + +return 0 ; +} + +static int __maybe_unused sdhci_omap_resume (struct device *dev) +{ +struct sdhci_host *host =dev_get_drvdata (dev); +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct sdhci_omap_host *omap_host =sdhci_pltfm_priv (pltfm_host); + +pm_runtime_get_sync (dev); + +pinctrl_pm_select_default_state (dev); + +sdhci_omap_context_restore (omap_host); + +sdhci_resume_host (host); + +return 0 ; +} + +static SIMPLE_DEV_PM_OPS(sdhci_omap_dev_pm_ops, sdhci_omap_suspend, + sdhci_omap_resume); +static struct platform_driver sdhci_omap_driver = { .probe = sdhci_omap_probe, .remove = sdhci_omap_remove, .driver = { .name ="sdhci-omap" , + .pm = &sdhci_omap_dev_pm_ops, .of_match_table = omap_sdhci_match, }, };
Quoted 48 lines · Faiz Abbas
Add power management ops which save and restore the driver context and facilitate a system suspend and resume.
Signed-off-by Faiz Abbas <[email protected]>--- drivers/mmc/host/sdhci-omap.c | 59 +++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)drivers/mmc/host/sdhci-omap.c +24
-0@@ -108,6 +108,11 @@ struct sdhci_omap_host {struct pinctrl *pinctrl;struct pinctrl_state **pinctrl_state;bool is_tuning; +/* Omap specific context save */ +u32 con; +u32 hctl; +u32 sysctl; +u32 capa; };static void sdhci_omap_start_clock (struct sdhci_omap_host *omap_host);@@ -1233,11 +1238,65 @@ static int sdhci_omap_remove(struct platform_device *pdev)return 0 ; } +static void sdhci_omap_context_save (struct sdhci_omap_host *omap_host) +{ + omap_host->con =sdhci_omap_readl (omap_host,SDHCI_OMAP_CON ); + omap_host->hctl =sdhci_omap_readl (omap_host,SDHCI_OMAP_HCTL ); + omap_host->sysctl =sdhci_omap_readl (omap_host,SDHCI_OMAP_SYSCTL ); + omap_host->capa =sdhci_omap_readl (omap_host,SDHCI_OMAP_CAPA ); +} + +static void sdhci_omap_context_restore (struct sdhci_omap_host *omap_host) +{ +sdhci_omap_writel (omap_host,SDHCI_OMAP_CON , omap_host->con); +sdhci_omap_writel (omap_host,SDHCI_OMAP_HCTL , omap_host->hctl); +sdhci_omap_writel (omap_host,SDHCI_OMAP_SYSCTL , omap_host->sysctl); +sdhci_omap_writel (omap_host,SDHCI_OMAP_CAPA , omap_host->capa); +} + +static int __maybe_unused sdhci_omap_suspend (struct device *dev) +{ +struct sdhci_host *host =dev_get_drvdata (dev);
drivers/mmc/host/sdhci-omap.c static int sdhci_omap_remove(struct platform_device *pdev) · line 1269
Quoted 10 lines
drivers/mmc/host/sdhci-omap.c +10
-0+struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct sdhci_omap_host *omap_host =sdhci_pltfm_priv (pltfm_host); + +sdhci_suspend_host (host); + +sdhci_omap_context_save (omap_host); + +pinctrl_pm_select_idle_state (dev); + +pm_runtime_put_sync (dev);
What exactly do you want to achieve by calling pm_runtime_put_sync() here?
Restoring the usage count from the pm_runtime_get_sync() during ->probe(), makes little sense to me. This because, the PM core is preventing the device from being runtime suspended anyway, as it calls pm_runtime_get_noresume() in device_prepare().
Or maybe there are other reasons?
Quoted 34 lines
drivers/mmc/host/sdhci-omap.c +25
-1+ +return 0 ; +} + +static int __maybe_unused sdhci_omap_resume (struct device *dev) +{ +struct sdhci_host *host =dev_get_drvdata (dev); +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct sdhci_omap_host *omap_host =sdhci_pltfm_priv (pltfm_host); + +pm_runtime_get_sync (dev); + +pinctrl_pm_select_default_state (dev); + +sdhci_omap_context_restore (omap_host); + +sdhci_resume_host (host); + +return 0 ; +} + +static SIMPLE_DEV_PM_OPS(sdhci_omap_dev_pm_ops, sdhci_omap_suspend, + sdhci_omap_resume); +static struct platform_driver sdhci_omap_driver = { .probe = sdhci_omap_probe, .remove = sdhci_omap_remove, .driver = { .name ="sdhci-omap" , + .pm = &sdhci_omap_dev_pm_ops, .of_match_table = omap_sdhci_match, }, }; --
Quoted 2 lines
2.19.2
Kind regards
Uffe
kbuild test robot
build botThank you for the patch! Yet something to improve:
Hi Faiz,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linux/master]
[also build test ERROR on linus/master v5.6-rc2 next-20200219]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Faiz-Abbas/mmc-sdhci-omap-Add-Support-for-Suspend-Resume/20200220-060820 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git f5ae2ea6347a308cfe91f53b53682ce635497d0d config: parisc-randconfig-a001-20200219 (attached as .config) compiler: hppa-linux-gcc (GCC) 7.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=parisc
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
drivers/mmc/host/sdhci-omap.c: In function 'sdhci_omap_suspend':
>> drivers/mmc/host/sdhci-omap.c:1205:2: error: implicit declaration of function 'sdhci_suspend_host'; did you mean 'sdhci_add_host'? [-Werror=implicit-function-declaration]
sdhci_suspend_host(host);
^~~~~~~~~~~~~~~~~~
sdhci_add_host
drivers/mmc/host/sdhci-omap.c: In function 'sdhci_omap_resume':
>> drivers/mmc/host/sdhci-omap.c:1228:2: error: implicit declaration of function 'sdhci_resume_host'; did you mean 'sdhci_remove_host'? [-Werror=implicit-function-declaration]
sdhci_resume_host(host);
^~~~~~~~~~~~~~~~~
sdhci_remove_hostcc1: some warnings being treated as errors
vim +1205 drivers/mmc/host/sdhci-omap.c
1198
1199 static int __maybe_unused sdhci_omap_suspend(struct device *dev)
1200 {
1201 struct sdhci_host *host = dev_get_drvdata(dev);
1202 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
1203 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host);
1204
> 1205 sdhci_suspend_host(host);
1206
1207 sdhci_omap_context_save(omap_host);
1208
1209 pinctrl_pm_select_idle_state(dev);
1210
1211 pm_runtime_put_sync(dev);
1212
1213 return 0;
1214 }
1215
1216 static int __maybe_unused sdhci_omap_resume(struct device *dev)
1217 {
1218 struct sdhci_host *host = dev_get_drvdata(dev);
1219 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
1220 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host);
1221
1222 pm_runtime_get_sync(dev);
1223
1224 pinctrl_pm_select_default_state(dev);
1225
1226 sdhci_omap_context_restore(omap_host);
1227
> 1228 sdhci_resume_host(host); 1229
1230 return 0;
1231 }
1232
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org