drm/vkms: Fix race-condition between the hrtimer and the atomic commit
[platform/kernel/linux-rpi.git] / drivers / gpu / drm / vkms / vkms_composer.c
index 3c99fb8..d5d4f64 100644 (file)
@@ -408,10 +408,15 @@ void vkms_set_composer(struct vkms_output *out, bool enabled)
        if (enabled)
                drm_crtc_vblank_get(&out->crtc);
 
-       spin_lock_irq(&out->lock);
+       mutex_lock(&out->enabled_lock);
        old_enabled = out->composer_enabled;
        out->composer_enabled = enabled;
-       spin_unlock_irq(&out->lock);
+
+       /* the composition wasn't enabled, so unlock the lock to make sure the lock
+        * will be balanced even if we have a failed commit
+        */
+       if (!out->composer_enabled)
+               mutex_unlock(&out->enabled_lock);
 
        if (old_enabled)
                drm_crtc_vblank_put(&out->crtc);