dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/26] drm: Get rid of #ifdef CONFIG_PM* guards
@ 2022-11-07 17:50 Paul Cercueil
  2022-11-07 17:50 ` [PATCH 01/26] drm: modeset-helper: Export dev_pm_ops for simple drivers Paul Cercueil
                   ` (11 more replies)
  0 siblings, 12 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:50 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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.

Note that some drivers (etnaviv, tegra, vc4) currently don't have any
.suspend/.resume callbacks, but do provide
.runtime_suspend/.runtime_resume callbacks. These drivers should most
likely use DEFINE_RUNTIME_DEV_PM_OPS(), which provides .suspend/.resume
callbacks as well (pm_runtime_force_suspend / pm_runtime_force_resume
respectively). I did not do that, because that would be a functional
change and the callbacks being missing may actually be on purpose.

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

Cheers,
-Paul

Paul Cercueil (26):
  drm: modeset-helper: Export dev_pm_ops for simple drivers
  drm: bochs: Use the dev_pm_ops provided by modeset helper
  drm: imx: Use the dev_pm_ops provided by modeset helper
  drm: rockchip: Use the dev_pm_ops provided by modeset helper
  drm: tegra: Use the dev_pm_ops provided by modeset helper
  drm: sun4i: Use the dev_pm_ops provided by modeset helper
  drm: msxfb: Use the dev_pm_ops provided by modeset helper
  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/drm_modeset_helper.c          | 32 +++++++++++++++++++
 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            | 21 ++----------
 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   | 23 +------------
 drivers/gpu/drm/shmobile/shmob_drm_drv.c      |  9 ++----
 drivers/gpu/drm/sun4i/sun4i_drv.c             | 24 ++------------
 drivers/gpu/drm/tegra/dpaux.c                 |  6 ++--
 drivers/gpu/drm/tegra/drm.c                   | 21 +-----------
 drivers/gpu/drm/tidss/tidss_drv.c             | 29 ++++++++---------
 drivers/gpu/drm/tilcdc/tilcdc_drv.c           |  9 ++----
 drivers/gpu/drm/tiny/bochs.c                  | 27 ++--------------
 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              |  4 +++
 43 files changed, 171 insertions(+), 362 deletions(-)

-- 
2.35.1


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

