Thread (18 messages) 18 messages, 3 authors, 2013-10-01

RE: [PATCH v5 1/2] Bluetooth: btmrvl: add setup handler

From: Bing Zhao <hidden>
Date: 2013-09-24 19:42:57
Also in: linux-wireless

Hi Johan,
Hi Bing,
=20
On Tue, Sep 24, 2013, Bing Zhao wrote:
quoted
quoted
that is a bug. It should only be ever called once. Could this be due
to RFKILL issue we had? Please re-test with Johan's patches applied
and check if it makes a difference. Otherwise please send some logs
since we want to get this fixed.
Amitkumar Karwar has tested it with latest code on bluetooth-next tree
but the result is the same.
Apparently two threads race to call hci_dev_open(). If the thread from
hci_sock calls hci_dev_open earlier, it ends up not updating HCI_SETUP
hdev flag in hci_power_on(). This results that the setup handler gets
called again when user brings up the interface later.
=20
Let's see if I understood this right: the only hci_dev_open call in
hci_sock.c is the one for the HCIDEVUP ioctl. So what you're doing is
having user space call the HCIDEVUP ioctl before our own hci_power_on
callback gets called to initialize the adapter?
That's right. The ioctl is initiated by the Bluetooth daemon.
Amitkumar has a setup that can reproduce this corner case easily.
I tested it on my Ubuntu but I couldn't replicate it.
=20
You're right that we're missing the clearing of the HCI_SETUP flag for
such a scenario. Could you try the attached patch. It should fix the
issue. One problem that it does have is that if the HCIDEVUP ioctl path
goes through before hci_power_on gets called we will never notify mgmt
of the adapter. However, that might be acceptable here since if you're
using HCIDEVUP like this it seems it's not a mgmt based system anyway.
=20
quoted
I checked the bluetooth-next tree, the following two patches (by
Johan) are not present in this tree.

bf54303 Bluetooth: Fix rfkill functionality during the HCI setup stage
5e13036 Bluetooth: Introduce a new HCI_RFKILLED flag

They are in bluetooth.git tree. So, I'm not certain if Amitkumar has
applied them manually or not. Anyway we will re-test with Johan's
patches applied and confirm if they fix the race or not.
=20
I don't think these patches will help you in this case.
OK, we will test your patch instead.

Thanks,
Bing
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help