All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/1] Bluetooth: btusb: Record debug log for Mediatek Chip.
@ 2021-06-29 19:09 mark-yw.chen
  2021-06-30 20:12   ` Marcel Holtmann
  0 siblings, 1 reply; 3+ messages in thread
From: mark-yw.chen @ 2021-06-29 19:09 UTC (permalink / raw)
  To: marcel, johan.hedberg
  Cc: chris.lu, will-cy.lee, sean.wang, linux-bluetooth,
	linux-mediatek, linux-kernel, michaelfsun, shawnku, jemele,
	apusaka, mark-yw.chen

From: "mark-yw.chen" <mark-yw.chen@mediatek.com>

Mediatek Bluetooth Controller send the fw log via EP2, this patch
create callback(data->recv_acl) for processing acl packet.

1. create callback(data->recv_acl) for processing acl packet.
2. Add btusb_recv_acl_mtk to dispatch acl packet.
3. Send mediatek debug log and coredump via hci_recv_diag channel.
4. The upper layerd can use hci_channel_minitor to receive
   these packets.

Signed-off-by: mark-yw.chen <mark-yw.chen@mediatek.com>
---
 drivers/bluetooth/btusb.c | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index b015dcecfb13..cabf6eba2d95 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -569,6 +569,7 @@ struct btusb_data {
 	int suspend_count;
 
 	int (*recv_event)(struct hci_dev *hdev, struct sk_buff *skb);
+	int (*recv_acl)(struct hci_dev *hdev, struct sk_buff *skb);
 	int (*recv_bulk)(struct btusb_data *data, void *buffer, int count);
 
 	int (*setup_on_usb)(struct hci_dev *hdev);
@@ -776,7 +777,7 @@ static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count)
 
 		if (!hci_skb_expect(skb)) {
 			/* Complete frame */
-			hci_recv_frame(data->hdev, skb);
+			data->recv_acl(data->hdev, skb);
 			skb = NULL;
 		}
 	}
@@ -3075,6 +3076,10 @@ static int btusb_shutdown_intel_new(struct hci_dev *hdev)
 	return 0;
 }
 
+#define MTK_FW_DUMP	0xfc6f
+#define MTK_FW_LOG_1	0x05ff
+#define MTK_FW_LOG_2	0x05fe
+
 #define FIRMWARE_MT7663		"mediatek/mt7663pr2h.bin"
 #define FIRMWARE_MT7668		"mediatek/mt7668pr2h.bin"
 
@@ -3851,6 +3856,33 @@ static int btusb_mtk_shutdown(struct hci_dev *hdev)
 	return 0;
 }
 
+static int btusb_recv_acl_mtk(struct hci_dev *hdev, struct sk_buff *skb)
+{
+	struct btusb_data *data = hci_get_drvdata(hdev);
+	int err;
+	u16 handle = le16_to_cpu(hci_acl_hdr(skb)->handle);
+
+	switch (handle) {
+	case MTK_FW_DUMP:
+		/* It's MediaTek firmware dump from device. When the firmware
+		 * hang, the device can't be suspend successfully.
+		 */
+		usb_disable_autosuspend(data->udev);
+		err = hci_recv_diag(data->hdev, skb);
+		break;
+	case MTK_FW_LOG_1:
+	case MTK_FW_LOG_2:
+		/* It's MediaTek fw debug log */
+		err = hci_recv_diag(data->hdev, skb);
+		break;
+	default:
+		err = hci_recv_frame(data->hdev, skb);
+		break;
+	}
+
+	return err;
+}
+
 MODULE_FIRMWARE(FIRMWARE_MT7663);
 MODULE_FIRMWARE(FIRMWARE_MT7668);
 
@@ -4543,6 +4575,8 @@ static int btusb_probe(struct usb_interface *intf,
 		data->recv_bulk = btusb_recv_bulk;
 	}
 
+	data->recv_acl = hci_recv_frame;
+
 	hdev = hci_alloc_dev();
 	if (!hdev)
 		return -ENOMEM;
@@ -4669,6 +4703,7 @@ static int btusb_probe(struct usb_interface *intf,
 		hdev->setup = btusb_mtk_setup;
 		hdev->shutdown = btusb_mtk_shutdown;
 		hdev->manufacturer = 70;
+		data->recv_acl = btusb_recv_acl_mtk;
 		set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
 	}
 
-- 
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 1/1] Bluetooth: btusb: Record debug log for Mediatek Chip.
  2021-06-29 19:09 [PATCH v3 1/1] Bluetooth: btusb: Record debug log for Mediatek Chip mark-yw.chen
@ 2021-06-30 20:12   ` Marcel Holtmann
  0 siblings, 0 replies; 3+ messages in thread
From: Marcel Holtmann @ 2021-06-30 20:12 UTC (permalink / raw)
  To: Mark-YW.Chen
  Cc: Johan Hedberg, chris.lu, will-cy.lee, Sean Wang,
	Bluetooth Kernel Mailing List, linux-mediatek, open list,
	michaelfsun, shawnku, jemele, apusaka

Hi Mark,

> Mediatek Bluetooth Controller send the fw log via EP2, this patch
> create callback(data->recv_acl) for processing acl packet.
> 
> 1. create callback(data->recv_acl) for processing acl packet.
> 2. Add btusb_recv_acl_mtk to dispatch acl packet.
> 3. Send mediatek debug log and coredump via hci_recv_diag channel.
> 4. The upper layerd can use hci_channel_minitor to receive
>   these packets.

can you be more specific in what the logs do. I think the changes are easy to understand. I rather have an example btmon from this or more details on what is in these traces. Or even how they can be enabled etc.

> 
> Signed-off-by: mark-yw.chen <mark-yw.chen@mediatek.com>
> ---
> drivers/bluetooth/btusb.c | 37 ++++++++++++++++++++++++++++++++++++-
> 1 file changed, 36 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index b015dcecfb13..cabf6eba2d95 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -569,6 +569,7 @@ struct btusb_data {
> 	int suspend_count;
> 
> 	int (*recv_event)(struct hci_dev *hdev, struct sk_buff *skb);
> +	int (*recv_acl)(struct hci_dev *hdev, struct sk_buff *skb);
> 	int (*recv_bulk)(struct btusb_data *data, void *buffer, int count);
> 
> 	int (*setup_on_usb)(struct hci_dev *hdev);
> @@ -776,7 +777,7 @@ static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count)
> 
> 		if (!hci_skb_expect(skb)) {
> 			/* Complete frame */
> -			hci_recv_frame(data->hdev, skb);
> +			data->recv_acl(data->hdev, skb);
> 			skb = NULL;
> 		}
> 	}
> @@ -3075,6 +3076,10 @@ static int btusb_shutdown_intel_new(struct hci_dev *hdev)
> 	return 0;
> }
> 
> +#define MTK_FW_DUMP	0xfc6f
> +#define MTK_FW_LOG_1	0x05ff
> +#define MTK_FW_LOG_2	0x05fe
> +
> #define FIRMWARE_MT7663		"mediatek/mt7663pr2h.bin"
> #define FIRMWARE_MT7668		"mediatek/mt7668pr2h.bin"
> 
> @@ -3851,6 +3856,33 @@ static int btusb_mtk_shutdown(struct hci_dev *hdev)
> 	return 0;
> }
> 
> +static int btusb_recv_acl_mtk(struct hci_dev *hdev, struct sk_buff *skb)
> +{
> +	struct btusb_data *data = hci_get_drvdata(hdev);
> +	int err;
> +	u16 handle = le16_to_cpu(hci_acl_hdr(skb)->handle);
> +
> +	switch (handle) {
> +	case MTK_FW_DUMP:
> +		/* It's MediaTek firmware dump from device. When the firmware
> +		 * hang, the device can't be suspend successfully.
> +		 */
> +		usb_disable_autosuspend(data->udev);
> +		err = hci_recv_diag(data->hdev, skb);
> +		break;
> +	case MTK_FW_LOG_1:
> +	case MTK_FW_LOG_2:
> +		/* It's MediaTek fw debug log */
> +		err = hci_recv_diag(data->hdev, skb);
> +		break;
> +	default:
> +		err = hci_recv_frame(data->hdev, skb);
> +		break;
> +	}
> +
> +	return err;


	switch (handle) {
	case 0xfc6f:		/* Firmware dump from device */
		/* When the firmware hangs, the device can no longer
		 * suspend and thus disable auto-suspend.
		 */
		usb_disable_autosuspend(data->udev);
		/* fall through */

	case 0x05ff:		/* Firmware debug logging 1 */
	case 0x05fe:		/* Firmware debug logging 2 */
		return hci_recv_diag(data->hdev, skb);
	}

	return hci_recv_frame(data->hdev, skb);
}

> +}
> +
> MODULE_FIRMWARE(FIRMWARE_MT7663);
> MODULE_FIRMWARE(FIRMWARE_MT7668);
> 
> @@ -4543,6 +4575,8 @@ static int btusb_probe(struct usb_interface *intf,
> 		data->recv_bulk = btusb_recv_bulk;
> 	}
> 
> +	data->recv_acl = hci_recv_frame;
> +
> 	hdev = hci_alloc_dev();
> 	if (!hdev)
> 		return -ENOMEM;
> @@ -4669,6 +4703,7 @@ static int btusb_probe(struct usb_interface *intf,
> 		hdev->setup = btusb_mtk_setup;
> 		hdev->shutdown = btusb_mtk_shutdown;
> 		hdev->manufacturer = 70;
> +		data->recv_acl = btusb_recv_acl_mtk;
> 		set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);

Move this change after the quirk setting since it is local to btusb and not the hdev.

> 	}

Regards

Marcel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 1/1] Bluetooth: btusb: Record debug log for Mediatek Chip.
@ 2021-06-30 20:12   ` Marcel Holtmann
  0 siblings, 0 replies; 3+ messages in thread
From: Marcel Holtmann @ 2021-06-30 20:12 UTC (permalink / raw)
  To: Mark-YW.Chen
  Cc: Johan Hedberg, chris.lu, will-cy.lee, Sean Wang,
	Bluetooth Kernel Mailing List, linux-mediatek, open list,
	michaelfsun, shawnku, jemele, apusaka

Hi Mark,

> Mediatek Bluetooth Controller send the fw log via EP2, this patch
> create callback(data->recv_acl) for processing acl packet.
> 
> 1. create callback(data->recv_acl) for processing acl packet.
> 2. Add btusb_recv_acl_mtk to dispatch acl packet.
> 3. Send mediatek debug log and coredump via hci_recv_diag channel.
> 4. The upper layerd can use hci_channel_minitor to receive
>   these packets.

can you be more specific in what the logs do. I think the changes are easy to understand. I rather have an example btmon from this or more details on what is in these traces. Or even how they can be enabled etc.

> 
> Signed-off-by: mark-yw.chen <mark-yw.chen@mediatek.com>
> ---
> drivers/bluetooth/btusb.c | 37 ++++++++++++++++++++++++++++++++++++-
> 1 file changed, 36 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index b015dcecfb13..cabf6eba2d95 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -569,6 +569,7 @@ struct btusb_data {
> 	int suspend_count;
> 
> 	int (*recv_event)(struct hci_dev *hdev, struct sk_buff *skb);
> +	int (*recv_acl)(struct hci_dev *hdev, struct sk_buff *skb);
> 	int (*recv_bulk)(struct btusb_data *data, void *buffer, int count);
> 
> 	int (*setup_on_usb)(struct hci_dev *hdev);
> @@ -776,7 +777,7 @@ static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count)
> 
> 		if (!hci_skb_expect(skb)) {
> 			/* Complete frame */
> -			hci_recv_frame(data->hdev, skb);
> +			data->recv_acl(data->hdev, skb);
> 			skb = NULL;
> 		}
> 	}
> @@ -3075,6 +3076,10 @@ static int btusb_shutdown_intel_new(struct hci_dev *hdev)
> 	return 0;
> }
> 
> +#define MTK_FW_DUMP	0xfc6f
> +#define MTK_FW_LOG_1	0x05ff
> +#define MTK_FW_LOG_2	0x05fe
> +
> #define FIRMWARE_MT7663		"mediatek/mt7663pr2h.bin"
> #define FIRMWARE_MT7668		"mediatek/mt7668pr2h.bin"
> 
> @@ -3851,6 +3856,33 @@ static int btusb_mtk_shutdown(struct hci_dev *hdev)
> 	return 0;
> }
> 
> +static int btusb_recv_acl_mtk(struct hci_dev *hdev, struct sk_buff *skb)
> +{
> +	struct btusb_data *data = hci_get_drvdata(hdev);
> +	int err;
> +	u16 handle = le16_to_cpu(hci_acl_hdr(skb)->handle);
> +
> +	switch (handle) {
> +	case MTK_FW_DUMP:
> +		/* It's MediaTek firmware dump from device. When the firmware
> +		 * hang, the device can't be suspend successfully.
> +		 */
> +		usb_disable_autosuspend(data->udev);
> +		err = hci_recv_diag(data->hdev, skb);
> +		break;
> +	case MTK_FW_LOG_1:
> +	case MTK_FW_LOG_2:
> +		/* It's MediaTek fw debug log */
> +		err = hci_recv_diag(data->hdev, skb);
> +		break;
> +	default:
> +		err = hci_recv_frame(data->hdev, skb);
> +		break;
> +	}
> +
> +	return err;


	switch (handle) {
	case 0xfc6f:		/* Firmware dump from device */
		/* When the firmware hangs, the device can no longer
		 * suspend and thus disable auto-suspend.
		 */
		usb_disable_autosuspend(data->udev);
		/* fall through */

	case 0x05ff:		/* Firmware debug logging 1 */
	case 0x05fe:		/* Firmware debug logging 2 */
		return hci_recv_diag(data->hdev, skb);
	}

	return hci_recv_frame(data->hdev, skb);
}

> +}
> +
> MODULE_FIRMWARE(FIRMWARE_MT7663);
> MODULE_FIRMWARE(FIRMWARE_MT7668);
> 
> @@ -4543,6 +4575,8 @@ static int btusb_probe(struct usb_interface *intf,
> 		data->recv_bulk = btusb_recv_bulk;
> 	}
> 
> +	data->recv_acl = hci_recv_frame;
> +
> 	hdev = hci_alloc_dev();
> 	if (!hdev)
> 		return -ENOMEM;
> @@ -4669,6 +4703,7 @@ static int btusb_probe(struct usb_interface *intf,
> 		hdev->setup = btusb_mtk_setup;
> 		hdev->shutdown = btusb_mtk_shutdown;
> 		hdev->manufacturer = 70;
> +		data->recv_acl = btusb_recv_acl_mtk;
> 		set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);

Move this change after the quirk setting since it is local to btusb and not the hdev.

> 	}

Regards

Marcel


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-30 20:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-29 19:09 [PATCH v3 1/1] Bluetooth: btusb: Record debug log for Mediatek Chip mark-yw.chen
2021-06-30 20:12 ` Marcel Holtmann
2021-06-30 20:12   ` Marcel Holtmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.