* [PATCH v2 1/3] Bluetooth: Add driver setup stage for early init
2013-04-02 17:21 [PATCH v2 0/3] Bluetooth: Add HCI init setup stage Johan Hedberg
@ 2013-04-02 17:21 ` Johan Hedberg
2013-04-02 17:21 ` [PATCH v2 2/3] Bluetooth: Convert BCM92035 support to driver setup callback Johan Hedberg
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Johan Hedberg @ 2013-04-02 17:21 UTC (permalink / raw)
To: linux-bluetooth
From: Marcel Holtmann <marcel@holtmann.org>
Some drivers require a special stage for their early init. This is
always specific to the driver or transport. So call back into driver to
allow bringing up the device.
The advantage with this stage is that the Bluetooth core is actually
handling the HCI layer now. This means that command and event processing
is available.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 1 +
net/bluetooth/hci_core.c | 33 ++++++++++++++++++++-------------
2 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 0e7ee89..b464b2e 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -292,6 +292,7 @@ struct hci_dev {
int (*open)(struct hci_dev *hdev);
int (*close)(struct hci_dev *hdev);
int (*flush)(struct hci_dev *hdev);
+ int (*setup)(struct hci_dev *hdev);
int (*send)(struct sk_buff *skb);
void (*notify)(struct hci_dev *hdev, unsigned int evt);
int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index a199d63..cd93986 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1012,26 +1012,33 @@ int hci_dev_open(__u16 dev)
goto done;
}
- if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
- set_bit(HCI_RAW, &hdev->flags);
-
- /* Treat all non BR/EDR controllers as raw devices if
- enable_hs is not set */
- if (hdev->dev_type != HCI_BREDR && !enable_hs)
- set_bit(HCI_RAW, &hdev->flags);
-
if (hdev->open(hdev)) {
ret = -EIO;
goto done;
}
- if (!test_bit(HCI_RAW, &hdev->flags)) {
- atomic_set(&hdev->cmd_cnt, 1);
- set_bit(HCI_INIT, &hdev->flags);
- ret = __hci_init(hdev);
- clear_bit(HCI_INIT, &hdev->flags);
+ atomic_set(&hdev->cmd_cnt, 1);
+ set_bit(HCI_INIT, &hdev->flags);
+
+ if (hdev->setup && test_bit(HCI_SETUP, &hdev->dev_flags))
+ ret = hdev->setup(hdev);
+
+ if (!ret) {
+ /* Treat all non BR/EDR controllers as raw devices if
+ * enable_hs is not set.
+ */
+ if (hdev->dev_type != HCI_BREDR && !enable_hs)
+ set_bit(HCI_RAW, &hdev->flags);
+
+ if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
+ set_bit(HCI_RAW, &hdev->flags);
+
+ if (!test_bit(HCI_RAW, &hdev->flags))
+ ret = __hci_init(hdev);
}
+ clear_bit(HCI_INIT, &hdev->flags);
+
if (!ret) {
hci_dev_hold(hdev);
set_bit(HCI_UP, &hdev->flags);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v2 2/3] Bluetooth: Convert BCM92035 support to driver setup callback
2013-04-02 17:21 [PATCH v2 0/3] Bluetooth: Add HCI init setup stage Johan Hedberg
2013-04-02 17:21 ` [PATCH v2 1/3] Bluetooth: Add driver setup stage for early init Johan Hedberg
@ 2013-04-02 17:21 ` Johan Hedberg
2013-04-02 17:21 ` [PATCH v2 3/3] Bluetooth: Remove driver init queue from core Johan Hedberg
2013-04-04 8:24 ` [PATCH v2 0/3] Bluetooth: Add HCI init setup stage Johan Hedberg
3 siblings, 0 replies; 7+ messages in thread
From: Johan Hedberg @ 2013-04-02 17:21 UTC (permalink / raw)
To: linux-bluetooth
From: Marcel Holtmann <marcel@holtmann.org>
With the early init stage during setup, this quirk can be simplified
and kept fully inside the driver.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
---
drivers/bluetooth/btusb.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 1155ee0..b0399f7 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -242,6 +242,7 @@ struct btusb_data {
struct usb_endpoint_descriptor *isoc_rx_ep;
__u8 cmdreq_type;
+ unsigned long driver_info;
unsigned int sco_num;
int isoc_altsetting;
@@ -695,6 +696,20 @@ static int btusb_flush(struct hci_dev *hdev)
return 0;
}
+static int btusb_setup(struct hci_dev *hdev)
+{
+ struct btusb_data *data = hci_get_drvdata(hdev);
+
+ BT_DBG("%s", hdev->name);
+
+ if (data->driver_info & BTUSB_BCM92035) {
+ __u8 val = 0x00;
+ hci_send_cmd(hdev, 0xfc3b, 1, &val);
+ }
+
+ return 0;
+}
+
static int btusb_send_frame(struct sk_buff *skb)
{
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
@@ -992,6 +1007,7 @@ static int btusb_probe(struct usb_interface *intf,
return -ENODEV;
data->cmdreq_type = USB_TYPE_CLASS;
+ data->driver_info = id->driver_info;
data->udev = interface_to_usbdev(intf);
data->intf = intf;
@@ -1022,6 +1038,7 @@ static int btusb_probe(struct usb_interface *intf,
hdev->open = btusb_open;
hdev->close = btusb_close;
hdev->flush = btusb_flush;
+ hdev->setup = btusb_setup;
hdev->send = btusb_send_frame;
hdev->notify = btusb_notify;
@@ -1062,17 +1079,6 @@ static int btusb_probe(struct usb_interface *intf,
data->isoc = NULL;
}
- if (id->driver_info & BTUSB_BCM92035) {
- unsigned char cmd[] = { 0x3b, 0xfc, 0x01, 0x00 };
- struct sk_buff *skb;
-
- skb = bt_skb_alloc(sizeof(cmd), GFP_KERNEL);
- if (skb) {
- memcpy(skb_put(skb, sizeof(cmd)), cmd, sizeof(cmd));
- skb_queue_tail(&hdev->driver_init, skb);
- }
- }
-
if (data->isoc) {
err = usb_driver_claim_interface(&btusb_driver,
data->isoc, data);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v2 3/3] Bluetooth: Remove driver init queue from core
2013-04-02 17:21 [PATCH v2 0/3] Bluetooth: Add HCI init setup stage Johan Hedberg
2013-04-02 17:21 ` [PATCH v2 1/3] Bluetooth: Add driver setup stage for early init Johan Hedberg
2013-04-02 17:21 ` [PATCH v2 2/3] Bluetooth: Convert BCM92035 support to driver setup callback Johan Hedberg
@ 2013-04-02 17:21 ` Johan Hedberg
2013-04-04 8:24 ` [PATCH v2 0/3] Bluetooth: Add HCI init setup stage Johan Hedberg
3 siblings, 0 replies; 7+ messages in thread
From: Johan Hedberg @ 2013-04-02 17:21 UTC (permalink / raw)
To: linux-bluetooth
From: Marcel Holtmann <marcel@holtmann.org>
The driver init queue is no longer needed. This can be all handled
inside the drivers now. So remove it.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 2 --
net/bluetooth/hci_core.c | 23 -----------------------
2 files changed, 25 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index b464b2e..88dd46e 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -268,8 +268,6 @@ struct hci_dev {
struct hci_dev_stats stat;
- struct sk_buff_head driver_init;
-
atomic_t promisc;
struct dentry *debugfs;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index cd93986..2b488ed 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -201,29 +201,9 @@ static void amp_init(struct hci_request *req)
static void hci_init1_req(struct hci_request *req, unsigned long opt)
{
struct hci_dev *hdev = req->hdev;
- struct hci_request init_req;
- struct sk_buff *skb;
BT_DBG("%s %ld", hdev->name, opt);
- /* Driver initialization */
-
- hci_req_init(&init_req, hdev);
-
- /* Special commands */
- while ((skb = skb_dequeue(&hdev->driver_init))) {
- bt_cb(skb)->pkt_type = HCI_COMMAND_PKT;
- skb->dev = (void *) hdev;
-
- if (skb_queue_empty(&init_req.cmd_q))
- bt_cb(skb)->req.start = true;
-
- skb_queue_tail(&init_req.cmd_q, skb);
- }
- skb_queue_purge(&hdev->driver_init);
-
- hci_req_run(&init_req, NULL);
-
/* Reset */
if (!test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks))
hci_reset_req(req, 0);
@@ -2026,7 +2006,6 @@ struct hci_dev *hci_alloc_dev(void)
INIT_DELAYED_WORK(&hdev->discov_off, hci_discov_off);
INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work);
- skb_queue_head_init(&hdev->driver_init);
skb_queue_head_init(&hdev->rx_q);
skb_queue_head_init(&hdev->cmd_q);
skb_queue_head_init(&hdev->raw_q);
@@ -2045,8 +2024,6 @@ EXPORT_SYMBOL(hci_alloc_dev);
/* Free HCI device */
void hci_free_dev(struct hci_dev *hdev)
{
- skb_queue_purge(&hdev->driver_init);
-
/* will free via device release */
put_device(&hdev->dev);
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v2 0/3] Bluetooth: Add HCI init setup stage
2013-04-02 17:21 [PATCH v2 0/3] Bluetooth: Add HCI init setup stage Johan Hedberg
` (2 preceding siblings ...)
2013-04-02 17:21 ` [PATCH v2 3/3] Bluetooth: Remove driver init queue from core Johan Hedberg
@ 2013-04-04 8:24 ` Johan Hedberg
2013-04-04 9:46 ` Johan Hedberg
3 siblings, 1 reply; 7+ messages in thread
From: Johan Hedberg @ 2013-04-04 8:24 UTC (permalink / raw)
To: linux-bluetooth
Hi,
On Tue, Apr 02, 2013, Johan Hedberg wrote:
> This is a resend of Marcel's patches that were sent in November, rebased
> and fixed-up for bluetooth-next. They are a pre-requsite of some
> follow-up work I'm doing to have a simple way of doing synchronous
> single-command requests that will be needed by some HCI driver setup
> routines.
>
> Johan
>
> ----------------------------------------------------------------
> Marcel Holtmann (3):
> Bluetooth: Add driver setup stage for early init
> Bluetooth: Convert BCM92035 support to driver setup callback
> Bluetooth: Remove driver init queue from core
>
> drivers/bluetooth/btusb.c | 28 +++++++++++--------
> include/net/bluetooth/hci_core.h | 3 +-
> net/bluetooth/hci_core.c | 56 ++++++++++++++------------------------
> 3 files changed, 38 insertions(+), 49 deletions(-)
There patches have now been pushed to the bluetooth-next tree.
Johan
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v2 0/3] Bluetooth: Add HCI init setup stage
2013-04-04 8:24 ` [PATCH v2 0/3] Bluetooth: Add HCI init setup stage Johan Hedberg
@ 2013-04-04 9:46 ` Johan Hedberg
2013-04-04 15:22 ` Marcel Holtmann
0 siblings, 1 reply; 7+ messages in thread
From: Johan Hedberg @ 2013-04-04 9:46 UTC (permalink / raw)
To: linux-bluetooth
[-- Attachment #1: Type: text/plain, Size: 1418 bytes --]
Hi Marcel,
On Thu, Apr 04, 2013, Johan Hedberg wrote:
> On Tue, Apr 02, 2013, Johan Hedberg wrote:
> > This is a resend of Marcel's patches that were sent in November, rebased
> > and fixed-up for bluetooth-next. They are a pre-requsite of some
> > follow-up work I'm doing to have a simple way of doing synchronous
> > single-command requests that will be needed by some HCI driver setup
> > routines.
> >
> > Johan
> >
> > ----------------------------------------------------------------
> > Marcel Holtmann (3):
> > Bluetooth: Add driver setup stage for early init
> > Bluetooth: Convert BCM92035 support to driver setup callback
> > Bluetooth: Remove driver init queue from core
> >
> > drivers/bluetooth/btusb.c | 28 +++++++++++--------
> > include/net/bluetooth/hci_core.h | 3 +-
> > net/bluetooth/hci_core.c | 56 ++++++++++++++------------------------
> > 3 files changed, 38 insertions(+), 49 deletions(-)
>
> There patches have now been pushed to the bluetooth-next tree.
I had to temporarily remove these since they cause build breakage when
building as modules:
>> ERROR: "hci_send_cmd" [drivers/bluetooth/btusb.ko] undefined!
It seems the reason is a missing EXPORT_SYMBOL declaration for
hci_send_cmd which the attached patch should fix. I'll also send a
revised patch set of my own function additions since those too will need
this declaration.
Johan
[-- Attachment #2: 0001-Bluetooth-Export-hci_send_cmd-outside-of-the-HCI-cor.patch --]
[-- Type: text/plain, Size: 974 bytes --]
>From 74b40041d3caeae96d9cbdd2f0ac8a478b79c7c1 Mon Sep 17 00:00:00 2001
From: Johan Hedberg <johan.hedberg@intel.com>
Date: Thu, 4 Apr 2013 12:39:53 +0300
Subject: [PATCH] Bluetooth: Export hci_send_cmd outside of the HCI core
This function will be needed by HCI drivers when we enable the driver
setup sequence to use the HCI core functionality. Hence, export the
symbol using EXPORT_SYMBOL.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/hci_core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index a199d63..6dfb2f3 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2538,6 +2538,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param)
return 0;
}
+EXPORT_SYMBOL(hci_send_cmd);
/* Queue a command to an asynchronous HCI request */
void hci_req_add(struct hci_request *req, u16 opcode, u32 plen, void *param)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/3] Bluetooth: Add HCI init setup stage
2013-04-04 9:46 ` Johan Hedberg
@ 2013-04-04 15:22 ` Marcel Holtmann
0 siblings, 0 replies; 7+ messages in thread
From: Marcel Holtmann @ 2013-04-04 15:22 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
>>> This is a resend of Marcel's patches that were sent in November, rebased
>>> and fixed-up for bluetooth-next. They are a pre-requsite of some
>>> follow-up work I'm doing to have a simple way of doing synchronous
>>> single-command requests that will be needed by some HCI driver setup
>>> routines.
>>>
>>> Johan
>>>
>>> ----------------------------------------------------------------
>>> Marcel Holtmann (3):
>>> Bluetooth: Add driver setup stage for early init
>>> Bluetooth: Convert BCM92035 support to driver setup callback
>>> Bluetooth: Remove driver init queue from core
>>>
>>> drivers/bluetooth/btusb.c | 28 +++++++++++--------
>>> include/net/bluetooth/hci_core.h | 3 +-
>>> net/bluetooth/hci_core.c | 56 ++++++++++++++------------------------
>>> 3 files changed, 38 insertions(+), 49 deletions(-)
>>
>> There patches have now been pushed to the bluetooth-next tree.
>
> I had to temporarily remove these since they cause build breakage when
> building as modules:
>
>>> ERROR: "hci_send_cmd" [drivers/bluetooth/btusb.ko] undefined!
>
> It seems the reason is a missing EXPORT_SYMBOL declaration for
> hci_send_cmd which the attached patch should fix. I'll also send a
> revised patch set of my own function additions since those too will need
> this declaration.
can we just switch over to use __hci_cmd_sync() for this as well. I really like to keep hci_send_cmd() internal.
Regards
Marcel
^ permalink raw reply [flat|nested] 7+ messages in thread