From nobody Wed Jun 17 01:51:17 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D38E13254BD for ; Tue, 28 Apr 2026 16:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777394012; cv=none; b=WpNNoNi4DbF1AA9Oui8ym/RcZLzgk9175rD5yks7NvsbOyp1r5khnWiowOchlpuhR93pBI2FY2AjoI+DSNM2MgAx15Vik+gQSLv6187LNwwL2qtK+JDPlKuKt46v5oWvTJiryNaEpNY992sjHQoxWIz6T7Q73CRqLL5ZiIScOXY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777394012; c=relaxed/simple; bh=dAGm4PiwWs80ZnheUKD2LU5YAlmFHcW8oMdB+VthDOQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HsdAV41HCIMvj1FzHCsWWRTkWSNI7ZVNX2biD1azUwZCNAjvBTvTsbVXRYofU84fxSzfAtHnanPESjyhQrihfFqxMBsagsKnsxTbYuzartFFsdLmKj7kn/qDTJ6LO5F9KAdbPTw9AGM0xoqqzVL++jDBzVo41jpWGKaL2+33xmA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=tpujZFg8; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="tpujZFg8" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 59F1B4E42B61; Tue, 28 Apr 2026 16:33:29 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2F420601D0; Tue, 28 Apr 2026 16:33:29 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id AFB1E10728F25; Tue, 28 Apr 2026 18:33:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777394007; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=+0AqFZZvY0X0WypoYom4SAfWrYqe9FmXmaw/Ruojua0=; b=tpujZFg8P80/C/0+z6G3WGNUMBqqd6OBU/2f0bUtBrfwu9kUCAupJ15DyHo5htcWXJgFwu QJrO6pxRVobTz4UZQFXWsrheAkrB9QerOAUw617WALNUBKV9HzhklPJ2ntOsgVpzr4yVH6 P0zcZU+JCdf7Vu5yzUB70kSzjPJ6EVaNj/jA4lQcoG4Ld8xJ/6VuevqH49um+zjuvLbDiI 34rhUJEC67WWFRMPo41ivUIVMzqbT0vRkxAhLbz5aRFRPtfunoP77E0msbkSPFfB7yUJv4 Yg+6H35lIeS+Az9QtPvgzH9+BDRzeDw0uErmAVT+TQSgGL/vEYQS6YCpmcRQrw== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Tue, 28 Apr 2026 18:32:57 +0200 Subject: [PATCH net v2 1/4] net: macb: give reasons for Tx SKB kfree Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260428-macb-drop-tx-v2-1-647f5199d8df@bootlin.com> References: <20260428-macb-drop-tx-v2-0-647f5199d8df@bootlin.com> In-Reply-To: <20260428-macb-drop-tx-v2-0-647f5199d8df@bootlin.com> To: Nicolas Ferre , Claudiu Beznea , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Haavard Skinnemoen , Jeff Garzik Cc: Paolo Valerio , Conor Dooley , Nicolai Buchwitz , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , Gregory CLEMENT , =?utf-8?q?Beno=C3=AEt_Monin?= , Tawfik Bayouk , Thomas Petazzoni , Maxime Chevallier , =?utf-8?q?Th=C3=A9o_Lebrun?= , stable@vger.kernel.org X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 Using dev_consume_skb_any() marks the drop reason as SKB_CONSUMED every time we free a Tx SKB. Instead, replace by SKB_DROP_REASON_NOT_SPECIFIED when packet has been dropped without sending. It is not precise but at least differs from SKB_CONSUMED and is used by many drivers for their error codepaths through dev_kfree_skb_{any,irq}(). Pass a reason around rather than call dev_consume_skb_any() or dev_kfree_skb_any() because macb_tx_unmap() is called for cleanup in all cases. macb_tx_error_task() is made complex because some SKBs encountered have been successfully sent. Fixes: 89e5785fc8a6 ("[PATCH] Atmel MACB ethernet driver") Cc: stable@vger.kernel.org Signed-off-by: Th=C3=A9o Lebrun Reviewed-by: Nicolai Buchwitz --- drivers/net/ethernet/cadence/macb_main.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/etherne= t/cadence/macb_main.c index a12aa21244e8..9caae1ef52b1 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -1201,7 +1201,8 @@ static int macb_halt_tx(struct macb *bp) bp, TSR); } =20 -static void macb_tx_unmap(struct macb *bp, struct macb_tx_skb *tx_skb, int= budget) +static void macb_tx_unmap(struct macb *bp, struct macb_tx_skb *tx_skb, + int budget, enum skb_drop_reason reason) { if (tx_skb->mapping) { if (tx_skb->mapped_as_page) @@ -1214,7 +1215,7 @@ static void macb_tx_unmap(struct macb *bp, struct mac= b_tx_skb *tx_skb, int budge } =20 if (tx_skb->skb) { - dev_consume_skb_any(tx_skb->skb); + dev_kfree_skb_any_reason(tx_skb->skb, reason); tx_skb->skb =3D NULL; } } @@ -1297,7 +1298,8 @@ static void macb_tx_error_task(struct work_struct *wo= rk) * Free transmit buffers in upper layer. */ for (tail =3D queue->tx_tail; tail !=3D queue->tx_head; tail++) { - u32 ctrl; + enum skb_drop_reason reason =3D SKB_DROP_REASON_NOT_SPECIFIED; + u32 ctrl; =20 desc =3D macb_tx_desc(queue, tail); ctrl =3D desc->ctrl; @@ -1307,7 +1309,10 @@ static void macb_tx_error_task(struct work_struct *w= ork) if (ctrl & MACB_BIT(TX_USED)) { /* skb is set for the last buffer of the frame */ while (!skb) { - macb_tx_unmap(bp, tx_skb, 0); + /* The reason parameter is unused because it + * only matters when skb is valid. + */ + macb_tx_unmap(bp, tx_skb, 0, SKB_CONSUMED); tail++; tx_skb =3D macb_tx_skb(queue, tail); skb =3D tx_skb->skb; @@ -1326,6 +1331,7 @@ static void macb_tx_error_task(struct work_struct *wo= rk) bp->dev->stats.tx_bytes +=3D skb->len; queue->stats.tx_bytes +=3D skb->len; bytes +=3D skb->len; + reason =3D SKB_CONSUMED; } } else { /* "Buffers exhausted mid-frame" errors may only happen @@ -1339,7 +1345,7 @@ static void macb_tx_error_task(struct work_struct *wo= rk) desc->ctrl =3D ctrl | MACB_BIT(TX_USED); } =20 - macb_tx_unmap(bp, tx_skb, 0); + macb_tx_unmap(bp, tx_skb, 0, reason); } =20 netdev_tx_completed_queue(netdev_get_tx_queue(bp->dev, queue_index), @@ -1458,7 +1464,7 @@ static int macb_tx_complete(struct macb_queue *queue,= int budget) } =20 /* Now we can safely release resources */ - macb_tx_unmap(bp, tx_skb, budget); + macb_tx_unmap(bp, tx_skb, budget, SKB_CONSUMED); =20 /* skb is set only for the last buffer of the frame. * WARNING: at this point skb has been freed by @@ -2357,7 +2363,11 @@ static unsigned int macb_tx_map(struct macb *bp, for (i =3D queue->tx_head; i !=3D tx_head; i++) { tx_skb =3D macb_tx_skb(queue, i); =20 - macb_tx_unmap(bp, tx_skb, 0); + /* The reason parameter is unused, tx_skb->skb has not yet + * been assigned. Parent caller is responsible for freeing + * the SKB. + */ + macb_tx_unmap(bp, tx_skb, 0, SKB_DROP_REASON_NOT_SPECIFIED); } =20 return -ENOMEM; --=20 2.54.0 From nobody Wed Jun 17 01:51:17 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7405E324B33; Tue, 28 Apr 2026 16:33:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777394015; cv=none; b=HbmU1cWdbMa2pNk6QNIwMgbYtKh/QWJFSvO8AAhy9iRaswN55lvhX0eaWzOqjh83ECYcO6XAy02a8uhN51VgbGZcWv/3mD5CeHm0R1oUpucm0Nye8yeKTkPJJjNtx6n27MrCg+SD/gnI9D2tCXJ8kgNwausIqToe3ZJNiMkOoqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777394015; c=relaxed/simple; bh=1jBDxYXWJq8oVg4cfwRSFslEeHBgkTsITO5M9rYbr1Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ScuRMLCiHgqS1d/PIYrvqcjWaevdJ7W3GOZeBb3wmlIh0Lqb/XX4NjMKj75ODxRRM1lElrdijxqrE9pbTxkI70JKo+1tlbPmbaHDBfuoqacY/54vVOTnbfE4BmGSfxtQAwydL0UP/P2f6URj3BU+82u9AeYiCICSbpXOxiiObWQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=JumcAp5o; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="JumcAp5o" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 32E614E42B62; Tue, 28 Apr 2026 16:33:32 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 013F7601D0; Tue, 28 Apr 2026 16:33:32 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 39B0E10728F26; Tue, 28 Apr 2026 18:33:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777394010; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=G9FpCeKi3Ynv/LOiUy9epKx2SW5IzmteIiDj38KugCY=; b=JumcAp5onXM9jDLvIyBzPUYK8wJtJs6z5CeeXt1/YIOK9qYS5hVZggb1tfvouRmYku+c8W eWN3rV904DjoDfHdibquMUXbtrqyglCVTL4l984IEAhdHiPtYFckalWeR7SXGSAmqPNaw6 1ETYBOLB4WG1AL/zETolvTeXrlJTNfG/9dL8fZCtTK9xo6T5wQlVE3RB7RtANmUnj+JkTr glLS1k5gtMhJwG404+sxsFtr01nwLxV9H9/NxRLwaxYz6KXsg9+t3DUtlfH/5ZEA955fv+ EbQMIY2JDoAhYl1MiTtwDSuYVE2CVSVGxKEUEgJWyERANYrpuuX2ko1tlxrISw== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Tue, 28 Apr 2026 18:32:58 +0200 Subject: [PATCH net v2 2/4] net: macb: drop in-flight Tx SKBs on close Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260428-macb-drop-tx-v2-2-647f5199d8df@bootlin.com> References: <20260428-macb-drop-tx-v2-0-647f5199d8df@bootlin.com> In-Reply-To: <20260428-macb-drop-tx-v2-0-647f5199d8df@bootlin.com> To: Nicolas Ferre , Claudiu Beznea , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Haavard Skinnemoen , Jeff Garzik Cc: Paolo Valerio , Conor Dooley , Nicolai Buchwitz , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , Gregory CLEMENT , =?utf-8?q?Beno=C3=AEt_Monin?= , Tawfik Bayouk , Thomas Petazzoni , Maxime Chevallier , =?utf-8?q?Th=C3=A9o_Lebrun?= , stable@vger.kernel.org X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 The MACB driver has since forever leaked the outgoing SKBs that have not yet been marked as completed. They live in queue->tx_skb which gets freed without remorse nor checking. macb_free_consistent() gets called in a few codepaths, but only close will trigger the added expressions. In macb_open() and macb_alloc_consistent() failure cases, tx_skb just got allocated and is empty. Use the new macb_tx_unmap() prototype to report our error as SKB_DROP_REASON_NOT_SPECIFIED rather than SKB_CONSUMED which makes it sound like no error occurred. Equivalent to dev_kfree_skb_any(). Fixes: 89e5785fc8a6 ("[PATCH] Atmel MACB ethernet driver") Cc: stable@vger.kernel.org Signed-off-by: Th=C3=A9o Lebrun Reviewed-by: Nicolai Buchwitz --- drivers/net/ethernet/cadence/macb_main.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/etherne= t/cadence/macb_main.c index 9caae1ef52b1..5a2500bd59a6 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -2678,8 +2678,26 @@ static void macb_free_consistent(struct macb *bp) dma_free_coherent(dev, size, bp->queues[0].rx_ring, bp->queues[0].rx_ring= _dma); =20 for (q =3D 0, queue =3D bp->queues; q < bp->num_queues; ++q, ++queue) { - kfree(queue->tx_skb); - queue->tx_skb =3D NULL; + if (queue->tx_skb) { + unsigned int dropped =3D 0, tail; + + for (tail =3D queue->tx_tail; tail !=3D queue->tx_head; + tail++) { + if (macb_tx_skb(queue, tail)->skb) + dropped++; + macb_tx_unmap(bp, macb_tx_skb(queue, tail), 0, + SKB_DROP_REASON_NOT_SPECIFIED); + } + + queue->stats.tx_dropped +=3D dropped; + bp->dev->stats.tx_dropped +=3D dropped; + + kfree(queue->tx_skb); + queue->tx_skb =3D NULL; + } + + queue->tx_head =3D 0; + queue->tx_tail =3D 0; queue->tx_ring =3D NULL; queue->rx_ring =3D NULL; } --=20 2.54.0 From nobody Wed Jun 17 01:51:17 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C4E433F595 for ; Tue, 28 Apr 2026 16:33:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777394027; cv=none; b=GFGWxrS3PDLTuRlo/N8PzBn+Hyohf0Kb4U+NZtXD1Y1IWxiA0PdYmyv+c2yUt0Y5RLiIsSCtZl80P4BwICVWxdbfGWbLK57bT71GhbMkSf1DgrgfubhBZnH8Iy4dwljnJb0uKtNs1l/Vgr1BK3gFydUl4mhaZt/hYbhtc+XY8wg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777394027; c=relaxed/simple; bh=M/fO4066R9QBn0wuWeOwifRMZmhtbV9/kRBeDvKY7fE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OmpmhjcZZY87CCHxXvNxbV7RYF1ElbhDGUOHCHK7MXc54EimXyYDbrzPbazPkdJu0teLPn/MRBcAHgr2RBEkvhfz8Yvmcmc7dHUBYCO+LEE//UzCrzNzUQ5zblxKKGTj1EdHPOloYu3B4IvlFaIuSl5oGhAJUCLSe/as3JFWzYc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=k0/aCrcX; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="k0/aCrcX" Received: from smtpout-01.galae.net (unknown [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 3BD7DC5CD54; Tue, 28 Apr 2026 16:34:28 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 804E9601D0; Tue, 28 Apr 2026 16:33:34 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 2EFEB10728EC7; Tue, 28 Apr 2026 18:33:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777394013; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=KysA7h9zhISCGBCF1f+mzV/3bsFT/VxDM5MEU5kyFBI=; b=k0/aCrcXQQrSD0Xxlp/t3xhzZXmFUHJ157lAGjkuBJfFBpW0e6Qt/0N7pcheFeR9Ux7br+ 44YXx4HRHdVriSLy0lhvzv7H2oeAR7HfVZ2IsQHCw3lmBclTjNL886jN+NEF/T/QOK0KOw De5XfGCqCXVJJ5DnCP43y1VZo5h1tyPJBCmmQt4GB1McjoRjGPecCvvJpJ9hJoxSNfDU2A wmR3gaow8wZSZp/YWjnrWaGoAwlusZNAMR3pwjBhDk5oXbmTFZ2ILfBB6VVA98IN1XDStg rpNGjmEPulRzf/LrjXxzfPVb6odEWGLJy/oRvJng0HA2uw1ryoGW4R+Jb/WEkQ== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Tue, 28 Apr 2026 18:32:59 +0200 Subject: [PATCH net v2 3/4] net: macb: increment stats.tx_dropped on tx error Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260428-macb-drop-tx-v2-3-647f5199d8df@bootlin.com> References: <20260428-macb-drop-tx-v2-0-647f5199d8df@bootlin.com> In-Reply-To: <20260428-macb-drop-tx-v2-0-647f5199d8df@bootlin.com> To: Nicolas Ferre , Claudiu Beznea , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Haavard Skinnemoen , Jeff Garzik Cc: Paolo Valerio , Conor Dooley , Nicolai Buchwitz , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , Gregory CLEMENT , =?utf-8?q?Beno=C3=AEt_Monin?= , Tawfik Bayouk , Thomas Petazzoni , Maxime Chevallier , =?utf-8?q?Th=C3=A9o_Lebrun?= , stable@vger.kernel.org X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 macb_tx_error_task() is the workqueue callback on Tx errors interrupts (MACB_TX_ERR_FLAGS). Count number of errored SKBs and increment the Tx dropped stat by that amount. Two types of dropped (not consumed) packets: - Those that have been TX_USED but with an error. - Those that have not been TX_USED but that'll we drop to reset. Fixes: 89e5785fc8a6 ("[PATCH] Atmel MACB ethernet driver") Cc: stable@vger.kernel.org Signed-off-by: Th=C3=A9o Lebrun Reviewed-by: Nicolai Buchwitz --- drivers/net/ethernet/cadence/macb_main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/etherne= t/cadence/macb_main.c index 5a2500bd59a6..ba7cbb10dc2c 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -1261,6 +1261,7 @@ static void macb_tx_error_task(struct work_struct *wo= rk) struct macb *bp =3D queue->bp; u32 queue_index; u32 packets =3D 0; + unsigned int dropped =3D 0; u32 bytes =3D 0; struct macb_tx_skb *tx_skb; struct macb_dma_desc *desc; @@ -1332,6 +1333,8 @@ static void macb_tx_error_task(struct work_struct *wo= rk) queue->stats.tx_bytes +=3D skb->len; bytes +=3D skb->len; reason =3D SKB_CONSUMED; + } else { + dropped++; } } else { /* "Buffers exhausted mid-frame" errors may only happen @@ -1343,11 +1346,17 @@ static void macb_tx_error_task(struct work_struct *= work) "BUG: TX buffers exhausted mid-frame\n"); =20 desc->ctrl =3D ctrl | MACB_BIT(TX_USED); + + if (skb) + dropped++; } =20 macb_tx_unmap(bp, tx_skb, 0, reason); } =20 + queue->stats.tx_dropped +=3D dropped; + bp->dev->stats.tx_dropped +=3D dropped; + netdev_tx_completed_queue(netdev_get_tx_queue(bp->dev, queue_index), packets, bytes); =20 --=20 2.54.0 From nobody Wed Jun 17 01:51:17 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6438333F595; Tue, 28 Apr 2026 16:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777394021; cv=none; b=Dilz2WaXSWbZA88THjjzEFNkCARR2vX6ptffxpF7DOGDiADqzDVKTutGEwUelADEymurtSkHWhw+QRN78oZke6b7H61Q9VI1tdc0cIb6wvXbiVI7SL26PNSZAu+6xBlNX4bRNkhTcgWNRyVLsCuydcPYwb5kdzd9YTeJVux2Xds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777394021; c=relaxed/simple; bh=LJcDzkbzMgg8a2Np1026O9dXp+J1K4xRgXPvw4T8nj8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kCbBkVT6H8laiMiQgvWMf0ZnM5FXx2M5da/pCcy+Ul95lUN+Pp8Brnb3rhckNIK+siOM0EPIHhpGUFX2HRHsGedL4UVeWi8rabbF1UTpCMJjFXNi6h/8tYENfvuhWfGmOu4m4xy/KRhJeiks8Rau7QLTx+0GCU3fSQueAeF1LCs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=JUAPbehr; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="JUAPbehr" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 1D1201A3471; Tue, 28 Apr 2026 16:33:37 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id DED77601DF; Tue, 28 Apr 2026 16:33:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 8B6AB10728F25; Tue, 28 Apr 2026 18:33:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777394015; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=F+fWRHMku/NSooDweeu7yQQBqEo3+O1KjKNJurnc3pg=; b=JUAPbehrAEqoCKk6RRoYgY0gTNvrT88yQJNJ0tcYE4KQBuAaAYSUZuLgx9kP8/3z5V99+l i3EDiPwoCTEh76Io3nH/OyHHZHL+TA4Fjof/0CgM539l4cOaBXHRDwCW07dV2gpm4HT7gS sVUpht/NHaJtCbYL398M0UVCztFD/IIQXKf/sJ79R/Sbw+x8QqmKJoYSLeAgoY8NJU6JDp DPbYgkWgVNE3i8EfB4pdTTIK9Kx0dyjpKx03mUHKSqQdryYUjq9slpNsuhW8zy0VdV+WvH YQBqyfpO9Ou5WOByLNRiThaeEa6JDW/SrkRCQCazT/It+mQUZBhsw6W35DK5xQ== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Tue, 28 Apr 2026 18:33:00 +0200 Subject: [PATCH net v2 4/4] net: macb: increment stats.tx_dropped on DMA map error Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260428-macb-drop-tx-v2-4-647f5199d8df@bootlin.com> References: <20260428-macb-drop-tx-v2-0-647f5199d8df@bootlin.com> In-Reply-To: <20260428-macb-drop-tx-v2-0-647f5199d8df@bootlin.com> To: Nicolas Ferre , Claudiu Beznea , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Haavard Skinnemoen , Jeff Garzik Cc: Paolo Valerio , Conor Dooley , Nicolai Buchwitz , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , Gregory CLEMENT , =?utf-8?q?Beno=C3=AEt_Monin?= , Tawfik Bayouk , Thomas Petazzoni , Maxime Chevallier , =?utf-8?q?Th=C3=A9o_Lebrun?= , stable@vger.kernel.org X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 On .ndo_start_xmit() and DMA mapping failure, increment the Tx dropped statistics counter by one. Fixes: 89e5785fc8a6 ("[PATCH] Atmel MACB ethernet driver") Cc: stable@vger.kernel.org Signed-off-by: Th=C3=A9o Lebrun Reviewed-by: Nicolai Buchwitz --- drivers/net/ethernet/cadence/macb_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/etherne= t/cadence/macb_main.c index ba7cbb10dc2c..353b4bd61aae 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -2567,6 +2567,8 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *sk= b, struct net_device *dev) /* Map socket buffer for DMA transfer */ if (macb_tx_map(bp, queue, skb, hdrlen)) { dev_kfree_skb_any(skb); + queue->stats.tx_dropped++; + bp->dev->stats.tx_dropped++; goto unlock; } =20 --=20 2.54.0