Remove ASYNC_CLOSING
Subsystems (5)
cover Remove ASYNC_CLOSING
Hi Greg,
This series removes ASYNC_CLOSING from kernel use. However, the definition is in a uapi header so I think it needs to stay.
The mxser driver used ASYNC_CLOSING to purge its fifo _with each byte received_ while closing. This is clearly unnecessary but the hangup/shutdown sequence in that driver is spaghetti and I don't have the hardware to test (what I would consider to be) the proper fix:
cleaning up its hangup/shutdown so that clearing the fifo can be done once in shutdown.
The isdn subsystem used ASYNC_CLOSING for unclear purposes; the immediate effect was to prevent sending AT commands from the emulator, but its not clear why that's necessary when closing. Since idsn does not use the tty_port helpers, I simply added to isdn the equivalent of an ASYNC_CLOSING flag.
Regards,
Peter Hurley (3):
tty: mxser: Remove ASYNC_CLOSING
isdn: Remove ASYNC_CLOSING
tty: Remove ASYNC_CLOSING
drivers/isdn/i4l/isdn_tty.c | 12 ++++++------ drivers/s390/char/con3215.c | 3 +-- drivers/tty/mxser.c | 9 +++++---- drivers/tty/rocket.c | 2 +- drivers/tty/serial/68328serial.c | 3 +-- drivers/tty/serial/crisv10.c | 3 +-- drivers/tty/serial/serial_core.c | 1 - drivers/tty/tty_port.c | 3 +-- include/linux/isdn.h | 1 + net/irda/ircomm/ircomm_tty.c | 4 ---- 10 files changed, 17 insertions(+), 24 deletions(-)
Signature · 1 line
2.6.3
PATCH 1/3 tty: mxser: Remove ASYNC_CLOSING
The tty core no longer provides ASYNC_CLOSING. Use private flag for same purpose, which is to clear the fifos at each and every interrupt during driver close(). The driver uses this sledgehammer approach because its close/shutdown sequence is hopelessly borked.
--- drivers/tty/mxser.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/tty/mxser.c +5 -4
@@ -254,6 +254,7 @@ struct mxser_port {int xmit_head;int xmit_tail;int xmit_cnt; +int closing;struct ktermios normal_termios;
@@ -1081,6 +1082,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)return ;if (tty_port_close_start (port, tty, filp) ==0 )return ; + info->closing =1 ;mutex_lock (&port->mutex);mxser_close_port (port);mxser_flush_buffer (tty);
@@ -1091,6 +1093,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)mxser_shutdown_port (port);clear_bit (ASYNCB_INITIALIZED , &port->flags);mutex_unlock (&port->mutex); + info->closing =0 ;/* Right now the tty_port set is done outside of the close_end helper as we don't yet have everyone using refcounts */ tty_port_close_end (port, tty);
@@ -2255,10 +2258,8 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)break ; iir &=MOXA_MUST_IIR_MASK ; tty =tty_port_tty_get (&port->port); -if (!tty || - (port->port.flags &ASYNC_CLOSING ) || - !(port->port.flags & -ASYNC_INITIALIZED )) { +if (!tty || port->closing || + !(port->port.flags &ASYNC_INITIALIZED )) { status =inb (port->ioaddr +UART_LSR );outb (0x27 , port->ioaddr +UART_FCR );inb (port->ioaddr +UART_MSR );
Signature · 1 line
2.6.3
PATCH 2/3 isdn: Remove ASYNC_CLOSING
In reply to Peter HurleyThe tty core no longer provides ASYNC_CLOSING. Use private flag for same purpose, which is to disable AT-emulator output (why this is necessary is not clear).
--- drivers/isdn/i4l/isdn_tty.c | 12 ++++++------ include/linux/isdn.h | 1 + 2 files changed, 7 insertions(+), 6 deletions(-)
drivers/isdn/i4l/isdn_tty.c +6 -6
@@ -1572,7 +1572,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)#endif return ; } - port->flags |=ASYNC_CLOSING ; + info->closing =1 ;tty_ldisc_closing (tty);/*
@@ -1603,6 +1603,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp) info->ncarrier =0 ;tty_port_close_end (port, tty); + info->closing =0 ;#ifdef ISDN_DEBUG_MODEM_OPEN printk (KERN_DEBUG "isdn_tty_close normal exit\n" );#endif
@@ -2236,7 +2237,7 @@ isdn_tty_at_cout(char *msg, modem_info *info) l =strlen (msg);spin_lock_irqsave (&info->readlock, flags); -if (port->flags &ASYNC_CLOSING ) { +if (info->closing) {spin_unlock_irqrestore (&info->readlock, flags);return ; }
@@ -2386,13 +2387,12 @@ isdn_tty_modem_result(int code, modem_info *info)case RESULT_NO_CARRIER :#ifdef ISDN_DEBUG_MODEM_HUP printk (KERN_DEBUG "modem_result: NO CARRIER %d %d\n" , - (info->port.flags &ASYNC_CLOSING ), - (!info->port.tty)); + info->closing, !info->port.tty);#endif m->mdmreg[REG_RINGCNT ] =0 ;del_timer (&info->nc_timer); info->ncarrier =0 ; -if ((info->port.flags &ASYNC_CLOSING ) || (!info->port.tty)) +if (info->closing || !info->port.tty)return ;#ifdef CONFIG_ISDN_AUDIO
@@ -2525,7 +2525,7 @@ isdn_tty_modem_result(int code, modem_info *info) } }if (code ==RESULT_NO_CARRIER ) { -if ((info->port.flags &ASYNC_CLOSING ) || (!info->port.tty)) +if (info->closing || (!info->port.tty))return ;if (info->port.flags &ASYNC_CHECK_CD )
include/linux/isdn.h +1 -0
@@ -319,6 +319,7 @@ typedef struct modem_info {int online;/* 1 = B-Channel is up, drop data */ /* 2 = B-Channel is up, deliver d.*/ int dialing;/* Dial in progress or ATA */ +int closing;int rcvsched;/* Receive needs schedule */ int isdn_driver;/* Index to isdn-driver */ int isdn_channel;/* Index to isdn-channel */
Signature · 1 line
2.6.3
PATCH 3/3 tty: Remove ASYNC_CLOSING
In reply to Peter HurleyThe tty core no longer provides nor uses ASYNC_CLOSING; remove from tty_port_close_start() and tty_port_close_end() as well as tty drivers which open-code these state changes. Unfortunately, even though the bit is masked from userspace, its inclusion in a uapi header precludes removing the macro.
--- drivers/s390/char/con3215.c | 3 +-- drivers/tty/rocket.c | 2 +- drivers/tty/serial/68328serial.c | 3 +-- drivers/tty/serial/crisv10.c | 3 +-- drivers/tty/serial/serial_core.c | 1 - drivers/tty/tty_port.c | 3 +-- net/irda/ircomm/ircomm_tty.c | 4 ---- 7 files changed, 5 insertions(+), 14 deletions(-)
drivers/s390/char/con3215.c +1 -2
@@ -643,7 +643,6 @@ static void raw3215_shutdown(struct raw3215_info *raw)if ((raw->flags &RAW3215_WORKING ) || raw->queued_write !=NULL || raw->queued_read !=NULL ) { - raw->port.flags |=ASYNC_CLOSING ;add_wait_queue (&raw->empty_wait, &wait);set_current_state (TASK_INTERRUPTIBLE );spin_unlock_irqrestore (get_ccwdev_lock (raw->cdev), flags);
@@ -651,7 +650,7 @@ static void raw3215_shutdown(struct raw3215_info *raw)spin_lock_irqsave (get_ccwdev_lock (raw->cdev), flags);remove_wait_queue (&raw->empty_wait, &wait);set_current_state (TASK_RUNNING ); - raw->port.flags &= ~(ASYNC_INITIALIZED |ASYNC_CLOSING ); + raw->port.flags &= ~ASYNC_INITIALIZED ; }spin_unlock_irqrestore (get_ccwdev_lock (raw->cdev), flags); }
drivers/tty/rocket.c +1 -1
@@ -1040,7 +1040,7 @@ static void rp_close(struct tty_struct *tty, struct file *filp) } }spin_lock_irq (&port->lock); - info->port.flags &= ~(ASYNC_INITIALIZED |ASYNC_CLOSING |ASYNC_NORMAL_ACTIVE ); + info->port.flags &= ~(ASYNC_INITIALIZED |ASYNC_NORMAL_ACTIVE );spin_unlock_irq (&port->lock);mutex_unlock (&port->mutex);tty_port_tty_set (port,NULL );
drivers/tty/serial/68328serial.c +1 -2
@@ -1030,7 +1030,6 @@ static void rs_close(struct tty_struct *tty, struct file * filp)local_irq_restore (flags);return ; } - port->flags |=ASYNC_CLOSING ;/* * Now we wait for the transmit buffer to clear; and we notify * the line discipline to only process XON/XOFF characters.
@@ -1059,7 +1058,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)msleep_interruptible (jiffies_to_msecs (port->close_delay));wake_up_interruptible (&port->open_wait); } - port->flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); + port->flags &= ~ASYNC_NORMAL_ACTIVE ;local_irq_restore (flags); }
drivers/tty/serial/crisv10.c +1 -2
@@ -3613,7 +3613,6 @@ rs_close(struct tty_struct *tty, struct file * filp)local_irq_restore (flags);return ; } - info->port.flags |=ASYNC_CLOSING ;/* * Now we wait for the transmit buffer to clear; and we notify * the line discipline to only process XON/XOFF characters.
@@ -3651,7 +3650,7 @@ rs_close(struct tty_struct *tty, struct file * filp)schedule_timeout_interruptible (info->port.close_delay);wake_up_interruptible (&info->port.open_wait); } - info->port.flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); + info->port.flags &= ~ASYNC_NORMAL_ACTIVE ;local_irq_restore (flags);/* port closed */
drivers/tty/serial/serial_core.c +0 -1
@@ -1434,7 +1434,6 @@ static void uart_close(struct tty_struct *tty, struct file *filp)* Wake up anyone trying to open this port. */ clear_bit (ASYNCB_NORMAL_ACTIVE , &port->flags); -clear_bit (ASYNCB_CLOSING , &port->flags);spin_unlock_irq (&port->lock);wake_up_interruptible (&port->open_wait);
drivers/tty/tty_port.c +1 -2
@@ -476,7 +476,6 @@ int tty_port_close_start(struct tty_port *port,spin_unlock_irqrestore (&port->lock, flags);return 0 ; } -set_bit (ASYNCB_CLOSING , &port->flags);spin_unlock_irqrestore (&port->lock, flags);tty_ldisc_closing (tty);
@@ -514,7 +513,7 @@ void tty_port_close_end(struct tty_port *port, struct tty_struct *tty)spin_lock_irqsave (&port->lock, flags);wake_up_interruptible (&port->open_wait); } - port->flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); + port->flags &= ~ASYNC_NORMAL_ACTIVE ;spin_unlock_irqrestore (&port->lock, flags); }EXPORT_SYMBOL (tty_port_close_end);
net/irda/ircomm/ircomm_tty.c +0 -4
@@ -1268,10 +1268,6 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)seq_printf (m,"%cASYNC_LOW_LATENCY" , sep); sep ='|' ; } -if (self->port.flags &ASYNC_CLOSING ) { -seq_printf (m,"%cASYNC_CLOSING" , sep); - sep ='|' ; - }if (self->port.flags &ASYNC_NORMAL_ACTIVE ) {seq_printf (m,"%cASYNC_NORMAL_ACTIVE" , sep); sep ='|' ;
Signature · 1 line
2.6.3
v2 cover Remove ASYNC_CLOSING
In reply to Peter HurleyChanges for v2: rebased on top of tty-next
Hi Greg,
This series removes ASYNC_CLOSING from kernel use. However, the definition is in a uapi header so I think it needs to stay.
The mxser driver used ASYNC_CLOSING to purge its fifo _with each byte received_ while closing. This is clearly unnecessary but the hangup/shutdown sequence in that driver is spaghetti and I don't have the hardware to test (what I would consider to be) the proper fix:
cleaning up its hangup/shutdown so that clearing the fifo can be done once in shutdown.
The isdn subsystem used ASYNC_CLOSING for unclear purposes; the immediate effect was to prevent sending AT commands from the emulator, but its not clear why that's necessary when closing. Since idsn does not use the tty_port helpers, I simply added to isdn the equivalent of an ASYNC_CLOSING flag.
Regards,
Peter Hurley (3):
tty: mxser: Remove ASYNC_CLOSING
isdn: Remove ASYNC_CLOSING
tty: Remove ASYNC_CLOSING
drivers/isdn/i4l/isdn_tty.c | 12 ++++++------ drivers/s390/char/con3215.c | 3 +-- drivers/tty/mxser.c | 9 +++++---- drivers/tty/rocket.c | 2 +- drivers/tty/serial/68328serial.c | 3 +-- drivers/tty/serial/crisv10.c | 3 +-- drivers/tty/serial/serial_core.c | 1 - drivers/tty/tty_port.c | 3 +-- include/linux/isdn.h | 1 + net/irda/ircomm/ircomm_tty.c | 4 ---- 10 files changed, 17 insertions(+), 24 deletions(-)
Signature · 1 line
2.7.0
PATCH v2 1/3 tty: mxser: Remove ASYNC_CLOSING
The tty core no longer provides ASYNC_CLOSING. Use private flag for same purpose, which is to clear the fifos at each and every interrupt during driver close(). The driver uses this sledgehammer approach because its close/shutdown sequence is hopelessly borked.
--- drivers/tty/mxser.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/tty/mxser.c +5 -4
@@ -254,6 +254,7 @@ struct mxser_port {int xmit_head;int xmit_tail;int xmit_cnt; +int closing;struct ktermios normal_termios;
@@ -1081,6 +1082,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)return ;if (tty_port_close_start (port, tty, filp) ==0 )return ; + info->closing =1 ;mutex_lock (&port->mutex);mxser_close_port (port);mxser_flush_buffer (tty);
@@ -1091,6 +1093,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)mxser_shutdown_port (port);clear_bit (ASYNCB_INITIALIZED , &port->flags);mutex_unlock (&port->mutex); + info->closing =0 ;/* Right now the tty_port set is done outside of the close_end helper as we don't yet have everyone using refcounts */ tty_port_close_end (port, tty);
@@ -2253,10 +2256,8 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)break ; iir &=MOXA_MUST_IIR_MASK ; tty =tty_port_tty_get (&port->port); -if (!tty || - (port->port.flags &ASYNC_CLOSING ) || - !(port->port.flags & -ASYNC_INITIALIZED )) { +if (!tty || port->closing || + !(port->port.flags &ASYNC_INITIALIZED )) { status =inb (port->ioaddr +UART_LSR );outb (0x27 , port->ioaddr +UART_FCR );inb (port->ioaddr +UART_MSR );
Signature · 1 line
2.7.0
PATCH v2 2/3 isdn: Remove ASYNC_CLOSING
In reply to Peter HurleyThe tty core no longer provides ASYNC_CLOSING. Use private flag for same purpose, which is to disable AT-emulator output (why this is necessary is not clear).
--- drivers/isdn/i4l/isdn_tty.c | 12 ++++++------ include/linux/isdn.h | 1 + 2 files changed, 7 insertions(+), 6 deletions(-)
drivers/isdn/i4l/isdn_tty.c +6 -6
@@ -1572,7 +1572,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)#endif return ; } - port->flags |=ASYNC_CLOSING ; + info->closing =1 ; tty->closing =1 ;/*
@@ -1603,6 +1603,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp) info->ncarrier =0 ;tty_port_close_end (port, tty); + info->closing =0 ;#ifdef ISDN_DEBUG_MODEM_OPEN printk (KERN_DEBUG "isdn_tty_close normal exit\n" );#endif
@@ -2236,7 +2237,7 @@ isdn_tty_at_cout(char *msg, modem_info *info) l =strlen (msg);spin_lock_irqsave (&info->readlock, flags); -if (port->flags &ASYNC_CLOSING ) { +if (info->closing) {spin_unlock_irqrestore (&info->readlock, flags);return ; }
@@ -2386,13 +2387,12 @@ isdn_tty_modem_result(int code, modem_info *info)case RESULT_NO_CARRIER :#ifdef ISDN_DEBUG_MODEM_HUP printk (KERN_DEBUG "modem_result: NO CARRIER %d %d\n" , - (info->port.flags &ASYNC_CLOSING ), - (!info->port.tty)); + info->closing, !info->port.tty);#endif m->mdmreg[REG_RINGCNT ] =0 ;del_timer (&info->nc_timer); info->ncarrier =0 ; -if ((info->port.flags &ASYNC_CLOSING ) || (!info->port.tty)) +if (info->closing || !info->port.tty)return ;#ifdef CONFIG_ISDN_AUDIO
@@ -2525,7 +2525,7 @@ isdn_tty_modem_result(int code, modem_info *info) } }if (code ==RESULT_NO_CARRIER ) { -if ((info->port.flags &ASYNC_CLOSING ) || (!info->port.tty)) +if (info->closing || (!info->port.tty))return ;if (info->port.flags &ASYNC_CHECK_CD )
include/linux/isdn.h +1 -0
@@ -319,6 +319,7 @@ typedef struct modem_info {int online;/* 1 = B-Channel is up, drop data */ /* 2 = B-Channel is up, deliver d.*/ int dialing;/* Dial in progress or ATA */ +int closing;int rcvsched;/* Receive needs schedule */ int isdn_driver;/* Index to isdn-driver */ int isdn_channel;/* Index to isdn-channel */
Signature · 1 line
2.7.0
PATCH v2 3/3 tty: Remove ASYNC_CLOSING
In reply to Peter HurleyThe tty core no longer provides nor uses ASYNC_CLOSING; remove from tty_port_close_start() and tty_port_close_end() as well as tty drivers which open-code these state changes. Unfortunately, even though the bit is masked from userspace, its inclusion in a uapi header precludes removing the macro.
--- drivers/s390/char/con3215.c | 3 +-- drivers/tty/rocket.c | 2 +- drivers/tty/serial/68328serial.c | 3 +-- drivers/tty/serial/crisv10.c | 3 +-- drivers/tty/serial/serial_core.c | 1 - drivers/tty/tty_port.c | 3 +-- net/irda/ircomm/ircomm_tty.c | 4 ---- 7 files changed, 5 insertions(+), 14 deletions(-)
drivers/s390/char/con3215.c +1 -2
@@ -643,7 +643,6 @@ static void raw3215_shutdown(struct raw3215_info *raw)if ((raw->flags &RAW3215_WORKING ) || raw->queued_write !=NULL || raw->queued_read !=NULL ) { - raw->port.flags |=ASYNC_CLOSING ;add_wait_queue (&raw->empty_wait, &wait);set_current_state (TASK_INTERRUPTIBLE );spin_unlock_irqrestore (get_ccwdev_lock (raw->cdev), flags);
@@ -651,7 +650,7 @@ static void raw3215_shutdown(struct raw3215_info *raw)spin_lock_irqsave (get_ccwdev_lock (raw->cdev), flags);remove_wait_queue (&raw->empty_wait, &wait);set_current_state (TASK_RUNNING ); - raw->port.flags &= ~(ASYNC_INITIALIZED |ASYNC_CLOSING ); + raw->port.flags &= ~ASYNC_INITIALIZED ; }spin_unlock_irqrestore (get_ccwdev_lock (raw->cdev), flags); }
drivers/tty/rocket.c +1 -1
@@ -1042,7 +1042,7 @@ static void rp_close(struct tty_struct *tty, struct file *filp) } }spin_lock_irq (&port->lock); - info->port.flags &= ~(ASYNC_INITIALIZED |ASYNC_CLOSING |ASYNC_NORMAL_ACTIVE ); + info->port.flags &= ~(ASYNC_INITIALIZED |ASYNC_NORMAL_ACTIVE ); tty->closing =0 ;spin_unlock_irq (&port->lock);mutex_unlock (&port->mutex);
drivers/tty/serial/68328serial.c +1 -2
@@ -1028,7 +1028,6 @@ static void rs_close(struct tty_struct *tty, struct file *filp)local_irq_restore (flags);return ; } - port->flags |=ASYNC_CLOSING ;/* * Now we wait for the transmit buffer to clear; and we notify * the line discipline to only process XON/XOFF characters.
@@ -1058,7 +1057,7 @@ static void rs_close(struct tty_struct *tty, struct file *filp)msleep_interruptible (jiffies_to_msecs (port->close_delay));wake_up_interruptible (&port->open_wait); } - port->flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); + port->flags &= ~ASYNC_NORMAL_ACTIVE ;local_irq_restore (flags); }
drivers/tty/serial/crisv10.c +1 -2
@@ -3610,7 +3610,6 @@ rs_close(struct tty_struct *tty, struct file * filp)local_irq_restore (flags);return ; } - info->port.flags |=ASYNC_CLOSING ;/* * Now we wait for the transmit buffer to clear; and we notify * the line discipline to only process XON/XOFF characters.
@@ -3649,7 +3648,7 @@ rs_close(struct tty_struct *tty, struct file * filp)schedule_timeout_interruptible (info->port.close_delay);wake_up_interruptible (&info->port.open_wait); } - info->port.flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); + info->port.flags &= ~ASYNC_NORMAL_ACTIVE ;local_irq_restore (flags);/* port closed */
drivers/tty/serial/serial_core.c +0 -1
@@ -1423,7 +1423,6 @@ static void uart_close(struct tty_struct *tty, struct file *filp)* Wake up anyone trying to open this port. */ clear_bit (ASYNCB_NORMAL_ACTIVE , &port->flags); -clear_bit (ASYNCB_CLOSING , &port->flags);spin_unlock_irq (&port->lock);wake_up_interruptible (&port->open_wait);
drivers/tty/tty_port.c +1 -2
@@ -476,7 +476,6 @@ int tty_port_close_start(struct tty_port *port,spin_unlock_irqrestore (&port->lock, flags);return 0 ; } -set_bit (ASYNCB_CLOSING , &port->flags);spin_unlock_irqrestore (&port->lock, flags); tty->closing =1 ;
@@ -515,7 +514,7 @@ void tty_port_close_end(struct tty_port *port, struct tty_struct *tty)spin_lock_irqsave (&port->lock, flags);wake_up_interruptible (&port->open_wait); } - port->flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); + port->flags &= ~ASYNC_NORMAL_ACTIVE ;spin_unlock_irqrestore (&port->lock, flags); }EXPORT_SYMBOL (tty_port_close_end);
net/irda/ircomm/ircomm_tty.c +0 -4
@@ -1267,10 +1267,6 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)seq_printf (m,"%cASYNC_LOW_LATENCY" , sep); sep ='|' ; } -if (self->port.flags &ASYNC_CLOSING ) { -seq_printf (m,"%cASYNC_CLOSING" , sep); - sep ='|' ; - }if (self->port.flags &ASYNC_NORMAL_ACTIVE ) {seq_printf (m,"%cASYNC_NORMAL_ACTIVE" , sep); sep ='|' ;
Signature · 1 line
2.7.0