public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2 1/5] PCI: host-common: Add helper to determine host bridge D3cold eligibility
       [not found] <20260217-d3cold-v2-1-89b322864043@oss.qualcomm.com>
@ 2026-02-23 18:10 ` Bjorn Helgaas
  2026-02-23 18:46   ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Bjorn Helgaas @ 2026-02-23 18:10 UTC (permalink / raw)
  To: Krishna Chaitanya Chundru
  Cc: Jingoo Han, Manivannan Sadhasivam, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
	Will Deacon, linux-pci, linux-kernel, linux-arm-msm,
	linux-arm-kernel, jonathanh, bjorn.andersson, Rafael J. Wysocki,
	linux-pm

[+cc Rafael, linux-pm]

On Tue, Feb 17, 2026 at 04:49:06PM +0530, Krishna Chaitanya Chundru wrote:
> Add a common helper, pci_host_common_can_enter_d3cold(), to determine
> whether a PCI host bridge can safely transition to D3cold.
> 
> This helper is intended to be used by PCI host controller drivers to
> decide whether they may safely put the host bridge into D3cold based on
> the power state and wakeup capabilities of downstream endpoints.
> 
> The helper walks all devices on the bridge's primary bus and only allows
> the host bridge to enter D3cold if all PCIe endpoints are already in
> PCI_D3hot. This ensures that we do not power off the host bridge while
> any active endpoint still requires the link to remain powered.
> 
> For devices that may wake the system, the helper additionally requires
> that the device supports PME wake from D3cold (via WAKE#). Devices that
> do not have wakeup enabled are not restricted by this check and do not
> block the host bridge from entering D3cold.
> 
> Devices without a bound driver and with PCI not enabled via sysfs are
> treated as inactive and therefore do not prevent the host bridge from
> entering D3cold. This allows controllers to power down more aggressively
> when there are no actively managed endpoints.

This series is currently structured so it's only applicable to native
host bridge drivers, i.e., things using DT.  Is there anything that
prevents using D3cold for host bridges in ACPI systems?

> Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
> ---
>  drivers/pci/controller/pci-host-common.c | 45 ++++++++++++++++++++++++++++++++
>  drivers/pci/controller/pci-host-common.h |  2 ++
>  2 files changed, 47 insertions(+)
> 
> diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c
> index d6258c1cffe5ec480fd2a7e50b3af39ef6ac4c8c..b0a4a3c995e80e0245657f0273a349334071013c 100644
> --- a/drivers/pci/controller/pci-host-common.c
> +++ b/drivers/pci/controller/pci-host-common.c
> @@ -106,5 +106,50 @@ void pci_host_common_remove(struct platform_device *pdev)
>  }
>  EXPORT_SYMBOL_GPL(pci_host_common_remove);
>  
> +static int pci_host_common_check_d3cold(struct pci_dev *pdev, void *userdata)
> +{
> +	bool *d3cold_allow = userdata;
> +
> +	if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ENDPOINT)
> +		return 0;
> +
> +	if (!pdev->dev.driver && !pci_is_enabled(pdev))
> +		return 0;
> +
> +	if (pdev->current_state != PCI_D3hot)
> +		goto exit;
> +
> +	if (device_may_wakeup(&pdev->dev) && !pci_pme_capable(pdev, PCI_D3cold))
> +		goto exit;
> +
> +	return 0;
> +exit:
> +	*d3cold_allow = false;
> +	return -EBUSY;
> +}
> +
> +/**
> + * pci_host_common_can_enter_d3cold - Determine whether a host bridge may enter D3cold
> + * @bridge: PCI host bridge to check
> + *
> + * Walk downstream PCIe endpoint devices and determine whether the host bridge
> + * is permitted to transition to D3cold.
> + *
> + * The host bridge may enter D3cold only if all active PCIe endpoints are in
> + * %PCI_D3hot and any wakeup-enabled endpoint is capable of generating PME from
> + * D3cold. Inactive endpoints are ignored.
> + *
> + * Return: %true if the host bridge may enter D3cold, otherwise %false.
> + */
> +bool pci_host_common_can_enter_d3cold(struct pci_host_bridge *bridge)
> +{
> +	bool d3cold_allow = true;
> +
> +	pci_walk_bus(bridge->bus, pci_host_common_check_d3cold, &d3cold_allow);
> +
> +	return d3cold_allow;
> +}
> +EXPORT_SYMBOL_GPL(pci_host_common_can_enter_d3cold);
> +
>  MODULE_DESCRIPTION("Common library for PCI host controller drivers");
>  MODULE_LICENSE("GPL v2");
> diff --git a/drivers/pci/controller/pci-host-common.h b/drivers/pci/controller/pci-host-common.h
> index b5075d4bd7eb31fbf1dc946ef1a6afd5afb5b3c6..18a731bca058828340bca84776d0e91da1edbbf7 100644
> --- a/drivers/pci/controller/pci-host-common.h
> +++ b/drivers/pci/controller/pci-host-common.h
> @@ -20,4 +20,6 @@ void pci_host_common_remove(struct platform_device *pdev);
>  
>  struct pci_config_window *pci_host_common_ecam_create(struct device *dev,
>  	struct pci_host_bridge *bridge, const struct pci_ecam_ops *ops);
> +
> +bool pci_host_common_can_enter_d3cold(struct pci_host_bridge *bridge);
>  #endif
> 
> -- 
> 2.34.1
> 

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

* Re: [PATCH v2 1/5] PCI: host-common: Add helper to determine host bridge D3cold eligibility
  2026-02-23 18:10 ` [PATCH v2 1/5] PCI: host-common: Add helper to determine host bridge D3cold eligibility Bjorn Helgaas
