2022-05-25 08:29:31

by Bastian Germann

[permalink] [raw]
Subject: [PATCH v2 0/3] arm64: allwinner: a64: add bluetooth support for Pinebook

Pinebook uses RTL8723CS for WiFi and bluetooth. Unfortunately RTL8723CS
has broken BT-4.1 support, so it requires a quirk.

Add a quirk, wire up 8723CS support in btrtl and enable bluetooth
in Pinebook dts.

This series was sent in July 2020 by Vasily Khoruzhick.
This is a rebase on the current tree.
I have tested it to work on the Pinebook.

Changelog:
v2:
* Rebase
* Add uart-has-rtscts to device tree as requested by reviewer

Vasily Khoruzhick (3):
Bluetooth: Add new quirk for broken local ext features max_page
Bluetooth: btrtl: add support for the RTL8723CS
arm64: allwinner: a64: enable Bluetooth On Pinebook

.../dts/allwinner/sun50i-a64-pinebook.dts | 13 ++
drivers/bluetooth/btrtl.c | 120 +++++++++++++++++-
drivers/bluetooth/btrtl.h | 5 +
drivers/bluetooth/hci_h5.c | 4 +
include/net/bluetooth/hci.h | 7 +
net/bluetooth/hci_event.c | 4 +-
6 files changed, 148 insertions(+), 5 deletions(-)

--
2.36.1




2022-05-25 11:57:58

by Bastian Germann

[permalink] [raw]
Subject: [PATCH v2 1/3] Bluetooth: Add new quirk for broken local ext features max_page

From: Vasily Khoruzhick <[email protected]>

Some adapters (e.g. RTL8723CS) advertise that they have more than
2 pages for local ext features, but they don't support any features
declared in these pages. RTL8723CS reports max_page = 2 and declares
support for sync train and secure connection, but it responds with
either garbage or with error in status on corresponding commands.

Signed-off-by: Vasily Khoruzhick <[email protected]>
[rebase on current tree]
Signed-off-by: Bastian Germann <[email protected]>
---
include/net/bluetooth/hci.h | 7 +++++++
net/bluetooth/hci_event.c | 4 +++-
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 69ef31cea582..af26e8051905 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -265,6 +265,13 @@ enum {
* runtime suspend, because event filtering takes place there.
*/
HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL,
+
+ /* When this quirk is set, max_page for local extended features
+ * is set to 1, even if controller reports higher number. Some
+ * controllers (e.g. RTL8723CS) report more pages, but they
+ * don't actually support features declared there.
+ */
+ HCI_QUIRK_BROKEN_LOCAL_EXT_FTR_MAX_PAGE,
};

/* HCI device flags */
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 66451661283c..52b358c33344 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -837,7 +837,9 @@ static u8 hci_cc_read_local_ext_features(struct hci_dev *hdev, void *data,
if (rp->status)
return rp->status;

- if (hdev->max_page < rp->max_page)
+ if (!test_bit(HCI_QUIRK_BROKEN_LOCAL_EXT_FTR_MAX_PAGE,
+ &hdev->quirks) &&
+ hdev->max_page < rp->max_page)
hdev->max_page = rp->max_page;

if (rp->page < HCI_MAX_PAGES)
--
2.36.1



2022-06-02 16:53:20

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH v2 1/3] Bluetooth: Add new quirk for broken local ext features max_page

Hi Bastian,

> Some adapters (e.g. RTL8723CS) advertise that they have more than
> 2 pages for local ext features, but they don't support any features
> declared in these pages. RTL8723CS reports max_page = 2 and declares
> support for sync train and secure connection, but it responds with
> either garbage or with error in status on corresponding commands.


please include btmon output for the garbage and/or error.

>
> Signed-off-by: Vasily Khoruzhick <[email protected]>
> [rebase on current tree]
> Signed-off-by: Bastian Germann <[email protected]>
> ---
> include/net/bluetooth/hci.h | 7 +++++++
> net/bluetooth/hci_event.c | 4 +++-
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 69ef31cea582..af26e8051905 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -265,6 +265,13 @@ enum {
> * runtime suspend, because event filtering takes place there.
> */
> HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL,
> +
> + /* When this quirk is set, max_page for local extended features
> + * is set to 1, even if controller reports higher number. Some
> + * controllers (e.g. RTL8723CS) report more pages, but they
> + * don't actually support features declared there.
> + */
> + HCI_QUIRK_BROKEN_LOCAL_EXT_FTR_MAX_PAGE,
> };

