Skip to content

Commit 035a960

Browse files
bgodavarholtmann
authored andcommitted
Bluetooth: hci_qca: Disable IBS state machine and flush Tx buffer
During hci down we observed IBS sleep commands are queued in the Tx buffer and hci_uart_write_work is sending data to the chip which is not required as the chip is powered off. This patch will disable IBS and flush the Tx buffer before we turn off the chip. Signed-off-by: Balakrishna Godavarthi <[email protected]> Reviewed-by: Matthias Kaehlcke <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 78e8fa2 commit 035a960

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

drivers/bluetooth/hci_qca.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,16 +771,17 @@ static int qca_enqueue(struct hci_uart *hu, struct sk_buff *skb)
771771
/* Prepend skb with frame type */
772772
memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
773773

774+
spin_lock_irqsave(&qca->hci_ibs_lock, flags);
775+
774776
/* Don't go to sleep in middle of patch download or
775777
* Out-Of-Band(GPIOs control) sleep is selected.
776778
*/
777779
if (!test_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags)) {
778780
skb_queue_tail(&qca->txq, skb);
781+
spin_unlock_irqrestore(&qca->hci_ibs_lock, flags);
779782
return 0;
780783
}
781784

782-
spin_lock_irqsave(&qca->hci_ibs_lock, flags);
783-
784785
/* Act according to current state */
785786
switch (qca->tx_ibs_state) {
786787
case HCI_IBS_TX_AWAKE:
@@ -1275,6 +1276,18 @@ static const struct qca_vreg_data qca_soc_data = {
12751276

12761277
static void qca_power_shutdown(struct hci_uart *hu)
12771278
{
1279+
struct qca_data *qca = hu->priv;
1280+
unsigned long flags;
1281+
1282+
/* From this point we go into power off state. But serial port is
1283+
* still open, stop queueing the IBS data and flush all the buffered
1284+
* data in skb's.
1285+
*/
1286+
spin_lock_irqsave(&qca->hci_ibs_lock, flags);
1287+
clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
1288+
qca_flush(hu);
1289+
spin_unlock_irqrestore(&qca->hci_ibs_lock, flags);
1290+
12781291
host_set_baudrate(hu, 2400);
12791292
qca_send_power_pulse(hu, QCA_WCN3990_POWEROFF_PULSE);
12801293
qca_power_setup(hu, false);

0 commit comments

Comments
 (0)