Netdev List
 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, zheng.z.yan@intel.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH net 3/3] igb: only allow runtime PM if the device can wake up
Date: Tue, 17 Nov 2026 11:18:34 +0000	[thread overview]
Message-ID: <179491431428.3136.15501039766024079493@kernel.org> (raw)
In-Reply-To: <20261113105835.3821433-3-antonio@mandelbit.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · 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).

- [Medium] Probe and remove can disagree about the runtime PM usage
  count.
- [Medium] The patch decides whether igb may runtime-suspend from one
  pci_dev_run_wake() check in igb_probe().

--

igb: only allow runtime PM if the device can wake up

This patch changes igb_probe() so it drops the probe-time runtime PM
usage reference only when pci_dev_run_wake() is true. Devices that can't
signal a wake-up from D3 therefore no longer runtime suspend.
igb_remove() takes the reference back under the same condition.

> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index f1ce9aa696ab7..145daee832640 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -3677,7 +3677,11 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  
>  	dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_NO_DIRECT_COMPLETE);
>  
> -	pm_runtime_put_noidle(&pdev->dev);
> +	/* A device that can't wake up wouldn't notice the link coming back
> +	 * while runtime suspended
> +	 */
> +	if (pci_dev_run_wake(pdev))
> +		pm_runtime_put_noidle(&pdev->dev);

[Severity: Medium]
Is one check at probe time enough to close the bug described in the
commit message?

pci_dev_run_wake() depends on pci_target_state(), and that can change
after probe. On ACPI platforms, acpi_pci_choose_state() limits the
target to D3hot only when d3cold_allowed is clear:

drivers/pci/pci-acpi.c:acpi_pci_choose_state() {
    ...
	if (pdev->no_d3cold || !pdev->d3cold_allowed)
		d_max = ACPI_STATE_D3_HOT;
	else
		d_max = ACPI_STATE_D3_COLD;
    ...
}

Root can change d3cold_allowed through sysfs while igb is bound.

Here is one sequence:

1. igb binds with d3cold_allowed=0. The target is D3hot and PME is
   supported from D3hot, so the probe check passes and the reference is
   dropped.
2. Root writes d3cold_allowed=1, so the target becomes D3cold.
3. The part doesn't support PME from D3cold.

On the next link-down, igb_runtime_idle() or the watchdog schedules a
suspend. igb_runtime_suspend()->__igb_shutdown() arms the WUFC
link-change filter without any PCI-level check. Then
pci_finish_runtime_suspend() runs:

drivers/pci/pci.c:pci_finish_runtime_suspend() {
    ...
	__pci_enable_wake(dev, target_state, pci_dev_run_wake(dev));

	error = pci_set_power_state(dev, target_state);
    ...
}

pci_dev_run_wake() is now false. Wouldn't the device then go into D3cold
with PME disarmed? The port would stay down after the cable is plugged
back in, until user space resumes it.

Could igb_runtime_idle() or igb_runtime_suspend() return -EBUSY when
pci_dev_run_wake() is false? That would cover this case and also remove
the need for the separate probe and remove accounting below.

>  	return 0;
>  
>  err_register:
> @@ -3899,7 +3903,8 @@ static void igb_remove(struct pci_dev *pdev)
>  	struct igb_adapter *adapter = netdev_priv(netdev);
>  	struct e1000_hw *hw = &adapter->hw;
>  
> -	pm_runtime_get_noresume(&pdev->dev);
> +	if (pci_dev_run_wake(pdev))
> +		pm_runtime_get_noresume(&pdev->dev);

[Severity: Medium]
Can igb_probe() and igb_remove() disagree about the runtime PM usage
count here?

igb_remove() calls pci_dev_run_wake() again instead of reusing the
decision made in igb_probe(). The result comes from
pci_pme_capable(dev, pci_target_state(dev, true)), and the target state
can change while the driver is bound.

One way it can change is a write to d3cold_allowed through
d3cold_allowed_store(). That changes what acpi_pci_choose_state()
returns, as described above.

Another way is surprise removal of a runtime-suspended igb that the
platform does not manage. pci_device_remove() calls
pm_runtime_get_sync() before drv->remove(), and during that resume
pci_power_up() does:

drivers/pci/pci.c:pci_power_up() {
    ...
	if (pci_dev_is_disconnected(dev)) {
		dev->current_state = PCI_D3cold;
		return -EIO;
	}
    ...
}

pci_target_state() then returns PCI_D3cold when igb_remove() runs. On a
part with PME from D3hot but not from D3cold, pci_dev_run_wake()
changes from true to false.

After that, pci_device_remove() runs the same sequence regardless:

drivers/pci/pci-driver.c:pci_device_remove() {
    ...
		pm_runtime_get_sync(dev);
		pm_runtime_barrier(dev);
		drv->remove(pci_dev);
		pm_runtime_put_noidle(dev);
	}
    ...
	pm_runtime_put_sync(dev);
    ...
}

If the check was false at probe and true at remove, doesn't the usage
count stay one too high for good? The device could then never runtime
suspend again, even after rebinding.

If the check was true at probe and false at remove, doesn't this drop
one reference too many?

With power/control=auto, rpm_drop_usage_count() would warn "Runtime PM
usage count underflow!". With power/control=on, the extra put would
silently cancel the pm_runtime_forbid() reference.

Would it help to save the probe-time decision in struct igb_adapter and
test that flag in igb_remove()?

e1000e and r8169 also re-check pci_dev_run_wake() in their remove paths.
Following them doesn't by itself show that the pattern stays balanced.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113105835.3821433-1-antonio%40mandelbit.com

  reply	other threads:[~2026-11-17 11:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 10:58 [PATCH net 1/3] igb: fix RTNL assertion when resuming from runtime suspend Antonio Quartulli
2026-11-13 10:58 ` [PATCH net 2/3] igb: link queues to NAPIs under RTNL after runtime resume Antonio Quartulli
2026-11-17 11:18   ` netdev-bot+sashiko
2026-11-13 10:58 ` [PATCH net 3/3] igb: only allow runtime PM if the device can wake up Antonio Quartulli
2026-11-17 11:18   ` netdev-bot+sashiko [this message]
2026-11-13 11:03 ` [PATCH net 1/3] igb: fix RTNL assertion when resuming from runtime suspend netdev-bot+sinfo
2026-11-15 19:37 ` Antonio Quartulli
2026-11-17 11:18 ` netdev-bot+sashiko

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=179491431428.3136.15501039766024079493@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=kuba@kernel.org \
    --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 \
    --cc=zheng.z.yan@intel.com \
    /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