drm/fb-helper: Don't schedule_work() to flush frame buffer during panic()
authorjsg <jsg@openbsd.org>
Mon, 9 Sep 2024 08:18:38 +0000 (08:18 +0000)
committerjsg <jsg@openbsd.org>
Mon, 9 Sep 2024 08:18:38 +0000 (08:18 +0000)
From Qiuxu Zhuo
d5618eaea8868e2534c375b8a512693658068cf8 in linux-6.6.y/6.6.50
833cd3e9ad8360785b6c23c82dd3856df00732d9 in mainline linux

sys/dev/pci/drm/drm_fb_helper.c

index 1a0be9c..18a9d1d 100644 (file)
@@ -647,6 +647,17 @@ static void drm_fb_helper_add_damage_clip(struct drm_fb_helper *helper, u32 x, u
 static void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y,
                                 u32 width, u32 height)
 {
+       /*
+        * This function may be invoked by panic() to flush the frame
+        * buffer, where all CPUs except the panic CPU are stopped.
+        * During the following schedule_work(), the panic CPU needs
+        * the worker_pool lock, which might be held by a stopped CPU,
+        * causing schedule_work() and panic() to block. Return early on
+        * oops_in_progress to prevent this blocking.
+        */
+       if (oops_in_progress)
+               return;
+
        drm_fb_helper_add_damage_clip(helper, x, y, width, height);
 
        schedule_work(&helper->damage_work);