|
From: Paul M. <le...@us...> - 2006-08-02 06:18:19
|
Update of /cvsroot/linuxsh/linux/drivers/serial In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv7896/drivers/serial Modified Files: sh-sci.c Log Message: Complete overhaul of sh-sci locking. Index: sh-sci.c =================================================================== RCS file: /cvsroot/linuxsh/linux/drivers/serial/sh-sci.c,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- sh-sci.c 1 Aug 2006 10:12:06 -0000 1.46 +++ sh-sci.c 2 Aug 2006 06:18:15 -0000 1.47 @@ -111,8 +111,8 @@ unsigned short status; int c; - local_irq_save(flags); - do { + spin_lock_irqsave(&port->lock, flags); + do { status = sci_in(port, SCxSR); if (status & SCxSR_ERRORS(port)) { handle_error(port); @@ -122,7 +122,7 @@ c = sci_in(port, SCxRDR); sci_in(port, SCxSR); /* Dummy read */ sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); - local_irq_restore(flags); + spin_unlock_irqrestore(&port->lock, flags); return c; } @@ -134,7 +134,7 @@ unsigned long flags; unsigned short status; - local_irq_save(flags); + spin_lock_irqsave(&port->lock, flags); do { status = sci_in(port, SCxSR); @@ -144,7 +144,7 @@ sci_in(port, SCxSR); /* Dummy read */ sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port)); - local_irq_restore(flags); + spin_unlock_irqrestore(&port->lock, flags); } #endif @@ -380,14 +380,12 @@ { struct circ_buf *xmit = &port->info->xmit; unsigned int stopped = uart_tx_stopped(port); - unsigned long flags; unsigned short status; unsigned short ctrl; int count; status = sci_in(port, SCxSR); if (!(status & SCxSR_TDxE(port))) { - local_irq_save(flags); ctrl = sci_in(port, SCSCR); if (uart_circ_empty(xmit)) { ctrl &= ~SCI_CTRL_FLAGS_TIE; @@ -395,7 +393,6 @@ ctrl |= SCI_CTRL_FLAGS_TIE; } sci_out(port, SCSCR, ctrl); - local_irq_restore(flags); return; } @@ -431,7 +428,6 @@ if (uart_circ_empty(xmit)) { sci_stop_tx(port); } else { - local_irq_save(flags); ctrl = sci_in(port, SCSCR); #if !defined(SCI_ONLY) @@ -443,7 +439,6 @@ ctrl |= SCI_CTRL_FLAGS_TIE; sci_out(port, SCSCR, ctrl); - local_irq_restore(flags); } } @@ -634,7 +629,7 @@ s->break_flag = 1; #endif /* Notify of BREAK */ - if(tty_insert_flip_char(tty, 0, TTY_BREAK)) + if (tty_insert_flip_char(tty, 0, TTY_BREAK)) copied++; pr_debug("sci: BREAK detected\n"); } @@ -643,7 +638,7 @@ /* XXX: Handle SCIF overrun error */ if (port->type == PORT_SCIF && (sci_in(port, SCLSR) & SCIF_ORER) != 0) { sci_out(port, SCLSR, 0); - if(tty_insert_flip_char(tty, 0, TTY_OVERRUN)) { + if (tty_insert_flip_char(tty, 0, TTY_OVERRUN)) { copied++; pr_debug("sci: overrun error\n"); } @@ -652,13 +647,12 @@ if (copied) tty_flip_buffer_push(tty); + return copied; } -static irqreturn_t sci_rx_interrupt(int irq, void *ptr, struct pt_regs *regs) +static irqreturn_t sci_rx_interrupt(int irq, void *port, struct pt_regs *regs) { - struct uart_port *port = ptr; - /* I think sci_receive_chars has to be called irrespective * of whether the I_IXOFF is set, otherwise, how is the interrupt * to be disabled? @@ -672,7 +666,9 @@ { struct uart_port *port = ptr; + spin_lock_irq(&port->lock); sci_transmit_chars(port); + spin_unlock_irq(&port->lock); return IRQ_HANDLED; } @@ -873,50 +869,42 @@ static void sci_start_tx(struct uart_port *port) { - struct sci_port *s = &sci_ports[port->line]; + unsigned short ctrl; - disable_irq(s->irqs[SCIx_TXI_IRQ]); - sci_transmit_chars(port); - enable_irq(s->irqs[SCIx_TXI_IRQ]); + /* Set TIE (Transmit Interrupt Enable) bit in SCSCR */ + ctrl = sci_in(port, SCSCR); + ctrl |= SCI_CTRL_FLAGS_TIE; + sci_out(port, SCSCR, ctrl); } static void sci_stop_tx(struct uart_port *port) { - unsigned long flags; unsigned short ctrl; /* Clear TIE (Transmit Interrupt Enable) bit in SCSCR */ - local_irq_save(flags); ctrl = sci_in(port, SCSCR); ctrl &= ~SCI_CTRL_FLAGS_TIE; sci_out(port, SCSCR, ctrl); - local_irq_restore(flags); } static void sci_start_rx(struct uart_port *port, unsigned int tty_start) { - unsigned long flags; unsigned short ctrl; /* Set RIE (Receive Interrupt Enable) bit in SCSCR */ - local_irq_save(flags); ctrl = sci_in(port, SCSCR); ctrl |= SCI_CTRL_FLAGS_RIE | SCI_CTRL_FLAGS_REIE; sci_out(port, SCSCR, ctrl); - local_irq_restore(flags); } static void sci_stop_rx(struct uart_port *port) { - unsigned long flags; unsigned short ctrl; /* Clear RIE (Receive Interrupt Enable) bit in SCSCR */ - local_irq_save(flags); ctrl = sci_in(port, SCSCR); ctrl &= ~(SCI_CTRL_FLAGS_RIE | SCI_CTRL_FLAGS_REIE); sci_out(port, SCSCR, ctrl); - local_irq_restore(flags); } static void sci_enable_ms(struct uart_port *port) @@ -965,6 +953,23 @@ baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); + switch (baud) { + case 0: + t = -1; + break; + default: + { +#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) + struct clk *clk = clk_get("module_clk"); + t = SCBRR_VALUE(baud, clk_get_rate(clk)); + clk_put(clk); +#else + t = SCBRR_VALUE(baud); +#endif + } + break; + } + spin_lock_irqsave(&port->lock, flags); do { @@ -992,25 +997,6 @@ sci_out(port, SCSMR, smr_val); - spin_unlock_irqrestore(&port->lock, flags); - - switch (baud) { - case 0: - t = -1; - break; - default: - { -#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) - struct clk *clk = clk_get("module_clk"); - t = SCBRR_VALUE(baud, clk_get_rate(clk)); - clk_put(clk); -#else - t = SCBRR_VALUE(baud); -#endif - } - break; - } - if (t > 0) { if(t >= 256) { sci_out(port, SCSMR, (sci_in(port, SCSMR) & ~3) | 1); @@ -1029,6 +1015,8 @@ if ((termios->c_cflag & CREAD) != 0) sci_start_rx(port,0); + + spin_unlock_irqrestore(&port->lock, flags); } static const char *sci_type(struct uart_port *port) |