Char: mxser_new, alter locking in isr
Subsystems (2)
PATCH 1/4 Char: mxser_new, alter locking in isr
mxser_new, alter locking in isr
Avoid oopsing when stress-testing open/close -- port->tty is NULL sometimes, but is expected to be non-NULL, since dereferencing. Receive/transmit chars iff ASYNC_CLOSING is not set and ASYNC_INITIALIZED is set. Thanks Sergei for pointing this out and testing.
---
commit 15e7e157283a86bb819a0193a8cb137d7640d3a6
tree c0d4130f898c835c4e283af0e343ee504345d4c0
parent ab35af25a3d01f1e07fc8de5b96f484b93a8ad2a
author Jiri Slaby <[email protected]> Fri, 29 Dec 2006 20:00:21 +0059 committer Jiri Slaby <[email protected]> Fri, 29 Dec 2006 20:00:21 +0059
drivers/char/mxser_new.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/char/mxser_new.c +9 -13
@@ -2073,9 +2073,6 @@ static void mxser_receive_chars(struct mxser_port *port, int *status)int cnt =0 ;int recv_room;int max =256 ; -unsigned long flags; - -spin_lock_irqsave (&port->slock, flags); recv_room = tty->receive_room;if ((recv_room ==0 ) && (!port->ldisc_stop_rx))
@@ -2159,7 +2156,6 @@ end_intr: mxvar_log.rxcnt[port->tty->index] += cnt; port->mon_data.rxcnt += cnt; port->mon_data.up_rxcnt += cnt; -spin_unlock_irqrestore (&port->slock, flags);tty_flip_buffer_push (tty); }
@@ -2167,9 +2163,6 @@ end_intr:static void mxser_transmit_chars (struct mxser_port *port) {int count, cnt; -unsigned long flags; - -spin_lock_irqsave (&port->slock, flags);if (port->x_char) {outb (port->x_char, port->ioaddr +UART_TX );
@@ -2178,11 +2171,11 @@ static void mxser_transmit_chars(struct mxser_port *port) port->mon_data.txcnt++; port->mon_data.up_txcnt++; port->icount.tx++; - goto unlock; +return ; }if (port->xmit_buf ==0 ) - goto unlock; +return ; if ((port->xmit_cnt <= 0) || port->tty->stopped || (port->tty->hw_stopped &&
@@ -2190,7 +2183,7 @@ static void mxser_transmit_chars(struct mxser_port *port) (!port->board->chip_flag))) { port->IER &= ~UART_IER_THRI ;outb (port->IER, port->ioaddr +UART_IER ); - goto unlock; +return ; } cnt = port->xmit_cnt;
@@ -2215,8 +2208,6 @@ static void mxser_transmit_chars(struct mxser_port *port) port->IER &= ~UART_IER_THRI ;outb (port->IER, port->ioaddr +UART_IER ); } -unlock: -spin_unlock_irqrestore (&port->slock, flags); }/*
@@ -2257,12 +2248,16 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id) port = &brd->ports[i]; int_cnt =0 ; +spin_lock (&port->slock); do { iir = inb(port->ioaddr + UART_IIR); if (iir & UART_IIR_NO_INT) break; iir &= MOXA_MUST_IIR_MASK; - if (!port->tty) { + if (!port->tty || + (port->flags & ASYNC_CLOSING) || + !(port->flags & + ASYNC_INITIALIZED)) { status = inb(port->ioaddr + UART_LSR); outb(0x27, port->ioaddr + UART_FCR); inb(port->ioaddr + UART_MSR);
@@ -2308,6 +2303,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)mxser_transmit_chars (port); } }while (int_cnt++ <MXSER_ISR_PASS_LIMIT ); +spin_unlock (&port->slock); }if (pass_counter++ >MXSER_ISR_PASS_LIMIT )break ;/* Prevent infinite loops */
PATCH 2/4 Char: mxser_new, header file cleanup
mxser_new, header file cleanup
- Remove no longer used macros
- Move some macros from the header to the code
- Remove c++ comments
- Align backslashes to one column
---
commit cc46acb974ba967794f7b199fb65ad4abd9531b7
tree 56be354d64287e9b79013b8d8d35fd6ca4dc0d49
parent 15e7e157283a86bb819a0193a8cb137d7640d3a6
author Jiri Slaby <[email protected]> Fri, 29 Dec 2006 20:57:07 +0059 committer Jiri Slaby <[email protected]> Fri, 29 Dec 2006 20:57:07 +0059
drivers/char/mxser_new.c | 7 - drivers/char/mxser_new.h | 461 +++++++++++++++------------------------------- 2 files changed, 154 insertions(+), 314 deletions(-)
drivers/char/mxser_new.c +5 -2
@@ -53,8 +53,6 @@#define MXSERMAJOR 174#define MXSERCUMAJOR 175 -#define MXSER_EVENT_TXLOW 1 -#define MXSER_BOARDS 4/* Max. boards */ #define MXSER_PORTS_PER_BOARD 8/* Max. ports per board */ #define MXSER_PORTS (MXSER_BOARDS * MXSER_PORTS_PER_BOARD)
@@ -65,6 +63,11 @@#define MXSER_ERR_IRQ_CONFLIT -3#define MXSER_ERR_VECTOR -4 +/*CheckIsMoxaMust return value*/ +#define MOXA_OTHER_UART 0x00 +#define MOXA_MUST_MU150_HWID 0x01 +#define MOXA_MUST_MU860_HWID 0x02 +#define WAKEUP_CHARS 256#define UART_MCR_AFE 0x20
drivers/char/mxser_new.h +149 -312
556 lines not on this page · raw message
PATCH 3/4 Char: mxser_new, less loops in isr
In reply to Jiri Slabymxser_new, less loops in isr
Loop only 100^2 times, not 99999^2 times in isr (at most).
---
commit 5065aa25fd624e3477d993baebbf3255a1d492fa
tree a4b05ea113ceea8b8ad1382fa3a5778473597d0f
parent cc46acb974ba967794f7b199fb65ad4abd9531b7
author Jiri Slaby <[email protected]> Fri, 29 Dec 2006 21:07:10 +0059 committer Jiri Slaby <[email protected]> Fri, 29 Dec 2006 21:07:10 +0059
drivers/char/mxser_new.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-)
drivers/char/mxser_new.c +3 -6
@@ -56,7 +56,7 @@#define MXSER_BOARDS 4/* Max. boards */ #define MXSER_PORTS_PER_BOARD 8/* Max. ports per board */ #define MXSER_PORTS (MXSER_BOARDS * MXSER_PORTS_PER_BOARD) -#define MXSER_ISR_PASS_LIMIT 99999L +#define MXSER_ISR_PASS_LIMIT 100#define MXSER_ERR_IOADDR -1#define MXSER_ERR_IRQ -2
@@ -2222,8 +2222,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)struct mxser_board *brd =NULL ;struct mxser_port *port;int max, irqbits, bits, msr; -int pass_counter =0 ; -unsigned int int_cnt; +unsigned int int_cnt, pass_counter =0 ;int handled =IRQ_NONE ;for (i =0 ; i <MXSER_BOARDS ; i++)
@@ -2237,7 +2236,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)if (brd ==NULL ) goto irq_stop; max = brd->info->nports; -while (1 ) { +while (pass_counter++ <MXSER_ISR_PASS_LIMIT ) { irqbits =inb (brd->vector) & brd->vector_mask;if (irqbits == brd->vector_mask)break ;
@@ -2308,8 +2307,6 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id) }while (int_cnt++ <MXSER_ISR_PASS_LIMIT );spin_unlock (&port->slock); } -if (pass_counter++ >MXSER_ISR_PASS_LIMIT ) -break ;/* Prevent infinite loops */ } irq_stop:
PATCH 4/4 Char: mxser_new, fix twice resource releasing
In reply to Jiri Slabymxser_new, fix twice resource releasing
Because brd->info is not NULLed, resources are released twice. NULL it in pci_remove function. Also take care of retval and releasing in pci_probe -- mxser_initbrd alreasy releases resource, do not do it again in fail path in probe function.
---
commit 549237a65498ad3880cd1ca40f23f8bc942041cb
tree 8208eb0eb881aa6bd1532c90a60c72009415e3e1
parent 5065aa25fd624e3477d993baebbf3255a1d492fa
author Jiri Slaby <[email protected]> Fri, 29 Dec 2006 21:38:56 +0059 committer Jiri Slaby <[email protected]> Fri, 29 Dec 2006 21:38:56 +0059
drivers/char/mxser_new.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/char/mxser_new.c +6 -6
@@ -2403,9 +2403,8 @@ static int __devinit mxser_initbrd(struct mxser_board *brd, brd->info->name, brd->irq);/* We hold resources, we need to release them. */ mxser_release_res (brd, pdev,0 ); -return retval; } -return 0 ; +return retval; }static int __init mxser_get_ISA_conf (int cap,struct mxser_board *brd)
@@ -2590,8 +2589,9 @@ static int __devinit mxser_probe(struct pci_dev *pdev, }/* mxser_initbrd will hook ISR. */ -if (mxser_initbrd (brd, pdev) <0 ) - goto err_relvec; + retval =mxser_initbrd (brd, pdev); +if (retval) + goto err_null;for (i =0 ; i < brd->info->nports; i++)tty_register_device (mxvar_sdriver, brd->idx + i, &pdev->dev);
@@ -2599,10 +2599,9 @@ static int __devinit mxser_probe(struct pci_dev *pdev,pci_set_drvdata (pdev, brd);return 0 ; -err_relvec: -pci_release_region (pdev,3 ); err_relio:pci_release_region (pdev,2 ); +err_null: brd->info =NULL ; err:return retval;
@@ -2620,6 +2619,7 @@ static void __devexit mxser_remove(struct pci_dev *pdev)tty_unregister_device (mxvar_sdriver, brd->idx + i);mxser_release_res (brd, pdev,1 ); + brd->info =NULL ; }static struct pci_driver mxser_driver = {
Re: [PATCH 4/4] Char: mxser_new, fix twice resource releasing
Quoted 2 lines · Jiri Slaby
mxser_new, fix twice resource releasing
Hi Jiri,
I've noticed the patch(es) and will be happy to test them after the holidays.
Thank you very much for working on these issues and Happy New Year!
-- Sergei.