🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #12591

[PATCH net 2/2] net: macb: take tx_ptr_lock in macb_tx_error_task()

#12591
From: Nicolai Buchwitz
Date: Sat, 07 Nov 2026 20:58
41 lines
9842 bytes
The error task resets the TX ring under bp->lock while macb_start_xmit()
updates it under tx_ptr_lock. Stopping the queues does not wait for an
xmit already running on another CPU, so a frame mapped during the reset
is lost and its skb and DMA mapping leak.

Take tx_ptr_lock like macb_start_xmit() does.

Fixes: 138badbc21a0 ("net: macb: use NAPI for TX completion path")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
 drivers/net/ethernet/cadence/macb_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index b6105f915fe35..ff5e364e857e5 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -1369,7 +1369,8 @@ static void macb_tx_error_task(struct work_struct *work)
 	 * network engine about the macb/gem being halted.
 	 */
 	napi_disable(&queue->napi_tx);
-	spin_lock_irqsave(&bp->lock, flags);
+	spin_lock_irqsave(&queue->tx_ptr_lock, flags);
+	spin_lock(&bp->lock);
 
 	/* Make sure nobody is trying to queue up new packets */
 	netif_tx_stop_all_queues(bp->netdev);
@@ -1463,7 +1464,8 @@ static void macb_tx_error_task(struct work_struct *work)
 	netif_tx_start_all_queues(bp->netdev);
 	macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(TSTART));
 
-	spin_unlock_irqrestore(&bp->lock, flags);
+	spin_unlock(&bp->lock);
+	spin_unlock_irqrestore(&queue->tx_ptr_lock, flags);
 
 	napi_enable(&queue->napi_tx);
 

-- 
2.53.0
Technical Details
Message-ID: <20261107-nb-macb-tx-error-task-net-v1-2-a2aac5d64d52@tipi-net.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358526-linux-kernel-netdev=dewy.ru
References: <20261107-nb-macb-tx-error-task-net-v1-0-a2aac5d64d52@tipi-net.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358526-linux-kernel-netdev=dewy.ru
From: nb@tipi-net.de (Nicolai Buchwitz)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net 2/2] net: macb: take tx_ptr_lock in
 macb_tx_error_task()
