From nobody Tue Dec 2 02:04:16 2025 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (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 573B5343D7F for ; Fri, 21 Nov 2025 10:03:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763719426; cv=none; b=XzNHKVoazmwmfoh8bamkumk2v8BM4BktxqiWqQhAEzh202uHRTRlxXdSRdqXzctVkR8vYe6D0zo2eg0X/A+ECTuQSlR9nhi8MKtowgWnWDoHymdrtId8wtRgGb6UTYc/c7KBtg5ZNE3dG6cPUuXdM8DOngkOgoTI1VJN112IZmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763719426; c=relaxed/simple; bh=MJxuCpjjKZOzZQVt9PIbLTi9e2sc7SsHSJWlFzSJx7U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZJaLgMzsB5aIPGzymMKlDr2vzazx1R6Il8f61meUrmtqTxeWy/6DoQUws3IxU9CUExmX3vTSInN+YtkBFG8URCugJYv7TtOBZHqO+oBkWGD9y0wW1fLnHHNZFFN8C/NmBb5mQYdZNvGpF4BxAmTVy7436p/laYAEtI+viXPqsZI= 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=NkMIuz0g; arc=none smtp.client-ip=209.85.208.181 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="NkMIuz0g" Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-37a3a4d3d53so14389111fa.3 for ; Fri, 21 Nov 2025 02:03:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763719420; x=1764324220; 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=1jGPeEHKWVuJIa8HHZpuFjo58itYUjW84JrZNCFr27o=; b=NkMIuz0gQbdK7lRn62Mqtfw88TAIqwTsKy9EyKgTGQsLohNU3OsAx5PDeWTEY6nsGS +HTvINv8mIJj7uoGkWgzPx8BQ+q2tt4+88yzAQ5hKszg9ILTHE5kl6+aFVfAASw/WqAU Af2L/VwvS4iuUOBKugptedFlmbGkXXz6P7eVA37MjMg0MfIc8aUWWPPf3UIuVpExn4bF iQvLzYFmv099NKX0daE/w3eC4Nc34CJdviK+UxMlY7A1lw6WaVhghky4Azfgl7oT+7Fk VIyBWtsgFqq8y3VxEsIZ/x7dzKgsyjP+NMW2y3HATmYdW7A2YieoJaI4botnfvryiQUk lS3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763719420; x=1764324220; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=1jGPeEHKWVuJIa8HHZpuFjo58itYUjW84JrZNCFr27o=; b=sbHtUUUUtV8gAgF+cM6tWPM8ku5wkvFF1/w49nH7acdEqXajqKojTDWQkF3JaFsM2y ZTT77MxECtrRxdldONcdBjui6EmE0woIcu+61KaVz69V/p/8392Tntk7DOWNO0Ch+sAz BMa+jeya6EnrshCAclG57Rt/XMMhDSQwB7O3OOOZRERrc+Ed2v/TqzJ2ffKsJb2qBtlP aBbJ9noWXhwYjDr6d2ZaGAOB0BniQQhnVtWMOlm2hGIrDWdQf0TGQ141VKSUDNOK5hEx Pr6CW+M5cLsCBo9i3MvDMEdCXd74ObUKFcWw+chUSr8nb1kmBnjMLwbe/whOZ8DlOa0X r9mA== X-Forwarded-Encrypted: i=1; AJvYcCX4gZch4Xq9JiaWERjFFrWpJG7JrchOFZt7omqh6e5YatU4ZegetsZmjW1XPPfwmNE3+/yAjI+pzCUjr4k=@vger.kernel.org X-Gm-Message-State: AOJu0YzRqPYKdzRPuTvIzlz4wflxpQefFsEVr9oY/TVvrjnGqXSr39gn Q/eX32PUg+DTxF0uewL9wxZwyD5XjxbHBfTkPPgyM7eqn7Uzi48q3rMAz4Mk271jHQA= X-Gm-Gg: ASbGnctIaxamb2Ac8klPThk4IeCrBqA+Jy+gTmsdXbA1qowNPmUpfANtTuKEA0wWa5k RaeTXK7mc+G88uhX9Vu+kFQVr9SZgTeUSP9Wdqfxsuq5U2Zgl0MiKzi1/wSFD0dQOBmmRRd9EO+ TD6ROD2tqWC9mb70Q3DTSKp+jVFvFM181f0zOrjYWOVJTte0wqG/Rl0bJDsTuOXSqv8peHsPHAZ Fu0yzR+7AINykE3tI0lO1JCnPOoJXVW+0PeF22QtmB8cxwtldWKjxPyzYHdG+ovT7lKOmVS2cK9 gXOyCDqoX35q5BaVcd3IgoD7yhOyXViMQfMSHdotwfnPq4rOfe6CmqUWJHo7XqnxccmZba3IVJf izg5HE5rfV8HyeOLDWt3+6cxC1BFCsWB7RNhVoyDi6/X6t8ljCl6yW2406LtkEs9nkizfG8s7Aq phwdpYs5XVXMmUMVLVtiG8JlnCuS72uzs77urN8KrJkTwIahoVZURuaJCuw6a+ X-Google-Smtp-Source: AGHT+IFLmq3mXcT5DxVN+3wK08/EmPXPJaubrK1WkqZ8td8Jxs6hqP0+/hynWWzg8tl6NP7ARG8PKw== X-Received: by 2002:a2e:8a96:0:b0:35f:a210:2a35 with SMTP id 38308e7fff4ca-37cd91aab9cmr4951321fa.7.1763719419900; Fri, 21 Nov 2025 02:03:39 -0800 (PST) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-37cc6b597b2sm11056181fa.12.2025.11.21.02.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Nov 2025 02:03:39 -0800 (PST) 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 , Maulik Shah , Prasad Sodagudi , Dhruva Gole , Deepti Jaggi , Ulf Hansson , linux-kernel@vger.kernel.org Subject: [PATCH v3 2/6] pmdomain: Respect the CPU system wakeup QoS limit for s2idle Date: Fri, 21 Nov 2025 11:03:08 +0100 Message-ID: <20251121100315.316300-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251121100315.316300-1-ulf.hansson@linaro.org> References: <20251121100315.316300-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 domain idle state, by taking into account the QoS limit. Signed-off-by: Ulf Hansson Reviewed-by: Dhruva Gole --- Changes in v3: - Updated the commit message. 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