dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards
@ 2022-11-29 19:17 Paul Cercueil
  2022-11-29 19:17 ` [PATCH v2 01/26] drm: modeset-helper: Add DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS macro Paul Cercueil
                   ` (14 more replies)
  0 siblings, 15 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:17 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter; +Cc: Paul Cercueil, linux-kernel, dri-devel

Hi,

This patchset updates the DRM drivers to use the new set of PM-related
macros introduced recently.

The point of these macros is to allow the PM functions to be
automatically dropped by the compiler when CONFIG_PM or CONFIG_SUSPEND
is disabled, without having to use #ifdef guards.

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

Checkpatch complains about patch [11/26], as I replaced a
"#if defined(IS_NOT_BROKEN)" to a "if (IS_ENABLED(IS_NOT_BROKEN))".
I don't really know how to make it better so I left it like that.

Compile-tested with allyesconfig, with the following cases:
- CONFIG_PM=y CONFIG_PM_SLEEP=y
- CONFIG_PM=y CONFIG_PM_SLEEP=n
- CONFIG_PM=n

V2:
- Patch [1/26] now adds a macro named
  DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() instead of exporting a
  dev_pm_ops instance.
- Patches [3/26] to [7/26] are updated accordingly.
- I updated the description of patches [12/26], [20/26] and [23/26].
  The code itself did not change.

Note that I can commit to drm-misc-next but not drm-next, so I cannot
apply this patchset myself when it's all properly tagged.

Cheers,
-Paul


Paul Cercueil (26):
  drm: modeset-helper: Add DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS macro
  drm: bochs: Define and use generic PM ops
  drm: imx: Define and use generic PM ops
  drm: rockchip: Define and use generic PM ops
  drm: tegra: Define and use generic PM ops
  drm: sun4i: Define and use generic PM ops
  drm: mxsfb: Define and use generic PM ops
  drm: atmel-hlcdc: Remove #ifdef guards for PM related functions
  drm: exynos: Remove #ifdef guards for PM related functions
  drm: imx/dcss: Remove #ifdef guards for PM related functions
  drm: bridge/dw-hdmi: Remove #ifdef guards for PM related functions
  drm: etnaviv: Remove #ifdef guards for PM related functions
  drm: fsl-dcu: Remove #ifdef guards for PM related functions
  drm: mediatek: Remove #ifdef guards for PM related functions
  drm: omap: Remove #ifdef guards for PM related functions
  drm: panfrost: Remove #ifdef guards for PM related functions
  drm: rcar-du: Remove #ifdef guards for PM related functions
  drm: rockchip: Remove #ifdef guards for PM related functions
  drm: shmobile: Remove #ifdef guards for PM related functions
  drm: tegra: Remove #ifdef guards for PM related functions
  drm: tilcdc: Remove #ifdef guards for PM related functions
  drm: vboxvideo: Remove #ifdef guards for PM related functions
  drm: vc4: Remove #ifdef guards for PM related functions
  drm: gm12u320: Remove #ifdef guards for PM related functions
  drm: tidss: Remove #ifdef guards for PM related functions
  drm/i915/gt: Remove #ifdef guards for PM related functions

 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c  |  9 ++---
 .../drm/bridge/synopsys/dw-hdmi-ahb-audio.c   | 17 ++++-----
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c         | 30 ++++++---------
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 13 ++-----
 drivers/gpu/drm/exynos/exynos7_drm_decon.c    | 12 ++----
 drivers/gpu/drm/exynos/exynos_dp.c            | 11 ++----
 drivers/gpu/drm/exynos/exynos_drm_fimc.c      | 11 ++----
 drivers/gpu/drm/exynos/exynos_drm_fimd.c      | 11 ++----
 drivers/gpu/drm/exynos/exynos_drm_g2d.c       | 10 ++---
 drivers/gpu/drm/exynos/exynos_drm_mic.c       | 11 ++----
 drivers/gpu/drm/exynos/exynos_drm_rotator.c   | 12 ++----
 drivers/gpu/drm/exynos/exynos_drm_scaler.c    | 12 ++----
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c     |  9 ++---
 drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c   |  8 +---
 drivers/gpu/drm/imx/dcss/dcss-dev.c           | 17 +++++----
 drivers/gpu/drm/imx/dcss/dcss-dev.h           |  7 ++--
 drivers/gpu/drm/imx/dcss/dcss-drv.c           |  8 +---
 drivers/gpu/drm/imx/imx-drm-core.c            | 23 ++---------
 drivers/gpu/drm/mediatek/mtk_dp.c             |  6 +--
 drivers/gpu/drm/mediatek/mtk_hdmi.c           |  9 ++---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c             | 22 +----------
 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 -
 drivers/gpu/drm/panfrost/panfrost_device.c    | 10 +++--
 drivers/gpu/drm/panfrost/panfrost_device.h    |  4 +-
 drivers/gpu/drm/panfrost/panfrost_drv.c       |  7 +---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c         |  9 ++---
 .../gpu/drm/rockchip/analogix_dp-rockchip.c   |  6 +--
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c   | 25 ++----------
 drivers/gpu/drm/shmobile/shmob_drm_drv.c      |  9 ++---
 drivers/gpu/drm/sun4i/sun4i_drv.c             | 26 ++-----------
 drivers/gpu/drm/tegra/dpaux.c                 |  6 +--
 drivers/gpu/drm/tegra/drm.c                   | 23 ++---------
 drivers/gpu/drm/tidss/tidss_drv.c             | 29 +++++++-------
 drivers/gpu/drm/tilcdc/tilcdc_drv.c           |  9 ++---
 drivers/gpu/drm/tiny/bochs.c                  | 29 ++------------
 drivers/gpu/drm/tiny/gm12u320.c               | 15 ++++----
 drivers/gpu/drm/vboxvideo/vbox_drv.c          |  6 +--
 drivers/gpu/drm/vc4/vc4_v3d.c                 |  6 +--
 include/drm/drm_modeset_helper.h              | 38 +++++++++++++++++++
 42 files changed, 184 insertions(+), 361 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH v2 01/26] drm: modeset-helper: Add DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS macro
  2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
@ 2022-11-29 19:17 ` Paul Cercueil
  2022-11-29 19:17 ` [PATCH v2 02/26] drm: bochs: Define and use generic PM ops Paul Cercueil
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:17 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter; +Cc: Paul Cercueil, linux-kernel, dri-devel

This macro can be used with simple drivers, which have their
"struct drm_device" registered as their "struct device"'s drvdata, and
only call drm_mode_config_pm_{suspend,resume}.

The macro will define a "struct dev_pm_ops" with the name passed as
argument. This object cannot be referenced directly; instead, the
pm_sleep_ptr() macro should be used, like this:

DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS(foo_pm_ops);

static struct platform_driver foo_driver = {
    .driver.pm = pm_sleep_ptr(&foo_pm_ops),
    ...
};

This ensures that the generated code will be dropped by the compiler in
the case where CONFIG_PM has been disabled in the config.

v2: instead of exporting a dev_pm_ops, introduce the
    DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 include/drm/drm_modeset_helper.h | 38 ++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/include/drm/drm_modeset_helper.h b/include/drm/drm_modeset_helper.h
index 995fd981cab0..2ecf0e5c2e16 100644
--- a/include/drm/drm_modeset_helper.h
+++ b/include/drm/drm_modeset_helper.h
@@ -41,4 +41,42 @@ int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
 int drm_mode_config_helper_suspend(struct drm_device *dev);
 int drm_mode_config_helper_resume(struct drm_device *dev);
 
+/**
+ * DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS - Generate simple PM callbacks
+ *
+ * This macro can be used by simple drivers that would otherwise only call
+ * drm_mode_config_helper_suspend / drm_mode_config_helper_resume in their PM
+ * callbacks. It will generate a struct dev_pm_ops of the given name, that can
+ * then be referenced in the device_driver structure.
+ *
+ * Note that it is only valid if the driver's drm_device has been registered as
+ * the struct device's drvdata.
+ *
+ * Additionally, the generated dev_pm_ops structure should not be referenced
+ * directly; instead, the pm_sleep_ptr() macro should be used, like this:
+ *
+ * DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS(foo_pm_ops);
+ *
+ * static struct platform_driver foo_driver = {
+ *	.driver.pm = pm_sleep_ptr(&foo_pm_ops),
+ *	...
+ * };
+ *
+ * This ensures that the generated code will be dropped by the compiler in the
+ * case where CONFIG_PM has been disabled in the config.
++ */
+
+#define DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS(_name) \
+	static int __##_name##_drm_mode_config_pm_suspend(struct device *dev) \
+	{ \
+		return drm_mode_config_helper_suspend(dev_get_drvdata(dev)); \
+	} \
+	static int __##_name##_drm_mode_config_pm_resume(struct device *dev) \
+	{ \
+		return drm_mode_config_helper_resume(dev_get_drvdata(dev)); \
+	} \
+	static DEFINE_SIMPLE_DEV_PM_OPS(_name, \
+					__##_name##_drm_mode_config_pm_suspend, \
+					__##_name##_drm_mode_config_pm_resume)
+
 #endif
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 02/26] drm: bochs: Define and use generic PM ops
  2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
  2022-11-29 19:17 ` [PATCH v2 01/26] drm: modeset-helper: Add DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS macro Paul Cercueil
@ 2022-11-29 19:17 ` Paul Cercueil
  2022-11-29 19:17 ` [PATCH v2 03/26] drm: imx: " Paul Cercueil
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:17 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Paul Cercueil, virtualization, linux-kernel, dri-devel, Gerd Hoffmann

Use the new DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro to create a
"struct dev_pm_ops" that can be used by this driver, instead of using
custom PM callbacks with the same behaviour.

v2: Use the DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro instead of an
    exported dev_pm_ops.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
---
 drivers/gpu/drm/tiny/bochs.c | 29 ++++-------------------------
 1 file changed, 4 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
index 024346054c70..598488905607 100644
--- a/drivers/gpu/drm/tiny/bochs.c
+++ b/drivers/gpu/drm/tiny/bochs.c
@@ -2,6 +2,7 @@
 
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/pm.h>
 
 #include <drm/drm_aperture.h>
 #include <drm/drm_atomic_helper.h>
@@ -610,30 +611,6 @@ static const struct drm_driver bochs_driver = {
 	DRM_GEM_VRAM_DRIVER,
 };
 
-/* ---------------------------------------------------------------------- */
-/* pm interface                                                           */
-
-#ifdef CONFIG_PM_SLEEP
-static int bochs_pm_suspend(struct device *dev)
-{
-	struct drm_device *drm_dev = dev_get_drvdata(dev);
-
-	return drm_mode_config_helper_suspend(drm_dev);
-}
-
-static int bochs_pm_resume(struct device *dev)
-{
-	struct drm_device *drm_dev = dev_get_drvdata(dev);
-
-	return drm_mode_config_helper_resume(drm_dev);
-}
-#endif
-
-static const struct dev_pm_ops bochs_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(bochs_pm_suspend,
-				bochs_pm_resume)
-};
-
 /* ---------------------------------------------------------------------- */
 /* pci interface                                                          */
 
@@ -716,12 +693,14 @@ static const struct pci_device_id bochs_pci_tbl[] = {
 	{ /* end of list */ }
 };
 
+DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS(bochs_pm_ops);
+
 static struct pci_driver bochs_pci_driver = {
 	.name =		"bochs-drm",
 	.id_table =	bochs_pci_tbl,
 	.probe =	bochs_pci_probe,
 	.remove =	bochs_pci_remove,
-	.driver.pm =    &bochs_pm_ops,
+	.driver.pm =    pm_sleep_ptr(&bochs_pm_ops),
 };
 
 /* ---------------------------------------------------------------------- */
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 03/26] drm: imx: Define and use generic PM ops
  2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
  2022-11-29 19:17 ` [PATCH v2 01/26] drm: modeset-helper: Add DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS macro Paul Cercueil
  2022-11-29 19:17 ` [PATCH v2 02/26] drm: bochs: Define and use generic PM ops Paul Cercueil
@ 2022-11-29 19:17 ` Paul Cercueil
  2022-11-29 19:17 ` [PATCH v2 04/26] drm: rockchip: " Paul Cercueil
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:17 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Pengutronix Kernel Team, Sascha Hauer, linux-kernel, dri-devel,
	Paul Cercueil, NXP Linux Team, Shawn Guo, linux-arm-kernel

Use the new DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro to create a
"struct dev_pm_ops" that can be used by this driver, instead of using
custom PM callbacks with the same behaviour.

v2: Use the DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro instead of an
    exported dev_pm_ops.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/gpu/drm/imx/imx-drm-core.c | 23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index e060fa6cbcb9..1992934034e0 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -10,6 +10,7 @@
 #include <linux/dma-buf.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <video/imx-ipu-v3.h>
 
@@ -298,36 +299,20 @@ static int imx_drm_platform_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int imx_drm_suspend(struct device *dev)
-{
-	struct drm_device *drm_dev = dev_get_drvdata(dev);
-
-	return drm_mode_config_helper_suspend(drm_dev);
-}
-
-static int imx_drm_resume(struct device *dev)
-{
-	struct drm_device *drm_dev = dev_get_drvdata(dev);
-
-	return drm_mode_config_helper_resume(drm_dev);
-}
-#endif
-
-static SIMPLE_DEV_PM_OPS(imx_drm_pm_ops, imx_drm_suspend, imx_drm_resume);
-
 static const struct of_device_id imx_drm_dt_ids[] = {
 	{ .compatible = "fsl,imx-display-subsystem", },
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, imx_drm_dt_ids);
 
+DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS(imx_pm_ops);
+
 static struct platform_driver imx_drm_pdrv = {
 	.probe		= imx_drm_platform_probe,
 	.remove		= imx_drm_platform_remove,
 	.driver		= {
 		.name	= "imx-drm",
-		.pm	= &imx_drm_pm_ops,
+		.pm	= pm_sleep_ptr(&imx_pm_ops),
 		.of_match_table = imx_drm_dt_ids,
 	},
 };
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 04/26] drm: rockchip: Define and use generic PM ops
  2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (2 preceding siblings ...)
  2022-11-29 19:17 ` [PATCH v2 03/26] drm: imx: " Paul Cercueil
@ 2022-11-29 19:17 ` Paul Cercueil
  2022-11-29 19:17 ` [PATCH v2 05/26] drm: tegra: " Paul Cercueil
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:17 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: linux-kernel, dri-devel, Sandy Huang, Paul Cercueil,
	linux-rockchip, linux-arm-kernel

Use the new DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro to create a
"struct dev_pm_ops" that can be used by this driver, instead of using
custom PM callbacks with the same behaviour.

v2: Use the DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro instead of an
    exported dev_pm_ops.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 25 +++------------------
 1 file changed, 3 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 6e0788d14c10..ec117c52cb24 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -236,27 +236,6 @@ static const struct drm_driver rockchip_drm_driver = {
 	.minor	= DRIVER_MINOR,
 };
 
-#ifdef CONFIG_PM_SLEEP
-static int rockchip_drm_sys_suspend(struct device *dev)
-{
-	struct drm_device *drm = dev_get_drvdata(dev);
-
-	return drm_mode_config_helper_suspend(drm);
-}
-
-static int rockchip_drm_sys_resume(struct device *dev)
-{
-	struct drm_device *drm = dev_get_drvdata(dev);
-
-	return drm_mode_config_helper_resume(drm);
-}
-#endif
-
-static const struct dev_pm_ops rockchip_drm_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(rockchip_drm_sys_suspend,
-				rockchip_drm_sys_resume)
-};
-
 #define MAX_ROCKCHIP_SUB_DRIVERS 16
 static struct platform_driver *rockchip_sub_drivers[MAX_ROCKCHIP_SUB_DRIVERS];
 static int num_rockchip_sub_drivers;
@@ -473,6 +452,8 @@ static const struct of_device_id rockchip_drm_dt_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, rockchip_drm_dt_ids);
 
+DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS(rockchip_pm_ops);
+
 static struct platform_driver rockchip_drm_platform_driver = {
 	.probe = rockchip_drm_platform_probe,
 	.remove = rockchip_drm_platform_remove,
@@ -480,7 +461,7 @@ static struct platform_driver rockchip_drm_platform_driver = {
 	.driver = {
 		.name = "rockchip-drm",
 		.of_match_table = rockchip_drm_dt_ids,
-		.pm = &rockchip_drm_pm_ops,
+		.pm = pm_sleep_ptr(&rockchip_pm_ops),
 	},
 };
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 05/26] drm: tegra: Define and use generic PM ops
  2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (3 preceding siblings ...)
  2022-11-29 19:17 ` [PATCH v2 04/26] drm: rockchip: " Paul Cercueil
@ 2022-11-29 19:17 ` Paul Cercueil
  2022-11-29 19:17 ` [PATCH v2 06/26] drm: sun4i: " Paul Cercueil
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:17 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: linux-kernel, dri-devel, Jonathan Hunter, Paul Cercueil,
	Thierry Reding, linux-tegra

Use the new DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro to create a
"struct dev_pm_ops" that can be used by this driver, instead of using
custom PM callbacks with the same behaviour.

v2: Use the DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro instead of an
    exported dev_pm_ops.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: linux-tegra@vger.kernel.org
---
 drivers/gpu/drm/tegra/drm.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index a1f909dac89a..c844444ff522 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -1329,25 +1329,6 @@ static int host1x_drm_remove(struct host1x_device *dev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int host1x_drm_suspend(struct device *dev)
-{
-	struct drm_device *drm = dev_get_drvdata(dev);
-
-	return drm_mode_config_helper_suspend(drm);
-}
-
-static int host1x_drm_resume(struct device *dev)
-{
-	struct drm_device *drm = dev_get_drvdata(dev);
-
-	return drm_mode_config_helper_resume(drm);
-}
-#endif
-
-static SIMPLE_DEV_PM_OPS(host1x_drm_pm_ops, host1x_drm_suspend,
-			 host1x_drm_resume);
-
 static const struct of_device_id host1x_drm_subdevs[] = {
 	{ .compatible = "nvidia,tegra20-dc", },
 	{ .compatible = "nvidia,tegra20-hdmi", },
@@ -1389,10 +1370,12 @@ static const struct of_device_id host1x_drm_subdevs[] = {
 	{ /* sentinel */ }
 };
 
+DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS(tegra_pm_ops);
+
 static struct host1x_driver host1x_drm_driver = {
 	.driver = {
 		.name = "drm",
-		.pm = &host1x_drm_pm_ops,
+		.pm = pm_sleep_ptr(&tegra_pm_ops),
 	},
 	.probe = host1x_drm_probe,
 	.remove = host1x_drm_remove,
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 06/26] drm: sun4i: Define and use generic PM ops
  2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (4 preceding siblings ...)
  2022-11-29 19:17 ` [PATCH v2 05/26] drm: tegra: " Paul Cercueil
@ 2022-11-29 19:17 ` Paul Cercueil
  2022-11-30  4:08   ` Samuel Holland
  2022-11-29 19:17 ` [PATCH v2 07/26] drm: mxsfb: " Paul Cercueil
                   ` (8 subsequent siblings)
  14 siblings, 1 reply; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:17 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Samuel Holland, linux-kernel, Jernej Skrabec, Paul Cercueil,
	Chen-Yu Tsai, dri-devel, linux-sunxi, linux-arm-kernel

Use the new DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro to create a
"struct dev_pm_ops" that can be used by this driver, instead of using
custom PM callbacks with the same behaviour.

v2: Use the DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro instead of an
    exported dev_pm_ops.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---

Samuel: since the code changed I had to remove your reviewed-by, sorry
        about that.

Cc: Maxime Ripard <mripard@kernel.org>
Cc: Chen-Yu Tsai <wens@csie.org>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: Samuel Holland <samuel@sholland.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-sunxi@lists.linux.dev
---
 drivers/gpu/drm/sun4i/sun4i_drv.c | 26 ++++----------------------
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index cc94efbbf2d4..178ada09b467 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -13,6 +13,7 @@
 #include <linux/of_graph.h>
 #include <linux/of_reserved_mem.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 
 #include <drm/drm_aperture.h>
 #include <drm/drm_atomic_helper.h>
