• Pauli Virtanen's avatar
    Bluetooth: ISO: do not emit new LE Create CIS if previous is pending · 7f74563e
    Pauli Virtanen authored
    LE Create CIS command shall not be sent before all CIS Established
    events from its previous invocation have been processed. Currently it is
    sent via hci_sync but that only waits for the first event, but there can
    be multiple.
    
    Make it wait for all events, and simplify the CIS creation as follows:
    
    Add new flag HCI_CONN_CREATE_CIS, which is set if Create CIS has been
    sent for the connection but it is not yet completed.
    
    Make BT_CONNECT state to mean the connection wants Create CIS.
    
    On events after which new Create CIS may need to be sent, send it if
    possible and some connections need it. These events are:
    hci_connect_cis, iso_connect_cfm, hci_cs_le_create_cis,
    hci_le_cis_estabilished_evt.
    
    The Create CIS status/completion events shall queue new Create CIS only
    if at least one of the connections transitions away from BT_CONNECT, so
    that we don't loop if controller is sending bogus events.
    
    This fixes sending multiple CIS Create for the same CIS in the
    "ISO AC 6(i) - Success" BlueZ test case:
    
    < HCI Command: LE Create Co.. (0x08|0x0064) plen 9  #129 [hci0]
            Number of CIS: 2
            CIS Handle: 257
            ACL Handle: 42
            CIS Handle: 258
            ACL Handle: 42
    > HCI Event: Command Status (0x0f) plen 4           #130 [hci0]
          LE Create Connected Isochronous Stream (0x08|0x0064) ncmd 1
            Status: Success (0x00)
    > HCI Event: LE Meta Event (0x3e) plen 29           #131 [hci0]
          LE Connected Isochronous Stream Established (0x19)
            Status: Success (0x00)
            Connection Handle: 257
            ...
    < HCI Command: LE Setup Is.. (0x08|0x006e) plen 13  #132 [hci0]
            ...
    > HCI Event: Command Complete (0x0e) plen 6         #133 [hci0]
          LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1
            ...
    < HCI Command: LE Create Co.. (0x08|0x0064) plen 5  #134 [hci0]
            Number of CIS: 1
            CIS Handle: 258
            ACL Handle: 42
    > HCI Event: Command Status (0x0f) plen 4           #135 [hci0]
          LE Create Connected Isochronous Stream (0x08|0x0064) ncmd 1
            Status: ACL Connection Already Exists (0x0b)
    > HCI Event: LE Meta Event (0x3e) plen 29           #136 [hci0]
          LE Connected Isochronous Stream Established (0x19)
            Status: Success (0x00)
            Connection Handle: 258
            ...
    
    Fixes: c09b80be ("Bluetooth: hci_conn: Fix not waiting for HCI_EVT_LE_CIS_ESTABLISHED")
    Signed-off-by: default avatarPauli Virtanen <pav@iki.fi>
    Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
    7f74563e
hci_event.c 193 KB