drm: Try to acquire modeset lock on panic or sysrq
Subsystems (2)
PATCH 1/1 drm: Try to acquire modeset lock on panic or sysrq
From: Thierry Reding <[email protected]>
Commit 62ff94a54921 "drm/crtc-helper: remove LOCKING from kerneldoc" causes drm_helper_crtc_in_use() and drm_helper_encoder_in_use() to complain loudly during a kernel panic or sysrq processing. This is caused by nobody acquiring the modeset lock in these code paths.
This patch fixes this by trying to acquire the modeset lock for each FB helper that's forced to kernel mode. If the lock can't be acquired, it's likely that somebody else is performing a modeset. However, doing another modeset concurrently might make things even worse, so the safe option is to simply bail out in that case.
--- drivers/gpu/drm/drm_fb_helper.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_fb_helper.c +10 -1
@@ -325,12 +325,21 @@ static bool drm_fb_helper_force_kernel_mode(void)return false;list_for_each_entry (helper, &kernel_fb_helper_list, kernel_fb_list) { -if (helper->dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +struct drm_device *dev = helper->dev; + +if (dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +continue ; + +if (!mutex_trylock (&dev->mode_config.mutex)) { + error = true;continue ; + } ret =drm_fb_helper_restore_fbdev_mode (helper);if (ret) error = true; + +mutex_unlock (&dev->mode_config.mutex); }return error; }
Signature · 1 line
1.9.1
Quoted 7 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Commit
62ff94a54921"drm/crtc-helper: remove LOCKING from kerneldoc" causesdrm_helper_crtc_in_use()anddrm_helper_encoder_in_use()to complain loudly during a kernel panic or sysrq processing. This is caused by nobody acquiring the modeset lock in these code paths.
Quoted 7 lines
This patch fixes this by trying to acquire the modeset lock for each FB helper that's forced to kernel mode. If the lock can't be acquired, it's likely that somebody else is performing a modeset. However, doing another modeset concurrently might make things even worse, so the safe option is to simply bail out in that case.
Signed-off-by Thierry Reding <[email protected]>
I guess we should also try to grab the crtc locks, but blocking ongoing pageflips shouldn't be too harmful. Otherwise I think this should help a bit in some of the hilarious failures I've seen when kms itself blows up. -Daniel
Quoted 34 lines
--- drivers/gpu/drm/drm_fb_helper.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_fb_helper.c +10
-1@@ -325,12 +325,21 @@ static bool drm_fb_helper_force_kernel_mode(void)return false;list_for_each_entry (helper, &kernel_fb_helper_list, kernel_fb_list) { -if (helper->dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +struct drm_device *dev = helper->dev; + +if (dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +continue ; + +if (!mutex_trylock (&dev->mode_config.mutex)) { + error = true;continue ; + } ret =drm_fb_helper_restore_fbdev_mode (helper);if (ret) error = true; + +mutex_unlock (&dev->mode_config.mutex); }return error; }Signature · 1 line
1.9.1
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Hi
Quoted 24 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Commit
62ff94a54921"drm/crtc-helper: remove LOCKING from kerneldoc" causesdrm_helper_crtc_in_use()anddrm_helper_encoder_in_use()to complain loudly during a kernel panic or sysrq processing. This is caused by nobody acquiring the modeset lock in these code paths.This patch fixes this by trying to acquire the modeset lock for each FB helper that's forced to kernel mode. If the lock can't be acquired, it's likely that somebody else is performing a modeset. However, doing another modeset concurrently might make things even worse, so the safe option is to simply bail out in that case.
Signed-off-by Thierry Reding <[email protected]>--- drivers/gpu/drm/drm_fb_helper.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_fb_helper.c +0
-0@@ -325,12 +325,21 @@ static bool drm_fb_helper_force_kernel_mode(void)return false;
drivers/gpu/drm/drm_fb_helper.c static bool drm_fb_helper_force_kernel_mode(void) · line 334
Quoted 10 lines
drivers/gpu/drm/drm_fb_helper.c +7
-1list_for_each_entry (helper, &kernel_fb_helper_list, kernel_fb_list) { -if (helper->dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +struct drm_device *dev = helper->dev; + +if (dev->switch_power_state ==DRM_SWITCH_POWER_OFF ) +continue ; + +if (!mutex_trylock (&dev->mode_config.mutex)) { + error = true;
Thanks
David
Quoted 14 lines
drivers/gpu/drm/drm_fb_helper.c +3
-1continue ; + } ret =drm_fb_helper_restore_fbdev_mode (helper);if (ret) error = true; + +mutex_unlock (&dev->mode_config.mutex); }return error; } --1.9.1