Bluetooth: HCI: Add HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN quirk
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH 1/2 Bluetooth: HCI: Add HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN quirk
From: Luiz Augusto von Dentz <[email protected]>
This adds HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN quirk which can be used to mark HCI_Enhanced_Setup_Synchronous_Connection as broken even if its support command bit are set since some controller report it as supported but the command don't work properly with some configurations (e.g. BT_VOICE_TRANSPARENT/mSBC).
--- include/net/bluetooth/hci.h | 9 +++++++++ include/net/bluetooth/hci_core.h | 8 ++++++-- net/bluetooth/hci_conn.c | 2 +- net/bluetooth/sco.c | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-)
include/net/bluetooth/hci.h +9 -0
@@ -265,6 +265,15 @@ enum {* runtime suspend, because event filtering takes place there. */ HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL , + +/* +* When this quirk is set, disables the use of +* HCI_OP_ENHANCED_SETUP_SYNC_CONN command to setup SCO connections. +* +* This quirk can be set before hci_register_dev is called or +* during the hdev->setup vendor callback. +*/ + HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN, };/* HCI device flags */
include/net/bluetooth/hci_core.h +6 -2
@@ -1492,8 +1492,12 @@ void hci_conn_del_sysfs(struct hci_conn *conn);#define privacy_mode_capable (dev) (use_ll_privacy(dev) && \ (hdev->commands[39] & 0x04)) -/* Use enhanced synchronous connection if command is supported */ -#define enhanced_sco_capable (dev) ((dev)->commands[29] & 0x08) +/* Use enhanced synchronous connection if command is supported and its quirk +* has not been set. +*/ +#define enhanced_sync_conn_capable (dev) \ + (((dev)->commands[29] & 0x08) && \ + !test_bit(HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN, &(dev)->quirks))/* Use ext scanning if set ext scan param and ext scan enable is supported */ #define use_ext_scan (dev) (((dev)->commands[37] & 0x20) && \
net/bluetooth/hci_conn.c +1 -1
@@ -481,7 +481,7 @@ static bool hci_setup_sync_conn(struct hci_conn *conn, __u16 handle)bool hci_setup_sync (struct hci_conn *conn,__u16 handle) { -if (enhanced_sco_capable (conn->hdev)) +if (enhanced_sync_conn_capable (conn->hdev))return hci_enhanced_setup_sync_conn (conn, handle);return hci_setup_sync_conn (conn, handle);
net/bluetooth/sco.c +1 -1
@@ -885,7 +885,7 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, err = -EBADFD ;break ; } -if (enhanced_sco_capable (hdev) && +if (enhanced_sync_conn_capable (hdev) && voice.setting ==BT_VOICE_TRANSPARENT )sco_pi (sk)->codec.id =BT_CODEC_TRANSPARENT ;hci_dev_put (hdev);
Signature · 1 line
2.35.1
Luiz Augusto von Dentz
maintainerPATCH 2/2 Bluetooth: Print broken quirks
From: Luiz Augusto von Dentz <[email protected]>
This prints warnings for controllers setting broken quirks to increase their visibility and warn about broken controllers firmware that probably needs updates to behave properly.
--- net/bluetooth/hci_sync.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
net/bluetooth/hci_sync.c +44 -0
@@ -3825,6 +3825,48 @@ static int hci_init_sync(struct hci_dev *hdev)return 0 ; } +#define HCI_BROKEN (_quirk, _desc) \ +{ \ + .quirk = _quirk, \ + .desc = _desc, \ +} + +struct hci_broken { +unsigned long quirk; +const char *desc; +} hci_broken_table[] = { +HCI_BROKEN (HCI_QUIRK_BROKEN_LOCAL_COMMANDS , +"HCI Read Local Supported Commands not supported" ), +HCI_BROKEN (HCI_QUIRK_BROKEN_STORED_LINK_KEY , +"HCI Delete Stored Link Key command is advertised, " +"but not supported." ), +HCI_BROKEN (HCI_QUIRK_BROKEN_ERR_DATA_REPORTING , +"HCI Read Default Erroneous Data Reporting command is " +"advertised, but not supported." ), +HCI_BROKEN (HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER , +"HCI Read Transmit Power Level command is advertised, " +"but not supported." ), +HCI_BROKEN (HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL , +"HCI Set Event Filter command not supported." ), +HCI_BROKEN (HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN , +"HCI Enhanced Setup Synchronous Connection command is " +"advertised, but not supported." ) +}; + +static void hci_dev_print_broken (struct hci_dev *hdev) +{ +int i; + +bt_dev_dbg (hdev,"" ); + +for (i =0 ; i <ARRAY_SIZE (hci_broken_table); i++) { +struct hci_broken *broken = &hci_broken_table[i]; + +if (test_bit (broken->quirk, &hdev->quirks)) +bt_dev_warn (hdev,"%s" , broken->desc); + } +} +int hci_dev_open_sync (struct hci_dev *hdev) {int ret =0 ;
@@ -4031,6 +4073,8 @@ int hci_dev_open_sync(struct hci_dev *hdev) } done: +hci_dev_print_broken (hdev); +return ret; }
Signature · 1 line
2.35.1
kernel test robot
build botRe: [PATCH 2/2] Bluetooth: Print broken quirks
I love your patch! Perhaps something to improve:
Hi Luiz,
I love your patch! Perhaps something to improve:
[auto build test WARNING on bluetooth-next/master]
[also build test WARNING on next-20220325]
[cannot apply to bluetooth/master v5.17]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Luiz-Augusto-von-Dentz/Bluetooth-HCI-Add-HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN-quirk/20220326-051551 base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master config: x86_64-randconfig-s021 (https://download.01.org/0day-ci/archive/20220326/[email protected]/config) compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 reproduce: # apt-get install sparse # sparse version: v0.6.4-dirty # https://github.com/0day-ci/linux/commit/5ca7f4a3fcd3584b663e15b4c3d8230918b8971d git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Luiz-Augusto-von-Dentz/Bluetooth-HCI-Add-HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN-quirk/20220326-051551 git checkout 5ca7f4a3fcd3584b663e15b4c3d8230918b8971d # save the config file to linux build tree mkdir build_dir make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
sparse warnings: (new ones prefixed by >>)
>> net/bluetooth/hci_sync.c:3837:3: sparse: sparse: symbol 'hci_broken_table' was not declared. Should it be static?
vim +/hci_broken_table +3837 net/bluetooth/hci_sync.c
3833
3834 struct hci_broken {
3835 unsigned long quirk;
3836 const char *desc;
> 3837 } hci_broken_table[] = { 3838 HCI_BROKEN(HCI_QUIRK_BROKEN_LOCAL_COMMANDS,
3839 "HCI Read Local Supported Commands not supported"),
3840 HCI_BROKEN(HCI_QUIRK_BROKEN_STORED_LINK_KEY,
3841 "HCI Delete Stored Link Key command is advertised, "
3842 "but not supported."),
3843 HCI_BROKEN(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING,
3844 "HCI Read Default Erroneous Data Reporting command is "
3845 "advertised, but not supported."),
3846 HCI_BROKEN(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
3847 "HCI Read Transmit Power Level command is advertised, "
3848 "but not supported."),
3849 HCI_BROKEN(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL,
3850 "HCI Set Event Filter command not supported."),
3851 HCI_BROKEN(HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN,
3852 "HCI Enhanced Setup Synchronous Connection command is "
3853 "advertised, but not supported.")
3854 };
3855
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
Marcel Holtmann
maintainerRe: [PATCH 2/2] Bluetooth: Print broken quirks
In reply to Luiz Augusto von DentzHi Luiz,
Quoted 34 lines
This prints warnings for controllers setting broken quirks to increase their visibility and warn about broken controllers firmware that probably needs updates to behave properly.
Signed-off-by Luiz Augusto von Dentz <[email protected]>---
net/bluetooth/hci_sync.c| 44 ++++++++++++++++++++++++++++++++++++++++1 file changed, 44 insertions(+)net/bluetooth/hci_sync.c +17
-0@@ -3825,6 +3825,48 @@ static int hci_init_sync(struct hci_dev *hdev)return 0 ; } +#define HCI_BROKEN (_quirk, _desc) \ +{ \ + .quirk = _quirk, \ + .desc = _desc, \ +} + +struct hci_broken { +unsigned long quirk; +const char *desc; +} hci_broken_table[] = { +HCI_BROKEN (HCI_QUIRK_BROKEN_LOCAL_COMMANDS , +"HCI Read Local Supported Commands not supported" ), +HCI_BROKEN (HCI_QUIRK_BROKEN_STORED_LINK_KEY , +"HCI Delete Stored Link Key command is advertised, " +"but not supported." ), + HCI_BROKEN(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, + "HCI Read Default Erroneous Data Reporting command is "
net/bluetooth/hci_sync.c static int hci_init_sync(struct hci_dev *hdev) · line 3854
Quoted 10 lines
net/bluetooth/hci_sync.c +10
-0+ "advertised, but not supported."), +HCI_BROKEN (HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER , +"HCI Read Transmit Power Level command is advertised, " +"but not supported." ), +HCI_BROKEN (HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL , +"HCI Set Event Filter command not supported." ), +HCI_BROKEN (HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN , +"HCI Enhanced Setup Synchronous Connection command is " + "advertised, but not supported.") +};
static const hci_quirk_broken
And then HCI_QUIRK_BROKEN(LOCAL_COMMANDS, “text”),
Quoted 22 lines
net/bluetooth/hci_sync.c +15
-0+ +static void hci_dev_print_broken (struct hci_dev *hdev) +{ +int i; + +bt_dev_dbg (hdev,"" ); + +for (i =0 ; i <ARRAY_SIZE (hci_broken_table); i++) { +struct hci_broken *broken = &hci_broken_table[i]; + +if (test_bit (broken->quirk, &hdev->quirks)) +bt_dev_warn (hdev,"%s" , broken->desc); + } +} +int hci_dev_open_sync (struct hci_dev *hdev) {int ret =0 ;@@ -4031,6 +4073,8 @@ int hci_dev_open_sync(struct hci_dev *hdev) }done:
net/bluetooth/hci_sync.c int hci_dev_open_sync(struct hci_dev *hdev) · line 4077
Quoted 2 lines
net/bluetooth/hci_sync.c +2
-0+hci_dev_print_broken (hdev); +
This is wrong. It gets printed all the time and no matter if success or failure. This needs to go after hdev->setup.
Regards
Marcel
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=626431
---Test result---
Test Summary:
CheckPatch FAIL 3.90 seconds GitLint PASS 1.92 seconds SubjectPrefix PASS 1.75 seconds BuildKernel PASS 31.26 seconds BuildKernel32 PASS 27.90 seconds Incremental Build with patchesPASS 43.49 seconds TestRunner: Setup PASS 493.04 seconds TestRunner: l2cap-tester PASS 15.79 seconds TestRunner: bnep-tester PASS 6.39 seconds TestRunner: mgmt-tester PASS 101.39 seconds TestRunner: rfcomm-tester PASS 7.86 seconds TestRunner: sco-tester PASS 7.79 seconds TestRunner: smp-tester PASS 7.81 seconds TestRunner: userchan-tester PASS 6.51 seconds
Details
##############################
Test: CheckPatch - FAIL - 3.90 seconds
Run checkpatch.pl script with rule in .checkpatch.conf
[2/2] Bluetooth: Print broken quirks\WARNING:SPLIT_STRING: quoted string split across lines #113: FILE: net/bluetooth/hci_sync.c:3842:
+ "HCI Delete Stored Link Key command is advertised, "
+ "but not supported."),
WARNING:SPLIT_STRING: quoted string split across lines #116: FILE: net/bluetooth/hci_sync.c:3845:
+ "HCI Read Default Erroneous Data Reporting command is "
+ "advertised, but not supported."),
WARNING:SPLIT_STRING: quoted string split across lines #119: FILE: net/bluetooth/hci_sync.c:3848:
+ "HCI Read Transmit Power Level command is advertised, "
+ "but not supported."),
WARNING:SPLIT_STRING: quoted string split across lines #124: FILE: net/bluetooth/hci_sync.c:3853:
+ "HCI Enhanced Setup Synchronous Connection command is "
+ "advertised, but not supported.")
total: 0 errors, 4 warnings, 0 checks, 56 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/12792078.patch has style problems, please review.
NOTE: Ignored message types: UNKNOWN_COMMIT_ID
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
---
Regards,
Linux Bluetooth