Message ID | 20230207115741.122854-1-tomasz.mon@nordicsemi.no (mailing list archive) |
---|---|
State | Accepted |
Commit | dbf27f4a6adb530999726340bd133a22f57779c9 |
Headers | show |
Series | Bluetooth: btusb: Do not require hardcoded interface numbers | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
tedd_an/CheckPatch | success | CheckPatch PASS |
tedd_an/GitLint | success | Gitlint PASS |
tedd_an/SubjectPrefix | success | Gitlint PASS |
tedd_an/BuildKernel | success | BuildKernel PASS |
tedd_an/CheckAllWarning | success | CheckAllWarning PASS |
tedd_an/CheckSparse | success | CheckSparse PASS |
tedd_an/CheckSmatch | success | CheckSparse PASS |
tedd_an/BuildKernel32 | success | BuildKernel32 PASS |
tedd_an/TestRunnerSetup | success | TestRunnerSetup PASS |
tedd_an/TestRunner_l2cap-tester | success | TestRunner PASS |
tedd_an/TestRunner_iso-tester | success | TestRunner PASS |
tedd_an/TestRunner_bnep-tester | success | TestRunner PASS |
tedd_an/TestRunner_mgmt-tester | success | TestRunner PASS |
tedd_an/TestRunner_rfcomm-tester | success | TestRunner PASS |
tedd_an/TestRunner_sco-tester | success | TestRunner PASS |
tedd_an/TestRunner_ioctl-tester | success | TestRunner PASS |
tedd_an/TestRunner_mesh-tester | success | TestRunner PASS |
tedd_an/TestRunner_smp-tester | success | TestRunner PASS |
tedd_an/TestRunner_userchan-tester | success | TestRunner PASS |
tedd_an/IncrementalBuild | success | Incremental Build PASS |
This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series: PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=719475 ---Test result--- Test Summary: CheckPatch PASS 0.92 seconds GitLint PASS 0.33 seconds SubjectPrefix PASS 0.11 seconds BuildKernel PASS 30.90 seconds CheckAllWarning PASS 33.91 seconds CheckSparse PASS 38.08 seconds CheckSmatch PASS 106.45 seconds BuildKernel32 PASS 29.68 seconds TestRunnerSetup PASS 428.94 seconds TestRunner_l2cap-tester PASS 15.94 seconds TestRunner_iso-tester PASS 16.64 seconds TestRunner_bnep-tester PASS 5.43 seconds TestRunner_mgmt-tester PASS 108.68 seconds TestRunner_rfcomm-tester PASS 8.69 seconds TestRunner_sco-tester PASS 7.99 seconds TestRunner_ioctl-tester PASS 9.37 seconds TestRunner_mesh-tester PASS 6.89 seconds TestRunner_smp-tester PASS 7.89 seconds TestRunner_userchan-tester PASS 5.68 seconds IncrementalBuild PASS 27.68 seconds --- Regards, Linux Bluetooth
Hi Tomasz, On Tue, Feb 7, 2023 at 3:58 AM Tomasz Moń <tomasz.mon@nordicsemi.no> wrote: > > Remove hardcoded interface number check because Bluetooth specification > since version 4.0 only recommends and no longer requires specific > interface numbers. > > While earlier Bluetooth versions, i.e. 2.1 + EDR and 3.0 + HS, contain > required configuration table in Volume 4 - Host Controller Interface > Part B - USB Transport Layer, Bluetooth Core Specification Addendum 2 > changes the table from required to recommended configuration. Can you give it a little more context, is this supposed to be the case for LE only controllers? I assume this shouldn't cause any regressions for other controllers right? > Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no> > --- > drivers/bluetooth/btusb.c | 10 +++------- > 1 file changed, 3 insertions(+), 7 deletions(-) > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > index 2ad4efdd9e40..5110d26cff7a 100644 > --- a/drivers/bluetooth/btusb.c > +++ b/drivers/bluetooth/btusb.c > @@ -3830,13 +3830,9 @@ static int btusb_probe(struct usb_interface *intf, > > BT_DBG("intf %p id %p", intf, id); > > - /* interface numbers are hardcoded in the spec */ > - if (intf->cur_altsetting->desc.bInterfaceNumber != 0) { > - if (!(id->driver_info & BTUSB_IFNUM_2)) > - return -ENODEV; > - if (intf->cur_altsetting->desc.bInterfaceNumber != 2) > - return -ENODEV; > - } > + if ((id->driver_info & BTUSB_IFNUM_2) && > + (intf->cur_altsetting->desc.bInterfaceNumber != 2)) > + return -ENODEV; > > ifnum_base = intf->cur_altsetting->desc.bInterfaceNumber; > > -- > 2.39.1 >
On Thu, 2023-02-09 at 13:32 -0800, Luiz Augusto von Dentz wrote: > On Tue, Feb 7, 2023 at 3:58 AM Tomasz Moń <tomasz.mon@nordicsemi.no> wrote: > > Remove hardcoded interface number check because Bluetooth specification > > since version 4.0 only recommends and no longer requires specific > > interface numbers. > > > > While earlier Bluetooth versions, i.e. 2.1 + EDR and 3.0 + HS, contain > > required configuration table in Volume 4 - Host Controller Interface > > Part B - USB Transport Layer, Bluetooth Core Specification Addendum 2 > > changes the table from required to recommended configuration. > > Can you give it a little more context, is this supposed to be the case > for LE only controllers? I assume this shouldn't cause any regressions > for other controllers right? Why do you think it is the case for LE only controllers? The Bluetooth Host Controller interface is not limited to LE. I believe this doesn't cause any regressions for other controllers. Because I don't know anything nor have access to the Apple-specific (Broadcom) devices that have BTUSB_IFNUM_2 flag set, I left the BTUSB_IFNUM_2 check intact. It might be that the BTUSB_IFNUM_2 is not necessary after all (and was only added because of this no longer necessary hardcoded interface check), but you really need the actual hardware to tell. Note that this patch is merely removing the no longer necessary check and otherwise leaving the communication intact. The hardcoded interface check is preventing btusb from attaching to Bluetooth HCI controller in a composite device that have some other interface under the number 0. The composite devices that previously failed due to check do work with this patch, because the specification (Bluetooth Core Specification Version 5.3 Vol 4, Part B 2.2.2 Controller function in a composite device) says host **should** address control packets to Interface (and not Device) while at the same time the specification explicitly says that the device **shall** recognize the HCI command packets directed to Device. Because **should** equals to recommended and **shall** is mandatory requirement, the btusb driver is actually compliant even if it always directs the control transfers to Device.
Hello: This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>: On Tue, 7 Feb 2023 12:57:41 +0100 you wrote: > Remove hardcoded interface number check because Bluetooth specification > since version 4.0 only recommends and no longer requires specific > interface numbers. > > While earlier Bluetooth versions, i.e. 2.1 + EDR and 3.0 + HS, contain > required configuration table in Volume 4 - Host Controller Interface > Part B - USB Transport Layer, Bluetooth Core Specification Addendum 2 > changes the table from required to recommended configuration. > > [...] Here is the summary with links: - Bluetooth: btusb: Do not require hardcoded interface numbers https://git.kernel.org/bluetooth/bluetooth-next/c/dbf27f4a6adb You are awesome, thank you!
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 2ad4efdd9e40..5110d26cff7a 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -3830,13 +3830,9 @@ static int btusb_probe(struct usb_interface *intf, BT_DBG("intf %p id %p", intf, id); - /* interface numbers are hardcoded in the spec */ - if (intf->cur_altsetting->desc.bInterfaceNumber != 0) { - if (!(id->driver_info & BTUSB_IFNUM_2)) - return -ENODEV; - if (intf->cur_altsetting->desc.bInterfaceNumber != 2) - return -ENODEV; - } + if ((id->driver_info & BTUSB_IFNUM_2) && + (intf->cur_altsetting->desc.bInterfaceNumber != 2)) + return -ENODEV; ifnum_base = intf->cur_altsetting->desc.bInterfaceNumber;
Remove hardcoded interface number check because Bluetooth specification since version 4.0 only recommends and no longer requires specific interface numbers. While earlier Bluetooth versions, i.e. 2.1 + EDR and 3.0 + HS, contain required configuration table in Volume 4 - Host Controller Interface Part B - USB Transport Layer, Bluetooth Core Specification Addendum 2 changes the table from required to recommended configuration. Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no> --- drivers/bluetooth/btusb.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)