Skip to content

Bluetooth: Asynchronous HCI transaction API

Johan Hedberg linux-bluetooth 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest12 patches 8 repliesIn review
  2. v212 patches 0 repliesSuperseded
  3. v112 patches 11 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12Bluetooth: Add initial hooks for HCI transaction supportinclude/net/bluetooth/hci_core.h net/bluetooth/hci_core.c+53 -00 replies
2/12Bluetooth: Add basic start/complete HCI transaction functionsinclude/net/bluetooth/hci_core.h net/bluetooth/hci_core.c+85 -03 replies
3/12Bluetooth: Add hci_transaction_cmd_complete functioninclude/net/bluetooth/hci_core.h net/bluetooth/hci_core.c+66 -02 replies
4/12Bluetooth: Add hci_transaction_from_skb functioninclude/net/bluetooth/hci_core.h net/bluetooth/hci_core.c+29 -00 replies
5/12Bluetooth: Switch from hdev->cmd_q to using transactionsnet/bluetooth/hci_core.c net/bluetooth/hci_event.c net/bluetooth/hci_sock.c+88 -162 replies
6/12Bluetooth: Remove unused hdev->cmd_q HCI command queueinclude/net/bluetooth/hci_core.h net/bluetooth/hci_core.c+0 -60 replies
7/12Bluetooth: Fix mgmt powered indication by using a HCI transactionnet/bluetooth/mgmt.c+34 -91 reply
8/12Bluetooth: Enable HCI transaction support cmd_status 0include/net/bluetooth/hci_core.h net/bluetooth/hci_core.c net/bluetooth/hci_event.c+35 -20 replies
9/12Bluetooth: Add HCI init sequence support for HCI transactionsnet/bluetooth/hci_core.c+44 -30 replies
10/12Bluetooth: Convert hci_request to use HCI transactionsinclude/net/bluetooth/hci_core.h net/bluetooth/hci_core.c net/bluetooth/hci_event.c+11 -1160 replies
11/12Bluetooth: Remove unused hdev->init_last_cmdinclude/net/bluetooth/hci_core.h net/bluetooth/hci_core.c+0 -60 replies
12/12Bluetooth: Remove empty HCI event handlersnet/bluetooth/hci_event.c+0 -1330 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH 00/12 v3] Bluetooth: Asynchronous HCI transaction API

Hi,

v3: Convert to using GFP_KERNEL in two places and another kzmalloc improvement.

Quoted 1 line

From the original cover letter (with updated diffstat):

There are several places in the kernel code where a way of grouping together commands, sending them asynchronously and getting notified when they've completed (or a command failed) would be very useful. We already have the hci_request() API which allows doing this in a blocking fashion but there's nothing for asynchronous needs.

One example is a long outstanding bug with powering adapters on through the Management API where some HCI commands are sent after we already replied with "done" to user space. These commands need to be monitored in some clean way for completion but so far there hasn't been any good API for that.

This patch set introduces an API for doing this kind of asynchronous operations (called "transactions" in the code). It also contains cleanups enabled by this API such as converting the hci_request() implementation to use transactions (e.g. removing the hci_req_done() public function) and unnecessary HCI event callback handlers.

Patch 07/12 is the first example of an actual fix enabled by this new API, fixing the mgmt bug described above. When applied the 1 second artificial delay in the user space mgmt-tester can be removed.

I've tested this patch set with various adapters, ranging from old 1.1 ones to LE capable 4.0 ones. I've also tested that legacy APIs such as the ioctls for doing inquiry and other operations still work as they should, as well as that device discovery, pairing and connecting still works fine through bluetoothd. This still doesn't guarantee that there aren't bugs so any review/testing/feedback is welcome!

Johan Hedberg (12):
Bluetooth: Add initial hooks for HCI transaction support
Bluetooth: Add basic start/complete HCI transaction functions
Bluetooth: Add hci_transaction_cmd_complete function
Bluetooth: Add hci_transaction_from_skb function
Bluetooth: Switch from hdev->cmd_q to using transactions
Bluetooth: Remove unused hdev->cmd_q HCI command queue
Bluetooth: Fix mgmt powered indication by using a HCI transaction
Bluetooth: Enable HCI transaction support cmd_status 0
Bluetooth: Add HCI init sequence support for HCI transactions
Bluetooth: Convert hci_request to use HCI transactions
Bluetooth: Remove unused hdev->init_last_cmd
Bluetooth: Remove empty HCI event handlers

 include/net/bluetooth/hci_core.h |   30 ++-
 net/bluetooth/hci_core.c         |  391 +++++++++++++++++++++++++++++++++-----
 net/bluetooth/hci_event.c        |  225 ++--------------------
 net/bluetooth/hci_sock.c         |    5 +-
 net/bluetooth/mgmt.c             |   43 ++++-
 5 files changed, 424 insertions(+), 270 deletions(-)