mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Abel Vesa <abel.vesa@oss.qualcomm.com>
To: Ulf Hansson <ulfh@kernel.org>, "Rafael J. Wysocki" <rafael@kernel.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org,
	Abel Vesa <abel.vesa@oss.qualcomm.com>
Subject: [PATCH 2/4] pmdomain: core: Prepare boot performance floors before system suspend
Date: Tue, 13 Oct 2026 15:48:40 +0300	[thread overview]
Message-ID: <20261013-genpd-boot-performance-floor-v1-2-a765dc83e6d7@oss.qualcomm.com> (raw)
In-Reply-To: <20261013-genpd-boot-performance-floor-v1-0-a765dc83e6d7@oss.qualcomm.com>

A system suspend can occur before a provider has received sync_state().
If a domain has not been used through runtime PM, its boot performance
floor may not have been applied when genpd_sync_power_on() enables it
during resume-noirq.

Prepare boot performance floors from genpd_prepare(), where performance
callbacks may sleep. Walk the parent hierarchy even when the device's
own domain has no boot floor: a parent without direct consumers would
otherwise miss preparation entirely. Take parent locks in the existing
child-to-parent order and propagate preparation failures to the PM core.

Also retain boot power protection in genpd_sync_power_off() for domains
with a boot performance floor. This prevents the system-sleep path from
withdrawing their power vote while boot protection remains active.

Keep performance programming out of resume-noirq. Domains with their
floor already satisfied do not need another performance update, and
no floor is imposed after sync_state() releases boot protection.

Assisted-by: LLM
Signed-off-by: Abel Vesa <abel.vesa@oss.qualcomm.com>
---
 drivers/pmdomain/core.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 6f2b406ce049..4ff55175d899 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -1538,7 +1538,9 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,
 {
 	struct gpd_link *link;
 
-	if (!genpd_status_on_unlocked(genpd) || genpd_is_always_on(genpd))
+	if (!genpd_status_on_unlocked(genpd) || genpd_is_always_on(genpd) ||
+	    (genpd_is_power_unknown(genpd) && genpd->stay_on &&
+	     genpd->boot_performance_state))
 		return;
 
 	if (genpd->suspended_count != genpd->device_count
@@ -1623,6 +1625,31 @@ static void genpd_sync_power_on(struct generic_pm_domain *genpd, bool use_lock,
 	genpd->status = GENPD_STATE_ON;
 }
 
+/* Called with the domain lock held, before entering noirq. */
+static int genpd_prepare_boot_performance(struct generic_pm_domain *genpd,
+					 unsigned int depth)
+{
+	struct gpd_link *link;
+	int ret;
+
+	/* Parents may need a boot floor even when this domain does not. */
+	list_for_each_entry(link, &genpd->child_links, child_node) {
+		struct generic_pm_domain *parent = link->parent;
+
+		genpd_lock_nested(parent, depth + 1);
+		ret = genpd_prepare_boot_performance(parent, depth + 1);
+		genpd_unlock(parent);
+		if (ret)
+			return ret;
+	}
+
+	if (genpd_needs_boot_performance_state(genpd))
+		return _genpd_set_performance_state(genpd,
+						   genpd->performance_state, depth);
+
+	return 0;
+}
+
 /**
  * genpd_prepare - Start power transition of a device in a PM domain.
  * @dev: Device to start the transition of.
@@ -1644,6 +1671,12 @@ static int genpd_prepare(struct device *dev)
 		return -EINVAL;
 
 	genpd_lock(genpd);
+	/* Performance callbacks may sleep; prepare the hierarchy before noirq. */
+	ret = genpd_prepare_boot_performance(genpd, 0);
+	if (ret) {
+		genpd_unlock(genpd);
+		return ret;
+	}
 	genpd->prepared_count++;
 	genpd_unlock(genpd);
 

-- 
2.54.0


  parent reply	other threads:[~2026-10-13 12:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 12:48 [PATCH 0/4] pmdomain: Preserve boot performance constraints until sync_state Abel Vesa
2026-10-13 12:48 ` [PATCH 1/4] pmdomain: core: Support a boot performance floor " Abel Vesa
2026-10-13 12:48 ` Abel Vesa [this message]
2026-10-13 12:48 ` [PATCH 3/4] pmdomain: qcom: rpmhpd: Let genpd enforce the boot performance floor Abel Vesa
2026-10-13 12:48 ` [PATCH 4/4] pmdomain: qcom: rpmpd: " Abel Vesa

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=20261013-genpd-boot-performance-floor-v1-2-a765dc83e6d7@oss.qualcomm.com \
    --to=abel.vesa@oss.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=ulfh@kernel.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

all inboxes | Powered by JetHome®