Commit c3c296b0 authored by Daniel Vetter's avatar Daniel Vetter Committed by Tomi Valkeinen

fbdev: Debug knob to register without holding console_lock

When the usual fbcon legacy options are enabled we have
->register_framebuffer
  ->fb notifier chain calls into fbcon
    ->fbcon sets up console on new fbi
      ->fbi->set_par
        ->drm_fb_helper_set_par exercises full kms api

And because of locking inversion hilarity all of register_framebuffer
is done with the console lock held. Which means that the first time on
driver load we exercise _all_ the kms code (all probe paths and
modeset paths for everything connected) is under the console lock.
That means if anything goes belly-up in that big pile of code nothing
ever reaches logfiles (and the machine is dead).

Usual tactic to debug that is to temporarily remove those console_lock
calls to be able to capture backtraces. I'm fed up writing this patch
and recompiling kernels. Hence this patch here to add an unsafe,
kernel-taining option to do this at runtime.

Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: linux-fbdev@vger.kernel.org
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent 1c639bae
...@@ -1608,6 +1608,11 @@ static int do_remove_conflicting_framebuffers(struct apertures_struct *a, ...@@ -1608,6 +1608,11 @@ static int do_remove_conflicting_framebuffers(struct apertures_struct *a,
return 0; return 0;
} }
static bool lockless_register_fb;
module_param_named_unsafe(lockless_register_fb, lockless_register_fb, bool, 0400);
MODULE_PARM_DESC(lockless_register_fb,
"Lockless framebuffer registration for debugging [default=off]");
static int do_register_framebuffer(struct fb_info *fb_info) static int do_register_framebuffer(struct fb_info *fb_info)
{ {
int i, ret; int i, ret;
...@@ -1675,15 +1680,18 @@ static int do_register_framebuffer(struct fb_info *fb_info) ...@@ -1675,15 +1680,18 @@ static int do_register_framebuffer(struct fb_info *fb_info)
registered_fb[i] = fb_info; registered_fb[i] = fb_info;
event.info = fb_info; event.info = fb_info;
console_lock(); if (!lockless_register_fb)
console_lock();
if (!lock_fb_info(fb_info)) { if (!lock_fb_info(fb_info)) {
console_unlock(); if (!lockless_register_fb)
console_unlock();
return -ENODEV; return -ENODEV;
} }
fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, &event); fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, &event);
unlock_fb_info(fb_info); unlock_fb_info(fb_info);
console_unlock(); if (!lockless_register_fb)
console_unlock();
return 0; return 0;
} }
......
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