Continuing the Xbox One Bluetooth controller debugging

Message ID CABBYNZ+cfdym=m+Xn2kT_E74Vq81XTKB5mzv_JOWa7vvcHXVrg@mail.gmail.com
State New
Headers show

Commit Message

Luiz Augusto von Dentz Nov. 30, 2016, 2:54 p.m.
Hi,

On Wed, Nov 30, 2016 at 11:42 AM, Anthony Bourguignon
<contact@toniob.net> wrote:
> Le mardi 29 novembre 2016 à 20:51 -0800, Cameron Gutman a écrit :

>> Hi,

>>

>> I'm interesting in continuing the debugging of the Xbox One S

>> controller's issues with the BlueZ stack (original report [0]).

>> I confirmed the issue still affects v4.9-rc7. I've also tried

>> Vinicius's patch from [1] applied on v4.9-rc7 without success.

>>

>> The controller is updated with the latest firmware and connects

>> reliably to (at least) macOS Sierra, Windows 10 14393, Android

>> 6.0.1, 7.0, and 7.1.1 (including devices using 3.10 and 3.18

>> based kernels).

>>

>> I'm happy to collect logs, test other patches, etc.

>

> Steam has made a patch referencing the xbox one S controller :

> https://github.com/ValveSoftware/steamlink-sdk/commit/d6afa93787217033a0f0f5db5f557b252c36260e#diff-

> 45ba5a41f43606276c9bf9018eed43c2

>

> You should check this.


That is a big hammer, instead I was thinking in just ignoring the
Unknown option since basic mode is default, so please check with the
following patch.

-- 
Luiz Augusto von Dentz

Comments

Cameron Gutman Dec. 1, 2016, 5:01 a.m. | #1
On Wed, 2016-11-30 at 16:54 +0200, Luiz Augusto von Dentz wrote:
> Hi,

> 

> On Wed, Nov 30, 2016 at 11:42 AM, Anthony Bourguignon

> <contact@toniob.net> wrote:

> > Le mardi 29 novembre 2016 à 20:51 -0800, Cameron Gutman a écrit :

> > > Hi,

> > > 

> > > I'm interesting in continuing the debugging of the Xbox One S

> > > controller's issues with the BlueZ stack (original report [0]).

> > > I confirmed the issue still affects v4.9-rc7. I've also tried

> > > Vinicius's patch from [1] applied on v4.9-rc7 without success.

> > > 

> > > The controller is updated with the latest firmware and connects

> > > reliably to (at least) macOS Sierra, Windows 10 14393, Android

> > > 6.0.1, 7.0, and 7.1.1 (including devices using 3.10 and 3.18

> > > based kernels).

> > > 

> > > I'm happy to collect logs, test other patches, etc.

> > 

> > Steam has made a patch referencing the xbox one S controller :

> > https://github.com/ValveSoftware/steamlink-sdk/commit/d6afa93787217

> > 033a0f0f5db5f557b252c36260e#diff-

> > 45ba5a41f43606276c9bf9018eed43c2

> > 

> > You should check this.

> 

> That is a big hammer, instead I was thinking in just ignoring the

> Unknown option since basic mode is default, so please check with the

> following patch.

> 


No dice. I think ignoring it won't work because it's the controller
itself initiating the disconnect. Attached an hcidump log with the
patch applied and another with disable_ertm set to 1.
HCI sniffer - Bluetooth packet analyzer ver 5.43
device: hci0 snap_len: 1500 filter: 0xffffffffffffffff
> HCI Event: Vendor (0xff) plen 2
> HCI Event: Vendor (0xff) plen 2
> HCI Event: Connect Request (0x04) plen 10
    bdaddr C8:3F:26:0D:A4:57 class 0x000508 type ACL
< HCI Command: Accept Connection Request (0x01|0x0009) plen 7
    bdaddr C8:3F:26:0D:A4:57 role 0x00
    Role: Master
> HCI Event: Command Status (0x0f) plen 4
    Accept Connection Request (0x01|0x0009) status 0x00 ncmd 1
> HCI Event: Role Change (0x12) plen 8
    status 0x00 bdaddr C8:3F:26:0D:A4:57 role 0x00
    Role: Master
> HCI Event: Vendor (0xff) plen 4
> HCI Event: Connect Complete (0x03) plen 11
    status 0x00 handle 256 bdaddr C8:3F:26:0D:A4:57 type ACL encrypt 0x00
< HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2
    handle 256
> HCI Event: Command Status (0x0f) plen 4
    Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1
