Lee, Chun-Yi 45f7e7
From: Sean Wang <sean.wang@mediatek.com>
Lee, Chun-Yi 45f7e7
Date: Wed, 12 Jan 2022 15:39:17 +0800
Lee, Chun-Yi 45f7e7
Subject: Bluetooth: btmtksdio: mask out interrupt status
Lee, Chun-Yi 45f7e7
Patch-mainline: v5.18-rc1
Lee, Chun-Yi 45f7e7
Git-commit: db3f1f9b5d88d8d7f9eaa486f71784dd319285ff
Lee, Chun-Yi 45f7e7
References: jsc#PED-1407
Lee, Chun-Yi 45f7e7
Lee, Chun-Yi 45f7e7
Currently, there is a loop in btmtksdio_txrx_work() which iteratively
Lee, Chun-Yi 45f7e7
executes until the variable int_status is zero.
Lee, Chun-Yi 45f7e7
Lee, Chun-Yi 45f7e7
But the variable int_status should be masked out with the actual interrupt
Lee, Chun-Yi 45f7e7
sources (MTK_REG_CHISR bit 0-15) before we check the loop condition.
Lee, Chun-Yi 45f7e7
Otherwise, RX_PKT_LEN (MTK_REG_CHISR bit 16-31) which is read-only and
Lee, Chun-Yi 45f7e7
unclearable would cause the loop to get stuck on some chipsets like
Lee, Chun-Yi 45f7e7
MT7663s.
Lee, Chun-Yi 45f7e7
Lee, Chun-Yi 45f7e7
Fixes: 26270bc189ea ("Bluetooth: btmtksdio: move interrupt service to work")
Lee, Chun-Yi 45f7e7
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Lee, Chun-Yi 45f7e7
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Lee, Chun-Yi 45f7e7
Acked-by: Lee, Chun-Yi <jlee@suse.com>
Lee, Chun-Yi 45f7e7
---
Lee, Chun-Yi 45f7e7
 drivers/bluetooth/btmtksdio.c |    2 ++
Lee, Chun-Yi 45f7e7
 1 file changed, 2 insertions(+)
Lee, Chun-Yi 45f7e7
Lee, Chun-Yi 45f7e7
--- a/drivers/bluetooth/btmtksdio.c
Lee, Chun-Yi 45f7e7
+++ b/drivers/bluetooth/btmtksdio.c
Lee, Chun-Yi 45f7e7
@@ -92,6 +92,7 @@ MODULE_DEVICE_TABLE(sdio, btmtksdio_tabl
Lee, Chun-Yi 45f7e7
 #define TX_EMPTY		BIT(2)
Lee, Chun-Yi 45f7e7
 #define TX_FIFO_OVERFLOW	BIT(8)
Lee, Chun-Yi 45f7e7
 #define FW_MAILBOX_INT		BIT(15)
Lee, Chun-Yi 45f7e7
+#define INT_MASK		GENMASK(15, 0)
Lee, Chun-Yi 45f7e7
 #define RX_PKT_LEN		GENMASK(31, 16)
Lee, Chun-Yi 45f7e7
 
Lee, Chun-Yi 45f7e7
 #define MTK_REG_CSICR		0xc0
Lee, Chun-Yi 45f7e7
@@ -565,6 +566,7 @@ static void btmtksdio_txrx_work(struct w
Lee, Chun-Yi 45f7e7
 		 * FIFO.
Lee, Chun-Yi 45f7e7
 		 */
Lee, Chun-Yi 45f7e7
 		sdio_writel(bdev->func, int_status, MTK_REG_CHISR, NULL);
Lee, Chun-Yi 45f7e7
+		int_status &= INT_MASK;
Lee, Chun-Yi 45f7e7
 
Lee, Chun-Yi 45f7e7
 		if ((int_status & FW_MAILBOX_INT) &&
Lee, Chun-Yi 45f7e7
 		    bdev->data->chipid == 0x7921) {