drm/panel: simple: Add a comment about unprepare+disable at shutdown/remove
authorDouglas Anderson <dianders@chromium.org>
Fri, 3 May 2024 21:33:08 +0000 (14:33 -0700)
committerDouglas Anderson <dianders@chromium.org>
Tue, 28 May 2024 20:09:11 +0000 (13:09 -0700)
It's the responsibility of a correctly written DRM modeset driver to
call drm_atomic_helper_shutdown() at shutdown time and that should be
disabling / unpreparing the panel if needed. Panel drivers shouldn't
be calling these functions themselves.

A recent effort was made to fix as many DRM modeset drivers as
possible [1] [2] [3] and most drivers are fixed now.

Unfortunately, it's very difficult to know exactly which DRM modeset
drivers are using panel-simple due to the sheer number of panels it
handles. For now, we'll leave the calls and just add a comment to keep
people from copying this code.

[1] https://lore.kernel.org/r/20230901234015.566018-1-dianders@chromium.org
[2] https://lore.kernel.org/r/20230901234202.566951-1-dianders@chromium.org
[3] https://lore.kernel.org/r/20230921192749.1542462-1-dianders@chromium.org

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240503143327.RFT.v2.27.I639183ac987e139092491a94e22d46a5d857580c@changeid
drivers/gpu/drm/panel/panel-simple.c

index df32284fa293e7572cd6b061557eb1dccd2ff763..9b9e078ec8aa52178e81c736597ec7ef51b01b50 100644 (file)
@@ -716,26 +716,39 @@ free_ddc:
        return err;
 }
 
-static void panel_simple_remove(struct device *dev)
+static void panel_simple_shutdown(struct device *dev)
 {
        struct panel_simple *panel = dev_get_drvdata(dev);
 
-       drm_panel_remove(&panel->base);
+       /*
+        * NOTE: the following two calls don't really belong here. It is the
+        * responsibility of a correctly written DRM modeset driver to call
+        * drm_atomic_helper_shutdown() at shutdown time and that should
+        * cause the panel to be disabled / unprepared if needed. For now,
+        * however, we'll keep these calls due to the sheer number of
+        * different DRM modeset drivers used with panel-simple. The fact that
+        * we're calling these and _also_ the drm_atomic_helper_shutdown()
+        * will try to disable/unprepare means that we can get a warning about
+        * trying to disable/unprepare an already disabled/unprepared panel,
+        * but that's something we'll have to live with until we've confirmed
+        * that all DRM modeset drivers are properly calling
+        * drm_atomic_helper_shutdown().
+        */
        drm_panel_disable(&panel->base);
        drm_panel_unprepare(&panel->base);
-
-       pm_runtime_dont_use_autosuspend(dev);
-       pm_runtime_disable(dev);
-       if (panel->ddc)
-               put_device(&panel->ddc->dev);
 }
 
-static void panel_simple_shutdown(struct device *dev)
+static void panel_simple_remove(struct device *dev)
 {
        struct panel_simple *panel = dev_get_drvdata(dev);
 
-       drm_panel_disable(&panel->base);
-       drm_panel_unprepare(&panel->base);
+       drm_panel_remove(&panel->base);
+       panel_simple_shutdown(dev);
+
+       pm_runtime_dont_use_autosuspend(dev);
+       pm_runtime_disable(dev);
+       if (panel->ddc)
+               put_device(&panel->ddc->dev);
 }
 
 static const struct drm_display_mode ampire_am_1280800n3tzqw_t00h_mode = {