@@ -339,27 +340,6 @@ static int sun4i_drv_add_endpoints(struct device *dev,
 	return count;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int sun4i_drv_drm_sys_suspend(struct device *dev)
-{
-	struct drm_device *drm = dev_get_drvdata(dev);
-
-	return drm_mode_config_helper_suspend(drm);
-}
-
-static int sun4i_drv_drm_sys_resume(struct device *dev)
-{
-	struct drm_device *drm = dev_get_drvdata(dev);
-
-	return drm_mode_config_helper_resume(drm);
-}
-#endif
-
-static const struct dev_pm_ops sun4i_drv_drm_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sun4i_drv_drm_sys_suspend,
-				sun4i_drv_drm_sys_resume)
-};
-
 static int sun4i_drv_probe(struct platform_device *pdev)
 {
 	struct component_match *match = NULL;
@@ -434,13 +414,15 @@ static const struct of_device_id sun4i_drv_of_table[] = {
 };
 MODULE_DEVICE_TABLE(of, sun4i_drv_of_table);
 
+DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS(sun4i_pm_ops);
+
 static struct platform_driver sun4i_drv_platform_driver = {
 	.probe		= sun4i_drv_probe,
 	.remove		= sun4i_drv_remove,
 	.driver		= {
 		.name		= "sun4i-drm",
 		.of_match_table	= sun4i_drv_of_table,
-		.pm = &sun4i_drv_drm_pm_ops,
+		.pm = pm_sleep_ptr(&sun4i_pm_ops),
 	},
 };
 drm_module_platform_driver(sun4i_drv_platform_driver);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 07/26] drm: mxsfb: Define and use generic PM ops
  2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (5 preceding siblings ...)
  2022-11-29 19:17 ` [PATCH v2 06/26] drm: sun4i: " Paul Cercueil
@ 2022-11-29 19:17 ` Paul Cercueil
  2022-11-29 21:48   ` Marek Vasut
  2022-11-29 19:17 ` [PATCH v2 08/26] drm: atmel-hlcdc: Remove #ifdef guards for PM related functions Paul Cercueil
                   ` (7 subsequent siblings)
  14 siblings, 1 reply; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:17 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Marek Vasut, Sascha Hauer, linux-kernel, Paul Cercueil,
	dri-devel, Pengutronix Kernel Team, Shawn Guo, linux-arm-kernel,
	NXP Linux Team

Use the new DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro to create a
"struct dev_pm_ops" that can be used by this driver, instead of using
custom PM callbacks with the same behaviour.

v2: Use the DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro instead of an
    exported dev_pm_ops.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
Cc: Marek Vasut <marex@denx.de>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index 810edea0a31e..c63d2eb3b379 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -398,25 +398,7 @@ static void mxsfb_shutdown(struct platform_device *pdev)
 	drm_atomic_helper_shutdown(drm);
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int mxsfb_suspend(struct device *dev)
-{
-	struct drm_device *drm = dev_get_drvdata(dev);
-
-	return drm_mode_config_helper_suspend(drm);
-}
-
-static int mxsfb_resume(struct device *dev)
-{
-	struct drm_device *drm = dev_get_drvdata(dev);
-
-	return drm_mode_config_helper_resume(drm);
-}
-#endif
-
-static const struct dev_pm_ops mxsfb_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(mxsfb_suspend, mxsfb_resume)
-};
+DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS(mxsfb_pm_ops);
 
 static struct platform_driver mxsfb_platform_driver = {
 	.probe		= mxsfb_probe,
@@ -425,7 +407,7 @@ static struct platform_driver mxsfb_platform_driver = {
 	.driver	= {
 		.name		= "mxsfb",
 		.of_match_table	= mxsfb_dt_ids,
-		.pm		= &mxsfb_pm_ops,
+		.pm		= pm_sleep_ptr(&mxsfb_pm_ops),
 	},
 };
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 08/26] drm: atmel-hlcdc: Remove #ifdef guards for PM related functions
  2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (6 preceding siblings ...)
  2022-11-29 19:17 ` [PATCH v2 07/26] drm: mxsfb: " Paul Cercueil
