Linux-mediatek Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Eason Lai <eason.lai@mediatek.com>
To: <nbd@nbd.name>, <lorenzo@kernel.org>
Cc: <linux-wireless@vger.kernel.org>,
	<linux-mediatek@lists.infradead.org>, <kun.wu@mediatek.com>,
	<deren.wu@mediatek.com>, <sean.wang@mediatek.com>,
	<quan.zhou@mediatek.com>, <ryder.lee@mediatek.com>,
	<leon.yen@mediatek.com>, <litien.chang@mediatek.com>,
	<jb.tsai@mediatek.com>, <ck.chang@mediatek.com>,
	<eason.lai@mediatek.com>
Subject: [PATCH v1 1/2] wifi: mt76: mt7925: Fix coredump size not enough issue
Date: Wed, 5 Aug 2026 17:25:30 +0800	[thread overview]
Message-ID: <20260805092531.1490746-2-eason.lai@mediatek.com> (raw)
In-Reply-To: <20260805092531.1490746-1-eason.lai@mediatek.com>

From: "ck.chang" <ck.chang@mediatek.com>

Original allocate coredump file size is not enough to save all coredump content, change the code to dynamic allocate the coredump file size which equal to the actual coredump content size.

Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips")
Signed-off-by: ck.chang <ck.chang@mediatek.com>
---
 .../net/wireless/mediatek/mt76/mt7925/mac.c   | 44 +++++++++++++------
 1 file changed, 30 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
index 101f571b027f..b5dd1b58618c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
@@ -1571,11 +1571,14 @@ void mt7925_mac_reset_work(struct work_struct *work)
 
 void mt7925_coredump_work(struct work_struct *work)
 {
+	size_t hdr_len = sizeof(struct mt7925_mcu_rxd) + 8;
+	struct sk_buff_head local_list;
 	struct mt792x_dev *dev;
+	struct sk_buff *skb;
+	size_t total_sz = 0;
 	char *dump, *data;
 
-	dev = (struct mt792x_dev *)container_of(work, struct mt792x_dev,
-						coredump.work.work);
+	dev = (struct mt792x_dev *)container_of(work, struct mt792x_dev, coredump.work.work);
 
 	if (time_is_after_jiffies(dev->coredump.last_activity +
 				  4 * MT76_CONNAC_COREDUMP_TIMEOUT)) {
@@ -1584,35 +1587,48 @@ void mt7925_coredump_work(struct work_struct *work)
 		return;
 	}
 
-	dump = vzalloc(MT76_CONNAC_COREDUMP_SZ);
+	skb_queue_head_init(&local_list);
+	spin_lock_bh(&dev->mt76.lock);
+	skb_queue_splice_init(&dev->coredump.msg_list, &local_list);
+	spin_unlock_bh(&dev->mt76.lock);
+
+	skb_queue_walk(&local_list, skb) {
+		if (skb->len > hdr_len)
+			total_sz += skb->len - hdr_len;
+	}
+
+	if (!total_sz) {
+		skb_queue_purge(&local_list);
+		goto reset;
+	}
+
+	dump = vzalloc(total_sz);
 	data = dump;
 
 	while (true) {
-		struct sk_buff *skb;
-
-		spin_lock_bh(&dev->mt76.lock);
-		skb = __skb_dequeue(&dev->coredump.msg_list);
-		spin_unlock_bh(&dev->mt76.lock);
+		skb = __skb_dequeue(&local_list);
 
 		if (!skb)
 			break;
 
-		skb_pull(skb, sizeof(struct mt7925_mcu_rxd) + 8);
-		if (!dump || data + skb->len - dump > MT76_CONNAC_COREDUMP_SZ) {
+		if (skb->len <= hdr_len) {
 			dev_kfree_skb(skb);
 			continue;
 		}
 
-		memcpy(data, skb->data, skb->len);
-		data += skb->len;
+		skb_pull(skb, hdr_len);
+		if (dump) {
+			memcpy(data, skb->data, skb->len);
+			data += skb->len;
+		}
 
 		dev_kfree_skb(skb);
 	}
 
 	if (dump)
-		dev_coredumpv(dev->mt76.dev, dump, MT76_CONNAC_COREDUMP_SZ,
-			      GFP_KERNEL);
+		dev_coredumpv(dev->mt76.dev, dump, total_sz, GFP_KERNEL);
 
+reset:
 	mt792x_reset(&dev->mt76);
 }
 
-- 
2.45.2



  reply	other threads:[~2026-08-05  9:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05  9:25 [PATCH v1 0/2] wifi: mt76: mt7925: Fix coredump issue and add coredump end collect mechanism Eason Lai
2026-08-05  9:25 ` Eason Lai [this message]
2026-08-05  9:25 ` [PATCH v1 2/2] wifi: mt76: mt7925: Add " Eason Lai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260805092531.1490746-2-eason.lai@mediatek.com \
    --to=eason.lai@mediatek.com \
    --cc=ck.chang@mediatek.com \
    --cc=deren.wu@mediatek.com \
    --cc=jb.tsai@mediatek.com \
    --cc=kun.wu@mediatek.com \
    --cc=leon.yen@mediatek.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=litien.chang@mediatek.com \
    --cc=lorenzo@kernel.org \
    --cc=nbd@nbd.name \
    --cc=quan.zhou@mediatek.com \
    --cc=ryder.lee@mediatek.com \
    --cc=sean.wang@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox