tty: take 3 - termios, locking and 8250 bugs
Subsystems (11)
cover tty: take 3 - termios, locking and 8250 bugs
This patch series is the tty backlog third attempt, so hopefully it's now all behaving. This is versus the -next tree of Friday and has been doing 24hrs of testing.
It starts with a revert of the tty lock localise that was applied already before its dependancies. Without the dependancies it causes random obscure memory scribbles so we really want it out before we do the other bits so that we can bisect this !
The final patch then puts it back again.
Sorry for the mess up on the previous attempt. I love major structure and API changes 8)
Alan
---
Alan Cox (12):
tty: localise the lock
tty: Move the handling of the tty release logic
vt: fix the keyboard/led locking
tty: tidy up the RESET_TERMIOS case
8250: add support for ASIX devices with a FIFO bug 8250: propogate the bugs field
8250: use the 8250 register interface not the legacy one usb, kobil: Sort out some bogus tty handling
usb: fix sillies in the metro USB driver
f81232: correct stubbed termios handler
tty: move the termios object into the tty
tty: revert incorrectly applied lock patch
arch/ia64/hp/sim/simserial.c | 2 - arch/mips/cavium-octeon/serial.c | 30 ++++---- drivers/bluetooth/hci_ath.c | 2 - drivers/char/mwave/mwavedd.c | 16 ++-- drivers/isdn/gigaset/interface.c | 4 + drivers/isdn/i4l/isdn_tty.c | 16 ++-- drivers/misc/ibmasm/uart.c | 16 ++-- drivers/mmc/card/sdio_uart.c | 20 +++-- drivers/net/ethernet/sgi/ioc3-eth.c | 22 +++--- drivers/net/irda/irtty-sir.c | 10 +-- drivers/net/usb/hso.c | 12 +-- drivers/tty/amiserial.c | 20 +++-- drivers/tty/cyclades.c | 19 ++--- drivers/tty/hvc/hvsi_lib.c | 2 - drivers/tty/isicom.c | 8 +- drivers/tty/moxa.c | 10 +-- drivers/tty/mxser.c | 20 +++-- drivers/tty/n_gsm.c | 8 +- drivers/tty/n_tty.c | 2 - drivers/tty/pty.c | 35 ++------- drivers/tty/rocket.c | 18 ++--- drivers/tty/serial/8250/8250.c | 80 ++++++++------------- drivers/tty/serial/8250/8250.h | 31 -------- drivers/tty/serial/8250/8250_acorn.c | 22 +++--- drivers/tty/serial/8250/8250_dw.c | 38 +++++----- drivers/tty/serial/8250/8250_gsc.c | 26 +++---- drivers/tty/serial/8250/8250_hp300.c | 26 +++---- drivers/tty/serial/8250/8250_pci.c | 116 ++++++++++++++++++------------- drivers/tty/serial/8250/8250_pnp.c | 28 ++++--- drivers/tty/serial/8250/serial_cs.c | 30 ++++---- drivers/tty/serial/bfin_uart.c | 2 - drivers/tty/serial/crisv10.c | 26 +++---- drivers/tty/serial/ioc4_serial.c | 2 - drivers/tty/serial/jsm/jsm_tty.c | 8 +- drivers/tty/serial/of_serial.c | 9 ++ drivers/tty/serial/samsung.c | 2 - drivers/tty/serial/serial_core.c | 28 ++++--- drivers/tty/synclink.c | 36 +++++----- drivers/tty/synclink_gt.c | 24 +++--- drivers/tty/synclinkmp.c | 24 +++--- drivers/tty/tty_io.c | 77 ++++++++------------ drivers/tty/tty_ioctl.c | 124 +++++++++++++++++---------------- drivers/tty/tty_ldisc.c | 10 +-- drivers/tty/tty_port.c | 6 +- drivers/tty/vt/keyboard.c | 41 ++++++----- drivers/tty/vt/vt.c | 5 + drivers/usb/class/cdc-acm.c | 2 - drivers/usb/serial/ark3116.c | 4 + drivers/usb/serial/belkin_sa.c | 2 - drivers/usb/serial/cp210x.c | 8 +- drivers/usb/serial/cypress_m8.c | 40 +++++------ drivers/usb/serial/digi_acceleport.c | 14 ++-- drivers/usb/serial/empeg.c | 2 - drivers/usb/serial/f81232.c | 3 + drivers/usb/serial/ftdi_sio.c | 2 - drivers/usb/serial/io_edgeport.c | 12 ++- drivers/usb/serial/io_ti.c | 12 ++- drivers/usb/serial/ir-usb.c | 2 - drivers/usb/serial/iuu_phoenix.c | 28 ++++--- drivers/usb/serial/keyspan.c | 6 +- drivers/usb/serial/keyspan_pda.c | 4 + drivers/usb/serial/kl5kusb105.c | 18 ++--- drivers/usb/serial/kobil_sct.c | 14 ++-- drivers/usb/serial/mct_u232.c | 4 + drivers/usb/serial/metro-usb.c | 8 -- drivers/usb/serial/mos7720.c | 14 ++-- drivers/usb/serial/mos7840.c | 12 ++- drivers/usb/serial/oti6858.c | 10 +-- drivers/usb/serial/pl2303.c | 6 +- drivers/usb/serial/quatech2.c | 4 + drivers/usb/serial/sierra.c | 2 - drivers/usb/serial/spcp8x5.c | 12 ++- drivers/usb/serial/ssu100.c | 4 + drivers/usb/serial/ti_usb_3410_5052.c | 10 +-- drivers/usb/serial/usb-serial.c | 5 + drivers/usb/serial/usb_wwan.c | 2 - drivers/usb/serial/whiteheat.c | 2 - include/linux/kbd_kern.h | 1 include/linux/serial_8250.h | 33 ++++++++- include/linux/tty.h | 47 ++++++------- include/linux/tty_driver.h | 11 +-- net/bluetooth/rfcomm/tty.c | 2 - net/irda/ircomm/ircomm_tty.c | 12 ++- net/irda/ircomm/ircomm_tty_ioctl.c | 10 +-- 84 files changed, 728 insertions(+), 769 deletions(-)
Signature · 1 line
Signature
PATCH 1/12 tty: revert incorrectly applied lock patch
From: Alan Cox <[email protected]>
I sent GregKH this after the pre-requisites. He dropped the pre-requesites for good reason and unfortunately then applied this patch. Without this reverted you get random kernel memory corruption which will make bisecting anything between it and the properly applied patches a complete sod.
---
drivers/tty/amiserial.c | 14 ++++---- drivers/tty/cyclades.c | 2 + drivers/tty/n_r3964.c | 10 +++--- drivers/tty/pty.c | 25 +++++++-------- drivers/tty/serial/crisv10.c | 8 ++--- drivers/tty/synclink.c | 4 +- drivers/tty/synclink_gt.c | 4 +- drivers/tty/synclinkmp.c | 4 +- drivers/tty/tty_io.c | 67 ++++++++++++++++------------------------ drivers/tty/tty_ldisc.c | 67 +++++++++++++++++----------------------- drivers/tty/tty_mutex.c | 71 +++++++++--------------------------------- drivers/tty/tty_port.c | 6 ++-- include/linux/tty.h | 23 +++++--------- net/bluetooth/rfcomm/tty.c | 4 +- 14 files changed, 119 insertions(+), 190 deletions(-)
drivers/tty/amiserial.c +7 -7
@@ -1033,7 +1033,7 @@ static int get_serial_info(struct tty_struct *tty, struct serial_state *state,if (!retinfo)return -EFAULT ;memset (&tmp,0 ,sizeof (tmp)); -tty_lock (tty); +tty_lock (); tmp.line = tty->index; tmp.port = state->port; tmp.flags = state->tport.flags;
@@ -1042,7 +1042,7 @@ static int get_serial_info(struct tty_struct *tty, struct serial_state *state, tmp.close_delay = state->tport.close_delay; tmp.closing_wait = state->tport.closing_wait; tmp.custom_divisor = state->custom_divisor; -tty_unlock (tty); +tty_unlock ();if (copy_to_user (retinfo,&tmp,sizeof (*retinfo)))return -EFAULT ;return 0 ;
@@ -1059,12 +1059,12 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,if (copy_from_user (&new_serial,new_info,sizeof (new_serial)))return -EFAULT ; -tty_lock (tty); +tty_lock (); change_spd = ((new_serial.flags ^ port->flags) &ASYNC_SPD_MASK ) || new_serial.custom_divisor != state->custom_divisor;if (new_serial.irq || new_serial.port != state->port || new_serial.xmit_fifo_size != state->xmit_fifo_size) { -tty_unlock (tty); +tty_unlock ();return -EINVAL ; }
@@ -1074,7 +1074,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state, (new_serial.xmit_fifo_size != state->xmit_fifo_size) || ((new_serial.flags & ~ASYNC_USR_MASK) != (port->flags & ~ASYNC_USR_MASK))) { -tty_unlock (tty); +tty_unlock ();return -EPERM ; } port->flags = ((port->flags & ~ASYNC_USR_MASK) |
@@ -1084,7 +1084,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state, }if (new_serial.baud_base <9600 ) { -tty_unlock (tty); +tty_unlock ();return -EINVAL ; }
@@ -1116,7 +1116,7 @@ check_and_exit: } }else retval =startup (tty, state); -tty_unlock (tty); +tty_unlock ();return retval; }
drivers/tty/cyclades.c +1 -1
@@ -1599,7 +1599,7 @@ static int cy_open(struct tty_struct *tty, struct file *filp)* If the port is the middle of closing, bail out now */ if (tty_hung_up_p (filp) || (info->port.flags &ASYNC_CLOSING )) { -wait_event_interruptible_tty (tty, info->port.close_wait, +wait_event_interruptible_tty (info->port.close_wait, !(info->port.flags &ASYNC_CLOSING ));return (info->port.flags &ASYNC_HUP_NOTIFY ) ? -EAGAIN : -ERESTARTSYS ; }
drivers/tty/n_r3964.c +5 -5
@@ -1065,7 +1065,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,TRACE_L ("read()" ); -tty_lock (tty); +tty_lock (); pClient =findClient (pInfo,task_pid (current));if (pClient) {
@@ -1077,7 +1077,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file, goto unlock; }/* block until there is a message: */ -wait_event_interruptible_tty (tty, pInfo->read_wait, +wait_event_interruptible_tty (pInfo->read_wait, (pMsg =remove_msg (pInfo, pClient))); }
@@ -1107,7 +1107,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file, } ret = -EPERM ; unlock: -tty_unlock (tty); +tty_unlock ();return ret; }
@@ -1156,7 +1156,7 @@ static ssize_t r3964_write(struct tty_struct *tty, struct file *file, pHeader->locks =0 ; pHeader->owner =NULL ; -tty_lock (tty); +tty_lock (); pClient =findClient (pInfo,task_pid (current));if (pClient) {
@@ -1175,7 +1175,7 @@ static ssize_t r3964_write(struct tty_struct *tty, struct file *file,add_tx_queue (pInfo, pHeader);trigger_transmit (pInfo); -tty_unlock (tty); +tty_unlock ();return 0 ; }
drivers/tty/pty.c +11 -14
@@ -47,7 +47,6 @@ static void pty_close(struct tty_struct *tty, struct file *filp)wake_up_interruptible (&tty->read_wait);wake_up_interruptible (&tty->write_wait); tty->packet =0 ; -/* Review - krefs on tty_link ?? */ if (!tty->link)return ; tty->link->packet =0 ;
@@ -63,9 +62,9 @@ static void pty_close(struct tty_struct *tty, struct file *filp) mutex_unlock(&devpts_mutex); }#endif -tty_unlock (tty); +tty_unlock ();tty_vhangup (tty->link); -tty_lock (tty); +tty_lock (); } }
@@ -616,27 +615,26 @@ static int ptmx_open(struct inode *inode, struct file *filp)return retval;/* find a device that is not in use. */ -mutex_lock (&devpts_mutex); +tty_lock (); index =devpts_new_index (inode); +tty_unlock ();if (index <0 ) { retval = index; goto err_file; } -mutex_unlock (&devpts_mutex); -mutex_lock (&tty_mutex); +mutex_lock (&devpts_mutex); tty =tty_init_dev (ptm_driver, index); +mutex_unlock (&devpts_mutex); +tty_lock (); +mutex_unlock (&tty_mutex);if (IS_ERR (tty)) { retval =PTR_ERR (tty); goto out; } -/* The tty returned here is locked so we can safely -drop the mutex */ -mutex_unlock (&tty_mutex); -set_bit (TTY_PTY_LOCK , &tty->flags);/* LOCK THE SLAVE */ tty_add_file (tty, filp);
@@ -649,17 +647,16 @@ static int ptmx_open(struct inode *inode, struct file *filp)if (retval) goto err_release; -tty_unlock (tty); +tty_unlock ();return 0 ; err_release: -tty_unlock (tty); +tty_unlock ();tty_release (inode, filp);return retval; out: -mutex_unlock (&tty_mutex);devpts_kill_index (inode, index); +tty_unlock (); err_file: -mutex_unlock (&devpts_mutex);tty_free_file (filp);return retval; }
drivers/tty/serial/crisv10.c +4 -4
@@ -3976,7 +3976,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp,*/ if (tty_hung_up_p (filp) || (info->flags &ASYNC_CLOSING )) { -wait_event_interruptible_tty (tty, info->close_wait, +wait_event_interruptible_tty (info->close_wait, !(info->flags &ASYNC_CLOSING ));#ifdef SERIAL_DO_RESTART if (info->flags &ASYNC_HUP_NOTIFY )
@@ -4052,9 +4052,9 @@ block_til_ready(struct tty_struct *tty, struct file * filp,printk ("block_til_ready blocking: ttyS%d, count = %d\n" , info->line, info->count);#endif -tty_unlock (tty); +tty_unlock ();schedule (); -tty_lock (tty); +tty_lock (); }set_current_state (TASK_RUNNING );remove_wait_queue (&info->open_wait, &wait);
@@ -4115,7 +4115,7 @@ rs_open(struct tty_struct *tty, struct file * filp)*/ if (tty_hung_up_p (filp) || (info->flags &ASYNC_CLOSING )) { -wait_event_interruptible_tty (tty, info->close_wait, +wait_event_interruptible_tty (info->close_wait, !(info->flags &ASYNC_CLOSING ));#ifdef SERIAL_DO_RESTART return ((info->flags & ASYNC_HUP_NOTIFY) ?
drivers/tty/synclink.c +2 -2
@@ -3338,9 +3338,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,printk ("%s(%d):block_til_ready blocking on %s count=%d\n" , __FILE__,__LINE__, tty->driver->name, port->count ); -tty_unlock (tty); +tty_unlock ();schedule (); -tty_lock (tty); +tty_lock (); }set_current_state (TASK_RUNNING );
drivers/tty/synclink_gt.c +2 -2
@@ -3336,9 +3336,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, }DBGINFO (("%s block_til_ready wait\n" , tty->driver->name)); -tty_unlock (tty); +tty_unlock ();schedule (); -tty_lock (tty); +tty_lock (); }set_current_state (TASK_RUNNING );
drivers/tty/synclinkmp.c +2 -2
@@ -3357,9 +3357,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,printk ("%s(%d):%s block_til_ready() count=%d\n" , __FILE__,__LINE__, tty->driver->name, port->count ); -tty_unlock (tty); +tty_unlock ();schedule (); -tty_lock (tty); +tty_lock (); }set_current_state (TASK_RUNNING );
drivers/tty/tty_io.c +27 -40
234 lines not on this page · raw message
drivers/tty/tty_ldisc.c +29 -38
153 lines not on this page · raw message
drivers/tty/tty_mutex.c +15 -56
85 lines not on this page · raw message
drivers/tty/tty_port.c +3 -3
@@ -239,7 +239,7 @@ int tty_port_block_til_ready(struct tty_port *port,/* block if port is in the process of being closed */ if (tty_hung_up_p (filp) || port->flags &ASYNC_CLOSING ) { -wait_event_interruptible_tty (tty, port->close_wait, +wait_event_interruptible_tty (port->close_wait, !(port->flags &ASYNC_CLOSING ));if (port->flags &ASYNC_HUP_NOTIFY )return -EAGAIN ;
@@ -305,9 +305,9 @@ int tty_port_block_til_ready(struct tty_port *port, retval = -ERESTARTSYS ;break ; } -tty_unlock (tty); +tty_unlock ();schedule (); -tty_lock (tty); +tty_lock (); }finish_wait (&port->open_wait, &wait);
include/linux/tty.h +9 -14
@@ -268,7 +268,6 @@ struct tty_struct {struct mutex ldisc_mutex;struct tty_ldisc *ldisc; -struct mutex legacy_mutex;struct mutex termios_mutex;spinlock_t ctrl_lock;/* Termios values are protected by the termios mutex */
@@ -611,12 +610,8 @@ extern long vt_compat_ioctl(struct tty_struct *tty,/* tty_mutex.c */ /* functions for preparation of BKL removal */ -extern void __lockfunc tty_lock(struct tty_struct *tty); -extern void __lockfunc tty_unlock(struct tty_struct *tty); -extern void __lockfunc tty_lock_pair(struct tty_struct *tty, -struct tty_struct *tty2); -extern void __lockfunc tty_unlock_pair(struct tty_struct *tty, -struct tty_struct *tty2); +extern void __lockfunc tty_lock(void) __acquires(tty_lock); +extern void __lockfunc tty_unlock(void) __releases(tty_lock);/* * this shall be called only from where BTM is held (like close)
@@ -631,9 +626,9 @@ extern void __lockfunc tty_unlock_pair(struct tty_struct *tty,static inline void tty_wait_until_sent_from_close (struct tty_struct *tty,long timeout) { -tty_unlock (tty);/* tty->ops->close holds the BTM, drop it while waiting */ +tty_unlock ();/* tty->ops->close holds the BTM, drop it while waiting */ tty_wait_until_sent (tty, timeout); -tty_lock (tty); +tty_lock (); }/*
@@ -648,16 +643,16 @@ static inline void tty_wait_until_sent_from_close(struct tty_struct *tty,* * Do not use in new code. */ -#define wait_event_interruptible_tty (tty, wq, condition) \ +#define wait_event_interruptible_tty (wq, condition) \ ({ \ int __ret = 0; \ if (!(condition)) { \ - __wait_event_interruptible_tty(tty, wq, condition, __ret); \ + __wait_event_interruptible_tty(wq, condition, __ret); \ } \ __ret; \ }) -#define __wait_event_interruptible_tty (tty, wq, condition, ret) \ +#define __wait_event_interruptible_tty (wq, condition, ret) \ do { \ DEFINE_WAIT(__wait); \ \
@@ -666,9 +661,9 @@ do { \if (condition) \break ; \if (!signal_pending (current)) { \ -tty_unlock (tty); \ +tty_unlock (); \schedule (); \ -tty_lock (tty); \ +tty_lock (); \continue ; \ } \ ret = -ERESTARTSYS ; \
net/bluetooth/rfcomm/tty.c +2 -2
@@ -705,9 +705,9 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)break ; } -tty_unlock (tty); +tty_unlock ();schedule (); -tty_lock (tty); +tty_lock (); }set_current_state (TASK_RUNNING );remove_wait_queue (&dev->wait, &wait);
PATCH 3/12 f81232: correct stubbed termios handler
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/f81232.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/f81232.c +1 -0
@@ -177,6 +177,7 @@ static void f81232_set_termios(struct tty_struct *tty,return ;/* Do the real work here... */ +tty_termios_copy_hw (&tty->termios, old_termios); }static int f81232_tiocmget (struct tty_struct *tty)
PATCH 4/12 usb: fix sillies in the metro USB driver
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Bits noticed doing the termios conversion
---
drivers/usb/serial/metro-usb.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/usb/serial/metro-usb.c +1 -7
@@ -130,20 +130,14 @@ static void metrousb_read_int_callback(struct urb *urb)/* Set the data read from the usb port into the serial port buffer. */ tty =tty_port_tty_get (&port->port); -if (!tty) { -dev_err (&port->dev,"%s - bad tty pointer - exiting\n" , - __func__); -return ; - } -if (tty && urb->actual_length) {/* Loop through the data copying each byte to the tty layer. */ tty_insert_flip_string (tty, data, urb->actual_length);/* Force the data to the tty layer. */ tty_flip_buffer_push (tty); +tty_kref_put (tty); } -tty_kref_put (tty);/* Set any port variables. */ spin_lock_irqsave (&metro_priv->lock, flags);
PATCH 5/12 usb, kobil: Sort out some bogus tty handling
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Stuff noticed while doing the termios conversion.
---
drivers/usb/serial/kobil_sct.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/serial/kobil_sct.c +3 -3
@@ -192,8 +192,8 @@ static void kobil_init_termios(struct tty_struct *tty) {/* Default to echo off and other sane device settings */ tty->termios.c_lflag =0 ; - tty->termios.c_lflag &= ~(ISIG |ICANON |ECHO |IEXTEN |XCASE ); - tty->termios.c_lflag =IGNBRK |IGNPAR |IXOFF ; + tty->termios.c_iflag &= ~(ISIG |ICANON |ECHO |IEXTEN |XCASE ); + tty->termios.c_iflag |=IGNBRK |IGNPAR |IXOFF ;/* do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) */ tty->termios.c_oflag &= ~ONLCR ; }
@@ -588,7 +588,7 @@ static void kobil_set_termios(struct tty_struct *tty,if (priv->device_type ==KOBIL_USBTWIN_PRODUCT_ID || priv->device_type ==KOBIL_KAAN_SIM_PRODUCT_ID ) {/* This device doesn't support ioctl calls */ - tty->termios = *old; +tty_termios_copy_hw (&tty->termios, old);return ; }
PATCH 6/12 8250: use the 8250 register interface not the legacy one
In reply to Alan CoxFrom: Alan Cox <[email protected]>
The old interface just copies bits over and calls the newer one. In addition we can now pass more information.
Updated to fix the cases reported by Stephen Rothwell and those found by Fegguang's nifty new 0 day build tester. In particular it now builds correctly for openfirmware and for OLPC.
---
arch/mips/cavium-octeon/serial.c | 30 ++++++----- drivers/char/mwave/mwavedd.c | 16 +++--- drivers/misc/ibmasm/uart.c | 16 +++--- drivers/net/ethernet/sgi/ioc3-eth.c | 22 ++++---- drivers/tty/serial/8250/8250.c | 71 +++++++++----------------- drivers/tty/serial/8250/8250.h | 30 ----------- drivers/tty/serial/8250/8250_acorn.c | 22 ++++---- drivers/tty/serial/8250/8250_dw.c | 38 +++++++------- drivers/tty/serial/8250/8250_gsc.c | 26 +++++----- drivers/tty/serial/8250/8250_hp300.c | 26 +++++----- drivers/tty/serial/8250/8250_pci.c | 92 +++++++++++++++++----------------- drivers/tty/serial/8250/8250_pnp.c | 28 +++++----- drivers/tty/serial/8250/serial_cs.c | 30 ++++++----- drivers/tty/serial/of_serial.c | 9 +++ include/linux/serial_8250.h | 33 +++++++++++- 15 files changed, 236 insertions(+), 253 deletions(-)
arch/mips/cavium-octeon/serial.c +15 -15
@@ -47,40 +47,40 @@ static int __devinit octeon_serial_probe(struct platform_device *pdev) {int irq, res;struct resource *res_mem; -struct uart_port port; +struct uart_8250_port uart;/* All adaptors have an irq. */ irq =platform_get_irq (pdev,0 );if (irq <0 )return irq; -memset (&port,0 ,sizeof (port)); +memset (&uart,0 ,sizeof (uart)); - port.flags =ASYNC_SKIP_TEST |UPF_SHARE_IRQ |UPF_FIXED_TYPE ; - port.type =PORT_OCTEON ; - port.iotype =UPIO_MEM ; - port.regshift =3 ; - port.dev = &pdev->dev; + uart.port.flags =ASYNC_SKIP_TEST |UPF_SHARE_IRQ |UPF_FIXED_TYPE ; + uart.port.type =PORT_OCTEON ; + uart.port.iotype =UPIO_MEM ; + uart.port.regshift =3 ; + uart.port.dev = &pdev->dev;if (octeon_is_simulation ())/* Make simulator output fast*/ - port.uartclk =115200 *16 ; + uart.port.uartclk =115200 *16 ;else - port.uartclk =octeon_get_io_clock_rate (); + uart.port.uartclk =octeon_get_io_clock_rate (); - port.serial_in = octeon_serial_in; - port.serial_out = octeon_serial_out; - port.irq = irq; + uart.port.serial_in = octeon_serial_in; + uart.port.serial_out = octeon_serial_out; + uart.port.irq = irq; res_mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (res_mem ==NULL ) {dev_err (&pdev->dev,"found no memory resource\n" );return -ENXIO ; } - port.mapbase = res_mem->start; - port.membase =ioremap (res_mem->start,resource_size (res_mem)); + uart.port.mapbase = res_mem->start; + uart.port.membase =ioremap (res_mem->start,resource_size (res_mem)); - res =serial8250_register_port (&port); + res =serial8250_register_8250_port (&uart);return res >=0 ?0 : res; }
drivers/char/mwave/mwavedd.c +8 -8
@@ -430,7 +430,7 @@ static ssize_t mwave_write(struct file *file, const char __user *buf,static int register_serial_portandirq (unsigned int port,int irq) { -struct uart_port uart; +struct uart_8250_port uart;switch ( port ) {case 0x3f8 :
@@ -462,14 +462,14 @@ static int register_serial_portandirq(unsigned int port, int irq) }/* switch */ /* irq is okay */ -memset (&uart,0 ,sizeof (struct uart_port )); +memset (&uart,0 ,sizeof (uart)); - uart.uartclk =1843200 ; - uart.iobase = port; - uart.irq = irq; - uart.iotype =UPIO_PORT ; - uart.flags =UPF_SHARE_IRQ ; -return serial8250_register_port (&uart); + uart.port.uartclk =1843200 ; + uart.port.iobase = port; + uart.port.irq = irq; + uart.port.iotype =UPIO_PORT ; + uart.port.flags =UPF_SHARE_IRQ ; +return serial8250_register_8250_port (&uart); }
drivers/misc/ibmasm/uart.c +8 -8
@@ -33,7 +33,7 @@void ibmasm_register_uart (struct service_processor *sp) { -struct uart_port uport; +struct uart_8250_port uart;void __iomem *iomem_base; iomem_base = sp->base_address +SCOUT_COM_B_BASE ;
@@ -47,14 +47,14 @@ void ibmasm_register_uart(struct service_processor *sp)return ; } -memset (&uport,0 ,sizeof (struct uart_port )); - uport.irq = sp->irq; - uport.uartclk =3686400 ; - uport.flags =UPF_SHARE_IRQ ; - uport.iotype =UPIO_MEM ; - uport.membase = iomem_base; +memset (&uart,0 ,sizeof (uart)); + uart.port.irq = sp->irq; + uart.port.uartclk =3686400 ; + uart.port.flags =UPF_SHARE_IRQ ; + uart.port.iotype =UPIO_MEM ; + uart.port.membase = iomem_base; - sp->serial_line =serial8250_register_port (&uport); + sp->serial_line =serial8250_register_8250_port (&uart);if (sp->serial_line <0 ) {dev_err (sp->dev,"Failed to register serial port\n" );return ;
drivers/net/ethernet/sgi/ioc3-eth.c +12 -10
@@ -1147,15 +1147,17 @@ static void __devinit ioc3_8250_register(struct ioc3_uartregs __iomem *uart) {#define COSMISC_CONSTANT 6 -struct uart_port port = { - .irq =0 , - .flags =UPF_SKIP_TEST |UPF_BOOT_AUTOCONF , - .iotype =UPIO_MEM , - .regshift =0 , - .uartclk = (22000000 <<1 ) /COSMISC_CONSTANT , - - .membase = (unsigned char __iomem *) uart, - .mapbase = (unsigned long ) uart, +struct uart_8250_port port = { + .port = { + .irq =0 , + .flags =UPF_SKIP_TEST |UPF_BOOT_AUTOCONF , + .iotype =UPIO_MEM , + .regshift =0 , + .uartclk = (22000000 <<1 ) /COSMISC_CONSTANT , + + .membase = (unsigned char __iomem *) uart, + .mapbase = (unsigned long ) uart, + } };unsigned char lcr;
@@ -1164,7 +1166,7 @@ static void __devinit ioc3_8250_register(struct ioc3_uartregs __iomem *uart) uart->iu_scr =COSMISC_CONSTANT , uart->iu_lcr = lcr; uart->iu_lcr; -serial8250_register_port (&port); +serial8250_register_8250_port (&port); }static void __devinit ioc3_serial_probe (struct pci_dev *pdev,struct ioc3 *ioc3)
drivers/tty/serial/8250/8250.c +24 -47
96 lines not on this page · raw message
drivers/tty/serial/8250/8250.h +0 -30
@@ -13,36 +13,6 @@#include <linux/serial_8250.h> -struct uart_8250_port { -struct uart_port port; -struct timer_list timer;/* "no irq" timer */ -struct list_head list;/* ports on this IRQ */ -unsigned short capabilities;/* port capabilities */ -unsigned short bugs;/* port bugs */ -unsigned int tx_loadsz;/* transmit fifo load size */ -unsigned char acr; -unsigned char ier; -unsigned char lcr; -unsigned char mcr; -unsigned char mcr_mask;/* mask of user bits */ -unsigned char mcr_force;/* mask of forced bits */ -unsigned char cur_iotype;/* Running I/O type */ - -/* -* Some bits in registers are cleared on a read, so they must -* be saved whenever the register is read but the bits will not -* be immediately processed. -*/ -#define LSR_SAVE_FLAGS UART_LSR_BRK_ERROR_BITS -unsigned char lsr_saved_flags; -#define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA -unsigned char msr_saved_flags; - -/* 8250 specific callbacks */ -int (*dl_read)(struct uart_8250_port *); -void (*dl_write)(struct uart_8250_port *,int ); -}; -struct old_serial_port {unsigned int uart;unsigned int baud_base;
drivers/tty/serial/8250/8250_acorn.c +11 -11
@@ -43,7 +43,7 @@ serial_card_probe(struct expansion_card *ec, const struct ecard_id *id) {struct serial_card_info *info;struct serial_card_type *type = id->data; -struct uart_port port; +struct uart_8250_port uart;unsigned long bus_addr;unsigned int i;
@@ -62,19 +62,19 @@ serial_card_probe(struct expansion_card *ec, const struct ecard_id *id)ecard_set_drvdata (ec, info); -memset (&port,0 ,sizeof (struct uart_port )); - port.irq = ec->irq; - port.flags =UPF_BOOT_AUTOCONF |UPF_SHARE_IRQ ; - port.uartclk = type->uartclk; - port.iotype =UPIO_MEM ; - port.regshift =2 ; - port.dev = &ec->dev; +memset (&uart,0 ,sizeof (struct uart_8250_port )); + uart.port.irq = ec->irq; + uart.port.flags =UPF_BOOT_AUTOCONF |UPF_SHARE_IRQ ; + uart.port.uartclk = type->uartclk; + uart.port.iotype =UPIO_MEM ; + uart.port.regshift =2 ; + uart.port.dev = &ec->dev;for (i =0 ; i < info->num_ports; i ++) { - port.membase = info->vaddr + type->offset[i]; - port.mapbase = bus_addr + type->offset[i]; + uart.port.membase = info->vaddr + type->offset[i]; + uart.port.mapbase = bus_addr + type->offset[i]; - info->ports[i] =serial8250_register_port (&port); + info->ports[i] =serial8250_register_8250_port (&uart); }return 0 ;
drivers/tty/serial/8250/8250_dw.c +19 -19
@@ -89,7 +89,7 @@ static int dw8250_handle_irq(struct uart_port *p)static int __devinit dw8250_probe (struct platform_device *pdev) { -struct uart_port port = {}; +struct uart_8250_port uart = {};struct resource *regs =platform_get_resource (pdev,IORESOURCE_MEM ,0 );struct resource *irq =platform_get_resource (pdev,IORESOURCE_IRQ ,0 );struct device_node *np = pdev->dev.of_node;
@@ -104,28 +104,28 @@ static int __devinit dw8250_probe(struct platform_device *pdev) data =devm_kzalloc (&pdev->dev,sizeof (*data),GFP_KERNEL );if (!data)return -ENOMEM ; - port.private_data = data; - -spin_lock_init (&port.lock); - port.mapbase = regs->start; - port.irq = irq->start; - port.handle_irq = dw8250_handle_irq; - port.type =PORT_8250 ; - port.flags =UPF_SHARE_IRQ |UPF_BOOT_AUTOCONF |UPF_IOREMAP | + uart.port.private_data = data; + +spin_lock_init (&uart.port.lock); + uart.port.mapbase = regs->start; + uart.port.irq = irq->start; + uart.port.handle_irq = dw8250_handle_irq; + uart.port.type =PORT_8250 ; + uart.port.flags =UPF_SHARE_IRQ |UPF_BOOT_AUTOCONF |UPF_IOREMAP |UPF_FIXED_PORT |UPF_FIXED_TYPE ; - port.dev = &pdev->dev; + uart.port.dev = &pdev->dev; - port.iotype =UPIO_MEM ; - port.serial_in = dw8250_serial_in; - port.serial_out = dw8250_serial_out; + uart.port.iotype =UPIO_MEM ; + uart.port.serial_in = dw8250_serial_in; + uart.port.serial_out = dw8250_serial_out;if (!of_property_read_u32 (np,"reg-io-width" , &val)) {switch (val) {case 1 :break ;case 4 : - port.iotype =UPIO_MEM32 ; - port.serial_in = dw8250_serial_in32; - port.serial_out = dw8250_serial_out32; + uart.port.iotype =UPIO_MEM32 ; + uart.port.serial_in = dw8250_serial_in32; + uart.port.serial_out = dw8250_serial_out32;break ;default : dev_err(&pdev->dev, "unsupported reg-io-width (%u)\n",
@@ -135,15 +135,15 @@ static int __devinit dw8250_probe(struct platform_device *pdev) }if (!of_property_read_u32 (np,"reg-shift" , &val)) - port.regshift = val; + uart.port.regshift = val;if (of_property_read_u32 (np,"clock-frequency" , &val)) {dev_err (&pdev->dev,"no clock-frequency property set\n" );return -EINVAL ; } - port.uartclk = val; + uart.port.uartclk = val; - data->line =serial8250_register_port (&port); + data->line =serial8250_register_8250_port (&uart);if (data->line <0 )return data->line;
drivers/tty/serial/8250/8250_gsc.c +13 -13
@@ -26,7 +26,7 @@static int __init serial_init_chip (struct parisc_device *dev) { -struct uart_port port; +struct uart_8250_port uart;unsigned long address;int err;
@@ -48,21 +48,21 @@ static int __init serial_init_chip(struct parisc_device *dev)if (dev->id.sversion !=0x8d ) address +=0x800 ; -memset (&port,0 ,sizeof (port)); - port.iotype =UPIO_MEM ; +memset (&uart,0 ,sizeof (uart)); + uart.port.iotype =UPIO_MEM ;/* 7.272727MHz on Lasi. Assumed the same for Dino, Wax and Timi. */ - port.uartclk =7272727 ; - port.mapbase = address; - port.membase =ioremap_nocache (address,16 ); - port.irq = dev->irq; - port.flags =UPF_BOOT_AUTOCONF ; - port.dev = &dev->dev; - - err =serial8250_register_port (&port); + uart.port.uartclk =7272727 ; + uart.port.mapbase = address; + uart.port.membase =ioremap_nocache (address,16 ); + uart.port.irq = dev->irq; + uart.port.flags =UPF_BOOT_AUTOCONF ; + uart.port.dev = &dev->dev; + + err =serial8250_register_8250_port (&uart);if (err <0 ) {printk (KERN_WARNING -"serial8250_register_port returned error %d\n" , err); -iounmap (port.membase); +"serial8250_register_8250_port returned error %d\n" , err); +iounmap (uart.port.membase);return err; }
drivers/tty/serial/8250/8250_hp300.c +13 -13
@@ -171,7 +171,7 @@ static int __devinit hpdca_init_one(struct dio_dev *d, return 0; }#endif -memset (&port,0 ,sizeof (struct uart_port )); +memset (&uart,0 ,sizeof (uart));/* Memory mapped I/O */ port.iotype =UPIO_MEM ;
@@ -182,7 +182,7 @@ static int __devinit hpdca_init_one(struct dio_dev *d, port.membase = (char *)(port.mapbase +DIO_VIRADDRBASE ); port.regshift =1 ; port.dev = &d->dev; - line =serial8250_register_port (&port); + line =serial8250_register_8250_port (&uart);if (line <0 ) { printk(KERN_NOTICE "8250_hp300: register_serial() DCA scode %d"
@@ -210,7 +210,7 @@ static int __init hp300_8250_init(void)#ifdef CONFIG_HPAPCI int line;unsigned long base; -struct uart_port uport; +struct uart_8250_port uart;struct hp300_port *port;int i;#endif
@@ -248,26 +248,26 @@ static int __init hp300_8250_init(void)if (!port)return -ENOMEM ; -memset (&uport,0 ,sizeof (struct uart_port )); +memset (&uart,0 ,sizeof (uart)); base = (FRODO_BASE +FRODO_APCI_OFFSET (i));/* Memory mapped I/O */ - uport.iotype =UPIO_MEM ; - uport.flags =UPF_SKIP_TEST |UPF_SHARE_IRQ \ + uart.port.iotype =UPIO_MEM ; + uart.port.flags =UPF_SKIP_TEST |UPF_SHARE_IRQ \ |UPF_BOOT_AUTOCONF ;/* XXX - no interrupt support yet */ - uport.irq =0 ; - uport.uartclk =HPAPCI_BAUD_BASE *16 ; - uport.mapbase = base; - uport.membase = (char *)(base +DIO_VIRADDRBASE ); - uport.regshift =2 ; + uart.port.irq =0 ; + uart.port.uartclk =HPAPCI_BAUD_BASE *16 ; + uart.port.mapbase = base; + uart.port.membase = (char *)(base +DIO_VIRADDRBASE ); + uart.port.regshift =2 ; - line =serial8250_register_port (&uport); + line =serial8250_register_8250_port (&uart);if (line <0 ) {printk (KERN_NOTICE "8250_hp300: register_serial() APCI" -" %d irq %d failed\n" , i, uport.irq); +" %d irq %d failed\n" , i, uart.port.irq);kfree (port);continue ; }
drivers/tty/serial/8250/8250_pci.c +46 -46
234 lines not on this page · raw message
drivers/tty/serial/8250/8250_pnp.c +14 -14
@@ -424,7 +424,7 @@ static int __devinit serial_pnp_guess_board(struct pnp_dev *dev, int *flags)static int __devinit serial_pnp_probe (struct pnp_dev *dev,const struct pnp_device_id *dev_id) { -struct uart_port port; +struct uart_8250_port uart;int ret, line, flags = dev_id->driver_data;if (flags &UNKNOWN_DEV ) {
@@ -433,32 +433,32 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)return ret; } -memset (&port,0 ,sizeof (struct uart_port )); +memset (&uart,0 ,sizeof (uart));if (pnp_irq_valid (dev,0 )) - port.irq =pnp_irq (dev,0 ); + uart.port.irq =pnp_irq (dev,0 );if (pnp_port_valid (dev,0 )) { - port.iobase =pnp_port_start (dev,0 ); - port.iotype =UPIO_PORT ; + uart.port.iobase =pnp_port_start (dev,0 ); + uart.port.iotype =UPIO_PORT ; }else if (pnp_mem_valid (dev,0 )) { - port.mapbase =pnp_mem_start (dev,0 ); - port.iotype =UPIO_MEM ; - port.flags =UPF_IOREMAP ; + uart.port.mapbase =pnp_mem_start (dev,0 ); + uart.port.iotype =UPIO_MEM ; + uart.port.flags =UPF_IOREMAP ; }else return -ENODEV ;#ifdef SERIAL_DEBUG_PNP printk (KERN_DEBUG "Setup PNP port: port %x, mem 0x%lx, irq %d, type %d\n" , - port.iobase, port.mapbase, port.irq, port.iotype); + uart.port.iobase, uart.port.mapbase, uart.port.irq, uart.port.iotype);#endif - port.flags |=UPF_SKIP_TEST |UPF_BOOT_AUTOCONF ; + uart.port.flags |=UPF_SKIP_TEST |UPF_BOOT_AUTOCONF ;if (pnp_irq_flags (dev,0 ) &IORESOURCE_IRQ_SHAREABLE ) - port.flags |=UPF_SHARE_IRQ ; - port.uartclk =1843200 ; - port.dev = &dev->dev; + uart.port.flags |=UPF_SHARE_IRQ ; + uart.port.uartclk =1843200 ; + uart.port.dev = &dev->dev; - line =serial8250_register_port (&port); + line =serial8250_register_8250_port (&uart);if (line <0 )return -ENODEV ;
drivers/tty/serial/8250/serial_cs.c +15 -15
@@ -73,7 +73,7 @@ struct serial_quirk {unsigned int prodid;int multi;/* 1 = multifunction, > 1 = # ports */ void (*config)(struct pcmcia_device *); -void (*setup)(struct pcmcia_device *,struct uart_port *); +void (*setup)(struct pcmcia_device *,struct uart_8250_port *);void (*wakeup)(struct pcmcia_device *);int (*post)(struct pcmcia_device *); };
@@ -105,9 +105,9 @@ struct serial_cfg_mem {* Elan VPU16551 UART with 14.7456MHz oscillator * manfid 0x015D, 0x4C45 */ -static void quirk_setup_brainboxes_0104 (struct pcmcia_device *link,struct uart_port *port) +static void quirk_setup_brainboxes_0104 (struct pcmcia_device *link,struct uart_8250_port *uart) { - port->uartclk =14745600 ; + uart->port.uartclk =14745600 ; }static int quirk_post_ibm (struct pcmcia_device *link)
@@ -343,25 +343,25 @@ static void serial_detach(struct pcmcia_device *link)static int setup_serial (struct pcmcia_device *handle,struct serial_info * info,unsigned int iobase,int irq) { -struct uart_port port; +struct uart_8250_port uart;int line; -memset (&port,0 ,sizeof (struct uart_port )); - port.iobase = iobase; - port.irq = irq; - port.flags =UPF_BOOT_AUTOCONF |UPF_SKIP_TEST |UPF_SHARE_IRQ ; - port.uartclk =1843200 ; - port.dev = &handle->dev; +memset (&uart,0 ,sizeof (uart)); + uart.port.iobase = iobase; + uart.port.irq = irq; + uart.port.flags =UPF_BOOT_AUTOCONF |UPF_SKIP_TEST |UPF_SHARE_IRQ ; + uart.port.uartclk =1843200 ; + uart.port.dev = &handle->dev;if (buggy_uart) - port.flags |=UPF_BUGGY_UART ; + uart.port.flags |=UPF_BUGGY_UART ;if (info->quirk && info->quirk->setup) - info->quirk->setup (handle, &port); + info->quirk->setup (handle, &uart); - line =serial8250_register_port (&port); + line =serial8250_register_8250_port (&uart);if (line <0 ) { -printk (KERN_NOTICE "serial_cs: serial8250_register_port() at " -"0x%04lx, irq %d failed\n" , (u_long )iobase, irq); +pr_err ("serial_cs: serial8250_register_8250_port() at 0x%04lx, irq %d failed\n" , + (unsigned long )iobase, irq);return -EINVAL ; }
drivers/tty/serial/of_serial.c +8 -1
@@ -144,8 +144,15 @@ static int __devinit of_platform_serial_probe(struct platform_device *ofdev)switch (port_type) {#ifdef CONFIG_SERIAL_8250 case PORT_8250 ... PORT_MAX_8250: - ret =serial8250_register_port (&port); + { +/* For now the of bindings don't support the extra +8250 specific bits */ +struct uart_8250_port port8250; +memset (&port8250,0 ,sizeof (port8250)); + port8250.port = port; + ret =serial8250_register_8250_port (&port8250);break ; + }#endif #ifdef CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL case PORT_NWPSERIAL :
include/linux/serial_8250.h +30 -3
@@ -65,11 +65,38 @@ enum {* platform device. Using these will make your driver * dependent on the 8250 driver. */ -struct uart_port ; -struct uart_8250_port ; + +struct uart_8250_port { +struct uart_port port; +struct timer_list timer;/* "no irq" timer */ +struct list_head list;/* ports on this IRQ */ +unsigned short capabilities;/* port capabilities */ +unsigned short bugs;/* port bugs */ +unsigned int tx_loadsz;/* transmit fifo load size */ +unsigned char acr; +unsigned char ier; +unsigned char lcr; +unsigned char mcr; +unsigned char mcr_mask;/* mask of user bits */ +unsigned char mcr_force;/* mask of forced bits */ +unsigned char cur_iotype;/* Running I/O type */ + +/* +* Some bits in registers are cleared on a read, so they must +* be saved whenever the register is read but the bits will not +* be immediately processed. +*/ +#define LSR_SAVE_FLAGS UART_LSR_BRK_ERROR_BITS +unsigned char lsr_saved_flags; +#define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA +unsigned char msr_saved_flags; + +/* 8250 specific callbacks */ +int (*dl_read)(struct uart_8250_port *); +void (*dl_write)(struct uart_8250_port *,int ); +};int serial8250_register_8250_port (struct uart_8250_port *); -int serial8250_register_port (struct uart_port *);void serial8250_unregister_port (int line);void serial8250_suspend_port (int line);void serial8250_resume_port (int line);
PATCH 7/12 8250: propogate the bugs field
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Now we are using the uart_8250_port this is trivial
---
drivers/tty/serial/8250/8250.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/8250/8250.c +1 -0
@@ -3155,6 +3155,7 @@ int serial8250_register_8250_port(struct uart_8250_port *up) uart->port.regshift = up->port.regshift; uart->port.iotype = up->port.iotype; uart->port.flags = up->port.flags |UPF_BOOT_AUTOCONF ; + uart->bugs = up->bugs; uart->port.mapbase = up->port.mapbase; uart->port.private_data = up->port.private_data;if (up->port.dev)
PATCH 8/12 8250: add support for ASIX devices with a FIFO bug
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Information and a different patch provided by <[email protected]>. We do it a little differently to keep the modularity and to avoid playing with RLSI.
We add a new uart bug for the parity flaw and set it in the pci matches. If parity check is enabled then we drop the FIFO trigger to 1 as per the Asix reference code.
---
drivers/tty/serial/8250/8250.c | 8 ++++++-- drivers/tty/serial/8250/8250.h | 1 + drivers/tty/serial/8250/8250_pci.c | 24 +++++++++++++++++++++--- 3 files changed, 28 insertions(+), 5 deletions(-)
drivers/tty/serial/8250/8250.c +6 -2
@@ -2202,6 +2202,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,unsigned char cval, fcr =0 ;unsigned long flags;unsigned int baud, quot; +int fifo_bug =0 ;switch (termios->c_cflag &CSIZE ) {case CS5 :
@@ -2221,8 +2222,11 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,if (termios->c_cflag &CSTOPB ) cval |=UART_LCR_STOP ; -if (termios->c_cflag &PARENB ) +if (termios->c_cflag &PARENB ) { cval |=UART_LCR_PARITY ; +if (up->bugs &UART_BUG_PARITY ) + fifo_bug =1 ; + }if (!(termios->c_cflag &PARODD )) cval |=UART_LCR_EPAR ;#ifdef CMSPAR
@@ -2246,7 +2250,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,if (up->capabilities &UART_CAP_FIFO && port->fifosize >1 ) { fcr = uart_config[port->type].fcr; -if (baud <2400 ) { +if (baud <2400 || fifo_bug) { fcr &= ~UART_FCR_TRIGGER_MASK ; fcr |=UART_FCR_TRIGGER_1 ; }
drivers/tty/serial/8250/8250.h +1 -0
@@ -48,6 +48,7 @@ struct serial8250_config {#define UART_BUG_TXEN (1 << 1)/* UART has buggy TX IIR status */ #define UART_BUG_NOMSR (1 << 2)/* UART has buggy MSR status bits (Au1x00) */ #define UART_BUG_THRE (1 << 3)/* UART has buggy THRE reassertion */ +#define UART_BUG_PARITY (1 << 4)/* UART mishandles parity if FIFO enabled */ #define PROBE_RSA (1 << 0)#define PROBE_ANY (~0)
drivers/tty/serial/8250/8250_pci.c +21 -3
@@ -1032,8 +1032,15 @@ static int pci_oxsemi_tornado_init(struct pci_dev *dev)return number_uarts; } -static int -pci_default_setup (struct serial_private *priv, +static int pci_asix_setup (struct serial_private *priv, +const struct pciserial_board *board, +struct uart_8250_port *port,int idx) +{ + port->bugs |=UART_BUG_PARITY ; +return pci_default_setup (priv, board, port, idx); +} + +static int pci_default_setup (struct serial_private *priv,const struct pciserial_board *board,struct uart_8250_port *port,int idx) {
@@ -1187,6 +1194,7 @@ pci_xr17c154_setup(struct serial_private *priv,#define PCIE_DEVICE_ID_NEO_2_OX_IBM 0x00F6#define PCI_DEVICE_ID_PLX_CRONYX_OMEGA 0xc001#define PCI_DEVICE_ID_INTEL_PATSBURG_KT 0x1d3d +#define PCI_VENDOR_ID_ASIX 0x9710/* Unknown vendors/cards - this should not be in linux/pci_ids.h */ #define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584
@@ -1726,7 +1734,17 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = { .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, .setup = pci_omegapci_setup, - }, + }, +/* +* ASIX devices with FIFO bug +*/ + { + .vendor = PCI_VENDOR_ID_ASIX, + .device = PCI_ANY_ID, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .setup = pci_asix_setup, + },/* * Default "match everything" terminator entry */
PATCH 9/12 tty: tidy up the RESET_TERMIOS case
In reply to Alan CoxFrom: Alan Cox <[email protected]>
If we are going to reset the termios then we don't need the driver side buffers at all as we now have the tty allocation.
---
drivers/tty/tty_io.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-)
drivers/tty/tty_io.c +23 -22
@@ -1249,16 +1249,20 @@ int tty_init_termios(struct tty_struct *tty)struct ktermios *tp;int idx = tty->index; - tp = tty->driver->termios[idx]; -if (tp ==NULL ) { - tp =kmalloc (sizeof (struct ktermios ),GFP_KERNEL ); -if (tp ==NULL ) -return -ENOMEM ; - *tp = tty->driver->init_termios; - tty->driver->termios[idx] = tp; - } - tty->termios = *tp; - +if (tty->driver->flags &TTY_DRIVER_RESET_TERMIOS ) + tty->termios = tty->driver->init_termios; +else { + tp = tty->driver->termios[idx]; +if (tp ==NULL ) { + tp =kzalloc (sizeof (struct ktermios [2 ]),GFP_KERNEL ); +if (tp ==NULL ) +return -ENOMEM ; + tp[0 ] = tty->driver->init_termios; + tty->driver->termios[idx] = tp; + } + tty->termios = tp[0 ]; + tty->termios_locked = tp[1 ]; + }/* Compatibility until drivers always set this */ tty->termios.c_ispeed =tty_termios_input_baud_rate (&tty->termios); tty->termios.c_ospeed =tty_termios_baud_rate (&tty->termios);
@@ -1435,16 +1439,9 @@ err_release_tty:void tty_free_termios (struct tty_struct *tty) { -struct ktermios *tp;int idx = tty->index;/* Kill this flag and push into drivers for locking etc */ -if (tty->driver->flags &TTY_DRIVER_RESET_TERMIOS ) { -/* FIXME: Locking on ->termios array */ - tp = tty->driver->termios[idx]; - tty->driver->termios[idx] =NULL ; -kfree (tp); - } -else +if (!(tty->driver->flags &TTY_DRIVER_RESET_TERMIOS )) *tty->driver->termios[idx] = tty->termios; }EXPORT_SYMBOL (tty_free_termios);
@@ -3072,16 +3069,19 @@ static void destruct_tty_driver(struct kref *kref)* drivers are removed from the kernel. */ for (i =0 ; i < driver->num; i++) { - tp = driver->termios[i]; -if (tp) { - driver->termios[i] =NULL ; -kfree (tp); +if (!(driver->flags &TTY_DRIVER_RESET_TERMIOS )) { + tp = driver->termios[i]; +if (tp) { + driver->termios[i] =NULL ; +kfree (tp); + } }if (!(driver->flags &TTY_DRIVER_DYNAMIC_DEV ))tty_unregister_device (driver, i); } p = driver->ttys;proc_tty_unregister_driver (driver); +/* FIXME: who frees driver->termios itself */ driver->ttys =NULL ; driver->termios =NULL ;kfree (p);
@@ -3121,6 +3121,7 @@ int tty_register_driver(struct tty_driver *driver)void **p =NULL ;struct device *d; +/* FIXME: at this point we are overallocating for the RESET_TERMIOS case */ if (!(driver->flags &TTY_DRIVER_DEVPTS_MEM ) && driver->num) { p =kzalloc (driver->num *2 *sizeof (void *),GFP_KERNEL );if (!p)
PATCH 10/12 vt: fix the keyboard/led locking
In reply to Alan CoxFrom: Alan Cox <[email protected]>
We touch the LED from both keyboard callback and direct paths. In one case we've got the lock held way up the call chain and in the other we haven't. This leads to complete insanity so fix it by giving the LED bits their own lock.
---
drivers/tty/vt/keyboard.c | 41 +++++++++++++++++++++++------------------ include/linux/kbd_kern.h | 1 - 2 files changed, 23 insertions(+), 19 deletions(-)
drivers/tty/vt/keyboard.c +23 -18
@@ -119,6 +119,7 @@ static const int NR_TYPES = ARRAY_SIZE(max_vals);static struct input_handler kbd_handler;static DEFINE_SPINLOCK (kbd_event_lock); +static DEFINE_SPINLOCK (led_lock);static unsigned long key_down[BITS_TO_LONGS (KEY_CNT )];/* keyboard key bitmap */ static unsigned char shift_down[NR_SHIFT ];/* shift state counters.. */ static bool dead_key_next;
@@ -984,7 +985,7 @@ static void k_brl(struct vc_data *vc, unsigned char value, char up_flag)* or (ii) whatever pattern of lights people want to show using KDSETLED, * or (iii) specified bits of specified words in kernel memory. */ -unsigned char getledstate (void ) +static unsigned char getledstate (void ) {return ledstate; }
@@ -992,7 +993,7 @@ unsigned char getledstate(void)void setledstate (struct kbd_struct *kbd,unsigned int led) {unsigned long flags; -spin_lock_irqsave (&kbd_event_lock, flags); +spin_lock_irqsave (&led_lock, flags);if (!(led & ~7 )) { ledioctl = led; kbd->ledmode =LED_SHOW_IOCTL ;
@@ -1000,7 +1001,7 @@ void setledstate(struct kbd_struct *kbd, unsigned int led) kbd->ledmode =LED_SHOW_FLAGS ;set_leds (); -spin_unlock_irqrestore (&kbd_event_lock, flags); +spin_unlock_irqrestore (&led_lock, flags); }static inline unsigned char getleds (void )
@@ -1051,8 +1052,11 @@ int vt_get_leds(int console, int flag) {struct kbd_struct * kbd = kbd_table + console;int ret; +unsigned long flags; +spin_lock_irqsave (&led_lock, flags); ret =vc_kbd_led (kbd, flag); +spin_unlock_irqrestore (&led_lock, flags);return ret; }
@@ -1088,11 +1092,11 @@ void vt_set_led_state(int console, int leds)void vt_kbd_con_start (int console) {struct kbd_struct * kbd = kbd_table + console; -/* unsigned long flags; */ -/* spin_lock_irqsave(&kbd_event_lock, flags); */ +unsigned long flags; +spin_lock_irqsave (&led_lock, flags);clr_vc_kbd_led (kbd,VC_SCROLLOCK );set_leds (); -/* spin_unlock_irqrestore(&kbd_event_lock, flags); */ +spin_unlock_irqrestore (&led_lock, flags); }/**
@@ -1101,21 +1105,15 @@ void vt_kbd_con_start(int console)* * Handle console stop. This is a wrapper for the VT layer * so that we can keep kbd knowledge internal -* -* FIXME: We eventually need to hold the kbd lock here to protect -* the LED updating. We can't do it yet because fn_hold calls stop_tty -* and start_tty under the kbd_event_lock, while normal tty paths -* don't hold the lock. We probably need to split out an LED lock -* but not during an -rc release! */ void vt_kbd_con_stop (int console) {struct kbd_struct * kbd = kbd_table + console; -/* unsigned long flags; */ -/* spin_lock_irqsave(&kbd_event_lock, flags); */ +unsigned long flags; +spin_lock_irqsave (&led_lock, flags);set_vc_kbd_led (kbd,VC_SCROLLOCK );set_leds (); -/* spin_unlock_irqrestore(&kbd_event_lock, flags); */ +spin_unlock_irqrestore (&led_lock, flags); }/*
@@ -1127,7 +1125,12 @@ void vt_kbd_con_stop(int console)*/ static void kbd_bh (unsigned long dummy) { -unsigned char leds =getleds (); +unsigned char leds; +unsigned long flags; + +spin_lock_irqsave (&led_lock, flags); + leds =getleds (); +spin_unlock_irqrestore (&led_lock, flags);if (leds != ledstate) { input_handler_for_each_handle(&kbd_handler, &leds,
@@ -2032,11 +2035,11 @@ int vt_do_kdskled(int console, int cmd, unsigned long arg, int perm)return -EPERM ;if (arg & ~0x77 )return -EINVAL ; -spin_lock_irqsave (&kbd_event_lock, flags); +spin_lock_irqsave (&led_lock, flags); kbd->ledflagstate = (arg &7 ); kbd->default_ledflagstate = ((arg >>4 ) &7 );set_leds (); -spin_unlock_irqrestore (&kbd_event_lock, flags); +spin_unlock_irqrestore (&led_lock, flags);return 0 ;/* the ioctls below only set the lights, not the functions */
@@ -2131,8 +2134,10 @@ void vt_reset_keyboard(int console)clr_vc_kbd_mode (kbd,VC_CRLF ); kbd->lockstate =0 ; kbd->slockstate =0 ; +spin_lock (&led_lock); kbd->ledmode =LED_SHOW_FLAGS ; kbd->ledflagstate = kbd->default_ledflagstate; +spin_unlock (&led_lock);/* do not do set_leds here because this causes an endless tasklet loop when the keyboard hasn't been initialized yet */ spin_unlock_irqrestore (&kbd_event_lock, flags);
include/linux/kbd_kern.h +0 -1
@@ -65,7 +65,6 @@ struct kbd_struct {extern int kbd_init (void ); -extern unsigned char getledstate (void );extern void setledstate (struct kbd_struct *kbd,unsigned int led);extern int do_poke_blanked_console;
PATCH 11/12 tty: Move the handling of the tty release logic
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Now that we don't have tty->termios tied to drivers->tty we can untangle the logic here. In addition we can push the removal logic out of the destructor path.
At that point we can think about sorting out tty_port and console and all the other ugly hangovers.
---
drivers/tty/pty.c | 12 ++---------- drivers/tty/tty_io.c | 16 +++++----------- drivers/tty/vt/vt.c | 1 - drivers/usb/serial/usb-serial.c | 3 +-- include/linux/tty.h | 1 - include/linux/tty_driver.h | 11 +++-------- 6 files changed, 11 insertions(+), 33 deletions(-)
drivers/tty/pty.c +2 -10
@@ -527,12 +527,6 @@ static struct tty_struct *pts_unix98_lookup(struct tty_driver *driver,return tty; } -static void pty_unix98_shutdown (struct tty_struct *tty) -{ -tty_driver_remove_tty (tty->driver, tty); -/* We have our own method as we don't use the tty index */ -} -/* We have no need to install and remove our tty objects as devpts does all the work for us */
@@ -558,9 +552,8 @@ static const struct tty_operations ptm_unix98_ops = { .unthrottle = pty_unthrottle, .set_termios = pty_set_termios, .ioctl = pty_unix98_ioctl, - .shutdown = pty_unix98_shutdown, - .cleanup = pty_cleanup, - .resize = pty_resize + .resize = pty_resize, + .cleanup = pty_cleanup };static const struct tty_operations pty_unix98_ops = {
@@ -575,7 +568,6 @@ static const struct tty_operations pty_unix98_ops = { .chars_in_buffer = pty_chars_in_buffer, .unthrottle = pty_unthrottle, .set_termios = pty_set_termios, - .shutdown = pty_unix98_shutdown, .cleanup = pty_cleanup, };
drivers/tty/tty_io.c +5 -11
@@ -1446,12 +1446,6 @@ void tty_free_termios(struct tty_struct *tty) }EXPORT_SYMBOL (tty_free_termios); -void tty_shutdown (struct tty_struct *tty) -{ -tty_driver_remove_tty (tty->driver, tty); -tty_free_termios (tty); -} -EXPORT_SYMBOL (tty_shutdown);/** * release_one_tty - release tty structure memory
@@ -1495,11 +1489,6 @@ static void queue_release_one_tty(struct kref *kref) { struct tty_struct *tty = container_of(kref, struct tty_struct, kref); -if (tty->ops->shutdown) - tty->ops->shutdown (tty); -else -tty_shutdown (tty); -/* The hangup queue is now free so we can reuse it rather than waste a chunk of memory for each port */ INIT_WORK (&tty->hangup_work, release_one_tty);
@@ -1539,6 +1528,11 @@ static void release_tty(struct tty_struct *tty, int idx)/* This should always be true but check for the moment */ WARN_ON (tty->index != idx); +if (tty->ops->shutdown) + tty->ops->shutdown (tty); +tty_free_termios (tty); +tty_driver_remove_tty (tty->driver, tty); +if (tty->link)tty_kref_put (tty->link);tty_kref_put (tty);
drivers/tty/vt/vt.c +0 -1
@@ -2850,7 +2850,6 @@ static void con_shutdown(struct tty_struct *tty)console_lock (); vc->port.tty =NULL ;console_unlock (); -tty_shutdown (tty); }static int default_italic_color =2 ;// green (ASCII)
drivers/usb/serial/usb-serial.c +1 -2
@@ -305,8 +305,7 @@ static void serial_close(struct tty_struct *tty, struct file *filp)* Do the resource freeing and refcount dropping for the port. * Avoid freeing the console. * -* Called asynchronously after the last tty kref is dropped, -* and the tty layer has already done the tty_shutdown(tty); +* Called asynchronously after the last tty kref is dropped. */ static void serial_cleanup (struct tty_struct *tty) {
include/linux/tty.h +0 -1
@@ -423,7 +423,6 @@ extern void tty_unthrottle(struct tty_struct *tty);extern int tty_do_resize (struct tty_struct *tty,struct winsize *ws);extern void tty_driver_remove_tty (struct tty_driver *driver,struct tty_struct *tty); -extern void tty_shutdown (struct tty_struct *tty);extern void tty_free_termios (struct tty_struct *tty);extern int is_current_pgrp_orphaned (void );extern struct pid *tty_get_pgrp (struct tty_struct *tty);
include/linux/tty_driver.h +3 -8
@@ -45,14 +45,9 @@* * void (*shutdown)(struct tty_struct * tty); * -* This routine is called synchronously when a particular tty device -* is closed for the last time freeing up the resources. -* Note that tty_shutdown() is not called if ops->shutdown is defined. -* This means one is responsible to take care of calling ops->remove (e.g. -* via tty_driver_remove_tty) and releasing tty->termios. -* Note that this hook may be called from *all* the contexts where one -* uses tty refcounting (e.g. tty_port_tty_get). -* +* This routine is called under the tty lock when a particular tty device +* is closed for the last time. It executes before the tty resources +* are freed so may execute while another function holds a tty kref. * * void (*cleanup)(struct tty_struct * tty); *
PATCH 12/12 tty: localise the lock
In reply to Alan CoxFrom: Alan Cox <[email protected]>
The termios and other changes mean the other protections needed on the driver tty arrays should be adequate. Turn it all back on.
This contains pieces folded in from the fixes made to the original patches
| From: Geert Uytterhoeven <[email protected]> (fix m68k) | From: Paul Gortmaker <[email protected]> (fix cris) | From: Jiri Kosina <[email protected]> (lockdep) | From: Eric Dumazet <[email protected]> (lockdep)
---
drivers/tty/amiserial.c | 14 ++++---- drivers/tty/cyclades.c | 2 + drivers/tty/n_r3964.c | 10 +++--- drivers/tty/pty.c | 25 ++++++++------- drivers/tty/serial/crisv10.c | 8 ++--- drivers/tty/synclink.c | 4 +- drivers/tty/synclink_gt.c | 4 +- drivers/tty/synclinkmp.c | 4 +- drivers/tty/tty_io.c | 67 ++++++++++++++++++++++++---------------- drivers/tty/tty_ldisc.c | 67 ++++++++++++++++++++++------------------ drivers/tty/tty_mutex.c | 71 +++++++++++++++++++++++++++++++++--------- drivers/tty/tty_port.c | 6 ++-- include/linux/tty.h | 23 ++++++++------ net/bluetooth/rfcomm/tty.c | 4 +- 14 files changed, 190 insertions(+), 119 deletions(-)
drivers/tty/amiserial.c +7 -7
@@ -1033,7 +1033,7 @@ static int get_serial_info(struct tty_struct *tty, struct serial_state *state,if (!retinfo)return -EFAULT ;memset (&tmp,0 ,sizeof (tmp)); -tty_lock (); +tty_lock (tty); tmp.line = tty->index; tmp.port = state->port; tmp.flags = state->tport.flags;
@@ -1042,7 +1042,7 @@ static int get_serial_info(struct tty_struct *tty, struct serial_state *state, tmp.close_delay = state->tport.close_delay; tmp.closing_wait = state->tport.closing_wait; tmp.custom_divisor = state->custom_divisor; -tty_unlock (); +tty_unlock (tty);if (copy_to_user (retinfo,&tmp,sizeof (*retinfo)))return -EFAULT ;return 0 ;
@@ -1059,12 +1059,12 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,if (copy_from_user (&new_serial,new_info,sizeof (new_serial)))return -EFAULT ; -tty_lock (); +tty_lock (tty); change_spd = ((new_serial.flags ^ port->flags) &ASYNC_SPD_MASK ) || new_serial.custom_divisor != state->custom_divisor;if (new_serial.irq || new_serial.port != state->port || new_serial.xmit_fifo_size != state->xmit_fifo_size) { -tty_unlock (); +tty_unlock (tty);return -EINVAL ; }
@@ -1074,7 +1074,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state, (new_serial.xmit_fifo_size != state->xmit_fifo_size) || ((new_serial.flags & ~ASYNC_USR_MASK) != (port->flags & ~ASYNC_USR_MASK))) { -tty_unlock (); +tty_unlock (tty);return -EPERM ; } port->flags = ((port->flags & ~ASYNC_USR_MASK) |
@@ -1084,7 +1084,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state, }if (new_serial.baud_base <9600 ) { -tty_unlock (); +tty_unlock (tty);return -EINVAL ; }
@@ -1116,7 +1116,7 @@ check_and_exit: } }else retval =startup (tty, state); -tty_unlock (); +tty_unlock (tty);return retval; }
drivers/tty/cyclades.c +1 -1
@@ -1599,7 +1599,7 @@ static int cy_open(struct tty_struct *tty, struct file *filp)* If the port is the middle of closing, bail out now */ if (tty_hung_up_p (filp) || (info->port.flags &ASYNC_CLOSING )) { -wait_event_interruptible_tty (info->port.close_wait, +wait_event_interruptible_tty (tty, info->port.close_wait, !(info->port.flags &ASYNC_CLOSING ));return (info->port.flags &ASYNC_HUP_NOTIFY ) ? -EAGAIN : -ERESTARTSYS ; }
drivers/tty/n_r3964.c +5 -5
@@ -1065,7 +1065,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,TRACE_L ("read()" ); -tty_lock (); +tty_lock (tty); pClient =findClient (pInfo,task_pid (current));if (pClient) {
@@ -1077,7 +1077,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file, goto unlock; }/* block until there is a message: */ -wait_event_interruptible_tty (pInfo->read_wait, +wait_event_interruptible_tty (tty, pInfo->read_wait, (pMsg =remove_msg (pInfo, pClient))); }
@@ -1107,7 +1107,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file, } ret = -EPERM ; unlock: -tty_unlock (); +tty_unlock (tty);return ret; }
@@ -1156,7 +1156,7 @@ static ssize_t r3964_write(struct tty_struct *tty, struct file *file, pHeader->locks =0 ; pHeader->owner =NULL ; -tty_lock (); +tty_lock (tty); pClient =findClient (pInfo,task_pid (current));if (pClient) {
@@ -1175,7 +1175,7 @@ static ssize_t r3964_write(struct tty_struct *tty, struct file *file,add_tx_queue (pInfo, pHeader);trigger_transmit (pInfo); -tty_unlock (); +tty_unlock (tty);return 0 ; }
drivers/tty/pty.c +14 -11
@@ -47,6 +47,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)wake_up_interruptible (&tty->read_wait);wake_up_interruptible (&tty->write_wait); tty->packet =0 ; +/* Review - krefs on tty_link ?? */ if (!tty->link)return ; tty->link->packet =0 ;
@@ -62,9 +63,9 @@ static void pty_close(struct tty_struct *tty, struct file *filp) mutex_unlock(&devpts_mutex); }#endif -tty_unlock (); +tty_unlock (tty);tty_vhangup (tty->link); -tty_lock (); +tty_lock (tty); } }
@@ -596,26 +597,27 @@ static int ptmx_open(struct inode *inode, struct file *filp)return retval;/* find a device that is not in use. */ -tty_lock (); +mutex_lock (&devpts_mutex); index =devpts_new_index (inode); -tty_unlock ();if (index <0 ) { retval = index; goto err_file; } +mutex_unlock (&devpts_mutex); +mutex_lock (&tty_mutex); -mutex_lock (&devpts_mutex); tty =tty_init_dev (ptm_driver, index); -mutex_unlock (&devpts_mutex); -tty_lock (); -mutex_unlock (&tty_mutex);if (IS_ERR (tty)) { retval =PTR_ERR (tty); goto out; } +/* The tty returned here is locked so we can safely +drop the mutex */ +mutex_unlock (&tty_mutex); +set_bit (TTY_PTY_LOCK , &tty->flags);/* LOCK THE SLAVE */ tty_add_file (tty, filp);
@@ -628,16 +630,17 @@ static int ptmx_open(struct inode *inode, struct file *filp)if (retval) goto err_release; -tty_unlock (); +tty_unlock (tty);return 0 ; err_release: -tty_unlock (); +tty_unlock (tty);tty_release (inode, filp);return retval; out: +mutex_unlock (&tty_mutex);devpts_kill_index (inode, index); -tty_unlock (); err_file: +mutex_unlock (&devpts_mutex);tty_free_file (filp);return retval; }
drivers/tty/serial/crisv10.c +4 -4
@@ -3976,7 +3976,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp,*/ if (tty_hung_up_p (filp) || (info->flags &ASYNC_CLOSING )) { -wait_event_interruptible_tty (info->close_wait, +wait_event_interruptible_tty (tty, info->close_wait, !(info->flags &ASYNC_CLOSING ));#ifdef SERIAL_DO_RESTART if (info->flags &ASYNC_HUP_NOTIFY )
@@ -4052,9 +4052,9 @@ block_til_ready(struct tty_struct *tty, struct file * filp,printk ("block_til_ready blocking: ttyS%d, count = %d\n" , info->line, info->count);#endif -tty_unlock (); +tty_unlock (tty);schedule (); -tty_lock (); +tty_lock (tty); }set_current_state (TASK_RUNNING );remove_wait_queue (&info->open_wait, &wait);
@@ -4115,7 +4115,7 @@ rs_open(struct tty_struct *tty, struct file * filp)*/ if (tty_hung_up_p (filp) || (info->flags &ASYNC_CLOSING )) { -wait_event_interruptible_tty (info->close_wait, +wait_event_interruptible_tty (tty, info->close_wait, !(info->flags &ASYNC_CLOSING ));#ifdef SERIAL_DO_RESTART return ((info->flags & ASYNC_HUP_NOTIFY) ?
drivers/tty/synclink.c +2 -2
@@ -3338,9 +3338,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,printk ("%s(%d):block_til_ready blocking on %s count=%d\n" , __FILE__,__LINE__, tty->driver->name, port->count ); -tty_unlock (); +tty_unlock (tty);schedule (); -tty_lock (); +tty_lock (tty); }set_current_state (TASK_RUNNING );
drivers/tty/synclink_gt.c +2 -2
@@ -3336,9 +3336,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, }DBGINFO (("%s block_til_ready wait\n" , tty->driver->name)); -tty_unlock (); +tty_unlock (tty);schedule (); -tty_lock (); +tty_lock (tty); }set_current_state (TASK_RUNNING );
drivers/tty/synclinkmp.c +2 -2
@@ -3357,9 +3357,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,printk ("%s(%d):%s block_til_ready() count=%d\n" , __FILE__,__LINE__, tty->driver->name, port->count ); -tty_unlock (); +tty_unlock (tty);schedule (); -tty_lock (); +tty_lock (tty); }set_current_state (TASK_RUNNING );
drivers/tty/tty_io.c +40 -27
234 lines not on this page · raw message
drivers/tty/tty_ldisc.c +38 -29
153 lines not on this page · raw message
drivers/tty/tty_mutex.c +56 -15
85 lines not on this page · raw message
drivers/tty/tty_port.c +3 -3
@@ -239,7 +239,7 @@ int tty_port_block_til_ready(struct tty_port *port,/* block if port is in the process of being closed */ if (tty_hung_up_p (filp) || port->flags &ASYNC_CLOSING ) { -wait_event_interruptible_tty (port->close_wait, +wait_event_interruptible_tty (tty, port->close_wait, !(port->flags &ASYNC_CLOSING ));if (port->flags &ASYNC_HUP_NOTIFY )return -EAGAIN ;
@@ -305,9 +305,9 @@ int tty_port_block_til_ready(struct tty_port *port, retval = -ERESTARTSYS ;break ; } -tty_unlock (); +tty_unlock (tty);schedule (); -tty_lock (); +tty_lock (tty); }finish_wait (&port->open_wait, &wait);
include/linux/tty.h +14 -9
@@ -268,6 +268,7 @@ struct tty_struct {struct mutex ldisc_mutex;struct tty_ldisc *ldisc; +struct mutex legacy_mutex;struct mutex termios_mutex;spinlock_t ctrl_lock;/* Termios values are protected by the termios mutex */
@@ -609,8 +610,12 @@ extern long vt_compat_ioctl(struct tty_struct *tty,/* tty_mutex.c */ /* functions for preparation of BKL removal */ -extern void __lockfunc tty_lock(void) __acquires(tty_lock); -extern void __lockfunc tty_unlock(void) __releases(tty_lock); +extern void __lockfunc tty_lock(struct tty_struct *tty); +extern void __lockfunc tty_unlock(struct tty_struct *tty); +extern void __lockfunc tty_lock_pair(struct tty_struct *tty, +struct tty_struct *tty2); +extern void __lockfunc tty_unlock_pair(struct tty_struct *tty, +struct tty_struct *tty2);/* * this shall be called only from where BTM is held (like close)
@@ -625,9 +630,9 @@ extern void __lockfunc tty_unlock(void) __releases(tty_lock);static inline void tty_wait_until_sent_from_close (struct tty_struct *tty,long timeout) { -tty_unlock ();/* tty->ops->close holds the BTM, drop it while waiting */ +tty_unlock (tty);/* tty->ops->close holds the BTM, drop it while waiting */ tty_wait_until_sent (tty, timeout); -tty_lock (); +tty_lock (tty); }/*
@@ -642,16 +647,16 @@ static inline void tty_wait_until_sent_from_close(struct tty_struct *tty,* * Do not use in new code. */ -#define wait_event_interruptible_tty (wq, condition) \ +#define wait_event_interruptible_tty (tty, wq, condition) \ ({ \ int __ret = 0; \ if (!(condition)) { \ - __wait_event_interruptible_tty(wq, condition, __ret); \ + __wait_event_interruptible_tty(tty, wq, condition, __ret); \ } \ __ret; \ }) -#define __wait_event_interruptible_tty (wq, condition, ret) \ +#define __wait_event_interruptible_tty (tty, wq, condition, ret) \ do { \ DEFINE_WAIT(__wait); \ \
@@ -660,9 +665,9 @@ do { \if (condition) \break ; \if (!signal_pending (current)) { \ -tty_unlock (); \ +tty_unlock (tty); \schedule (); \ -tty_lock (); \ +tty_lock (tty); \continue ; \ } \ ret = -ERESTARTSYS ; \
net/bluetooth/rfcomm/tty.c +2 -2
@@ -705,9 +705,9 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)break ; } -tty_unlock (); +tty_unlock (tty);schedule (); -tty_lock (); +tty_lock (tty); }set_current_state (TASK_RUNNING );remove_wait_queue (&dev->wait, &wait);
Re: [PATCH 04/12] usb: fix sillies in the metro USB driver
In reply to Alan CoxQuoted 6 lines · Alan Cox
From: Alan Cox <[email protected]>
Bits noticed doing the termios conversion
Signed-off-by Alan Cox <[email protected]>---
Already applied previously.
greg k-h
Re: [PATCH 06/12] 8250: use the 8250 register interface not the legacy one
In reply to Alan CoxQuoted 10 lines · Alan Cox
From: Alan Cox <[email protected]>
The old interface just copies bits over and calls the newer one. In addition we can now pass more information.
Updated to fix the cases reported by Stephen Rothwell and those found by Fegguang's nifty new 0 day build tester. In particular it now builds correctly for openfirmware and for OLPC.
Signed-off-by Alan Cox <[email protected]>
I already applied an older version of this, so it doesn't apply properly.
can you redo this patch series based on my tty-next branch now, and resend these last 6 patches, if they are still needed?
thanks,
greg k-h
Re: [PATCH 06/12] 8250: use the 8250 register interface not the legacy one
Quoted 10 lines · On Mon, 16 Jul 2012 13:09:50 -0700 Greg KH <[email protected]> wrote:
Quoted 9 lines · Alan Cox
From: Alan Cox <[email protected]>
The old interface just copies bits over and calls the newer one. In addition we can now pass more information.
Updated to fix the cases reported by Stephen Rothwell and those found by Fegguang's nifty new 0 day build tester. In particular it now builds correctly for openfirmware and for OLPC.
Quoted 7 lines
Quoted 1 line
Signed-off-by Alan Cox <[email protected]>I already applied an older version of this, so it doesn't apply properly.
can you redo this patch series based on my tty-next branch now, and resend these last 6 patches, if they are still needed?
I can do but that will simply be a series of reverts of the old stuff followed by the patches I sent... we need to rewind to before the lock change patch or it all ends up impossible to bisect.
Alan
Re: [PATCH 06/12] 8250: use the 8250 register interface not the legacy one
Quoted 18 lines · Alan Cox
Quoted 15 lines · On Mon, 16 Jul 2012 13:09:50 -0700 Greg KH <[email protected]> wrote:
Quoted 10 lines · Alan Cox
From: Alan Cox <[email protected]>
The old interface just copies bits over and calls the newer one. In addition we can now pass more information.
Updated to fix the cases reported by Stephen Rothwell and those found by Fegguang's nifty new 0 day build tester. In particular it now builds correctly for openfirmware and for OLPC.
Signed-off-by Alan Cox <[email protected]>I already applied an older version of this, so it doesn't apply properly.
Quoted 6 lines
Quoted 2 lines
can you redo this patch series based on my tty-next branch now, and resend these last 6 patches, if they are still needed?
I can do but that will simply be a series of reverts of the old stuff followed by the patches I sent... we need to rewind to before the lock change patch or it all ends up impossible to bisect.
Ok, that's fine with me.
greg k-h