Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/panel: simple: Add a comment about unprepare+disable at shutdown/remove

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

+23 -10
+23 -10
drivers/gpu/drm/panel/panel-simple.c
··· 716 716 return err; 717 717 } 718 718 719 + static void panel_simple_shutdown(struct device *dev) 720 + { 721 + struct panel_simple *panel = dev_get_drvdata(dev); 722 + 723 + /* 724 + * NOTE: the following two calls don't really belong here. It is the 725 + * responsibility of a correctly written DRM modeset driver to call 726 + * drm_atomic_helper_shutdown() at shutdown time and that should 727 + * cause the panel to be disabled / unprepared if needed. For now, 728 + * however, we'll keep these calls due to the sheer number of 729 + * different DRM modeset drivers used with panel-simple. The fact that 730 + * we're calling these and _also_ the drm_atomic_helper_shutdown() 731 + * will try to disable/unprepare means that we can get a warning about 732 + * trying to disable/unprepare an already disabled/unprepared panel, 733 + * but that's something we'll have to live with until we've confirmed 734 + * that all DRM modeset drivers are properly calling 735 + * drm_atomic_helper_shutdown(). 736 + */ 737 + drm_panel_disable(&panel->base); 738 + drm_panel_unprepare(&panel->base); 739 + } 740 + 719 741 static void panel_simple_remove(struct device *dev) 720 742 { 721 743 struct panel_simple *panel = dev_get_drvdata(dev); 722 744 723 745 drm_panel_remove(&panel->base); 724 - drm_panel_disable(&panel->base); 725 - drm_panel_unprepare(&panel->base); 746 + panel_simple_shutdown(dev); 726 747 727 748 pm_runtime_dont_use_autosuspend(dev); 728 749 pm_runtime_disable(dev); 729 750 if (panel->ddc) 730 751 put_device(&panel->ddc->dev); 731 - } 732 - 733 - static void panel_simple_shutdown(struct device *dev) 734 - { 735 - struct panel_simple *panel = dev_get_drvdata(dev); 736 - 737 - drm_panel_disable(&panel->base); 738 - drm_panel_unprepare(&panel->base); 739 752 } 740 753 741 754 static const struct drm_display_mode ampire_am_1280800n3tzqw_t00h_mode = {