* [PATCH 01/26] drm: modeset-helper: Export dev_pm_ops for simple drivers
  2022-11-07 17:50 [PATCH 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
@ 2022-11-07 17:50 ` Paul Cercueil
  2022-11-08 12:10   ` Thomas Zimmermann
  2022-11-07 17:50 ` [PATCH 02/26] drm: bochs: Use the dev_pm_ops provided by modeset helper Paul Cercueil
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:50 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter
  Cc: Paul Cercueil, linux-kernel, dri-devel

Export a dev_pm_ops meant to 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 symbol is conditionally exported if IS_ENABLED(CONFIG_PM_SLEEP), and
therefore it should always be referenced using the pm_sleep_ptr() macro.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/gpu/drm/drm_modeset_helper.c | 32 ++++++++++++++++++++++++++++
 include/drm/drm_modeset_helper.h     |  4 ++++
 2 files changed, 36 insertions(+)

diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index f858dfedf2cf..0bc9f9228a60 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -20,6 +20,9 @@
  * OF THIS SOFTWARE.
  */
 
+#include <linux/device.h>
+#include <linux/pm.h>
+
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_fourcc.h>
@@ -244,3 +247,32 @@ int drm_mode_config_helper_resume(struct drm_device *dev)
 	return ret;
 }
 EXPORT_SYMBOL(drm_mode_config_helper_resume);
+
+static int drm_mode_config_pm_suspend(struct device *dev)
+{
+	struct drm_device *drm = dev_get_drvdata(dev);
+
+	return drm_mode_config_helper_suspend(drm);
+}
+
+static int drm_mode_config_pm_resume(struct device *dev)
+{
+	struct drm_device *drm = dev_get_drvdata(dev);
+
+	return drm_mode_config_helper_resume(drm);
+}
+
+/**
+ * drm_mode_config_pm_ops - Exported dev_pm_ops helper for simple drivers
+ *
+ * This dev_pm_ops can be used for simple drivers that would otherwise only call
+ * drm_mode_config_helper_suspend / drm_mode_config_helper_resume in their PM
+ * callbacks. It is only valid if the driver's drm_device has been registered as
+ * the struct device's drvdata.
+ *
+ * The exported symbol must always be used with the pm_sleep_ptr() macro, like
+ * this:
+ * .pm = pm_sleep_ptr(&drm_mode_config_pm_ops),
+ */
+EXPORT_SIMPLE_DEV_PM_OPS(drm_mode_config_pm_ops,
+			 drm_mode_config_pm_suspend, drm_mode_config_pm_resume);
diff --git a/include/drm/drm_modeset_helper.h b/include/drm/drm_modeset_helper.h
index 995fd981cab0..85f29637e9c1 100644
--- a/include/drm/drm_modeset_helper.h
+++ b/include/drm/drm_modeset_helper.h
@@ -23,6 +23,8 @@
 #ifndef __DRM_KMS_HELPER_H__
 #define __DRM_KMS_HELPER_H__
 
+#include <linux/pm.h>
+
 struct drm_crtc;
 struct drm_crtc_funcs;
 struct drm_device;
@@ -41,4 +43,6 @@ 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);
 
+extern const struct dev_pm_ops drm_mode_config_pm_ops;
+
 #endif
-- 
2.35.1


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

* [PATCH 02/26] drm: bochs: Use the dev_pm_ops provided by modeset helper
  2022-11-07 17:50 [PATCH 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
  2022-11-07 17:50 ` [PATCH 01/26] drm: modeset-helper: Export dev_pm_ops for simple drivers Paul Cercueil
@ 2022-11-07 17:50 ` Paul Cercueil
  2022-11-07 17:50 ` [PATCH 03/26] drm: imx: " Paul Cercueil
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:50 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter
  Cc: Paul Cercueil, virtualization, linux-kernel, dri-devel, Gerd Hoffmann

Use the drm_mode_config_pm_ops structure exported by
drm_modeset_helper.c, which provides the exact same PM callbacks.

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 | 27 ++-------------------------
 1 file changed, 2 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
index 04682f831544..26e9cba89f68 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                                                          */
 
@@ -721,7 +698,7 @@ static struct pci_driver bochs_pci_driver = {
 	.id_table =	bochs_pci_tbl,
 	.probe =	bochs_pci_probe,
 	.remove =	bochs_pci_remove,
-	.driver.pm =    &bochs_pm_ops,
+	.driver.pm =    pm_sleep_ptr(&drm_mode_config_pm_ops),
 };
 
 /* ---------------------------------------------------------------------- */
-- 
2.35.1


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

* [PATCH 03/26] drm: imx: Use the dev_pm_ops provided by modeset helper
  2022-11-07 17:50 [PATCH 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
  2022-11-07 17:50 ` [PATCH 01/26] drm: modeset-helper: Export dev_pm_ops for simple drivers Paul Cercueil
  2022-11-07 17:50 ` [PATCH 02/26] drm: bochs: Use the dev_pm_ops provided by modeset helper Paul Cercueil
@ 2022-11-07 17:50 ` Paul Cercueil
  2022-11-07 17:50 ` [PATCH 04/26] drm: rockchip: " Paul Cercueil
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:50 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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 drm_mode_config_pm_ops structure exported by
drm_modeset_helper.c, which provides the exact same PM callbacks.

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 | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index 8dd8b0f912af..4cbd15c2c8ea 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,24 +299,6 @@ 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 */ },
@@ -327,7 +310,7 @@ static struct platform_driver imx_drm_pdrv = {
 	.remove		= imx_drm_platform_remove,
 	.driver		= {
 		.name	= "imx-drm",
-		.pm	= &imx_drm_pm_ops,
+		.pm	= pm_sleep_ptr(&drm_mode_config_pm_ops),
 		.of_match_table = imx_drm_dt_ids,
 	},
 };
-- 
2.35.1


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

* [PATCH 04/26] drm: rockchip: Use the dev_pm_ops provided by modeset helper
  2022-11-07 17:50 [PATCH 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (2 preceding siblings ...)
  2022-11-07 17:50 ` [PATCH 03/26] drm: imx: " Paul Cercueil
@ 2022-11-07 17:50 ` Paul Cercueil
  2022-11-07 17:50 ` [PATCH 05/26] drm: tegra: " Paul Cercueil
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:50 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter
  Cc: linux-kernel, dri-devel, Sandy Huang, Paul Cercueil,
	linux-rockchip, linux-arm-kernel

Use the drm_mode_config_pm_ops structure exported by
drm_modeset_helper.c, which provides the exact same PM callbacks.

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 | 23 +--------------------
 1 file changed, 1 insertion(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 813f9f8c8698..c76593b3f8eb 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;
@@ -480,7 +459,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(&drm_mode_config_pm_ops),
 	},
 };
 
-- 
2.35.1


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

* [PATCH 05/26] drm: tegra: Use the dev_pm_ops provided by modeset helper
  2022-11-07 17:50 [PATCH 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (3 preceding siblings ...)
  2022-11-07 17:50 ` [PATCH 04/26] drm: rockchip: " Paul Cercueil
@ 2022-11-07 17:50 ` Paul Cercueil
  2022-11-07 17:50 ` [PATCH 06/26] drm: sun4i: " Paul Cercueil
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:50 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter
  Cc: linux-kernel, dri-devel, Jonathan Hunter, Paul Cercueil,
	Thierry Reding, linux-tegra

Use the drm_mode_config_pm_ops structure exported by
drm_modeset_helper.c, which provides the exact same PM callbacks.

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 | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 6748ec1e0005..c9b6b3acb8c7 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -1325,25 +1325,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", },
@@ -1388,7 +1369,7 @@ static const struct of_device_id host1x_drm_subdevs[] = {
 static struct host1x_driver host1x_drm_driver = {
 	.driver = {
 		.name = "drm",
-		.pm = &host1x_drm_pm_ops,
+		.pm = pm_sleep_ptr(&drm_mode_config_pm_ops),
 	},
 	.probe = host1x_drm_probe,
 	.remove = host1x_drm_remove,
-- 
2.35.1


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

* [PATCH 06/26] drm: sun4i: Use the dev_pm_ops provided by modeset helper
  2022-11-07 17:50 [PATCH 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (4 preceding siblings ...)
  2022-11-07 17:50 ` [PATCH 05/26] drm: tegra: " Paul Cercueil
@ 2022-11-07 17:50 ` Paul Cercueil
  2022-11-14  0:34   ` Samuel Holland
  2022-11-07 17:50 ` [PATCH 07/26] drm: msxfb: " Paul Cercueil
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:50 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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 drm_mode_config_pm_ops structure exported by
drm_modeset_helper.c, which provides the exact same PM callbacks.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
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 | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index d06ffd99d86e..8147b2abe5ba 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;
@@ -440,7 +420,7 @@ static struct platform_driver sun4i_drv_platform_driver = {
 	.driver		= {
 		.name		= "sun4i-drm",
 		.of_match_table	= sun4i_drv_of_table,
-		.pm = &sun4i_drv_drm_pm_ops,
+		.pm = pm_sleep_ptr(&drm_mode_config_pm_ops),
 	},
 };
 drm_module_platform_driver(sun4i_drv_platform_driver);
-- 
2.35.1


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

* [PATCH 07/26] drm: msxfb: Use the dev_pm_ops provided by modeset helper
  2022-11-07 17:50 [PATCH 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (5 preceding siblings ...)
  2022-11-07 17:50 ` [PATCH 06/26] drm: sun4i: " Paul Cercueil
@ 2022-11-07 17:50 ` Paul Cercueil
  2022-11-07 17:50 ` [PATCH 08/26] drm: atmel-hlcdc: Remove #ifdef guards for PM related functions Paul Cercueil
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:50 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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 drm_mode_config_pm_ops structure exported by
drm_modeset_helper.c, which provides the exact same PM callbacks.

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, 1 insertion(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index b29b332ed381..917ba3bfadcf 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -398,26 +398,6 @@ 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)
-};
-
 static struct platform_driver mxsfb_platform_driver = {
 	.probe		= mxsfb_probe,
 	.remove		= mxsfb_remove,
@@ -425,7 +405,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(&drm_mode_config_pm_ops),
 	},
 };
 
-- 
2.35.1


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

* [PATCH 08/26] drm: atmel-hlcdc: Remove #ifdef guards for PM related functions
  2022-11-07 17:50 [PATCH 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (6 preceding siblings ...)
  2022-11-07 17:50 ` [PATCH 07/26] drm: msxfb: " Paul Cercueil
@ 2022-11-07 17:50 ` Paul Cercueil
  2022-11-07 17:53   ` Sam Ravnborg
  2022-11-10 15:28   ` Claudiu.Beznea
  2022-11-07 17:50 ` [PATCH 09/26] drm: exynos: " Paul Cercueil
                   ` (3 subsequent siblings)
  11 siblings, 2 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:50 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter
  Cc: Alexandre Belloni, Boris Brezillon, Nicolas Ferre, dri-devel,
	linux-kernel, 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>
---
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 f7e7f4e919c7..05146936cc70 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] 44+ messages in thread

* [PATCH 09/26] drm: exynos: Remove #ifdef guards for PM related functions
  2022-11-07 17:50 [PATCH 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (7 preceding siblings ...)
  2022-11-07 17:50 ` [PATCH 08/26] drm: atmel-hlcdc: Remove #ifdef guards for PM related functions Paul Cercueil
@ 2022-11-07 17:50 ` Paul Cercueil
  2022-11-21  4:25   ` Inki Dae
  2022-11-07 17:50 ` [PATCH 10/26] drm: imx/dcss: " Paul Cercueil
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:50 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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>
---
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] 44+ messages in thread

* [PATCH 10/26] drm: imx/dcss: Remove #ifdef guards for PM related functions
  2022-11-07 17:50 [PATCH 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (8 preceding siblings ...)
  2022-11-07 17:50 ` [PATCH 09/26] drm: exynos: " Paul Cercueil
@ 2022-11-07 17:50 ` Paul Cercueil
  2022-11-11 14:27   ` Laurentiu Palcu
  2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
  2022-11-07 17:55 ` [PATCH 24/26] drm: gm12u320: " Paul Cercueil
  11 siblings, 1 reply; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:50 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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>
---
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] 44+ messages in thread

* [PATCH 11/26] drm: bridge/dw-hdmi: Remove #ifdef guards for PM related functions
  2022-11-07 17:50 [PATCH 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (9 preceding siblings ...)
  2022-11-07 17:50 ` [PATCH 10/26] drm: imx/dcss: " Paul Cercueil
@ 2022-11-07 17:52 ` Paul Cercueil
  2022-11-07 17:52   ` [PATCH 12/26] drm: etnaviv: " Paul Cercueil
                     ` (12 more replies)
  2022-11-07 17:55 ` [PATCH 24/26] drm: gm12u320: " Paul Cercueil
  11 siblings, 13 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:52 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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] 44+ messages in thread

* [PATCH 12/26] drm: etnaviv: Remove #ifdef guards for PM related functions
  2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
@ 2022-11-07 17:52   ` Paul Cercueil
  2022-11-07 18:07     ` Lucas Stach
  2022-11-07 17:52   ` [PATCH 13/26] drm: fsl-dcu: " Paul Cercueil
                     ` (11 subsequent siblings)
  12 siblings, 1 reply; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:52 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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))".

Note that this driver should probably use the
DEFINE_RUNTIME_DEV_PM_OPS() macro instead, which will provide
.suspend/.resume callbacks, pointing to pm_runtime_force_suspend() and
pm_runtime_force_resume() respectively; unless those callbacks really
aren't needed.

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 37018bc55810..e9a5444ec1c7 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -1605,7 +1605,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;
@@ -1621,7 +1620,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,
@@ -1689,11 +1687,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;
 
@@ -1737,12 +1734,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);
@@ -1856,7 +1853,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);
@@ -1899,18 +1895,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] 44+ messages in thread

