Re: [PATCH] drm/panel: samsung: s6e8aa0: Add backlight control support

From: Joonas KylmÃlÃ
Date: Mon Sep 23 2019 - 13:57:29 EST


Hi,

thanks a lot for the review, Andrzej!

Andrzej Hajda:
>> +static const struct backlight_ops s6e8aa0_backlight_ops = {
>> + .update_status = s6e8aa0_set_brightness,
>
>
> This is racy, update_status can be called in any time between probe and
> remove, particularly:
>
> a) before panel enable,
>
> b) during panel enable,
>
> c) when panel is enabled,
>
> d) during panel disable,
>
> e) after panel disable,
>
>
> b and d are racy for sure - backlight and drm callbacks are async.
>
> IMO the best solution would be to register backlight after attaching
> panel to drm, but for this drm_panel_funcs should have attach/detach
> callbacks (like drm_bridge_funcs),
>
> then update_status callback should take some drm_connector lock to
> synchronize with drm, and write to hw only when pipe is enabled.

I will start reading the kernel DRM KMS documentation in order to learn
how the attach callback would fit in the picture and do what you suggest
but it might take a few weeks or months.

Also, as a lot of this code was mimicked from
drivers/gpu/drm/panel/panel-samsung-s6e63m0.c it looks like that is also
having this race condition. Unfortunately, I don't think I have the
s6e63m0 panel so for that I probably cannot fix this issue.

Joonas