mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: antonio@mandelbit.com
Cc: intel-wired-lan@lists.osuosl.org, anthony.l.nguyen@intel.com,
	przemyslaw.kitszel@intel.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, janislacis06@gmail.com, kurt@linutronix.de,
	joe@dama.to, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH net v5 5/6] igb: resume the device before changing XDP or XSK settings
Date: Sun, 29 Nov 2026 00:37:09 +0000	[thread overview]
Message-ID: <179591262958.3135.1982212772873974426@kernel.org> (raw)
In-Reply-To: <20261124235723.1135808-6-antonio@mandelbit.com>

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

  parent reply	other threads:[~2026-11-29  0:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 23:57 [PATCH net v5 0/6] igb: fix runtime PM resume issues Antonio Quartulli
2026-11-24 23:57 ` [PATCH net v5 1/6] igb: don't touch rings that don't exist when disabling an XSK pool Antonio Quartulli
2026-11-28 13:36   ` Janis Edvarts Lacis
2026-11-29  0:37   ` netdev-bot+sashiko
2026-11-24 23:57 ` [PATCH net v5 2/6] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
2026-11-28 13:37   ` Janis Edvarts Lacis
2026-11-29  0:37   ` netdev-bot+sashiko
2026-11-24 23:57 ` [PATCH net v5 3/6] igb: keep the stack's Rx queues that still have an XSK pool Antonio Quartulli
2026-11-28 13:37   ` Janis Edvarts Lacis
2026-11-29  0:37   ` netdev-bot+sashiko
2026-11-24 23:57 ` [PATCH net v5 4/6] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
2026-11-28 13:38   ` Janis Edvarts Lacis
2026-11-24 23:57 ` [PATCH net v5 5/6] igb: resume the device before changing XDP or XSK settings Antonio Quartulli
2026-11-28 13:38   ` Janis Edvarts Lacis
2026-11-29  0:37   ` netdev-bot+sashiko [this message]
2026-11-24 23:57 ` [PATCH net v5 6/6] igb: only allow runtime PM if the device can wake up Antonio Quartulli
2026-11-28 13:40   ` Janis Edvarts Lacis
2026-11-28 13:32 ` [PATCH net v5 0/6] igb: fix runtime PM resume issues Janis Edvarts Lacis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179591262958.3135.1982212772873974426@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=antonio@mandelbit.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=janislacis06@gmail.com \
    --cc=joe@dama.to \
    --cc=kuba@kernel.org \
    --cc=kurt@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®