> HCI Event: Max Slots Change (0x1b) plen 3
    handle 256 slots 5
> HCI Event: Read Remote Supported Features (0x0b) plen 11
    status 0x00 handle 256
    Features: 0xbf 0x3e 0x8d 0xfe 0xdb 0xfd 0x7b 0x87
< HCI Command: Read Remote Extended Features (0x01|0x001c) plen 3
    handle 256 page 1
> HCI Event: Command Status (0x0f) plen 4
    Read Remote Extended Features (0x01|0x001c) status 0x00 ncmd 1
> HCI Event: Link Key Request (0x17) plen 6
    bdaddr C8:3F:26:0D:A4:57
< HCI Command: Link Key Request Reply (0x01|0x000b) plen 22
    bdaddr C8:3F:26:0D:A4:57 key 4723E829AE0274800390B1AE4AA4504D
> HCI Event: Command Complete (0x0e) plen 10
    Link Key Request Reply (0x01|0x000b) ncmd 1
    status 0x00 bdaddr C8:3F:26:0D:A4:57
> HCI Event: Read Remote Extended Features (0x23) plen 13
    status 0x00 handle 256 page 1 max 3
    Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
< HCI Command: Remote Name Request (0x01|0x0019) plen 10
    bdaddr C8:3F:26:0D:A4:57 mode 2 clkoffset 0x0000
< ACL data: handle 256 flags 0x00 dlen 10
    L2CAP(s): Info req: type 2
> HCI Event: Command Status (0x0f) plen 4
    Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
> HCI Event: Encrypt Change (0x08) plen 4
    status 0x00 handle 256 encrypt 0x01
< HCI Command: Read Encryption Key Size (0x05|0x0008) plen 2
> HCI Event: Command Complete (0x0e) plen 7
    Read Encryption Key Size (0x05|0x0008) ncmd 1
> ACL data: handle 256 flags 0x02 dlen 12
    L2CAP(s): Connect req: psm 17 scid 0x0040
< ACL data: handle 256 flags 0x00 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0040 result 1 status 0
      Connection pending - No futher information available
< ACL data: handle 256 flags 0x00 dlen 10
    L2CAP(s): Info req: type 2
> ACL data: handle 256 flags 0x02 dlen 16
    L2CAP(s): Info rsp: type 2 result 0
      Extended feature mask 0x0010
        Streaming mode
> HCI Event: Remote Name Req Complete (0x07) plen 255
    status 0x00 bdaddr C8:3F:26:0D:A4:57 name 'Xbox Wireless Controller'
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> ACL data: handle 256 flags 0x02 dlen 16
    L2CAP(s): Info rsp: type 2 result 0
      Extended feature mask 0x0010
        Streaming mode
< ACL data: handle 256 flags 0x00 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0040 result 0 status 0
      Connection successful
< ACL data: handle 256 flags 0x00 dlen 23
    L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 11
      RFC 0x00 (Basic) 
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> ACL data: handle 256 flags 0x02 dlen 16
    L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 4
      MTU 1480 
< ACL data: handle 256 flags 0x00 dlen 18
    L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 4
      MTU 1480 
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> ACL data: handle 256 flags 0x02 dlen 15
    L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 3 clen 1
      Failure - unknown options
      RFC 
< ACL data: handle 256 flags 0x00 dlen 12
    L2CAP(s): Disconn req: dcid 0x0040 scid 0x0040
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> ACL data: handle 256 flags 0x02 dlen 12
    L2CAP(s): Disconn rsp: dcid 0x0040 scid 0x0040
< HCI Command: Disconnect (0x01|0x0006) plen 3
    handle 256 reason 0x13
    Reason: Remote User Terminated Connection
> HCI Event: Command Status (0x0f) plen 4
    Disconnect (0x01|0x0006) status 0x00 ncmd 1
> HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 256 reason 0x16
    Reason: Connection Terminated by Local Host
HCI sniffer - Bluetooth packet analyzer ver 5.43
device: hci0 snap_len: 1500 filter: 0xffffffffffffffff
> HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 256 reason 0x08
    Reason: Connection Timeout
< HCI Command: Write Scan Enable (0x03|0x001a) plen 1
    enable 2
> HCI Event: Command Complete (0x0e) plen 4
    Write Scan Enable (0x03|0x001a) ncmd 2
    status 0x00
> HCI Event: Vendor (0xff) plen 2
> HCI Event: Vendor (0xff) plen 2
> HCI Event: Connect Request (0x04) plen 10
    bdaddr C8:3F:26:0D:A4:57 class 0x000508 type ACL