@ 2022-11-29 19:17 ` Paul Cercueil
  2022-11-29 19:17 ` [PATCH v2 09/26] drm: exynos: " Paul Cercueil
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:17 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Alexandre Belloni, Boris Brezillon, linux-kernel, dri-devel,
	Nicolas Ferre, Paul Cercueil, Sam Ravnborg, Claudiu Beznea,
	linux-arm-kernel

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 <paul@crapouillou.net>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Boris Brezillon <bbrezillon@kernel.org>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Claudiu Beznea <claudiu.beznea@microchip.com>
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index a2bb5b916235..4e806b06d35d 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -784,7 +784,6 @@ static int atmel_hlcdc_dc_drm_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int atmel_hlcdc_dc_drm_suspend(struct device *dev)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
@@ -815,10 +814,10 @@ static int atmel_hlcdc_dc_drm_resume(struct device *dev)
 
 	return drm_atomic_helper_resume(drm_dev, dc->suspend.state);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(atmel_hlcdc_dc_drm_pm_ops,
-		atmel_hlcdc_dc_drm_suspend, atmel_hlcdc_dc_drm_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(atmel_hlcdc_dc_drm_pm_ops,
+				atmel_hlcdc_dc_drm_suspend,
+				atmel_hlcdc_dc_drm_resume);
 
 static const struct of_device_id atmel_hlcdc_dc_of_match[] = {
 	{ .compatible = "atmel,hlcdc-display-controller" },
@@ -830,7 +829,7 @@ static struct platform_driver atmel_hlcdc_dc_platform_driver = {
 	.remove	= atmel_hlcdc_dc_drm_remove,
 	.driver	= {
 		.name	= "atmel-hlcdc-display-controller",
-		.pm	= &atmel_hlcdc_dc_drm_pm_ops,
+		.pm	= pm_sleep_ptr(&atmel_hlcdc_dc_drm_pm_ops),
 		.of_match_table = atmel_hlcdc_dc_of_match,
 	},
 };
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 09/26] drm: exynos: Remove #ifdef guards for PM related functions
  2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (7 preceding siblings ...)
  2022-11-29 19:17 ` [PATCH v2 08/26] drm: atmel-hlcdc: Remove #ifdef guards for PM related functions Paul Cercueil
@ 2022-11-29 19:17 ` Paul Cercueil
  2022-11-29 19:17 ` [PATCH v2 10/26] drm: imx/dcss: " Paul Cercueil
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:17 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: linux-samsung-soc, Jingoo Han, Seung-Woo Kim, linux-kernel,
	dri-devel, Paul Cercueil, Krzysztof Kozlowski, Kyungmin Park,
	Alim Akhtar, linux-arm-kernel

Use the DEFINE_RUNTIME_DEV_PM_OPS(), SYSTEM_SLEEP_PM_OPS(),
RUNTIME_PM_OPS() and pm_ptr() macros to handle the runtime and suspend
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.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Acked-by : Inki Dae <inki.dae@samsung.com>
---
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 13 ++++---------
 drivers/gpu/drm/exynos/exynos7_drm_decon.c    | 12 +++---------
 drivers/gpu/drm/exynos/exynos_dp.c            | 11 +++--------
 drivers/gpu/drm/exynos/exynos_drm_fimc.c      | 11 +++--------
 drivers/gpu/drm/exynos/exynos_drm_fimd.c      | 11 +++--------
 drivers/gpu/drm/exynos/exynos_drm_g2d.c       | 10 +++-------
 drivers/gpu/drm/exynos/exynos_drm_mic.c       | 11 +++--------
 drivers/gpu/drm/exynos/exynos_drm_rotator.c   | 12 +++---------
 drivers/gpu/drm/exynos/exynos_drm_scaler.c    | 12 +++---------
 9 files changed, 28 insertions(+), 75 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index 8155d7e650f1..2867b39fa35e 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -710,7 +710,6 @@ static irqreturn_t decon_irq_handler(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-#ifdef CONFIG_PM
 static int exynos5433_decon_suspend(struct device *dev)
 {
 	struct decon_context *ctx = dev_get_drvdata(dev);
@@ -741,14 +740,10 @@ static int exynos5433_decon_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-static const struct dev_pm_ops exynos5433_decon_pm_ops = {
-	SET_RUNTIME_PM_OPS(exynos5433_decon_suspend, exynos5433_decon_resume,
-			   NULL)
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				     pm_runtime_force_resume)
-};
+static DEFINE_RUNTIME_DEV_PM_OPS(exynos5433_decon_pm_ops,
+				 exynos5433_decon_suspend,
+				 exynos5433_decon_resume, NULL);
 
 static const struct of_device_id exynos5433_decon_driver_dt_match[] = {
 	{
@@ -881,7 +876,7 @@ struct platform_driver exynos5433_decon_driver = {
 	.remove		= exynos5433_decon_remove,
 	.driver		= {
 		.name	= "exynos5433-decon",
-		.pm	= &exynos5433_decon_pm_ops,
+		.pm	= pm_ptr(&exynos5433_decon_pm_ops),
 		.of_match_table = exynos5433_decon_driver_dt_match,
 	},
 };
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index 7080cf7952ec..3126f735dedc 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -779,7 +779,6 @@ static int decon_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int exynos7_decon_suspend(struct device *dev)
 {
 	struct decon_context *ctx = dev_get_drvdata(dev);
@@ -836,21 +835,16 @@ static int exynos7_decon_resume(struct device *dev)
 err_pclk_enable:
 	return ret;
 }
-#endif
 
-static const struct dev_pm_ops exynos7_decon_pm_ops = {
-	SET_RUNTIME_PM_OPS(exynos7_decon_suspend, exynos7_decon_resume,
-			   NULL)
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-};
+static DEFINE_RUNTIME_DEV_PM_OPS(exynos7_decon_pm_ops, exynos7_decon_suspend,
+				 exynos7_decon_resume, NULL);
 
 struct platform_driver decon_driver = {
 	.probe		= decon_probe,
 	.remove		= decon_remove,
 	.driver		= {
 		.name	= "exynos-decon",
-		.pm	= &exynos7_decon_pm_ops,
+		.pm	= pm_ptr(&exynos7_decon_pm_ops),
 		.of_match_table = decon_driver_dt_match,
 	},
 };
diff --git a/drivers/gpu/drm/exynos/exynos_dp.c b/drivers/gpu/drm/exynos/exynos_dp.c
index 4e3d3d5f6866..3404ec1367fb 100644
--- a/drivers/gpu/drm/exynos/exynos_dp.c
+++ b/drivers/gpu/drm/exynos/exynos_dp.c
@@ -260,7 +260,6 @@ static int exynos_dp_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int exynos_dp_suspend(struct device *dev)
 {
 	struct exynos_dp_device *dp = dev_get_drvdata(dev);
@@ -274,13 +273,9 @@ static int exynos_dp_resume(struct device *dev)
 
 	return analogix_dp_resume(dp->adp);
 }
-#endif
 
-static const struct dev_pm_ops exynos_dp_pm_ops = {
-	SET_RUNTIME_PM_OPS(exynos_dp_suspend, exynos_dp_resume, NULL)
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-};
+static DEFINE_RUNTIME_DEV_PM_OPS(exynos_dp_pm_ops, exynos_dp_suspend,
+				 exynos_dp_resume, NULL);
 
 static const struct of_device_id exynos_dp_match[] = {
 	{ .compatible = "samsung,exynos5-dp" },
@@ -294,7 +289,7 @@ struct platform_driver dp_driver = {
 	.driver		= {
 		.name	= "exynos-dp",
 		.owner	= THIS_MODULE,
-		.pm	= &exynos_dp_pm_ops,
+		.pm	= pm_ptr(&exynos_dp_pm_ops),
 		.of_match_table = exynos_dp_match,
 	},
 };
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
index 0ee32e4b1e43..8de2714599fc 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
@@ -1381,7 +1381,6 @@ static int fimc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int fimc_runtime_suspend(struct device *dev)
 {
 	struct fimc_context *ctx = get_fimc_context(dev);
@@ -1398,13 +1397,9 @@ static int fimc_runtime_resume(struct device *dev)
 	DRM_DEV_DEBUG_KMS(dev, "id[%d]\n", ctx->id);
 	return clk_prepare_enable(ctx->clocks[FIMC_CLK_GATE]);
 }
-#endif
 
-static const struct dev_pm_ops fimc_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(fimc_runtime_suspend, fimc_runtime_resume, NULL)
-};
+static DEFINE_RUNTIME_DEV_PM_OPS(fimc_pm_ops, fimc_runtime_suspend,
+				 fimc_runtime_resume, NULL);
 
 static const struct of_device_id fimc_of_match[] = {
 	{ .compatible = "samsung,exynos4210-fimc" },
@@ -1420,6 +1415,6 @@ struct platform_driver fimc_driver = {
 		.of_match_table = fimc_of_match,
 		.name	= "exynos-drm-fimc",
 		.owner	= THIS_MODULE,
-		.pm	= &fimc_pm_ops,
+		.pm	= pm_ptr(&fimc_pm_ops),
 	},
 };
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index ae6636e6658e..7f4a0be03dd1 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -1287,7 +1287,6 @@ static int fimd_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int exynos_fimd_suspend(struct device *dev)
 {
 	struct fimd_context *ctx = dev_get_drvdata(dev);
@@ -1321,13 +1320,9 @@ static int exynos_fimd_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static const struct dev_pm_ops exynos_fimd_pm_ops = {
-	SET_RUNTIME_PM_OPS(exynos_fimd_suspend, exynos_fimd_resume, NULL)
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-};
+static DEFINE_RUNTIME_DEV_PM_OPS(exynos_fimd_pm_ops, exynos_fimd_suspend,
+				 exynos_fimd_resume, NULL);
 
 struct platform_driver fimd_driver = {
 	.probe		= fimd_probe,
@@ -1335,7 +1330,7 @@ struct platform_driver fimd_driver = {
 	.driver		= {
 		.name	= "exynos4-fb",
 		.owner	= THIS_MODULE,
-		.pm	= &exynos_fimd_pm_ops,
+		.pm	= pm_ptr(&exynos_fimd_pm_ops),
 		.of_match_table = fimd_driver_dt_match,
 	},
 };
diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
index 471fd6c8135f..7711cb67b807 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
@@ -1549,7 +1549,6 @@ static int g2d_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int g2d_suspend(struct device *dev)
 {
 	struct g2d_data *g2d = dev_get_drvdata(dev);
@@ -1574,9 +1573,7 @@ static int g2d_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-#ifdef CONFIG_PM
 static int g2d_runtime_suspend(struct device *dev)
 {
 	struct g2d_data *g2d = dev_get_drvdata(dev);
@@ -1597,11 +1594,10 @@ static int g2d_runtime_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
 static const struct dev_pm_ops g2d_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(g2d_suspend, g2d_resume)
-	SET_RUNTIME_PM_OPS(g2d_runtime_suspend, g2d_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(g2d_suspend, g2d_resume)
+	RUNTIME_PM_OPS(g2d_runtime_suspend, g2d_runtime_resume, NULL)
 };
 
 static const struct of_device_id exynos_g2d_match[] = {
@@ -1617,7 +1613,7 @@ struct platform_driver g2d_driver = {
 	.driver		= {
 		.name	= "exynos-drm-g2d",
 		.owner	= THIS_MODULE,
-		.pm	= &g2d_pm_ops,
+		.pm	= pm_ptr(&g2d_pm_ops),
 		.of_match_table = exynos_g2d_match,
 	},
 };
diff --git a/drivers/gpu/drm/exynos/exynos_drm_mic.c b/drivers/gpu/drm/exynos/exynos_drm_mic.c
index 09ce28ee08d9..17bab5b1663f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_mic.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_mic.c
@@ -340,7 +340,6 @@ static const struct component_ops exynos_mic_component_ops = {
 	.unbind	= exynos_mic_unbind,
 };
 
-#ifdef CONFIG_PM
 static int exynos_mic_suspend(struct device *dev)
 {
 	struct exynos_mic *mic = dev_get_drvdata(dev);
@@ -369,13 +368,9 @@ static int exynos_mic_resume(struct device *dev)
 	}
 	return 0;
 }
-#endif
 
-static const struct dev_pm_ops exynos_mic_pm_ops = {
-	SET_RUNTIME_PM_OPS(exynos_mic_suspend, exynos_mic_resume, NULL)
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-};
+static DEFINE_RUNTIME_DEV_PM_OPS(exynos_mic_pm_ops, exynos_mic_suspend,
+				 exynos_mic_resume, NULL);
 
 static int exynos_mic_probe(struct platform_device *pdev)
 {
@@ -470,7 +465,7 @@ struct platform_driver mic_driver = {
 	.remove		= exynos_mic_remove,
 	.driver		= {
 		.name	= "exynos-mic",
-		.pm	= &exynos_mic_pm_ops,
+		.pm	= pm_ptr(&exynos_mic_pm_ops),
 		.owner	= THIS_MODULE,
 		.of_match_table = exynos_mic_of_match,
 	},
diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
index dec7df35baa9..8706f377c349 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
@@ -340,7 +340,6 @@ static int rotator_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int rotator_runtime_suspend(struct device *dev)
 {
 	struct rot_context *rot = dev_get_drvdata(dev);
@@ -355,7 +354,6 @@ static int rotator_runtime_resume(struct device *dev)
 
 	return clk_prepare_enable(rot->clock);
 }
-#endif
 
 static const struct drm_exynos_ipp_limit rotator_s5pv210_rbg888_limits[] = {
 	{ IPP_SIZE_LIMIT(BUFFER, .h = { 8, SZ_16K }, .v = { 8, SZ_16K }) },
@@ -450,12 +448,8 @@ static const struct of_device_id exynos_rotator_match[] = {
 };
 MODULE_DEVICE_TABLE(of, exynos_rotator_match);
 
-static const struct dev_pm_ops rotator_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(rotator_runtime_suspend, rotator_runtime_resume,
-									NULL)
-};
+static DEFINE_RUNTIME_DEV_PM_OPS(rotator_pm_ops, rotator_runtime_suspend,
+				 rotator_runtime_resume, NULL);
 
 struct platform_driver rotator_driver = {
 	.probe		= rotator_probe,
@@ -463,7 +457,7 @@ struct platform_driver rotator_driver = {
 	.driver		= {
 		.name	= "exynos-rotator",
 		.owner	= THIS_MODULE,
-		.pm	= &rotator_pm_ops,
+		.pm	= pm_ptr(&rotator_pm_ops),
 		.of_match_table = exynos_rotator_match,
 	},
 };
diff --git a/drivers/gpu/drm/exynos/exynos_drm_scaler.c b/drivers/gpu/drm/exynos/exynos_drm_scaler.c
index 3c049fb658a3..20608e9780ce 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_scaler.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_scaler.c
@@ -550,8 +550,6 @@ static int scaler_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-
 static int clk_disable_unprepare_wrapper(struct clk *clk)
 {
 	clk_disable_unprepare(clk);
@@ -584,13 +582,9 @@ static int scaler_runtime_resume(struct device *dev)
 
 	return  scaler_clk_ctrl(scaler, true);
 }
-#endif
 
-static const struct dev_pm_ops scaler_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(scaler_runtime_suspend, scaler_runtime_resume, NULL)
-};
+static DEFINE_RUNTIME_DEV_PM_OPS(scaler_pm_ops, scaler_runtime_suspend,
+				 scaler_runtime_resume, NULL);
 
 static const struct drm_exynos_ipp_limit scaler_5420_two_pixel_hv_limits[] = {
 	{ IPP_SIZE_LIMIT(BUFFER, .h = { 16, SZ_8K }, .v = { 16, SZ_8K }) },
@@ -731,7 +725,7 @@ struct platform_driver scaler_driver = {
 	.driver		= {
 		.name	= "exynos-scaler",
 		.owner	= THIS_MODULE,
-		.pm	= &scaler_pm_ops,
+		.pm	= pm_ptr(&scaler_pm_ops),
 		.of_match_table = exynos_scaler_match,
 	},
 };
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 10/26] drm: imx/dcss: Remove #ifdef guards for PM related functions
  2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (8 preceding siblings ...)
  2022-11-29 19:17 ` [PATCH v2 09/26] drm: exynos: " Paul Cercueil
@ 2022-11-29 19:17 ` Paul Cercueil
  2022-11-29 19:17 ` [PATCH v2 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:17 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Pengutronix Kernel Team, Sascha Hauer, linux-kernel, dri-devel,
	Paul Cercueil, NXP Linux Team, Laurentiu Palcu, Shawn Guo,
	linux-arm-kernel

Use the EXPORT_GPL_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 <paul@crapouillou.net>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Tested-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
---
Cc: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/gpu/drm/imx/dcss/dcss-dev.c | 17 +++++++++--------
 drivers/gpu/drm/imx/dcss/dcss-dev.h |  7 +++----
 drivers/gpu/drm/imx/dcss/dcss-drv.c |  8 +-------
 3 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/imx/dcss/dcss-dev.c b/drivers/gpu/drm/imx/dcss/dcss-dev.c
index 3f5750cc2673..66d9233ffb98 100644
--- a/drivers/gpu/drm/imx/dcss/dcss-dev.c
+++ b/drivers/gpu/drm/imx/dcss/dcss-dev.c
@@ -249,8 +249,7 @@ void dcss_dev_destroy(struct dcss_dev *dcss)
 	kfree(dcss);
 }
 
-#ifdef CONFIG_PM_SLEEP
-int dcss_dev_suspend(struct device *dev)
+static int dcss_dev_suspend(struct device *dev)
 {
 	struct dcss_dev *dcss = dcss_drv_dev_to_dcss(dev);
 	struct drm_device *ddev = dcss_drv_dev_to_drm(dev);
@@ -273,7 +272,7 @@ int dcss_dev_suspend(struct device *dev)
 	return 0;
 }
 
-int dcss_dev_resume(struct device *dev)
+static int dcss_dev_resume(struct device *dev)
 {
 	struct dcss_dev *dcss = dcss_drv_dev_to_dcss(dev);
 	struct drm_device *ddev = dcss_drv_dev_to_drm(dev);
@@ -296,10 +295,8 @@ int dcss_dev_resume(struct device *dev)
 
 	return 0;
 }
-#endif /* CONFIG_PM_SLEEP */
 
-#ifdef CONFIG_PM
-int dcss_dev_runtime_suspend(struct device *dev)
+static int dcss_dev_runtime_suspend(struct device *dev)
 {
 	struct dcss_dev *dcss = dcss_drv_dev_to_dcss(dev);
 	int ret;
@@ -313,7 +310,7 @@ int dcss_dev_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-int dcss_dev_runtime_resume(struct device *dev)
+static int dcss_dev_runtime_resume(struct device *dev)
 {
 	struct dcss_dev *dcss = dcss_drv_dev_to_dcss(dev);
 
@@ -325,4 +322,8 @@ int dcss_dev_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif /* CONFIG_PM */
+
+EXPORT_GPL_DEV_PM_OPS(dcss_dev_pm_ops) = {
+	RUNTIME_PM_OPS(dcss_dev_runtime_suspend, dcss_dev_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(dcss_dev_suspend, dcss_dev_resume)
+};
diff --git a/drivers/gpu/drm/imx/dcss/dcss-dev.h b/drivers/gpu/drm/imx/dcss/dcss-dev.h
index 1e582270c6ea..f27b87c09599 100644
--- a/drivers/gpu/drm/imx/dcss/dcss-dev.h
+++ b/drivers/gpu/drm/imx/dcss/dcss-dev.h
@@ -9,6 +9,7 @@
 #include <drm/drm_fourcc.h>
 #include <drm/drm_plane.h>
 #include <linux/io.h>
+#include <linux/pm.h>
 #include <video/videomode.h>
 
 #define SET			0x04
@@ -95,13 +96,11 @@ struct dcss_dev *dcss_drv_dev_to_dcss(struct device *dev);
 struct drm_device *dcss_drv_dev_to_drm(struct device *dev);
 struct dcss_dev *dcss_dev_create(struct device *dev, bool hdmi_output);
 void dcss_dev_destroy(struct dcss_dev *dcss);
-int dcss_dev_runtime_suspend(struct device *dev);
-int dcss_dev_runtime_resume(struct device *dev);
-int dcss_dev_suspend(struct device *dev);
-int dcss_dev_resume(struct device *dev);
 void dcss_enable_dtg_and_ss(struct dcss_dev *dcss);
 void dcss_disable_dtg_and_ss(struct dcss_dev *dcss);
 
+extern const struct dev_pm_ops dcss_dev_pm_ops;
+
 /* BLKCTL */
 int dcss_blkctl_init(struct dcss_dev *dcss, unsigned long blkctl_base);
 void dcss_blkctl_cfg(struct dcss_blkctl *blkctl);
diff --git a/drivers/gpu/drm/imx/dcss/dcss-drv.c b/drivers/gpu/drm/imx/dcss/dcss-drv.c
index 1c70f70247f6..431510bd811b 100644
--- a/drivers/gpu/drm/imx/dcss/dcss-drv.c
+++ b/drivers/gpu/drm/imx/dcss/dcss-drv.c
@@ -117,19 +117,13 @@ static const struct of_device_id dcss_of_match[] = {
 
 MODULE_DEVICE_TABLE(of, dcss_of_match);
 
-static const struct dev_pm_ops dcss_dev_pm = {
-	SET_SYSTEM_SLEEP_PM_OPS(dcss_dev_suspend, dcss_dev_resume)
-	SET_RUNTIME_PM_OPS(dcss_dev_runtime_suspend,
-			   dcss_dev_runtime_resume, NULL)
-};
-
 static struct platform_driver dcss_platform_driver = {
 	.probe	= dcss_drv_platform_probe,
 	.remove	= dcss_drv_platform_remove,
 	.driver	= {
 		.name = "imx-dcss",
 		.of_match_table	= dcss_of_match,
-		.pm = &dcss_dev_pm,
+		.pm = pm_ptr(&dcss_dev_pm_ops),
 	},
 };
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 11/26] drm: bridge/dw-hdmi: Remove #ifdef guards for PM related functions
  2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (9 preceding siblings ...)
  2022-11-29 19:17 ` [PATCH v2 10/26] drm: imx/dcss: " Paul Cercueil
@ 2022-11-29 19:17 ` Paul Cercueil
  2022-11-29 19:17 ` [PATCH v2 12/26] drm: etnaviv: " Paul Cercueil
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:17 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Neil Armstrong, Jernej Skrabec, Jonas Karlman, linux-kernel,
	Robert Foss, Paul Cercueil, dri-devel, Andrzej Hajda,
	Laurent Pinchart

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 IS_NOT_BROKEN guard was also changed to a
IS_ENABLED(IS_NOT_BROKEN) check within the PM functions.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
Note:
 Checkpatch complains as I replaced a "#if defined(IS_NOT_BROKEN)"
 to a "if (IS_ENABLED(IS_NOT_BROKEN))".
 I don't really know how to make it better so I left it like that.

Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Robert Foss <robert.foss@linaro.org>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
---
 .../gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
index 4efb62bcdb63..2ae231af7e4b 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
@@ -593,7 +593,6 @@ static int snd_dw_hdmi_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#if defined(CONFIG_PM_SLEEP) && defined(IS_NOT_BROKEN)
 /*
  * This code is fine, but requires implementation in the dw_hdmi_trigger()
  * method which is currently missing as I have no way to test this.
@@ -602,7 +601,8 @@ static int snd_dw_hdmi_suspend(struct device *dev)
 {
 	struct snd_dw_hdmi *dw = dev_get_drvdata(dev);
 
-	snd_power_change_state(dw->card, SNDRV_CTL_POWER_D3cold);
+	if (IS_ENABLED(IS_NOT_BROKEN))
+		snd_power_change_state(dw->card, SNDRV_CTL_POWER_D3cold);
 
 	return 0;
 }
@@ -611,24 +611,21 @@ static int snd_dw_hdmi_resume(struct device *dev)
 {
 	struct snd_dw_hdmi *dw = dev_get_drvdata(dev);
 
-	snd_power_change_state(dw->card, SNDRV_CTL_POWER_D0);
+	if (IS_ENABLED(IS_NOT_BROKEN))
+		snd_power_change_state(dw->card, SNDRV_CTL_POWER_D0);
 
 	return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(snd_dw_hdmi_pm, snd_dw_hdmi_suspend,
-			 snd_dw_hdmi_resume);
-#define PM_OPS &snd_dw_hdmi_pm
-#else
-#define PM_OPS NULL
-#endif
+static DEFINE_SIMPLE_DEV_PM_OPS(snd_dw_hdmi_pm_ops, snd_dw_hdmi_suspend,
+				snd_dw_hdmi_resume);
 
 static struct platform_driver snd_dw_hdmi_driver = {
 	.probe	= snd_dw_hdmi_probe,
 	.remove	= snd_dw_hdmi_remove,
 	.driver	= {
 		.name = DRIVER_NAME,
-		.pm = PM_OPS,
+		.pm = pm_sleep_ptr(&snd_dw_hdmi_pm_ops),
 	},
 };
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 12/26] drm: etnaviv: Remove #ifdef guards for PM related functions
  2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (10 preceding siblings ...)
  2022-11-29 19:17 ` [PATCH v2 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
@ 2022-11-29 19:17 ` Paul Cercueil
  2022-12-15 19:22   ` Lucas Stach
  2022-11-29 19:17 ` [PATCH v2 13/26] drm: fsl-dcu: " Paul Cercueil
                   ` (2 subsequent siblings)
  14 siblings, 1 reply; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:17 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: linux-kernel, dri-devel, etnaviv, Paul Cercueil, Russell King

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.

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

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Russell King <linux+etnaviv@armlinux.org.uk>
Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: etnaviv@lists.freedesktop.org
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 30 +++++++++++----------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index 51320eeebfcf..310382812029 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -1629,7 +1629,6 @@ static int etnaviv_gpu_hw_suspend(struct etnaviv_gpu *gpu)
 	return etnaviv_gpu_clk_disable(gpu);
 }
 
-#ifdef CONFIG_PM
 static int etnaviv_gpu_hw_resume(struct etnaviv_gpu *gpu)
 {
 	int ret;
@@ -1645,7 +1644,6 @@ static int etnaviv_gpu_hw_resume(struct etnaviv_gpu *gpu)
 
 	return 0;
 }
-#endif
 
 static int
 etnaviv_gpu_cooling_get_max_state(struct thermal_cooling_device *cdev,
@@ -1713,11 +1711,10 @@ static int etnaviv_gpu_bind(struct device *dev, struct device *master,
 	if (ret)
 		goto out_workqueue;
 
-#ifdef CONFIG_PM
-	ret = pm_runtime_get_sync(gpu->dev);
-#else
-	ret = etnaviv_gpu_clk_enable(gpu);
-#endif
+	if (IS_ENABLED(CONFIG_PM))
+		ret = pm_runtime_get_sync(gpu->dev);
+	else
+		ret = etnaviv_gpu_clk_enable(gpu);
 	if (ret < 0)
 		goto out_sched;
 
@@ -1761,12 +1758,12 @@ static void etnaviv_gpu_unbind(struct device *dev, struct device *master,
 
 	etnaviv_sched_fini(gpu);
 
-#ifdef CONFIG_PM
-	pm_runtime_get_sync(gpu->dev);
-	pm_runtime_put_sync_suspend(gpu->dev);
-#else
-	etnaviv_gpu_hw_suspend(gpu);
-#endif
+	if (IS_ENABLED(CONFIG_PM)) {
+		pm_runtime_get_sync(gpu->dev);
+		pm_runtime_put_sync_suspend(gpu->dev);
+	} else {
+		etnaviv_gpu_hw_suspend(gpu);
+	}
 
 	if (gpu->mmu_context)
 		etnaviv_iommu_context_put(gpu->mmu_context);
@@ -1880,7 +1877,6 @@ static int etnaviv_gpu_platform_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int etnaviv_gpu_rpm_suspend(struct device *dev)
 {
 	struct etnaviv_gpu *gpu = dev_get_drvdata(dev);
@@ -1923,18 +1919,16 @@ static int etnaviv_gpu_rpm_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops etnaviv_gpu_pm_ops = {
-	SET_RUNTIME_PM_OPS(etnaviv_gpu_rpm_suspend, etnaviv_gpu_rpm_resume,
-			   NULL)
+	RUNTIME_PM_OPS(etnaviv_gpu_rpm_suspend, etnaviv_gpu_rpm_resume, NULL)
 };
 
 struct platform_driver etnaviv_gpu_driver = {
 	.driver = {
 		.name = "etnaviv-gpu",
 		.owner = THIS_MODULE,
-		.pm = &etnaviv_gpu_pm_ops,
+		.pm = pm_ptr(&etnaviv_gpu_pm_ops),
 		.of_match_table = etnaviv_gpu_match,
 	},
 	.probe = etnaviv_gpu_platform_probe,
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 13/26] drm: fsl-dcu: Remove #ifdef guards for PM related functions
  2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (11 preceding siblings ...)
  2022-11-29 19:17 ` [PATCH v2 12/26] drm: etnaviv: " Paul Cercueil
@ 2022-11-29 19:17 ` Paul Cercueil
  2022-11-29 19:17 ` [PATCH v2 14/26] drm: mediatek: " Paul Cercueil
  2022-11-29 19:19 ` Paul Cercueil
  14 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:17 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Paul Cercueil, Alison Wang, linux-kernel, dri-devel

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 <paul@crapouillou.net>
---
Cc: Stefan Agner <stefan@agner.ch>
Cc: Alison Wang <alison.wang@nxp.com>
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
index 8579c7629f5e..474ad45c73be 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
@@ -164,7 +164,6 @@ static const struct drm_driver fsl_dcu_drm_driver = {
 	.minor			= 1,
 };
 
-#ifdef CONFIG_PM_SLEEP
 static int fsl_dcu_drm_pm_suspend(struct device *dev)
 {
 	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev);
@@ -209,11 +208,9 @@ static int fsl_dcu_drm_pm_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static const struct dev_pm_ops fsl_dcu_drm_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(fsl_dcu_drm_pm_suspend, fsl_dcu_drm_pm_resume)
-};
+static DEFINE_SIMPLE_DEV_PM_OPS(fsl_dcu_drm_pm_ops,
+				fsl_dcu_drm_pm_suspend, fsl_dcu_drm_pm_resume);
 
 static const struct fsl_dcu_soc_data fsl_dcu_ls1021a_data = {
 	.name = "ls1021a",
@@ -363,7 +360,7 @@ static struct platform_driver fsl_dcu_drm_platform_driver = {
 	.remove		= fsl_dcu_drm_remove,
 	.driver		= {
 		.name	= "fsl-dcu",
-		.pm	= &fsl_dcu_drm_pm_ops,
+		.pm	= pm_sleep_ptr(&fsl_dcu_drm_pm_ops),
 		.of_match_table = fsl_dcu_of_match,
 	},
 };
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 14/26] drm: mediatek: Remove #ifdef guards for PM related functions
  2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (12 preceding siblings ...)
  2022-11-29 19:17 ` [PATCH v2 13/26] drm: fsl-dcu: " Paul Cercueil
@ 2022-11-29 19:17 ` Paul Cercueil
  2022-11-29 19:19 ` Paul Cercueil
  14 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:17 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Chun-Kuang Hu, linux-kernel, dri-devel, Paul Cercueil,
	linux-mediatek, Matthias Brugger, linux-arm-kernel

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 <paul@crapouillou.net>
---
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: linux-mediatek@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
---
 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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 14/26] drm: mediatek: Remove #ifdef guards for PM related functions
  2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (13 preceding siblings ...)
  2022-11-29 19:17 ` [PATCH v2 14/26] drm: mediatek: " Paul Cercueil
@ 2022-11-29 19:19 ` Paul Cercueil
  2022-11-29 19:19   ` [PATCH v2 15/26] drm: omap: " Paul Cercueil
                     ` (11 more replies)
  14 siblings, 12 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:19 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Chun-Kuang Hu, linux-kernel, dri-devel, Paul Cercueil,
	linux-mediatek, Matthias Brugger, linux-arm-kernel

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 <paul@crapouillou.net>
---
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: linux-mediatek@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
---
 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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 15/26] drm: omap: Remove #ifdef guards for PM related functions
  2022-11-29 19:19 ` Paul Cercueil
@ 2022-11-29 19:19   ` Paul Cercueil
  2022-11-29 19:19   ` [PATCH v2 16/26] drm: panfrost: " Paul Cercueil
                     ` (10 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:19 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Paul Cercueil, Tomi Valkeinen, linux-kernel, dri-devel

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 <paul@crapouillou.net>
---
Cc: Tomi Valkeinen <tomba@kernel.org>
---
 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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 16/26] drm: panfrost: Remove #ifdef guards for PM related functions
  2022-11-29 19:19 ` Paul Cercueil
  2022-11-29 19:19   ` [PATCH v2 15/26] drm: omap: " Paul Cercueil
@ 2022-11-29 19:19   ` Paul Cercueil
  2022-11-29 19:54     ` Alyssa Rosenzweig
  2022-11-29 19:19   ` [PATCH v2 17/26] drm: rcar-du: " Paul Cercueil
                     ` (9 subsequent siblings)
  11 siblings, 1 reply; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:19 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Tomeu Vizoso, linux-kernel, dri-devel, Steven Price,
	Paul Cercueil, Alyssa Rosenzweig

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 <paul@crapouillou.net>
Reviewed-by: Steven Price <steven.price@arm.com>
---
Cc: Rob Herring <robh@kernel.org>
Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: Steven Price <steven.price@arm.com>
Cc: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
---
 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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 17/26] drm: rcar-du: Remove #ifdef guards for PM related functions
  2022-11-29 19:19 ` Paul Cercueil
  2022-11-29 19:19   ` [PATCH v2 15/26] drm: omap: " Paul Cercueil
  2022-11-29 19:19   ` [PATCH v2 16/26] drm: panfrost: " Paul Cercueil
@ 2022-11-29 19:19   ` Paul Cercueil
  2022-11-29 19:43     ` Laurent Pinchart
  2022-11-29 19:19   ` [PATCH v2 18/26] drm: rockchip: " Paul Cercueil
                     ` (8 subsequent siblings)
  11 siblings, 1 reply; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:19 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: linux-renesas-soc, linux-kernel, dri-devel, Paul Cercueil,
	Kieran Bingham, Laurent Pinchart

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 <paul@crapouillou.net>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
---
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org
---
 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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 18/26] drm: rockchip: Remove #ifdef guards for PM related functions
  2022-11-29 19:19 ` Paul Cercueil
                     ` (2 preceding siblings ...)
  2022-11-29 19:19   ` [PATCH v2 17/26] drm: rcar-du: " Paul Cercueil
@ 2022-11-29 19:19   ` Paul Cercueil
  2022-11-29 19:19   ` [PATCH v2 19/26] drm: shmobile: " Paul Cercueil
                     ` (7 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:19 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: linux-kernel, dri-devel, Sandy Huang, Paul Cercueil,
	linux-rockchip, linux-arm-kernel

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 <paul@crapouillou.net>
---
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
---
 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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 19/26] drm: shmobile: Remove #ifdef guards for PM related functions
  2022-11-29 19:19 ` Paul Cercueil
                     ` (3 preceding siblings ...)
  2022-11-29 19:19   ` [PATCH v2 18/26] drm: rockchip: " Paul Cercueil
@ 2022-11-29 19:19   ` Paul Cercueil
  2022-11-29 19:44     ` Laurent Pinchart
  2022-11-29 19:19   ` [PATCH v2 20/26] drm: tegra: " Paul Cercueil
                     ` (6 subsequent siblings)
  11 siblings, 1 reply; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:19 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: linux-renesas-soc, linux-kernel, dri-devel, Paul Cercueil,
	Kieran Bingham, Laurent Pinchart

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 <paul@crapouillou.net>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
---
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org
---
 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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 20/26] drm: tegra: Remove #ifdef guards for PM related functions
  2022-11-29 19:19 ` Paul Cercueil
                     ` (4 preceding siblings ...)
  2022-11-29 19:19   ` [PATCH v2 19/26] drm: shmobile: " Paul Cercueil
@ 2022-11-29 19:19   ` Paul Cercueil
  2022-11-29 19:19   ` [PATCH v2 21/26] drm: tilcdc: " Paul Cercueil
                     ` (5 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:19 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: linux-kernel, dri-devel, Jonathan Hunter, Paul Cercueil,
	Thierry Reding, linux-tegra

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 <paul@crapouillou.net>
---
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: linux-tegra@vger.kernel.org
---
 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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 21/26] drm: tilcdc: Remove #ifdef guards for PM related functions
  2022-11-29 19:19 ` Paul Cercueil
                     ` (5 preceding siblings ...)
  2022-11-29 19:19   ` [PATCH v2 20/26] drm: tegra: " Paul Cercueil
@ 2022-11-29 19:19   ` Paul Cercueil
  2022-11-29 19:19   ` [PATCH v2 22/26] drm: vboxvideo: " Paul Cercueil
                     ` (4 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:19 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Tomi Valkeinen, linux-kernel, Jyri Sarha, Paul Cercueil,
	dri-devel, Jyri Sarha

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 <paul@crapouillou.net>
Acked-by: Jyri Sarha <jyri.sarhaı@iki.fi>
---
Cc: Jyri Sarha <jyri.sarha@iki.fi>
Cc: Tomi Valkeinen <tomba@kernel.org>
---
 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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 22/26] drm: vboxvideo: Remove #ifdef guards for PM related functions
  2022-11-29 19:19 ` Paul Cercueil
                     ` (6 preceding siblings ...)
  2022-11-29 19:19   ` [PATCH v2 21/26] drm: tilcdc: " Paul Cercueil
@ 2022-11-29 19:19   ` Paul Cercueil
  2022-11-29 19:19   ` [PATCH v2 23/26] drm: vc4: " Paul Cercueil
                     ` (3 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:19 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Paul Cercueil, Hans de Goede, linux-kernel, dri-devel

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 <paul@crapouillou.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
Cc: Hans de Goede <hdegoede@redhat.com>
---
 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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 23/26] drm: vc4: Remove #ifdef guards for PM related functions
  2022-11-29 19:19 ` Paul Cercueil
                     ` (7 preceding siblings ...)
  2022-11-29 19:19   ` [PATCH v2 22/26] drm: vboxvideo: " Paul Cercueil
@ 2022-11-29 19:19   ` Paul Cercueil
  2022-11-29 19:19   ` [PATCH v2 24/26] drm: gm12u320: " Paul Cercueil
                     ` (2 subsequent siblings)
  11 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:19 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Paul Cercueil, linux-kernel, dri-devel, Emma Anholt

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 <paul@crapouillou.net>
---
Cc: Emma Anholt <emma@anholt.net>
Cc: Maxime Ripard <mripard@kernel.org>
---
 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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 24/26] drm: gm12u320: Remove #ifdef guards for PM related functions
  2022-11-29 19:19 ` Paul Cercueil
                     ` (8 preceding siblings ...)
  2022-11-29 19:19   ` [PATCH v2 23/26] drm: vc4: " Paul Cercueil
@ 2022-11-29 19:19   ` Paul Cercueil
  2022-11-29 19:19   ` [PATCH v2 25/26] drm: tidss: " Paul Cercueil
  2022-11-29 19:19   ` [PATCH v2 26/26] drm/i915/gt: " Paul Cercueil
  11 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:19 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Paul Cercueil, Hans de Goede, linux-kernel, dri-devel

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 <paul@crapouillou.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
Cc: Hans de Goede <hdegoede@redhat.com>
---
 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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 25/26] drm: tidss: Remove #ifdef guards for PM related functions
  2022-11-29 19:19 ` Paul Cercueil
                     ` (9 preceding siblings ...)
  2022-11-29 19:19   ` [PATCH v2 24/26] drm: gm12u320: " Paul Cercueil
@ 2022-11-29 19:19   ` Paul Cercueil
  2022-11-29 19:19   ` [PATCH v2 26/26] drm/i915/gt: " Paul Cercueil
  11 siblings, 0 replies; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:19 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Paul Cercueil, Tomi Valkeinen, Jyri Sarha, linux-kernel, dri-devel

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 <paul@crapouillou.net>
---
Cc: Jyri Sarha <jyri.sarha@iki.fi>
Cc: Tomi Valkeinen <tomba@kernel.org>
---
 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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 26/26] drm/i915/gt: Remove #ifdef guards for PM related functions
  2022-11-29 19:19 ` Paul Cercueil
                     ` (10 preceding siblings ...)
  2022-11-29 19:19   ` [PATCH v2 25/26] drm: tidss: " Paul Cercueil
@ 2022-11-29 19:19   ` Paul Cercueil
  2022-12-07 15:56     ` [Intel-gfx] " Rodrigo Vivi
  11 siblings, 1 reply; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 19:19 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Tvrtko Ursulin, intel-gfx, linux-kernel, Paul Cercueil,
	dri-devel, Rodrigo Vivi

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 <paul@crapouillou.net>
---
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
---
 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


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 17/26] drm: rcar-du: Remove #ifdef guards for PM related functions
  2022-11-29 19:19   ` [PATCH v2 17/26] drm: rcar-du: " Paul Cercueil
@ 2022-11-29 19:43     ` Laurent Pinchart
  2022-11-29 21:05       ` Paul Cercueil
  0 siblings, 1 reply; 37+ messages in thread
From: Laurent Pinchart @ 2022-11-29 19:43 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: linux-kernel, dri-devel, linux-renesas-soc, Kieran Bingham

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 <paul@crapouillou.net>
> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

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 <laurent.pinchart@ideasonboard.com>
> Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> Cc: linux-renesas-soc@vger.kernel.org
> ---
>  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

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 19/26] drm: shmobile: Remove #ifdef guards for PM related functions
  2022-11-29 19:19   ` [PATCH v2 19/26] drm: shmobile: " Paul Cercueil
@ 2022-11-29 19:44     ` Laurent Pinchart
  0 siblings, 0 replies; 37+ messages in thread
From: Laurent Pinchart @ 2022-11-29 19:44 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: linux-kernel, dri-devel, linux-renesas-soc, Kieran Bingham

Hi Paul,

Thank you for the patch.

On Tue, Nov 29, 2022 at 07:19:35PM +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 <paul@crapouillou.net>
> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

> ---
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> Cc: linux-renesas-soc@vger.kernel.org
> ---
>  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),
>  	},
>  };
>  

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 16/26] drm: panfrost: Remove #ifdef guards for PM related functions
  2022-11-29 19:19   ` [PATCH v2 16/26] drm: panfrost: " Paul Cercueil
@ 2022-11-29 19:54     ` Alyssa Rosenzweig
  0 siblings, 0 replies; 37+ messages in thread
