2022-11-29 19:23:30

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 14/26] drm: mediatek: Remove #ifdef guards for PM related functions

Use the DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros to handle
the .suspend/.resume callbacks.

These macros allow the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <[email protected]>
---
Cc: Chun-Kuang Hu <[email protected]>
Cc: Philipp Zabel <[email protected]>
Cc: Matthias Brugger <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
drivers/gpu/drm/mediatek/mtk_dp.c | 6 ++----
drivers/gpu/drm/mediatek/mtk_hdmi.c | 9 ++++-----
2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
index 9d085c05c49c..00861a914855 100644
--- a/drivers/gpu/drm/mediatek/mtk_dp.c
+++ b/drivers/gpu/drm/mediatek/mtk_dp.c
@@ -2590,7 +2590,6 @@ static int mtk_dp_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
static int mtk_dp_suspend(struct device *dev)
{
struct mtk_dp *mtk_dp = dev_get_drvdata(dev);
@@ -2613,9 +2612,8 @@ static int mtk_dp_resume(struct device *dev)

return 0;
}
-#endif

-static SIMPLE_DEV_PM_OPS(mtk_dp_pm_ops, mtk_dp_suspend, mtk_dp_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(mtk_dp_pm_ops, mtk_dp_suspend, mtk_dp_resume);

static const struct mtk_dp_data mt8195_edp_data = {
.bridge_type = DRM_MODE_CONNECTOR_eDP,
@@ -2650,7 +2648,7 @@ static struct platform_driver mtk_dp_driver = {
.driver = {
.name = "mediatek-drm-dp",
.of_match_table = mtk_dp_of_match,
- .pm = &mtk_dp_pm_ops,
+ .pm = pm_sleep_ptr(&mtk_dp_pm_ops),
},
};

diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index 0a8e0a13f516..52f77a6af10f 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -1755,7 +1755,6 @@ static int mtk_drm_hdmi_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
static int mtk_hdmi_suspend(struct device *dev)
{
struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
@@ -1778,9 +1777,9 @@ static int mtk_hdmi_resume(struct device *dev)

return 0;
}
-#endif
-static SIMPLE_DEV_PM_OPS(mtk_hdmi_pm_ops,
- mtk_hdmi_suspend, mtk_hdmi_resume);
+
+static DEFINE_SIMPLE_DEV_PM_OPS(mtk_hdmi_pm_ops,
+ mtk_hdmi_suspend, mtk_hdmi_resume);

static const struct mtk_hdmi_conf mtk_hdmi_conf_mt2701 = {
.tz_disabled = true,
@@ -1810,7 +1809,7 @@ static struct platform_driver mtk_hdmi_driver = {
.driver = {
.name = "mediatek-drm-hdmi",
.of_match_table = mtk_drm_hdmi_of_ids,
- .pm = &mtk_hdmi_pm_ops,
+ .pm = pm_sleep_ptr(&mtk_hdmi_pm_ops),
},
};

--
2.35.1


2022-11-29 19:35:24

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 17/26] drm: rcar-du: Remove #ifdef guards for PM related functions

Use the DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros to handle
the .suspend/.resume callbacks.

These macros allow the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <[email protected]>
Reviewed-by: Kieran Bingham <[email protected]>
---
Cc: Laurent Pinchart <[email protected]>
Cc: Kieran Bingham <[email protected]>
Cc: [email protected]
---
drivers/gpu/drm/rcar-du/rcar_du_drv.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index d003e8d9e7a2..eeec1e02446f 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -599,7 +599,6 @@ static const struct drm_driver rcar_du_driver = {
* Power management
*/

-#ifdef CONFIG_PM_SLEEP
static int rcar_du_pm_suspend(struct device *dev)
{
struct rcar_du_device *rcdu = dev_get_drvdata(dev);
@@ -613,11 +612,9 @@ static int rcar_du_pm_resume(struct device *dev)

return drm_mode_config_helper_resume(&rcdu->ddev);
}
-#endif

-static const struct dev_pm_ops rcar_du_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(rcar_du_pm_suspend, rcar_du_pm_resume)
-};
+static DEFINE_SIMPLE_DEV_PM_OPS(rcar_du_pm_ops,
+ rcar_du_pm_suspend, rcar_du_pm_resume);

/* -----------------------------------------------------------------------------
* Platform driver
@@ -712,7 +709,7 @@ static struct platform_driver rcar_du_platform_driver = {
.shutdown = rcar_du_shutdown,
.driver = {
.name = "rcar-du",
- .pm = &rcar_du_pm_ops,
+ .pm = pm_sleep_ptr(&rcar_du_pm_ops),
.of_match_table = rcar_du_of_table,
},
};
--
2.35.1

2022-11-29 19:44:25

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 21/26] drm: tilcdc: Remove #ifdef guards for PM related functions

Use the DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros to handle
the .suspend/.resume callbacks.

These macros allow the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <[email protected]>
Acked-by: Jyri Sarha <jyri.sarhaı@iki.fi>
---
Cc: Jyri Sarha <[email protected]>
Cc: Tomi Valkeinen <[email protected]>
---
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 80615ecdae0b..4ca426007dc8 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -496,7 +496,6 @@ static const struct drm_driver tilcdc_driver = {
* Power management:
*/

-#ifdef CONFIG_PM_SLEEP
static int tilcdc_pm_suspend(struct device *dev)
{
struct drm_device *ddev = dev_get_drvdata(dev);
@@ -518,11 +517,9 @@ static int tilcdc_pm_resume(struct device *dev)
pinctrl_pm_select_default_state(dev);
return drm_mode_config_helper_resume(ddev);
}
-#endif

-static const struct dev_pm_ops tilcdc_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(tilcdc_pm_suspend, tilcdc_pm_resume)
-};
+static DEFINE_SIMPLE_DEV_PM_OPS(tilcdc_pm_ops,
+ tilcdc_pm_suspend, tilcdc_pm_resume);

/*
* Platform driver:
@@ -597,7 +594,7 @@ static struct platform_driver tilcdc_platform_driver = {
.remove = tilcdc_pdev_remove,
.driver = {
.name = "tilcdc",
- .pm = &tilcdc_pm_ops,
+ .pm = pm_sleep_ptr(&tilcdc_pm_ops),
.of_match_table = tilcdc_of_match,
},
};
--
2.35.1

2022-11-29 19:45:30

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 18/26] drm: rockchip: Remove #ifdef guards for PM related functions

Use the pm_sleep_ptr() macros to handle the .suspend_late /
.resume_early callbacks.

This macro allows the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <[email protected]>
---
Cc: Sandy Huang <[email protected]>
Cc: "Heiko Stübner" <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
index ad2d3ae7e621..0df0fa540d7e 100644
--- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -429,7 +429,6 @@ static int rockchip_dp_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
static int rockchip_dp_suspend(struct device *dev)
{
struct rockchip_dp_device *dp = dev_get_drvdata(dev);
@@ -449,13 +448,10 @@ static int rockchip_dp_resume(struct device *dev)

return analogix_dp_resume(dp->adp);
}
-#endif

static const struct dev_pm_ops rockchip_dp_pm_ops = {
-#ifdef CONFIG_PM_SLEEP
.suspend_late = rockchip_dp_suspend,
.resume_early = rockchip_dp_resume,
-#endif
};

static const struct rockchip_dp_chip_data rk3399_edp = {
@@ -484,7 +480,7 @@ struct platform_driver rockchip_dp_driver = {
.remove = rockchip_dp_remove,
.driver = {
.name = "rockchip-dp",
- .pm = &rockchip_dp_pm_ops,
+ .pm = pm_sleep_ptr(&rockchip_dp_pm_ops),
.of_match_table = rockchip_dp_dt_ids,
},
};
--
2.35.1

2022-11-29 19:45:35

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 24/26] drm: gm12u320: Remove #ifdef guards for PM related functions

Use the pm_ptr() macro to handle the .suspend / .resume / .reset_resume
callbacks.

This macro allows the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_PM is disabled, without having
to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch. It also allows to drop the
__maybe_unused tags.

Signed-off-by: Paul Cercueil <[email protected]>
Reviewed-by: Hans de Goede <[email protected]>
---
Cc: Hans de Goede <[email protected]>
---
drivers/gpu/drm/tiny/gm12u320.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
index 130fd07a967d..c5bb683e440c 100644
--- a/drivers/gpu/drm/tiny/gm12u320.c
+++ b/drivers/gpu/drm/tiny/gm12u320.c
@@ -4,6 +4,7 @@
*/

#include <linux/module.h>
+#include <linux/pm.h>
#include <linux/usb.h>

#include <drm/drm_atomic_helper.h>
@@ -718,15 +719,15 @@ static void gm12u320_usb_disconnect(struct usb_interface *interface)
drm_atomic_helper_shutdown(dev);
}

