From: Alexander Holler <holler@ahsoftware.de> To: Andrew Morton <akpm@linux-foundation.org> Cc: linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, Florian Tobias Schandinat <FlorianSchandinat@gmx.de>, Bernie Thompson <bernie@plugable.com>, Steve Glendinning <steve.glendinning@shawell.net>, stable@vger.kernel.org Subject: Re: [PATCH 2/3 v2] fb: udlfb: fix hang at disconnect Date: Tue, 29 Jan 2013 21:35:42 +0100 [thread overview] Message-ID: <5108329E.2050802@ahsoftware.de> (raw) In-Reply-To: <5107F014.4030704@ahsoftware.de> Am 29.01.2013 16:51, schrieb Alexander Holler: > Am 29.01.2013 12:11, schrieb Alexander Holler: > >> >> To explain the problem on shutdown a bit further, I think the following >> happens (usb and driver are statically linked and started by the kernel): >> >> shutdown -> kill signal -> usb stack shuts down -> udlfb waits (forever) >> for a kill or an urb which it doesn't get. > > Having a second look at what I've written above, I'm not even sure if > the kernel sends one or more fatal signals on shutdown at all. I've just > assumed it because otherwise down_interruptible() wouldn't have worked > before (it would have stalled on shutdown too (if an urb got missed), > not only on disconnect). > > Sounds like an interesting question I should read about (if/when fatal > signals are issued by the kernel). ;) > >> Maybe the sequence is different if the usb-stack and udlfb are used as a >> module and/or udlfb is used only for X/fb. I'm not sure what actually >> does shut down the usb-stack in such a case, but maybe more than one >> kill signal might be thrown around. If anyone still follows my monologue: The question was interesting enough that I couldn't resist for long. ;) (all pasted => format broken) In drivers/tty/sysrq.c there is ------ static void send_sig_all(int sig) { struct task_struct *p; read_lock(&tasklist_lock); for_each_process(p) { if (p->flags & PF_KTHREAD) continue; if (is_global_init(p)) continue; do_send_sig_info(sig, SEND_SIG_FORCED, p, true); } read_unlock(&tasklist_lock); } static void sysrq_handle_term(int key) { send_sig_all(SIGTERM); console_loglevel = 8; } (...) static void sysrq_handle_kill(int key) { send_sig_all(SIGKILL); console_loglevel = 8; } ------ Now I've done some learning by doing (kernel 3.7.5 + some patches): ------ diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c index df249f3..db8a86c 100644 --- a/drivers/video/udlfb.c +++ b/drivers/video/udlfb.c @@ -1876,14 +1876,18 @@ static void dlfb_free_urb_list(struct dlfb_data *dev) unsigned long flags; pr_notice("Freeing all render urbs\n"); + if (current->flags & PF_KTHREAD) + pr_info("AHO: I'm a kernel thread\n"); /* keep waiting and freeing, until we've got 'em all */ while (count--) { /* Timeout likely occurs at disconnect (resulting in a leak) */ ret = down_timeout_killable(&dev->urbs.limit_sem, FREE_URB_TIMEOUT); - if (ret) + if (ret) { + pr_info("AHO: ret %d\n", ret); break; + } spin_lock_irqsave(&dev->urbs.lock, flags); ------ Now I've disconnected the display. And, as send_sig_all() already suggests, the result was (besides discovering an oops in call_timer_fn.isra (once)): ------ [ 120.963010] udlfb: AHO: I'm a kernel thread [ 122.957024] udlfb: AHO: ret -62 ------ (-62 is -ETIME) So, if the above down_timeout_killable() is only down_interruptible(), as in kernel 3.7.5, the box would not shutdown afterwards, because on shutdown no signal would be send to that kernel-thread which called dlfb_free_urb_list(). A last note: dlfb_usb_disconnect() (thus dlfb_free_urb_list()) isn't called on shutdown if the device would still be connected. So the problem only might happen, if the screen will be disconnected before shutdown (and an urb gets missed). So the subject of my patch is correct. ;) </monologue> Regards, Alexander
WARNING: multiple messages have this Message-ID (diff)
From: Alexander Holler <holler@ahsoftware.de> To: Andrew Morton <akpm@linux-foundation.org> Cc: linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, Florian Tobias Schandinat <FlorianSchandinat@gmx.de>, Bernie Thompson <bernie@plugable.com>, Steve Glendinning <steve.glendinning@shawell.net>, stable@vger.kernel.org Subject: Re: [PATCH 2/3 v2] fb: udlfb: fix hang at disconnect Date: Tue, 29 Jan 2013 20:35:42 +0000 [thread overview] Message-ID: <5108329E.2050802@ahsoftware.de> (raw) In-Reply-To: <5107F014.4030704@ahsoftware.de> Am 29.01.2013 16:51, schrieb Alexander Holler: > Am 29.01.2013 12:11, schrieb Alexander Holler: > >> >> To explain the problem on shutdown a bit further, I think the following >> happens (usb and driver are statically linked and started by the kernel): >> >> shutdown -> kill signal -> usb stack shuts down -> udlfb waits (forever) >> for a kill or an urb which it doesn't get. > > Having a second look at what I've written above, I'm not even sure if > the kernel sends one or more fatal signals on shutdown at all. I've just > assumed it because otherwise down_interruptible() wouldn't have worked > before (it would have stalled on shutdown too (if an urb got missed), > not only on disconnect). > > Sounds like an interesting question I should read about (if/when fatal > signals are issued by the kernel). ;) > >> Maybe the sequence is different if the usb-stack and udlfb are used as a >> module and/or udlfb is used only for X/fb. I'm not sure what actually >> does shut down the usb-stack in such a case, but maybe more than one >> kill signal might be thrown around. If anyone still follows my monologue: The question was interesting enough that I couldn't resist for long. ;) (all pasted => format broken) In drivers/tty/sysrq.c there is ------ static void send_sig_all(int sig) { struct task_struct *p; read_lock(&tasklist_lock); for_each_process(p) { if (p->flags & PF_KTHREAD) continue; if (is_global_init(p)) continue; do_send_sig_info(sig, SEND_SIG_FORCED, p, true); } read_unlock(&tasklist_lock); } static void sysrq_handle_term(int key) { send_sig_all(SIGTERM); console_loglevel = 8; } (...) static void sysrq_handle_kill(int key) { send_sig_all(SIGKILL); console_loglevel = 8; } ------ Now I've done some learning by doing (kernel 3.7.5 + some patches): ------ diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c index df249f3..db8a86c 100644 --- a/drivers/video/udlfb.c +++ b/drivers/video/udlfb.c @@ -1876,14 +1876,18 @@ static void dlfb_free_urb_list(struct dlfb_data *dev) unsigned long flags; pr_notice("Freeing all render urbs\n"); + if (current->flags & PF_KTHREAD) + pr_info("AHO: I'm a kernel thread\n"); /* keep waiting and freeing, until we've got 'em all */ while (count--) { /* Timeout likely occurs at disconnect (resulting in a leak) */ ret = down_timeout_killable(&dev->urbs.limit_sem, FREE_URB_TIMEOUT); - if (ret) + if (ret) { + pr_info("AHO: ret %d\n", ret); break; + } spin_lock_irqsave(&dev->urbs.lock, flags); ------ Now I've disconnected the display. And, as send_sig_all() already suggests, the result was (besides discovering an oops in call_timer_fn.isra (once)): ------ [ 120.963010] udlfb: AHO: I'm a kernel thread [ 122.957024] udlfb: AHO: ret -62 ------ (-62 is -ETIME) So, if the above down_timeout_killable() is only down_interruptible(), as in kernel 3.7.5, the box would not shutdown afterwards, because on shutdown no signal would be send to that kernel-thread which called dlfb_free_urb_list(). A last note: dlfb_usb_disconnect() (thus dlfb_free_urb_list()) isn't called on shutdown if the device would still be connected. So the problem only might happen, if the screen will be disconnected before shutdown (and an urb gets missed). So the subject of my patch is correct. ;) </monologue> Regards, Alexander
next prev parent reply other threads:[~2013-01-29 20:36 UTC|newest] Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-01-12 13:20 [PATCH] fb: udlfb: fix hang at disconnect Alexander Holler 2013-01-12 13:20 ` Alexander Holler 2013-01-12 22:22 ` Bernie Thompson 2013-01-12 22:22 ` Bernie Thompson 2013-01-13 12:05 ` Alexander Holler 2013-01-13 12:05 ` Alexander Holler 2013-01-13 12:24 ` Alexander Holler 2013-01-13 12:24 ` Alexander Holler 2013-01-25 18:49 ` [PATCH 1/3] semaphore: introduce down_timeout_killable() Alexander Holler 2013-01-25 18:49 ` Alexander Holler 2013-01-25 18:49 ` [PATCH 2/3 v2] fb: udlfb: fix hang at disconnect Alexander Holler 2013-01-25 18:49 ` Alexander Holler 2013-01-29 0:22 ` Andrew Morton 2013-01-29 0:22 ` Andrew Morton 2013-01-29 0:56 ` Alexander Holler 2013-01-29 0:56 ` Alexander Holler 2013-01-29 10:35 ` Alexander Holler 2013-01-29 10:35 ` Alexander Holler 2013-01-29 11:11 ` Alexander Holler 2013-01-29 11:11 ` Alexander Holler 2013-01-29 15:51 ` Alexander Holler 2013-01-29 15:51 ` Alexander Holler 2013-01-29 20:35 ` Alexander Holler [this message] 2013-01-29 20:35 ` Alexander Holler 2013-01-29 20:56 ` Alexander Holler 2013-01-29 20:56 ` Alexander Holler 2013-02-04 1:14 ` Greg KH 2013-02-04 1:14 ` Greg KH 2013-02-04 12:05 ` Alexander Holler 2013-02-04 12:05 ` Alexander Holler 2013-02-04 19:17 ` Alexander Holler 2013-02-04 19:17 ` Alexander Holler 2013-02-04 19:25 ` Greg KH 2013-02-04 19:25 ` Greg KH 2013-02-05 7:08 ` Alexander Holler 2013-02-05 7:08 ` Alexander Holler 2013-02-05 17:22 ` Greg KH 2013-02-05 17:22 ` Greg KH 2013-02-05 17:36 ` Alexander Holler 2013-02-05 17:36 ` Alexander Holler 2013-02-08 4:07 ` Dave Airlie 2013-02-08 4:07 ` Dave Airlie 2013-02-08 9:53 ` Alexander Holler 2013-02-08 9:53 ` Alexander Holler 2013-01-25 18:49 ` [PATCH 3/3] fb: smscufx: " Alexander Holler 2013-01-25 18:49 ` Alexander Holler
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=5108329E.2050802@ahsoftware.de \ --to=holler@ahsoftware.de \ --cc=FlorianSchandinat@gmx.de \ --cc=akpm@linux-foundation.org \ --cc=bernie@plugable.com \ --cc=linux-fbdev@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=stable@vger.kernel.org \ --cc=steve.glendinning@shawell.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.