From patchwork Mon Apr 29 14:05:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13647063 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 46D70C04FFE for ; Mon, 29 Apr 2024 14:06:27 +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=4v61oNLN1Lj7Aqb0ZajK6g3668KFU9q90n5xn8MOfZQ=; b=M7FftxnyYy65dZ 7iY8fHpsoucU995sOjkhP8P8M1whZGw8Nm4noPUiZyaKqaSWeiG2hqw2a+s3k+FCKoC+2SoT2MoYZ 8k3GGHayHCohWm4FgmJTagT68JkijsVnHFN4Qjo4GoHcQead0QueAKfQT82hBEsC//oSVCc2IUtJz 5z7i0cepJfg/X5N9FgU05WhSU6264KFZ04pqPtgJe2coINVAHr/54yBJuSuTsCiOc5rBjNe30Vjnm As2Rk9aZWeyYZRp16Fkd5BZrVtLGeEqQSIJmcVGELxMaiSYRZ6oCBnbqmOJWxhCKwnoign/PAH256 mTmRxWiDS3c1sZtTvKAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Rdz-000000033Qk-3Ci1; Mon, 29 Apr 2024 14:06:11 +0000 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Rdr-000000033MY-0Dk8 for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 14:06:04 +0000 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2dd041acff1so51666411fa.1 for ; Mon, 29 Apr 2024 07:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714399560; x=1715004360; 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=PRW2Pq+Tdw9L+sqrvYL/hlPVkk69kmUaGQ7JliOeiWk=; b=dx4Zh4/CE+FUznrr9v762ehM5qotcWuLXMv9ThMr/bPwuyg5ata3LT9XR/rTUshzTS C6BGf06S1ToEIHFrieXP0tV/aSsgjyFeAQDHvYtaPiuiZUC/YcR85XVemdCAGo8wx8DV 0MO7kBTlp/3yQ7m57TboQh7t5WLMere795FiaoaDUmoIODkq7DB1zHxotFVOVueXCGsN fG9xbFQxYa0BBt/m66D6kVoNxnUgI6yjH3+6/6pkhwz/LMfE5fcXKPiHnve5bzt6GXNn 8iptPB9/kYQrC363WtrhPrkjbMUYsEkq1YvI6K8cfTnJ/MGC7CKbGm1tx3R6CawoXosZ McPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714399560; x=1715004360; 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=PRW2Pq+Tdw9L+sqrvYL/hlPVkk69kmUaGQ7JliOeiWk=; b=GNjf37JgOzmgou4Nt+cXXKUOFUVIFGs8UGXJu8tsgjWXZ6WZDYQIuQLTPYgoj04x4M pi9OZpKTNjBakvpdfL3tFmNHtmA1K8euB3tbZJZixUJa35ikdpgiQSzRsydHsuNz2WI3 13AMVtzcmr9uizrSVC/N5QjJrTtqizkSz85U2MI1OuE/K2nXxgKLbnSmcTZPJEYjAD2z ZXVTczq3UtJODphBPRJXkuhWeKxSjXoaw8/NtuHmYURni80HhmCuAqfJHWWtYotbxMKW 0AIqi8nBYGXk1TGDiOOd54lHzhHZjpc6x33TBmzcDdcYLJCRFFgwkw9R9h1Tfy8R+GDk epZg== X-Forwarded-Encrypted: i=1; AJvYcCU8gJTMwsRQR9S3Y8iKVfSUbHskLxKPoeeDOa3Gw93npkQnKZ7LETDywIeplCVhaUWKUGQrAVWPDcv+fhB7t0FshgaUVMAvRFKo1s93RlNCxCRYOpc= X-Gm-Message-State: AOJu0YzArJTkKAitAbvPLWrzsLEufsNsUnGDMG0vHkMNYkpjQ9q0/M0C RNaiM+hdwQ6rIHoEMiRAlutZYr1zUmHWprGOO7+Cwocr1wPVAItiFJUK70tl7+o= X-Google-Smtp-Source: AGHT+IGIsr9yUsbk31OY7Zps8MJ+0AvyGsEZBZ8WqFFN1lmQJPsxbIeDmm4LCdu93BtCTFbs9IJWAA== X-Received: by 2002:a2e:a26c:0:b0:2df:b0c4:3ede with SMTP id k12-20020a2ea26c000000b002dfb0c43edemr4066331ljm.19.1714399559743; Mon, 29 Apr 2024 07:05:59 -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 l5-20020a2e9085000000b002d7095bf808sm3636733ljg.128.2024.04.29.07.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 07:05:59 -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 5/6] cpuidle: psci: Enable the hierarchical topology for s2ram on PREEMPT_RT Date: Mon, 29 Apr 2024 16:05:30 +0200 Message-Id: <20240429140531.210576-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240429140531.210576-1-ulf.hansson@linaro.org> References: <20240429140531.210576-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-20240429_070603_147998_EEC8803C X-CRM114-Status: GOOD ( 18.00 ) 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 --- 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;