Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2780242pxb; Fri, 8 Oct 2021 15:22:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVYWhvkJnKgkM+kyBhsnEfZE/SZoMR1vTfqxif/OledZZYvIbM5n75kPUSAAPfZik2ltbO X-Received: by 2002:a63:ed03:: with SMTP id d3mr6874978pgi.24.1633731736022; Fri, 08 Oct 2021 15:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633731736; cv=none; d=google.com; s=arc-20160816; b=YX6Zx63YtBu8qdlenIbzSLEMbgaJqmpnPoWhCBBq81ceLeDT2vQNBx4Qj1AFp610+w i3p5LMUpHz1TMaXsCuv7laJkroto+2V2HMEBoJnKZUOEBFTCRgB4QUnNTfb0fljmMZgp ObgaS2FbdKTgDlEZBKhbempsCK8hxwvDM3QQ89YwARyuhcL/zvvpeUKUHaVx6ukM4urh Pgz1EcgtypClKbUBnBpXmwjLqjY9E6X837Mqv/R3EoZZbwGnShqiK6QLOBs18qm+kP9W 2FTXH30H6AKEvNdM8KYispBACbASTYt/wBOr+fmLJw9dxh3cV7s+/GPR/y7/kgywXwWS OwlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=W9UDO8jOH0Ce4PhcOU1LxizIDeVLnkhH/h5bknHiFp4=; b=VwQirIRuvb6ZDyEy6CEaL8kGqFmfVCIybFA9Gj1StBwjBS6+9R+YGxeI18YBEPVD+m 5ipdyUz/UsZB/+h/FO1eRn8i1tgsXHLrNF58h8Qqh8yWMHqrQUHAspwFvIf9ZPGGaJZ2 sBL4hCjHjGnYiqeFEcr1eAC7qne4AipKBz33QK4aLoJZyMZesRWeSdlFULcVT9PsfPga 7iMNNuswpB6qOjFpEiuFvFWz9VkqcQUJMD/2NpcjH36GIJUWpvM2HuXORiTUana8Uqm6 FbaEFnvACwZd+z0aTIDw9GcPMj5MyFd42lQe/nU7og9dgiqrYb93OtI1w1rPqMSIVy8W MeOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m128si656754pfd.255.2021.10.08.15.22.03; Fri, 08 Oct 2021 15:22:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243644AbhJHWWx (ORCPT + 99 others); Fri, 8 Oct 2021 18:22:53 -0400 Received: from mailgw01.mediatek.com ([216.200.240.184]:17418 "EHLO mailgw01.mediatek.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243625AbhJHWWu (ORCPT ); Fri, 8 Oct 2021 18:22:50 -0400 X-UUID: 94fefff4d9df494ab8c3ac5ebead086a-20211008 X-UUID: 94fefff4d9df494ab8c3ac5ebead086a-20211008 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 100845730; Fri, 08 Oct 2021 15:15:41 -0700 Received: from mtkcas10.mediatek.inc (172.21.101.39) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 8 Oct 2021 15:10:53 -0700 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 9 Oct 2021 06:10:53 +0800 From: To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , Mark-yw Chen Subject: [PATCH v1 08/10] Bluetooth: btmtksdio: transmit packet according to the status TX_EMPTY Date: Sat, 9 Oct 2021 06:10:15 +0800 Message-ID: <0f16a1070b325660fed4584ca4cc7480326538a7.1633728573.git.objelf@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark-yw Chen 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 Signed-off-by: Sean Wang Signed-off-by: Mark-yw Chen --- drivers/bluetooth/btmtksdio.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c index f816a7cb0a74..3266c5d83cae 100644 --- a/drivers/bluetooth/btmtksdio.c +++ b/drivers/bluetooth/btmtksdio.c @@ -103,6 +103,7 @@ struct btmtksdio_dev { struct work_struct txrx_work; unsigned long tx_state; struct sk_buff_head txq; + bool hw_tx_ready; struct sk_buff *evt_skb; @@ -229,6 +230,7 @@ static int btmtksdio_tx_packet(struct btmtksdio_dev *bdev, sdio_hdr->reserved = cpu_to_le16(0); sdio_hdr->bt_type = hci_skb_pkt_type(skb); + bdev->hw_tx_ready = false; err = sdio_writesb(bdev->func, MTK_REG_CTDR, skb->data, round_up(skb->len, MTK_SDIO_BLOCK_SIZE)); if (err < 0) @@ -417,15 +419,6 @@ static void btmtksdio_txrx_work(struct work_struct *work) /* Disable interrupt */ sdio_writel(bdev->func, C_INT_EN_CLR, MTK_REG_CHLPCR, 0); - while ((skb = skb_dequeue(&bdev->txq))) { - err = btmtksdio_tx_packet(bdev, skb); - if (err < 0) { - bdev->hdev->stat.err_tx++; - skb_queue_head(&bdev->txq, skb); - break; - } - } - txrx_timeout = jiffies + 5 * HZ; do { @@ -446,10 +439,21 @@ static void btmtksdio_txrx_work(struct work_struct *work) bt_dev_dbg(bdev->hdev, "Get fw own back"); if (int_status & TX_EMPTY) - schedule_work(&bdev->txrx_work); + bdev->hw_tx_ready = true; else if (unlikely(int_status & TX_FIFO_OVERFLOW)) bt_dev_warn(bdev->hdev, "Tx fifo overflow"); + if (bdev->hw_tx_ready) { + skb = skb_dequeue(&bdev->txq); + if (skb) { + err = btmtksdio_tx_packet(bdev, skb); + if (err < 0) { + bdev->hdev->stat.err_tx++; + skb_queue_head(&bdev->txq, skb); + } + } + } + if (int_status & RX_DONE_INT) { rx_size = sdio_readl(bdev->func, MTK_REG_CRPLR, NULL); rx_size = (rx_size & RX_PKT_LEN) >> 16; @@ -642,6 +646,7 @@ static int btmtksdio_setup(struct hci_dev *hdev) u8 param = 0x1; calltime = ktime_get(); + bdev->hw_tx_ready = true; /* Query whether the firmware is already download */ wmt_params.op = BTMTK_WMT_SEMAPHORE; -- 2.25.1