tty_port,usb-console: Fix usb serial console open/close regression
Subsystems (4)
PATCH 1/2 tty_port,usb-console: Fix usb serial console open/close regression
Commit e1108a63e10d344284011cccc06328b2cd3e5da3 ("usb_serial: Use the shutdown() operation") breaks the ability to use a usb console starting in 2.6.33. This was observed when using console=ttyUSB0,115200 as a boot argument with an FTDI device. The error is:
ftdi_sio ttyUSB0: ftdi_submit_read_urb - failed submitting read urb, error -22
The handling of the ASYNCB_INITIALIZED changed in 2.6.32 such that in tty_port_shutdown() it always clears the flag if it is set. The fix is to add a variable to the tty_port struct to indicate when the tty port is a console.
--- drivers/char/tty_port.c | 2 +- drivers/usb/serial/console.c | 1 + include/linux/tty.h | 1 + 3 files changed, 3 insertions(+), 1 deletions(-)
drivers/char/tty_port.c +1 -1
@@ -119,7 +119,7 @@ EXPORT_SYMBOL(tty_port_tty_set);static void tty_port_shutdown (struct tty_port *port) {mutex_lock (&port->mutex); -if (port->ops->shutdown && +if (port->ops->shutdown && !port->console &&test_and_clear_bit (ASYNCB_INITIALIZED , &port->flags)) port->ops->shutdown (port);mutex_unlock (&port->mutex);
drivers/usb/serial/console.c +1 -0
@@ -181,6 +181,7 @@ static int usb_console_setup(struct console *co, char *options)/* The console is special in terms of closing the device so * indicate this port is now acting as a system console. */ port->console =1 ; + port->port.console =1 ;mutex_unlock (&serial->disc_mutex);return retval;
include/linux/tty.h +1 -0
@@ -223,6 +223,7 @@ struct tty_port {wait_queue_head_t close_wait;/* Close waiters */ wait_queue_head_t delta_msr_wait;/* Modem status change */ unsigned long flags;/* TTY flags ASY_*/ + unsigned char console:1; /* port is a console */struct mutex mutex;/* Locking */ struct mutex buf_mutex;/* Buffer alloc lock */ unsigned char *xmit_buf;/* Optional buffer */
Signature · 1 line
1.5.4.3
PATCH 2/2 usb-serial: Use tty_port version console instead of usb_serial_port
Replace all instances of using the console variable in struct usb_serial_port with the struct tty_port version.
--- drivers/usb/serial/console.c | 5 ++--- drivers/usb/serial/ftdi_sio.c | 2 +- drivers/usb/serial/generic.c | 4 ++-- drivers/usb/serial/pl2303.c | 2 +- drivers/usb/serial/usb-serial.c | 2 +- include/linux/usb/serial.h | 2 -- 6 files changed, 7 insertions(+), 10 deletions(-)
drivers/usb/serial/console.c +2 -3
@@ -180,7 +180,6 @@ static int usb_console_setup(struct console *co, char *options) --port->port.count;/* The console is special in terms of closing the device so * indicate this port is now acting as a system console. */ - port->console =1 ; port->port.console =1 ;mutex_unlock (&serial->disc_mutex);
@@ -217,7 +216,7 @@ static void usb_console_write(struct console *co,dbg ("%s - port %d, %d byte(s)" , __func__, port->number, count); -if (!port->console) { +if (!port->port.console) {dbg ("%s - port not opened" , __func__);return ; }
@@ -313,7 +312,7 @@ void usb_serial_console_exit(void) {if (usbcons_info.port) {unregister_console (&usbcons); - usbcons_info.port->console =0 ; + usbcons_info.port->port.console =0 ; usbcons_info.port =NULL ; } }
drivers/usb/serial/ftdi_sio.c +1 -1
@@ -2073,7 +2073,7 @@ static int ftdi_process_packet(struct tty_struct *tty,return 0 ;/* status only */ ch = packet +2 ; -if (!(port->console && port->sysrq) && flag ==TTY_NORMAL ) +if (!(port->port.console && port->sysrq) && flag ==TTY_NORMAL )tty_insert_flip_string (tty, ch, len);else {for (i =0 ; i < len; i++, ch++) {
drivers/usb/serial/generic.c +2 -2
@@ -437,7 +437,7 @@ static void flush_and_resubmit_read_urb(struct usb_serial_port *port)/* The per character mucking around with sysrq path it too slow for stuff like 3G modems, so shortcircuit it in the 99.9999999% of cases where the USB serial is not a console anyway */ -if (!port->console || !port->sysrq) +if (!port->port.console || !port->sysrq)tty_insert_flip_string (tty, ch, urb->actual_length);else {/* Push data to tty */
@@ -556,7 +556,7 @@ void usb_serial_generic_unthrottle(struct tty_struct *tty)int usb_serial_handle_sysrq_char (struct tty_struct *tty,struct usb_serial_port *port,unsigned int ch) { -if (port->sysrq && port->console) { +if (port->sysrq && port->port.console) {if (ch &&time_before (jiffies, port->sysrq)) {handle_sysrq (ch, tty); port->sysrq =0 ;
drivers/usb/serial/pl2303.c +1 -1
@@ -1056,7 +1056,7 @@ static void pl2303_push_data(struct tty_struct *tty,if (line_status &UART_OVERRUN_ERROR )tty_insert_flip_char (tty,0 ,TTY_OVERRUN ); -if (tty_flag ==TTY_NORMAL && !(port->console && port->sysrq)) +if (tty_flag ==TTY_NORMAL && !(port->port.console && port->sysrq))tty_insert_flip_string (tty, data, urb->actual_length);else {int i;
drivers/usb/serial/usb-serial.c +1 -1
@@ -328,7 +328,7 @@ static void serial_cleanup(struct tty_struct *tty)/* The console is magical. Do not hang up the console hardware * or there will be tears. */ -if (port->console) +if (port->port.console)return ;dbg ("%s - port %d" , __func__, port->number);
include/linux/usb/serial.h +0 -2
@@ -66,7 +66,6 @@ enum port_dev_state {* @work: work queue entry for the line discipline waking up. * @throttled: nonzero if the read urb is inactive to throttle the device * @throttle_req: nonzero if the tty wants to throttle us -* @console: attached usb serial console * @dev: pointer to the serial device * * This structure is used by the usb-serial core and drivers for the specific
@@ -106,7 +105,6 @@ struct usb_serial_port {struct work_struct work;char throttled;char throttle_req; -char console;unsigned long sysrq;/* sysrq timeout */ struct device dev;enum port_dev_state dev_state;
Signature · 1 line
1.5.4.3