🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10594

[PATCH net-next v6 15/15] net: ethernet: cortina: Drain RX coalescing timer on stop

#10594
From: Linus Walleij
Date: Tue, 03 Nov 2026 17:51
55 lines
9586 bytes
gmac_stop() cancels the RX coalescing timer before disabling and
freeing the IRQ. An RX interrupt racing with that cancellation can
rearm the timer, leaving it queued after the netdev and its private
port state have been freed.

Initialize the timer before requesting the IRQ, and cancel it again
after free_irq() has drained every handler that can rearm it. Keep the
first cancellation to prevent the timer callback from scheduling NAPI
while the poll instance is being disabled.

This was found by code inspection and tested on the D-Link DIR-685.

Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet")
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
 drivers/net/ethernet/cortina/gemini.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index c32e9574c8c9..d4afe6efb29e 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -2194,6 +2194,10 @@ static int gmac_open(struct net_device *netdev)
 	struct gemini_ethernet_port *port = netdev_priv(netdev);
 	int err;
 
+	hrtimer_setup(&port->rx_coalesce_timer,
+		      &gmac_coalesce_delay_expired,
+		      CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+
 	err = request_irq(netdev->irq, gmac_irq,
 			  IRQF_SHARED, netdev->name, netdev);
 	if (err) {
@@ -2230,9 +2234,6 @@ static int gmac_open(struct net_device *netdev)
 	gmac_enable_tx_rx(netdev);
 	netif_tx_start_all_queues(netdev);
 
-	hrtimer_setup(&port->rx_coalesce_timer, &gmac_coalesce_delay_expired, CLOCK_MONOTONIC,
-		      HRTIMER_MODE_REL);
-
 	netdev_dbg(netdev, "opened\n");
 
 	return 0;
@@ -2269,6 +2270,7 @@ static int gmac_stop(struct net_device *netdev)
 
 	phy_stop(netdev->phydev);
 	free_irq(netdev->irq, netdev);
+	hrtimer_cancel(&port->rx_coalesce_timer);
 
 	gmac_update_hw_stats(netdev);
 	return 0;

-- 
2.56.0
Technical Details
Message-ID: <20261103-gemini-ethernet-fixes-3-v6-15-c4b5ff8a65d8@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355896-linux-kernel-netdev=dewy.ru
References: <20261103-gemini-ethernet-fixes-3-v6-0-c4b5ff8a65d8@kernel.org>

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-355896-linux-kernel-netdev=dewy.ru
From: linusw@kernel.org (Linus Walleij)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v6 15/15] net: ethernet: cortina: Drain RX
 coalescing timer on stop
Date: Tue, 03 Nov 2026 18:51:26 +0100
Organization: Usenet Network
Message-ID: <20261103-gemini-ethernet-fixes-3-v6-15-c4b5ff8a65d8@kernel.org>
References: <20261103-gemini-ethernet-fixes-3-v6-0-c4b5ff8a65d8@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="3239794"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:VkjDZs6xlPmleySXuDEc4nXzQ8M= sha256:1NtreoRJxv8gIhgfiBa8Gqnaq+SBXq+eMQluqRX7pe0=
	sha1:CTzHtlu3b6sx0US65S10Y+2NZ70= sha256:97Rkr45KLjwwGhtarWDL/trxp7xmzMikS0hs2YNkwkM=
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 BDB031129CD; Tue,  3 Nov 2026 22:10:51 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	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=kernel.org
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 5COQS7az9kZy;
	Tue,  3 Nov 2026 22:10:49 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-355896-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 39C241129CC; Tue,  3 Nov 2026 22:10:41 +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 5F5246745E; Tue,  3 Nov 2026 17:52:16 +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=1793728320;
	b=bphA2J7BZMob6tD/SzWix8IPhkZFWCkqnhckl7r2yVjKgNGZcbSz1oLMBjKqYP4pcN95
	 v2v5xVTUrDnIQb01LF0HsodtyTd/rb+JPl1NiGc9gJVyNrxlnRD/syecQgF3BhuEMmqqn
	 5XKKYekO1qG5Q4kWzVAzFPo6i2MoaHenJRB9YK128ShTfnptZh2EaUWxLMA0FIxxkrvdr
	 Hopr+4toDRjA3c4Vpu+e83+E4awid7LK2BUiiBhTC9OTsJj7nuPeJ/uMmS1D0UIngVtOg
	 PnR1Evg5sIdXkMsqw/VMjGVsZpMYLnlR2S4zkS77S237Ns3p70MuMYPW6zuwiYIbr5A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793728320;
	h=X-Original-To:Received: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;
	bh=yOoskEkhcENCBR5CgtNpFEXxmqGszMkffnbh+nNVs0g=;
	b=hs+OiuQuVv/iqS+CuHSWLyGxpHg/21236lT25/Mw0XfHwLRyz/oWtUndcvAxuqUOMoVx
	 xd2ECim7kDbT5CYuLfMwdoirGZgiJe/mvGqenB8nJ8ihA4aI9UTdpCulTMC5IDFDg9+Vb
	 rwijfGA81ofgt34nLsJvnbaoaH+c7qNoq0IzjklQh9Pf/ArfZHCeted/wxLLnkH9OZS5/
	 GXrnXa220Evv0FKknmcnt0Jsh4VScpCilgX4ADy6hkg3cpc7I4n7H4XXkqefUA9hM7JLm
	 kuFMU//g3lyR4d6jynGISro4ar8GcTYOc1NVL9GVNRo9/7eEe/HYvFeSCqlFwXTI4Lw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YDuMhVaD;
	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 8C06F606D802;
	Tue,  3 Nov 2026 17:52:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YDuMhVaD
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793728319;
	b=VZdIESAVJAjj7hDe24k7V+mxamvOXvU8K1wzP7Bewh2808p+fcQCfQGN8N9CkDWK9Aqr
	 9wg+XAE8kDw0iKbYbenX5EwcQYarCjb9U6hVUyE0f/2CpAwDxu7Wr7dO56N6c28Spg8N7
	 oxkfD4k90WNw7XG7csO7S7dvKf6NvDqcs3TWOeVuRyO0Xw+ul+1h1Pyp5zJs6gpuyWwqw
	 tFrSqEDZTF4pc2AOQarvG+0Uj7xaCUFGXeuau+oXfeNV1p1H6BbwR+j5ZubgrFBtrOP7d
	 ovCzZQtdoxuptKwVXj1PKnD6Rxbo/DtwZFew0hLixMEophBYQFE9TJWeL7u5yW+I4fQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793728319;
	h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type:
	 Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc:
	 X-Mailer;
	bh=yOoskEkhcENCBR5CgtNpFEXxmqGszMkffnbh+nNVs0g=;
	b=zr5HsmcaaF3DUSUgHp5soOnc1hPAKIuWXuKX0JNPV4jpxdMoU2VCI8ivkyFsBgvkEtMS
	 taESFO7dJqkrN0j0BdT67YviZAUItHIt32yGA4sj1iM3JBBjHmUk201XpzY4hTWk5ofzI
	 oPqOFa7J1iCxPJIJAlHSr1aTWsXf4KhtYvEqBbWRR3S+2dEDl25yk18Lv/B25cBQxv36q
	 tBH5ZlbXyM+J8F24cQV6lnUKSSTzWWvOhKLvZdTByd9TmS8VDm/BSDYi6tsD76HIa+YIU
	 HRNCp3qZJMJSdjjd0HW0LzJ8vxpg7GxisafVxJZQoxHSy/Y3wDwDl+vmBMMPnNNyyxw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YDuMhVaD;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(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 6C25D606A329
	for <netdev@vger.kernel.org>; Tue,  3 Nov 2026 17:51:59 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 645451F000C1;
	Tue,  3 Nov 2026 17:51:56 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793728319;
	bh=yOoskEkhcENCBR5CgtNpFEXxmqGszMkffnbh+nNVs0g=;
	h=From:Date:Subject:References:In-Reply-To:To:Cc;
	b=YDuMhVaDED01tfbd1vextX9nHYdD/uUrrKuAwww0yd3t3tlnCvPCWfaorinV+MQvE
	 bsSTx1McAKrrP/LCQVQUDfQ6ijwXX7kcblqqru4uU29svIisaZtOPK0CDpw+/h+aqG
	 V9PIou4nK5eGVk6Bf85j4uC9fvh6vM90QDEFMJ5cFmRp80BvbCoSlPyK6yVB3zADx1
	 tk5sX6kS1NNw5IeZhbUHuwLI3xmx5pJBT69D7hpHJouin6evFh/7Ufvk5fCC8voTfi
	 rKlAM4C1a1t2gnFQlgmejClZDTqhpQP/1b7rySscvyVoAmVH1yZQS7FvXdaYMIPPx4
	 FJ6kM59gNpsNA==
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: <20261103-gemini-ethernet-fixes-3-v6-0-c4b5ff8a65d8@kernel.org>
X-Cc: netdev@vger.kernel.org, Linus Walleij <linusw@kernel.org>
X-Mailer: b4 0.16.0