From: Alyssa Rosenzweig @ 2022-11-29 19:54 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Tomeu Vizoso, linux-kernel, dri-devel, Steven Price, Alyssa Rosenzweig

Sounds like a nice clean up :-) 

	Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>

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 <paul@crapouillou.net>
> Reviewed-by: Steven Price <steven.price@arm.com>
> ---
> Cc: Rob Herring <robh@kernel.org>
> Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Cc: Steven Price <steven.price@arm.com>
> Cc: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
> ---
>  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
> 

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 17/26] drm: rcar-du: Remove #ifdef guards for PM related functions
  2022-11-29 19:43     ` Laurent Pinchart
@ 2022-11-29 21:05       ` Paul Cercueil
  2022-11-29 21:24         ` Laurent Pinchart
  0 siblings, 1 reply; 37+ messages in thread
From: Paul Cercueil @ 2022-11-29 21:05 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-kernel, dri-devel, linux-renesas-soc, Kieran Bingham

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 <paul@crapouillou.net>
> > Reviewed-by: Kieran Bingham
> > <kieran.bingham+renesas@ideasonboard.com>
> 
> Reviewed-by: Laurent Pinchart
> <laurent.pinchart+renesas@ideasonboard.com>
> 
> 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 <laurent.pinchart@ideasonboard.com>
> > Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> > Cc: linux-renesas-soc@vger.kernel.org
> > ---
> >  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,
> >         },
> >  };
> 


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 17/26] drm: rcar-du: Remove #ifdef guards for PM related functions
  2022-11-29 21:05       ` Paul Cercueil
