All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btusb: Do not require hardcoded interface numbers
@ 2023-02-07 11:57 Tomasz Moń
  2023-02-07 12:42 ` bluez.test.bot
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Tomasz Moń @ 2023-02-07 11:57 UTC (permalink / raw)
  To: linux-bluetooth, Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz
  Cc: Carles Cufí, Tomasz Moń

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(-)

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: Bluetooth: btusb: Do not require hardcoded interface numbers
  2023-02-07 11:57 [PATCH] Bluetooth: btusb: Do not require hardcoded interface numbers Tomasz Moń
@ 2023-02-07 12:42 ` bluez.test.bot
  2023-02-09 21:32 ` [PATCH] " Luiz Augusto von Dentz
  2023-02-14 20:40 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2023-02-07 12:42 UTC (permalink / raw)
  To: linux-bluetooth, tomasz.mon

[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Do not require hardcoded interface numbers
  2023-02-07 11:57 [PATCH] Bluetooth: btusb: Do not require hardcoded interface numbers Tomasz Moń
  2023-02-07 12:42 ` bluez.test.bot
@ 2023-02-09 21:32 ` Luiz Augusto von Dentz
  2023-02-10  6:31   ` Tomasz Moń
  2023-02-14 20:40 ` patchwork-bot+bluetooth
  2 siblings, 1 reply; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2023-02-09 21:32 UTC (permalink / raw)
  To: Tomasz Moń
  Cc: linux-bluetooth, Marcel Holtmann, Johan Hedberg, Carles Cufí

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
>


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Do not require hardcoded interface numbers
  2023-02-09 21:32 ` [PATCH] " Luiz Augusto von Dentz
@ 2023-02-10  6:31   ` Tomasz Moń
  0 siblings, 0 replies; 5+ messages in thread
From: Tomasz Moń @ 2023-02-10  6:31 UTC (permalink / raw)
  To: Luiz Augusto von Dentz
  Cc: linux-bluetooth, Marcel Holtmann, Johan Hedberg, Carles Cufí

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.

-- 
Tomasz Moń        | Senior Firmware Engineer
P +48 882 826 111 | Wrocław, Poland
nordicsemi.com    | devzone.nordicsemi.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Do not require hardcoded interface numbers
  2023-02-07 11:57 [PATCH] Bluetooth: btusb: Do not require hardcoded interface numbers Tomasz Moń
  2023-02-07 12:42 ` bluez.test.bot
  2023-02-09 21:32 ` [PATCH] " Luiz Augusto von Dentz
@ 2023-02-14 20:40 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2023-02-14 20:40 UTC (permalink / raw)
  To: =?utf-8?q?Tomasz_Mo=C5=84_=3Ctomasz=2Emon=40nordicsemi=2Eno=3E?=
  Cc: linux-bluetooth, marcel, johan.hedberg, luiz.dentz, carles.cufi

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-14 20:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07 11:57 [PATCH] Bluetooth: btusb: Do not require hardcoded interface numbers Tomasz Moń
2023-02-07 12:42 ` bluez.test.bot
2023-02-09 21:32 ` [PATCH] " Luiz Augusto von Dentz
2023-02-10  6:31   ` Tomasz Moń
2023-02-14 20:40 ` patchwork-bot+bluetooth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.