On Mon, Jul 27, 2020 at 12:44 PM Arnd Bergmann <arnd@xxxxxxxx> wrote: > On Mon, Jul 27, 2020 at 10:18 AM Anson Huang <anson.huang@xxxxxxx> wrote: > > > Why is this driver using syscore_ops rather than > > > SIMPLE_DEV_PM_OPS() or similar? > > > > Below is the original patch of using syscore_ops, it has explanation: > > > > commit 1a5287a3dbc34cd0c02c8f64c9131bd23cdfe2bb > > Author: Anson Huang <anson.huang@xxxxxxx> > > Date: Fri Nov 9 04:56:56 2018 +0000 > > > > gpio: mxc: move gpio noirq suspend/resume to syscore phase > > > > During noirq suspend/resume phase, GPIO irq could arrive > > and its registers like IMR will be changed by irq handle > > process, to make the GPIO registers exactly when it is > > powered ON after resume, move the GPIO noirq suspend/resume > > callback to syscore suspend/resume phase, local irq is > > disabled at this phase so GPIO registers are atomic. This looks like it would have been easier to use SET_NOIRQ_SYSTEM_SLEEP_PM_OPS as pointed out later... > The description makes sense, but this must be a problem that > other gpio/pinctrl irqchip drivers have as well. > > Linus, could you have a look? I see these other pinctrl drivers > using SIMPLE_DEV_PM_OPS: > > drivers/pinctrl/nomadik/pinctrl-nomadik.c:static > SIMPLE_DEV_PM_OPS(nmk_pinctrl_pm_ops, This one does not involve IRQs rather calls pinctrl_force_sleep/default which sets up hogged pins for energy saving while sleeping. > drivers/pinctrl/pinctrl-rockchip.c:static > SIMPLE_DEV_PM_OPS(rockchip_pinctrl_dev_pm_ops, > rockchip_pinctrl_suspend, Pretty much the same as Nomadik, with some extra register (also not IRQ-related). > drivers/pinctrl/pinctrl-stmfx.c:static > SIMPLE_DEV_PM_OPS(stmfx_pinctrl_dev_pm_ops, This one is problematic. However this is on an I2C expander meaning the slow bus traffic needs to be working and if IRQs are off at syscore suspend/resume time, I2C will not work. I think Amelie has tested this thing pretty thoroughly, and that expanders are less sensitive to this. > drivers/pinctrl/qcom/pinctrl-msm.c:SIMPLE_DEV_PM_OPS(msm_pinctrl_dev_pm_ops, > msm_pinctrl_suspend, This one is like the Nomadik: just forcing some hogs to go into low power mode. > drivers/pinctrl/spear/pinctrl-plgpio.c:static > SIMPLE_DEV_PM_OPS(plgpio_dev_pm_ops, plgpio_suspend, plgpio_resume); This one is affected by the same problem, I don't know if anyone really has this hardware anymore, but there are some SPEAr products deployed so the users should be notified that they may need to move this to syscore ops. Viresh? > It seems that some drivers use SET_NOIRQ_SYSTEM_SLEEP_PM_OPS() > instead, which looks like it is meant to address the same problem, but > as I have not used that myself, I may be misunderstanding the problem > or what this one does. IIUC that callback is for exactly this, and occurs after IRQs are disabled and before IRQs are re-enabled. Again the same problem if you need slow bus traffic in your callback (I2C/SPI devices): it is not going to work. Yours, Linus Walleij