@ 2022-11-29 21:24         ` Laurent Pinchart
  0 siblings, 0 replies; 37+ messages in thread
From: Laurent Pinchart @ 2022-11-29 21:24 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: linux-kernel, dri-devel, linux-renesas-soc, Kieran Bingham

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 <paul@crapouillou.net>
> > > Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> > 
> > Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > 
> > 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 <laurent.pinchart@ideasonboard.com>
> > > Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> > > Cc: linux-renesas-soc@vger.kernel.org
> > > ---
> > >  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

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 07/26] drm: mxsfb: Define and use generic PM ops
  2022-11-29 19:17 ` [PATCH v2 07/26] drm: mxsfb: " Paul Cercueil
@ 2022-11-29 21:48   ` Marek Vasut
  0 siblings, 0 replies; 37+ messages in thread
From: Marek Vasut @ 2022-11-29 21:48 UTC (permalink / raw)
  To: Paul Cercueil, David Airlie, Daniel Vetter
  Cc: Sascha Hauer, linux-kernel, dri-devel, Pengutronix Kernel Team,
	Shawn Guo, linux-arm-kernel, NXP Linux Team

On 11/29/22 20:17, Paul Cercueil wrote:
> Use the new DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro to create a
> "struct dev_pm_ops" that can be used by this driver, instead of using
> custom PM callbacks with the same behaviour.
> 
> v2: Use the DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro instead of an
>      exported dev_pm_ops.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

[...]

Reviewed-by: Marek Vasut <marex@denx.de>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 06/26] drm: sun4i: Define and use generic PM ops
  2022-11-29 19:17 ` [PATCH v2 06/26] drm: sun4i: " Paul Cercueil