* [PATCH 13/26] drm: fsl-dcu: Remove #ifdef guards for PM related functions
  2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
  2022-11-07 17:52   ` [PATCH 12/26] drm: etnaviv: " Paul Cercueil
@ 2022-11-07 17:52   ` Paul Cercueil
  2022-11-07 17:52   ` [PATCH 14/26] drm: mediatek: " Paul Cercueil
                     ` (10 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:52 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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 b4acc3422ba4..5aa6ca451ddc 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] 44+ messages in thread

* [PATCH 14/26] drm: mediatek: Remove #ifdef guards for PM related functions
  2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
  2022-11-07 17:52   ` [PATCH 12/26] drm: etnaviv: " Paul Cercueil
  2022-11-07 17:52   ` [PATCH 13/26] drm: fsl-dcu: " Paul Cercueil
@ 2022-11-07 17:52   ` Paul Cercueil
  2022-11-07 17:52   ` [PATCH 15/26] drm: omap: " Paul Cercueil
                     ` (9 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:52 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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 4c80b6896dc3..93b2a36d3fc5 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -1754,7 +1754,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);
@@ -1777,9 +1776,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,
@@ -1809,7 +1808,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] 44+ messages in thread

* [PATCH 15/26] drm: omap: Remove #ifdef guards for PM related functions
  2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
                     ` (2 preceding siblings ...)
  2022-11-07 17:52   ` [PATCH 14/26] drm: mediatek: " Paul Cercueil
@ 2022-11-07 17:52   ` Paul Cercueil
  2022-11-07 17:52   ` [PATCH 16/26] drm: panfrost: " Paul Cercueil
                     ` (8 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:52 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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] 44+ messages in thread

* [PATCH 16/26] drm: panfrost: Remove #ifdef guards for PM related functions
  2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
                     ` (3 preceding siblings ...)
  2022-11-07 17:52   ` [PATCH 15/26] drm: omap: " Paul Cercueil
@ 2022-11-07 17:52   ` Paul Cercueil
  2022-11-09 15:16     ` Steven Price
  2022-11-07 17:52   ` [PATCH 17/26] drm: rcar-du: " Paul Cercueil
                     ` (7 subsequent siblings)
  12 siblings, 1 reply; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:52 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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>
---
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] 44+ messages in thread

* [PATCH 17/26] drm: rcar-du: Remove #ifdef guards for PM related functions
  2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
                     ` (4 preceding siblings ...)
  2022-11-07 17:52   ` [PATCH 16/26] drm: panfrost: " Paul Cercueil
@ 2022-11-07 17:52   ` Paul Cercueil
  2022-11-16 13:41     ` Kieran Bingham
  2022-11-07 17:52   ` [PATCH 18/26] drm: rockchip: " Paul Cercueil
                     ` (6 subsequent siblings)
  12 siblings, 1 reply; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:52 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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>
---
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 a2776f1d6f2c..0a89094461cc 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] 44+ messages in thread

* [PATCH 18/26] drm: rockchip: Remove #ifdef guards for PM related functions
  2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
                     ` (5 preceding siblings ...)
  2022-11-07 17:52   ` [PATCH 17/26] drm: rcar-du: " Paul Cercueil
@ 2022-11-07 17:52   ` Paul Cercueil
  2022-11-07 17:52   ` [PATCH 19/26] drm: shmobile: " Paul Cercueil
                     ` (5 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:52 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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] 44+ messages in thread

* [PATCH 19/26] drm: shmobile: Remove #ifdef guards for PM related functions
  2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
                     ` (6 preceding siblings ...)
  2022-11-07 17:52   ` [PATCH 18/26] drm: rockchip: " Paul Cercueil
@ 2022-11-07 17:52   ` Paul Cercueil
  2022-11-16 13:41     ` Kieran Bingham
  2022-11-07 17:52   ` [PATCH 20/26] drm: tegra: " Paul Cercueil
                     ` (4 subsequent siblings)
  12 siblings, 1 reply; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:52 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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>
---
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] 44+ messages in thread

* [PATCH 20/26] drm: tegra: Remove #ifdef guards for PM related functions
  2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
                     ` (7 preceding siblings ...)
  2022-11-07 17:52   ` [PATCH 19/26] drm: shmobile: " Paul Cercueil
@ 2022-11-07 17:52   ` Paul Cercueil
  2022-11-07 17:52   ` [PATCH 21/26] drm: tilcdc: " Paul Cercueil
                     ` (3 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:52 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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.

Note that this driver should probably use the
DEFINE_RUNTIME_DEV_PM_OPS() macro instead, which will provide
.suspend/.resume callbacks, pointing to pm_runtime_force_suspend() and
pm_runtime_force_resume() respectively; unless those callbacks really
aren't needed.

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] 44+ messages in thread

