diff mbox series

pinctrl: renesas: Allow the compiler to optimize away sh_pfc_pm

Message ID 6238a78e32fa21f0c795406b6cba7bce7af92577.1708513940.git.geert+renesas@glider.be (mailing list archive)
State Mainlined
Commit a6f06b909fee72c679c565adfa7f080f9595e336
Delegated to: Geert Uytterhoeven
Headers show
Series pinctrl: renesas: Allow the compiler to optimize away sh_pfc_pm | expand

Commit Message

Geert Uytterhoeven Feb. 21, 2024, 11:13 a.m. UTC
The conversion to DEFINE_NOIRQ_DEV_PM_OPS() lost the ability of the
compiler to optimize away the struct dev_pm_ops object when it is not
needed.

Fix this by replacing the use of pm_sleep_ptr() by a custom wrapper.

Fixes: 727eb02eb753375e ("pinctrl: renesas: Switch to use DEFINE_NOIRQ_DEV_PM_OPS() helper")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
To be queued in renesas-pinctrl for v6.9.

Alternatively, one could add a unified definition:

    #define pm_psci_sleep_ptr(_ptr)        PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP) && \
					  IS_ENABLED(CONFIG_ARM_PSCI_FW), (_ptr))

Since there are already separate sections for CONFIG_ARM_PSCI_FW enabled
vs. disabled, I split in two and simplified the definition.
---
 drivers/pinctrl/renesas/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Andy Shevchenko Feb. 21, 2024, 1:19 p.m. UTC | #1
On Wed, Feb 21, 2024 at 12:13:59PM +0100, Geert Uytterhoeven wrote:
> The conversion to DEFINE_NOIRQ_DEV_PM_OPS() lost the ability of the
> compiler to optimize away the struct dev_pm_ops object when it is not
> needed.
> 
> Fix this by replacing the use of pm_sleep_ptr() by a custom wrapper.
> 
> Fixes: 727eb02eb753375e ("pinctrl: renesas: Switch to use DEFINE_NOIRQ_DEV_PM_OPS() helper")

Is this a new requirement (I mean more than 12 digits of SHA)?

...

> ---
> To be queued in renesas-pinctrl for v6.9.
> 
> Alternatively, one could add a unified definition:
> 
>     #define pm_psci_sleep_ptr(_ptr)        PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP) && \
> 					  IS_ENABLED(CONFIG_ARM_PSCI_FW), (_ptr))
> 
> Since there are already separate sections for CONFIG_ARM_PSCI_FW enabled
> vs. disabled, I split in two and simplified the definition.

I'm fine with current approach, IIUC we discussed this that time and the
727eb02eb753 was not the first version (or I can be mistaken, I don't remember
exact driver that the discussion was about during the DEFINE_NOIRQ_DEV_PM_OPS()
conversions).


FWIW,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Geert Uytterhoeven Feb. 21, 2024, 1:37 p.m. UTC | #2
Hi Andy,

Cc Paul

On Wed, Feb 21, 2024 at 2:19 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Wed, Feb 21, 2024 at 12:13:59PM +0100, Geert Uytterhoeven wrote:
> > The conversion to DEFINE_NOIRQ_DEV_PM_OPS() lost the ability of the
> > compiler to optimize away the struct dev_pm_ops object when it is not
> > needed.
> >
> > Fix this by replacing the use of pm_sleep_ptr() by a custom wrapper.
> >
> > Fixes: 727eb02eb753375e ("pinctrl: renesas: Switch to use DEFINE_NOIRQ_DEV_PM_OPS() helper")
>
> Is this a new requirement (I mean more than 12 digits of SHA)?

Nah, better safe than sorry, as 12 is becoming a bit small.
(Yes, I have to rework/resubmit patches related to that)

> > ---
> > To be queued in renesas-pinctrl for v6.9.
> >
> > Alternatively, one could add a unified definition:
> >
> >     #define pm_psci_sleep_ptr(_ptr)        PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP) && \
> >                                         IS_ENABLED(CONFIG_ARM_PSCI_FW), (_ptr))
> >
> > Since there are already separate sections for CONFIG_ARM_PSCI_FW enabled
> > vs. disabled, I split in two and simplified the definition.
>
> I'm fine with current approach, IIUC we discussed this that time and the
> 727eb02eb753 was not the first version (or I can be mistaken, I don't remember
> exact driver that the discussion was about during the DEFINE_NOIRQ_DEV_PM_OPS()
> conversions).

Thanks, I had forgotten about that discussion...

> FWIW,
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thanks!

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

diff --git a/drivers/pinctrl/renesas/core.c b/drivers/pinctrl/renesas/core.c
index 78331d7f7cca9d8c..96d6040a8871419b 100644
--- a/drivers/pinctrl/renesas/core.c
+++ b/drivers/pinctrl/renesas/core.c
@@ -737,10 +737,12 @@  static int sh_pfc_resume_noirq(struct device *dev)
 		sh_pfc_walk_regs(pfc, sh_pfc_restore_reg);
 	return 0;
 }
+#define pm_psci_sleep_ptr(_ptr)	pm_sleep_ptr(_ptr)
 #else
 static int sh_pfc_suspend_init(struct sh_pfc *pfc) { return 0; }
 static int sh_pfc_suspend_noirq(struct device *dev) { return 0; }
 static int sh_pfc_resume_noirq(struct device *dev) { return 0; }
+#define pm_psci_sleep_ptr(_ptr)	PTR_IF(false, (_ptr))
 #endif	/* CONFIG_ARM_PSCI_FW */
 
 static DEFINE_NOIRQ_DEV_PM_OPS(sh_pfc_pm, sh_pfc_suspend_noirq, sh_pfc_resume_noirq);
@@ -1423,7 +1425,7 @@  static struct platform_driver sh_pfc_driver = {
 	.driver		= {
 		.name	= DRV_NAME,
 		.of_match_table = of_match_ptr(sh_pfc_of_table),
-		.pm	= pm_sleep_ptr(&sh_pfc_pm),
+		.pm	= pm_psci_sleep_ptr(&sh_pfc_pm),
 	},
 };