diff options
author | Sonic Zhang <sonic.zhang@analog.com> | 2011-01-11 00:16:43 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-02-03 17:44:54 -0500 |
commit | 0f66e50af53d39edebf4bc64ef90077e738c171f (patch) | |
tree | b4983675b49343d1e6f7c21352b787168f57eac7 /drivers/tty/serial/bfin_5xx.c | |
parent | 3e517f4b1de4787ecff87a73a9865a0b1aa2b10b (diff) |
serial: bfin_5xx: split uart RX lock from uart port lock to avoid deadlock
The RX lock is used to protect the RX buffer from concurrent access in DMA
mode between the timer and RX interrupt routines. It is independent from
the uart lock which is used to protect the TX buffer. It is possible for
a uart TX transfer to be started up from the RX interrupt handler if low
latency is enabled. So we need to split the locks to avoid deadlocking in
this situation.
In PIO mode, the RX lock is not necessary because the handle_simple_irq
and handle_level_irq functions ensure driver interrupt handlers are called
once on one core.
And now that the RX path has its own lock, the TX interrupt has nothing to
do with the RX path, so disabling it at the same time.
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/tty/serial/bfin_5xx.c')
-rw-r--r-- | drivers/tty/serial/bfin_5xx.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/tty/serial/bfin_5xx.c b/drivers/tty/serial/bfin_5xx.c index e381b895b04d..9b1ff2b6bb37 100644 --- a/drivers/tty/serial/bfin_5xx.c +++ b/drivers/tty/serial/bfin_5xx.c | |||
@@ -370,10 +370,8 @@ static irqreturn_t bfin_serial_rx_int(int irq, void *dev_id) | |||
370 | { | 370 | { |
371 | struct bfin_serial_port *uart = dev_id; | 371 | struct bfin_serial_port *uart = dev_id; |
372 | 372 | ||
373 | spin_lock(&uart->port.lock); | ||
374 | while (UART_GET_LSR(uart) & DR) | 373 | while (UART_GET_LSR(uart) & DR) |
375 | bfin_serial_rx_chars(uart); | 374 | bfin_serial_rx_chars(uart); |
376 | spin_unlock(&uart->port.lock); | ||
377 | 375 | ||
378 | return IRQ_HANDLED; | 376 | return IRQ_HANDLED; |
379 | } | 377 | } |
@@ -490,9 +488,8 @@ void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart) | |||
490 | { | 488 | { |
491 | int x_pos, pos; | 489 | int x_pos, pos; |
492 | 490 | ||
493 | dma_disable_irq(uart->tx_dma_channel); | 491 | dma_disable_irq_nosync(uart->rx_dma_channel); |
494 | dma_disable_irq(uart->rx_dma_channel); | 492 | spin_lock_bh(&uart->rx_lock); |
495 | spin_lock_bh(&uart->port.lock); | ||
496 | 493 | ||
497 | /* 2D DMA RX buffer ring is used. Because curr_y_count and | 494 | /* 2D DMA RX buffer ring is used. Because curr_y_count and |
498 | * curr_x_count can't be read as an atomic operation, | 495 | * curr_x_count can't be read as an atomic operation, |
@@ -523,8 +520,7 @@ void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart) | |||
523 | uart->rx_dma_buf.tail = uart->rx_dma_buf.head; | 520 | uart->rx_dma_buf.tail = uart->rx_dma_buf.head; |
524 | } | 521 | } |
525 | 522 | ||
526 | spin_unlock_bh(&uart->port.lock); | 523 | spin_unlock_bh(&uart->rx_lock); |
527 | dma_enable_irq(uart->tx_dma_channel); | ||
528 | dma_enable_irq(uart->rx_dma_channel); | 524 | dma_enable_irq(uart->rx_dma_channel); |
529 | 525 | ||
530 | mod_timer(&(uart->rx_dma_timer), jiffies + DMA_RX_FLUSH_JIFFIES); | 526 | mod_timer(&(uart->rx_dma_timer), jiffies + DMA_RX_FLUSH_JIFFIES); |
@@ -571,7 +567,7 @@ static irqreturn_t bfin_serial_dma_rx_int(int irq, void *dev_id) | |||
571 | unsigned short irqstat; | 567 | unsigned short irqstat; |
572 | int x_pos, pos; | 568 | int x_pos, pos; |
573 | 569 | ||
574 | spin_lock(&uart->port.lock); | 570 | spin_lock(&uart->rx_lock); |
575 | irqstat = get_dma_curr_irqstat(uart->rx_dma_channel); | 571 | irqstat = get_dma_curr_irqstat(uart->rx_dma_channel); |
576 | clear_dma_irqstat(uart->rx_dma_channel); | 572 | clear_dma_irqstat(uart->rx_dma_channel); |
577 | 573 | ||
@@ -589,7 +585,7 @@ static irqreturn_t bfin_serial_dma_rx_int(int irq, void *dev_id) | |||
589 | uart->rx_dma_buf.tail = uart->rx_dma_buf.head; | 585 | uart->rx_dma_buf.tail = uart->rx_dma_buf.head; |
590 | } | 586 | } |
591 | 587 | ||
592 | spin_unlock(&uart->port.lock); | 588 | spin_unlock(&uart->rx_lock); |
593 | 589 | ||
594 | return IRQ_HANDLED; | 590 | return IRQ_HANDLED; |
595 | } | 591 | } |
@@ -1332,6 +1328,7 @@ static int bfin_serial_probe(struct platform_device *pdev) | |||
1332 | } | 1328 | } |
1333 | 1329 | ||
1334 | #ifdef CONFIG_SERIAL_BFIN_DMA | 1330 | #ifdef CONFIG_SERIAL_BFIN_DMA |
1331 | spin_lock_init(&uart->rx_lock); | ||
1335 | uart->tx_done = 1; | 1332 | uart->tx_done = 1; |
1336 | uart->tx_count = 0; | 1333 | uart->tx_count = 0; |
1337 | 1334 | ||