Bluetooth: Add debugfs option to enable runtime debug statements
Subsystems (2)
Marcel Holtmann
maintainerRFC v3 1/1 Bluetooth: Add debugfs option to enable runtime debug statements
--- include/net/bluetooth/bluetooth.h | 10 +++++ net/bluetooth/Kconfig | 7 +++ net/bluetooth/af_bluetooth.c | 2 + net/bluetooth/lib.c | 73 +++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+)
include/net/bluetooth/bluetooth.h +10 -0
@@ -129,6 +129,10 @@ void bt_warn(const char *fmt, ...); __printf(1, 2)void bt_err (const char *fmt, ...); __printf(1, 2) +#if IS_ENABLED (CONFIG_BT_DEBUGFS_OPTION ) +void bt_dbg (const char *fmt, ...); +__printf(1, 2) +#endif void bt_warn_ratelimited (const char *fmt, ...); __printf(1, 2)void bt_err_ratelimited (const char *fmt, ...);
@@ -136,7 +140,11 @@ void bt_err_ratelimited(const char *fmt, ...);#define BT_INFO (fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__)#define BT_WARN (fmt, ...) bt_warn(fmt "\n", ##__VA_ARGS__)#define BT_ERR (fmt, ...) bt_err(fmt "\n", ##__VA_ARGS__) +#if IS_ENABLED (CONFIG_BT_DEBUGFS_OPTION ) +#define BT_DBG (fmt, ...) bt_dbg(fmt "\n", ##__VA_ARGS__) +#else #define BT_DBG (fmt, ...) pr_debug(fmt "\n", ##__VA_ARGS__) +#endif #define bt_dev_info (hdev, fmt, ...) \ BT_INFO("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
@@ -393,6 +401,8 @@ void bt_procfs_cleanup(struct net *net, const char *name);extern struct dentry *bt_debugfs; +void bt_lib_debugfs_init (void ); +int l2cap_init (void );void l2cap_exit (void );
net/bluetooth/Kconfig +7 -0
@@ -128,4 +128,11 @@ config BT_DEBUGFS Provide extensive information about internal Bluetooth states in debugfs. + When dynamic debug is not used, then this option also includes + a switch to enable/disable internal debug statements. + +config BT_DEBUGFS_OPTION + bool + default y if BT_DEBUGFS && !DYNAMIC_DEBUG + source "drivers/bluetooth/Kconfig"
net/bluetooth/af_bluetooth.c +2 -0
@@ -731,6 +731,8 @@ static int __init bt_init(void) bt_debugfs =debugfs_create_dir ("bluetooth" ,NULL ); +bt_lib_debugfs_init (); +bt_leds_init (); err =bt_sysfs_init ();
net/bluetooth/lib.c +73 -0
91 lines not on this page · raw message
Signature · 1 line
2.24.1
Marcel Holtmann
maintainerHi,
Quoted 7 lines
Signed-off-by Marcel Holtmann <[email protected]>---
include/net/bluetooth/bluetooth.h | 10 +++++ net/bluetooth/Kconfig | 7 +++ net/bluetooth/af_bluetooth.c | 2 + net/bluetooth/lib.c | 73 +++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+)
does anybody have any comments on this. It is not the final solution, but as an interim it might be a good start.
I have not seen any kbuild issues popping up. However I like to get some Tested-By, Reviewed-By lines added to the patch and I can send a patch version with proper commit message if there is interest in getting this upstream.
Regards
Marcel
Hi Marcel,
I have some cycle today and tomorrow and I can run quick test.
Is there any procedure you want me to test other than enabling kernel config and enable via debugfs? Let me know.
Regards,
Tedd
On 2/12/20, 11:31 PM, "Marcel Holtmann" <[email protected] on behalf of [email protected]> wrote:
Hi,
> Signed-off-by: Marcel Holtmann <[email protected]> > ---
> include/net/bluetooth/bluetooth.h | 10 +++++
> net/bluetooth/Kconfig | 7 +++
> net/bluetooth/af_bluetooth.c | 2 +
> net/bluetooth/lib.c | 73 +++++++++++++++++++++++++++++++
> 4 files changed, 92 insertions(+)
does anybody have any comments on this. It is not the final solution, but as an interim it might be a good start.
I have not seen any kbuild issues popping up. However I like to get some Tested-By, Reviewed-By lines added to the patch and I can send a patch version with proper commit message if there is interest in getting this upstream.
Regards
Marcel
Hi Marcel,
Quoted 10 lines · Marcel Holtmann
Hi,
Quoted 7 lines
Signed-off-by Marcel Holtmann <[email protected]>---
include/net/bluetooth/bluetooth.h | 10 +++++ net/bluetooth/Kconfig | 7 +++ net/bluetooth/af_bluetooth.c | 2 + net/bluetooth/lib.c | 73 +++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+)
Quoted 3 lines
does anybody have any comments on this. It is not the final solution, but as an interim it might be a good start.
I did quick test and it worked fine. Below is the testing output. Let me know if need further testing..
root@tester-VirtualBox:/sys/kernel/debug/bluetooth# dmesg -c root@tester-VirtualBox:/sys/kernel/debug/bluetooth# cat debug_enable N root@tester-VirtualBox:/sys/kernel/debug/bluetooth# echo 'Y' > debug_enable root@tester-VirtualBox:/sys/kernel/debug/bluetooth# hciconfig -a hci0: Type: Primary Bus: USB BD Address: 9C:DA:3E:F2:8E:46 ACL MTU: 1021:4 SCO MTU: 96:6 UP RUNNING RX bytes:1367 acl:0 sco:0 events:68 errors:0 TX bytes:3729 acl:0 sco:0 commands:68 errors:0 Features: 0xbf 0xfe 0x0f 0xfe 0xdb 0xff 0x7b 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH SNIFF Link mode: SLAVE ACCEPT Name: 'tester-VirtualBox' Class: 0x0c0000 Service Classes: Rendering, Capturing Device Class: Miscellaneous, HCI Version: 5.0 (0x9) Revision: 0x100 LMP Version: 5.0 (0x9) Subversion: 0x100 Manufacturer: Intel Corp. (2)
root@tester-VirtualBox:/sys/kernel/debug/bluetooth# dmesg [ 891.432216] Bluetooth: sock 00000000ec80bfe5 [ 891.432448] Bluetooth: cmd 800448d2 arg 565442b6c260 [ 891.432465] Bluetooth: channel 2 len 36 [ 891.432480] Bluetooth: cmd 800448d3 arg 565441d4b860 [ 891.432485] Bluetooth: 0 [ 891.432489] Bluetooth: hci0 orig refcnt 5 [ 891.432493] Bluetooth: hci0 orig refcnt 6 [ 891.434491] Bluetooth: sock 00000000a8d1e746 [ 891.434511] Bluetooth: sock 00000000a8d1e746 sk 00000000ea127ff9 [ 891.434514] Bluetooth: 0 [ 891.434517] Bluetooth: hci0 orig refcnt 5 [ 891.434527] Bluetooth: channel 2 len 36 [ 891.434538] Bluetooth: sk 00000000ea127ff9, opt 2 [ 891.434546] Bluetooth: sk 00000000ea127ff9, opt 2 [ 891.434558] Bluetooth: sock 00000000a8d1e746 sk 00000000ea127ff9 [ 891.434577] Bluetooth: hci0 cmd_cnt 1 cmd queued 1 [ 891.434584] Bluetooth: hci0 type 1 len 3 [ 891.434588] Bluetooth: hdev 00000000124fe225 len 3 [ 891.434593] Bluetooth: hci0 [ 891.532680] Bluetooth: intf 00000000ed2b072f [ 891.532682] Bluetooth: intf 00000000600468f3 [ 891.532683] Bluetooth: hci0 [ 891.532696] Bluetooth: hci0 [ 891.532702] Bluetooth: hci0 [ 891.533095] Bluetooth: hci0 urb 0000000015f7b113 status 0 count 3 [ 891.534575] Bluetooth: hci0 urb 00000000f939b99d status 0 count 64 [ 891.535214] Bluetooth: hci0 urb 00000000f939b99d status 0 count 64 [ 891.535885] Bluetooth: hci0 urb 00000000f939b99d status 0 count 64 [ 891.536831] Bluetooth: hci0 urb 00000000f939b99d status 0 count 62 [ 891.536852] Bluetooth: hci0 [ 891.536854] Bluetooth: hdev 00000000124fe225 len 254 [ 891.536860] Bluetooth: hci0 Event packet [ 891.536862] Bluetooth: hci0 status 0x00 [ 891.536864] Bluetooth: opcode 0x0c14 status 0x00 [ 891.536865] Bluetooth: hci0 opcode 0x0c14 [ 891.536880] Bluetooth: sock 00000000a8d1e746, sk 00000000ea127ff9 [ 891.536885] Bluetooth: sk 00000000ea127ff9, opt 2 [ 891.536905] Bluetooth: sock 00000000a8d1e746 sk 00000000ea127ff9 [ 891.536907] Bluetooth: channel 2 len 10 [ 891.536909] Bluetooth: hci0 orig refcnt 6 [ 891.536921] Bluetooth: sock 000000004b3ad07d [ 891.536927] Bluetooth: sock 000000004b3ad07d sk 00000000ea127ff9 [ 891.536928] Bluetooth: 0 [ 891.536929] Bluetooth: hci0 orig refcnt 5 [ 891.536932] Bluetooth: channel 2 len 36 [ 891.536935] Bluetooth: sk 00000000ea127ff9, opt 2 [ 891.536937] Bluetooth: sk 00000000ea127ff9, opt 2 [ 891.536941] Bluetooth: sock 000000004b3ad07d sk 00000000ea127ff9 [ 891.536946] Bluetooth: hci0 cmd_cnt 1 cmd queued 1 [ 891.536948] Bluetooth: hci0 type 1 len 3 [ 891.536949] Bluetooth: hdev 00000000124fe225 len 3 [ 891.536950] Bluetooth: hci0 [ 891.537315] Bluetooth: hci0 urb 00000000bf489ae9 status 0 count 3 [ 891.537789] Bluetooth: hci0 urb 00000000f939b99d status 0 count 9 [ 891.537807] Bluetooth: hci0 [ 891.537808] Bluetooth: hdev 00000000124fe225 len 9 [ 891.537812] Bluetooth: hci0 Event packet [ 891.537813] Bluetooth: hci0 status 0x00 [ 891.537814] Bluetooth: hci0 class 0x0c0000 [ 891.537816] Bluetooth: opcode 0x0c23 status 0x00 [ 891.537817] Bluetooth: hci0 opcode 0x0c23 [ 891.537827] Bluetooth: sock 000000004b3ad07d, sk 00000000ea127ff9 [ 891.537832] Bluetooth: sk 00000000ea127ff9, opt 2 [ 891.537853] Bluetooth: sock 000000004b3ad07d sk 00000000ea127ff9 [ 891.537855] Bluetooth: channel 2 len 10 [ 891.537856] Bluetooth: hci0 orig refcnt 6 [ 891.537865] Bluetooth: sock 00000000847c4083 [ 891.537870] Bluetooth: sock 00000000847c4083 sk 00000000ea127ff9 [ 891.537871] Bluetooth: 0 [ 891.537872] Bluetooth: hci0 orig refcnt 5 [ 891.537874] Bluetooth: channel 2 len 36 [ 891.537877] Bluetooth: sk 00000000ea127ff9, opt 2 [ 891.537879] Bluetooth: sk 00000000ea127ff9, opt 2 [ 891.537882] Bluetooth: sock 00000000847c4083 sk 00000000ea127ff9 [ 891.537886] Bluetooth: hci0 cmd_cnt 1 cmd queued 1 [ 891.537888] Bluetooth: hci0 type 1 len 3 [ 891.537889] Bluetooth: hdev 00000000124fe225 len 3 [ 891.537890] Bluetooth: hci0 [ 891.538149] Bluetooth: hci0 urb 00000000bf489ae9 status 0 count 3 [ 891.538822] Bluetooth: hci0 urb 00000000f939b99d status 0 count 14 [ 891.538854] Bluetooth: hci0 [ 891.538856] Bluetooth: hdev 00000000124fe225 len 14 [ 891.538862] Bluetooth: hci0 Event packet [ 891.538864] Bluetooth: hci0 status 0x00 [ 891.538866] Bluetooth: opcode 0x1001 status 0x00 [ 891.538868] Bluetooth: hci0 opcode 0x1001 [ 891.538883] Bluetooth: sock 00000000847c4083, sk 00000000ea127ff9 [ 891.538889] Bluetooth: sk 00000000ea127ff9, opt 2 [ 891.538924] Bluetooth: sock 00000000847c4083 sk 00000000ea127ff9 [ 891.538927] Bluetooth: channel 2 len 10 [ 891.538930] Bluetooth: hci0 orig refcnt 6 [ 891.539051] Bluetooth: sock 00000000ec80bfe5 sk 0000000035240669 [ 891.539053] Bluetooth: channel 2 len 10 [ 893.959807] Bluetooth: intf 00000000600468f3 [ 893.961620] Bluetooth: hci0 urb 00000000f939b99d status -2 count 0 [ 893.963498] Bluetooth: hci0 urb 00000000abc1f0d6 status -2 count 0 [ 893.964657] Bluetooth: hci0 urb 000000002a96d38f status -2 count 0 [ 893.964993] Bluetooth: intf 00000000ed2b072f root@tester-VirtualBox:/sys/kernel/debug/bluetooth# dmesg -c > /dev/null 2>&1 root@tester-VirtualBox:/sys/kernel/debug/bluetooth# echo 'N' > debug_enable root@tester-VirtualBox:/sys/kernel/debug/bluetooth# hciconfig -a hci0: Type: Primary Bus: USB BD Address: 9C:DA:3E:F2:8E:46 ACL MTU: 1021:4 SCO MTU: 96:6 UP RUNNING RX bytes:1644 acl:0 sco:0 events:71 errors:0 TX bytes:3738 acl:0 sco:0 commands:71 errors:0 Features: 0xbf 0xfe 0x0f 0xfe 0xdb 0xff 0x7b 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH SNIFF Link mode: SLAVE ACCEPT Name: 'tester-VirtualBox' Class: 0x0c0000 Service Classes: Rendering, Capturing Device Class: Miscellaneous, HCI Version: 5.0 (0x9) Revision: 0x100 LMP Version: 5.0 (0x9) Subversion: 0x100 Manufacturer: Intel Corp. (2)
root@tester-VirtualBox:/sys/kernel/debug/bluetooth# dmesg root@tester-VirtualBox:/sys/kernel/debug/bluetooth#
Quoted 8 lines
I have not seen any kbuild issues popping up. However I like to get some Tested-By, Reviewed-By lines added to the patch and I can send a patch version with proper commit message if there is interest in getting this upstream.
Regards
Marcel