* [PATCH 21/26] drm: tilcdc: Remove #ifdef guards for PM related functions
  2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
                     ` (8 preceding siblings ...)
  2022-11-07 17:52   ` [PATCH 20/26] drm: tegra: " Paul Cercueil
@ 2022-11-07 17:52   ` Paul Cercueil
  2022-11-07 17:52   ` [PATCH 22/26] drm: vboxvideo: " Paul Cercueil
                     ` (2 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:52 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter
  Cc: Paul Cercueil, Tomi Valkeinen, Jyri Sarha, 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: 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 f72755b8ea14..cd5bdc2f803a 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] 44+ messages in thread

* [PATCH 22/26] drm: vboxvideo: Remove #ifdef guards for PM related functions
  2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
                     ` (9 preceding siblings ...)
  2022-11-07 17:52   ` [PATCH 21/26] drm: tilcdc: " Paul Cercueil
@ 2022-11-07 17:52   ` Paul Cercueil
  2022-11-07 19:43     ` Hans de Goede
  2022-11-07 17:52   ` [PATCH 23/26] drm: vc4: " Paul Cercueil
  2022-11-07 20:27   ` [PATCH 21/26] drm: tilcdc: " sarha
  12 siblings, 1 reply; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:52 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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>
---
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 f4f2bd79a7cb..79318441ed7e 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] 44+ messages in thread

* [PATCH 23/26] drm: vc4: Remove #ifdef guards for PM related functions
  2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
                     ` (10 preceding siblings ...)
  2022-11-07 17:52   ` [PATCH 22/26] drm: vboxvideo: " Paul Cercueil
@ 2022-11-07 17:52   ` Paul Cercueil
  2022-11-07 20:27   ` [PATCH 21/26] drm: tilcdc: " sarha
  12 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:52 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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.

Note that this driver should probably use the
DEFINE_RUNTIME_DEV_PM_OPS() macro instead, which will provide
.suspend/.resume callbacks, pointing to pm_runtime_force_suspend() and
pm_runtime_force_resume() respectively; unless those callbacks really
aren't needed.

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] 44+ messages in thread

* Re: [PATCH 08/26] drm: atmel-hlcdc: Remove #ifdef guards for PM related functions
  2022-11-07 17:50 ` [PATCH 08/26] drm: atmel-hlcdc: Remove #ifdef guards for PM related functions Paul Cercueil
@ 2022-11-07 17:53   ` Sam Ravnborg
  2022-11-10 15:28   ` Claudiu.Beznea
  1 sibling, 0 replies; 44+ messages in thread
From: Sam Ravnborg @ 2022-11-07 17:53 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Alexandre Belloni, Thomas Zimmermann, Boris Brezillon,
	linux-kernel, dri-devel, Nicolas Ferre, Claudiu Beznea,
	linux-arm-kernel

On Mon, Nov 07, 2022 at 05:50:48PM +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>
> ---
> 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
Acked-by: Sam Ravnborg <sam@ravnborg.org>

Thanks for taking care of this.

	Sam


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

* [PATCH 24/26] drm: gm12u320: Remove #ifdef guards for PM related functions
  2022-11-07 17:50 [PATCH 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
                   ` (10 preceding siblings ...)
  2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
@ 2022-11-07 17:55 ` Paul Cercueil
  2022-11-07 17:55   ` [PATCH 25/26] drm: tidss: " Paul Cercueil
                     ` (2 more replies)
  11 siblings, 3 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:55 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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>
---
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 7441d992a5d7..0a901201142e 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] 44+ messages in thread

* [PATCH 25/26] drm: tidss: Remove #ifdef guards for PM related functions
  2022-11-07 17:55 ` [PATCH 24/26] drm: gm12u320: " Paul Cercueil
@ 2022-11-07 17:55   ` Paul Cercueil
  2022-11-07 17:55   ` [PATCH 26/26] drm/i915/gt: " Paul Cercueil
  2022-11-07 19:43   ` [PATCH 24/26] drm: gm12u320: " Hans de Goede
  2 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:55 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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 15cd9b91b7e2..6957c86f9e85 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] 44+ messages in thread

* [PATCH 26/26] drm/i915/gt: Remove #ifdef guards for PM related functions
  2022-11-07 17:55 ` [PATCH 24/26] drm: gm12u320: " Paul Cercueil
  2022-11-07 17:55   ` [PATCH 25/26] drm: tidss: " Paul Cercueil
@ 2022-11-07 17:55   ` Paul Cercueil
  2022-11-07 20:31     ` Rodrigo Vivi
  2022-11-07 19:43   ` [PATCH 24/26] drm: gm12u320: " Hans de Goede
  2 siblings, 1 reply; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 17:55 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	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 2b5f05b31187..decf892a4508 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, i915_reg_t reg)
 {
 	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] 44+ messages in thread

* Re: [PATCH 12/26] drm: etnaviv: Remove #ifdef guards for PM related functions
  2022-11-07 17:52   ` [PATCH 12/26] drm: etnaviv: " Paul Cercueil
@ 2022-11-07 18:07     ` Lucas Stach
  2022-11-07 21:03       ` Paul Cercueil
  0 siblings, 1 reply; 44+ messages in thread
From: Lucas Stach @ 2022-11-07 18:07 UTC (permalink / raw)
  To: Paul Cercueil, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter
  Cc: etnaviv, linux-kernel, dri-devel, Russell King

Am Montag, dem 07.11.2022 um 17:52 +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))".
> 
Reasoning and the change itself look good.

> Note that this driver should probably use the
> DEFINE_RUNTIME_DEV_PM_OPS() macro instead, which will provide
> .suspend/.resume callbacks, pointing to pm_runtime_force_suspend() and
> pm_runtime_force_resume() respectively; unless those callbacks really
> aren't needed.

This however isn't true, specifically this driver can _not_ use
pm_runtime_force_suspend, as the GPU can't be forced into suspend by
calling the rpm callback. A real suspend implementation would first
need to make sure the GPU finished working on the current queued jobs,
only then it would be able to power it down via the rpm suspend
callback.

Regards,
Lucas

> 
> 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 37018bc55810..e9a5444ec1c7 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> @@ -1605,7 +1605,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;
> @@ -1621,7 +1620,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,
> @@ -1689,11 +1687,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;
>  
> @@ -1737,12 +1734,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);
> @@ -1856,7 +1853,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);
> @@ -1899,18 +1895,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] 44+ messages in thread

* Re: [PATCH 22/26] drm: vboxvideo: Remove #ifdef guards for PM related functions
  2022-11-07 17:52   ` [PATCH 22/26] drm: vboxvideo: " Paul Cercueil
@ 2022-11-07 19:43     ` Hans de Goede
  0 siblings, 0 replies; 44+ messages in thread
