From nobody Sun Feb 8 12:31:40 2026 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AD882D9EE6 for ; Thu, 16 Oct 2025 15:19:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760627984; cv=none; b=hqel1TaQ5rZ8VGRN73XREZ13KTMhSLgDMw+Ot52z71Be/u6YZ3z/jEzvhYKkE87JQA+BdgvlHid/qJpqG1xprmkTjCKodc85MT6S3PLoO+hNkTzJ8G0LRAYTTl9PbKrAJjcTL7+v2fGaEi3O2qTCC7O9kQVjLYN72XSDa4i+ZLU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760627984; c=relaxed/simple; bh=sCfbpHo5fIF3/zQ3JHtaRMEvTMmL6ALOlZnjy4ooLO8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I9tvHmKB5f2drorpsYVzs9XtGuMiXDR3uJtsRlqRYFQYyr5oMd1yn5Csr1qzvMpR3oxvm7h1PnwaXuPIx2ED1oUEaNABIFG8/AfIKP1f1/gJCy0LNOnDdDoc3ZSZU0bMJNT325sMqnIW4XE5t0ho9Vl9prMMzW2NpQAZqwHPouA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=jEcUDrG/; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jEcUDrG/" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-57dfd0b6cd7so1097405e87.0 for ; Thu, 16 Oct 2025 08:19:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760627980; x=1761232780; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KgcvO+gPEQsR+HMyLzcQjdVtkJ1xXNA2WBarA1I1cN8=; b=jEcUDrG/i+t8en9kX0+kW1saQ4Znz79ligkq3O0hwJDQQp3bow9idyRWR6aWIf4W5J H9naIvAtKjIgirJAFtKWMJSXYblZe0s5gk9DrlNwLdIS0q9fRWmmkX5L6zeMwvXv243L r0NRoXzMj1oEz23lQYWoc45dYj2NbEJIugT4Oj2oMj92KNIrDqKkFcYOq4w4KHqX1+Qi M031mtK/ZqdDku9JKvouxpJ8JkWOErYv41we7gwn8hCY8/7YuAv7Dbfzvu3XytGsnZ2u GRrros+I/hyNi7ZmA9VCq5aWbn3m93yOFegIBnUBrvsMkzfMI0QeXLfyZ3wO+ZRE25DV HqDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760627980; x=1761232780; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KgcvO+gPEQsR+HMyLzcQjdVtkJ1xXNA2WBarA1I1cN8=; b=pURPJA4x8JWIeFPrFmCeyUONVhjvuPTd6MXNyIWPmIdsmPzW4Q+ss5KG+A6q0P1ab8 JBGAWuhdAB+8oZytOhwHM3j3/88MFKCcD+frbQSWy13wXZj+IYAZVRyq8tq4rDE2RRm5 Dxw4MJo2Y5UbTCe5Q65i2QOqm6W380UbSv0JzljbT+/JmnwGfvbYFIlYF/zyhVeeO57O +KnTfcti/IN2i6iTrNsVKp37thHg7qEh1QnYPd3av9/cX3tBldGuvjmEpp9vaRNW53JH PzmXOv0/4Bzl+y0yYy/0cMxjzwY6pJ7E0iu8CtfIBFMYBiM3yihiA1inVEPHjLDDrI6b N/TA== X-Forwarded-Encrypted: i=1; AJvYcCUqKFmoABFS8ti2oprpicQDzho1IoqM6huuYQIpxmQhemDTGZnEWz1ClST3pJQ0Y3zAIi/0ZZfxZ6bLyJY=@vger.kernel.org X-Gm-Message-State: AOJu0YzeLN7UludggzG+hCkJbqb7ODnKrYKgF1XGZ0MAQ2MWERmdIHKw CJqyS4pHItgiynwkPL1M6M60MLzf9uMcsrLwEON1SiyIUSCr/gw5ePqVYOhmYBtNaFs= X-Gm-Gg: ASbGnctdZEdzf0zclksiXg+4I/t60/XNShWR/lAjN2Wg6NamuEF37LACFEQrtaVAJN/ 3EouZYBfeBxSqfNF4QxNYGXjP58b6rJfSvYe2hv6eHQ98mNGJv+hHDkCdwX/V1x+zzwEvbuuKbk VZrGnIfKpCDOgYZiPdrSioz0a2Hltf8V+hOKPde8UxlCmZ5x6XGAfGWSXPts79++PqzJPvdiSeB JKGdSOEvIX5taiuL3wqKeOdKRauBainDlqrMFhA0gTNEywJ0i5Sg92e0t64AQG/wSkkXlZhpem+ YLAwdqixtyQX05+asJTVgLmZSBiyMpY6iRYRLYM9T/0XwjNQ5StUhGk31r7PNCaFuxTUuGWU+Cv JnoQYpqotOXwwhuPBk+w4LI+WEj/w1mGcasDJYSO19zq/p9+aCNkqBkX/XrWNgXjQ+QnMIe0mom OZFqI7F5ChgMsyXIyceKvOWwFFQu8Tt92X8AbY/pEn18d/Phhu+ODhg+xkKRO1 X-Google-Smtp-Source: AGHT+IHS+myDqRuX+iBJBDwEMx61N/d5XjvPEfVHHf93vOT0Dz0tWmYJOfqu7EaF6BGelpIrP68Yyg== X-Received: by 2002:a05:6512:696:b0:590:6598:4edf with SMTP id 2adb3069b0e04-591d8557d82mr153331e87.47.1760627980468; Thu, 16 Oct 2025 08:19:40 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5908856397csm7150663e87.75.2025.10.16.08.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Oct 2025 08:19:39 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Vincent Guittot , Peter Zijlstra , Kevin Hilman , Pavel Machek , Len Brown , Daniel Lezcano , Saravana Kannan , Maulik Shah , Prasad Sodagudi , Dhruva Gole , Ulf Hansson , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/4] PM: QoS: Introduce a CPU system-wakeup QoS limit Date: Thu, 16 Oct 2025 17:19:21 +0200 Message-ID: <20251016151929.75863-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251016151929.75863-1-ulf.hansson@linaro.org> References: <20251016151929.75863-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 some use-cases. 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 --- Changes in v2: - Renamings to reflect the QoS are limited to CPUs. - Move code inside "CONFIG_CPU_IDLE". --- include/linux/pm_qos.h | 5 ++ kernel/power/qos.c | 102 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 4a69d4af3ff8..bf7524d38933 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -149,6 +149,7 @@ bool cpu_latency_qos_request_active(struct pm_qos_reque= st *req); void cpu_latency_qos_add_request(struct pm_qos_request *req, s32 value); void cpu_latency_qos_update_request(struct pm_qos_request *req, s32 new_va= lue); void cpu_latency_qos_remove_request(struct pm_qos_request *req); +s32 cpu_wakeup_latency_qos_limit(void); #else static inline s32 cpu_latency_qos_limit(void) { return INT_MAX; } static inline bool cpu_latency_qos_request_active(struct pm_qos_request *r= eq) @@ -160,6 +161,10 @@ static inline void cpu_latency_qos_add_request(struct = pm_qos_request *req, static inline void cpu_latency_qos_update_request(struct pm_qos_request *r= eq, s32 new_value) {} static inline void cpu_latency_qos_remove_request(struct pm_qos_request *r= eq) {} +static inline s32 cpu_wakeup_latency_qos_limit(void) +{ + return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; +} #endif =20 #ifdef CONFIG_PM diff --git a/kernel/power/qos.c b/kernel/power/qos.c index 4244b069442e..8c024d7dc43e 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c @@ -415,6 +415,103 @@ static struct miscdevice cpu_latency_qos_miscdev =3D { .fops =3D &cpu_latency_qos_fops, }; =20 +/* The CPU system wakeup latency QoS. */ +static struct pm_qos_constraints cpu_wakeup_latency_constraints =3D { + .list =3D PLIST_HEAD_INIT(cpu_wakeup_latency_constraints.list), + .target_value =3D PM_QOS_RESUME_LATENCY_NO_CONSTRAINT, + .default_value =3D PM_QOS_RESUME_LATENCY_NO_CONSTRAINT, + .no_constraint_value =3D PM_QOS_RESUME_LATENCY_NO_CONSTRAINT, + .type =3D PM_QOS_MIN, +}; + +/** + * cpu_wakeup_latency_qos_limit - Current CPU system wakeup latency QoS li= mit. + * + * Returns the current CPU system wakeup latency QoS limit that may have b= een + * 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 *f= ilp) +{ + struct pm_qos_request *req; + + req =3D kzalloc(sizeof(*req), GFP_KERNEL); + if (!req) + return -ENOMEM; + + req->qos =3D &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 =3D req; + + return 0; +} + +static int cpu_wakeup_latency_qos_release(struct inode *inode, + struct file *filp) +{ + struct pm_qos_request *req =3D filp->private_data; + + filp->private_data =3D 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 =3D 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 =3D filp->private_data; + s32 value; + + if (count =3D=3D sizeof(s32)) { + if (copy_from_user(&value, buf, sizeof(s32))) + return -EFAULT; + } else { + int ret; + + ret =3D 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 =3D { + .open =3D cpu_wakeup_latency_qos_open, + .release =3D cpu_wakeup_latency_qos_release, + .read =3D cpu_wakeup_latency_qos_read, + .write =3D cpu_wakeup_latency_qos_write, + .llseek =3D noop_llseek, +}; + +static struct miscdevice cpu_wakeup_latency_qos_miscdev =3D { + .minor =3D MISC_DYNAMIC_MINOR, + .name =3D "cpu_wakeup_latency", + .fops =3D &cpu_wakeup_latency_qos_fops, +}; + static int __init cpu_latency_qos_init(void) { int ret; @@ -424,6 +521,11 @@ static int __init cpu_latency_qos_init(void) pr_err("%s: %s setup failed\n", __func__, cpu_latency_qos_miscdev.name); =20 + ret =3D misc_register(&cpu_wakeup_latency_qos_miscdev); + if (ret < 0) + pr_err("%s: %s setup failed\n", __func__, + cpu_wakeup_latency_qos_miscdev.name); + return ret; } late_initcall(cpu_latency_qos_init); --=20 2.43.0 From nobody Sun Feb 8 12:31:40 2026 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4312034AB09 for ; Thu, 16 Oct 2025 15:19:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760627987; cv=none; b=RrsMmB6e5tK15SEJ34w6hmNxuEQz1wSghaDwKIITu5f3+WgtqOmnilr48gU2LK1bUz5AJDRPLAXXbhTTs546KNihxTzL1vkv+5lg9WAPF482usY4aj2ITBAyH7JyLBu1fO3o14kRlWWCqosB5fyUH/zIwhQvENlHflpKA9IjKaU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760627987; c=relaxed/simple; bh=QfTmQDOc1pDn+Jv1CASWybdMSC/xCqrK8wzzxyN33ZM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bh7qZO+qa86Pivj7zC6wtrznftmfOp2hE6ih4X0WddeyHU0jdCbF5DKXBndTErjzhwwxgrlMlNmg6UzGJ1We48+ZvVP6zaMATT21fYec/R6C6rQuFlF3VGAOboZv4AMV+frkC1l8S42S35NL4pnIpPAVR1FCQ8bmUccF6EvisWg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=moP1n3Ng; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="moP1n3Ng" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-57ea78e0618so1092812e87.0 for ; Thu, 16 Oct 2025 08:19:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760627983; x=1761232783; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gCBJWiwmmJTUNM0j8C8szqE8iwROCYTEd9fYpRnBY7g=; b=moP1n3NgvqW+gWYkeznwT6xVCkt86tIJPFIO7c0N+rGw3IjlRErMIq9p3v372Glu9j ik73Cs5pxQAUu75iRLa3axtXQF4GpKDG6m1/dZ/7x0yQ2g45/vca5jDmoug4kTt5mGGr zbf+YauGjUB37Roatp8t7Km9xUHIcFyvt23gKRLoRqILzqnYCK/NoHMa/GqBFqxMCoEe Os1OlyUHlVP1XjEgBv8+RQW+8efnjv6gYjtkWyyWTKRKjF4qVA+IMU4h9cbca2KEx/yY xHnrhGIXUNodQtlSJdWwCNBzHbA0UudrwgwfiQUvD/2kuZKDIuB/eWI4AF9VumpMoqtY kWwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760627983; x=1761232783; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gCBJWiwmmJTUNM0j8C8szqE8iwROCYTEd9fYpRnBY7g=; b=Ls5lsiA3fEVCG1wbWY+QJ7kWAmp5hygmrr3d3xfDL8LeQK5N/o1XZ2dIU9wAH38323 2oxY/WteIuCmcdApTPzPdg4yoi+n4WdD0Kza6vmj8X0jgFvvmg2CWRufGkh8sr6tbq2A kdpX3/GWSGxX1QEGyvGay7RmZi7MXsBrBZYNQigcBaoN32LyxqqKo99gflLiEewVmpvM r7WkVtdRlM6FB6APD4WUGllGojBjUNtLkpUSPKfbq7ywfwd67Xi1RbE0HzDbY7cGUwij 3LT+Ob8W6VDgmfQX1rid01RD2oZrUmLRtOp2xt3+CZjTLoHiDF6u1papiVu7XpMXONIR ztmQ== X-Forwarded-Encrypted: i=1; AJvYcCW2qA7BBshWpQCpQUYUJuphg+Wq08FMpq6clNb7nxPXPf/QNp4ZsYiD/9Maz5FwQGDuv0WkL0BP2LtnRMM=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4gLzMq4mrsibvjafEFztqIJJWEW3Q0aGi3s44DvUH6id1rnno dQxhCJltU8vZCz9mC+MDYYPHh/Zbz9vjKR9SHuI22cV2duJ615H3UUf+hBOOj6yeIVA= X-Gm-Gg: ASbGncvXbtrOnRjbCFB2XZAbIK7H56f7/U9uRg2wgArHf5hxkkqBdu1OPxBCt0Mrkkm Kre3yYGDuDl4UiD57uOZzYpYxc2mC8wNtYkcqpFWRHoxdJB8miRNMG3Dghpen3USqbci9clppn4 8kpz6ZJtkOYDtmT8aBMcXkwBt9M/kqo8Jp9XgmoF2c96rbP8xFmyrPDTf7eO4eSTC1ZlUy9wgHl FA2jdh5tAdcA+EVL4Jj7NLUuQVUAW5d/iX4/l5KFmmxdrErcKC9XkR/vAu3jWdnT47fJii4j1dM ydZmnbk6P2pscF0Ue2p6oW0QchUDpB9yBAX5MS4qpXk9hfihS2et8Cjr9XeadIoJC/lwAWIGg5p FhuDSytGl4fnzWZbVHz84Tdw4CutcTLLfkGoks20Tch4hJo6e3ad3VFojdn0YsgT72Y4+tci+kd qQRzJ5omSoKrtI09iBCunCfTcUo1ur5h+4qfIrVbmVKFIIk2b1EEqNNq2cB6xy X-Google-Smtp-Source: AGHT+IF5oCdaBh84LKLSVZ51c8p7Jct0vsWdmbZ3Nwl6dlWGi8PUK/GV6A2horTszFBvye+XnNBgqg== X-Received: by 2002:a05:6512:b89:b0:578:ed03:7b5f with SMTP id 2adb3069b0e04-591d8589d9dmr133097e87.26.1760627981949; Thu, 16 Oct 2025 08:19:41 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5908856397csm7150663e87.75.2025.10.16.08.19.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Oct 2025 08:19:41 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Vincent Guittot , Peter Zijlstra , Kevin Hilman , Pavel Machek , Len Brown , Daniel Lezcano , Saravana Kannan , Maulik Shah , Prasad Sodagudi , Dhruva Gole , Ulf Hansson , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] pmdomain: Respect the CPU system-wakeup QoS limit during s2idle Date: Thu, 16 Oct 2025 17:19:22 +0200 Message-ID: <20251016151929.75863-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251016151929.75863-1-ulf.hansson@linaro.org> References: <20251016151929.75863-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A CPU system-wakeup QoS limit may have been requested by user-space. To avoid breaking this constraint when entering a low-power state during s2idle through genpd, let's extend the corresponding genpd governor for CPUs. More precisely, during s2idle let the genpd governor select a suitable low-power state, by taking into account the QoS limit. Signed-off-by: Ulf Hansson --- Changes in v2: - Limite the change to the genpd governor for CPUs. --- drivers/pmdomain/core.c | 10 ++++++++-- drivers/pmdomain/governor.c | 27 +++++++++++++++++++++++++++ include/linux/pm_domain.h | 1 + 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index 61c2277c9ce3..4fd546ef0448 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -1425,8 +1425,14 @@ static void genpd_sync_power_off(struct generic_pm_d= omain *genpd, bool use_lock, return; } =20 - /* Choose the deepest state when suspending */ - genpd->state_idx =3D genpd->state_count - 1; + if (genpd->gov && genpd->gov->system_power_down_ok) { + if (!genpd->gov->system_power_down_ok(&genpd->domain)) + return; + } else { + /* Default to the deepest state. */ + genpd->state_idx =3D genpd->state_count - 1; + } + if (_genpd_power_off(genpd, false)) { genpd->states[genpd->state_idx].rejected++; return; diff --git a/drivers/pmdomain/governor.c b/drivers/pmdomain/governor.c index 39359811a930..bd1b9d66d4a5 100644 --- a/drivers/pmdomain/governor.c +++ b/drivers/pmdomain/governor.c @@ -415,9 +415,36 @@ static bool cpu_power_down_ok(struct dev_pm_domain *pd) return false; } =20 +static bool cpu_system_power_down_ok(struct dev_pm_domain *pd) +{ + s64 constraint_ns =3D cpu_wakeup_latency_qos_limit() * NSEC_PER_USEC; + struct generic_pm_domain *genpd =3D pd_to_genpd(pd); + int state_idx =3D genpd->state_count - 1; + + if (!(genpd->flags & GENPD_FLAG_CPU_DOMAIN)) { + genpd->state_idx =3D state_idx; + return true; + } + + /* Find the deepest state for the latency constraint. */ + while (state_idx >=3D 0) { + s64 latency_ns =3D genpd->states[state_idx].power_off_latency_ns + + genpd->states[state_idx].power_on_latency_ns; + + if (latency_ns <=3D constraint_ns) { + genpd->state_idx =3D state_idx; + return true; + } + state_idx--; + } + + return false; +} + struct dev_power_governor pm_domain_cpu_gov =3D { .suspend_ok =3D default_suspend_ok, .power_down_ok =3D cpu_power_down_ok, + .system_power_down_ok =3D cpu_system_power_down_ok, }; #endif =20 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index f67a2cb7d781..93ba0143ca47 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -153,6 +153,7 @@ enum genpd_sync_state { }; =20 struct dev_power_governor { + bool (*system_power_down_ok)(struct dev_pm_domain *domain); bool (*power_down_ok)(struct dev_pm_domain *domain); bool (*suspend_ok)(struct device *dev); }; --=20 2.43.0 From nobody Sun Feb 8 12:31:40 2026 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C55E346A1D for ; Thu, 16 Oct 2025 15:19:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760627987; cv=none; b=fNm58bF19ZL+DknKAoK77dEQvfzqULgpTsCCggW5PYYDvqEd3V6xKeB8SW7hKyflaOZ6PYleH4F76ayqvsAA1dU1Q92+jZaVezgc/71U2uZoindyaok+QDLInjLKR1+T5mzRiNQDh2aFUO1Hk0Nidpg1yoHnYzYpkz7I9VihEEs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760627987; c=relaxed/simple; bh=o5HEvZCwSuySR1jmKB8nhGyW1NxQC5ADbI+U76W6bP8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N+Y/WlUqfGf16GOr8cK3UIMJysosB20y7AAxzzSNsmtHtOYItzbttvZ9+M7iI8HtOUaZDHbr9OU2CMoal2SPNjNz8nmeBCZBfMd38zkFScVAffPh1X0urc7232MCX1oj0ew/bh8mNT8+FbyQrHruAGKFgZVbpNB8rDVTJiROgU0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=JCQvoQeU; arc=none smtp.client-ip=209.85.167.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="JCQvoQeU" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-591c9934e0cso1021910e87.0 for ; Thu, 16 Oct 2025 08:19:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760627983; x=1761232783; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IxV71jdmV/ByebbrIUZHic+K8dLTxGDirB2bOa0abyc=; b=JCQvoQeUGcxacX2D/AnYo3Dzm6vlttJoJjw8Kc3UEUKY2CMHSVy93nHE4vFx7OQ78W EdsaJ8UBLjOeSUG9R4+J5n8RtUGUhRZsF84bpy7wjtrwyGAliorbghL/8USrWbPx8ooV 8AsydmcdifIGzanyUk/pKVTWK1p8IXYx1DaH1vu8y8hYVn75n/je7H0HdGzYCve1j+wY fvKcU1Zva4eBmUkkmz52Aebo44KaU+th4GKUV2DWQJLGv98KhT0+0Nb0dGHSnaE39x7A zF8uF9gYq9QCDlUW0+Mpsn45AOoBF/2hafMH8TfxHY95Al7AHmYZw7ZcbLkmP3VaXmHg PdUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760627983; x=1761232783; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IxV71jdmV/ByebbrIUZHic+K8dLTxGDirB2bOa0abyc=; b=uKllfxOIrFK3Pf60vOxJkQVtSMGLdzbXVS2KxLsaOOoevY3LmEPfdnoBoIW1xu9q78 AzLzUHuLJaUelKmEa/eQasEkXUzCQjh6ft28jqC1JsRB3oNMYPuPnIB9DHja+ZnGfe6o RDAa6kYZmOqiz7/DTqpG2lNI4WQ19dhonycCUov5WfnNO4QoR04pbvrnwicdzY4R5z1u 9PUraOC1hJjaTeqy5sOS6G+ilJGGYeARldMRFxb11F4AIBtNPy/vm1oKag/qY7zm6VMA 6O9a1kJ4s5OXevLe9Xrh0WNvcZYKTHQJ8uXIKqNO5M4weXnLb42+48I34CoATkoqq00G /3dg== X-Forwarded-Encrypted: i=1; AJvYcCXAf//TQKKRW7gJG7sioiysPoWIKwjzCno3/KxEnL4eCvC6TeNG0p585qu3mEQbALbtB+FS4nVV9NZbZxg=@vger.kernel.org X-Gm-Message-State: AOJu0YwKXrtkPHRDyc5i5bzJE93fX4h74/bVrhf/CuSLe+7gFwM+49+w 2Xgsx0kRRtEeN81km6uyzZh5Px3Hms6N23SdqVmLg1h0G/Obo61G53cQl0jjmKadG9Y= X-Gm-Gg: ASbGncuXqsrAiTn5pNmKt0nXdz05k0HE5GCRbE1/hrS01ckACuc+tDnRAOA+afYdWYb TuDytoV2kSjD0eWGlVqQHo6qlhM6i0F6x6UWAbKu+W2p5t468mpfedOsZRo6Uz/r4AVsFUvvVpR 45Zs4qI04y6SXvdT8xJIFvAJ76vpL/SwCxaQ/DByztqIx2NHhkxSuvP4G4gUd8wUhsaB+D/Y5rt BDTG/Yoa83pZrv4zLxgAgKgq4HzysemAbc+kXyycCHNKBHSX1lZ7iI2FI570wblpv4JsQOyswo3 xCNwHt0paFRpKKbdfpZhTr5KzVqRCwy7NQEO8ohU4kdbuIiMve3OZlyHkI64fFeCphK4NWhBAu0 UwoaajN835MJNxjx8kNm/a4DLuECzPQVYFSPCWjamu5p9wA9UnjIn9RJcBG55y1HDvVHFu0+Eh8 8HJ94P9kmGDjzD1iDnWynjY3tnypQIJPv0xRawkPsCNUVoc/sHNvuSeHjw5QgqHBtawASXO1M= X-Google-Smtp-Source: AGHT+IGvjg5uCswfR+tN9GifXO55mjU6KM6v0+HQbxwAe6xg9Y/5B3QZKxZkKucPhWtwh9KJ7o0QpQ== X-Received: by 2002:a05:6512:ba1:b0:55f:5245:d695 with SMTP id 2adb3069b0e04-591d84cf610mr190387e87.10.1760627983295; Thu, 16 Oct 2025 08:19:43 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5908856397csm7150663e87.75.2025.10.16.08.19.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Oct 2025 08:19:42 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Vincent Guittot , Peter Zijlstra , Kevin Hilman , Pavel Machek , Len Brown , Daniel Lezcano , Saravana Kannan , Maulik Shah , Prasad Sodagudi , Dhruva Gole , Ulf Hansson , linux-kernel@vger.kernel.org Subject: [PATCH v2 3/4] sched: idle: Respect the CPU system-wakeup QoS limit for s2idle Date: Thu, 16 Oct 2025 17:19:23 +0200 Message-ID: <20251016151929.75863-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251016151929.75863-1-ulf.hansson@linaro.org> References: <20251016151929.75863-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A CPU system-wakeup QoS limit may have been requested by user-space. To avoid breaking this constraint when entering a low-power state during s2idle, let's start to take into account the QoS limit. Signed-off-by: Ulf Hansson Acked-by: Peter Zijlstra (Intel) --- Changes in v2: - Rework the code to take into account the failure/error path, when we don't find a s2idle specific state. --- drivers/cpuidle/cpuidle.c | 12 +++++++----- include/linux/cpuidle.h | 6 ++++-- kernel/sched/idle.c | 12 +++++++----- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 56132e843c99..c7876e9e024f 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -184,20 +184,22 @@ static noinstr void enter_s2idle_proper(struct cpuidl= e_driver *drv, * cpuidle_enter_s2idle - Enter an idle state suitable for suspend-to-idle. * @drv: cpuidle driver for the given CPU. * @dev: cpuidle device for the given CPU. + * @latency_limit_ns: Idle state exit latency limit * * If there are states with the ->enter_s2idle callback, find the deepest = of * them and enter it with frozen tick. */ -int cpuidle_enter_s2idle(struct cpuidle_driver *drv, struct cpuidle_device= *dev) +int cpuidle_enter_s2idle(struct cpuidle_driver *drv, struct cpuidle_device= *dev, + u64 latency_limit_ns) { int index; =20 /* - * Find the deepest state with ->enter_s2idle present, which guarantees - * that interrupts won't be enabled when it exits and allows the tick to - * be frozen safely. + * Find the deepest state with ->enter_s2idle present that meets the + * specified latency limit, which guarantees that interrupts won't be + * enabled when it exits and allows the tick to be frozen safely. */ - index =3D find_deepest_state(drv, dev, U64_MAX, 0, true); + index =3D find_deepest_state(drv, dev, latency_limit_ns, 0, true); if (index > 0) { enter_s2idle_proper(drv, dev, index); local_irq_enable(); diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index a9ee4fe55dcf..4073690504a7 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -248,7 +248,8 @@ extern int cpuidle_find_deepest_state(struct cpuidle_dr= iver *drv, struct cpuidle_device *dev, u64 latency_limit_ns); extern int cpuidle_enter_s2idle(struct cpuidle_driver *drv, - struct cpuidle_device *dev); + struct cpuidle_device *dev, + u64 latency_limit_ns); extern void cpuidle_use_deepest_state(u64 latency_limit_ns); #else static inline int cpuidle_find_deepest_state(struct cpuidle_driver *drv, @@ -256,7 +257,8 @@ static inline int cpuidle_find_deepest_state(struct cpu= idle_driver *drv, u64 latency_limit_ns) {return -ENODEV; } static inline int cpuidle_enter_s2idle(struct cpuidle_driver *drv, - struct cpuidle_device *dev) + struct cpuidle_device *dev, + u64 latency_limit_ns) {return -ENODEV; } static inline void cpuidle_use_deepest_state(u64 latency_limit_ns) { diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index c39b089d4f09..c1c3d0166610 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -131,12 +131,13 @@ void __cpuidle default_idle_call(void) } =20 static int call_cpuidle_s2idle(struct cpuidle_driver *drv, - struct cpuidle_device *dev) + struct cpuidle_device *dev, + u64 max_latency_ns) { if (current_clr_polling_and_test()) return -EBUSY; =20 - return cpuidle_enter_s2idle(drv, dev); + return cpuidle_enter_s2idle(drv, dev, max_latency_ns); } =20 static int call_cpuidle(struct cpuidle_driver *drv, struct cpuidle_device = *dev, @@ -205,12 +206,13 @@ static void cpuidle_idle_call(void) u64 max_latency_ns; =20 if (idle_should_enter_s2idle()) { + max_latency_ns =3D cpu_wakeup_latency_qos_limit() * + NSEC_PER_USEC; =20 - entered_state =3D call_cpuidle_s2idle(drv, dev); + entered_state =3D call_cpuidle_s2idle(drv, dev, + max_latency_ns); if (entered_state > 0) goto exit_idle; - - max_latency_ns =3D U64_MAX; } else { max_latency_ns =3D dev->forced_idle_latency_limit_ns; } --=20 2.43.0 From nobody Sun Feb 8 12:31:40 2026 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBCD634AB17 for ; Thu, 16 Oct 2025 15:19:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760627989; cv=none; b=sKyqPIDHFGfJxu7jMXo5155sL2vs4qP1jBvVxzC3WWvXiKf6I1ZdL9dVV5adIlG7BcSOGLis4T5nJRfR8DLO4p3IDZcpRovuidd39savov3k+jkG4PrpSZDGzZhKvtSMHfWHE3k0mszhPP0xYptUN1SijqulIeVySrsLEcGxvzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760627989; c=relaxed/simple; bh=p1hkManqbLEmcUPdUEpLpgNeA8lMmi5PhV3KbHSxIjY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DWXxK48rXA+2IguUNuGJ9J0XD1y2yRg/yBpco+Q2JoFSww0UgmnPWnp5/jCG8LXpX3aGW80gaC3NiEPZmUeOeffR9nT2XGoy3y8IKacL58YCU1lN+QeD2N7H3Q21m0/f1XTGQ/B37/6S12QC3Cn84KucD05yqlHubD6yR7Ucm5E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=x1HrFSVh; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="x1HrFSVh" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-57e03279bfeso1000410e87.0 for ; Thu, 16 Oct 2025 08:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760627985; x=1761232785; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w/XQJbOqKvDoDR3qmpupw7hVZDh6O7Rf47/OK/uAp/8=; b=x1HrFSVhkga7SKFre3fy1WLK2mdoiHzjXsvSAgRNYBS9b93JyxEtkGDjd8dCFvxO7M RdTbJniLjs8ZAMlzXMef09MD6nNS6S99+aEsicx7jIreA3P0PRcIIdbCPriL8MzYwll0 3gvxJiKtQjXQLAlIb8UA9yR3CX7DnjdGp/RHLDpLJDO34BADOaslzeN95t+WsINZK3k3 tv6sDDvCD7EBxU8b93WsC5HzmtqLtKWJLkdXhBK97x45lz32QdGnhbTLD/AfARwHvctc aW5nClet29GTPyQ2z5hMVKytfJ98MBdL9sGZ3whzbEKOK9EUwihOBc6z1pz0UPeIzim0 LN1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760627985; x=1761232785; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w/XQJbOqKvDoDR3qmpupw7hVZDh6O7Rf47/OK/uAp/8=; b=wsUmEKavumi05Du9U+wm+shpt37+ZY1VHa7TuHp6wj73xdEroJJIIZlNc6mJcR1dBS cdiS6LTT17i1BIRXaJRhK5dt5rjVgL2Wa7WgwL2+DwbH9dkCY0THJtzjWkNYbg0RzmlG nFoc1MfZioTXKAHGHoweHyzgL/agQ5QYp3cqky4TxaZpkf9IDDJTX8RXBTQoxit3arDJ Gqq1qUukDDAbScMJpF9DevwvbSuUOjf03rEZ2GAeewJEGI3UvuIXXh5cjJqhXx8BQ7yG qn7SbI5AuoE1Un8SNqru2BFPrCyf0yQB9HHxyxT3WUlaIKTGcMw3NB+hiaU8/CcLLZZH 192g== X-Forwarded-Encrypted: i=1; AJvYcCWOD1wbvxPkCGpWN/7k8cgytHob7G3bL1tx0Or22LBC/43HT4PNecnQYYPUv07MZmsjXgLTJ2eHNdNcDH4=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1SoJWTcffFcwn7bLyLdWGduqIHRVLIzZFkGkAw95XH7PnYuMq fslSNLennuwIbwUd3ctvCzADebyLKBZ49ualDWPTUIMUMkNfw5NeiRxFAJjdJDSRDV0= X-Gm-Gg: ASbGncu7aD6O4f5nLaRSADhVsF6jDJMgonjX5xSZkVHyWVFWRy9RWDRjKt5DvVm0Ge/ kKKzUzLdn7L8DsHddfPTnYHDAMhmaiXWeU6VmZ7+2FQSYq8boVrBrALOc3DgJ/TMj+M6+vzP+bL HVMkzYHna9WUs63Ym9o+4CN8qes8kPb8OeG8wRsQxuVuKQ+eBqpXlE+4S9p6vtywCeBOYTBtyo8 v+HKm+Nk3l4eGFNL27Svkb4TLH+LWmGSjrQlGC9cfjnXgeP4/n4WJeOAmeGltc/AiPMDDIy2D/q k1Fs+LuVLoyelMuiYY2ra6dr9TalV0TZAPbymRlFn5jPIAYBWDUkwSorsvvkO0TeKtWNpwG27wI v3EPU46NePvzcpCq9Ag4UoMg0tCChadePZr+dRaqtONvulB4jc4wFuErvmo6mM1ZAiGj14YlYC1 8RB38PXeYs3FWOiKVFrETYJccNinxVqGQzghE0o842Bm/9oWJnkXIVBp2k8rFT X-Google-Smtp-Source: AGHT+IF+GI3D/A2Y8t0ukuJaRK98VfRgBctUREszulCJr3ra3+43QykgtfUE5rGgset7s3mjRIh84Q== X-Received: by 2002:a05:6512:681:b0:57a:9595:5b24 with SMTP id 2adb3069b0e04-591d839512emr217368e87.7.1760627984819; Thu, 16 Oct 2025 08:19:44 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5908856397csm7150663e87.75.2025.10.16.08.19.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Oct 2025 08:19:44 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Vincent Guittot , Peter Zijlstra , Kevin Hilman , Pavel Machek , Len Brown , Daniel Lezcano , Saravana Kannan , Maulik Shah , Prasad Sodagudi , Dhruva Gole , Ulf Hansson , linux-kernel@vger.kernel.org, Jonathan Corbet Subject: [PATCH v2 4/4] Documentation: power/cpuidle: Document the CPU system-wakeup latency QoS Date: Thu, 16 Oct 2025 17:19:24 +0200 Message-ID: <20251016151929.75863-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251016151929.75863-1-ulf.hansson@linaro.org> References: <20251016151929.75863-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let's document how the new CPU system-wakeup latency QoS can be used from user space, along with how the corresponding latency constraint gets respected during s2idle. Cc: Jonathan Corbet Signed-off-by: Ulf Hansson --- Changes in v2: - New patch. --- Documentation/admin-guide/pm/cpuidle.rst | 7 +++++++ Documentation/power/pm_qos_interface.rst | 9 +++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/pm/cpuidle.rst b/Documentation/admin= -guide/pm/cpuidle.rst index 0c090b076224..3f6f79a9bc8f 100644 --- a/Documentation/admin-guide/pm/cpuidle.rst +++ b/Documentation/admin-guide/pm/cpuidle.rst @@ -580,6 +580,13 @@ the given CPU as the upper limit for the exit latency = of the idle states that they are allowed to select for that CPU. They should never select any idle states with exit latency beyond that limit. =20 +While the above CPU QoS constraints applies to a running system, user spac= e may +also request a CPU system-wakeup latency QoS limit, via the `cpu_wakeup_la= tency` +file. This QoS constraint is respected when selecting a suitable idle sta= te +for the CPUs, while entering the system-wide suspend-to-idle sleep state. + +Note that, in regards how to manage the QoS request from user space for the +`cpu_wakeup_latency` file, it works according to the `cpu_dma_latency` fil= e. =20 Idle States Control Via Kernel Command Line =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/Documentation/power/pm_qos_interface.rst b/Documentation/power= /pm_qos_interface.rst index 5019c79c7710..723f4714691a 100644 --- a/Documentation/power/pm_qos_interface.rst +++ b/Documentation/power/pm_qos_interface.rst @@ -55,7 +55,8 @@ int cpu_latency_qos_request_active(handle): =20 From user space: =20 -The infrastructure exposes one device node, /dev/cpu_dma_latency, for the = CPU +The infrastructure exposes two separate device nodes, /dev/cpu_dma_latency= for +the CPU latency QoS and /dev/cpu_wakeup_latency for the CPU system-wakeup latency QoS. =20 Only processes can register a PM QoS request. To provide for automatic @@ -63,15 +64,15 @@ cleanup of a process, the interface requires the proces= s to register its parameter requests as follows. =20 To register the default PM QoS target for the CPU latency QoS, the process= must -open /dev/cpu_dma_latency. +open /dev/cpu_dma_latency. To register a CPU system-wakeup QoS limit, the +process must open /dev/cpu_wakeup_latency. =20 As long as the device node is held open that process has a registered request on the parameter. =20 To change the requested target value, the process needs to write an s32 va= lue to the open device node. Alternatively, it can write a hex string for the va= lue -using the 10 char long format e.g. "0x12345678". This translates to a -cpu_latency_qos_update_request() call. +using the 10 char long format e.g. "0x12345678". =20 To remove the user mode request for a target value simply close the device node. --=20 2.43.0