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

drm/panel: Avoid warnings w/ panel-simple/panel-edp at shutdown

At shutdown if you've got a _properly_ coded DRM modeset driver then
you'll get these two warnings at shutdown time:

Skipping disable of already disabled panel
Skipping unprepare of already unprepared panel

These warnings are ugly and sound concerning, but they're actually a
sign of a properly working system. That's not great.

We're not ready to get rid of the calls to drm_panel_disable() and
drm_panel_unprepare() because we're not 100% convinced that all DRM
modeset drivers are properly calling drm_atomic_helper_shutdown() or
drm_helper_force_disable_all() at the right times. However, having the
warning show up for correctly working systems is bad.

As a bit of a workaround, add some "if" tests to try to avoid the
warning on correctly working systems. Also add some comments and
update the TODO items in the hopes that future developers won't be too
confused by what's going on here.

Suggested-by: Daniel Vetter <daniel@ffwll.ch>
Acked-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240621134427.1.Ieb287c2c3ee3f6d3b0d5f49b29f746b93621749c@changeid

+66 -35
+14 -17
Documentation/gpu/todo.rst
··· 475 475 As of commit d2aacaf07395 ("drm/panel: Check for already prepared/enabled in 476 476 drm_panel"), we have a check in the drm_panel core to make sure nobody 477 477 double-calls prepare/enable/disable/unprepare. Eventually that should probably 478 - be turned into a WARN_ON() or somehow made louder, but right now we actually 479 - expect it to trigger and so we don't want it to be too loud. 478 + be turned into a WARN_ON() or somehow made louder. 480 479 481 - Specifically, that warning will trigger for panel-edp and panel-simple at 482 - shutdown time because those panels hardcode a call to drm_panel_disable() 483 - and drm_panel_unprepare() at shutdown and remove time that they call regardless 484 - of panel state. On systems with a properly coded DRM modeset driver that 485 - calls drm_atomic_helper_shutdown() this is pretty much guaranteed to cause 486 - the warning to fire. 480 + At the moment, we expect that we may still encounter the warnings in the 481 + drm_panel core when using panel-simple and panel-edp. Since those panel 482 + drivers are used with a lot of different DRM modeset drivers they still 483 + make an extra effort to disable/unprepare the panel themsevles at shutdown 484 + time. Specifically we could still encounter those warnings if the panel 485 + driver gets shutdown() _before_ the DRM modeset driver and the DRM modeset 486 + driver properly calls drm_atomic_helper_shutdown() in its own shutdown() 487 + callback. Warnings could be avoided in such a case by using something like 488 + device links to ensure that the panel gets shutdown() after the DRM modeset 489 + driver. 487 490 488 - Unfortunately we can't safely remove the calls in panel-edp and panel-simple 489 - until we're sure that all DRM modeset drivers that are used with those panels 490 - properly call drm_atomic_helper_shutdown(). This TODO item is to validate 491 - that all DRM modeset drivers used with panel-edp and panel-simple properly 492 - call drm_atomic_helper_shutdown() and then remove the calls to 493 - disable/unprepare from those panels. Alternatively, this TODO item could be 494 - removed by convincing stakeholders that those calls are fine and downgrading 495 - the error message in drm_panel_disable() / drm_panel_unprepare() to a 496 - debug-level message. 491 + Once all DRM modeset drivers are known to shutdown properly, the extra 492 + calls to disable/unprepare in remove/shutdown in panel-simple and panel-edp 493 + should be removed and this TODO item marked complete. 497 494 498 495 Contact: Douglas Anderson <dianders@chromium.org> 499 496
+18
drivers/gpu/drm/drm_panel.c
··· 161 161 if (!panel) 162 162 return -EINVAL; 163 163 164 + /* 165 + * If you are seeing the warning below it likely means one of two things: 166 + * - Your panel driver incorrectly calls drm_panel_unprepare() in its 167 + * shutdown routine. You should delete this. 168 + * - You are using panel-edp or panel-simple and your DRM modeset 169 + * driver's shutdown() callback happened after the panel's shutdown(). 170 + * In this case the warning is harmless though ideally you should 171 + * figure out how to reverse the order of the shutdown() callbacks. 172 + */ 164 173 if (!panel->prepared) { 165 174 dev_warn(panel->dev, "Skipping unprepare of already unprepared panel\n"); 166 175 return 0; ··· 254 245 if (!panel) 255 246 return -EINVAL; 256 247 248 + /* 249 + * If you are seeing the warning below it likely means one of two things: 250 + * - Your panel driver incorrectly calls drm_panel_disable() in its 251 + * shutdown routine. You should delete this. 252 + * - You are using panel-edp or panel-simple and your DRM modeset 253 + * driver's shutdown() callback happened after the panel's shutdown(). 254 + * In this case the warning is harmless though ideally you should 255 + * figure out how to reverse the order of the shutdown() callbacks. 256 + */ 257 257 if (!panel->enabled) { 258 258 dev_warn(panel->dev, "Skipping disable of already disabled panel\n"); 259 259 return 0;
+17 -9
drivers/gpu/drm/panel/panel-edp.c
··· 954 954 * drm_atomic_helper_shutdown() at shutdown time and that should 955 955 * cause the panel to be disabled / unprepared if needed. For now, 956 956 * however, we'll keep these calls due to the sheer number of 957 - * different DRM modeset drivers used with panel-edp. The fact that 958 - * we're calling these and _also_ the drm_atomic_helper_shutdown() 959 - * will try to disable/unprepare means that we can get a warning about 960 - * trying to disable/unprepare an already disabled/unprepared panel, 961 - * but that's something we'll have to live with until we've confirmed 962 - * that all DRM modeset drivers are properly calling 963 - * drm_atomic_helper_shutdown(). 957 + * different DRM modeset drivers used with panel-edp. Once we've 958 + * confirmed that all DRM modeset drivers using this panel properly 959 + * call drm_atomic_helper_shutdown() we can simply delete the two 960 + * calls below. 961 + * 962 + * TO BE EXPLICIT: THE CALLS BELOW SHOULDN'T BE COPIED TO ANY NEW 963 + * PANEL DRIVERS. 964 + * 965 + * FIXME: If we're still haven't figured out if all DRM modeset 966 + * drivers properly call drm_atomic_helper_shutdown() but we _have_ 967 + * managed to make sure that DRM modeset drivers get their shutdown() 968 + * callback before the panel's shutdown() callback (perhaps using 969 + * device link), we could add a WARN_ON here to help move forward. 964 970 */ 965 - drm_panel_disable(&panel->base); 966 - drm_panel_unprepare(&panel->base); 971 + if (panel->base.enabled) 972 + drm_panel_disable(&panel->base); 973 + if (panel->base.prepared) 974 + drm_panel_unprepare(&panel->base); 967 975 } 968 976 969 977 static void panel_edp_remove(struct device *dev)
+17 -9
drivers/gpu/drm/panel/panel-simple.c
··· 726 726 * drm_atomic_helper_shutdown() at shutdown time and that should 727 727 * cause the panel to be disabled / unprepared if needed. For now, 728 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(). 729 + * different DRM modeset drivers used with panel-simple. Once we've 730 + * confirmed that all DRM modeset drivers using this panel properly 731 + * call drm_atomic_helper_shutdown() we can simply delete the two 732 + * calls below. 733 + * 734 + * TO BE EXPLICIT: THE CALLS BELOW SHOULDN'T BE COPIED TO ANY NEW 735 + * PANEL DRIVERS. 736 + * 737 + * FIXME: If we're still haven't figured out if all DRM modeset 738 + * drivers properly call drm_atomic_helper_shutdown() but we _have_ 739 + * managed to make sure that DRM modeset drivers get their shutdown() 740 + * callback before the panel's shutdown() callback (perhaps using 741 + * device link), we could add a WARN_ON here to help move forward. 736 742 */ 737 - drm_panel_disable(&panel->base); 738 - drm_panel_unprepare(&panel->base); 743 + if (panel->base.enabled) 744 + drm_panel_disable(&panel->base); 745 + if (panel->base.prepared) 746 + drm_panel_unprepare(&panel->base); 739 747 } 740 748 741 749 static void panel_simple_remove(struct device *dev)