From: Hans de Goede @ 2022-11-07 19:43 UTC (permalink / raw)
  To: Paul Cercueil, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter
  Cc: linux-kernel, dri-devel

Hi,

On 11/7/22 18:52, Paul Cercueil wrote:
> 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>
> ---
> Cc: Hans de Goede <hdegoede@redhat.com>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
>  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 f4f2bd79a7cb..79318441ed7e 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);


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

* Re: [PATCH 24/26] drm: gm12u320: Remove #ifdef guards for PM related functions
  2022-11-07 17:55 ` [PATCH 24/26] drm: gm12u320: " Paul Cercueil
  2022-11-07 17:55   ` [PATCH 25/26] drm: tidss: " Paul Cercueil
  2022-11-07 17:55   ` [PATCH 26/26] drm/i915/gt: " Paul Cercueil
@ 2022-11-07 19:43   ` Hans de Goede
  2 siblings, 0 replies; 44+ messages in thread
From: Hans de Goede @ 2022-11-07 19:43 UTC (permalink / raw)
  To: Paul Cercueil, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter
  Cc: linux-kernel, dri-devel

Hi,

On 11/7/22 18:55, Paul Cercueil wrote:
> 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>
> ---
> Cc: Hans de Goede <hdegoede@redhat.com>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
>  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 7441d992a5d7..0a901201142e 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);


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

* Re: [PATCH 21/26] drm: tilcdc: Remove #ifdef guards for PM related functions
  2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
                     ` (11 preceding siblings ...)
  2022-11-07 17:52   ` [PATCH 23/26] drm: vc4: " Paul Cercueil
@ 2022-11-07 20:27   ` sarha
  12 siblings, 0 replies; 44+ messages in thread
From: sarha @ 2022-11-07 20:27 UTC (permalink / raw)
  To: Paul Cercueil, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter
  Cc: Tomi Valkeinen, Jyri Sarha, linux-kernel, dri-devel

November 7, 2022 at 7:52 PM, "Paul Cercueil" <paul@crapouillou.net mailto:paul@crapouillou.net?to=%22Paul%20Cercueil%22%20%3Cpaul%40crapouillou.net%3E > 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>

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 f72755b8ea14..cd5bdc2f803a 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	[flat|nested] 44+ messages in thread

* Re: [PATCH 26/26] drm/i915/gt: Remove #ifdef guards for PM related functions
  2022-11-07 17:55   ` [PATCH 26/26] drm/i915/gt: " Paul Cercueil
@ 2022-11-07 20:31     ` Rodrigo Vivi
  2022-11-07 20:59       ` Paul Cercueil
  0 siblings, 1 reply; 44+ messages in thread
From: Rodrigo Vivi @ 2022-11-07 20:31 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Tvrtko Ursulin, Thomas Zimmermann, intel-gfx, linux-kernel, dri-devel

On Mon, Nov 07, 2022 at 05:55:10PM +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.

Making the RC6 to depend on the CONFIG_PM is probably an historical
mistake and probably the right solution is simply to remove that
dependency.

> 
> 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 2b5f05b31187..decf892a4508 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, i915_reg_t reg)
>  {
>  	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] 44+ messages in thread

* Re: [PATCH 26/26] drm/i915/gt: Remove #ifdef guards for PM related functions
  2022-11-07 20:31     ` Rodrigo Vivi
@ 2022-11-07 20:59       ` Paul Cercueil
  0 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 20:59 UTC (permalink / raw)
  To: Rodrigo Vivi
  Cc: Tvrtko Ursulin, Thomas Zimmermann, intel-gfx, linux-kernel, dri-devel

Hi Rodrigo,

Le lun. 7 nov. 2022 à 15:31:49 -0500, Rodrigo Vivi 
<rodrigo.vivi@intel.com> a écrit :
> On Mon, Nov 07, 2022 at 05:55:10PM +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.
> 
> Making the RC6 to depend on the CONFIG_PM is probably an historical
> mistake and probably the right solution is simply to remove that
> dependency.

I don't know anything about i915, so the best I can do is update the 
code without changing the functionality.

Then someone with a better understanding can send a patch to remove the 
check on CONFIG_PM.

Cheers,
-Paul

>> 
>>  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 2b5f05b31187..decf892a4508 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, i915_reg_t reg)
>>   {
>>   	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] 44+ messages in thread

* Re: [PATCH 12/26] drm: etnaviv: Remove #ifdef guards for PM related functions
  2022-11-07 18:07     ` Lucas Stach
@ 2022-11-07 21:03       ` Paul Cercueil
  0 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-07 21:03 UTC (permalink / raw)
  To: Lucas Stach
  Cc: Thomas Zimmermann, linux-kernel, dri-devel, etnaviv, Russell King

Hi Lucas,

Le lun. 7 nov. 2022 à 19:07:32 +0100, Lucas Stach 
<l.stach@pengutronix.de> a écrit :
> Am Montag, dem 07.11.2022 um 17:52 +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))".
>> 
> Reasoning and the change itself look good.

That's an ack? :)

>>  Note that this driver should probably use the
>>  DEFINE_RUNTIME_DEV_PM_OPS() macro instead, which will provide
>>  .suspend/.resume callbacks, pointing to pm_runtime_force_suspend() 
>> and
>>  pm_runtime_force_resume() respectively; unless those callbacks 
>> really
>>  aren't needed.
> 
> This however isn't true, specifically this driver can _not_ use
> pm_runtime_force_suspend, as the GPU can't be forced into suspend by
> calling the rpm callback. A real suspend implementation would first
> need to make sure the GPU finished working on the current queued jobs,
> only then it would be able to power it down via the rpm suspend
> callback.

Understood. I'll remove this paragraph if I have to V2.

Cheers,
-Paul

>> 
>>  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 37018bc55810..e9a5444ec1c7 100644
>>  --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
>>  +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
>>  @@ -1605,7 +1605,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;
>>  @@ -1621,7 +1620,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,
>>  @@ -1689,11 +1687,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;
>> 
>>  @@ -1737,12 +1734,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);
>>  @@ -1856,7 +1853,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);
>>  @@ -1899,18 +1895,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] 44+ messages in thread