< HCI Command: Accept Connection Request (0x01|0x0009) plen 7
    bdaddr C8:3F:26:0D:A4:57 role 0x00
    Role: Master
> HCI Event: Command Status (0x0f) plen 4
    Accept Connection Request (0x01|0x0009) status 0x00 ncmd 1
> HCI Event: Role Change (0x12) plen 8
    status 0x00 bdaddr C8:3F:26:0D:A4:57 role 0x00
    Role: Master
> HCI Event: Vendor (0xff) plen 4
> HCI Event: Connect Complete (0x03) plen 11
    status 0x00 handle 256 bdaddr C8:3F:26:0D:A4:57 type ACL encrypt 0x00
< HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2
    handle 256
> HCI Event: Command Status (0x0f) plen 4
    Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1
< HCI Command: Write Scan Enable (0x03|0x001a) plen 1
    enable 0
> HCI Event: Command Complete (0x0e) plen 4
    Write Scan Enable (0x03|0x001a) ncmd 2
    status 0x00
> HCI Event: Max Slots Change (0x1b) plen 3
    handle 256 slots 5
> HCI Event: Read Remote Supported Features (0x0b) plen 11
    status 0x00 handle 256
    Features: 0xbf 0x3e 0x8d 0xfe 0xdb 0xfd 0x7b 0x87
< HCI Command: Read Remote Extended Features (0x01|0x001c) plen 3
    handle 256 page 1
> HCI Event: Command Status (0x0f) plen 4
    Read Remote Extended Features (0x01|0x001c) status 0x00 ncmd 1
> HCI Event: Link Key Request (0x17) plen 6
    bdaddr C8:3F:26:0D:A4:57
< HCI Command: Link Key Request Reply (0x01|0x000b) plen 22
    bdaddr C8:3F:26:0D:A4:57 key 8EFE498AD09511DDD149C146B3E43C0C
> HCI Event: Command Complete (0x0e) plen 10
    Link Key Request Reply (0x01|0x000b) ncmd 1
    status 0x00 bdaddr C8:3F:26:0D:A4:57
> HCI Event: Read Remote Extended Features (0x23) plen 13
    status 0x00 handle 256 page 1 max 3
    Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
< HCI Command: Remote Name Request (0x01|0x0019) plen 10
    bdaddr C8:3F:26:0D:A4:57 mode 2 clkoffset 0x0000
< ACL data: handle 256 flags 0x00 dlen 10
    L2CAP(s): Info req: type 2
> HCI Event: Command Status (0x0f) plen 4
    Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
> HCI Event: Encrypt Change (0x08) plen 4
    status 0x00 handle 256 encrypt 0x01
< HCI Command: Read Encryption Key Size (0x05|0x0008) plen 2
> HCI Event: Command Complete (0x0e) plen 7
    Read Encryption Key Size (0x05|0x0008) ncmd 1
> ACL data: handle 256 flags 0x02 dlen 12
    L2CAP(s): Connect req: psm 17 scid 0x0040
< ACL data: handle 256 flags 0x00 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0040 result 1 status 0
      Connection pending - No futher information available
< ACL data: handle 256 flags 0x00 dlen 10
    L2CAP(s): Info req: type 2
> ACL data: handle 256 flags 0x02 dlen 16
    L2CAP(s): Info rsp: type 2 result 0
      Extended feature mask 0x0010
        Streaming mode
> HCI Event: Remote Name Req Complete (0x07) plen 255
    status 0x00 bdaddr C8:3F:26:0D:A4:57 name 'Xbox Wireless Controller'
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> ACL data: handle 256 flags 0x02 dlen 16
    L2CAP(s): Info rsp: type 2 result 0
      Extended feature mask 0x0010
        Streaming mode
< ACL data: handle 256 flags 0x00 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0040 result 0 status 0
      Connection successful
< ACL data: handle 256 flags 0x00 dlen 12
    L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 0
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> ACL data: handle 256 flags 0x02 dlen 16
    L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 4
      MTU 1480 
< ACL data: handle 256 flags 0x00 dlen 18
    L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 4
      MTU 1480 
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> ACL data: handle 256 flags 0x02 dlen 14
    L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 0
      Success
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> ACL data: handle 256 flags 0x02 dlen 12
    L2CAP(s): Connect req: psm 19 scid 0x0041
< ACL data: handle 256 flags 0x00 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0041 scid 0x0041 result 1 status 2
      Connection pending - Authorization pending
