Skip to content

Commit 10fe40e

Browse files
Mark-yw Chenholtmann
authored andcommitted
Bluetooth: btmtksdio: transmit packet according to status TX_EMPTY
Each packet should be sent out until the device emits the TX_EMPTY signal to the host, that is firmware people suggested to add to meet the actual firmware behavior and that is compatible among all the devices. Co-developed-by: Sean Wang <[email protected]> Signed-off-by: Sean Wang <[email protected]> Signed-off-by: Mark-yw Chen <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 184ea40 commit 10fe40e

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

drivers/bluetooth/btmtksdio.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ struct btmtksdio_dev {
103103
struct work_struct txrx_work;
104104
unsigned long tx_state;
105105
struct sk_buff_head txq;
106+
bool hw_tx_ready;
106107

107108
struct sk_buff *evt_skb;
108109

@@ -229,6 +230,7 @@ static int btmtksdio_tx_packet(struct btmtksdio_dev *bdev,
229230
sdio_hdr->reserved = cpu_to_le16(0);
230231
sdio_hdr->bt_type = hci_skb_pkt_type(skb);
231232

233+
bdev->hw_tx_ready = false;
232234
err = sdio_writesb(bdev->func, MTK_REG_CTDR, skb->data,
233235
round_up(skb->len, MTK_SDIO_BLOCK_SIZE));
234236
if (err < 0)
@@ -417,15 +419,6 @@ static void btmtksdio_txrx_work(struct work_struct *work)
417419
/* Disable interrupt */
418420
sdio_writel(bdev->func, C_INT_EN_CLR, MTK_REG_CHLPCR, 0);
419421

420-
while ((skb = skb_dequeue(&bdev->txq))) {
421-
err = btmtksdio_tx_packet(bdev, skb);
422-
if (err < 0) {
423-
bdev->hdev->stat.err_tx++;
424-
skb_queue_head(&bdev->txq, skb);
425-
break;
426-
}
427-
}
428-
429422
txrx_timeout = jiffies + 5 * HZ;
430423

431424
do {
@@ -446,10 +439,21 @@ static void btmtksdio_txrx_work(struct work_struct *work)
446439
bt_dev_dbg(bdev->hdev, "Get fw own back");
447440

448441
if (int_status & TX_EMPTY)
449-
schedule_work(&bdev->txrx_work);
442+
bdev->hw_tx_ready = true;
450443
else if (unlikely(int_status & TX_FIFO_OVERFLOW))
451444
bt_dev_warn(bdev->hdev, "Tx fifo overflow");
452445

446+
if (bdev->hw_tx_ready) {
447+
skb = skb_dequeue(&bdev->txq);
448+
if (skb) {
449+
err = btmtksdio_tx_packet(bdev, skb);
450+
if (err < 0) {
451+
bdev->hdev->stat.err_tx++;
452+
skb_queue_head(&bdev->txq, skb);
453+
}
454+
}
455+
}
456+
453457
if (int_status & RX_DONE_INT) {
454458
rx_size = sdio_readl(bdev->func, MTK_REG_CRPLR, NULL);
455459
rx_size = (rx_size & RX_PKT_LEN) >> 16;
@@ -642,6 +646,7 @@ static int btmtksdio_setup(struct hci_dev *hdev)
642646
u8 param = 0x1;
643647

644648
calltime = ktime_get();
649+
bdev->hw_tx_ready = true;
645650

646651
/* Query whether the firmware is already download */
647652
wmt_params.op = BTMTK_WMT_SEMAPHORE;

0 commit comments

Comments
 (0)