Linux Power Management development
 help / color / mirror / Atom feed
From: Dhruva Gole <d-gole@ti.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
	<linux-pm@vger.kernel.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Kevin Hilman <khilman@baylibre.com>,
	Pavel Machek <pavel@kernel.org>, Len Brown <len.brown@intel.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Maulik Shah <quic_mkshah@quicinc.com>,
	"Prasad Sodagudi" <psodagud@quicinc.com>,
	Deepti Jaggi <quic_djaggi@quicinc.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 1/6] PM: QoS: Introduce a CPU system wakeup QoS limit
Date: Tue, 25 Nov 2025 10:26:18 +0530	[thread overview]
Message-ID: <20251125045618.texoubmzmiz7cz6c@lcpd911> (raw)
In-Reply-To: <20251121100315.316300-2-ulf.hansson@linaro.org>

On Nov 21, 2025 at 11:03:07 +0100, Ulf Hansson wrote:
> Some platforms supports multiple low power states for CPUs that can be used
> when entering system-wide suspend. Currently we are always selecting the
> deepest possible state for the CPUs, which can break the system wakeup
> latency constraint that may be required for a use case.
> 
> Let's take the first step towards addressing this problem, by introducing
> an interface for user space, that allows us to specify the CPU system
> wakeup QoS limit. Subsequent changes will start taking into account the new
> QoS limit.
> 
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
> 
> Changes in v3:
> 	- Add Kconfig for the new interface (Rafael).
> 	- Updated commit message.
> 
> Changes in v2:
> 	- Renamings to reflect the QoS are limited to CPUs.
> 	- Move code inside "CONFIG_CPU_IDLE".
> ---
>  include/linux/pm_qos.h |   9 ++++
>  kernel/power/Kconfig   |   4 ++
>  kernel/power/qos.c     | 106 +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 119 insertions(+)
> 
> diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h
> index 4a69d4af3ff8..6cea4455f867 100644
> --- a/include/linux/pm_qos.h
> +++ b/include/linux/pm_qos.h
> @@ -162,6 +162,15 @@ static inline void cpu_latency_qos_update_request(struct pm_qos_request *req,
>  static inline void cpu_latency_qos_remove_request(struct pm_qos_request *req) {}
>  #endif
>  
> +#ifdef CONFIG_PM_QOS_CPU_SYSTEM_WAKEUP
> +s32 cpu_wakeup_latency_qos_limit(void);
> +#else
> +static inline s32 cpu_wakeup_latency_qos_limit(void)
> +{
> +	return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT;
> +}
> +#endif
> +
>  #ifdef CONFIG_PM
>  enum pm_qos_flags_status __dev_pm_qos_flags(struct device *dev, s32 mask);
>  enum pm_qos_flags_status dev_pm_qos_flags(struct device *dev, s32 mask);
> diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
> index 54a623680019..839e2dbb889e 100644
> --- a/kernel/power/Kconfig
> +++ b/kernel/power/Kconfig
> @@ -202,6 +202,10 @@ config PM_WAKELOCKS_GC
>  	depends on PM_WAKELOCKS
>  	default y
>  
> +config PM_QOS_CPU_SYSTEM_WAKEUP
> +	bool "User space interface for CPU system wakeup QoS"
> +	depends on CPU_IDLE
> +

I see that checkpatch complains here with a warning:
please write a help paragraph that fully describes the config symbol with at least 4 lines

I somewhat agree too, since it's a new and pretty important feature that
we're putting behind this config best to add some help around it.

With that,
Reviewed-by: Dhruva Gole <d-gole@ti.com>

>  config PM
>  	bool "Device power management core functionality"
>  	help
> diff --git a/kernel/power/qos.c b/kernel/power/qos.c
> index 4244b069442e..f7d8064e9adc 100644
> --- a/kernel/power/qos.c
> +++ b/kernel/power/qos.c
> @@ -415,6 +415,105 @@ static struct miscdevice cpu_latency_qos_miscdev = {
>  	.fops = &cpu_latency_qos_fops,
>  };
>  
> +#ifdef CONFIG_PM_QOS_CPU_SYSTEM_WAKEUP
> +/* The CPU system wakeup latency QoS. */
> +static struct pm_qos_constraints cpu_wakeup_latency_constraints = {
> +	.list = PLIST_HEAD_INIT(cpu_wakeup_latency_constraints.list),
> +	.target_value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT,
> +	.default_value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT,
> +	.no_constraint_value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT,
> +	.type = PM_QOS_MIN,
> +};
> +
> +/**
> + * cpu_wakeup_latency_qos_limit - Current CPU system wakeup latency QoS limit.
> + *
> + * Returns the current CPU system wakeup latency QoS limit that may have been
> + * requested by user space.
> + */
> +s32 cpu_wakeup_latency_qos_limit(void)
> +{
> +	return pm_qos_read_value(&cpu_wakeup_latency_constraints);
> +}
> +
> +static int cpu_wakeup_latency_qos_open(struct inode *inode, struct file *filp)
> +{
> +	struct pm_qos_request *req;
> +
> +	req = kzalloc(sizeof(*req), GFP_KERNEL);
> +	if (!req)
> +		return -ENOMEM;
> +
> +	req->qos = &cpu_wakeup_latency_constraints;
> +	pm_qos_update_target(req->qos, &req->node, PM_QOS_ADD_REQ,
> +			     PM_QOS_RESUME_LATENCY_NO_CONSTRAINT);
> +	filp->private_data = req;
> +
> +	return 0;
> +}
> +
> +static int cpu_wakeup_latency_qos_release(struct inode *inode,
> +					  struct file *filp)
> +{
> +	struct pm_qos_request *req = filp->private_data;
> +
> +	filp->private_data = NULL;
> +	pm_qos_update_target(req->qos, &req->node, PM_QOS_REMOVE_REQ,
> +			     PM_QOS_RESUME_LATENCY_NO_CONSTRAINT);
> +	kfree(req);
> +
> +	return 0;
> +}
> +
> +static ssize_t cpu_wakeup_latency_qos_read(struct file *filp, char __user *buf,
> +					   size_t count, loff_t *f_pos)
> +{
> +	s32 value = pm_qos_read_value(&cpu_wakeup_latency_constraints);
> +
> +	return simple_read_from_buffer(buf, count, f_pos, &value, sizeof(s32));
> +}
> +
> +static ssize_t cpu_wakeup_latency_qos_write(struct file *filp,
> +					    const char __user *buf,
> +					    size_t count, loff_t *f_pos)
> +{
> +	struct pm_qos_request *req = filp->private_data;
> +	s32 value;
> +
> +	if (count == sizeof(s32)) {
> +		if (copy_from_user(&value, buf, sizeof(s32)))
> +			return -EFAULT;
> +	} else {
> +		int ret;
> +
> +		ret = kstrtos32_from_user(buf, count, 16, &value);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	if (value < 0)
> +		return -EINVAL;
> +
> +	pm_qos_update_target(req->qos, &req->node, PM_QOS_UPDATE_REQ, value);
> +
> +	return count;
> +}
> +
> +static const struct file_operations cpu_wakeup_latency_qos_fops = {
> +	.open = cpu_wakeup_latency_qos_open,
> +	.release = cpu_wakeup_latency_qos_release,
> +	.read = cpu_wakeup_latency_qos_read,
> +	.write = cpu_wakeup_latency_qos_write,
> +	.llseek = noop_llseek,
> +};
> +
> +static struct miscdevice cpu_wakeup_latency_qos_miscdev = {
> +	.minor = MISC_DYNAMIC_MINOR,
> +	.name = "cpu_wakeup_latency",
> +	.fops = &cpu_wakeup_latency_qos_fops,
> +};
> +#endif /* CONFIG_PM_QOS_CPU_SYSTEM_WAKEUP */
> +
>  static int __init cpu_latency_qos_init(void)
>  {
>  	int ret;
> @@ -424,6 +523,13 @@ static int __init cpu_latency_qos_init(void)
>  		pr_err("%s: %s setup failed\n", __func__,
>  		       cpu_latency_qos_miscdev.name);
>  
> +#ifdef CONFIG_PM_QOS_CPU_SYSTEM_WAKEUP
> +	ret = misc_register(&cpu_wakeup_latency_qos_miscdev);
> +	if (ret < 0)
> +		pr_err("%s: %s setup failed\n", __func__,
> +		       cpu_wakeup_latency_qos_miscdev.name);
> +#endif
> +


-- 
Best regards,
Dhruva Gole
Texas Instruments Incorporated

  reply	other threads:[~2025-11-25  4:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21 10:03 [PATCH v3 0/6] PM: QoS: Introduce a CPU system wakeup QoS limit for s2idle Ulf Hansson
2025-11-21 10:03 ` [PATCH v3 1/6] PM: QoS: Introduce a CPU system wakeup QoS limit Ulf Hansson
2025-11-25  4:56   ` Dhruva Gole [this message]
2025-11-21 10:03 ` [PATCH v3 2/6] pmdomain: Respect the CPU system wakeup QoS limit for s2idle Ulf Hansson
2025-11-25  5:27   ` Dhruva Gole
2025-11-21 10:03 ` [PATCH v3 3/6] pmdomain: Respect the CPU system wakeup QoS limit for cpuidle Ulf Hansson
2025-11-25  5:28   ` Dhruva Gole
2025-11-21 10:03 ` [PATCH v3 4/6] sched: idle: Respect the CPU system wakeup QoS limit for s2idle Ulf Hansson
2025-11-25  5:39   ` Dhruva Gole
2025-11-21 10:03 ` [PATCH v3 5/6] cpuidle: Respect the CPU system wakeup QoS limit for cpuidle Ulf Hansson
2025-11-25  5:41   ` Dhruva Gole
2025-11-21 10:03 ` [PATCH v3 6/6] Documentation: power/cpuidle: Document the CPU system wakeup latency QoS Ulf Hansson
2025-11-24 18:36   ` Dhruva Gole
2025-11-24 18:27 ` [PATCH v3 0/6] PM: QoS: Introduce a CPU system wakeup QoS limit for s2idle Rafael J. Wysocki
2025-11-25 11:31   ` Ulf Hansson
2025-11-24 23:43 ` Kevin Hilman

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=20251125045618.texoubmzmiz7cz6c@lcpd911 \
    --to=d-gole@ti.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=khilman@baylibre.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=peterz@infradead.org \
    --cc=psodagud@quicinc.com \
    --cc=quic_djaggi@quicinc.com \
    --cc=quic_mkshah@quicinc.com \
    --cc=rafael@kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=vincent.guittot@linaro.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