Re: [PATCH net v5 1/2] net: atl1c: wait for in-flight RX polls before the link-down ring reset

From: Federico Musto

Date: Mon Nov 30 2026 - 15:08:38 EST


Thank you for the review. The four findings are correct. Before I
write a v6 I would like to ask the maintainers about the direction,
because I do not think another round of fixes to the wait is the right
answer. The question is at the end.

[Medium] The link-down sequence is skipped when the wait gives up.

Correct. When atl1c_rx_poll_sync() returns false the handler returns
before hw->hibernate, atl1c_reset_mac(), atl1c_set_aspm(SPEED_0),
atl1c_post_phy_linkchg(SPEED_0) and atl1c_configure(), and nothing
records that this work is owed. With a threaded busy-poll that is every
link-down, not a rare case.

[Low] The comment and the commit message overstate the guarantee.

Correct. atl1c_clean_rx() writes REG_IMR after napi_complete_done(), so
the poll is still running once NAPI_STATE_SCHED is clear, and polls can
still start. Only the narrower claim holds: no RX poll walks the rings.

[High, pre-existing] The TX side of the same reset.
[High, pre-existing] No exclusion against the atl1c_down() callers.

Both correct. atl1c_clean_tx() has no carrier gate, and __AT_DOWN is
only looked at while NAPI_STATE_SCHED is set.

These findings, and most of those on v4, have one cause:
atl1c_common_task() is not serialised with any path that resets or
tears down the rings (change_mtu, atl1c_reinit_locked(), suspend, PCI
error recovery), and it takes neither RTNL nor __AT_RESETTING. A
lock-free wait on NAPI_STATE_SCHED can only cover the RX poll, and each
revision has exposed the next uncovered context.

What I propose for v6 is to replace this patch with the locking model
of alx, the sibling driver:

- a mutex in struct atl1c_adapter, as alx has alx->mtx, taken by the
work item (which rechecks __AT_DOWN under it), by open and close
around atl1c_up() and atl1c_down(), by atl1c_change_mtu(),
atl1c_reinit_locked(), suspend, resume and the PCI error handlers;
- under that mutex the link-down branch does what alx_check_link()
does: netif_tx_disable() and napi_disable() on every TX and RX NAPI,
then the existing reset sequence unchanged, then napi_enable() and
the queues are woken;
- atl1c_rx_poll_sync(), its timeout and the smp_mb() go away, and no
part of the link-down sequence is ever skipped.

That removes the Medium and the Low above and closes both pre-existing
issues. It is a larger patch than anything in this series so far, and
it touches every entry point of the driver.

Questions for the maintainers:

1. Is this the direction you want for atl1c, or would you prefer
something smaller?
2. Should the locking change go to net with Fixes: and stable, or to
net-next? If net-next, should the leak fix in patch 2 wait for it,
since it adds a free in the window of the same race?

On testing, following up on Chris's note of Nov 4: I can test on a
MikroTik CCR2004-1G-2XS-PCIe. It is not Atheros silicon; the card
exposes emulated AR8151 functions to the host, so it does not stand in
for a physical AR8151. Within that limit I am willing to test atl1c
patches on it, mine or anyone else's.

pw-bot: cr