@ 2026-02-23 18:46   ` Rafael J. Wysocki
  2026-02-23 19:55     ` Bjorn Helgaas
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2026-02-23 18:46 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Krishna Chaitanya Chundru, Jingoo Han, Manivannan Sadhasivam,
	Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
	Bjorn Helgaas, Will Deacon, linux-pci, linux-kernel,
	linux-arm-msm, linux-arm-kernel, jonathanh, bjorn.andersson,
	Rafael J. Wysocki, linux-pm

On Mon, Feb 23, 2026 at 7:10 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> [+cc Rafael, linux-pm]
>
> On Tue, Feb 17, 2026 at 04:49:06PM +0530, Krishna Chaitanya Chundru wrote:
> > Add a common helper, pci_host_common_can_enter_d3cold(), to determine
> > whether a PCI host bridge can safely transition to D3cold.
> >
> > This helper is intended to be used by PCI host controller drivers to
> > decide whether they may safely put the host bridge into D3cold based on
> > the power state and wakeup capabilities of downstream endpoints.
> >
> > The helper walks all devices on the bridge's primary bus and only allows
> > the host bridge to enter D3cold if all PCIe endpoints are already in
> > PCI_D3hot. This ensures that we do not power off the host bridge while
> > any active endpoint still requires the link to remain powered.
> >
> > For devices that may wake the system, the helper additionally requires
> > that the device supports PME wake from D3cold (via WAKE#). Devices that
> > do not have wakeup enabled are not restricted by this check and do not
> > block the host bridge from entering D3cold.
> >
> > Devices without a bound driver and with PCI not enabled via sysfs are
> > treated as inactive and therefore do not prevent the host bridge from
> > entering D3cold. This allows controllers to power down more aggressively
> > when there are no actively managed endpoints.
>
> This series is currently structured so it's only applicable to native
> host bridge drivers, i.e., things using DT.  Is there anything that
> prevents using D3cold for host bridges in ACPI systems?

Do you mean in principle or in practice?

x86 platforms don't support PCI host bridge PM AFAICS and the ACPI
driver doesn't support PM either.  I'd rather not add it ad hoc
because of this patch series.

> > Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
> > ---
> >  drivers/pci/controller/pci-host-common.c | 45 ++++++++++++++++++++++++++++++++
> >  drivers/pci/controller/pci-host-common.h |  2 ++
> >  2 files changed, 47 insertions(+)
> >
> > diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c
> > index d6258c1cffe5ec480fd2a7e50b3af39ef6ac4c8c..b0a4a3c995e80e0245657f0273a349334071013c 100644
> > --- a/drivers/pci/controller/pci-host-common.c
> > +++ b/drivers/pci/controller/pci-host-common.c
> > @@ -106,5 +106,50 @@ void pci_host_common_remove(struct platform_device *pdev)
> >  }
> >  EXPORT_SYMBOL_GPL(pci_host_common_remove);
> >
> > +static int pci_host_common_check_d3cold(struct pci_dev *pdev, void *userdata)
> > +{
> > +     bool *d3cold_allow = userdata;
> > +
> > +     if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ENDPOINT)
> > +             return 0;
> > +
> > +     if (!pdev->dev.driver && !pci_is_enabled(pdev))
> > +             return 0;
> > +
> > +     if (pdev->current_state != PCI_D3hot)
> > +             goto exit;
> > +
> > +     if (device_may_wakeup(&pdev->dev) && !pci_pme_capable(pdev, PCI_D3cold))
> > +             goto exit;
> > +
> > +     return 0;
> > +exit:
> > +     *d3cold_allow = false;
> > +     return -EBUSY;
> > +}
> > +
> > +/**
> > + * pci_host_common_can_enter_d3cold - Determine whether a host bridge may enter D3cold
> > + * @bridge: PCI host bridge to check
> > + *
> > + * Walk downstream PCIe endpoint devices and determine whether the host bridge
> > + * is permitted to transition to D3cold.
> > + *
> > + * The host bridge may enter D3cold only if all active PCIe endpoints are in
> > + * %PCI_D3hot and any wakeup-enabled endpoint is capable of generating PME from
> > + * D3cold. Inactive endpoints are ignored.
> > + *
> > + * Return: %true if the host bridge may enter D3cold, otherwise %false.
> > + */
> > +bool pci_host_common_can_enter_d3cold(struct pci_host_bridge *bridge)
> > +{
> > +     bool d3cold_allow = true;
> > +
> > +     pci_walk_bus(bridge->bus, pci_host_common_check_d3cold, &d3cold_allow);
> > +
> > +     return d3cold_allow;
> > +}
> > +EXPORT_SYMBOL_GPL(pci_host_common_can_enter_d3cold);
> > +
> >  MODULE_DESCRIPTION("Common library for PCI host controller drivers");
> >  MODULE_LICENSE("GPL v2");
> > diff --git a/drivers/pci/controller/pci-host-common.h b/drivers/pci/controller/pci-host-common.h
> > index b5075d4bd7eb31fbf1dc946ef1a6afd5afb5b3c6..18a731bca058828340bca84776d0e91da1edbbf7 100644
> > --- a/drivers/pci/controller/pci-host-common.h
> > +++ b/drivers/pci/controller/pci-host-common.h
> > @@ -20,4 +20,6 @@ void pci_host_common_remove(struct platform_device *pdev);
> >
> >  struct pci_config_window *pci_host_common_ecam_create(struct device *dev,
> >       struct pci_host_bridge *bridge, const struct pci_ecam_ops *ops);
> > +
> > +bool pci_host_common_can_enter_d3cold(struct pci_host_bridge *bridge);
> >  #endif
> >
> > --
> > 2.34.1
> >

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

* Re: [PATCH v2 1/5] PCI: host-common: Add helper to determine host bridge D3cold eligibility
  2026-02-23 18:46   ` Rafael J. Wysocki
@ 2026-02-23 19:55     ` Bjorn Helgaas
  2026-02-23 20:03       ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Bjorn Helgaas @ 2026-02-23 19:55 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Krishna Chaitanya Chundru, Jingoo Han, Manivannan Sadhasivam,
	Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
	Bjorn Helgaas, Will Deacon, linux-pci, linux-kernel,
	linux-arm-msm, linux-arm-kernel, jonathanh, bjorn.andersson,
	linux-pm

On Mon, Feb 23, 2026 at 07:46:08PM +0100, Rafael J. Wysocki wrote:
> On Mon, Feb 23, 2026 at 7:10 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
> > On Tue, Feb 17, 2026 at 04:49:06PM +0530, Krishna Chaitanya Chundru wrote:
> > > Add a common helper, pci_host_common_can_enter_d3cold(), to determine
> > > whether a PCI host bridge can safely transition to D3cold.
> > >
> > > This helper is intended to be used by PCI host controller drivers to
> > > decide whether they may safely put the host bridge into D3cold based on
> > > the power state and wakeup capabilities of downstream endpoints.
> > >
> > > The helper walks all devices on the bridge's primary bus and only allows
> > > the host bridge to enter D3cold if all PCIe endpoints are already in
> > > PCI_D3hot. This ensures that we do not power off the host bridge while
> > > any active endpoint still requires the link to remain powered.
> > >
> > > For devices that may wake the system, the helper additionally requires
> > > that the device supports PME wake from D3cold (via WAKE#). Devices that
> > > do not have wakeup enabled are not restricted by this check and do not
> > > block the host bridge from entering D3cold.
> > >
> > > Devices without a bound driver and with PCI not enabled via sysfs are
> > > treated as inactive and therefore do not prevent the host bridge from
> > > entering D3cold. This allows controllers to power down more aggressively
> > > when there are no actively managed endpoints.
> >
> > This series is currently structured so it's only applicable to native
> > host bridge drivers, i.e., things using DT.  Is there anything that
> > prevents using D3cold for host bridges in ACPI systems?
> 
> Do you mean in principle or in practice?

Just in principle.  I was hoping for some way to tie this decision
making back to a spec.  Everything downstream being in D3 already, and
any wakeup devices supporting PME from D3cold sounds plausible to me,
but I don't know about any prescriptive spec language, and I wouldn't
want to get locked into a scheme that couldn't be supported on ACPI.

> x86 platforms don't support PCI host bridge PM AFAICS and the ACPI
> driver doesn't support PM either.  I'd rather not add it ad hoc
> because of this patch series.

Agreed.

> > > Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
> > > ---
> > >  drivers/pci/controller/pci-host-common.c | 45 ++++++++++++++++++++++++++++++++
> > >  drivers/pci/controller/pci-host-common.h |  2 ++
> > >  2 files changed, 47 insertions(+)
> > >
> > > diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c
> > > index d6258c1cffe5ec480fd2a7e50b3af39ef6ac4c8c..b0a4a3c995e80e0245657f0273a349334071013c 100644
> > > --- a/drivers/pci/controller/pci-host-common.c
> > > +++ b/drivers/pci/controller/pci-host-common.c
> > > @@ -106,5 +106,50 @@ void pci_host_common_remove(struct platform_device *pdev)
> > >  }
> > >  EXPORT_SYMBOL_GPL(pci_host_common_remove);
> > >
> > > +static int pci_host_common_check_d3cold(struct pci_dev *pdev, void *userdata)
> > > +{
> > > +     bool *d3cold_allow = userdata;
> > > +
> > > +     if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ENDPOINT)
> > > +             return 0;
> > > +
> > > +     if (!pdev->dev.driver && !pci_is_enabled(pdev))
> > > +             return 0;
> > > +
> > > +     if (pdev->current_state != PCI_D3hot)
> > > +             goto exit;
> > > +
> > > +     if (device_may_wakeup(&pdev->dev) && !pci_pme_capable(pdev, PCI_D3cold))
> > > +             goto exit;
> > > +
> > > +     return 0;
> > > +exit:
> > > +     *d3cold_allow = false;
> > > +     return -EBUSY;
> > > +}
> > > +
> > > +/**
> > > + * pci_host_common_can_enter_d3cold - Determine whether a host bridge may enter D3cold
> > > + * @bridge: PCI host bridge to check
> > > + *
> > > + * Walk downstream PCIe endpoint devices and determine whether the host bridge
> > > + * is permitted to transition to D3cold.
> > > + *
> > > + * The host bridge may enter D3cold only if all active PCIe endpoints are in
> > > + * %PCI_D3hot and any wakeup-enabled endpoint is capable of generating PME from
> > > + * D3cold. Inactive endpoints are ignored.
> > > + *
> > > + * Return: %true if the host bridge may enter D3cold, otherwise %false.
> > > + */
> > > +bool pci_host_common_can_enter_d3cold(struct pci_host_bridge *bridge)
> > > +{
> > > +     bool d3cold_allow = true;
> > > +
> > > +     pci_walk_bus(bridge->bus, pci_host_common_check_d3cold, &d3cold_allow);
> > > +
> > > +     return d3cold_allow;
> > > +}
> > > +EXPORT_SYMBOL_GPL(pci_host_common_can_enter_d3cold);
> > > +
> > >  MODULE_DESCRIPTION("Common library for PCI host controller drivers");
> > >  MODULE_LICENSE("GPL v2");
> > > diff --git a/drivers/pci/controller/pci-host-common.h b/drivers/pci/controller/pci-host-common.h
> > > index b5075d4bd7eb31fbf1dc946ef1a6afd5afb5b3c6..18a731bca058828340bca84776d0e91da1edbbf7 100644
> > > --- a/drivers/pci/controller/pci-host-common.h
> > > +++ b/drivers/pci/controller/pci-host-common.h
> > > @@ -20,4 +20,6 @@ void pci_host_common_remove(struct platform_device *pdev);
> > >
> > >  struct pci_config_window *pci_host_common_ecam_create(struct device *dev,
> > >       struct pci_host_bridge *bridge, const struct pci_ecam_ops *ops);
> > > +
> > > +bool pci_host_common_can_enter_d3cold(struct pci_host_bridge *bridge);
> > >  #endif
> > >
> > > --
> > > 2.34.1
> > >

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