* Re: [PATCH 01/26] drm: modeset-helper: Export dev_pm_ops for simple drivers
  2022-11-07 17:50 ` [PATCH 01/26] drm: modeset-helper: Export dev_pm_ops for simple drivers Paul Cercueil
@ 2022-11-08 12:10   ` Thomas Zimmermann
  2022-11-08 12:33     ` Paul Cercueil
  0 siblings, 1 reply; 44+ messages in thread
From: Thomas Zimmermann @ 2022-11-08 12:10 UTC (permalink / raw)
  To: Paul Cercueil, Maarten Lankhorst, Maxime Ripard, David Airlie,
	Daniel Vetter
  Cc: linux-kernel, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 4625 bytes --]

Hi Paul,

thanks for cleaning up. Please see my comments below.

Am 07.11.22 um 18:50 schrieb Paul Cercueil:
> Export a dev_pm_ops meant to 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 symbol is conditionally exported if IS_ENABLED(CONFIG_PM_SLEEP), and
> therefore it should always be referenced using the pm_sleep_ptr() macro.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>   drivers/gpu/drm/drm_modeset_helper.c | 32 ++++++++++++++++++++++++++++
>   include/drm/drm_modeset_helper.h     |  4 ++++
>   2 files changed, 36 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
> index f858dfedf2cf..0bc9f9228a60 100644
> --- a/drivers/gpu/drm/drm_modeset_helper.c
> +++ b/drivers/gpu/drm/drm_modeset_helper.c
> @@ -20,6 +20,9 @@
>    * OF THIS SOFTWARE.
>    */
>   
> +#include <linux/device.h>
> +#include <linux/pm.h>
> +
>   #include <drm/drm_atomic_helper.h>
>   #include <drm/drm_fb_helper.h>
>   #include <drm/drm_fourcc.h>
> @@ -244,3 +247,32 @@ int drm_mode_config_helper_resume(struct drm_device *dev)
>   	return ret;
>   }
>   EXPORT_SYMBOL(drm_mode_config_helper_resume);
> +
> +static int drm_mode_config_pm_suspend(struct device *dev)
> +{
> +	struct drm_device *drm = dev_get_drvdata(dev);
> +
> +	return drm_mode_config_helper_suspend(drm);
> +}
> +
> +static int drm_mode_config_pm_resume(struct device *dev)
> +{
> +	struct drm_device *drm = dev_get_drvdata(dev);
> +
> +	return drm_mode_config_helper_resume(drm);
> +}
> +
> +/**
> + * drm_mode_config_pm_ops - Exported dev_pm_ops helper for simple drivers
> + *
> + * This dev_pm_ops can be used for simple drivers that would otherwise only call
> + * drm_mode_config_helper_suspend / drm_mode_config_helper_resume in their PM
> + * callbacks. It is only valid if the driver's drm_device has been registered as
> + * the struct device's drvdata.
> + *
> + * The exported symbol must always be used with the pm_sleep_ptr() macro, like
> + * this:
> + * .pm = pm_sleep_ptr(&drm_mode_config_pm_ops),
> + */
> +EXPORT_SIMPLE_DEV_PM_OPS(drm_mode_config_pm_ops,
> +			 drm_mode_config_pm_suspend, drm_mode_config_pm_resume);
> diff --git a/include/drm/drm_modeset_helper.h b/include/drm/drm_modeset_helper.h
> index 995fd981cab0..85f29637e9c1 100644
> --- a/include/drm/drm_modeset_helper.h
> +++ b/include/drm/drm_modeset_helper.h
> @@ -23,6 +23,8 @@
>   #ifndef __DRM_KMS_HELPER_H__
>   #define __DRM_KMS_HELPER_H__

I like that you clean up the driver, but not how it's done TBH.

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

Half of DRM somehow incudes drm_kms_helper.h. So this include statements 
affects more or less everything.

>   struct drm_crtc;
>   struct drm_crtc_funcs;
>   struct drm_device;
> @@ -41,4 +43,6 @@ 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);
>   
> +extern const struct dev_pm_ops drm_mode_config_pm_ops;
> +

That's maybe subjective, but I don't like exporting such _funcs and _ops 
instances. They are like blackboxes.  And they pollute the symbol 
namespace unnecessarily.

I propose a solution similar to DEFINE_DRM_GEM_FOPS [1] or 
drm_module_pci_driver. [2]

Define a macro in the header to create the _ops instance, such as

#if defined(CONFIG_PM)
#define DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS(_name)  \
   static __ ## _name ## _suspend() {  \
     call drm_mode_config_helper_suspend()  \
   } \
   static __ ## _name ## _resume() {  \
     call drm_mode_config_helper_resume()  \
   }  \
   static SIMPLE_DEV_PM_OPS(_name, __ ## _name ## _suspend, __ ## _name 
## _resume);
#else
#define DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS(_name)
#endif

Drivers can then keep the instance and the include for pm.h internal 
within their _drv.c file. The small callback functions are within the 
source file as well.  If CONFIG_PM has been disabled, nothing is being 
generated.

Best regards
Thomas

[1] 
https://elixir.bootlin.com/linux/v6.1-rc4/source/include/drm/drm_gem.h#L396
[2] 
https://elixir.bootlin.com/linux/v6.1-rc4/source/include/drm/drm_module.h#L58


>   #endif

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

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

* Re: [PATCH 01/26] drm: modeset-helper: Export dev_pm_ops for simple drivers
  2022-11-08 12:10   ` Thomas Zimmermann