Date: Sat, 07 Nov 2026 21:58:48 +0100
Organization: Usenet Network
Message-ID: <20261107-nb-macb-tx-error-task-net-v1-2-a2aac5d64d52@tipi-net.de>
References: <20261107-nb-macb-tx-error-task-net-v1-0-a2aac5d64d52@tipi-net.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="4192691"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Xjy4840lkeFx4Xhv4Um2arDD5h8= sha256:hY1U9ef1g8DoZ+c97rX5KjQ0oPfzVFDh/fKXFrqXFfU=
	sha1:ojMp47RASJtlcExOYUDE8DeI0BY= sha256:G9niSzK+4O4s5Uv8bluPSk0QjZnTyF+kALTlR4ZLtSQ=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 0C6661134B4; Sun,  8 Nov 2026 00:05:17 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=tipi-net.de
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id iXELISDjeILK;
	Sun,  8 Nov 2026 00:05:14 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-358526-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=tipi-net.de
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id C0423112014; Sun,  8 Nov 2026 00:05:05 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 2AD0063252; Sat,  7 Nov 2026 20:59:55 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794085195;
	b=Jt52MFZ07YrLzHS0bg/Pnj/1uaaGVR62FbFbBP+Q5/S28PZP64BIIaHJLKNxn0yoEW/V
	 vrkQ/pOeEoGUSllmwcwuQ4ooVSO6yIGzsspusZpzkJD64tNl7QthmtW0A1aT/0axJvpMs
	 bsV/5MHxz1rIPuYLIDAeEnDDDwDmkPlGtiWbvBfahsuaYsi6XQ2EqUWvGnWVToQiBNxMF
	 kBURY4fcZpKqkL16x41ZzRmYfPwLpUK6qu2F2hU9YvjuzHV5Q+CpFoOoHsScmW0LytWqu
	 7RWtOH7eWkEmLQw7tVWqSra6ak6e+CbfRR0q/n2YI7MS23+YBfOuFLgjsanyFJZA9WQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794085195;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:From:
	 Date:Subject:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:Message-Id:References:
	 In-Reply-To:To:Cc:X-Mailer:X-Last-TLS-Session-Version;
	bh=hpR0zVuRuUqZ9VGR9qvagaBxW1BWpTXv26l9osews90=;
	b=n49SwIqyEVUVv9mJnqBVigNSYb7WJRdAJjOacBBj0LUffsRM4KUnqll8P0SpaSdLjkkX
	 At6OjRw9bkepiXI/0IDMiGcb3OIEcNbt/yap1JQFMOk3viix4AwhwTiqUgGtc8XYWM6vf
	 tMnQAS0A169Wb86UOLGIzRmc/gWz9xReC8Zb2Ya4of22jhwdwM7KIjF4OZVfNSr9axhzu
	 SfjD1b4YgbeDFVZo8PaPNxblxvFUkudZ0NtLPPybuxms1/62ExeDTOvqnaQHsUgOzUxUe
	 ZtccprSx8Dfmcx2KombRW/a8TIKgW2VquzA5mUWaKL7YOwFOY2gFbKqmD4KWXdsp2CA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=HMFHHVlL;
	dmarc=none header.from=tipi-net.de;
	spf=pass smtp.mailfrom=tipi-net.de;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 01FDB606A32D;
	Sat,  7 Nov 2026 20:59:55 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=HMFHHVlL
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=194.13.80.246
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794085184;
	b=XfQBGbQA6On2zXcB90jzyr+MD7fDJ6dmLfgayGTXUO4okZ4d6/GezxdShHc9jDIz/XSO
	 ChpAVKmFh2WmRlFPW5pWCENYrDF8cKLYjRY8h6y5VnO4vzbgOlpaay7SS0RsnxvYzWSiU
	 KUn/8zOEYhgkxIEXDYS2JFi05jEy/tdlyL8/+mnQ0whf+HdoThTyMWuoEtafYUNbHuQKe
	 mH0M+eTAgB3WgoLmrDXaNFoRSbqZOx237cdLXzWpS7yHlDbTYRip3c4boZ8cxhROP9yG7
	 gb9awJ3qRvlTlKx92LIY2EaadE4wKKp9BUk72LQTg7Y26SqpIobj+0VcHCMlBY3i9Pw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794085184;
	h=DMARC-Filter:Received:DKIM-Signature:From:Date:Subject:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:Message-Id:References:
	 In-Reply-To:To:Cc:X-Mailer:X-Last-TLS-Session-Version;
	bh=hpR0zVuRuUqZ9VGR9qvagaBxW1BWpTXv26l9osews90=;
	b=f1eOuN0IN88iWEzypFOe+AI+wGVJZ7ztufsUM9aPpqLoEiNZziew98z3sDik27iXAV4N
	 uKqzNrkZI6fn2ZUpKemduixkYWPUCXaypXOQt4d8HjjSMym/AQmnlfHYd5PxmwJsGaZMv
	 4YUj5U2JdY0N/LaPYnDjtxkfvo7cs49ogCT4DvdzUaUk0RtXQF/qwxR91PObw58JJYZIP
	 9K0K76nAgfSjOXXtQZgeT7F6B71252gsrNER6CqFZdBihk7drdcMsAGC5sTTz/ruH6jIb
	 1wmSEyzrX/YBJX13zHGyMVkkHoYLeMppCtLh+Eq7HotKKZWD0sHiJfyKFW4M3RgreGg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=tipi-net.de;
	spf=pass smtp.mailfrom=tipi-net.de;
	dkim=pass header.d=tipi-net.de header.i=@tipi-net.de header.a=rsa-sha256 header.s=dkim header.b=HMFHHVlL;
	arc=none smtp.remote-ip=194.13.80.246
X-Received: from mail.tipi-net.de (mail.tipi-net.de [194.13.80.246])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B447606D809;
	Sat,  7 Nov 2026 20:59:38 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4B447606D809
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tipi-net.de
X-Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 58028A1649;
	Sat, 07 Nov 2026 21:59:36 +0100 (CET)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim;
	t=1794085176; h=from:subject:date:message-id:to:cc:mime-version:content-type:
	 content-transfer-encoding:in-reply-to:references;
	bh=hpR0zVuRuUqZ9VGR9qvagaBxW1BWpTXv26l9osews90=;
	b=HMFHHVlLF1BTzDGHC7Ul38V7bG2CHGty4dh88arRy0FSCRlwoMF0aKrmwHJCsJgfCLH7YL
	TR1A4Pv7DZu+9+bSD3y1Z8A3Q+hqXpMjC2deZeaWXHidR1F7R0Syzk09iH0Go99V9nRlWn
	1e6WYAc18m8L1UjSkq9DLka7mLs2+TFbO2kmtF7vMHwojHFzRKseZV0u4WcO5VCZu/OOsD
	6DunosJzt/IEQLkATQRiLCnWQRDbhCcBzzpH2pQo/hxtScX9uZWkp/wSyTTHAxpKa/Lv+w
	CbvmPhusHBPvGeDuOb8FKah7kPUf9RgzFxw0zq1O/pD4Cb4hiiUhLelfk9Mckg==
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261107-nb-macb-tx-error-task-net-v1-0-a2aac5d64d52@tipi-net.de>
X-Cc: Sean Anderson <sean.anderson@linux.dev>, 
 Robert Hancock <robert.hancock@calian.com>, netdev@vger.kernel.org, 
 linux-kernel@vger.kernel.org, Nicolai Buchwitz <nb@tipi-net.de>
X-Mailer: b4 0.16.0
X-Last-TLS-Session-Version: TLSv1.3