* [PATCH] drm/probe-helper: reschedule output poll immediately if a delayed event is pending
@ 2026-12-04 11:07 Luca Ceresoli
2026-12-04 11:25 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Luca Ceresoli @ 2026-12-04 11:07 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Daniel Stone, Marius Vlad, Nicolas Frattaroli
Cc: Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel, linux-kernel,
Luca Ceresoli
Before commit 9499d3bc41a2 ("drm: Send per-connector hotplug events"),
output_poll_execute() used to always send connector hotplug events when
mode_config.delayed_event == true (which was good), without taking
mode_config.mutex (which was bad).
Since that commit, it always takes mode_config.mutex before checking
mode_config.delayed_event (which is good, because delayed event needs to be
read-and-updated) but at the cost of having to reschedule when the lock
cannot be taken.
So now a delayed event could be missed for up to DRM_OUTPUT_POLL_PERIOD,
i.e. 10 seconds. This happens frequently (10~20% of the cases in my tests)
when writing the 'status' sysfs attribute, as in:
echo on >/sys/class/drm/card*/status
#or
echo off >/sys/class/drm/card*/status
This is because:
CPU0 CPU1
status_store() in drm_sysfs.c:
* takes mode_config.mutex
* calls connector->funcs->fill_modes()
. -> drm_helper_probe_single_connector_modes()
. -> dev->mode_config.delayed_event = true
. -> mod_delayed_work() // with zero delay
. `-> wakes -----> output_poll_execute()
. -> tries taking mode_config.mutex
* releases mode_config.mutex
The CPU1 code sometimes runs before mode_config.mutex is released, and in
that case output_poll_execute() reschedules 10 seconds later. When this
happens, a display or panel will react exactly 10 seconds later.
Avoid the 10 seconds delay by rescheduling almost immediately when a
delayed event is known to be present, so it will be picked up very soon.
Fixes: 9499d3bc41a2 ("drm: Send per-connector hotplug events")
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/drm_probe_helper.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index 856b40fdaac4..fb93ae6f70e9 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;
}
---
base-commit: ae720e1e682846a3c23ba572d96a38f46709bef0
change-id: 20261204-drm-output-poll-10s-fix-e480efb33307
Best regards,
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] drm/probe-helper: reschedule output poll immediately if a delayed event is pending
2026-12-04 11:07 [PATCH] drm/probe-helper: reschedule output poll immediately if a delayed event is pending Luca Ceresoli
@ 2026-12-04 11:25 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-04 11:25 UTC (permalink / raw)
To: Luca Ceresoli; +Cc: dri-devel
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 <luca.ceresoli@bootlin.com>
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/20261204-drm-output-poll-10s-fix-v1-1-46fa0816517b@bootlin.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-04 11:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 11:07 [PATCH] drm/probe-helper: reschedule output poll immediately if a delayed event is pending Luca Ceresoli
2026-12-04 11:25 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.