@ 2022-11-08 12:33     ` Paul Cercueil
  0 siblings, 0 replies; 44+ messages in thread
From: Paul Cercueil @ 2022-11-08 12:33 UTC (permalink / raw)
  To: Thomas Zimmermann; +Cc: linux-kernel, dri-devel

Hi Thomas,

Le mar. 8 nov. 2022 à 13:10:49 +0100, Thomas Zimmermann 
<tzimmermann@suse.de> a écrit :
> Hi Paul,
> 
> thanks for cleaning up. Please see my comments below.
> 
> Am 07.11.22 um 18:50 schrieb Paul Cercueil:
>> Export a dev_pm_ops meant to 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 symbol is conditionally exported if IS_ENABLED(CONFIG_PM_SLEEP), 
>> and
>> therefore it should always be referenced using the pm_sleep_ptr() 
>> macro.
>> 
>> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>> ---
>>   drivers/gpu/drm/drm_modeset_helper.c | 32 
>> ++++++++++++++++++++++++++++
>>   include/drm/drm_modeset_helper.h     |  4 ++++
>>   2 files changed, 36 insertions(+)
>> 
>> diff --git a/drivers/gpu/drm/drm_modeset_helper.c 
>> b/drivers/gpu/drm/drm_modeset_helper.c
>> index f858dfedf2cf..0bc9f9228a60 100644
>> --- a/drivers/gpu/drm/drm_modeset_helper.c
>> +++ b/drivers/gpu/drm/drm_modeset_helper.c
>> @@ -20,6 +20,9 @@
>>    * OF THIS SOFTWARE.
>>    */
>> 
>> +#include <linux/device.h>
>> +#include <linux/pm.h>
>> +
>>   #include <drm/drm_atomic_helper.h>
>>   #include <drm/drm_fb_helper.h>
>>   #include <drm/drm_fourcc.h>
>> @@ -244,3 +247,32 @@ int drm_mode_config_helper_resume(struct 
>> drm_device *dev)
>>   	return ret;
>>   }
>>   EXPORT_SYMBOL(drm_mode_config_helper_resume);
>> +
>> +static int drm_mode_config_pm_suspend(struct device *dev)
>> +{
>> +	struct drm_device *drm = dev_get_drvdata(dev);
>> +
>> +	return drm_mode_config_helper_suspend(drm);
>> +}
>> +
>> +static int drm_mode_config_pm_resume(struct device *dev)
>> +{
>> +	struct drm_device *drm = dev_get_drvdata(dev);
>> +
>> +	return drm_mode_config_helper_resume(drm);
>> +}
>> +
>> +/**
>> + * drm_mode_config_pm_ops - Exported dev_pm_ops helper for simple 
>> drivers
>> + *
>> + * This dev_pm_ops can be used for simple drivers that would 
>> otherwise only call
>> + * drm_mode_config_helper_suspend / drm_mode_config_helper_resume 
>> in their PM
>> + * callbacks. It is only valid if the driver's drm_device has been 
>> registered as
>> + * the struct device's drvdata.
>> + *
>> + * The exported symbol must always be used with the pm_sleep_ptr() 
>> macro, like
>> + * this:
>> + * .pm = pm_sleep_ptr(&drm_mode_config_pm_ops),
>> + */
>> +EXPORT_SIMPLE_DEV_PM_OPS(drm_mode_config_pm_ops,
>> +			 drm_mode_config_pm_suspend, drm_mode_config_pm_resume);
>> diff --git a/include/drm/drm_modeset_helper.h 
>> b/include/drm/drm_modeset_helper.h
>> index 995fd981cab0..85f29637e9c1 100644
>> --- a/include/drm/drm_modeset_helper.h
>> +++ b/include/drm/drm_modeset_helper.h
>> @@ -23,6 +23,8 @@
>>   #ifndef __DRM_KMS_HELPER_H__
>>   #define __DRM_KMS_HELPER_H__
> 
> I like that you clean up the driver, but not how it's done TBH.
> 
>> 
>> +#include <linux/pm.h>
>> +
> 
> Half of DRM somehow incudes drm_kms_helper.h. So this include 
> statements
> affects more or less everything.
> 
>>   struct drm_crtc;
>>   struct drm_crtc_funcs;
>>   struct drm_device;
>> @@ -41,4 +43,6 @@ 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);
>> 
>> +extern const struct dev_pm_ops drm_mode_config_pm_ops;
>> +
> 
> That's maybe subjective, but I don't like exporting such _funcs and 
> _ops
> instances. They are like blackboxes.  And they pollute the symbol
> namespace unnecessarily.
> 
> I propose a solution similar to DEFINE_DRM_GEM_FOPS [1] or
> drm_module_pci_driver. [2]
> 
> Define a macro in the header to create the _ops instance, such as
> 
> #if defined(CONFIG_PM)
> #define DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS(_name)  \
>   static __ ## _name ## _suspend() {  \
>     call drm_mode_config_helper_suspend()  \
>   } \
>   static __ ## _name ## _resume() {  \
>     call drm_mode_config_helper_resume()  \
>   }  \
>   static SIMPLE_DEV_PM_OPS(_name, __ ## _name ## _suspend, __ ## _name
> ## _resume);
> #else
> #define DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS(_name)
> #endif
> 
> Drivers can then keep the instance and the include for pm.h internal
> within their _drv.c file. The small callback functions are within the
> source file as well.  If CONFIG_PM has been disabled, nothing is being
> generated.

Another alternative would be to make the exported 
"drm_mode_config_pm_ops" a pointer. Then it can be opaque and you 
wouldn't need the <linux/pm.h> include in the header.

Your solution works too, I guess. I find it inelegant, but I won't 
fight you hard on this.

Cheers,
-Paul

> 
> Best regards
> Thomas
> 
> [1]
> https://elixir.bootlin.com/linux/v6.1-rc4/source/include/drm/drm_gem.h#L396
> [2]
> https://elixir.bootlin.com/linux/v6.1-rc4/source/include/drm/drm_module.h#L58
> 
> 
>>   #endif
> 
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Ivo Totev



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

* Re: [PATCH 16/26] drm: panfrost: Remove #ifdef guards for PM related functions
  2022-11-07 17:52   ` [PATCH 16/26] drm: panfrost: " Paul Cercueil
@ 2022-11-09 15:16     ` Steven Price
  0 siblings, 0 replies; 44+ messages in thread
From: Steven Price @ 2022-11-09 15:16 UTC (permalink / raw)
  To: Paul Cercueil, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter
  Cc: Alyssa Rosenzweig, linux-kernel, dri-devel, Tomeu Vizoso

On 07/11/2022 17:52, 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,
>  	},
>  };


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

* Re: [PATCH 08/26] drm: atmel-hlcdc: Remove #ifdef guards for PM related functions
  2022-11-07 17:50 ` [PATCH 08/26] drm: atmel-hlcdc: Remove #ifdef guards for PM related functions Paul Cercueil
  2022-11-07 17:53   ` Sam Ravnborg
@ 2022-11-10 15:28   ` Claudiu.Beznea
  1 sibling, 0 replies; 44+ messages in thread
From: Claudiu.Beznea @ 2022-11-10 15:28 UTC (permalink / raw)
  To: paul, maarten.lankhorst, mripard, tzimmermann, airlied, daniel
  Cc: alexandre.belloni, bbrezillon, Nicolas.Ferre, dri-devel,
	linux-kernel, sam, linux-arm-kernel

On 07.11.2022 19:50, Paul Cercueil wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> 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: 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

Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>


> ---
>  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 f7e7f4e919c7..05146936cc70 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	[flat|nested] 44+ messages in thread

* Re: [PATCH 10/26] drm: imx/dcss: Remove #ifdef guards for PM related functions
  2022-11-07 17:50 ` [PATCH 10/26] drm: imx/dcss: " Paul Cercueil
@ 2022-11-11 14:27   ` Laurentiu Palcu
  0 siblings, 0 replies; 44+ messages in thread
From: Laurentiu Palcu @ 2022-11-11 14:27 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Thomas Zimmermann, Shawn Guo, Sascha Hauer, linux-kernel,
	dri-devel, NXP Linux Team, Pengutronix Kernel Team,
	linux-arm-kernel

Hi Paul,

On Mon, Nov 07, 2022 at 05:50:50PM +0000, Paul Cercueil wrote:
> 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>

Thanks,
Laurentiu

> ---
> 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	[flat|nested] 44+ messages in thread

* Re: [PATCH 06/26] drm: sun4i: Use the dev_pm_ops provided by modeset helper
  2022-11-07 17:50 ` [PATCH 06/26] drm: sun4i: " Paul Cercueil
@ 2022-11-14  0:34   ` Samuel Holland
  0 siblings, 0 replies; 44+ messages in thread
From: Samuel Holland @ 2022-11-14  0:34 UTC (permalink / raw)
  To: Paul Cercueil, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter
  Cc: linux-kernel, Jernej Skrabec, Chen-Yu Tsai, dri-devel,
	linux-sunxi, linux-arm-kernel

