Article View: linux.kernel.netdev
Article #19891[PATCH net-next v9 01/14] net: ethernet: cortina: Keep shared free queue parent-owned
From: Linus Walleij
Date: Fri, 20 Nov 2026 17:29
Date: Fri, 20 Nov 2026 17:29
130 lines
12212 bytes
12212 bytes
The software free queue is shared by both Ethernet ports, but teardown is
not ordered around that ownership. On parent unbind or module unload, the
parent remove callback runs before devres depopulates the child devices. It
therefore destroys the queue while both child netdevs are still registered
and can be doing DMA. Devres then removes each child, and both child remove
callbacks destroy the same queue again, resulting in up to three cleanup
attempts.
Removal before the first interface has been opened is broken as well. The
shared block initialization assigns a nonzero queue order, but allocation
is deferred until open. Cleanup consequently derives a nonzero page count
and dereferences the NULL queue ring.
Depopulate both port devices before cleaning up the queue, and perform that
cleanup only from the parent. Disable the free-queue interrupt after the
managed handlers have drained, since its threaded handler can re-enable it.
Guard cleanup for paths where no queue was allocated.
Hold parent-managed enables on the port clocks across child removal, IRQ
draining and shared queue cleanup, so teardown never relies on clocks
already released by the children.
Port 1 owns the shared refill interrupt, so prevent the children from being
unbound independently. Unregister each netdev before detaching its PHY so
ndo_stop can still access netdev->phydev.
Reported-by: Myeonghun Pak <mhun512@gmail.com>
Closes: https://lore.kernel.org/netdev/20260917192835.58126-1-mhun512@gmail.com/
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
drivers/net/ethernet/cortina/gemini.c | 40 +++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index 3ed8b1ae0bbc..f198e535f1a0 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -1004,6 +1004,9 @@ static void geth_cleanup_freeq(struct gemini_ethernet *geth)
unsigned int pages = len >> fpp_order;
unsigned int pn;
+ if (!geth->freeq_ring)
+ return;
+
writew(readw(geth->base + GLOBAL_SWFQ_RWPTR_REG),
geth->base + GLOBAL_SWFQ_RWPTR_REG + 2);
writel(0, geth->base + GLOBAL_SW_FREEQ_BASE_SIZE_REG);
@@ -2387,11 +2390,10 @@ static irqreturn_t gemini_port_irq(int irq, void *data)
static void gemini_port_remove(struct gemini_ethernet_port *port)
{
if (port->netdev) {
- phy_disconnect(port->netdev->phydev);
unregister_netdev(port->netdev);
+ phy_disconnect(port->netdev->phydev);
}
clk_disable_unprepare(port->pclk);
- geth_cleanup_freeq(port->geth);
}
static void gemini_ethernet_init(struct gemini_ethernet *geth)
@@ -2635,17 +2637,25 @@ static struct platform_driver gemini_ethernet_port_driver = {
.driver = {
.name = "gemini-ethernet-port",
.of_match_table = gemini_ethernet_port_of_match,
+ .suppress_bind_attrs = true,
},
.probe = gemini_ethernet_port_probe,
.remove = gemini_ethernet_port_remove,
};
+static void gemini_ethernet_disable_clk(void *data)
+{
+ clk_disable_unprepare(data);
+}
+
static int gemini_ethernet_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct gemini_ethernet *geth;
unsigned int retry = 5;
+ unsigned int clocks = 0;
u32 val;
+ int ret;
/* Global registers */
geth = devm_kzalloc_obj(dev, *geth);
@@ -2656,6 +2666,30 @@ static int gemini_ethernet_probe(struct platform_device *pdev)
return PTR_ERR(geth->base);
geth->dev = dev;
+ /* Keep both port clocks enabled until the shared queue is torn down. */
+ for_each_available_child_of_node_scoped(dev->of_node, child) {
+ struct clk *clk;
+
+ if (!of_device_is_compatible(child, "cortina,gemini-ethernet-port"))
+ continue;
+
+ clk = devm_get_clk_from_child(dev, child, "PCLK");
+ if (IS_ERR(clk))
+ return dev_err_probe(dev, PTR_ERR(clk),
+ "failed to get port clock\n");
+
+ ret = clk_prepare_enable(clk);
+ if (ret)
+ return ret;
+ ret = devm_add_action_or_reset(dev, gemini_ethernet_disable_clk,
+ clk);
+ if (ret)
+ return ret;
+ clocks++;
+ }
+ if (!clocks)
+ return -ENODEV;
+
/* Wait for ports to stabilize */
do {
udelay(2);
@@ -2683,6 +2717,8 @@ static void gemini_ethernet_remove(struct platform_device *pdev)
{
struct gemini_ethernet *geth = platform_get_drvdata(pdev);
+ devm_of_platform_depopulate(&pdev->dev);
+ writel(0, geth->base + GLOBAL_INTERRUPT_ENABLE_4_REG);
geth_cleanup_freeq(geth);
geth->initialized = false;
}
--
2.56.1
Technical Details
Message-ID:
<20261120-gemini-ethernet-fixes-3-v9-1-298671d799d5@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368040-linux-kernel-netdev=dewy.ruReferences:
<20261120-gemini-ethernet-fixes-3-v9-0-298671d799d5@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368040-linux-kernel-netdev=dewy.ru From: linusw@kernel.org (Linus Walleij) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v9 01/14] net: ethernet: cortina: Keep shared free queue parent-owned Date: Fri, 20 Nov 2026 18:29:20 +0100 Organization: Usenet Network Message-ID: <20261120-gemini-ethernet-fixes-3-v9-1-298671d799d5@kernel.org> References: <20261120-gemini-ethernet-fixes-3-v9-0-298671d799d5@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="3219252"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Y2obGFlwa5hktX/z4Hk297aNkxE= sha256:mnuMzf6XDbnKIckfPYgpbBj1Q6UhxJHq3pComEJY6lc= sha1:D7q+EBRS15cHKJVSPINswkKuM9c= sha256:X/ZYqXyj8ajhPvAfH5/hZz2RGmssZk46bLJ2EsIuyP4= 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 077BF115A1D; Fri, 20 Nov 2026 20:30:02 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[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 UdqAAL-Wq4EM; Fri, 20 Nov 2026 20:29:54 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-368040-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 1D737115983; Fri, 20 Nov 2026 20:29:43 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id D9FD86066A6; Fri, 20 Nov 2026 17:29:42 +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=1795195776; b=kxh7LMfghj3apY/CChXzvt74LtiyybFy3+4kf8xEo0Cy2QSjcWM84a2wVISeRUYimwTt rm6DHIcnhvKe95X4cCjD8cZvMIYFodd6RA+zZYPPOmXlcpdHVyrXikF0UMpaZa/siPZw/ k+kAIjFtOWKmni37F2OJwafv8m7YIE+bRbgKTJ8sxb6mHN3vCRG4qgh0/o9AGxmySIJwg 70I1QmnJoqi20VUs+y8zC5OlFjVhIh1FfRVSxW6fUPMSC0GTruaPZmy+G8l7u1aJzTDrF Tay90og5wKt6qM7PB+AWoLt2YXqKRHrswt0VM7OhGRjV6NDFZ4cmijNapyqx4sl/u3A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795195776; 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=VVhRmPzd3GJWUe1W4GtpoULEj7iHjpx9b6zhNdHXKfc=; b=aKUccKr+obKiAFYLm2Mz58Fg0Ut0ixDCsvl9I5YU21yxFfBSqdwOzQFINTV8oYUTi61N Qy0ygubLC1bWfalx1ir/XdfdtkGdnE+H6dRDt423SivFzwXR75ygeCfrYjWhWVigbWrZu s5KLZYupaKyCRIVDiKHPAEgAJCziCA7LWHvfPmLG7zEsWZ9M3+4eLpOotJwMmmARgHXl2 rZrbBE8dwHbLf5zlE1Gu8wcBEU/d67tsHMle0AmBYbBZj5NYttIfeXVp7o//fVe3kyPJm mIzBBl4JG3fTe1frd/NLQzUqqUCQOdL5ybxSacWmDxEL56e1EUhehiOGCir9NETJtog== 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=CQURBK4f; 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 E296260A2601; Fri, 20 Nov 2026 17:29:35 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CQURBK4f 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=1795195775; b=eS8JYAqGwavKowKGIpau0dMa5ZX7zURxEaVDz8K9KWwkHDUGvrn//WiBfq+wq2OUprjU sEbou5BlUtfJVcGcijxYVMH4qPvgNgv9DGk3oP+QI6ta6tvQZhweBgR8AAsdxMVjn8MIO 2Igv8OxfDjIOVZLWvQnhpY92gzsmKnNoTzmvmX5DuPJZxBzq8KAh8USP0cgPX/Y5l+nYo fcq1w2XMlsRaDZ1eChLq9Za0QlaOTVmNvnFJyR6Suluf9/vQqXDr+XYSprrdz+/QiCoel Slx06trCs096M3iB/DYuxpGKS/lVl4P6Rw63CuHD7+MTm/0GS3Pg6hJtYPEMZPtyBRg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795195775; 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=VVhRmPzd3GJWUe1W4GtpoULEj7iHjpx9b6zhNdHXKfc=; b=fv2LGKBp5p06Rw7BZSOdhFsVKvfXB1DPGtsd+nhwiNGvSK5c8dYkqZ/G1DGxIhgy6Nb5 wXxYXhEegyvFi6T+cXsR2TRLNlUlgATuHN4NGGQ0OtQ38v2D7XyfPZ+5hJLJZvT14cEr9 EfC/mPxgVdjTqmjUT5MJ2raTYDtiB/tIFo25jY+m3PjyV00J9z2t8CcHPbYU8GhuMqbcx 0uNRzozzt6zHorMMp3oXTcQjI8fJka8mlyVZsu+0cpZgGYl8T2vwPTKD0YbaqDPuDMtTk JhE4YrzSmlQc04LKbomkP+I/xnfDokv6qeQyEXXTA+Exuk04MMjluPxkc6RlWFK16pQ== 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=CQURBK4f; 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 1158D606A339 for <netdev@vger.kernel.org>; Fri, 20 Nov 2026 17:29:34 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC9F71F000D2; Fri, 20 Nov 2026 17:29:31 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795195774; bh=VVhRmPzd3GJWUe1W4GtpoULEj7iHjpx9b6zhNdHXKfc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=CQURBK4fh1Bn4X98X54iV8SuGb5LfaXxmtU5pfJitvbIEmzDRj9lw1eDrfJEZBK3e /179udLgDyFGtKtNDaE5lRAsUQhs0Hzlvn35CfHVXDqLqCDeZNPW+iXgwRaUu0Ch02 Sci4/MSStCt+t00LtzH68D9YQ4bn7T41Ube8HsecnH2f8OT1TquYJPpTsXXaaY0G3T GESb8spjRaltAJsqvWnsztRNf7FRQBIVrPrLUBT6HIH8yqooJD4vihvqcFzZb35Vkw rxVZN+4zBROuUXDlDRKMbaPQdzZJDdj0s9mV1UsoFqxSXOg0tws2DUOe49MokgW373 D3M3HMZ+ebftw== 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: <20261120-gemini-ethernet-fixes-3-v9-0-298671d799d5@kernel.org> X-Cc: netdev@vger.kernel.org, Linus Walleij <linusw@kernel.org> X-Mailer: b4 0.16.0