* [PATCH v2 0/3] PM: QoS/pmdomains: support resume latencies for system-wide PM
@ 2026-02-06 0:29 Kevin Hilman (TI)
2026-02-06 0:29 ` [PATCH v2 1/3] PM / QoS: add flag to indicate latency applies system-wide Kevin Hilman (TI)
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Kevin Hilman (TI) @ 2026-02-06 0:29 UTC (permalink / raw)
To: Rafael J. Wysocki, Ulf Hansson, linux-pm; +Cc: Dhruva Gole, linux-kernel
Currently QoS resume latencies are only considered for runtime PM
transitions of pmdomains, which remains the default.
In order to also support QoS resume latencies during system-wide PM,
add a new flag to indicate a resume latency should be used for
system-wide PM *in addition to* runtime PM.
If a user requires a different latency value for system-wide PM
compared to runtime PM, then the runtime PM value can be set for
normal operations, and the system-wide value (and flag) can be set by
during suspend (for example in a drivers ->prepare() hook) and the
runtime PM value can be restored after resume (for example, in a
driver's ->complete() hook.)
To: Rafael J. Wysocki <rafael@kernel.org>
To: Ulf Hansson <ulf.hansson@linaro.org>
To: linux-pm@vger.kernel.org
Signed-off-by: Kevin Hilman (TI) <khilman@baylibre.com>
---
Changes in v2:
- drop the userspace interface
- add genpd helper to iterate over all devices in domain and child domains
- new flag means latency applies to runtime PM *and* system-wide PM
- Link to v1: https://patch.msgid.link/20260120-topic-lpm-pmdomain-device-constraints-v1-0-108fc4cfafce@baylibre.com
---
Kevin Hilman (TI) (3):
PM / QoS: add flag to indicate latency applies system-wide
pmdomain: core: add genpd_for_each_child() helper
pmdommain: add support system-wide resume latency constraints
drivers/pmdomain/core.c | 42 ++++++++++++++++++++++++++++++++++++++++++
drivers/pmdomain/core.h | 17 +++++++++++++++++
drivers/pmdomain/governor.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
include/linux/pm_qos.h | 2 ++
4 files changed, 106 insertions(+)
---
base-commit: 3e7f562e20ee87a25e104ef4fce557d39d62fa85
change-id: 20260120-topic-lpm-pmdomain-device-constraints-e5e78ce48502
Best regards,
--
Kevin Hilman (TI) <khilman@baylibre.com>
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH v2 1/3] PM / QoS: add flag to indicate latency applies system-wide 2026-02-06 0:29 [PATCH v2 0/3] PM: QoS/pmdomains: support resume latencies for system-wide PM Kevin Hilman (TI) @ 2026-02-06 0:29 ` Kevin Hilman (TI) 2026-02-10 16:57 ` Rafael J. Wysocki 2026-02-06 0:29 ` [PATCH v2 2/3] pmdomain: core: add genpd_for_each_child() helper Kevin Hilman (TI) 2026-02-06 0:29 ` [PATCH v2 3/3] pmdommain: add support system-wide resume latency constraints Kevin Hilman (TI) 2 siblings, 1 reply; 9+ messages in thread From: Kevin Hilman (TI) @ 2026-02-06 0:29 UTC (permalink / raw) To: Rafael J. Wysocki, Ulf Hansson, linux-pm; +Cc: Dhruva Gole, linux-kernel By default, the QoS resume latency currenly only applied to runtime PM decisions. Add new PM_QOS_FLAG_LATENCY_SYS flag to indicate that the resume latency QoS constraint should be applied to system-wide PM *in addition to* runtime PM. Signed-off-by: Kevin Hilman (TI) <khilman@baylibre.com> --- include/linux/pm_qos.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 6cea4455f867..aededda52b6b 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -37,6 +37,8 @@ enum pm_qos_flags_status { #define PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT (-1) #define PM_QOS_FLAG_NO_POWER_OFF (1 << 0) +/* latency value applies to system-wide suspend/s2idle */ +#define PM_QOS_FLAG_LATENCY_SYS (2 << 0) enum pm_qos_type { PM_QOS_UNITIALIZED, -- 2.51.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/3] PM / QoS: add flag to indicate latency applies system-wide 2026-02-06 0:29 ` [PATCH v2 1/3] PM / QoS: add flag to indicate latency applies system-wide Kevin Hilman (TI) @ 2026-02-10 16:57 ` Rafael J. Wysocki 0 siblings, 0 replies; 9+ messages in thread From: Rafael J. Wysocki @ 2026-02-10 16:57 UTC (permalink / raw) To: Kevin Hilman (TI) Cc: Rafael J. Wysocki, Ulf Hansson, linux-pm, Dhruva Gole, linux-kernel On Fri, Feb 6, 2026 at 1:30 AM Kevin Hilman (TI) <khilman@baylibre.com> wrote: > > By default, the QoS resume latency currenly only applied to runtime PM > decisions. > > Add new PM_QOS_FLAG_LATENCY_SYS flag to indicate that the > resume latency QoS constraint should be applied to system-wide > PM *in addition to* runtime PM. > > Signed-off-by: Kevin Hilman (TI) <khilman@baylibre.com> Acked-by: Rafael J. Wysocki (Intel) <rafael@kernel.org> > --- > include/linux/pm_qos.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h > index 6cea4455f867..aededda52b6b 100644 > --- a/include/linux/pm_qos.h > +++ b/include/linux/pm_qos.h > @@ -37,6 +37,8 @@ enum pm_qos_flags_status { > #define PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT (-1) > > #define PM_QOS_FLAG_NO_POWER_OFF (1 << 0) > +/* latency value applies to system-wide suspend/s2idle */ > +#define PM_QOS_FLAG_LATENCY_SYS (2 << 0) > > enum pm_qos_type { > PM_QOS_UNITIALIZED, > > -- > 2.51.0 > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 2/3] pmdomain: core: add genpd_for_each_child() helper 2026-02-06 0:29 [PATCH v2 0/3] PM: QoS/pmdomains: support resume latencies for system-wide PM Kevin Hilman (TI) 2026-02-06 0:29 ` [PATCH v2 1/3] PM / QoS: add flag to indicate latency applies system-wide Kevin Hilman (TI) @ 2026-02-06 0:29 ` Kevin Hilman (TI) 2026-03-10 10:09 ` Ulf Hansson 2026-02-06 0:29 ` [PATCH v2 3/3] pmdommain: add support system-wide resume latency constraints Kevin Hilman (TI) 2 siblings, 1 reply; 9+ messages in thread From: Kevin Hilman (TI) @ 2026-02-06 0:29 UTC (permalink / raw) To: Rafael J. Wysocki, Ulf Hansson, linux-pm; +Cc: Dhruva Gole, linux-kernel Add a new internal helper function genpd_for_each_child() that recursively iterates over all devices in a PM domain and its child domains (subdomains). This helper is useful for governors and other core PM domain code that needs to examine or apply operations to all devices within a domain hierarchy. The function takes a callback that is invoked for each device, and supports early termination if the callback returns a non-zero value. The helper is defined in a new internal header drivers/pmdomain/core.h and implemented in drivers/pmdomain/core.c, making it available to other PM domain subsystem components. The first user of this helper is the cpu_system_power_down_ok() governor function, which uses it to check device QoS latency constraints across the entire domain hierarchy. Signed-off-by: Kevin Hilman (TI) <khilman@baylibre.com> --- drivers/pmdomain/core.c | 42 ++++++++++++++++++++++++++++++++++++++++++ drivers/pmdomain/core.h | 17 +++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index bf82775f6a67..41c987fc5c5a 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -24,6 +24,8 @@ #include <linux/cpu.h> #include <linux/debugfs.h> +#include "core.h" + /* Provides a unique ID for each genpd device */ static DEFINE_IDA(genpd_ida); @@ -281,6 +283,46 @@ static void genpd_sd_counter_inc(struct generic_pm_domain *genpd) smp_mb__after_atomic(); } +/** + * genpd_for_each_child - Recursively iterate over all devices + * in a PM domain and its subdomains. + * @genpd: PM domain to iterate over. + * @fn: Callback function to invoke for each device. + * @data: Data to pass to the callback function. + * + * This function recursively walks through all devices in the given PM domain + * and all devices in its child PM domains (subdomains). For each device found, + * the callback function @fn is invoked with the device and @data as arguments. + * + * Returns: 0 on success, or the first non-zero value returned by @fn. + */ +int genpd_for_each_child(struct generic_pm_domain *genpd, + int (*fn)(struct device *dev, void *data), + void *data) +{ + struct pm_domain_data *pdd; + struct gpd_link *link; + int ret; + + /* First, iterate over all devices in this domain */ + list_for_each_entry(pdd, &genpd->dev_list, list_node) { + ret = fn(pdd->dev, data); + if (ret) + return ret; + } + + /* Then, recursively iterate over all child domains (subdomains) */ + list_for_each_entry(link, &genpd->parent_links, parent_node) { + struct generic_pm_domain *child_pd = link->child; + + ret = genpd_for_each_child(child_pd, fn, data); + if (ret) + return ret; + } + + return 0; +} + #ifdef CONFIG_DEBUG_FS static struct dentry *genpd_debugfs_dir; diff --git a/drivers/pmdomain/core.h b/drivers/pmdomain/core.h new file mode 100644 index 000000000000..7061891d31fb --- /dev/null +++ b/drivers/pmdomain/core.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Internal header for PM domain core + * + * Copyright (C) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Renesas Electronics Corp. + */ + +#ifndef __PM_DOMAIN_CORE_H__ +#define __PM_DOMAIN_CORE_H__ + +#include <linux/pm_domain.h> + +int genpd_for_each_child(struct generic_pm_domain *genpd, + int (*fn)(struct device *dev, void *data), + void *data); + +#endif /* __PM_DOMAIN_CORE_H__ */ -- 2.51.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/3] pmdomain: core: add genpd_for_each_child() helper 2026-02-06 0:29 ` [PATCH v2 2/3] pmdomain: core: add genpd_for_each_child() helper Kevin Hilman (TI) @ 2026-03-10 10:09 ` Ulf Hansson 0 siblings, 0 replies; 9+ messages in thread From: Ulf Hansson @ 2026-03-10 10:09 UTC (permalink / raw) To: Kevin Hilman (TI); +Cc: Rafael J. Wysocki, linux-pm, Dhruva Gole, linux-kernel On Fri, 6 Feb 2026 at 01:30, Kevin Hilman (TI) <khilman@baylibre.com> wrote: > > Add a new internal helper function genpd_for_each_child() that recursively > iterates over all devices in a PM domain and its child domains (subdomains). > This helper is useful for governors and other core PM domain code that needs > to examine or apply operations to all devices within a domain hierarchy. > > The function takes a callback that is invoked for each device, and supports > early termination if the callback returns a non-zero value. > > The helper is defined in a new internal header drivers/pmdomain/core.h and > implemented in drivers/pmdomain/core.c, making it available to other PM > domain subsystem components. I think it's important to state that this isn't for pmdomain providers to use, but only for the core and the governor. Perhaps add a comment about that too in the function description. That said, if there is only one user, perhaps adding a helper isn't worth it after all? > > The first user of this helper is the cpu_system_power_down_ok() governor > function, which uses it to check device QoS latency constraints across the > entire domain hierarchy. > > Signed-off-by: Kevin Hilman (TI) <khilman@baylibre.com> > --- > drivers/pmdomain/core.c | 42 ++++++++++++++++++++++++++++++++++++++++++ > drivers/pmdomain/core.h | 17 +++++++++++++++++ > 2 files changed, 59 insertions(+) > > diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c > index bf82775f6a67..41c987fc5c5a 100644 > --- a/drivers/pmdomain/core.c > +++ b/drivers/pmdomain/core.c > @@ -24,6 +24,8 @@ > #include <linux/cpu.h> > #include <linux/debugfs.h> > > +#include "core.h" > + > /* Provides a unique ID for each genpd device */ > static DEFINE_IDA(genpd_ida); > > @@ -281,6 +283,46 @@ static void genpd_sd_counter_inc(struct generic_pm_domain *genpd) > smp_mb__after_atomic(); > } > > +/** > + * genpd_for_each_child - Recursively iterate over all devices > + * in a PM domain and its subdomains. > + * @genpd: PM domain to iterate over. > + * @fn: Callback function to invoke for each device. > + * @data: Data to pass to the callback function. > + * > + * This function recursively walks through all devices in the given PM domain > + * and all devices in its child PM domains (subdomains). For each device found, > + * the callback function @fn is invoked with the device and @data as arguments. > + * > + * Returns: 0 on success, or the first non-zero value returned by @fn. > + */ > +int genpd_for_each_child(struct generic_pm_domain *genpd, > + int (*fn)(struct device *dev, void *data), > + void *data) > +{ > + struct pm_domain_data *pdd; > + struct gpd_link *link; > + int ret; > + > + /* First, iterate over all devices in this domain */ > + list_for_each_entry(pdd, &genpd->dev_list, list_node) { > + ret = fn(pdd->dev, data); > + if (ret) > + return ret; > + } > + > + /* Then, recursively iterate over all child domains (subdomains) */ > + list_for_each_entry(link, &genpd->parent_links, parent_node) { > + struct generic_pm_domain *child_pd = link->child; > + > + ret = genpd_for_each_child(child_pd, fn, data); > + if (ret) > + return ret; > + } > + > + return 0; > +} > + > #ifdef CONFIG_DEBUG_FS > static struct dentry *genpd_debugfs_dir; > > diff --git a/drivers/pmdomain/core.h b/drivers/pmdomain/core.h > new file mode 100644 > index 000000000000..7061891d31fb > --- /dev/null > +++ b/drivers/pmdomain/core.h > @@ -0,0 +1,17 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Internal header for PM domain core > + * > + * Copyright (C) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Renesas Electronics Corp. > + */ > + > +#ifndef __PM_DOMAIN_CORE_H__ > +#define __PM_DOMAIN_CORE_H__ > + > +#include <linux/pm_domain.h> > + > +int genpd_for_each_child(struct generic_pm_domain *genpd, > + int (*fn)(struct device *dev, void *data), > + void *data); > + > +#endif /* __PM_DOMAIN_CORE_H__ */ > > -- > 2.51.0 > Kind regards Uffe ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 3/3] pmdommain: add support system-wide resume latency constraints 2026-02-06 0:29 [PATCH v2 0/3] PM: QoS/pmdomains: support resume latencies for system-wide PM Kevin Hilman (TI) 2026-02-06 0:29 ` [PATCH v2 1/3] PM / QoS: add flag to indicate latency applies system-wide Kevin Hilman (TI) 2026-02-06 0:29 ` [PATCH v2 2/3] pmdomain: core: add genpd_for_each_child() helper Kevin Hilman (TI) @ 2026-02-06 0:29 ` Kevin Hilman (TI) 2026-02-11 21:29 ` Kendall Willis 2026-03-10 10:23 ` Ulf Hansson 2 siblings, 2 replies; 9+ messages in thread From: Kevin Hilman (TI) @ 2026-02-06 0:29 UTC (permalink / raw) To: Rafael J. Wysocki, Ulf Hansson, linux-pm; +Cc: Dhruva Gole, linux-kernel In addition to checking for CPU latency constraints when checking if OK to power down a domain, also check for QoS latency constraints in all devices of a domain and use that in determining the final latency constraint to use for the domain. Since cpu_system_power_down_ok() is used for system-wide suspend, the per-device constratints are only relevant if the LATENCY_SYS QoS flag is set. Signed-off-by: Kevin Hilman (TI) <khilman@baylibre.com> --- drivers/pmdomain/governor.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/pmdomain/governor.c b/drivers/pmdomain/governor.c index 96737abbb496..bbf59b93c8b6 100644 --- a/drivers/pmdomain/governor.c +++ b/drivers/pmdomain/governor.c @@ -13,6 +13,8 @@ #include <linux/cpumask.h> #include <linux/ktime.h> +#include "core.h" + static int dev_update_qos_constraint(struct device *dev, void *data) { s64 *constraint_ns_p = data; @@ -425,17 +427,60 @@ static bool cpu_power_down_ok(struct dev_pm_domain *pd) return true; } +/** + * check_device_qos_latency - Callback to check device QoS latency constraints + * @dev: Device to check + * @data: Pointer to s32 variable holding minimum latency found so far + * + * This callback checks if the device has a system-wide resume latency QoS + * constraint and updates the minimum latency if this device has a stricter + * constraint. + * + * Returns: 0 to continue iteration. + */ +static int check_device_qos_latency(struct device *dev, void *data) +{ + s32 *min_dev_latency = data; + enum pm_qos_flags_status flag_status; + s32 dev_latency; + + dev_latency = dev_pm_qos_read_value(dev, DEV_PM_QOS_RESUME_LATENCY); + flag_status = dev_pm_qos_flags(dev, PM_QOS_FLAG_LATENCY_SYS); + if ((dev_latency != PM_QOS_RESUME_LATENCY_NO_CONSTRAINT) && + (flag_status == PM_QOS_FLAGS_ALL)) { + dev_dbg(dev, + "has QoS system-wide resume latency=%d\n", + dev_latency); + if (dev_latency < *min_dev_latency) + *min_dev_latency = dev_latency; + } + + return 0; +} + static bool cpu_system_power_down_ok(struct dev_pm_domain *pd) { s64 constraint_ns = cpu_wakeup_latency_qos_limit() * NSEC_PER_USEC; struct generic_pm_domain *genpd = pd_to_genpd(pd); int state_idx = genpd->state_count - 1; + s32 min_dev_latency = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; + s64 min_dev_latency_ns = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT_NS; if (!(genpd->flags & GENPD_FLAG_CPU_DOMAIN)) { genpd->state_idx = state_idx; return true; } + genpd_for_each_child(genpd, check_device_qos_latency, + &min_dev_latency); + + /* If device latency < CPU wakeup latency, use it instead */ + if (min_dev_latency != PM_QOS_RESUME_LATENCY_NO_CONSTRAINT) { + min_dev_latency_ns = min_dev_latency * NSEC_PER_USEC; + if (min_dev_latency_ns < constraint_ns) + constraint_ns = min_dev_latency_ns; + } + /* Find the deepest state for the latency constraint. */ while (state_idx >= 0) { s64 latency_ns = genpd->states[state_idx].power_off_latency_ns + -- 2.51.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] pmdommain: add support system-wide resume latency constraints 2026-02-06 0:29 ` [PATCH v2 3/3] pmdommain: add support system-wide resume latency constraints Kevin Hilman (TI) @ 2026-02-11 21:29 ` Kendall Willis 2026-02-26 17:43 ` Kevin Hilman 2026-03-10 10:23 ` Ulf Hansson 1 sibling, 1 reply; 9+ messages in thread From: Kendall Willis @ 2026-02-11 21:29 UTC (permalink / raw) To: Kevin Hilman (TI), Rafael J. Wysocki, Ulf Hansson, linux-pm Cc: Dhruva Gole, linux-kernel Hi Kevin, On 2/5/26 18:29, Kevin Hilman (TI) wrote: > In addition to checking for CPU latency constraints when checking if > OK to power down a domain, also check for QoS latency constraints in > all devices of a domain and use that in determining the final latency > constraint to use for the domain. > > Since cpu_system_power_down_ok() is used for system-wide suspend, the > per-device constratints are only relevant if the LATENCY_SYS QoS flag > is set. > > Signed-off-by: Kevin Hilman (TI) <khilman@baylibre.com> > --- Were you planning to also check the CPU devices QoS latency constraints in the cpu_system_power_down_ok function? At present, this patch does not add that functionality so if the PM_QOS_FLAG_LATENCY_SYS is present for a CPU device, the QoS latency is not taken into account. Best, Kendall Willis <k-willis@ti.com> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] pmdommain: add support system-wide resume latency constraints 2026-02-11 21:29 ` Kendall Willis @ 2026-02-26 17:43 ` Kevin Hilman 0 siblings, 0 replies; 9+ messages in thread From: Kevin Hilman @ 2026-02-26 17:43 UTC (permalink / raw) To: Kendall Willis, Rafael J. Wysocki, Ulf Hansson, linux-pm Cc: Dhruva Gole, linux-kernel Kendall Willis <k-willis@ti.com> writes: > Hi Kevin, > On 2/5/26 18:29, Kevin Hilman (TI) wrote: >> In addition to checking for CPU latency constraints when checking if >> OK to power down a domain, also check for QoS latency constraints in >> all devices of a domain and use that in determining the final latency >> constraint to use for the domain. >> >> Since cpu_system_power_down_ok() is used for system-wide suspend, the >> per-device constratints are only relevant if the LATENCY_SYS QoS flag >> is set. >> >> Signed-off-by: Kevin Hilman (TI) <khilman@baylibre.com> >> --- > > Were you planning to also check the CPU devices QoS latency constraints > in the cpu_system_power_down_ok function? At present, this patch does > not add that functionality so if the PM_QOS_FLAG_LATENCY_SYS is present > for a CPU device, the QoS latency is not taken into account. I did not add that functionality because the CPUs are managed by the new system-wide /dev/cpu_wakeup_latency, which is already checked. Kevin ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] pmdommain: add support system-wide resume latency constraints 2026-02-06 0:29 ` [PATCH v2 3/3] pmdommain: add support system-wide resume latency constraints Kevin Hilman (TI) 2026-02-11 21:29 ` Kendall Willis @ 2026-03-10 10:23 ` Ulf Hansson 1 sibling, 0 replies; 9+ messages in thread From: Ulf Hansson @ 2026-03-10 10:23 UTC (permalink / raw) To: Kevin Hilman (TI); +Cc: Rafael J. Wysocki, linux-pm, Dhruva Gole, linux-kernel On Fri, 6 Feb 2026 at 01:30, Kevin Hilman (TI) <khilman@baylibre.com> wrote: > > In addition to checking for CPU latency constraints when checking if > OK to power down a domain, also check for QoS latency constraints in > all devices of a domain and use that in determining the final latency > constraint to use for the domain. > > Since cpu_system_power_down_ok() is used for system-wide suspend, the > per-device constratints are only relevant if the LATENCY_SYS QoS flag > is set. > > Signed-off-by: Kevin Hilman (TI) <khilman@baylibre.com> > --- > drivers/pmdomain/governor.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > > diff --git a/drivers/pmdomain/governor.c b/drivers/pmdomain/governor.c > index 96737abbb496..bbf59b93c8b6 100644 > --- a/drivers/pmdomain/governor.c > +++ b/drivers/pmdomain/governor.c > @@ -13,6 +13,8 @@ > #include <linux/cpumask.h> > #include <linux/ktime.h> > > +#include "core.h" > + > static int dev_update_qos_constraint(struct device *dev, void *data) > { > s64 *constraint_ns_p = data; > @@ -425,17 +427,60 @@ static bool cpu_power_down_ok(struct dev_pm_domain *pd) > return true; > } > > +/** > + * check_device_qos_latency - Callback to check device QoS latency constraints > + * @dev: Device to check > + * @data: Pointer to s32 variable holding minimum latency found so far > + * > + * This callback checks if the device has a system-wide resume latency QoS > + * constraint and updates the minimum latency if this device has a stricter > + * constraint. > + * > + * Returns: 0 to continue iteration. > + */ > +static int check_device_qos_latency(struct device *dev, void *data) > +{ > + s32 *min_dev_latency = data; > + enum pm_qos_flags_status flag_status; > + s32 dev_latency; > + > + dev_latency = dev_pm_qos_read_value(dev, DEV_PM_QOS_RESUME_LATENCY); ->cpu_system_power_down_ok() executes in atomic context on a PREEMPT_RT configured system. dev_pm_qos_read_value() uses spinlocks, which sleep in that configuration. I don't know the best approach to fix this. Perhaps add a specific dev_pm_qos interface that can be used here? Or re-work the code so it only applies for !PREEMPT_RT? > + flag_status = dev_pm_qos_flags(dev, PM_QOS_FLAG_LATENCY_SYS); > + if ((dev_latency != PM_QOS_RESUME_LATENCY_NO_CONSTRAINT) && > + (flag_status == PM_QOS_FLAGS_ALL)) { > + dev_dbg(dev, > + "has QoS system-wide resume latency=%d\n", > + dev_latency); > + if (dev_latency < *min_dev_latency) > + *min_dev_latency = dev_latency; > + } > + > + return 0; > +} > + > static bool cpu_system_power_down_ok(struct dev_pm_domain *pd) > { > s64 constraint_ns = cpu_wakeup_latency_qos_limit() * NSEC_PER_USEC; > struct generic_pm_domain *genpd = pd_to_genpd(pd); > int state_idx = genpd->state_count - 1; > + s32 min_dev_latency = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; > + s64 min_dev_latency_ns = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT_NS; > > if (!(genpd->flags & GENPD_FLAG_CPU_DOMAIN)) { > genpd->state_idx = state_idx; > return true; > } > > + genpd_for_each_child(genpd, check_device_qos_latency, > + &min_dev_latency); > + > + /* If device latency < CPU wakeup latency, use it instead */ > + if (min_dev_latency != PM_QOS_RESUME_LATENCY_NO_CONSTRAINT) { > + min_dev_latency_ns = min_dev_latency * NSEC_PER_USEC; > + if (min_dev_latency_ns < constraint_ns) > + constraint_ns = min_dev_latency_ns; > + } > + > /* Find the deepest state for the latency constraint. */ > while (state_idx >= 0) { > s64 latency_ns = genpd->states[state_idx].power_off_latency_ns + > > -- > 2.51.0 > Kind regards Uffe ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-03-10 10:24 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-02-06 0:29 [PATCH v2 0/3] PM: QoS/pmdomains: support resume latencies for system-wide PM Kevin Hilman (TI) 2026-02-06 0:29 ` [PATCH v2 1/3] PM / QoS: add flag to indicate latency applies system-wide Kevin Hilman (TI) 2026-02-10 16:57 ` Rafael J. Wysocki 2026-02-06 0:29 ` [PATCH v2 2/3] pmdomain: core: add genpd_for_each_child() helper Kevin Hilman (TI) 2026-03-10 10:09 ` Ulf Hansson 2026-02-06 0:29 ` [PATCH v2 3/3] pmdommain: add support system-wide resume latency constraints Kevin Hilman (TI) 2026-02-11 21:29 ` Kendall Willis 2026-02-26 17:43 ` Kevin Hilman 2026-03-10 10:23 ` Ulf Hansson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox