All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI/portdrv: remove redundant pm_runtime_dont_use_autosuspend() calls
@ 2026-11-13 15:14 Joshua Crofts
  2026-11-13 15:25 ` sashiko-bot
  2026-11-13 15:40 ` Joshua Crofts
  0 siblings, 2 replies; 3+ messages in thread
From: Joshua Crofts @ 2026-11-13 15:14 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux-kernel, Joshua Crofts

Since commit d1706f9da9f4 ("PM: runtime: call pm_runtime_dont_use_autosuspend() on reinit()"),
driver core is now responsible for undoing any
pm_runtime_use_autosuspend() calls on driver exit.

Remove the redundant function calls.

Signed-off-by: Joshua Crofts <crofts@kernel.org>
---
 drivers/pci/pcie/portdrv.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
index 32fc623dd41087c7f92552117499359fae4c73d8..3ce960b4ea25e4a2bec1c9991398bc445871085d 100644
--- a/drivers/pci/pcie/portdrv.c
+++ b/drivers/pci/pcie/portdrv.c
@@ -728,7 +728,6 @@ static void pcie_portdrv_remove(struct pci_dev *dev)
 	if (pci_bridge_d3_possible(dev)) {
 		pm_runtime_forbid(&dev->dev);
 		pm_runtime_get_noresume(&dev->dev);
-		pm_runtime_dont_use_autosuspend(&dev->dev);
 	}
 
 	pcie_port_device_remove(dev);
@@ -741,7 +740,6 @@ static void pcie_portdrv_shutdown(struct pci_dev *dev)
 	if (pci_bridge_d3_possible(dev)) {
 		pm_runtime_forbid(&dev->dev);
 		pm_runtime_get_noresume(&dev->dev);
-		pm_runtime_dont_use_autosuspend(&dev->dev);
 	}
 
 	pcie_port_device_remove(dev);

---
base-commit: 7e1392a42ea288d70a266f6553fe06f57f8647ea
change-id: 20261113-pci-remove-dont-use-autosuspend-d30cbbea7888

Best regards,
-- 
Joshua Crofts <crofts@kernel.org>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI/portdrv: remove redundant pm_runtime_dont_use_autosuspend() calls
  2026-11-13 15:14 [PATCH] PCI/portdrv: remove redundant pm_runtime_dont_use_autosuspend() calls Joshua Crofts
@ 2026-11-13 15:25 ` sashiko-bot
  2026-11-13 15:40 ` Joshua Crofts
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-13 15:25 UTC (permalink / raw)
  To: Joshua Crofts; +Cc: linux-pci

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] PCI/portdrv: autosuspend state leak in pcie_portdrv_remove()
  and shutdown()
--

commit 62458954dcb1cf459473df3e377ccf5bc59b1591
Author: Joshua Crofts <crofts@kernel.org>

PCI/portdrv: remove redundant pm_runtime_dont_use_autosuspend() calls

This commit removes the pm_runtime_dont_use_autosuspend() calls from
pcie_portdrv_remove() and pcie_portdrv_shutdown(), relying on the driver
core to undo pm_runtime_use_autosuspend().

> diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
> index 32fc623dd4108..3ce960b4ea25e 100644
> --- a/drivers/pci/pcie/portdrv.c
> +++ b/drivers/pci/pcie/portdrv.c
> @@ -728,7 +728,6 @@ static void pcie_portdrv_remove(struct pci_dev *dev)
>  	if (pci_bridge_d3_possible(dev)) {
>  		pm_runtime_forbid(&dev->dev);
>  		pm_runtime_get_noresume(&dev->dev);
> -		pm_runtime_dont_use_autosuspend(&dev->dev);
>  	}
>  
>  	pcie_port_device_remove(dev);
> @@ -741,7 +740,6 @@ static void pcie_portdrv_shutdown(struct pci_dev *dev)
>  	if (pci_bridge_d3_possible(dev)) {
>  		pm_runtime_forbid(&dev->dev);
>  		pm_runtime_get_noresume(&dev->dev);
> -		pm_runtime_dont_use_autosuspend(&dev->dev);
>  	}

[Severity: Medium]
Does removing pm_runtime_dont_use_autosuspend() here leave
dev->dev.power.use_autosuspend enabled after driver unbind and system
shutdown?

pci_bus_add_device() enables runtime PM for the PCI device, and it remains
enabled across driver unbind.  Because pm_runtime_reinit() returns early
when runtime PM is enabled, device_unbind_cleanup() never calls
pm_runtime_dont_use_autosuspend():

drivers/base/power/runtime.c:pm_runtime_reinit() {
	if (pm_runtime_enabled(dev))
		return;

	if (dev->power.runtime_status == RPM_ACTIVE)
		pm_runtime_set_suspended(dev);

	if (dev->power.use_autosuspend)
		pm_runtime_dont_use_autosuspend(dev);
}

As a result, unbinding the driver leaves use_autosuspend set and leaks the
dev->dev.power.usage_count reference acquired by update_autosuspend() if a
negative autosuspend_delay_ms was written via sysfs.  In addition,
device_shutdown() invokes pcie_portdrv_shutdown() directly without calling
pm_runtime_reinit().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261113-pci-remove-dont-use-autosuspend-v1-1-413cb01fa0f6@kernel.org?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI/portdrv: remove redundant pm_runtime_dont_use_autosuspend() calls
  2026-11-13 15:14 [PATCH] PCI/portdrv: remove redundant pm_runtime_dont_use_autosuspend() calls Joshua Crofts
  2026-11-13 15:25 ` sashiko-bot
@ 2026-11-13 15:40 ` Joshua Crofts
  1 sibling, 0 replies; 3+ messages in thread
From: Joshua Crofts @ 2026-11-13 15:40 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux-kernel

On Fri, 13 Nov 2026 16:14:59 +0100
Joshua Crofts <crofts@kernel.org> wrote:

> Since commit d1706f9da9f4 ("PM: runtime: call pm_runtime_dont_use_autosuspend() on reinit()"),
> driver core is now responsible for undoing any
> pm_runtime_use_autosuspend() calls on driver exit.
> 
> Remove the redundant function calls.
> 
> Signed-off-by: Joshua Crofts <crofts@kernel.org>
> ---
>  drivers/pci/pcie/portdrv.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
> index 32fc623dd41087c7f92552117499359fae4c73d8..3ce960b4ea25e4a2bec1c9991398bc445871085d 100644
> --- a/drivers/pci/pcie/portdrv.c
> +++ b/drivers/pci/pcie/portdrv.c
> @@ -728,7 +728,6 @@ static void pcie_portdrv_remove(struct pci_dev *dev)
>  	if (pci_bridge_d3_possible(dev)) {
>  		pm_runtime_forbid(&dev->dev);
>  		pm_runtime_get_noresume(&dev->dev);
> -		pm_runtime_dont_use_autosuspend(&dev->dev);
>  	}
>  
>  	pcie_port_device_remove(dev);
> @@ -741,7 +740,6 @@ static void pcie_portdrv_shutdown(struct pci_dev *dev)
>  	if (pci_bridge_d3_possible(dev)) {
>  		pm_runtime_forbid(&dev->dev);
>  		pm_runtime_get_noresume(&dev->dev);
> -		pm_runtime_dont_use_autosuspend(&dev->dev);
>  	}
>  
>  	pcie_port_device_remove(dev);
> 

Ah, made a mistake, it can only be removed in pcie_portdrv_remove() and not in
pcie_portdrv_shutdown(). I'll send a new version, unless you can fix this up when
applying.

Thanks!

-- 
Kind regards,
Joshua Crofts

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-13 15:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 15:14 [PATCH] PCI/portdrv: remove redundant pm_runtime_dont_use_autosuspend() calls Joshua Crofts
2026-11-13 15:25 ` sashiko-bot
2026-11-13 15:40 ` Joshua Crofts

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.