Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/probe-helper: data race on delayed_event in
  output_poll_execute()
--

commit 3590d56e25fc2268f6037c709a9c3de88bf75348
Author: Luca Ceresoli <[email protected]>

drm/probe-helper: reschedule output poll immediately if a delayed event is 
pending

This commit changes output_poll_execute() to reschedule after 10 ms instead of
DRM_OUTPUT_POLL_PERIOD when mutex_trylock() fails and
dev->mode_config.delayed_event is set.

> diff --git a/drivers/gpu/drm/drm_probe_helper.c 
> b/drivers/gpu/drm/drm_probe_helper.c
> index 856b40fdaac4a..fb93ae6f70e97 100644
> --- a/drivers/gpu/drm/drm_probe_helper.c
> +++ b/drivers/gpu/drm/drm_probe_helper.c
> @@ -797,7 +797,13 @@ static void output_poll_execute(struct work_struct *work)
>       }
>  
>       if (!mutex_trylock(&dev->mode_config.mutex)) {
> -             schedule_delayed_work(delayed_work, DRM_OUTPUT_POLL_PERIOD);
> +             /*
> +              * Cannot get the lock: reschedule after the default
> +              * interval, or "very soon" if a delayed event is pending
> +              */
> +             schedule_delayed_work(delayed_work,
> +                                   dev->mode_config.delayed_event ?
> +                                   msecs_to_jiffies(10) : 
> DRM_OUTPUT_POLL_PERIOD);
>               return;
>       }

[Severity: Low]
Does this unlocked read of dev->mode_config.delayed_event introduce a data
race?

All writers update the plain bool dev->mode_config.delayed_event under
dev->mode_config.mutex with plain stores.  Because this branch runs while
another thread holds that mutex, output_poll_execute() can read delayed_event
concurrently with drm_helper_probe_single_connector_modes() setting it:

CPU0                                    CPU1
status_store()
  mutex_lock(&mode_config.mutex)
  ...
  drm_helper_probe_single_connector_modes()
                                        output_poll_execute()
                                          !mutex_trylock(&mode_config.mutex)
  mode_config.delayed_event = true        read mode_config.delayed_event
                                            <-- data race

This unmarked concurrent access triggers KCSAN reports under CONFIG_KCSAN.
Using READ_ONCE() here, paired with WRITE_ONCE() on the writes in
drm_helper_probe_single_connector_modes() and output_poll_execute(), would
keep this lockless check race-free.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to