Re: [PATCH net v5 5/6] igb: resume the device before changing XDP or XSK settings
From: netdev-bot+sashiko
Date: Sat Nov 28 2026 - 19:37:20 EST
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · Low: 0
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).
- [High] In drivers/net/ethernet/intel/igb/igb_main.c, igb_xdp() calls
pm_runtime_get_sync() at line 2950 and throws away the return value.
- [Medium] igb_xdp() in drivers/net/ethernet/intel/igb/igb_main.c now
calls pm_runtime_get_sync() (line 2950) while its callers hold RTNL.
--
igb: resume the device before changing XDP or XSK settings
This commit wraps igb_xdp() in pm_runtime_get_sync()/pm_runtime_put(), so
XDP program and XSK pool changes run against a resumed device. The goal is
to stop igb_xdp_setup() and igb_xsk_pool_setup() from seeing rings that
don't exist yet, or NAPIs that aren't enabled yet, while __igb_resume()
rebuilds them without RTNL.
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 25941a6e25b9f..83c88169840ab 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -2942,16 +2942,28 @@ static int igb_xdp_setup(struct net_device *dev, struct netdev_bpf *bpf)
> static int igb_xdp(struct net_device *dev, struct netdev_bpf *xdp)
> {
> struct igb_adapter *adapter = netdev_priv(dev);
> + int err;
> +
> + /* The rings only exist while the device is resumed, and resuming
> + * rebuilds them without RTNL
> + */
> + pm_runtime_get_sync(&adapter->pdev->dev);
[Severity: High]
What happens here if the runtime resume fails? The return value of
pm_runtime_get_sync() is thrown away. Nothing checks netif_device_present()
before igb_xdp_setup() or igb_xsk_pool_setup() runs.
Say __igb_open() fails during the resume, for example with -ENOMEM from
igb_setup_all_rx_resources() or a failure in igb_request_irq(). By then
__igb_resume() has already run igb_init_interrupt_scheme(), so the
q_vectors exist and num_rx_queues > 0. But every error label in
__igb_open() comes before this:
drivers/net/ethernet/intel/igb/igb_main.c:__igb_open() {
...
clear_bit(__IGB_DOWN, &adapter->state);
for (i = 0; i < adapter->num_q_vectors; i++) {
napi = &adapter->q_vector[i]->napi;
napi_enable(napi);
...
}
So the NAPIs still have SCHED/NPSVC set from netif_napi_add(), and the
descriptor memory has been freed. __igb_resume() also returns without
calling netif_device_attach().
Closing a zero-copy AF_XDP socket would then go through:
xp_release_deferred()
rtnl_lock()
xp_clear_dev()
igb_xdp()
pm_runtime_get_sync() <- resume fails, ignored
igb_xsk_pool_setup(pool == NULL)
igb_xsk_pool_disable()
igb_txrx_ring_disable()
napi_disable()
The check in igb_xsk_pool_disable() still passes:
if_running = netif_running(adapter->netdev) &&
igb_xdp_is_enabled(adapter) &&
qid < adapter->num_rx_queues;
Wouldn't napi_disable() spin forever with RTNL held, since that NAPI was
never enabled? Before that, igb_txrx_ring_disable() writes TXDCTL/RXDCTL
on a MAC that was reset and handed back to firmware. If napi_disable() did
return, igb_txrx_ring_enable() would refill rings whose descriptor memory
was freed.
For XDP_SETUP_PROG add/remove with the interface up, igb_close() does
nothing on the non-present device. igb_open() then runs a full open on the
device that failed to resume.
The commit message says the device is resumed "as ethtool does". However,
both __dev_ethtool() and ethnl_ops_begin() check the device after
resuming:
net/ethtool/netlink.c:ethnl_ops_begin() {
...
if (dev->dev.parent)
pm_runtime_get_sync(dev->dev.parent);
if (!netif_device_present(dev) ||
dev->reg_state >= NETREG_UNREGISTERING) {
ret = -ENODEV;
...
}
Should igb_xdp() check the same way? Returning an error on the pool
teardown path may not be enough on its own. xp_disable_drv_zc() WARNs in
that case, and the pool's DMA unmap would be skipped. The disable path may
still need to do its software cleanup when the hardware isn't resumed.
In this tree a failed resume doesn't set power.runtime_error, so each later
pm_runtime_get_sync() retries the resume callback. The direct trigger is a
failed resume inside igb_xdp()'s own pm_runtime_get_sync(). The last patch
in the series ("igb: only allow runtime PM if the device can wake up")
doesn't change igb_xdp().
[Severity: Medium]
Can this deadlock with a runtime suspend that is already in progress?
Every caller that reaches ndo_bpf here holds RTNL:
dev_xdp_attach()
xsk_bind() -> xp_assign_dev()
xp_release_deferred() -> xp_clear_dev()
The igb runtime suspend callback takes RTNL after the PM core has set the
status to RPM_SUSPENDING:
igb_runtime_suspend()
__igb_shutdown()
cancel_work_sync(&adapter->rtnl_resume_task);
rtnl_lock();
While the status is RPM_SUSPENDING, rpm_resume() for a synchronous caller
on a non-irq_safe device waits uninterruptibly on power.wait_queue. The
pm_wq worker waits for RTNL, and the igb_xdp() caller holds RTNL while it
waits for the suspend to finish. Lockdep won't report this.
The commit message mentions this ("closing an AF_XDP socket or changing
the XDP program is now one of them"). The same cycle already exists for
ethtool ops and for igb_open()/igb_close().
Before this patch, igb made no runtime PM calls on two paths:
AF_XDP zero-copy bind and teardown, and XDP program changes when the
interface is down or the program is only swapped. Both paths can now reach
this hang. The last patch in the series only limits when a suspend gets
scheduled. It doesn't remove the rtnl_lock() from the suspend callback.
Is there a way to avoid the synchronous resume under RTNL on these paths?
>
> switch (xdp->command) {
> case XDP_SETUP_PROG:
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124235723.1135808-1-antonio%40mandelbit.com