Article View: linux.kernel.netdev
Article #24136Re: [PATCH net v5 1/2] net: atl1c: wait for in-flight RX polls before the link-down ring reset
From: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 11:48
Date: Sun, 29 Nov 2026 11:48
272 lines
18487 bytes
18487 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 (2) · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] When atl1c_rx_poll_sync() returns false (timeout, or
__AT_DOWN), atl1c_check_link_status() returns at line 325, right after…
- [Low] The new comment above atl1c_rx_poll_sync() (lines 253-258), and
the matching sentence in the commit message, say that…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch
leaves it reachable: the link-down reset still frees TX buffers while…
- [High] This problem wasn't introduced by this patch, but the new
__AT_DOWN gate does not close it.
--
net: atl1c: wait for in-flight RX polls before the link-down ring reset
This patch makes the link-change work item wait until NAPI_STATE_SCHED is
clear on every RX queue before atl1c_check_link_status() resets the MAC
and the DMA rings. The wait starts after netif_carrier_off() and an
smp_mb(). It is bounded, and it gives up if __AT_DOWN appears, in which
case the link-down reset is skipped. atl1c_up() passes false and does not
wait.
> diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> index eddd8406867f7..afab3e16903ba 100644
> --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> @@ -248,7 +248,52 @@ void atl1c_reinit_locked(struct atl1c_adapter *adapter)
> clear_bit(__AT_RESETTING, &adapter->flags);
> }
>
> -static void atl1c_check_link_status(struct atl1c_adapter *adapter)
> +#define ATL1C_POLL_SYNC_TRIES 500
> +
> +/* atl1c_clean_rx() looks at the carrier only when it is entered. A poll
> + * that passed that test before the carrier went off keeps walking the RRD
> + * ring. NAPI_STATE_SCHED is held for the whole poll, and a poll that
> + * starts later sees the carrier off and returns without touching the
> + * rings, so once the bit is observed clear on every RX queue no poll is
> + * running and none can start.
[Severity: Low]
Is this description accurate? The commit message makes the same claim:
"NAPI_STATE_SCHED is held for the whole poll, so observing it clear on
every RX queue means no poll is running"
On every completion path, atl1c_clean_rx() calls napi_complete_done()
first, which clears NAPI_STATE_SCHED. Only after that does it write
REG_IMR:
quit_polling:
napi_complete_done(napi, work_done);
spin_lock_irqsave(&adapter->hw.intr_mask_lock, flags);
adapter->hw.intr_mask |= atl1c_qregs[rrd_ring->num].rx_isr;
AT_WRITE_REG(&adapter->hw, REG_IMR, adapter->hw.intr_mask);
Every poll takes this carrier-off quit path during the new wait.
atl1c_clean_tx() has the same tail. So the poll is still running, and still
writing a device register, after the bit being sampled has gone clear.
That write re-arms the mask that atl1c_common_task() cleared with
atl1c_irq_disable(). It does not check irq_sem. Two cases leave device
interrupts live during atl1c_reset_dma_ring() and atl1c_configure():
- the write lands after the soft reset in atl1c_reset_mac();
- atl1c_intr() runs (shared INTx or netpoll) and writes REG_ISR = 0.
New polls can also still start through IRQs, busy-poll or netpoll, which
contradicts "none can start". RX polls that start later return early once
they see the carrier off, so the RX ring argument still holds. The IMR
rewrite in the poll tail also predates this patch.
Could the comment and the commit message describe the guarantee more
narrowly?
[ ... ]
> +static bool atl1c_rx_poll_sync(struct atl1c_adapter *adapter)
> +{
> + int i;
> +
> + for (i = 0; i < adapter->rx_queue_count; ++i) {
> + int tries = ATL1C_POLL_SYNC_TRIES;
> +
> + while (test_bit(NAPI_STATE_SCHED,
> + &adapter->rrd_ring[i].napi.state)) {
[Severity: High]
This is a pre-existing issue, but the patch leaves it reachable. Only
rrd_ring[i].napi is sampled here. Once this returns true, the link-down
path calls atl1c_reset_dma_ring(), which frees every TX buffer first:
/* release tx-pending skbs and reset tx/rx ring index */
for (i = 0; i < adapter->tx_queue_count; ++i)
atl1c_clean_tx_ring(adapter, i);
atl1c_irq_disable() only calls synchronize_irq(). It does not wait for a TX
NAPI that is already scheduled or running on another CPU.
atl1c_clean_tx() has no carrier gate. It walks the same buffer_info[]
entries without a lock:
atl1c_clean_buffer(pdev, buffer_info, budget);
if (++next_to_clean == tpd_ring->count)
next_to_clean = 0;
atomic_set(&tpd_ring->next_to_clean, next_to_clean);
atl1c_clean_buffer() checks ATL1C_BUFFER_FREE, unmaps and calls
napi_consume_skb(). Only after that does it clear skb and dma.
Can atl1c_clean_tx() and atl1c_clean_tx_ring() both see the same entry as
live? That would mean a double DMA unmap and a double napi_consume_skb() of
the same skb. The poll could also write a stale next_to_clean back after
the reset has zeroed it.
The argument that "a poll that starts later sees the carrier off and
returns" holds for atl1c_clean_rx(), but not for atl1c_clean_tx().
The Fixes: commit 5e5c0964d9b9 added this reset specifically to release
pending TX skbs. The notes below the --- list the TX side as not addressed,
but those notes are dropped when the patch is applied. The second patch in
the series does not touch the TX side either.
Since this is tagged for stable, should the commit message say that the
TX half of the reset is still racy?
> + if (test_bit(__AT_DOWN, &adapter->flags))
> + return false;
[Severity: High]
This is a pre-existing issue, but does this check close the race with a
concurrent atl1c_down()?
__AT_DOWN is only tested while SCHED is observed set. If every RX SCHED
bit is clear when sampled, the function returns true without looking at
__AT_DOWN. Nothing rechecks it before atl1c_reset_mac() (which includes a
msleep(10)), atl1c_reset_dma_ring() and atl1c_configure().
atl1c_down() does:
set_bit(__AT_DOWN, &adapter->flags);
netif_carrier_off(netdev);
for (i = 0; i < adapter->tx_queue_count; ++i)
napi_disable(&adapter->tpd_ring[i].napi);
for (i = 0; i < adapter->rx_queue_count; ++i)
napi_disable(&adapter->rrd_ring[i].napi);
...
atl1c_reset_dma_ring(adapter);
Only atl1c_close() calls cancel_work_sync(&adapter->common_task) first.
These callers reach atl1c_down() while the work item may be running:
- atl1c_change_mtu()
- atl1c_reinit_locked() (ethtool)
- atl1c_suspend()
- PCI error recovery
The work item takes neither __AT_RESETTING nor RTNL.
Case one: atl1c_down() has set __AT_DOWN but has not yet disabled the RX
NAPIs, or it starts after the wait has returned true. Both contexts then
run atl1c_reset_dma_ring()->atl1c_clean_buffer() on the same buffer_info
entries. Could that double-free and double-unmap the skbs? The work item's
atl1c_configure() could also refill rings that the teardown is freeing.
Case two: a full down/up finishes inside that window.
atl1c_up()->atl1c_check_link_status(adapter, false) can turn the carrier
back on, then clear __AT_DOWN and call napi_enable(). A new RX poll would
then pass the carrier gate and walk the RRD/RFD rings while the work item
frees them.
The notes below the --- acknowledge the missing serialisation. The commit
body, though, presents the __AT_DOWN check as the answer to a concurrent
teardown.
Does this need real exclusion? One option is to take __AT_RESETTING or the
instance lock in the work item and recheck state under it. Another is to
have every atl1c_down() caller call cancel_work_sync() first.
> + if (!tries--) {
> + dev_warn_ratelimited(&adapter->pdev->dev,
> + "RX poll won't finish, skipping link-down reset\n");
> + return false;
> + }
> + usleep_range(1000, 2000);
> + }
> + }
> +
> + return true;
> +}
[ ... ]
> @@ -265,6 +310,20 @@ static void atl1c_check_link_status(struct atl1c_adapter *adapter)
> if (!link) {
> /* link down */
> netif_carrier_off(netdev);
> + if (sync_polls) {
[ ... ]
> + smp_mb();
> + if (!atl1c_rx_poll_sync(adapter))
> + return;
[Severity: Medium]
When atl1c_rx_poll_sync() returns false, this return skips the whole
link-down hardware sequence, not only the ring reset:
- hw->hibernate = true
- atl1c_reset_mac()
- atl1c_set_aspm(hw, SPEED_0)
- atl1c_post_phy_linkchg(hw, SPEED_0)
- atl1c_reset_dma_ring()
- atl1c_configure()
Nothing records that this work is still owed.
The next link-change event is normally a link-up. atl1c_link_chg_event()
has already set adapter->link_speed = SPEED_0, so the link-up branch runs
atl1c_set_aspm(), atl1c_post_phy_linkchg() and atl1c_start_mac() on a MAC
that was never stopped or reset. Would that leave TX descriptors pending in
the DMA engine, the condition 5e5c0964d9b9 was added to fix?
On msi_lnkpatch parts, the SPEED_0 branch of atl1c_post_phy_linkchg()
restores MIIDBG_SYSMODCTRL and MIIDBG_MSE16DB. That branch is skipped. The
link-up branch only rewrites those registers for SPEED_100, so a link that
comes back at 1000M would keep the 100M thresholds.
hw->hibernate also stays false while the link is down. On l2c_b2 and
l1d_2, atl1c_read_phy_core() and atl1c_write_phy_core() then use the fast
MDIO clock instead of MDIO_CTRL_CLK_25_128.
Under NAPI threaded busy-poll the timeout is not rare, it happens every
time. napi_complete_done() returns without clearing NAPI_STATE_SCHED while
NAPIF_STATE_IN_BUSY_POLL is set:
if (unlikely(n->state & (NAPIF_STATE_NPSVC |
NAPIF_STATE_IN_BUSY_POLL)))
return false;
In that mode every link-down sleeps about 0.5-1 s in the work item with
device interrupts masked, logs the warning and skips the reset. The commit
message only says "the rings are left untouched and the handler runs again
on the next link-change event".
Could the steps that don't touch the rings (hibernate, set_aspm(SPEED_0),
post_phy_linkchg(SPEED_0)) run before the wait? Alternatively, could the
skipped MAC/DMA reset be deferred, for example by setting
ATL1C_WORK_EVENT_RESET?
> + }
> hw->hibernate = true;
> if (atl1c_reset_mac(hw) != 0)
> if (netif_msg_hw(adapter))
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125113120.99743-1-federico%40rimpianto.com
Technical Details
Message-ID:
<179595291724.3146.10471005923458447939@kernel.org>Path:
mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373470-linux-kernel-netdev=dewy.ruReferences:
<20261125113120.99743-2-federico@rimpianto.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373470-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v5 1/2] net: atl1c: wait for in-flight RX polls before the link-down ring reset Date: Sun, 29 Nov 2026 11:48:37 +0000 Organization: Usenet Network Message-ID: <179595291724.3146.10471005923458447939@kernel.org> References: <20261125113120.99743-2-federico@rimpianto.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1161709"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:kAXyjOPQtxOx4ld6tB4ZSWYe7Mw= sha256:oP0x+yTgiEO3ZZ8sYvKUk9/rFAt4Ger0SOLnl02bcfo= sha1:Z6ueiEfbPsXY39KsP4mXwRkdiD0= sha256:41L1lu/Rkxz1w5BU5E4O8t96i3kj1BumB2H4IgD3myY= 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 2FDD0125CEE; Sun, 29 Nov 2026 14:49:13 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.5 X-Spam-Status: No, score=-3.5 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, URIBL_BLOCKED=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 EicNUSfzDazX; Sun, 29 Nov 2026 14:49:09 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-373470-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 532AA125F94; Sun, 29 Nov 2026 14:49:00 +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 C67476016D1; Sun, 29 Nov 2026 11:48:59 +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=1795952934; b=WW8XPJCXAUbZaWiAjdQCAMU2+RlKeJy7HzFqs33rw05gcvCHqUiOSRRf7iHzInJ3h00a 0wZSbZGbb5hqtQZ2bgZQmCUOYTGHX9Pz9Mav3A5spqC7ffWXAp9QmdLPSr9yHWIFrSWch ozX0WqyZ8ozqq/ZqIXAc0Via2DUZySmEPkz/IkWqK0H4KpEQfcecxBuoJR/E01W+mlgex EAZgpPFtZWHzosSXORljX2CQ6AQk6GNuyLtLvP4pJIAhIr6ac/GfcVr19eDN/7e2EcpCJ dd+WaMX1ccgRK7Y1M1TQ/JiFPAzaiGJKQy8MqQI055OyUJZGu7GGnG2rC0Ue1zfBlDg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795952934; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=SrL1uV1aluT7odiJfTC4qcKP+n1EifNIQWzvvq0fqLw=; b=IrgzougFRXu5QTMnYNNhMOGvk9zduF0IkvC6S0jovB+XBSGtk7lzYyrsLpRYW71pXkmy 9SR67e/5KQUeuWiT6q7KVxST4lvPFRwKTCkxDVbnACr3AVQhZY87ZkHDbLLz9pKC1RVii 8JtW+qULYtjGs33VoWRYzAYvVfxizd5QY++4YP06tal5egzLZHkW0kBTMbBxPMP79fRWy 5k3jZjNRqzYCxGbgSRi53Cbc9Kq/cKDV7XZqFCjNO08gVhWahnjurAbytFuHdxcQT1qZl y8smbElGO32cSaKwatHBhvRXdsUjstGDxI9QU2BIkSH4z5MLNX0Z2IZ6wLZ7+ong99Q== 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=NKnJoLQf; 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 60F34606A6B3; Sun, 29 Nov 2026 11:48:54 +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=NKnJoLQf 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=1795952918; b=wCjMWVzZiUhJgw2EGQA8OHlgiHzvWZa3OUPM6d6eAGRIqySy09GgCOtbKF3zK0qDElQl WbKTFFcTP+6cVw2nnMHC2uaBdK+LzOO93TH7TZIrC/rwsqtQGeb58K3Dz1pvmWaSUHz9C hRsU7uAd8CTbje6xyM7qFtYru1qzBR9AFARYx6WySbFHzRhnWbwKG+OUACuh0xis2pmp0 TEbgN72NQaLRWKSDzOU/dOX0iP0WgUEH7gmi2TXPq8wXf8OXfvv/0152ScyvHCIL+IBYT z/JAl1QWNJ0A/LbeuRqd4TvrNX7qXDhgPqRIIWy06DOLF8UF3h7ykP4daqH/UuBC64w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795952918; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=SrL1uV1aluT7odiJfTC4qcKP+n1EifNIQWzvvq0fqLw=; b=wp5cGRRCT5nEyJfP7zPjFcJ6PumFkY4/mORvKaMXLvRIrB5h8pHE8JFdMQIS6MF3bz1w YJIEwga1j1kn1CVzy8Tf1snQHTkt6zy8eYHj3zA0sVAEYfzaTil5t+/HsNsuNaLmNn7+O e8cA97el/JDulTPqVxiOxcg6wBkBKxTCSOHWnOABT6iosH7xoung2NEbPI42U+GlCUZkH L366iimKiR507QowVNm6XG24MXhMwUuBPHq/3eRgPRTgyQNo/nK3+Yumc75uuDjiBpJbl l3Oqar3w1iv1HdiHR/LTb5B2iZJCjseZo1F3SjBk4rXIYQZljI54NarY6Ic8k8FBx4w== 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=NKnJoLQf; 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 5B257606A69E; Sun, 29 Nov 2026 11:48:38 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAEA91F00896; Sun, 29 Nov 2026 11:48:37 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795952918; bh=SrL1uV1aluT7odiJfTC4qcKP+n1EifNIQWzvvq0fqLw=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=NKnJoLQfBwtuw4uw2CQO7GHIAUmrqYn6of/YHOSieZaJNLlRcmssma/iwPxqOMEPt sxrG6+Z8ySyDjNXP8FRDPt4jvulvc1RyGYbPrzTWu+/cEp6uOQwb5SVTV5NGC0FjeK YAlWeE1azXPC7KmvQeLixHodvS1fAXg/SGMOJyTy9hYkO1xIrGPbAX0gCWvm5l3Cw9 Sgmkio/8ODZb8k4FwitsaX31pt9es1mTQGOqPgwyo6EvxIZ/1Bp+v2ZklsFXXueB9Y xPOl+qJaU0fRQY0If9U9+wZCTpty6bW05PAM7OXnJaW1yj075VpRDxE+f33ujKmUZF rzxRlZ+ofRsGQ== X-Cc: chris.snook@gmail.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261125113120.99743-2-federico@rimpianto.com> X-sashiko-severity: Medium 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