@ 2022-11-30  4:08   ` Samuel Holland
  0 siblings, 0 replies; 37+ messages in thread
From: Samuel Holland @ 2022-11-30  4:08 UTC (permalink / raw)
  To: Paul Cercueil, David Airlie, Daniel Vetter
  Cc: dri-devel, linux-kernel, Chen-Yu Tsai, Jernej Skrabec,
	linux-sunxi, linux-arm-kernel

On 11/29/22 13:17, Paul Cercueil wrote:
> Use the new DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro to create a
> "struct dev_pm_ops" that can be used by this driver, instead of using
> custom PM callbacks with the same behaviour.
> 
> v2: Use the DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro instead of an
>     exported dev_pm_ops.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
> 
> Samuel: since the code changed I had to remove your reviewed-by, sorry
>         about that.
> 
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: Chen-Yu Tsai <wens@csie.org>
> Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
> Cc: Samuel Holland <samuel@sholland.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-sunxi@lists.linux.dev
> ---
>  drivers/gpu/drm/sun4i/sun4i_drv.c | 26 ++++----------------------
>  1 file changed, 4 insertions(+), 22 deletions(-)

Reviewed-by: Samuel Holland <samuel@sholland.org>


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [Intel-gfx] [PATCH v2 26/26] drm/i915/gt: Remove #ifdef guards for PM related functions
  2022-11-29 19:19   ` [PATCH v2 26/26] drm/i915/gt: " Paul Cercueil
