From nobody Wed Dec 17 20:40:11 2025 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 392CF43AA4 for ; Fri, 14 Mar 2025 10:01:20 +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=1741946483; cv=none; b=nqQLL1wS0itQWMaJHUrGvTEOYd6AaYutTv4WCa4eNYczdJxZ7oLwmfohCYCosp/cPbXblsLabxo6+dk6Vnpkq7gokM531qIJJqscvGo4z0kOkrKsc8yg6IBYnD5f/jg3lFPAEwY2KU2jrTPmyeoObA/FylXOTYwdOTxrqLiBPRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741946483; c=relaxed/simple; bh=omP1dmdXBpgOE00x/2D72922lfplNPRUo8oQ0BL4bBo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ndhdhQkto0vc7WNtajuN9K+zHjo4akQgYVu8/pV6UhX/FkODPBo1VG0pxSZG9G4TU00GVY4VlAbS5N29vBQzcyFMMuhp2Exnfjys69PyuCSJ8kctQL0HyeSm+TrRd9mqf15sHKVJNQAwIDWEc+ZenYER+tDFVhGH7xCe+1Tw33M= 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=u/IaguaO; 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="u/IaguaO" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-549a4a4400aso2107239e87.0 for ; Fri, 14 Mar 2025 03:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741946479; x=1742551279; 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=yxXrWuszmkPt9+jWh/jp7RjsQBBCWLjTzHixGfM6EZE=; b=u/IaguaOj5mqb7vZXxN0jrCnfvSI+A7xShqeT0Guz96NQdZkt+CtRs55Xe496T0IZh jF8qQfH59hEXdI2GRTGll5m1R5DRaSh2dLQxpNJTW/FBqTrvHWAtBCNS7Fprr1b8K4Ln PghjbZ4BWwHzxZPaJDPlW1hLcnNbvlPlBYNGQLQGQHdRFBJWHOLhXQaEemrOTFpL7cek HTJd93Wz9u2UY0bYpScrM8jEq7gzqi3cKjN2tsFcj2bwvU8MTe5Hdrsw5li8cV3obKZx FIDiVAUFpoMgiRv02ybOLXMo2NQi1o62JwR95EjFOhobGlpDVXU019pSq6OfQ8jMtI7d HPmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741946479; x=1742551279; 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=yxXrWuszmkPt9+jWh/jp7RjsQBBCWLjTzHixGfM6EZE=; b=J+WHtPbC2f7DGTerBuAeGIDA7HYVVcTdaRumz6p83XZ2BcAzkbicGD/BjaA91sggD2 Q7Mx1tgQNUTtDhTGwDXm4XPC/BowRAVT6ZzSwvvkMxGK4M29lfKRo19gZz1PDZ4xd1JA Bu1DKxDaLjUEufTbaCdwx62sTjeZV0lH+h5mkmRvEz9YOw+Yd/PMaJ4bTKeE+IV963ea PaSs5mIDxmiqN9EdxkOHbzM/cO6P6HrmCQje6i67txCPcBb4AeTyhHWvsZYnJ2O5dXGA vg2zdReEKh28MKckyoP6Xd7Ou8P1I2wjpzvqRo+mJuToCALnZg3TQwNEzeg3bnJJCbad QPeA== X-Forwarded-Encrypted: i=1; AJvYcCUMe2aWeFqQmKvCXtJ2srkytItCD8VMMD09TC3Dvr3KublX3MIT+dK72ldHLDvWu0QkzY8i1MwNtsako1Y=@vger.kernel.org X-Gm-Message-State: AOJu0YzvOq8Vdm1N4404ouYqfbqB2dkaqaVk94most6qDT3A6lJX54tk SDgPDZdcPWWnBIrQJiy+6vyGJ+nBGFY3CGCLNdw2aWPruDXrfOLjfvxGzLGSGxCD/SYdJvTPGM2 k X-Gm-Gg: ASbGncvSd3md2NYmjeY+xgAeUizwqTlx/ZljBwvZspEzOBKxYgznvk6vmWiCFThso+R TZiyiVS1RUzZPLZBp3/0c0BmE3e3F+lX4mWqnHm0uu/o+kEkUgl8LAScNbh6IszMJpW4Th4eQ/8 r8wNmt9e8apI7oC7dAmYEVI4p+4mUg+IwB7vtOgBFokGALY8hizzx30T6KLBO99lqsVKllxn5hr dEQau9CfhXGuNSwGu8JYQ7+L/TYZDTqXNiPJ4XDHrBMeRhLEOre81qLQPJFyhfeB8eajY+NhtQm EsENCD1xvE9mz2swK85rFb9ISAU7Q/9s66WvKWoa8CCKupjpfdOda1As1QZccByVqf4dXB0MU3T NYZwVcvKcjQkuSP7cIUuDKDVvq819tA== X-Google-Smtp-Source: AGHT+IGI4U+6gFVGvMxY7c2ZChVVcSTAYz3qWc9D46+/1FYmNXR+U/zCzRxHxW++97VulyB6QhEBRA== X-Received: by 2002:a05:6512:238d:b0:549:8d8d:2c62 with SMTP id 2adb3069b0e04-549c396e3d9mr653362e87.36.1741946479167; Fri, 14 Mar 2025 03:01:19 -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 38308e7fff4ca-30c3f0ea468sm5168221fa.41.2025.03.14.03.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Mar 2025 03:01:18 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Daniel Lezcano , Anup Patel , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] pmdomain: core: Add genpd helper to correct the usage/rejected counters Date: Fri, 14 Mar 2025 11:00:55 +0100 Message-ID: <20250314100103.1294715-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250314100103.1294715-1-ulf.hansson@linaro.org> References: <20250314100103.1294715-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" In the cpuidle-psci-domain case the ->power_off() callback is usually returning zero to indicate success. This is because the actual call to the PSCI FW to enter the selected domain-idlestate, needs to be done after the ->power_off() callback has returned. When the call to the PSCI FW fails, this leads to receiving an incorrect tracking of the usage/rejected counts for the selected domain-idlestate. In other words, the presented debug-statistics for genpd may look better than what the actually are. To allow a better correctness of the data, let's add a new genpd helper function, which enables the caller adjust the usage/rejected counters for a domain-idlestate, in cases of errors during power-off. Signed-off-by: Ulf Hansson --- drivers/pmdomain/core.c | 25 +++++++++++++++++++++++++ include/linux/pm_domain.h | 6 ++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index 9b2f28b34bb5..c79ef6e3ab85 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -728,6 +728,31 @@ int dev_pm_genpd_rpm_always_on(struct device *dev, boo= l on) } EXPORT_SYMBOL_GPL(dev_pm_genpd_rpm_always_on); =20 +/** + * pm_genpd_inc_rejected() - Adjust the rejected/usage counts for an idle-= state. + * + * @genpd: The PM domain the idle-state belongs to. + * @state_idx: The index of the idle-state that failed. + * + * In some special cases the ->power_off() callback is asynchronously powe= ring + * off the PM domain, leading to that it may return zero to indicate succe= ss, + * even though the actual power-off could fail. To account for this correc= tly in + * the rejected/usage counts for the idle-state statistics, users can call= this + * function to adjust the values. + * + * It is assumed that the users guarantee that the genpd doesn't get remov= ed + * while this routine is getting called. + */ +void pm_genpd_inc_rejected(struct generic_pm_domain *genpd, + unsigned int state_idx) +{ + genpd_lock(genpd); + genpd->states[genpd->state_idx].rejected++; + genpd->states[genpd->state_idx].usage--; + genpd_unlock(genpd); +} +EXPORT_SYMBOL_GPL(pm_genpd_inc_rejected); + static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed) { unsigned int state_idx =3D genpd->state_idx; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index d56a78af4af1..6e808aeecbcb 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -285,6 +285,8 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain = *genpd, int pm_genpd_init(struct generic_pm_domain *genpd, struct dev_power_governor *gov, bool is_off); int pm_genpd_remove(struct generic_pm_domain *genpd); +void pm_genpd_inc_rejected(struct generic_pm_domain *genpd, + unsigned int state_idx); struct device *dev_to_genpd_dev(struct device *dev); int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int st= ate); int dev_pm_genpd_add_notifier(struct device *dev, struct notifier_block *n= b); @@ -336,6 +338,10 @@ static inline int pm_genpd_remove(struct generic_pm_do= main *genpd) return -EOPNOTSUPP; } =20 +static inline void pm_genpd_inc_rejected(struct generic_pm_domain *genpd, + unsigned int state_idx) +{ } + static inline struct device *dev_to_genpd_dev(struct device *dev) { return ERR_PTR(-EOPNOTSUPP); --=20 2.43.0 From nobody Wed Dec 17 20:40:11 2025 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 4D30E1F37BA for ; Fri, 14 Mar 2025 10:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741946484; cv=none; b=DwT6KF2ufpM43A+ArmG4nxeSg0OIShDoH5n8g/6EAcpRr4sWhFTFWoPaSxHR2NzIRonBEcV6MbwbPJ4Ot7/QA+phcx++OokGcViIGqa0JEKKA+FTkqIfPByqWDCLxwNEDGFDVl9upH5Rb8g48mTQXVmJgTizfiTIrv/bopm6duQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741946484; c=relaxed/simple; bh=jpL7H2rEOd8mfJnn5VtdO8SHZXRMgJyBIOewncmh6Uw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q/e1IXGIfIVMDhCaK+yVSZmfJq1cyiPY7PPWd/wHu4kfx36MUO4K9yTZBYiKx0+4DvfWulmIhFza1dYW8kxs//KzVakzeLSrYk7d4K98hq3SyPCfffjNdMV6ahS5Njl6w++uSmwdW0Uhdv85DYtaga7BaWirT5lltfIso6T4s90= 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=pXHZ3iY8; arc=none smtp.client-ip=209.85.208.175 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="pXHZ3iY8" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-307c13298eeso22277571fa.0 for ; Fri, 14 Mar 2025 03:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741946480; x=1742551280; 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=JE+q5aCnF90doB2QrACuAQ2CKvBByABqrTNx0sOx31w=; b=pXHZ3iY8GcRPvLmwRq4JB+agxDOVFPP3/utpOvNsggUPT/v6kbLQK/RjdBLZgahXI4 at0BneNBqqgiri0wlYXE35ghozJP2uD6hnERhHIzbEhttpI+M/dLudepknf2cBmfN8Bm qvXppwSraIMP3BAaT2iY2dY+D/bmyP1iAGJaga4Ib76qzHgSpJxgyyvM/RRuelcWSQyR uy6/E6BvYCiYtUKKORDihai43jI2hblVJIsNKQ3kPjJe65sr+kWOV6JceEy5XaNL37wa G7J3NEPFt7Qt96FEVeLKiSvz/GtV2ltLyqABObL6Sl3CPmqbiSA58syXrdr0CjNGp66Q usDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741946480; x=1742551280; 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=JE+q5aCnF90doB2QrACuAQ2CKvBByABqrTNx0sOx31w=; b=fRdxQSs3Op3Bt2g8HN7heMOUvp54tNza6TCf/OStDTq5XfSYMx0oXb9zvXmhwgrF0W 4YsB+EWyhG3Mxm4x3yyonmQ7gWZVRGwpcfhdahknlXpZ/BuPSXll93C/tOMusvw52kzw HNwq37fqCapQJQNxJzgFDuXuGB6AFxhwvSgM57vgSoulcSek9dCcqH+vAiyX0C9dsQ5T 8eligxwc5Wgj6tNvjrrAt/L1NUWMwjZmHBolyEmxi0FA2WA7Ek9CuuwHooUYex64UF3V eRR0lpHUsrpFR9JaltMDMr7zRmXmSI4NUBh4fMBX2F6NIW69BEUqyyM4YYL3os5PeEKB sGCw== X-Forwarded-Encrypted: i=1; AJvYcCWro0koinLz5oscfWeAnmrnQxbKLuQNAskr+ycpUy2AMGWbS5MyVXmmRvTX7muHPgtTRFIBgW1swWc4nPY=@vger.kernel.org X-Gm-Message-State: AOJu0YwJb1ZprRiXuEUOELSBjjKxpBWhQavU8TIBQu++BX9CziGKstuS 0iWxUeu8AJD8tz7gFQ7l/OfINHZsgeBta4IiYc1mkeHIXrywBLEgf3oa8OpGY28= X-Gm-Gg: ASbGncsvtGByMmjwO2SzRfZfGAXnoDyEAwHeoH/yv95fra/nv3s2sU8/moESQB+eCJw 52OfLOtCdn2DMoeeV8Uy9UpnQR2kNNwIsBWvEnymojrFmjmeSAzwzyENTKTkIniu0ToGKyDdJeL cWREwFDur/RGps2LqDlAsQzWJECW7GbFMwyOlKfe/aBYQelSSFB/hBSg+ADMI3U5LWDhCVcxfCr WTYIYh154BXXbullb22dKL6LtCwTsrHgXHdG0s1i9CLgVL2RlrV8wboVWn0gTElulIVlo7wbv59 4GNYpPp6uQkOQxRlzSskhHfi9OzPeVzPb/90GwG7qUZAughXbo1RnrMc5ABmP0CLvpQx2s5yPCE C+guY9pxrELvOgVP8j5r4lw09jg6MZA== X-Google-Smtp-Source: AGHT+IGhYmFMbUeatQB/z6JS0kcTyMcIT1IzBAPuh4fApk2bCc0yDwcZPgTrJD62ufz1WRxkinRL3Q== X-Received: by 2002:a05:651c:1501:b0:30b:c36c:ba96 with SMTP id 38308e7fff4ca-30c4aa7711fmr7127431fa.1.1741946480268; Fri, 14 Mar 2025 03:01:20 -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 38308e7fff4ca-30c3f0ea468sm5168221fa.41.2025.03.14.03.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Mar 2025 03:01:19 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Daniel Lezcano , Anup Patel , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] cpuidle: psci: Move the per CPU variable domain_state to a struct Date: Fri, 14 Mar 2025 11:00:56 +0100 Message-ID: <20250314100103.1294715-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250314100103.1294715-1-ulf.hansson@linaro.org> References: <20250314100103.1294715-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" To prepare to extend the per CPU variable domain_state to include more data, let's move it into a struct. A subsequent change will add the new data. This change have no intended functional impact. Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index dd8d776d6e39..1aff1ec555d5 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -36,19 +36,28 @@ struct psci_cpuidle_data { struct device *dev; }; =20 +struct psci_cpuidle_domain_state { + u32 state; +}; + static DEFINE_PER_CPU_READ_MOSTLY(struct psci_cpuidle_data, psci_cpuidle_d= ata); -static DEFINE_PER_CPU(u32, domain_state); +static DEFINE_PER_CPU(struct psci_cpuidle_domain_state, psci_domain_state); static bool psci_cpuidle_use_syscore; static bool psci_cpuidle_use_cpuhp; =20 void psci_set_domain_state(u32 state) { - __this_cpu_write(domain_state, state); + __this_cpu_write(psci_domain_state.state, state); } =20 static inline u32 psci_get_domain_state(void) { - return __this_cpu_read(domain_state); + return __this_cpu_read(psci_domain_state.state); +} + +static inline void psci_clear_domain_state(void) +{ + __this_cpu_write(psci_domain_state.state, 0); } =20 static __cpuidle int __psci_enter_domain_idle_state(struct cpuidle_device = *dev, @@ -87,7 +96,7 @@ static __cpuidle int __psci_enter_domain_idle_state(struc= t cpuidle_device *dev, cpu_pm_exit(); =20 /* Clear the domain state to start fresh when back from idle. */ - psci_set_domain_state(0); + psci_clear_domain_state(); return ret; } =20 @@ -121,7 +130,7 @@ static int psci_idle_cpuhp_down(unsigned int cpu) if (pd_dev) { pm_runtime_put_sync(pd_dev); /* Clear domain state to start fresh at next online. */ - psci_set_domain_state(0); + psci_clear_domain_state(); } =20 return 0; @@ -147,7 +156,7 @@ static void psci_idle_syscore_switch(bool suspend) =20 /* Clear domain state to re-start fresh. */ if (!cleared) { - psci_set_domain_state(0); + psci_clear_domain_state(); cleared =3D true; } } --=20 2.43.0 From nobody Wed Dec 17 20:40:11 2025 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 4188F1F3D55 for ; Fri, 14 Mar 2025 10:01:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741946486; cv=none; b=ZQiik970hQmel5FxiYPBBbw/xA96WqscvOaSnqSI9iXsPe8PGpklh8UmrG6/RkzU4TlHs/qFhkRrA9oD9H5y0ae7xYd71ZvnyxlT4VJIUu0MsvEgRug8dibcjrzlcw7+zplOKedEmMlXhWHc230uwHtWb3y22/pnVT7sVfzyA48= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741946486; c=relaxed/simple; bh=kmzppo3sBM/QV1rz6m712RRfo3KqArFiDhfB5PEpOUY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DvncVnIyusx+urD6ybzoRYil5ByIR3dEZYQ0szfzHRBxETWQTQWms/Vq69HQC8mJqPeiyO5dFO5oX1Ci0nt6J1Cpi46gu2FXNSB8OdR9h6N+z/3YREjv9paqWMzkecgFc+0MOtRBXNphYRduOh5RW61WVW7fedK5EWE2mohCGr8= 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=DcE4pEPm; arc=none smtp.client-ip=209.85.208.179 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="DcE4pEPm" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-30bd11bfec6so19049931fa.0 for ; Fri, 14 Mar 2025 03:01:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741946482; x=1742551282; 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=Suz7cKLNuXGtB0nBu0oVhma/Td/1dTahkXdO6vQ+7gU=; b=DcE4pEPm/EGg3J7fiN1SHZM6XiO9zO0YcIUR9hy8zZfp1Co/oZjb4mKjHZUgYqrYqK 465tqUBoHmtP03c/FSt3hXRZmxPSGRip62zUhY81O3gV2OCDNf0F1MGMOziDSY11Uyz0 WqyCW6EUb2wI+PF1pF9DgPyhFOKenxQly0fbrbF5cHUiA8QhssQ4mHKNraPJJZJo76/v 28u8RE+MCIgscgoAdCV2lMbmzzSuWXi6Vbdf71GQmPM7NRho4zAo864EIPdPOqe50No2 kBBmgGtMvmDu5/Q4njC3GNvw1/M1c5OVjet+fFFpRClnu5rsKduNt8O8N6h2l9XcTlV8 /IhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741946482; x=1742551282; 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=Suz7cKLNuXGtB0nBu0oVhma/Td/1dTahkXdO6vQ+7gU=; b=MuaI9th2HiF3oeoI04Gx5760sALtG+LBjv4G7yCI26tkWU6TCuyeAEA0llWl95lZQB 5KrVQgGnAcp9nE0yBAdJrsy5Rf6I3vJ3I434y3l19cUPsam349ISNXA7ddY5MatI8df6 yOOaHYnvNJvnkDadWNZ2soVggqjZJaQrsAUoZXpEmckXv32Tbf4MAJ1Ug/i3HM57rIug X6VBiU727Mrv1r7GktQ64OhlvoVQt5APs+O6TDpqzADe/OMPcsgXQFcC5GJH6i/4bMSt qVhLIZQIQ78ny6QXQQoOzx1VqeE/GnmfECAKtN3ZIQnIXWlaLw3nCpfWruO1gisvMPOV 0OQg== X-Forwarded-Encrypted: i=1; AJvYcCWTkSqsj/DkOebVe6oUt4MchrR2I5WWIIcxpJX2k/L9GsZD/BBEHzpG/VnPsxl92RE1tA9lQy21+k/6KKk=@vger.kernel.org X-Gm-Message-State: AOJu0YzpyR4k9anBcFZp6lXm6DMj7uAzUONTzLJrCmxm9of0BwRuMPJn ttXVrA4VPIU31RQuBxNj3KKa8vsTZnrqYWTckj+dN0iyVUKzlQyDYvRyt+aoV70= X-Gm-Gg: ASbGncs4Kfy9IFWoIYJK3PHr2X2vhy+x0fT+xl8jCj8nZEqPvdmlKw+vRi0KpsCTzLd r12v//si47HQ5jHw3+71Wl9Cue9Yofff02/zfEr917LrQAqaArO+1erXEXsDI1tubFvtDUKgxKN zXopnatYKJ7N0H+3fu7TtIb1A2DZ/eH0zoUUGemU4MwukOlOx9BBCvYswKi0znNJURzUTbUGFNV o6zbHaSk9RfeySDnh1j42kdFTrq4XByuBMgYZ9fifFZmyCJ81Kiblg2Trf0NqM3wnTsBdPa+Nii 9X2WwYdIB0Fp0QZYYVBBaStMro2iP4p3E1U9X7b/oLzzEZ6N24MHja2n4Wtnoy+pyd4r+Ckj+ey LB4dH0bbcxr5uRJQzaktZ9WaPy9fexw== X-Google-Smtp-Source: AGHT+IEY83oFunB8w4RCdXC7/PTR7yqMmBEg98GVtkrv9yV920cpuM7Rd10omcbDGDOuiGclAjQbOw== X-Received: by 2002:a05:651c:2101:b0:309:26e8:cb1a with SMTP id 38308e7fff4ca-30c4a8dcaaemr6886561fa.30.1741946482339; Fri, 14 Mar 2025 03:01:22 -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 38308e7fff4ca-30c3f0ea468sm5168221fa.41.2025.03.14.03.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Mar 2025 03:01:21 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Daniel Lezcano , Anup Patel , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] cpuidle: psci: Correct the domain-idlestate statistics in debugfs Date: Fri, 14 Mar 2025 11:00:57 +0100 Message-ID: <20250314100103.1294715-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250314100103.1294715-1-ulf.hansson@linaro.org> References: <20250314100103.1294715-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" When trying to enter a domain-idlestate, we may occasionally fail to enter the state, which is informed to us by psci_cpu_suspend_enter() returning an error-code. In these cases, our corresponding genpd->power_off() callback has already returned zero to indicate success, leading to getting in-correct domain-idlestate statistics in debugfs for the genpd in question. Let's fix this by making use of the new pm_genpd_inc_rejected() helper, as it allows us to correct the domain-idlestate statistics for this type of scenario. Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci-domain.c | 2 +- drivers/cpuidle/cpuidle-psci.c | 27 +++++++++++++++++---------- drivers/cpuidle/cpuidle-psci.h | 4 +++- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidl= e-psci-domain.c index 5fb5228f6bf1..2041f59116ce 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -43,7 +43,7 @@ static int psci_pd_power_off(struct generic_pm_domain *pd) =20 /* OSI mode is enabled, set the corresponding domain state. */ pd_state =3D state->data; - psci_set_domain_state(*pd_state); + psci_set_domain_state(pd, pd->state_idx, *pd_state); =20 return 0; } diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index 1aff1ec555d5..26a0885444c4 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -37,6 +37,8 @@ struct psci_cpuidle_data { }; =20 struct psci_cpuidle_domain_state { + struct generic_pm_domain *pd; + unsigned int state_idx; u32 state; }; =20 @@ -45,14 +47,14 @@ static DEFINE_PER_CPU(struct psci_cpuidle_domain_state,= psci_domain_state); static bool psci_cpuidle_use_syscore; static bool psci_cpuidle_use_cpuhp; =20 -void psci_set_domain_state(u32 state) +void psci_set_domain_state(struct generic_pm_domain *pd, unsigned int stat= e_idx, + u32 state) { - __this_cpu_write(psci_domain_state.state, state); -} + struct psci_cpuidle_domain_state *ds =3D this_cpu_ptr(&psci_domain_state); =20 -static inline u32 psci_get_domain_state(void) -{ - return __this_cpu_read(psci_domain_state.state); + ds->pd =3D pd; + ds->state_idx =3D state_idx; + ds->state =3D state; } =20 static inline void psci_clear_domain_state(void) @@ -67,7 +69,8 @@ static __cpuidle int __psci_enter_domain_idle_state(struc= t cpuidle_device *dev, struct psci_cpuidle_data *data =3D this_cpu_ptr(&psci_cpuidle_data); u32 *states =3D data->psci_states; struct device *pd_dev =3D data->dev; - u32 state; + struct psci_cpuidle_domain_state *ds; + u32 state =3D states[idx]; int ret; =20 ret =3D cpu_pm_enter(); @@ -80,9 +83,9 @@ static __cpuidle int __psci_enter_domain_idle_state(struc= t cpuidle_device *dev, else pm_runtime_put_sync_suspend(pd_dev); =20 - state =3D psci_get_domain_state(); - if (!state) - state =3D states[idx]; + ds =3D this_cpu_ptr(&psci_domain_state); + if (ds->state) + state =3D ds->state; =20 trace_psci_domain_idle_enter(dev->cpu, state, s2idle); ret =3D psci_cpu_suspend_enter(state) ? -1 : idx; @@ -95,6 +98,10 @@ static __cpuidle int __psci_enter_domain_idle_state(stru= ct cpuidle_device *dev, =20 cpu_pm_exit(); =20 + /* Correct domain-idlestate statistics if we failed to enter. */ + if (ret =3D=3D -1 && ds->state) + pm_genpd_inc_rejected(ds->pd, ds->state_idx); + /* Clear the domain state to start fresh when back from idle. */ psci_clear_domain_state(); return ret; diff --git a/drivers/cpuidle/cpuidle-psci.h b/drivers/cpuidle/cpuidle-psci.h index ef004ec7a7c5..d29cbd796cd5 100644 --- a/drivers/cpuidle/cpuidle-psci.h +++ b/drivers/cpuidle/cpuidle-psci.h @@ -4,8 +4,10 @@ #define __CPUIDLE_PSCI_H =20 struct device_node; +struct generic_pm_domain; =20 -void psci_set_domain_state(u32 state); +void psci_set_domain_state(struct generic_pm_domain *pd, unsigned int stat= e_idx, + u32 state); int psci_dt_parse_state_node(struct device_node *np, u32 *state); =20 #endif /* __CPUIDLE_PSCI_H */ --=20 2.43.0 From nobody Wed Dec 17 20:40:11 2025 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 5F97C1F4170 for ; Fri, 14 Mar 2025 10:01:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741946487; cv=none; b=Zqw3CvICbA0PPM2C4aFtnWeADvfJom8WosP4sLpykpEBqN+VWAeY7xeeMVAR4tnHIfxzTv5gzJua1WSnBFT3ozeqyRH6fA2+37d399B90S0ksn5LhyAzjvaaC9ryQptzdJ3rmwhM4o0TPyv4j3EZbL5AE6wr2f9Im8zYzkp2h5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741946487; c=relaxed/simple; bh=ku7eBoH8HGNNqu6WgR7epnSx7DurvY3KB0R4PNQ8EGM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qk3qsOQ/pVGJpKSw16TfmrNL3weiMVadAjw9o0lhrT7elO7OHMUYBa9ODjxZfw2XDhZMW1Tjsocs/6NxIlnFzNcIXnr5MsQKh9uMHfqBsGbLGvdEi8crgOsNbGE8m7oFpzPpE2/SnMruRbKRyslmUDj6APV/6WN9W9GmaNFNPZE= 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=DcTMC4z0; arc=none smtp.client-ip=209.85.208.172 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="DcTMC4z0" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-30761be8fa8so20827621fa.2 for ; Fri, 14 Mar 2025 03:01:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741946483; x=1742551283; 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=/QggTlpxLWEC50ONNabSeYB6RhPieGr2Z8I7fdFvhr8=; b=DcTMC4z0e7embT0ZS37lE5r2pp3Acr3idH6UThu+6J9MYC5jxkC+ylaSX+VaVCmby3 oInTXj7WoA3QOj60xf55SPz/S7igMRwRQefqab0Zhqr4ZNRutVJcgWCH/haDona/Nw1c uQV7km+wUOYntCNMJnOvxRQJLEgNIdYgH4CW7tiuHyuDF7m9Q5TgOM8KrXQwqAu4RKcj h2ysZ4TBe6lP1OUd2X+CyWQ1t8cE63gs3sWdjEThR7Z6JpIfzwqISSmlZ9cCqXDDSKm8 I4FBvbd24jJW9BY5IxVQR9juwTmB1cPGitGTJ0fnIq+ib07NaKy+x9b8u6UKMl9vttLv GSqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741946483; x=1742551283; 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=/QggTlpxLWEC50ONNabSeYB6RhPieGr2Z8I7fdFvhr8=; b=eIzPeZg0q/E+bMHOByPwUTfgYY1VtPG4MA15D8F8Ct2JrOh+HcaLRSyjxEuVJpXmTf hvYwU0Xz+mN8BdciOw14UCjoqP4SirYEFnHFloXZ0Ai8RgCLkQ7dlcgltQJDG3EURjK5 WR9/kH5PJmCu3S23WN7Z64NzJc5SdfsyczCcMwZNeWnj3uX6AqB4dD927kol57t6GEvd 8a371viWpmwUYDrxXX3uVTnIvAnW8Kgf05ROMSYb0/CjVCtackHlqt8rMIHAMfhLelaK wG/qDIKN/DCMVOLifMzLNkVt3GrlLhpy9B/2D/GScbCN3/WIANeGLCmlolYXZ2Noawr3 Tj4g== X-Forwarded-Encrypted: i=1; AJvYcCU99H6eKnANpxzpUCkXNwTwenx4ecWVDaGear9mWCyrF1MKoQJSeDYQ24HFa2PzYl+l5grdH15NHrAer4Y=@vger.kernel.org X-Gm-Message-State: AOJu0YxCj7jdb3YZQxPzBvcYUpU0VlY639PX0gLAxpi0S1ZLBXIkfuLC MrouAuQs2hLI9NgpozIOodFdaR/HGtMVGzpmWbLPG+azuUHB6zUQBG/Pgr3RFxo= X-Gm-Gg: ASbGnctR5W8stsVDv5HQO6lmqmi6UvITIWs2EFYFZrXsJ5ht9vurDnauL3DXY79kBcg a/ujvRpuxGwsu3ljv8vMd9Ha1NjBAUJCcl4IWZqkNZNsiVC2IRhozpzn5ThyebO1a20fzPVO8t+ KhRLs1I7HmsL1JLn95Dc1mH4RKyql8dyNi7qArYomDgxMvggf1Cq5KnyN4SOhwL5Rudmr+m0ibd BD7xxg1d2JtgW5ZgfGjVr+1pzNt02BnzyAtePOtA5PSclBdZbz9N6EoUly8Cl2KZCaMXo4xZ+6o zdQROx5pAwNWCA4o0h+N8a9dxZ3KKx5pj85ssgoiVha1aDf5XC18hy4xueQ6cIfi0BbrKMcqJ9+ jI3sPtrmeNibiC7fwweA= X-Google-Smtp-Source: AGHT+IF3JWP6a57uvsfs3rKVvgBqgJHjNxLdTktMEECCgzMKQtOboYvvcrBZ2wGvWzv5dk6aRgujQw== X-Received: by 2002:a2e:88c9:0:b0:30b:8e06:86a3 with SMTP id 38308e7fff4ca-30c4a8665c1mr5313131fa.16.1741946483423; Fri, 14 Mar 2025 03:01:23 -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 38308e7fff4ca-30c3f0ea468sm5168221fa.41.2025.03.14.03.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Mar 2025 03:01:22 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Daniel Lezcano , Anup Patel , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] pmdomain: core: Add residency reflection for domain-idlestates to debugfs Date: Fri, 14 Mar 2025 11:00:58 +0100 Message-ID: <20250314100103.1294715-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250314100103.1294715-1-ulf.hansson@linaro.org> References: <20250314100103.1294715-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" For regular cpuidle states we are reflecting over the selected/entered state to see if the sleep-duration meets the residency for the state. The output from the reflection is an "above" value to indicate the number of times the state was too deep and a "below" value for the number of times it was too shallow. Let's implement the similar thing for genpd's domain-idlestates along with genpd's governor and put the information in the genpd's debugfs. Signed-off-by: Ulf Hansson --- drivers/pmdomain/core.c | 40 ++++++++++++++++++++++++++++++++++--- drivers/pmdomain/governor.c | 2 ++ include/linux/pm_domain.h | 4 ++++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index c79ef6e3ab85..3327de2f9ed2 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -304,10 +304,40 @@ static void genpd_update_accounting(struct generic_pm= _domain *genpd) =20 genpd->accounting_time =3D now; } + +static void genpd_reflect_residency(struct generic_pm_domain *genpd) +{ + struct genpd_governor_data *gd =3D genpd->gd; + struct genpd_power_state *state, *next_state; + unsigned int state_idx; + s64 sleep_ns, target_ns; + + if (!gd || !gd->reflect_residency) + return; + + sleep_ns =3D ktime_to_ns(ktime_sub(ktime_get(), gd->last_enter)); + state_idx =3D genpd->state_idx; + state =3D &genpd->states[state_idx]; + target_ns =3D state->power_off_latency_ns + state->residency_ns; + + if (sleep_ns < target_ns) { + state->above++; + } else if (state_idx < (genpd->state_count -1)) { + next_state =3D &genpd->states[state_idx + 1]; + target_ns =3D next_state->power_off_latency_ns + + next_state->residency_ns; + + if (sleep_ns >=3D target_ns) + state->below++; + } + + gd->reflect_residency =3D false; +} #else static inline void genpd_debug_add(struct generic_pm_domain *genpd) {} static inline void genpd_debug_remove(struct generic_pm_domain *genpd) {} static inline void genpd_update_accounting(struct generic_pm_domain *genpd= ) {} +static inline void genpd_reflect_residency(struct generic_pm_domain *genpd= ) {} #endif =20 static int _genpd_reeval_performance_state(struct generic_pm_domain *genpd, @@ -982,6 +1012,9 @@ static int genpd_power_on(struct generic_pm_domain *ge= npd, unsigned int depth) if (genpd_status_on(genpd)) return 0; =20 + /* Reflect over the entered idle-states residency for debugfs. */ + genpd_reflect_residency(genpd); + /* * The list is guaranteed not to change while the loop below is being * executed, unless one of the parents' .power_on() callbacks fiddles @@ -3517,7 +3550,7 @@ static int idle_states_show(struct seq_file *s, void = *data) if (ret) return -ERESTARTSYS; =20 - seq_puts(s, "State Time Spent(ms) Usage Rejected\n"); + seq_puts(s, "State Time Spent(ms) Usage Rejected Above = Below\n"); =20 for (i =3D 0; i < genpd->state_count; i++) { struct genpd_power_state *state =3D &genpd->states[i]; @@ -3537,9 +3570,10 @@ static int idle_states_show(struct seq_file *s, void= *data) snprintf(state_name, ARRAY_SIZE(state_name), "S%-13d", i); =20 do_div(idle_time, NSEC_PER_MSEC); - seq_printf(s, "%-14s %-14llu %-14llu %llu\n", + seq_printf(s, "%-14s %-14llu %-10llu %-10llu %-10llu %llu\n", state->name ?: state_name, idle_time, - state->usage, state->rejected); + state->usage, state->rejected, state->above, + state->below); } =20 genpd_unlock(genpd); diff --git a/drivers/pmdomain/governor.c b/drivers/pmdomain/governor.c index d1a10eeebd16..c1e148657c87 100644 --- a/drivers/pmdomain/governor.c +++ b/drivers/pmdomain/governor.c @@ -392,6 +392,8 @@ static bool cpu_power_down_ok(struct dev_pm_domain *pd) if (idle_duration_ns >=3D (genpd->states[i].residency_ns + genpd->states[i].power_off_latency_ns)) { genpd->state_idx =3D i; + genpd->gd->last_enter =3D now; + genpd->gd->reflect_residency =3D true; return true; } } while (--i >=3D 0); diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 6e808aeecbcb..0b18160901a2 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -142,6 +142,8 @@ struct genpd_governor_data { bool max_off_time_changed; ktime_t next_wakeup; ktime_t next_hrtimer; + ktime_t last_enter; + bool reflect_residency; bool cached_power_down_ok; bool cached_power_down_state_idx; }; @@ -153,6 +155,8 @@ struct genpd_power_state { s64 residency_ns; u64 usage; u64 rejected; + u64 above; + u64 below; struct fwnode_handle *fwnode; u64 idle_time; void *data; --=20 2.43.0