* Re: [PATCH v2 1/5] PCI: host-common: Add helper to determine host bridge D3cold eligibility
  2026-02-23 19:55     ` Bjorn Helgaas
@ 2026-02-23 20:03       ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2026-02-23 20:03 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Rafael J. Wysocki, Krishna Chaitanya Chundru, Jingoo Han,
	Manivannan Sadhasivam, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
	Will Deacon, linux-pci, linux-kernel, linux-arm-msm,
	linux-arm-kernel, jonathanh, bjorn.andersson, linux-pm

On Mon, Feb 23, 2026 at 8:55 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> On Mon, Feb 23, 2026 at 07:46:08PM +0100, Rafael J. Wysocki wrote:
> > On Mon, Feb 23, 2026 at 7:10 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
> > > On Tue, Feb 17, 2026 at 04:49:06PM +0530, Krishna Chaitanya Chundru wrote:
> > > > Add a common helper, pci_host_common_can_enter_d3cold(), to determine
> > > > whether a PCI host bridge can safely transition to D3cold.
> > > >
> > > > This helper is intended to be used by PCI host controller drivers to
> > > > decide whether they may safely put the host bridge into D3cold based on
> > > > the power state and wakeup capabilities of downstream endpoints.
> > > >
> > > > The helper walks all devices on the bridge's primary bus and only allows
> > > > the host bridge to enter D3cold if all PCIe endpoints are already in
> > > > PCI_D3hot. This ensures that we do not power off the host bridge while
> > > > any active endpoint still requires the link to remain powered.
> > > >
> > > > For devices that may wake the system, the helper additionally requires
> > > > that the device supports PME wake from D3cold (via WAKE#). Devices that
> > > > do not have wakeup enabled are not restricted by this check and do not
> > > > block the host bridge from entering D3cold.
> > > >
> > > > Devices without a bound driver and with PCI not enabled via sysfs are
> > > > treated as inactive and therefore do not prevent the host bridge from
> > > > entering D3cold. This allows controllers to power down more aggressively
> > > > when there are no actively managed endpoints.
> > >
> > > This series is currently structured so it's only applicable to native
> > > host bridge drivers, i.e., things using DT.  Is there anything that
> > > prevents using D3cold for host bridges in ACPI systems?
> >
> > Do you mean in principle or in practice?
>
> Just in principle.  I was hoping for some way to tie this decision
> making back to a spec.  Everything downstream being in D3 already, and
> any wakeup devices supporting PME from D3cold sounds plausible to me,
> but I don't know about any prescriptive spec language, and I wouldn't
> want to get locked into a scheme that couldn't be supported on ACPI.

In principle, I guess someone might want to add ACPI PM support to a
PCI host bridge device object.

In theory, there may be a problem with message-based PME wakeup unless
the host bridge device has some D3cold aux power, but it at least
seems to be doable.

I think that this question is for non-x86 folks who use ACPI in their
platforms because they may just have this use case.

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

end of thread, other threads:[~2026-02-23 20:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260217-d3cold-v2-1-89b322864043@oss.qualcomm.com>
2026-02-23 18:10 ` [PATCH v2 1/5] PCI: host-common: Add helper to determine host bridge D3cold eligibility Bjorn Helgaas
2026-02-23 18:46   ` Rafael J. Wysocki
2026-02-23 19:55     ` Bjorn Helgaas
2026-02-23 20:03       ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox