If a sysrq is processed on the while holding the usb hcd lock, it is impossible to drain the queue of urbs via the polling interface and all the printk output is lost. Using a tasklet to schedule the sysrq allows the hcd device lock to free up. Signed-off-by: Jason Wessel <jason.wessel@xxxxxxxxxxxxx> --- drivers/usb/serial/generic.c | 33 ++++++++++++++++++++++++++++++++- 1 files changed, 32 insertions(+), 1 deletions(-) diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index df56ed3..7554d71 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -527,11 +527,42 @@ void usb_serial_generic_unthrottle(struct tty_struct *tty) } } +#ifdef CONFIG_MAGIC_SYSRQ +/* The sysrq tasklet is used to make the sysrq request not occur with + * the hcd device lock held. + */ +static struct usb_sysrq_data { + struct tty_struct *tty; + unsigned int ch; + int pending; +} priv_usb_sysrq; + +static void usb_sysrq_task(unsigned long args) +{ + handle_sysrq(priv_usb_sysrq.ch, priv_usb_sysrq.tty); + priv_usb_sysrq.pending = 0; +} +static DECLARE_TASKLET(usb_sysrq_tasklet, usb_sysrq_task, 0); + +void usb_serial_generic_sysrq_invoke(struct usb_serial_port *port, + unsigned int ch) +{ + if (priv_usb_sysrq.pending) + return; + priv_usb_sysrq.pending = 1; + priv_usb_sysrq.ch = ch; + priv_usb_sysrq.tty = tty_port_tty_get(&port->port); + tasklet_schedule(&usb_sysrq_tasklet); +} +#else +static void usb_serial_generic_sysrq_invoke() {} +#endif /* CONFIG_SYSRQ */ + int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) { if (port->sysrq) { if (ch && time_before(jiffies, port->sysrq)) { - handle_sysrq(ch, tty_port_tty_get(&port->port)); + usb_serial_generic_sysrq_invoke(port, ch); port->sysrq = 0; return 1; } -- 1.6.3.9.g6345d -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html