Lee, Chun-Yi 24e03b
From: Sean Wang <sean.wang@mediatek.com>
Lee, Chun-Yi 24e03b
Date: Wed, 9 Feb 2022 02:17:41 +0800
Lee, Chun-Yi 24e03b
Subject: Bluetooth: mediatek: fix the conflict between mtk and msft vendor
Lee, Chun-Yi 24e03b
 event
Lee, Chun-Yi 24e03b
Patch-mainline: v5.18-rc1
Lee, Chun-Yi 24e03b
Git-commit: e4412654e260842e1a94ffe0d4026e8a6fd34246
Lee, Chun-Yi 24e03b
References: jsc#PED-1407
Lee, Chun-Yi 24e03b
Lee, Chun-Yi 24e03b
There is a conflict between MediaTek wmt event and msft vendor extension
Lee, Chun-Yi 24e03b
logic in the core layer since 145373cb1b1f ("Bluetooth: Add framework for
Lee, Chun-Yi 24e03b
Microsoft vendor extension") was introduced because we changed the type of
Lee, Chun-Yi 24e03b
mediatek wmt event to the type of msft vendor event in the driver.
Lee, Chun-Yi 24e03b
Lee, Chun-Yi 24e03b
But the purpose we reported mediatek event to the core layer is for the
Lee, Chun-Yi 24e03b
diagnostic purpose with that we are able to see the full packet trace via
Lee, Chun-Yi 24e03b
monitoring socket with btmon. Thus, it is harmless we keep the original
Lee, Chun-Yi 24e03b
type of mediatek vendor event here to avoid breaking the msft extension
Lee, Chun-Yi 24e03b
function especially they can be supported by Mediatek chipset like MT7921
Lee, Chun-Yi 24e03b
, MT7922 devices and future devices.
Lee, Chun-Yi 24e03b
Lee, Chun-Yi 24e03b
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Lee, Chun-Yi 24e03b
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Lee, Chun-Yi 24e03b
Acked-by: Lee, Chun-Yi <jlee@suse.com>
Lee, Chun-Yi 24e03b
---
Lee, Chun-Yi 24e03b
 drivers/bluetooth/btmtk.h     |    1 +
Lee, Chun-Yi 24e03b
 drivers/bluetooth/btmtksdio.c |    9 +--------
Lee, Chun-Yi 24e03b
 drivers/bluetooth/btusb.c     |    8 --------
Lee, Chun-Yi 24e03b
 3 files changed, 2 insertions(+), 16 deletions(-)
Lee, Chun-Yi 24e03b
Lee, Chun-Yi 24e03b
--- a/drivers/bluetooth/btmtk.h
Lee, Chun-Yi 24e03b
+++ b/drivers/bluetooth/btmtk.h
Lee, Chun-Yi 24e03b
@@ -5,6 +5,7 @@
Lee, Chun-Yi 24e03b
 #define FIRMWARE_MT7668		"mediatek/mt7668pr2h.bin"
Lee, Chun-Yi 24e03b
 #define FIRMWARE_MT7961		"mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin"
Lee, Chun-Yi 24e03b
 
Lee, Chun-Yi 24e03b
+#define HCI_EV_WMT 0xe4
Lee, Chun-Yi 24e03b
 #define HCI_WMT_MAX_EVENT_SIZE		64
Lee, Chun-Yi 24e03b
 
Lee, Chun-Yi 24e03b
 #define BTMTK_WMT_REG_WRITE 0x1
Lee, Chun-Yi 24e03b
--- a/drivers/bluetooth/btmtksdio.c
Lee, Chun-Yi 24e03b
+++ b/drivers/bluetooth/btmtksdio.c
Lee, Chun-Yi 24e03b
@@ -381,13 +381,6 @@ static int btmtksdio_recv_event(struct h
Lee, Chun-Yi 24e03b
 	struct hci_event_hdr *hdr = (void *)skb->data;
Lee, Chun-Yi 24e03b
 	int err;
Lee, Chun-Yi 24e03b
 
Lee, Chun-Yi 24e03b
-	/* Fix up the vendor event id with 0xff for vendor specific instead
Lee, Chun-Yi 24e03b
-	 * of 0xe4 so that event send via monitoring socket can be parsed
Lee, Chun-Yi 24e03b
-	 * properly.
Lee, Chun-Yi 24e03b
-	 */
Lee, Chun-Yi 24e03b
-	if (hdr->evt == 0xe4)
Lee, Chun-Yi 24e03b
-		hdr->evt = HCI_EV_VENDOR;
Lee, Chun-Yi 24e03b
-
Lee, Chun-Yi 24e03b
 	/* When someone waits for the WMT event, the skb is being cloned
Lee, Chun-Yi 24e03b
 	 * and being processed the events from there then.
Lee, Chun-Yi 24e03b
 	 */
Lee, Chun-Yi 24e03b
@@ -403,7 +396,7 @@ static int btmtksdio_recv_event(struct h
Lee, Chun-Yi 24e03b
 	if (err < 0)
Lee, Chun-Yi 24e03b
 		goto err_free_skb;
Lee, Chun-Yi 24e03b
 
Lee, Chun-Yi 24e03b
-	if (hdr->evt == HCI_EV_VENDOR) {
Lee, Chun-Yi 24e03b
+	if (hdr->evt == HCI_EV_WMT) {
Lee, Chun-Yi 24e03b
 		if (test_and_clear_bit(BTMTKSDIO_TX_WAIT_VND_EVT,
Lee, Chun-Yi 24e03b
 				       &bdev->tx_state)) {
Lee, Chun-Yi 24e03b
 			/* Barrier to sync with other CPUs */
Lee, Chun-Yi 24e03b
--- a/drivers/bluetooth/btusb.c
Lee, Chun-Yi 24e03b
+++ b/drivers/bluetooth/btusb.c
Lee, Chun-Yi 24e03b
@@ -2256,7 +2256,6 @@ static void btusb_mtk_wmt_recv(struct ur
Lee, Chun-Yi 24e03b
 {
Lee, Chun-Yi 24e03b
 	struct hci_dev *hdev = urb->context;
Lee, Chun-Yi 24e03b
 	struct btusb_data *data = hci_get_drvdata(hdev);
Lee, Chun-Yi 24e03b
-	struct hci_event_hdr *hdr;
Lee, Chun-Yi 24e03b
 	struct sk_buff *skb;
Lee, Chun-Yi 24e03b
 	int err;
Lee, Chun-Yi 24e03b
 
Lee, Chun-Yi 24e03b
@@ -2276,13 +2275,6 @@ static void btusb_mtk_wmt_recv(struct ur
Lee, Chun-Yi 24e03b
 		hci_skb_pkt_type(skb) = HCI_EVENT_PKT;
Lee, Chun-Yi 24e03b
 		skb_put_data(skb, urb->transfer_buffer, urb->actual_length);
Lee, Chun-Yi 24e03b
 
Lee, Chun-Yi 24e03b
-		hdr = (void *)skb->data;
Lee, Chun-Yi 24e03b
-		/* Fix up the vendor event id with 0xff for vendor specific
Lee, Chun-Yi 24e03b
-		 * instead of 0xe4 so that event send via monitoring socket can
Lee, Chun-Yi 24e03b
-		 * be parsed properly.
Lee, Chun-Yi 24e03b
-		 */
Lee, Chun-Yi 24e03b
-		hdr->evt = 0xff;
Lee, Chun-Yi 24e03b
-
Lee, Chun-Yi 24e03b
 		/* When someone waits for the WMT event, the skb is being cloned
Lee, Chun-Yi 24e03b
 		 * and being processed the events from there then.
Lee, Chun-Yi 24e03b
 		 */