< ACL data: handle 256 flags 0x00 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0041 scid 0x0041 result 0 status 0
      Connection successful
< ACL data: handle 256 flags 0x00 dlen 12
    L2CAP(s): Config req: dcid 0x0041 flags 0x00 clen 0
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> ACL data: handle 256 flags 0x02 dlen 16
    L2CAP(s): Config req: dcid 0x0041 flags 0x00 clen 4
      MTU 1480 
< ACL data: handle 256 flags 0x00 dlen 18
    L2CAP(s): Config rsp: scid 0x0041 flags 0x00 result 0 clen 4
      MTU 1480 
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> ACL data: handle 256 flags 0x02 dlen 14
    L2CAP(s): Config rsp: scid 0x0041 flags 0x00 result 0 clen 0
      Success
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> HCI Event: Max Slots Change (0x1b) plen 3
    handle 256 slots 1
< ACL data: handle 256 flags 0x00 dlen 6
    L2CAP(d): cid 0x0040 len 2 [psm 17]
      HIDP: Get report: Input report
> HCI Event: Mode Change (0x14) plen 6
    status 0x00 handle 256 mode 0x02 interval 12
    Mode: Sniff
> ACL data: handle 256 flags 0x02 dlen 22
    L2CAP(d): cid 0x0041 len 18 [psm 19]
      HIDP: Data: Input report
> ACL data: handle 256 flags 0x02 dlen 22
    L2CAP(d): cid 0x0041 len 18 [psm 19]
      HIDP: Data: Input report
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> ACL data: handle 256 flags 0x02 dlen 5
    L2CAP(d): cid 0x0040 len 1 [psm 17]
      HIDP: Handshake: Invalid report ID
< ACL data: handle 256 flags 0x00 dlen 6
    L2CAP(d): cid 0x0040 len 2 [psm 17]
      HIDP: Get report: Input report
< HCI Command: Exit Sniff Mode (0x02|0x0004) plen 2
    handle 256
> HCI Event: Command Status (0x0f) plen 4
    Exit Sniff Mode (0x02|0x0004) status 0x00 ncmd 1
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> HCI Event: Mode Change (0x14) plen 6
    status 0x00 handle 256 mode 0x00 interval 0
    Mode: Active
> HCI Event: Max Slots Change (0x1b) plen 3
    handle 256 slots 5
> HCI Event: Max Slots Change (0x1b) plen 3
    handle 256 slots 1
> ACL data: handle 256 flags 0x02 dlen 5
    L2CAP(d): cid 0x0040 len 1 [psm 17]
      HIDP: Handshake: Invalid report ID
< ACL data: handle 256 flags 0x00 dlen 6
    L2CAP(d): cid 0x0040 len 2 [psm 17]
      HIDP: Get report: Input report
> HCI Event: Mode Change (0x14) plen 6
    status 0x00 handle 256 mode 0x02 interval 12
    Mode: Sniff
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 256 packets 1
> ACL data: handle 256 flags 0x02 dlen 5
    L2CAP(d): cid 0x0040 len 1 [psm 17]
      HIDP: Handshake: Invalid report ID
> ACL data: handle 256 flags 0x02 dlen 7
    L2CAP(d): cid 0x0041 len 3 [psm 19]
      HIDP: Data: Input report

Patch hide | download patch | download mbox

From c7e471a082d6fc3cbff42f6e194f64d791a9b1c5 Mon Sep 17 00:00:00 2001
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date: Wed, 30 Nov 2016 16:45:13 +0200
Subject: [PATCH] Bluetooth: L2CAP: Ignore Unknown option error for basic mode

Some devices send Unknown option in case it only support basic mode
which will cause the channel the be disconnect, so instead the code
now just check if the Unknown option is RFC and the channel mode is
basic and ignore the error.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 net/bluetooth/l2cap_core.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 74abc53..c0ddace 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -4206,6 +4206,17 @@  static inline int l2cap_config_rsp(struct l2cap_conn *conn,
 			if (result != L2CAP_CONF_SUCCESS)
 				goto done;
 			break;
+	}
+
+	case L2CAP_CONF_UNKNOWN:
+		/* Ignore unkwown option for RFC in case of basic mode as it
+		 * is considered the default mode:
+		 * BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part A] page 96:
+		 * The Basic L2CAP mode is the default.
+		 */
+		if (rsp->data == L2CAP_CONF_RFC &&
+		    chan->mode == L2CAP_MODE_BASIC) {
+			break;
 		}
 
 	default:
-- 
2.9.3