Re: [PATCH 4/4] Bluetooth: hci_ldisc: make sure we don't loose HCI_UART_TX_WAKEUP events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 30 Aug 2016 09:53:53 -0700
Marcel Holtmann <marcel@xxxxxxxxxxxx> wrote:

> Hi Boris,
> 
> > The HCI_UART_TX_WAKEUP flag checking is racy and some HCI_UART_TX_WAKEUP
> > events can be lost.
> > 
> > Signed-off-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxxxxxxx>
> > ---
> > drivers/bluetooth/hci_ldisc.c | 11 +++++++++++
> > 1 file changed, 11 insertions(+)
> > 
> > diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
> > index 27f73294edcb..ee7b25f1c6ce 100644
> > --- a/drivers/bluetooth/hci_ldisc.c
> > +++ b/drivers/bluetooth/hci_ldisc.c
> > @@ -172,6 +172,17 @@ restart:
> > 		goto restart;
> > 
> > 	clear_bit(HCI_UART_SENDING, &hu->tx_state);
> > +
> > +	/*
> > +	 * One last check to make sure hci_uart_tx_wakeup() did not set
> > +	 * HCI_UART_TX_WAKEUP while we where clearing HCI_UART_SENDING.
> > +	 * The work might have been scheduled by someone else in the
> > +	 * meantime, in this case we return directly.
> > +	 */
> > +	if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state) &&
> > +	    !test_and_set_bit(HCI_UART_SENDING, &hu->tx_state))
> > +		goto restart;
> > +  
> 
> I know this is correct, but I would actually make it visually different.
> 
> 	if (test_bit(UART_TX_WAKEUP, ..) {
> 		/* comment goes here
> 		 */
> 		if (!test_and_set_bit(UART_SENDING, ..)
> 			goto restart;
> 	}
> 
> For me with a proper comment that is a lot easier to read and grok that it is correct.

Sure, I'll address that.

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux