Skip to contentSkip to conversation

Bluetooth: mt7921s: support bluetooth reset mechanism

PATCH In review [email protected] 3 participants 5 messages Feb 8, 2022 – Feb 17, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 Bluetooth: mt7921s: support bluetooth reset mechanism

From: Chih-Ying Chiang <[email protected]>

Implement .cmd_timeout to reset the MT7921s device via a dedicated GPIO pin when the firmware hang or the command has no response.

---
v2: no change

---
 drivers/bluetooth/btmtk.h     |   6 ++
 drivers/bluetooth/btmtksdio.c | 113 +++++++++++++++++++++++++++++++++-
 2 files changed, 118 insertions(+), 1 deletion(-)
drivers/bluetooth/btmtk.h +6 -0
index fb76d9765ce0..8960a5f89d48 100644
@@ -10,9 +10,15 @@
 #define BTMTK_WMT_REG_WRITE 0x1
 #define BTMTK_WMT_REG_READ 0x2
 
+#define MT7921_BTSYS_RST 0x70002610
+#define MT7921_BTSYS_RST_WITH_GPIO BIT(7)
+
 #define MT7921_PINMUX_0 0x70005050
 #define MT7921_PINMUX_1 0x70005054
 
+#define MT7921_DLSTATUS 0x7c053c10
+#define BT_DL_STATE BIT(1)
+
 enum {
 	BTMTK_WMT_PATCH_DWNLD = 0x1,
 	BTMTK_WMT_TEST = 0x2,
drivers/bluetooth/btmtksdio.c +112 -1

189 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 2/2 Bluetooth: mediatek: fix the conflict between mtk and msft vendor event

From: Sean Wang <[email protected]>

There is a conflict between MediaTek wmt event and msft vendor extension logic in the core layer since 145373cb1b1f ("Bluetooth: Add framework for Microsoft vendor extension") was introduced because we changed the type of mediatek wmt event to the type of msft vendor event in the driver.

But the purpose we reported mediatek event to the core layer is for the diagnostic purpose with that we are able to see the full packet trace via monitoring socket with btmon. Thus, it is harmless we keep the original type of mediatek vendor event here to avoid breaking the msft extension function especially they can be supported by Mediatek chipset like MT7921 , MT7922 devices and future devices.

---
v2: fix the warning: variable 'hdr' set but not used

---
 drivers/bluetooth/btmtk.h     | 1 +
 drivers/bluetooth/btmtksdio.c | 9 +--------
 drivers/bluetooth/btusb.c     | 8 --------
 3 files changed, 2 insertions(+), 16 deletions(-)
drivers/bluetooth/btmtk.h +1 -0
index 8960a5f89d48..013850fd2055 100644
@@ -5,6 +5,7 @@
 #define FIRMWARE_MT7668		"mediatek/mt7668pr2h.bin"
 #define FIRMWARE_MT7961		"mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin"
 
+#define HCI_EV_WMT 0xe4
 #define HCI_WMT_MAX_EVENT_SIZE		64
 
 #define BTMTK_WMT_REG_WRITE 0x1
drivers/bluetooth/btmtksdio.c +1 -8
index 8e200e80d2f6..cbb09e1b823d 100644
@@ -381,13 +381,6 @@ static int btmtksdio_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
 	struct hci_event_hdr *hdr = (void *)skb->data;
 	int err;
 
-	/* Fix up the vendor event id with 0xff for vendor specific instead
-	 * of 0xe4 so that event send via monitoring socket can be parsed
-	 * properly.
-	 */
-	if (hdr->evt == 0xe4)
-		hdr->evt = HCI_EV_VENDOR;
-
 	/* When someone waits for the WMT event, the skb is being cloned
 	 * and being processed the events from there then.
 	 */
@@ -403,7 +396,7 @@ static int btmtksdio_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
 	if (err < 0)
 		goto err_free_skb;
 
-	if (hdr->evt == HCI_EV_VENDOR) {
+	if (hdr->evt == HCI_EV_WMT) {
 		if (test_and_clear_bit(BTMTKSDIO_TX_WAIT_VND_EVT,
 				       &bdev->tx_state)) {
 			/* Barrier to sync with other CPUs */
drivers/bluetooth/btusb.c +0 -8
index e03dfbd92fcc..9f10c5e256ec 100644
@@ -2251,7 +2251,6 @@ static void btusb_mtk_wmt_recv(struct urb *urb)
 {
 	struct hci_dev *hdev = urb->context;
 	struct btusb_data *data = hci_get_drvdata(hdev);
-	struct hci_event_hdr *hdr;
 	struct sk_buff *skb;
 	int err;
 
@@ -2271,13 +2270,6 @@ static void btusb_mtk_wmt_recv(struct urb *urb)
 		hci_skb_pkt_type(skb) = HCI_EVENT_PKT;
 		skb_put_data(skb, urb->transfer_buffer, urb->actual_length);
 
-		hdr = (void *)skb->data;
-		/* Fix up the vendor event id with 0xff for vendor specific
-		 * instead of 0xe4 so that event send via monitoring socket can
-		 * be parsed properly.
-		 */
-		hdr->evt = 0xff;
-
 		/* When someone waits for the WMT event, the skb is being cloned
 		 * and being processed the events from there then.
 		 */
Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH v2 2/2] Bluetooth: mediatek: fix the conflict between mtk and msft vendor event

Hi Sean,

Quoted 12 lines

There is a conflict between MediaTek wmt event and msft vendor extension logic in the core layer since 145373cb1b1f ("Bluetooth: Add framework for Microsoft vendor extension") was introduced because we changed the type of mediatek wmt event to the type of msft vendor event in the driver.

But the purpose we reported mediatek event to the core layer is for the diagnostic purpose with that we are able to see the full packet trace via monitoring socket with btmon. Thus, it is harmless we keep the original type of mediatek vendor event here to avoid breaking the msft extension function especially they can be supported by Mediatek chipset like MT7921 , MT7922 devices and future devices.

Quoted 8 lines

---
v2: fix the warning: variable 'hdr' set but not used
---

drivers/bluetooth/btmtk.h     | 1 +
drivers/bluetooth/btmtksdio.c | 9 +--------
drivers/bluetooth/btusb.c     | 8 --------
3 files changed, 2 insertions(+), 16 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

#3 lore raw
In reply to [email protected]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=612283

---Test result---

Test Summary:

CheckPatch                    PASS      3.66 seconds
GitLint                       PASS      1.81 seconds
SubjectPrefix                 PASS      1.66 seconds
BuildKernel                   PASS      27.99 seconds
BuildKernel32                 PASS      24.98 seconds
Incremental Build with patchesPASS      41.37 seconds
TestRunner: Setup             PASS      442.04 seconds
TestRunner: l2cap-tester      PASS      13.30 seconds
TestRunner: bnep-tester       PASS      5.71 seconds
TestRunner: mgmt-tester       PASS      101.36 seconds
TestRunner: rfcomm-tester     PASS      7.26 seconds
TestRunner: sco-tester        PASS      7.53 seconds
TestRunner: smp-tester        PASS      7.40 seconds
TestRunner: userchan-tester   PASS      6.18 seconds

---
Regards,
Linux Bluetooth

maintainer
#4 lore raw
In reply to [email protected]

Hi Sean,

Quoted 8 lines

Implement .cmd_timeout to reset the MT7921s device via a dedicated GPIO pin when the firmware hang or the command has no response.

Quoted 6 lines

---
v2: no change
---
drivers/bluetooth/btmtk.h | 6 ++
drivers/bluetooth/btmtksdio.c | 113 +++++++++++++++++++++++++++++++++-

2 files changed, 118 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel