Bluetooth: Block SCO disconnect operation on BT_CLOSED state.  Have maximum blocking time for shutdown operation as DISCONNECT_TIMEOUT.   During this period when SCO connection closes, the userspace will be updated on the close operation. Existing approach of immidiate return on shutdown call can cause synchronization issues on SCO state between kernel and userspace. This happens when disconnect operation takes more time at kernel space.
Bluetooth: Disable sniff when the subrate values doesnt match.  Found there is possibility of sniff subrate collision with some IOT devices. When this collision happned if the remote device send subrate values that doesn't match with DUT supported values exit sniff mode. This will allow DUT to reconfigure sniff after idle time.
Bluetooth: hidp: use dest address from session info.  While hid device unpair process, we are trying to access released socket as apart of getting hci device which results a kernel panic.
Bluetooth: Adding HCI Dev lock for set_active and set_sniff routines.  When data transfer is in progress on a ACL connection, all the time the set_active_mode API will be called to update the timer for next sniff mode. If there is ACL disconnect triggered from remote side, there is possibility of hci connection delete when set_active routine in progress. Found a condition where delete API destroyed the wake lock, which is used in set_active API. In codition leads to crash in set_wakelock API. The current change is to lock hdev, before set_active and set_sniff APIs are called. This avoids the race condition in accessing hci connection, while delete in progress and vice versa.
Bluetooth: Avoid a case where sleep is getting called in soft irq context.  While turning off BT, sleep is getting called in the soft isr context from work queue which is queued from a code section guarded under the bh lock, To resolve this released the bh lock before queing the work, as it wont impact any BT functionality.
bluetooth: Check for hcon during during sock_close.  It is possible that during BT OFF operation the hcon could be released from a tasklet context while we are trying to send the l2cap disconnect req. Make sure that hcon is valid before dereferencing it during l2cap disconnect req.
Bluetooth: Handle ACL buffers sharing between multiple connections.  The BT host has fixed set of buffers to send data to SoC, generic value is 5. When a connection, like A2DP playback is ready to send data it fills one of the buffer available and sends to SoC. Once SoC got acknowledged from remote side that the data received it updates the host and the buffer is freed. Till host is acknowledged the send Complete info, the data buffer is locked for that data transfer. The below is the example for buffers availability.
Bluetooth: Validate session before rfcomm_session_del In rfcomm_session_put API the session count is decremented and when it is equal to zero rfcomm_session_del is called where session is removed from sessions list and freed. The current change is verify the existance of session in list before acting session. The avoids the possibility of action on a deleted session, which causes crash.
Bluetooth : Ignore incomming events when the hci device is down.  In error conditions Adapter state machine via Bluez tries to reset the hci device, during that in some rare scenario if some pending event comes from riva, the command complete apis tries to access some already freed memory in reset sequence.
Bluetooth : hidp: Get the valid hci_conn while unlink.  Since the context where unlink will be called is unaware of validity of hci_conn pointer, fetch the valid hci_conn before unlink.
Bluetooth: Hold wakelock until BT idle timer kicks in.  Holding a wakelock avoids suspend power collapse, whichallow the BT idle timer to kick in, which eventually initiates BT low power modes.
Bluetooth: mgmt: Fix device_connected sending order.  The mgmt_ev_device_connected signal must be sent before any event indications happen for sockets associated with the connection. Otherwise e.g. device authorization for the sockets will fail with ENOTCONN as user space things that there is no baseband link.  This patch fixes the issue by ensuring that the device_connected event is sent (if it hasn't been so already) as soon as the first ACL data packet arrives from the remote device.