From patchwork Mon May 27 14:25:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13675439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 90810C25B7E for ; Mon, 27 May 2024 14:26:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=33jvznGdS65qVZrUy8bELaW10niFCJO4Lp+oTMbVJcw=; b=S2NJiBHnMyQtwG ZvW8eLvsJPSi6ieIcd554F3nsj0dvsLczpBqxU8M1Y+ggT9AZKSYkWaFoJQxbxJ3jE8DFaow7BNmL xLsSGgpIGr1OLjVVvMn8f/URmRaMgeuTzJ7cD0ZttepjAd++25R+bztQYavWEJzTrf11ySlUAD27E +UNAUAcxSIGK9zVEx2eBOcGMI+li7hxnKnMscObQrGsE3afH8QAbMbeOX34/mYePAMebLjjNLI/eg NfNRRHcp4hW8Rctt0C9WqKykzrXaJg4EEXUxZwJYukUpoieQ9wqeEuKr2GA4LurD0tOvqSWAx3iQY Vtu9RSEPPOfqbAWP4qYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBbJ2-0000000FMEq-2U5E; Mon, 27 May 2024 14:26:32 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBbIo-0000000FM5r-24fa for linux-arm-kernel@lists.infradead.org; Mon, 27 May 2024 14:26:20 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-529682e013dso3428040e87.3 for ; Mon, 27 May 2024 07:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716819976; x=1717424776; darn=lists.infradead.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=LljiSusVSLaQvLa3fMIpBprCm3Nn7mYz+K0yIBAx5Q8=; b=PHZrRyt5xxt2OUUw+Yils0Z6uLNIBbKr5CRPysgO+5YjQvP4yE08WCuLWPxQr9k4zI GJ4awt6P4NJuidLl0SGUuxhh5qDQbAnX1DV5a9OAA/YQJrAUievaWWWsbFwOsnEgA3IW nWv/cP0foSxK5kG24FvCv7awVZ8wR68wGBhQIzR/xeYEUpsQqBu3FS6s3wda1zpep+xd hJwh88GpB019vFzgztDRERbExlCMSV1G56QWZAbdm4FJMVjPnRfpFSbhMPDJzMUz6/Bc S0p4I1LHi+je/u1vXIjTKOOVdGRFUlkQEXb+A4/NhG2v/8rsQhB+UMS/pEwboVa/I7n+ a03A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716819976; x=1717424776; 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=LljiSusVSLaQvLa3fMIpBprCm3Nn7mYz+K0yIBAx5Q8=; b=bFPzp9eNQ7P/fIPmphFCllXoExjcA5C9hhqjpiYSH9gAUPbjdfJWXbgt19pFkEpEme xxkt2CI17tX7JnhMTMQcQdz6IcIiFGLXyOiWv7JE7aW8OZ1UF/CfN5Y2NQctqX2siof7 yee3sIOg4xVBwRLq4+nuZ1FGAvWU8eM07mZaZTo1SGZIPcbFHev2Vg4tV1w626OFCR6Q UyZNvoyk5C6VQ7wi02E9yREZTh0hbUPp3IRe8EPKZu6rD5ckQkjVogErwUZ/BLyo21XR +ecSgGmutXK5GIuvjFEKm/eABQZ7bsyJTUDSRII1wP2gZ9rCMFnqS5IZWPihPLmnJP1o 8+kw== X-Forwarded-Encrypted: i=1; AJvYcCVGRkTPi+x5KWbSCRL25InNUOASV+52HV2PDtwMcvifKZkfVs/V0jE7wgEB94bAKRmjrrMNhXJbmmjwU47DGQr+J2OQDydDV5DOT9rkSZM7zxn1C3M= X-Gm-Message-State: AOJu0YySs4FPuYrPVXq6vxvX9hZ6W85pjAni/5V84O6r4LXVDBBgu+Sc M9Nom/g57W2ho9Q06MDlqP1s7YV21pxrGjIkRxwntgR+WHi+vm58wT2+n6CaoongiWWAHduy7eA J X-Google-Smtp-Source: AGHT+IHda/pxt1Ko7UnJfUcRRPdZ4toQLHtsmBjmcxqQ5f4apt+9Z4qbCKGMZXNL6CMfnbUjmtCv8g== X-Received: by 2002:a19:ee0b:0:b0:518:a9bf:73ec with SMTP id 2adb3069b0e04-5296519899emr5678201e87.35.1716819976367; Mon, 27 May 2024 07:26:16 -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-529711fa7f3sm562002e87.258.2024.05.27.07.26.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 07:26:15 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Nikunj Kela , Prasad Sodagudi , Maulik Shah , Daniel Lezcano , Krzysztof Kozlowski , Ulf Hansson , linux-rt-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/7] cpuidle: psci: Enable the hierarchical topology for s2ram on PREEMPT_RT Date: Mon, 27 May 2024 16:25:56 +0200 Message-Id: <20240527142557.321610-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240527142557.321610-1-ulf.hansson@linaro.org> References: <20240527142557.321610-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240527_072618_729856_B728EDC5 X-CRM114-Status: GOOD ( 18.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The hierarchical PM domain topology are currently disabled on a PREEMPT_RT based configuration. As a first step to enable it to be used, let's try to attach the CPU devices to their PM domains on PREEMPT_RT. In this way the syscore ops becomes available, allowing the PM domain topology to be managed during s2ram. For the moment let's leave the support for CPU hotplug outside PREEMPT_RT, as it's depending on using runtime PM. For s2ram, this isn't a problem as all CPUs are managed via the syscore ops. Signed-off-by: Ulf Hansson --- Changes in v2: - None. --- drivers/cpuidle/cpuidle-psci.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index d82a8bc1b194..ad6ce9fe12b4 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -37,6 +37,7 @@ struct psci_cpuidle_data { static DEFINE_PER_CPU_READ_MOSTLY(struct psci_cpuidle_data, psci_cpuidle_data); static DEFINE_PER_CPU(u32, domain_state); +static bool psci_cpuidle_use_syscore; static bool psci_cpuidle_use_cpuhp; void psci_set_domain_state(u32 state) @@ -166,6 +167,12 @@ static struct syscore_ops psci_idle_syscore_ops = { .resume = psci_idle_syscore_resume, }; +static void psci_idle_init_syscore(void) +{ + if (psci_cpuidle_use_syscore) + register_syscore_ops(&psci_idle_syscore_ops); +} + static void psci_idle_init_cpuhp(void) { int err; @@ -173,8 +180,6 @@ static void psci_idle_init_cpuhp(void) if (!psci_cpuidle_use_cpuhp) return; - register_syscore_ops(&psci_idle_syscore_ops); - err = cpuhp_setup_state_nocalls(CPUHP_AP_CPU_PM_STARTING, "cpuidle/psci:online", psci_idle_cpuhp_up, @@ -222,13 +227,16 @@ static int psci_dt_cpu_init_topology(struct cpuidle_driver *drv, if (!psci_has_osi_support()) return 0; - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - return 0; - data->dev = dt_idle_attach_cpu(cpu, "psci"); if (IS_ERR_OR_NULL(data->dev)) return PTR_ERR_OR_ZERO(data->dev); + psci_cpuidle_use_syscore = true; + + /* The hierarchical topology is limited to s2ram on PREEMPT_RT. */ + if (IS_ENABLED(CONFIG_PREEMPT_RT)) + return 0; + /* * Using the deepest state for the CPU to trigger a potential selection * of a shared state for the domain, assumes the domain states are all @@ -312,6 +320,7 @@ static void psci_cpu_deinit_idle(int cpu) struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu); dt_idle_detach_cpu(data->dev); + psci_cpuidle_use_syscore = false; psci_cpuidle_use_cpuhp = false; } @@ -408,6 +417,7 @@ static int psci_cpuidle_probe(struct platform_device *pdev) goto out_fail; } + psci_idle_init_syscore(); psci_idle_init_cpuhp(); return 0;