Skip to content

Commit 7908632

Browse files
committed
Revert "drm/vkms: Fix race-condition between the hrtimer and the atomic commit"
This reverts commit a0e6a01. Unlocking a mutex in the context of a hrtimer callback is violating mutex locking rules, as mutex_unlock() from interrupt context is not permitted. Link: https://lore.kernel.org/dri-devel/ZQLAc%2FFwkv%2FGiVoK@phenom.ffwll.local/T/#t Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Maíra Canal <mcanal@igalia.com> Signed-off-by: Maíra Canal <mairacanal@riseup.net> Link: https://patchwork.freedesktop.org/patch/msgid/20230914102024.1789154-1-mcanal@igalia.com
1 parent c900529 commit 7908632

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

drivers/gpu/drm/vkms/vkms_composer.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,10 @@ void vkms_set_composer(struct vkms_output *out, bool enabled)
408408
if (enabled)
409409
drm_crtc_vblank_get(&out->crtc);
410410

411-
mutex_lock(&out->enabled_lock);
411+
spin_lock_irq(&out->lock);
412412
old_enabled = out->composer_enabled;
413413
out->composer_enabled = enabled;
414-
415-
/* the composition wasn't enabled, so unlock the lock to make sure the lock
416-
* will be balanced even if we have a failed commit
417-
*/
418-
if (!out->composer_enabled)
419-
mutex_unlock(&out->enabled_lock);
414+
spin_unlock_irq(&out->lock);
420415

421416
if (old_enabled)
422417
drm_crtc_vblank_put(&out->crtc);

drivers/gpu/drm/vkms/vkms_crtc.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer)
1616
struct drm_crtc *crtc = &output->crtc;
1717
struct vkms_crtc_state *state;
1818
u64 ret_overrun;
19-
bool ret, fence_cookie, composer_enabled;
19+
bool ret, fence_cookie;
2020

2121
fence_cookie = dma_fence_begin_signalling();
2222

@@ -25,15 +25,15 @@ static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer)
2525
if (ret_overrun != 1)
2626
pr_warn("%s: vblank timer overrun\n", __func__);
2727

28+
spin_lock(&output->lock);
2829
ret = drm_crtc_handle_vblank(crtc);
2930
if (!ret)
3031
DRM_ERROR("vkms failure on handling vblank");
3132

3233
state = output->composer_state;
33-
composer_enabled = output->composer_enabled;
34-
mutex_unlock(&output->enabled_lock);
34+
spin_unlock(&output->lock);
3535

36-
if (state && composer_enabled) {
36+
if (state && output->composer_enabled) {
3737
u64 frame = drm_crtc_accurate_vblank_count(crtc);
3838

3939
/* update frame_start only if a queued vkms_composer_worker()
@@ -295,7 +295,6 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
295295

296296
spin_lock_init(&vkms_out->lock);
297297
spin_lock_init(&vkms_out->composer_lock);
298-
mutex_init(&vkms_out->enabled_lock);
299298

300299
vkms_out->composer_workq = alloc_ordered_workqueue("vkms_composer", 0);
301300
if (!vkms_out->composer_workq)

drivers/gpu/drm/vkms/vkms_drv.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,8 @@ struct vkms_output {
108108
struct workqueue_struct *composer_workq;
109109
/* protects concurrent access to composer */
110110
spinlock_t lock;
111-
/* guarantees that if the composer is enabled, a job will be queued */
112-
struct mutex enabled_lock;
113111

114-
/* protected by @enabled_lock */
112+
/* protected by @lock */
115113
bool composer_enabled;
116114
struct vkms_crtc_state *composer_state;
117115

0 commit comments

Comments
 (0)