@ 2022-12-07 15:56     ` Rodrigo Vivi
  0 siblings, 0 replies; 37+ messages in thread
From: Rodrigo Vivi @ 2022-12-07 15:56 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: dri-devel, intel-gfx, linux-kernel

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 <paul@crapouillou.net>
> ---
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>


Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>


> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> Cc: intel-gfx@lists.freedesktop.org
> ---
>  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
> 

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 12/26] drm: etnaviv: Remove #ifdef guards for PM related functions
  2022-11-29 19:17 ` [PATCH v2 12/26] drm: etnaviv: " Paul Cercueil
@ 2022-12-15 19:22   ` Lucas Stach
  0 siblings, 0 replies; 37+ messages in thread
From: Lucas Stach @ 2022-12-15 19:22 UTC (permalink / raw)
  To: Paul Cercueil, David Airlie, Daniel Vetter
  Cc: Russell King, linux-kernel, dri-devel, etnaviv

Am Dienstag, dem 29.11.2022 um 19:17 +0000 schrieb Paul Cercueil:
> 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.
> 
> Some #ifdef CONFIG_PM guards were protecting simple statements, and were
> also converted to "if (IS_ENABLED(CONFIG_PM))".
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

Thanks, applied to my etnaviv/next branch.

Regards,
Lucas

> ---
> Cc: Lucas Stach <l.stach@pengutronix.de>
> Cc: Russell King <linux+etnaviv@armlinux.org.uk>
> Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
> Cc: etnaviv@lists.freedesktop.org
> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 30 +++++++++++----------------
>  1 file changed, 12 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> index 51320eeebfcf..310382812029 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> @@ -1629,7 +1629,6 @@ static int etnaviv_gpu_hw_suspend(struct etnaviv_gpu *gpu)
>  	return etnaviv_gpu_clk_disable(gpu);
>  }
>  
> -#ifdef CONFIG_PM
>  static int etnaviv_gpu_hw_resume(struct etnaviv_gpu *gpu)
>  {
>  	int ret;
> @@ -1645,7 +1644,6 @@ static int etnaviv_gpu_hw_resume(struct etnaviv_gpu *gpu)
>  
>  	return 0;
>  }
> -#endif
>  
>  static int
>  etnaviv_gpu_cooling_get_max_state(struct thermal_cooling_device *cdev,
> @@ -1713,11 +1711,10 @@ static int etnaviv_gpu_bind(struct device *dev, struct device *master,
>  	if (ret)
>  		goto out_workqueue;
>  
> -#ifdef CONFIG_PM
> -	ret = pm_runtime_get_sync(gpu->dev);
> -#else
> -	ret = etnaviv_gpu_clk_enable(gpu);
> -#endif
> +	if (IS_ENABLED(CONFIG_PM))
> +		ret = pm_runtime_get_sync(gpu->dev);
> +	else
> +		ret = etnaviv_gpu_clk_enable(gpu);
>  	if (ret < 0)
>  		goto out_sched;
>  
> @@ -1761,12 +1758,12 @@ static void etnaviv_gpu_unbind(struct device *dev, struct device *master,
>  
>  	etnaviv_sched_fini(gpu);
>  
> -#ifdef CONFIG_PM
> -	pm_runtime_get_sync(gpu->dev);
> -	pm_runtime_put_sync_suspend(gpu->dev);
> -#else
> -	etnaviv_gpu_hw_suspend(gpu);
> -#endif
> +	if (IS_ENABLED(CONFIG_PM)) {
> +		pm_runtime_get_sync(gpu->dev);
> +		pm_runtime_put_sync_suspend(gpu->dev);
> +	} else {
> +		etnaviv_gpu_hw_suspend(gpu);
> +	}
>  
>  	if (gpu->mmu_context)
>  		etnaviv_iommu_context_put(gpu->mmu_context);
> @@ -1880,7 +1877,6 @@ static int etnaviv_gpu_platform_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -#ifdef CONFIG_PM
>  static int etnaviv_gpu_rpm_suspend(struct device *dev)
>  {
>  	struct etnaviv_gpu *gpu = dev_get_drvdata(dev);
> @@ -1923,18 +1919,16 @@ static int etnaviv_gpu_rpm_resume(struct device *dev)
>  
>  	return 0;
>  }
> -#endif
>  
>  static const struct dev_pm_ops etnaviv_gpu_pm_ops = {
> -	SET_RUNTIME_PM_OPS(etnaviv_gpu_rpm_suspend, etnaviv_gpu_rpm_resume,
> -			   NULL)
> +	RUNTIME_PM_OPS(etnaviv_gpu_rpm_suspend, etnaviv_gpu_rpm_resume, NULL)
>  };
>  
>  struct platform_driver etnaviv_gpu_driver = {
>  	.driver = {
>  		.name = "etnaviv-gpu",
>  		.owner = THIS_MODULE,
> -		.pm = &etnaviv_gpu_pm_ops,
> +		.pm = pm_ptr(&etnaviv_gpu_pm_ops),
>  		.of_match_table = etnaviv_gpu_match,
>  	},
>  	.probe = etnaviv_gpu_platform_probe,


^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2022-12-15 19:41 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29 19:17 [PATCH v2 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
2022-11-29 19:17 ` [PATCH v2 01/26] drm: modeset-helper: Add DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS macro Paul Cercueil
2022-11-29 19:17 ` [PATCH v2 02/26] drm: bochs: Define and use generic PM ops Paul Cercueil
2022-11-29 19:17 ` [PATCH v2 03/26] drm: imx: " Paul Cercueil
2022-11-29 19:17 ` [PATCH v2 04/26] drm: rockchip: " Paul Cercueil
2022-11-29 19:17 ` [PATCH v2 05/26] drm: tegra: " Paul Cercueil
2022-11-29 19:17 ` [PATCH v2 06/26] drm: sun4i: " Paul Cercueil
2022-11-30  4:08   ` Samuel Holland
2022-11-29 19:17 ` [PATCH v2 07/26] drm: mxsfb: " Paul Cercueil
2022-11-29 21:48   ` Marek Vasut
2022-11-29 19:17 ` [PATCH v2 08/26] drm: atmel-hlcdc: Remove #ifdef guards for PM related functions Paul Cercueil
2022-11-29 19:17 ` [PATCH v2 09/26] drm: exynos: " Paul Cercueil
2022-11-29 19:17 ` [PATCH v2 10/26] drm: imx/dcss: " Paul Cercueil
2022-11-29 19:17 ` [PATCH v2 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
2022-11-29 19:17 ` [PATCH v2 12/26] drm: etnaviv: " Paul Cercueil
2022-12-15 19:22   ` Lucas Stach
2022-11-29 19:17 ` [PATCH v2 13/26] drm: fsl-dcu: " Paul Cercueil
2022-11-29 19:17 ` [PATCH v2 14/26] drm: mediatek: " Paul Cercueil
2022-11-29 19:19 ` Paul Cercueil
2022-11-29 19:19   ` [PATCH v2 15/26] drm: omap: " Paul Cercueil
2022-11-29 19:19   ` [PATCH v2 16/26] drm: panfrost: " Paul Cercueil
2022-11-29 19:54     ` Alyssa Rosenzweig
2022-11-29 19:19   ` [PATCH v2 17/26] drm: rcar-du: " Paul Cercueil
2022-11-29 19:43     ` Laurent Pinchart
2022-11-29 21:05       ` Paul Cercueil
2022-11-29 21:24         ` Laurent Pinchart
2022-11-29 19:19   ` [PATCH v2 18/26] drm: rockchip: " Paul Cercueil
2022-11-29 19:19   ` [PATCH v2 19/26] drm: shmobile: " Paul Cercueil
2022-11-29 19:44     ` Laurent Pinchart
2022-11-29 19:19   ` [PATCH v2 20/26] drm: tegra: " Paul Cercueil
2022-11-29 19:19   ` [PATCH v2 21/26] drm: tilcdc: " Paul Cercueil
2022-11-29 19:19   ` [PATCH v2 22/26] drm: vboxvideo: " Paul Cercueil
2022-11-29 19:19   ` [PATCH v2 23/26] drm: vc4: " Paul Cercueil
2022-11-29 19:19   ` [PATCH v2 24/26] drm: gm12u320: " Paul Cercueil
2022-11-29 19:19   ` [PATCH v2 25/26] drm: tidss: " Paul Cercueil
2022-11-29 19:19   ` [PATCH v2 26/26] drm/i915/gt: " Paul Cercueil
2022-12-07 15:56     ` [Intel-gfx] " Rodrigo Vivi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).