Can we just call it _BROKEN_LOCAL_EXT_FEATURES_PAGE_2.

Now with that said, is Secure Connections really broken? We need that bit to indicate support for this.

Regards

Marcel


2022-11-05 07:15:16

by Vasily Khoruzhick

[permalink] [raw]
Subject: Re: [PATCH v2 1/3] Bluetooth: Add new quirk for broken local ext features max_page

On Thu, Jun 2, 2022 at 9:10 AM Marcel Holtmann <[email protected]> wrote:
>
> Hi Bastian,

Hi Marcel,

> > Some adapters (e.g. RTL8723CS) advertise that they have more than
> > 2 pages for local ext features, but they don't support any features
> > declared in these pages. RTL8723CS reports max_page = 2 and declares
> > support for sync train and secure connection, but it responds with
> > either garbage or with error in status on corresponding commands.
>
>
> please include btmon output for the garbage and/or error.

We had it in v1 thread, here is relevant part:

< HCI Command: Read Local Extend.. (0x04|0x0004) plen 1 #228 [hci0] 6.889869
Page: 2
> HCI Event: Command Complete (0x0e) plen 14 #229 [hci0] 6.890487
Read Local Extended Features (0x04|0x0004) ncmd 2
Status: Success (0x00)
Page: 2/2
Features: 0x5f 0x03 0x00 0x00 0x00 0x00 0x00 0x00
Connectionless Slave Broadcast - Master
Connectionless Slave Broadcast - Slave
Synchronization Train
Synchronization Scan
Inquiry Response Notification Event
Coarse Clock Adjustment
Secure Connections (Controller Support)
Ping
< HCI Command: Delete Stored Lin.. (0x03|0x0012) plen 7 #230 [hci0] 6.890559
Address: 00:00:00:00:00:00 (OUI 00-00-00)
Delete all: 0x01
> HCI Event: Command Complete (0x0e) plen 6 #231 [hci0] 6.891170
Delete Stored Link Key (0x03|0x0012) ncmd 2
Status: Success (0x00)
Num keys: 0
< HCI Command: Read Synchronizat.. (0x03|0x0077) plen 0 #232 [hci0] 6.891199
> HCI Event: Command Complete (0x0e) plen 9 #233 [hci0] 6.891788
Read Synchronization Train Parameters (0x03|0x0077) ncmd 2
invalid packet size
01 ac bd 11 80 80 ......
= Close Index: 00:E0:4C:23:99:87 [hci0] 6.891832

> >
> > Signed-off-by: Vasily Khoruzhick <[email protected]>
> > [rebase on current tree]
> > Signed-off-by: Bastian Germann <[email protected]>
> > ---
> > include/net/bluetooth/hci.h | 7 +++++++
> > net/bluetooth/hci_event.c | 4 +++-
> > 2 files changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> > index 69ef31cea582..af26e8051905 100644
> > --- a/include/net/bluetooth/hci.h
> > +++ b/include/net/bluetooth/hci.h
> > @@ -265,6 +265,13 @@ enum {
> > * runtime suspend, because event filtering takes place there.
> > */
> > HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL,
> > +
> > + /* When this quirk is set, max_page for local extended features
> > + * is set to 1, even if controller reports higher number. Some
> > + * controllers (e.g. RTL8723CS) report more pages, but they
> > + * don't actually support features declared there.
> > + */
> > + HCI_QUIRK_BROKEN_LOCAL_EXT_FTR_MAX_PAGE,
> > };
>
> Can we just call it _BROKEN_LOCAL_EXT_FEATURES_PAGE_2.
>
> Now with that said, is Secure Connections really broken? We need that bit to indicate support for this.

I don't really see the point in testing any 4.1 features if the chip
vendor claims that they are broken.

I understand your intention to get the max out of the hardware, but it
doesn't look like a good idea to me to use something that the vendor
claims to be broken.

Regards,
Vasily

> Regards
>
> Marcel
>