Commit a76fa354 authored by Daniel Vetter's avatar Daniel Vetter

drm/fb-helper: Add locking to sysrq handling

We didn't take the kernel_fb_helper_lock mutex, which protects that
code. While at it, simplify the code
- inline the function (originally shared with kgdb I think)
- drop the error tracking and all the complications
- drop the pointless early out, it served nothing
Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20201007133036.1541639-1-daniel.vetter@ffwll.ch
parent 5a388432
...@@ -281,18 +281,12 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper) ...@@ -281,18 +281,12 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)
EXPORT_SYMBOL(drm_fb_helper_restore_fbdev_mode_unlocked); EXPORT_SYMBOL(drm_fb_helper_restore_fbdev_mode_unlocked);
#ifdef CONFIG_MAGIC_SYSRQ #ifdef CONFIG_MAGIC_SYSRQ
/* /* emergency restore, don't bother with error reporting */
* restore fbcon display for all kms driver's using this helper, used for sysrq static void drm_fb_helper_restore_work_fn(struct work_struct *ignored)
* and panic handling.
*/
static bool drm_fb_helper_force_kernel_mode(void)
{ {
bool ret, error = false;
struct drm_fb_helper *helper; struct drm_fb_helper *helper;
if (list_empty(&kernel_fb_helper_list)) mutex_lock(&kernel_fb_helper_lock);
return false;
list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) { list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) {
struct drm_device *dev = helper->dev; struct drm_device *dev = helper->dev;
...@@ -300,22 +294,12 @@ static bool drm_fb_helper_force_kernel_mode(void) ...@@ -300,22 +294,12 @@ static bool drm_fb_helper_force_kernel_mode(void)
continue; continue;
mutex_lock(&helper->lock); mutex_lock(&helper->lock);
ret = drm_client_modeset_commit_locked(&helper->client); drm_client_modeset_commit_locked(&helper->client);
if (ret)
error = true;
mutex_unlock(&helper->lock); mutex_unlock(&helper->lock);
} }
return error; mutex_unlock(&kernel_fb_helper_lock);
} }
static void drm_fb_helper_restore_work_fn(struct work_struct *ignored)
{
bool ret;
ret = drm_fb_helper_force_kernel_mode();
if (ret == true)
DRM_ERROR("Failed to restore crtc configuration\n");
}
static DECLARE_WORK(drm_fb_helper_restore_work, drm_fb_helper_restore_work_fn); static DECLARE_WORK(drm_fb_helper_restore_work, drm_fb_helper_restore_work_fn);
static void drm_fb_helper_sysrq(int dummy1) static void drm_fb_helper_sysrq(int dummy1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment