aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2015-10-10 16:00:55 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-18 00:11:29 -0400
commit9b9ab1b3f0860138681862cf6e4c48be59377ef1 (patch)
tree5dcd70bcb2ab9a42db39a5c7d5311f08795d4a89
parentcc2aaabfd6d6335e2156781ca67715b4de17f993 (diff)
tty: r3964: Use tty->read_wait waitqueue
The tty core provides read_wait waitqueue specifically for line disciplines to wait readers; otherwise, the line discipline may miss wakeups generated by the tty core. NB: The tty core already provides serialization for the line discipline's close() method, and guarantees no readers or writers will be using the closing instance of the line discipline. Completely remove that wakeup. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/n_r3964.c10
-rw-r--r--include/linux/n_r3964.h3
2 files changed, 4 insertions, 9 deletions
diff --git a/drivers/tty/n_r3964.c b/drivers/tty/n_r3964.c
index 8b157d68a03e..6fdef921cdb7 100644
--- a/drivers/tty/n_r3964.c
+++ b/drivers/tty/n_r3964.c
@@ -276,7 +276,7 @@ static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code)
276 add_msg(pHeader->owner, R3964_MSG_ACK, pHeader->length, 276 add_msg(pHeader->owner, R3964_MSG_ACK, pHeader->length,
277 error_code, NULL); 277 error_code, NULL);
278 } 278 }
279 wake_up_interruptible(&pInfo->read_wait); 279 wake_up_interruptible(&pInfo->tty->read_wait);
280 } 280 }
281 281
282 spin_lock_irqsave(&pInfo->lock, flags); 282 spin_lock_irqsave(&pInfo->lock, flags);
@@ -542,7 +542,7 @@ static void on_receive_block(struct r3964_info *pInfo)
542 pBlock); 542 pBlock);
543 } 543 }
544 } 544 }
545 wake_up_interruptible(&pInfo->read_wait); 545 wake_up_interruptible(&pInfo->tty->read_wait);
546 546
547 pInfo->state = R3964_IDLE; 547 pInfo->state = R3964_IDLE;
548 548
@@ -979,7 +979,6 @@ static int r3964_open(struct tty_struct *tty)
979 979
980 spin_lock_init(&pInfo->lock); 980 spin_lock_init(&pInfo->lock);
981 pInfo->tty = tty; 981 pInfo->tty = tty;
982 init_waitqueue_head(&pInfo->read_wait);
983 pInfo->priority = R3964_MASTER; 982 pInfo->priority = R3964_MASTER;
984 pInfo->rx_first = pInfo->rx_last = NULL; 983 pInfo->rx_first = pInfo->rx_last = NULL;
985 pInfo->tx_first = pInfo->tx_last = NULL; 984 pInfo->tx_first = pInfo->tx_last = NULL;
@@ -1045,7 +1044,6 @@ static void r3964_close(struct tty_struct *tty)
1045 } 1044 }
1046 1045
1047 /* Free buffers: */ 1046 /* Free buffers: */
1048 wake_up_interruptible(&pInfo->read_wait);
1049 kfree(pInfo->rx_buf); 1047 kfree(pInfo->rx_buf);
1050 TRACE_M("r3964_close - rx_buf kfree %p", pInfo->rx_buf); 1048 TRACE_M("r3964_close - rx_buf kfree %p", pInfo->rx_buf);
1051 kfree(pInfo->tx_buf); 1049 kfree(pInfo->tx_buf);
@@ -1077,7 +1075,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
1077 goto unlock; 1075 goto unlock;
1078 } 1076 }
1079 /* block until there is a message: */ 1077 /* block until there is a message: */
1080 wait_event_interruptible_tty(tty, pInfo->read_wait, 1078 wait_event_interruptible_tty(tty, tty->read_wait,
1081 (pMsg = remove_msg(pInfo, pClient))); 1079 (pMsg = remove_msg(pInfo, pClient)));
1082 } 1080 }
1083 1081
@@ -1227,7 +1225,7 @@ static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,
1227 1225
1228 pClient = findClient(pInfo, task_pid(current)); 1226 pClient = findClient(pInfo, task_pid(current));
1229 if (pClient) { 1227 if (pClient) {
1230 poll_wait(file, &pInfo->read_wait, wait); 1228 poll_wait(file, &tty->read_wait, wait);
1231 spin_lock_irqsave(&pInfo->lock, flags); 1229 spin_lock_irqsave(&pInfo->lock, flags);
1232 pMsg = pClient->first_msg; 1230 pMsg = pClient->first_msg;
1233 spin_unlock_irqrestore(&pInfo->lock, flags); 1231 spin_unlock_irqrestore(&pInfo->lock, flags);
diff --git a/include/linux/n_r3964.h b/include/linux/n_r3964.h
index 5d0b2a1dee69..e9adb4226224 100644
--- a/include/linux/n_r3964.h
+++ b/include/linux/n_r3964.h
@@ -152,9 +152,6 @@ struct r3964_info {
152 unsigned char *rx_buf; /* ring buffer */ 152 unsigned char *rx_buf; /* ring buffer */
153 unsigned char *tx_buf; 153 unsigned char *tx_buf;
154 154
155 wait_queue_head_t read_wait;
156 //struct wait_queue *read_wait;
157
158 struct r3964_block_header *rx_first; 155 struct r3964_block_header *rx_first;
159 struct r3964_block_header *rx_last; 156 struct r3964_block_header *rx_last;
160 struct r3964_block_header *tx_first; 157 struct r3964_block_header *tx_first;