Hi, On Fri, Aug 4, 2023 at 2:07 PM Douglas Anderson <dianders@xxxxxxxxxxxx> wrote: > > As talked about in commit d2aacaf07395 ("drm/panel: Check for already > prepared/enabled in drm_panel"), we want to remove needless code from > panel drivers that was storing and double-checking the > prepared/enabled state. Even if someone was relying on the > double-check before, that double-check is now in the core and not > needed in individual drivers. > > For the "otm8009a" driver we fully remove the storing of the "enabled" > state and we remove the double-checking, but we still keep the storing > of the "prepared" state since the backlight code in the driver checks > it. This backlight code may not be perfectly safe since there doesn't > appear to be sufficient synchronization between the backlight driver > (which userspace can call into directly) and the code that's > unpreparing the panel. However, this lack of safety is not new and can > be addressed in a future patch. > > Signed-off-by: Douglas Anderson <dianders@xxxxxxxxxxxx> > --- > From quick inspection, I think the right way to handle the backlight > properly is: > 1. Start calling backlight_get_brightness() instead of directly > getting "bd->props.brightness" and bd->props.power. This should > return 0 for a disabled (or blanked or powered off) backlight. > 2. Cache the backlight level in "struct otm8009a" > 3. If the backlight isn't changing compared to the cached value, make > otm8009a_backlight_update_status() a no-op. > 4. Remove the caching of the "prepared" value. > > That should work and always be safe because we always enable/disable > the backlight in the panel's enable() and disable() functions. The > backlight core has proper locking in this case. A disabled backlight > will always return a level of 0 which will always make the backlight's > update_status a no-op when the panel is disabled and keep us from > trying to talk to the panel when it's off. Userspace can't directly > cause a backlight to be enabled/disabled, it can only affect the other > blanking modes. Note: I'm not planning to take on the cleanup of making the backlight of this driver work better. Ideally someone who uses / maintains the affected hardware could give it a shot. > .../gpu/drm/panel/panel-orisetech-otm8009a.c | 17 ----------------- > 1 file changed, 17 deletions(-) In response to the cover letter [1], I proposed landing patches #1-#3 directly from here while we resolve the issues talked about in response to patch #4 [2]. I didn't hear any complaints, so I took Linus W's review tag from the cover letter and pushed this to drm-misc-next. 1e0465eb16a4 drm/panel: otm8009a: Don't double check prepared/enabled [1] https://lore.kernel.org/r/CAD=FV=UFuUsrrZmkL8_RL5WLvkJryDwRSAy_PWTa-hX_p0dF+Q@xxxxxxxxxxxxxx [2] https://lore.kernel.org/r/20230804140605.RFC.4.I930069a32baab6faf46d6b234f89613b5cec0f14@changeid/