-static __maybe_unused int gm12u320_suspend(struct usb_interface *interface,
- pm_message_t message)
+static int gm12u320_suspend(struct usb_interface *interface,
+ pm_message_t message)
{
struct drm_device *dev = usb_get_intfdata(interface);

return drm_mode_config_helper_suspend(dev);
}

-static __maybe_unused int gm12u320_resume(struct usb_interface *interface)
+static int gm12u320_resume(struct usb_interface *interface)
{
struct drm_device *dev = usb_get_intfdata(interface);
struct gm12u320_device *gm12u320 = to_gm12u320(dev);
@@ -747,11 +748,9 @@ static struct usb_driver gm12u320_usb_driver = {
.probe = gm12u320_usb_probe,
.disconnect = gm12u320_usb_disconnect,
.id_table = id_table,
-#ifdef CONFIG_PM
- .suspend = gm12u320_suspend,
- .resume = gm12u320_resume,
- .reset_resume = gm12u320_resume,
-#endif
+ .suspend = pm_ptr(gm12u320_suspend),
+ .resume = pm_ptr(gm12u320_resume),
+ .reset_resume = pm_ptr(gm12u320_resume),
};

module_usb_driver(gm12u320_usb_driver);
--
2.35.1

2022-11-29 19:46:26

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 15/26] drm: omap: Remove #ifdef guards for PM related functions

Use the DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros to handle
the .suspend/.resume callbacks.

These macros allow the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

The #ifdef CONFIG_PM guard around omap_gem_resume() was also removed,
and replaced by a "if (IS_ENABLED(CONFIG_PM_SLEEP))" guard in-line.
The change to CONFIG_PM_SLEEP is because it is only ever called in this
configuration.

Signed-off-by: Paul Cercueil <[email protected]>
---
Cc: Tomi Valkeinen <[email protected]>
---
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 6 ++----
drivers/gpu/drm/omapdrm/omap_drv.c | 7 +++----
drivers/gpu/drm/omapdrm/omap_gem.c | 5 +++--
drivers/gpu/drm/omapdrm/omap_gem.h | 2 --
4 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index 61a27dd7392e..14cc4cb457d1 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -1161,7 +1161,6 @@ int tiler_map_show(struct seq_file *s, void *arg)
}
#endif

-#ifdef CONFIG_PM_SLEEP
static int omap_dmm_resume(struct device *dev)
{
struct tcm_area area;
@@ -1185,9 +1184,8 @@ static int omap_dmm_resume(struct device *dev)

return 0;
}
-#endif