On 11/7/22 11:50, Paul Cercueil wrote:
> Use the drm_mode_config_pm_ops structure exported by
> drm_modeset_helper.c, which provides the exact same PM callbacks.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
> 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 | 24 ++----------------------
>  1 file changed, 2 insertions(+), 22 deletions(-)

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


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

* Re: [PATCH 17/26] drm: rcar-du: Remove #ifdef guards for PM related functions
  2022-11-07 17:52   ` [PATCH 17/26] drm: rcar-du: " Paul Cercueil
@ 2022-11-16 13:41     ` Kieran Bingham
  0 siblings, 0 replies; 44+ messages in thread
From: Kieran Bingham @ 2022-11-16 13:41 UTC (permalink / raw)
  To: Daniel Vetter, David Airlie, Maarten Lankhorst, Maxime Ripard,
	Paul Cercueil, Thomas Zimmermann
  Cc: Paul Cercueil, linux-renesas-soc, linux-kernel, dri-devel,
	Laurent Pinchart

Quoting Paul Cercueil (2022-11-07 17:52:47)
> 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>

Seems reasonable to me.

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 a2776f1d6f2c..0a89094461cc 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	[flat|nested] 44+ messages in thread

* Re: [PATCH 19/26] drm: shmobile: Remove #ifdef guards for PM related functions
  2022-11-07 17:52   ` [PATCH 19/26] drm: shmobile: " Paul Cercueil
@ 2022-11-16 13:41     ` Kieran Bingham
  0 siblings, 0 replies; 44+ messages in thread
From: Kieran Bingham @ 2022-11-16 13:41 UTC (permalink / raw)
  To: Daniel Vetter, David Airlie, Maarten Lankhorst, Maxime Ripard,
	Paul Cercueil, Thomas Zimmermann
  Cc: Paul Cercueil, linux-renesas-soc, linux-kernel, dri-devel,
	Laurent Pinchart

Quoting Paul Cercueil (2022-11-07 17:52:49)
> 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	[flat|nested] 44+ messages in thread

* Re: [PATCH 09/26] drm: exynos: Remove #ifdef guards for PM related functions
  2022-11-07 17:50 ` [PATCH 09/26] drm: exynos: " Paul Cercueil
@ 2022-11-21  4:25   ` Inki Dae
  0 siblings, 0 replies; 44+ messages in thread
From: Inki Dae @ 2022-11-21  4:25 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: linux-samsung-soc, Thomas Zimmermann, Jingoo Han, linux-kernel,
	Seung-Woo Kim, Krzysztof Kozlowski, dri-devel, Kyungmin Park,
	Alim Akhtar, linux-arm-kernel

Hi,

2022년 11월 8일 (화) 오전 2:52, Paul Cercueil <paul@crapouillou.net>님이 작성:
>
> 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>

Thanks for cleanup,
Inki Dae

> ---
> 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	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2022-11-21  4:25 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-07 17:50 [PATCH 00/26] drm: Get rid of #ifdef CONFIG_PM* guards Paul Cercueil
2022-11-07 17:50 ` [PATCH 01/26] drm: modeset-helper: Export dev_pm_ops for simple drivers Paul Cercueil
2022-11-08 12:10   ` Thomas Zimmermann
2022-11-08 12:33     ` Paul Cercueil
2022-11-07 17:50 ` [PATCH 02/26] drm: bochs: Use the dev_pm_ops provided by modeset helper Paul Cercueil
2022-11-07 17:50 ` [PATCH 03/26] drm: imx: " Paul Cercueil
2022-11-07 17:50 ` [PATCH 04/26] drm: rockchip: " Paul Cercueil
2022-11-07 17:50 ` [PATCH 05/26] drm: tegra: " Paul Cercueil
2022-11-07 17:50 ` [PATCH 06/26] drm: sun4i: " Paul Cercueil
2022-11-14  0:34   ` Samuel Holland
2022-11-07 17:50 ` [PATCH 07/26] drm: msxfb: " Paul Cercueil
2022-11-07 17:50 ` [PATCH 08/26] drm: atmel-hlcdc: Remove #ifdef guards for PM related functions Paul Cercueil
2022-11-07 17:53   ` Sam Ravnborg
2022-11-10 15:28   ` Claudiu.Beznea
2022-11-07 17:50 ` [PATCH 09/26] drm: exynos: " Paul Cercueil
2022-11-21  4:25   ` Inki Dae
2022-11-07 17:50 ` [PATCH 10/26] drm: imx/dcss: " Paul Cercueil
2022-11-11 14:27   ` Laurentiu Palcu
2022-11-07 17:52 ` [PATCH 11/26] drm: bridge/dw-hdmi: " Paul Cercueil
2022-11-07 17:52   ` [PATCH 12/26] drm: etnaviv: " Paul Cercueil
2022-11-07 18:07     ` Lucas Stach
2022-11-07 21:03       ` Paul Cercueil
2022-11-07 17:52   ` [PATCH 13/26] drm: fsl-dcu: " Paul Cercueil
2022-11-07 17:52   ` [PATCH 14/26] drm: mediatek: " Paul Cercueil
2022-11-07 17:52   ` [PATCH 15/26] drm: omap: " Paul Cercueil
2022-11-07 17:52   ` [PATCH 16/26] drm: panfrost: " Paul Cercueil
2022-11-09 15:16     ` Steven Price
2022-11-07 17:52   ` [PATCH 17/26] drm: rcar-du: " Paul Cercueil
2022-11-16 13:41     ` Kieran Bingham
2022-11-07 17:52   ` [PATCH 18/26] drm: rockchip: " Paul Cercueil
2022-11-07 17:52   ` [PATCH 19/26] drm: shmobile: " Paul Cercueil
2022-11-16 13:41     ` Kieran Bingham
2022-11-07 17:52   ` [PATCH 20/26] drm: tegra: " Paul Cercueil
2022-11-07 17:52   ` [PATCH 21/26] drm: tilcdc: " Paul Cercueil
2022-11-07 17:52   ` [PATCH 22/26] drm: vboxvideo: " Paul Cercueil
2022-11-07 19:43     ` Hans de Goede
2022-11-07 17:52   ` [PATCH 23/26] drm: vc4: " Paul Cercueil
2022-11-07 20:27   ` [PATCH 21/26] drm: tilcdc: " sarha
2022-11-07 17:55 ` [PATCH 24/26] drm: gm12u320: " Paul Cercueil
2022-11-07 17:55   ` [PATCH 25/26] drm: tidss: " Paul Cercueil
2022-11-07 17:55   ` [PATCH 26/26] drm/i915/gt: " Paul Cercueil
2022-11-07 20:31     ` Rodrigo Vivi
2022-11-07 20:59       ` Paul Cercueil
2022-11-07 19:43   ` [PATCH 24/26] drm: gm12u320: " Hans de Goede

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).