-static SIMPLE_DEV_PM_OPS(omap_dmm_pm_ops, NULL, omap_dmm_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(omap_dmm_pm_ops, NULL, omap_dmm_resume);

#if defined(CONFIG_OF)
static const struct dmm_platform_data dmm_omap4_platform_data = {
@@ -1218,7 +1216,7 @@ struct platform_driver omap_dmm_driver = {
.owner = THIS_MODULE,
.name = DMM_DRIVER_NAME,
.of_match_table = of_match_ptr(dmm_of_match),
- .pm = &omap_dmm_pm_ops,
+ .pm = pm_sleep_ptr(&omap_dmm_pm_ops),
},
};

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index eaf67b9e5f12..5f22e63e26c7 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -877,7 +877,6 @@ static int pdev_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
static int omap_drm_suspend(struct device *dev)
{
struct omap_drm_private *priv = dev_get_drvdata(dev);
@@ -895,14 +894,14 @@ static int omap_drm_resume(struct device *dev)

return omap_gem_resume(drm_dev);
}
-#endif

-static SIMPLE_DEV_PM_OPS(omapdrm_pm_ops, omap_drm_suspend, omap_drm_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(omapdrm_pm_ops,
+ omap_drm_suspend, omap_drm_resume);

static struct platform_driver pdev = {
.driver = {
.name = "omapdrm",
- .pm = &omapdrm_pm_ops,
+ .pm = pm_sleep_ptr(&omapdrm_pm_ops),
},
.probe = pdev_probe,
.remove = pdev_remove,
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index cf571796fd26..119e829c40de 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -1104,7 +1104,6 @@ void *omap_gem_vaddr(struct drm_gem_object *obj)
* Power Management
*/

-#ifdef CONFIG_PM
/* re-pin objects in DMM in resume path: */
int omap_gem_resume(struct drm_device *dev)
{
@@ -1112,6 +1111,9 @@ int omap_gem_resume(struct drm_device *dev)
struct omap_gem_object *omap_obj;
int ret = 0;

+ if (!IS_ENABLED(CONFIG_PM_SLEEP))
+ return 0;
+
mutex_lock(&priv->list_lock);
list_for_each_entry(omap_obj, &priv->obj_list, mm_list) {
if (omap_obj->block) {
@@ -1133,7 +1135,6 @@ int omap_gem_resume(struct drm_device *dev)
mutex_unlock(&priv->list_lock);
return ret;
}
-#endif

/* -----------------------------------------------------------------------------
* DebugFS
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.h b/drivers/gpu/drm/omapdrm/omap_gem.h
index 4d4488939f6b..edcd92ecc2ea 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.h
+++ b/drivers/gpu/drm/omapdrm/omap_gem.h
@@ -32,9 +32,7 @@ union omap_gem_size;
void omap_gem_init(struct drm_device *dev);
void omap_gem_deinit(struct drm_device *dev);

-#ifdef CONFIG_PM
int omap_gem_resume(struct drm_device *dev);
-#endif

#ifdef CONFIG_DEBUG_FS
void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
--
2.35.1

2022-11-29 19:46:42

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 20/26] drm: tegra: Remove #ifdef guards for PM related functions

Use the RUNTIME_PM_OPS() and pm_ptr() macros to handle the
.runtime_suspend/.runtime_resume callbacks.

These macros allow the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_PM is disabled, without having
to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <[email protected]>
---
Cc: Thierry Reding <[email protected]>
Cc: Jonathan Hunter <[email protected]>
Cc: [email protected]
---
drivers/gpu/drm/tegra/dpaux.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c
index 7dc681e2ee90..3c84e73d5051 100644
--- a/drivers/gpu/drm/tegra/dpaux.c
+++ b/drivers/gpu/drm/tegra/dpaux.c
@@ -598,7 +598,6 @@ static int tegra_dpaux_remove(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM
static int tegra_dpaux_suspend(struct device *dev)
{
struct tegra_dpaux *dpaux = dev_get_drvdata(dev);
@@ -657,10 +656,9 @@ static int tegra_dpaux_resume(struct device *dev)
clk_disable_unprepare(dpaux->clk);
return err;
}
-#endif

static const struct dev_pm_ops tegra_dpaux_pm_ops = {
- SET_RUNTIME_PM_OPS(tegra_dpaux_suspend, tegra_dpaux_resume, NULL)
+ RUNTIME_PM_OPS(tegra_dpaux_suspend, tegra_dpaux_resume, NULL)
};

static const struct tegra_dpaux_soc tegra124_dpaux_soc = {
@@ -694,7 +692,7 @@ struct platform_driver tegra_dpaux_driver = {
.driver = {
.name = "tegra-dpaux",
.of_match_table = tegra_dpaux_of_match,
- .pm = &tegra_dpaux_pm_ops,
+ .pm = pm_ptr(&tegra_dpaux_pm_ops),
},
.probe = tegra_dpaux_probe,
.remove = tegra_dpaux_remove,
--
2.35.1

2022-11-29 19:56:43

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH v2 17/26] drm: rcar-du: Remove #ifdef guards for PM related functions

Hi Paul,

Thank you for the patch.

On Tue, Nov 29, 2022 at 07:19:33PM +0000, Paul Cercueil wrote:
> Use the DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros to handle
> the .suspend/.resume callbacks.
>
> These macros allow the suspend and resume functions to be automatically
> dropped by the compiler when CONFIG_SUSPEND is disabled, without having
> to use #ifdef guards.
>
> This has the advantage of always compiling these functions in,
> independently of any Kconfig option. Thanks to that, bugs and other
> regressions are subsequently easier to catch.
>
> Signed-off-by: Paul Cercueil <[email protected]>
> Reviewed-by: Kieran Bingham <[email protected]>

Reviewed-by: Laurent Pinchart <[email protected]>

Will you get this whole series merged in one go in drm-misc, or do you
expect me to take this patch in my tree ? I'd prefer the first option if
possible (less work for me :-)).

> ---
> Cc: Laurent Pinchart <[email protected]>
> Cc: Kieran Bingham <[email protected]>
> Cc: [email protected]
> ---
> drivers/gpu/drm/rcar-du/rcar_du_drv.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> index d003e8d9e7a2..eeec1e02446f 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> @@ -599,7 +599,6 @@ static const struct drm_driver rcar_du_driver = {
> * Power management
> */
>
> -#ifdef CONFIG_PM_SLEEP
> static int rcar_du_pm_suspend(struct device *dev)
> {
> struct rcar_du_device *rcdu = dev_get_drvdata(dev);
> @@ -613,11 +612,9 @@ static int rcar_du_pm_resume(struct device *dev)
>
> return drm_mode_config_helper_resume(&rcdu->ddev);
> }
> -#endif
>
> -static const struct dev_pm_ops rcar_du_pm_ops = {
> - SET_SYSTEM_SLEEP_PM_OPS(rcar_du_pm_suspend, rcar_du_pm_resume)
> -};
> +static DEFINE_SIMPLE_DEV_PM_OPS(rcar_du_pm_ops,
> + rcar_du_pm_suspend, rcar_du_pm_resume);
>
> /* -----------------------------------------------------------------------------
> * Platform driver
> @@ -712,7 +709,7 @@ static struct platform_driver rcar_du_platform_driver = {
> .shutdown = rcar_du_shutdown,
> .driver = {
> .name = "rcar-du",
> - .pm = &rcar_du_pm_ops,
> + .pm = pm_sleep_ptr(&rcar_du_pm_ops),
> .of_match_table = rcar_du_of_table,
> },
> };

--
Regards,

Laurent Pinchart

2022-11-29 20:16:03

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 25/26] drm: tidss: Remove #ifdef guards for PM related functions

Use the SYSTEM_SLEEP_PM_OPS() and RUNTIME_PM_OPS() macros to handle the
PM callbacks.

These macros allow the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_PM is disabled, without having
to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch. It also allows to drop the
__maybe_unused tags.

Some #ifndef CONFIG_PM guards were protecting simple statements, and
were also converted to "if (!IS_ENABLED(CONFIG_PM))".

Signed-off-by: Paul Cercueil <[email protected]>
---
Cc: Jyri Sarha <[email protected]>
Cc: Tomi Valkeinen <[email protected]>
---
drivers/gpu/drm/tidss/tidss_drv.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/tidss/tidss_drv.c b/drivers/gpu/drm/tidss/tidss_drv.c
index 07d94b1e8089..3f0217256948 100644
--- a/drivers/gpu/drm/tidss/tidss_drv.c
+++ b/drivers/gpu/drm/tidss/tidss_drv.c
@@ -48,7 +48,7 @@ void tidss_runtime_put(struct tidss_device *tidss)
WARN_ON(r < 0);
}

-static int __maybe_unused tidss_pm_runtime_suspend(struct device *dev)
+static int tidss_pm_runtime_suspend(struct device *dev)
{
struct tidss_device *tidss = dev_get_drvdata(dev);

@@ -57,7 +57,7 @@ static int __maybe_unused tidss_pm_runtime_suspend(struct device *dev)
return dispc_runtime_suspend(tidss->dispc);
}

-static int __maybe_unused tidss_pm_runtime_resume(struct device *dev)
+static int tidss_pm_runtime_resume(struct device *dev)
{
struct tidss_device *tidss = dev_get_drvdata(dev);
int r;
@@ -71,7 +71,7 @@ static int __maybe_unused tidss_pm_runtime_resume(struct device *dev)
return 0;
}

-static int __maybe_unused tidss_suspend(struct device *dev)
+static int tidss_suspend(struct device *dev)
{
struct tidss_device *tidss = dev_get_drvdata(dev);

@@ -80,7 +80,7 @@ static int __maybe_unused tidss_suspend(struct device *dev)
return drm_mode_config_helper_suspend(&tidss->ddev);
}

-static int __maybe_unused tidss_resume(struct device *dev)
+static int tidss_resume(struct device *dev)
{
struct tidss_device *tidss = dev_get_drvdata(dev);

@@ -89,9 +89,9 @@ static int __maybe_unused tidss_resume(struct device *dev)
return drm_mode_config_helper_resume(&tidss->ddev);
}

-static __maybe_unused const struct dev_pm_ops tidss_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(tidss_suspend, tidss_resume)
- SET_RUNTIME_PM_OPS(tidss_pm_runtime_suspend, tidss_pm_runtime_resume, NULL)
+static const struct dev_pm_ops tidss_pm_ops = {
+ SYSTEM_SLEEP_PM_OPS(tidss_suspend, tidss_resume)
+ RUNTIME_PM_OPS(tidss_pm_runtime_suspend, tidss_pm_runtime_resume, NULL)
};

/* DRM device Information */
@@ -145,10 +145,9 @@ static int tidss_probe(struct platform_device *pdev)

pm_runtime_enable(dev);

-#ifndef CONFIG_PM
/* If we don't have PM, we need to call resume manually */
- dispc_runtime_resume(tidss->dispc);
-#endif
+ if (!IS_ENABLED(CONFIG_PM))
+ dispc_runtime_resume(tidss->dispc);

ret = tidss_modeset_init(tidss);
if (ret < 0) {
@@ -190,9 +189,8 @@ static int tidss_probe(struct platform_device *pdev)
tidss_irq_uninstall(ddev);

err_runtime_suspend:
-#ifndef CONFIG_PM
- dispc_runtime_suspend(tidss->dispc);
-#endif
+ if (!IS_ENABLED(CONFIG_PM))
+ dispc_runtime_suspend(tidss->dispc);
pm_runtime_disable(dev);

return ret;
@@ -212,10 +210,9 @@ static int tidss_remove(struct platform_device *pdev)

tidss_irq_uninstall(ddev);

-#ifndef CONFIG_PM
/* If we don't have PM, we need to call suspend manually */
- dispc_runtime_suspend(tidss->dispc);
-#endif
+ if (!IS_ENABLED(CONFIG_PM))
+ dispc_runtime_suspend(tidss->dispc);
pm_runtime_disable(dev);

/* devm allocated dispc goes away with the dev so mark it NULL */
--
2.35.1

2022-11-29 20:16:25

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 26/26] drm/i915/gt: Remove #ifdef guards for PM related functions

Instead of defining two versions of intel_sysfs_rc6_init(), one for each
value of CONFIG_PM, add a check on !IS_ENABLED(CONFIG_PM) early in the
function. This will allow the compiler to automatically drop the dead
code when CONFIG_PM is disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <[email protected]>
---
Cc: Jani Nikula <[email protected]>
Cc: Joonas Lahtinen <[email protected]>
Cc: Rodrigo Vivi <[email protected]>
Cc: Tvrtko Ursulin <[email protected]>
Cc: [email protected]
---
drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c b/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
index cf71305ad586..09b9365ededd 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
@@ -164,7 +164,6 @@ sysfs_gt_attribute_r_func(struct kobject *kobj, struct attribute *attr,
NULL); \
INTEL_GT_ATTR_RO(_name)

-#ifdef CONFIG_PM
static u32 get_residency(struct intel_gt *gt, enum intel_rc6_res_type id)
{
intel_wakeref_t wakeref;
@@ -300,7 +299,7 @@ static void intel_sysfs_rc6_init(struct intel_gt *gt, struct kobject *kobj)
{
int ret;

- if (!HAS_RC6(gt->i915))
+ if (!IS_ENABLED(CONFIG_PM) || !HAS_RC6(gt->i915))
return;

ret = __intel_gt_sysfs_create_group(kobj, rc6_attr_group);
@@ -329,11 +328,6 @@ static void intel_sysfs_rc6_init(struct intel_gt *gt, struct kobject *kobj)
gt->info.id, ERR_PTR(ret));
}
}
-#else
-static void intel_sysfs_rc6_init(struct intel_gt *gt, struct kobject *kobj)
-{
-}
-#endif /* CONFIG_PM */

static u32 __act_freq_mhz_show(struct intel_gt *gt)
{
--
2.35.1

2022-11-29 20:16:27

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 23/26] drm: vc4: Remove #ifdef guards for PM related functions

Use the RUNTIME_PM_OPS() and pm_ptr() macros to handle the
.runtime_suspend/.runtime_resume callbacks.

These macros allow the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_PM is disabled, without having
to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <[email protected]>
---
Cc: Emma Anholt <[email protected]>
Cc: Maxime Ripard <[email protected]>
---
drivers/gpu/drm/vc4/vc4_v3d.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_v3d.c b/drivers/gpu/drm/vc4/vc4_v3d.c
index 56abb0d6bc39..6000c7032b92 100644
--- a/drivers/gpu/drm/vc4/vc4_v3d.c
+++ b/drivers/gpu/drm/vc4/vc4_v3d.c
@@ -368,7 +368,6 @@ void vc4_v3d_bin_bo_put(struct vc4_dev *vc4)
mutex_unlock(&vc4->bin_bo_lock);
}

-#ifdef CONFIG_PM
static int vc4_v3d_runtime_suspend(struct device *dev)
{
struct vc4_v3d *v3d = dev_get_drvdata(dev);
@@ -397,7 +396,6 @@ static int vc4_v3d_runtime_resume(struct device *dev)

return 0;
}
-#endif

int vc4_v3d_debugfs_init(struct drm_minor *minor)
{
@@ -525,7 +523,7 @@ static void vc4_v3d_unbind(struct device *dev, struct device *master,
}

static const struct dev_pm_ops vc4_v3d_pm_ops = {
- SET_RUNTIME_PM_OPS(vc4_v3d_runtime_suspend, vc4_v3d_runtime_resume, NULL)
+ RUNTIME_PM_OPS(vc4_v3d_runtime_suspend, vc4_v3d_runtime_resume, NULL)
};

static const struct component_ops vc4_v3d_ops = {
@@ -557,6 +555,6 @@ struct platform_driver vc4_v3d_driver = {
.driver = {
.name = "vc4_v3d",
.of_match_table = vc4_v3d_dt_match,
- .pm = &vc4_v3d_pm_ops,
+ .pm = pm_ptr(&vc4_v3d_pm_ops),
},
};
--
2.35.1

2022-11-29 20:17:25

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 19/26] drm: shmobile: Remove #ifdef guards for PM related functions

Use the DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros to handle
the .suspend/.resume callbacks.

These macros allow the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <[email protected]>
Reviewed-by: Kieran Bingham <[email protected]>
---
Cc: Laurent Pinchart <[email protected]>
Cc: Kieran Bingham <[email protected]>
Cc: [email protected]
---
drivers/gpu/drm/shmobile/shmob_drm_drv.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index 3d511fa38913..337040fa6438 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -143,7 +143,6 @@ static const struct drm_driver shmob_drm_driver = {
* Power management
*/

-#ifdef CONFIG_PM_SLEEP
static int shmob_drm_pm_suspend(struct device *dev)
{
struct shmob_drm_device *sdev = dev_get_drvdata(dev);
@@ -165,11 +164,9 @@ static int shmob_drm_pm_resume(struct device *dev)
drm_kms_helper_poll_enable(sdev->ddev);
return 0;
}
-#endif

-static const struct dev_pm_ops shmob_drm_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(shmob_drm_pm_suspend, shmob_drm_pm_resume)
-};
+static DEFINE_SIMPLE_DEV_PM_OPS(shmob_drm_pm_ops,
+ shmob_drm_pm_suspend, shmob_drm_pm_resume);

/* -----------------------------------------------------------------------------
* Platform driver
@@ -292,7 +289,7 @@ static struct platform_driver shmob_drm_platform_driver = {
.remove = shmob_drm_remove,
.driver = {
.name = "shmob-drm",
- .pm = &shmob_drm_pm_ops,
+ .pm = pm_sleep_ptr(&shmob_drm_pm_ops),
},
};

--
2.35.1

2022-11-29 20:17:46

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 22/26] drm: vboxvideo: Remove #ifdef guards for PM related functions

Use the pm_sleep_ptr() macro to handle the .suspend / .resume callbacks.

This macro allows the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <[email protected]>
Reviewed-by: Hans de Goede <[email protected]>
---
Cc: Hans de Goede <[email protected]>
---
drivers/gpu/drm/vboxvideo/vbox_drv.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
index b450f449a3ab..12fee99dbfe8 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
@@ -102,7 +102,6 @@ static void vbox_pci_remove(struct pci_dev *pdev)
vbox_hw_fini(vbox);
}

-#ifdef CONFIG_PM_SLEEP
static int vbox_pm_suspend(struct device *dev)
{
struct vbox_private *vbox = dev_get_drvdata(dev);
@@ -160,16 +159,13 @@ static const struct dev_pm_ops vbox_pm_ops = {
.poweroff = vbox_pm_poweroff,
.restore = vbox_pm_resume,
};
-#endif

static struct pci_driver vbox_pci_driver = {
.name = DRIVER_NAME,
.id_table = pciidlist,
.probe = vbox_pci_probe,
.remove = vbox_pci_remove,
-#ifdef CONFIG_PM_SLEEP
- .driver.pm = &vbox_pm_ops,
-#endif
+ .driver.pm = pm_sleep_ptr(&vbox_pm_ops),
};

DEFINE_DRM_GEM_FOPS(vbox_fops);
--
2.35.1

2022-11-29 20:30:25

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 16/26] drm: panfrost: Remove #ifdef guards for PM related functions

Use the EXPORT_GPL_RUNTIME_DEV_PM_OPS() and pm_ptr() macros to handle
the PM callbacks.

These macros allow the PM functions to be automatically dropped by the
compiler when CONFIG_PM is disabled, without having to use #ifdef
guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <[email protected]>
Reviewed-by: Steven Price <[email protected]>
---
Cc: Rob Herring <[email protected]>
Cc: Tomeu Vizoso <[email protected]>
Cc: Steven Price <[email protected]>
Cc: Alyssa Rosenzweig <[email protected]>
---
drivers/gpu/drm/panfrost/panfrost_device.c | 10 ++++++----
drivers/gpu/drm/panfrost/panfrost_device.h | 4 ++--
drivers/gpu/drm/panfrost/panfrost_drv.c | 7 +------
3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c
index ee612303f076..fa1a086a862b 100644
--- a/drivers/gpu/drm/panfrost/panfrost_device.c
+++ b/drivers/gpu/drm/panfrost/panfrost_device.c
@@ -6,6 +6,7 @@
#include <linux/reset.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
+#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>

#include "panfrost_device.h"
@@ -400,8 +401,7 @@ void panfrost_device_reset(struct panfrost_device *pfdev)
panfrost_job_enable_interrupts(pfdev);
}

-#ifdef CONFIG_PM
-int panfrost_device_resume(struct device *dev)
+static int panfrost_device_resume(struct device *dev)
{
struct panfrost_device *pfdev = dev_get_drvdata(dev);

@@ -411,7 +411,7 @@ int panfrost_device_resume(struct device *dev)
return 0;
}

-int panfrost_device_suspend(struct device *dev)
+static int panfrost_device_suspend(struct device *dev)
{
struct panfrost_device *pfdev = dev_get_drvdata(dev);

@@ -423,4 +423,6 @@ int panfrost_device_suspend(struct device *dev)

return 0;
}
-#endif
+
+EXPORT_GPL_RUNTIME_DEV_PM_OPS(panfrost_pm_ops, panfrost_device_suspend,
+ panfrost_device_resume, NULL);
diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h
index 8b25278f34c8..d9ba68cffb77 100644
--- a/drivers/gpu/drm/panfrost/panfrost_device.h
+++ b/drivers/gpu/drm/panfrost/panfrost_device.h
@@ -7,6 +7,7 @@

#include <linux/atomic.h>
#include <linux/io-pgtable.h>
+#include <linux/pm.h>
#include <linux/regulator/consumer.h>
#include <linux/spinlock.h>
#include <drm/drm_device.h>
@@ -172,8 +173,7 @@ int panfrost_device_init(struct panfrost_device *pfdev);
void panfrost_device_fini(struct panfrost_device *pfdev);
void panfrost_device_reset(struct panfrost_device *pfdev);

-int panfrost_device_resume(struct device *dev);
-int panfrost_device_suspend(struct device *dev);
+extern const struct dev_pm_ops panfrost_pm_ops;

enum drm_panfrost_exception_type {
DRM_PANFROST_EXCEPTION_OK = 0x00,
diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
index 2fa5afe21288..fa619fe72086 100644
--- a/drivers/gpu/drm/panfrost/panfrost_drv.c
+++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
@@ -676,17 +676,12 @@ static const struct of_device_id dt_match[] = {
};
MODULE_DEVICE_TABLE(of, dt_match);

-static const struct dev_pm_ops panfrost_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
- SET_RUNTIME_PM_OPS(panfrost_device_suspend, panfrost_device_resume, NULL)
-};
-
static struct platform_driver panfrost_driver = {
.probe = panfrost_probe,
.remove = panfrost_remove,
.driver = {
.name = "panfrost",
- .pm = &panfrost_pm_ops,
+ .pm = pm_ptr(&panfrost_pm_ops),
.of_match_table = dt_match,
},
};
--
2.35.1

2022-11-29 20:30:55

by Alyssa Rosenzweig

[permalink] [raw]
Subject: Re: [PATCH v2 16/26] drm: panfrost: Remove #ifdef guards for PM related functions

Sounds like a nice clean up :-)

Acked-by: Alyssa Rosenzweig <[email protected]>

On Tue, Nov 29, 2022 at 07:19:32PM +0000, Paul Cercueil wrote:
> Use the EXPORT_GPL_RUNTIME_DEV_PM_OPS() and pm_ptr() macros to handle
> the PM callbacks.
>
> These macros allow the PM functions to be automatically dropped by the
> compiler when CONFIG_PM is disabled, without having to use #ifdef
> guards.
>
> This has the advantage of always compiling these functions in,
> independently of any Kconfig option. Thanks to that, bugs and other
> regressions are subsequently easier to catch.
>
> Signed-off-by: Paul Cercueil <[email protected]>
> Reviewed-by: Steven Price <[email protected]>
> ---
> Cc: Rob Herring <[email protected]>
> Cc: Tomeu Vizoso <[email protected]>
> Cc: Steven Price <[email protected]>
> Cc: Alyssa Rosenzweig <[email protected]>
> ---
> drivers/gpu/drm/panfrost/panfrost_device.c | 10 ++++++----
> drivers/gpu/drm/panfrost/panfrost_device.h | 4 ++--
> drivers/gpu/drm/panfrost/panfrost_drv.c | 7 +------
> 3 files changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c
> index ee612303f076..fa1a086a862b 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_device.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_device.c
> @@ -6,6 +6,7 @@
> #include <linux/reset.h>
> #include <linux/platform_device.h>
> #include <linux/pm_domain.h>
> +#include <linux/pm_runtime.h>
> #include <linux/regulator/consumer.h>
>
> #include "panfrost_device.h"
> @@ -400,8 +401,7 @@ void panfrost_device_reset(struct panfrost_device *pfdev)
> panfrost_job_enable_interrupts(pfdev);
> }
>
> -#ifdef CONFIG_PM
> -int panfrost_device_resume(struct device *dev)
> +static int panfrost_device_resume(struct device *dev)
> {
> struct panfrost_device *pfdev = dev_get_drvdata(dev);
>
> @@ -411,7 +411,7 @@ int panfrost_device_resume(struct device *dev)
> return 0;
> }
>
> -int panfrost_device_suspend(struct device *dev)
> +static int panfrost_device_suspend(struct device *dev)
> {
> struct panfrost_device *pfdev = dev_get_drvdata(dev);
>
> @@ -423,4 +423,6 @@ int panfrost_device_suspend(struct device *dev)
>
> return 0;
> }
> -#endif
> +
> +EXPORT_GPL_RUNTIME_DEV_PM_OPS(panfrost_pm_ops, panfrost_device_suspend,
> + panfrost_device_resume, NULL);
> diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h
> index 8b25278f34c8..d9ba68cffb77 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_device.h
> +++ b/drivers/gpu/drm/panfrost/panfrost_device.h
> @@ -7,6 +7,7 @@
>
> #include <linux/atomic.h>
> #include <linux/io-pgtable.h>
> +#include <linux/pm.h>
> #include <linux/regulator/consumer.h>
> #include <linux/spinlock.h>
> #include <drm/drm_device.h>
> @@ -172,8 +173,7 @@ int panfrost_device_init(struct panfrost_device *pfdev);
> void panfrost_device_fini(struct panfrost_device *pfdev);
> void panfrost_device_reset(struct panfrost_device *pfdev);
>
> -int panfrost_device_resume(struct device *dev);
> -int panfrost_device_suspend(struct device *dev);
> +extern const struct dev_pm_ops panfrost_pm_ops;
>
> enum drm_panfrost_exception_type {
> DRM_PANFROST_EXCEPTION_OK = 0x00,
> diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
> index 2fa5afe21288..fa619fe72086 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_drv.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
> @@ -676,17 +676,12 @@ static const struct of_device_id dt_match[] = {
> };
> MODULE_DEVICE_TABLE(of, dt_match);
>
> -static const struct dev_pm_ops panfrost_pm_ops = {
> - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
> - SET_RUNTIME_PM_OPS(panfrost_device_suspend, panfrost_device_resume, NULL)
> -};
> -
> static struct platform_driver panfrost_driver = {
> .probe = panfrost_probe,
> .remove = panfrost_remove,
> .driver = {
> .name = "panfrost",
> - .pm = &panfrost_pm_ops,
> + .pm = pm_ptr(&panfrost_pm_ops),
> .of_match_table = dt_match,
> },
> };
> --
> 2.35.1
>

2022-11-29 21:40:11

by Paul Cercueil

[permalink] [raw]
Subject: Re: [PATCH v2 17/26] drm: rcar-du: Remove #ifdef guards for PM related functions

Hi Laurent,

Le mardi 29 novembre 2022 à 21:43 +0200, Laurent Pinchart a écrit :
> Hi Paul,
>
> Thank you for the patch.
>
> On Tue, Nov 29, 2022 at 07:19:33PM +0000, Paul Cercueil wrote:
> > Use the DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros to
> > handle
> > the .suspend/.resume callbacks.
> >
> > These macros allow the suspend and resume functions to be
> > automatically
> > dropped by the compiler when CONFIG_SUSPEND is disabled, without
> > having
> > to use #ifdef guards.
> >
> > This has the advantage of always compiling these functions in,
> > independently of any Kconfig option. Thanks to that, bugs and other
> > regressions are subsequently easier to catch.
> >
> > Signed-off-by: Paul Cercueil <[email protected]>
> > Reviewed-by: Kieran Bingham
> > <[email protected]>
>
> Reviewed-by: Laurent Pinchart
> <[email protected]>
>
> Will you get this whole series merged in one go in drm-misc, or do
> you
> expect me to take this patch in my tree ? I'd prefer the first option
> if
> possible (less work for me :-)).

I actually answered that in my cover letter ;)

However I assumed it had to go through drm-next, if you think it can go
through drm-misc-next, I can apply it myself.

Cheers,
-Paul

>
> > ---
> > Cc: Laurent Pinchart <[email protected]>
> > Cc: Kieran Bingham <[email protected]>
> > Cc: [email protected]
> > ---
> >  drivers/gpu/drm/rcar-du/rcar_du_drv.c | 9 +++------
> >  1 file changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> > b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> > index d003e8d9e7a2..eeec1e02446f 100644
> > --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> > +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> > @@ -599,7 +599,6 @@ static const struct drm_driver rcar_du_driver =
> > {
> >   * Power management
> >   */
> >  
> > -#ifdef CONFIG_PM_SLEEP
> >  static int rcar_du_pm_suspend(struct device *dev)
> >  {
> >         struct rcar_du_device *rcdu = dev_get_drvdata(dev);
> > @@ -613,11 +612,9 @@ static int rcar_du_pm_resume(struct device
> > *dev)
> >  
> >         return drm_mode_config_helper_resume(&rcdu->ddev);
> >  }
> > -#endif
> >  
> > -static const struct dev_pm_ops rcar_du_pm_ops = {
> > -       SET_SYSTEM_SLEEP_PM_OPS(rcar_du_pm_suspend,
> > rcar_du_pm_resume)
> > -};
> > +static DEFINE_SIMPLE_DEV_PM_OPS(rcar_du_pm_ops,
> > +                               rcar_du_pm_suspend,
> > rcar_du_pm_resume);
> >  
> >  /* ---------------------------------------------------------------
> > --------------
> >   * Platform driver
> > @@ -712,7 +709,7 @@ static struct platform_driver
> > rcar_du_platform_driver = {
> >         .shutdown       = rcar_du_shutdown,
> >         .driver         = {
> >                 .name   = "rcar-du",
> > -               .pm     = &rcar_du_pm_ops,
> > +               .pm     = pm_sleep_ptr(&rcar_du_pm_ops),
> >                 .of_match_table = rcar_du_of_table,
> >         },
> >  };
>

2022-11-29 22:27:01

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH v2 17/26] drm: rcar-du: Remove #ifdef guards for PM related functions

Hi Paul,

On Tue, Nov 29, 2022 at 09:05:49PM +0000, Paul Cercueil wrote:
> Le mardi 29 novembre 2022 à 21:43 +0200, Laurent Pinchart a écrit :
> > On Tue, Nov 29, 2022 at 07:19:33PM +0000, Paul Cercueil wrote:
> > > Use the DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros to handle
> > > the .suspend/.resume callbacks.
> > >
> > > These macros allow the suspend and resume functions to be automatically
> > > dropped by the compiler when CONFIG_SUSPEND is disabled, without having
> > > to use #ifdef guards.
> > >
> > > This has the advantage of always compiling these functions in,
> > > independently of any Kconfig option. Thanks to that, bugs and other
> > > regressions are subsequently easier to catch.
> > >
> > > Signed-off-by: Paul Cercueil <[email protected]>
> > > Reviewed-by: Kieran Bingham <[email protected]>
> >
> > Reviewed-by: Laurent Pinchart <[email protected]>
> >
> > Will you get this whole series merged in one go in drm-misc, or do you
> > expect me to take this patch in my tree ? I'd prefer the first option if
> > possible (less work for me :-)).
>
> I actually answered that in my cover letter ;)

Oops. I read until "V2" and didn't notice the last paragraph, sorry.

> However I assumed it had to go through drm-next, if you think it can go
> through drm-misc-next, I can apply it myself.

This seems like a good candidate for drm-misc to me.

> > > ---
> > > Cc: Laurent Pinchart <[email protected]>
> > > Cc: Kieran Bingham <[email protected]>
> > > Cc: [email protected]
> > > ---
> > >  drivers/gpu/drm/rcar-du/rcar_du_drv.c | 9 +++------
> > >  1 file changed, 3 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> > > b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> > > index d003e8d9e7a2..eeec1e02446f 100644
> > > --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> > > +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> > > @@ -599,7 +599,6 @@ static const struct drm_driver rcar_du_driver =
> > > {
> > >   * Power management
> > >   */
> > >  
> > > -#ifdef CONFIG_PM_SLEEP
> > >  static int rcar_du_pm_suspend(struct device *dev)
> > >  {
> > >         struct rcar_du_device *rcdu = dev_get_drvdata(dev);
> > > @@ -613,11 +612,9 @@ static int rcar_du_pm_resume(struct device
> > > *dev)
> > >  
> > >         return drm_mode_config_helper_resume(&rcdu->ddev);
> > >  }
> > > -#endif
> > >  
> > > -static const struct dev_pm_ops rcar_du_pm_ops = {
> > > -       SET_SYSTEM_SLEEP_PM_OPS(rcar_du_pm_suspend,
> > > rcar_du_pm_resume)
> > > -};
> > > +static DEFINE_SIMPLE_DEV_PM_OPS(rcar_du_pm_ops,
> > > +                               rcar_du_pm_suspend,
> > > rcar_du_pm_resume);
> > >  
> > >  /* ---------------------------------------------------------------
> > > --------------
> > >   * Platform driver
> > > @@ -712,7 +709,7 @@ static struct platform_driver
> > > rcar_du_platform_driver = {
> > >         .shutdown       = rcar_du_shutdown,
> > >         .driver         = {
> > >                 .name   = "rcar-du",
> > > -               .pm     = &rcar_du_pm_ops,
> > > +               .pm     = pm_sleep_ptr(&rcar_du_pm_ops),
> > >                 .of_match_table = rcar_du_of_table,
> > >         },
> > >  };

--
Regards,

Laurent Pinchart

2022-12-07 16:25:28

by Rodrigo Vivi

[permalink] [raw]
Subject: Re: [Intel-gfx] [PATCH v2 26/26] drm/i915/gt: Remove #ifdef guards for PM related functions

On Tue, Nov 29, 2022 at 07:19:42PM +0000, Paul Cercueil wrote:
> Instead of defining two versions of intel_sysfs_rc6_init(), one for each
> value of CONFIG_PM, add a check on !IS_ENABLED(CONFIG_PM) early in the
> function. This will allow the compiler to automatically drop the dead
> code when CONFIG_PM is disabled, without having to use #ifdef guards.
>
> This has the advantage of always compiling these functions in,
> independently of any Kconfig option. Thanks to that, bugs and other
> regressions are subsequently easier to catch.
>
> Signed-off-by: Paul Cercueil <[email protected]>
> ---
> Cc: Jani Nikula <[email protected]>
> Cc: Joonas Lahtinen <[email protected]>
> Cc: Rodrigo Vivi <[email protected]>


Reviewed-by: Rodrigo Vivi <[email protected]>


> Cc: Tvrtko Ursulin <[email protected]>
> Cc: [email protected]
> ---
> drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c b/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
> index cf71305ad586..09b9365ededd 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
> @@ -164,7 +164,6 @@ sysfs_gt_attribute_r_func(struct kobject *kobj, struct attribute *attr,
> NULL); \
> INTEL_GT_ATTR_RO(_name)
>
> -#ifdef CONFIG_PM
> static u32 get_residency(struct intel_gt *gt, enum intel_rc6_res_type id)
> {
> intel_wakeref_t wakeref;
> @@ -300,7 +299,7 @@ static void intel_sysfs_rc6_init(struct intel_gt *gt, struct kobject *kobj)
> {
> int ret;
>
> - if (!HAS_RC6(gt->i915))
> + if (!IS_ENABLED(CONFIG_PM) || !HAS_RC6(gt->i915))
> return;
>
> ret = __intel_gt_sysfs_create_group(kobj, rc6_attr_group);
> @@ -329,11 +328,6 @@ static void intel_sysfs_rc6_init(struct intel_gt *gt, struct kobject *kobj)
> gt->info.id, ERR_PTR(ret));
> }
> }
> -#else
> -static void intel_sysfs_rc6_init(struct intel_gt *gt, struct kobject *kobj)
> -{
> -}
> -#endif /* CONFIG_PM */
>
> static u32 __act_freq_mhz_show(struct intel_gt *gt)
> {
> --
> 2.35.1
>