From patchwork Fri Aug 14 12:34:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11714503 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 66C491744 for ; Fri, 14 Aug 2020 12:36:33 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3676C20866 for ; Fri, 14 Aug 2020 12:36:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="saZ5YdO7"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="x/Zvl0ou" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3676C20866 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=oMyBdaB28zcf4AaAwWWpWtTALg8ZqH+c5zagfE98vvA=; b=saZ5YdO7lCUU8f28au38AGXGF0 90Swk0lk8Vhjw619Sw0eAszTUtjT7XJbbjxTy/q8EYskT6qCScbGlkCelHfvkrgSkn2b/1FpDkqTq VtN+HqPybzzaiXdj3wPz7kbVVXrOqTYC2gUBmnTq9DbnXKJxQIZSAmv/gmitxjlsE9NpHmGoxN/B2 CXIgMfkTPdumajYCtlOmGnRNp5F9Vkl4VB/UOZsgMT3CJwfRtluZnLnCqu7bcAilkluOkhOmM+CxP 4RajL0i4YUpgHxgRiIPKpbX3u/qTPAJp34KwudkcFXpyob4Pim1Hf+KKFDq/55a8OG7SgQ1LJSKVk vh3pL2dw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6Yv3-0004KA-UP; Fri, 14 Aug 2020 12:34:49 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6Yv1-0004JB-4C for linux-arm-kernel@lists.infradead.org; Fri, 14 Aug 2020 12:34:48 +0000 Received: by mail-lj1-x241.google.com with SMTP id w25so9713830ljo.12 for ; Fri, 14 Aug 2020 05:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8aVoGCMCcv9Pur2tl+i/JV47L57zCbtcAw9hM4hvPuc=; b=x/Zvl0ougehRb3wVjQjr0HoONDuxi42khbGkjaslALueN2HvNKrxyJzDzpnyO5UTCt r38QGo1s2yP2+BIioamuO13Uu/nlhVXKbM1iQleCylilcLu0ITIfrBP+DFnYqJcCaiHu rhT4p0WmM6piixPya+OAjfBRKJuU2LBQtOJaTVWR3ZEg5DIdMxeGScmcbShOxEqxGoaI W5mI7Bx93MLe4v8v4jHAlY201dYwrznnZwwNnMLw3/0gy6aSC4Je9XXs9O7CHYIKTLga gmEuE4hMm8BdHmNx4JN9aiP93Lhioo8qqcwUMIM/o1q7q5cbxR1rXDYtXUFJzXIx7D7j xksQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8aVoGCMCcv9Pur2tl+i/JV47L57zCbtcAw9hM4hvPuc=; b=smqDrktaulBatpzPBpr4TqSYJGvOXTSKeyefwfWKIzvKKCQgtbgpC+4axaDSG7K8Hv 2EmRNUfAwH4ubUaQKYye8nLLtpKsxy+Ic52XuIOVgpr0LpyvUMIfB/nIfOTBaI5U0H9t IC+mAarr/R310SPQPapuxKMsqMcoS2z61NcyqmhQsxeGmE1RZ8ZjjHoJ0Vg3XVndFAR2 T185ABTQI/+Rc6bFR7+AAOs/yUMaOU7aWOrGIRJMTMoELjqMtz8H31KEuaXpXbPlmly4 gM/wiUibK7n6n9YdT0Xf4kelfmFlHx/Y6bROFwitdfed3uF6Ve0QdNpQlifD56BwcmSf nq4A== X-Gm-Message-State: AOAM5331qsL7r5bg6GgOPTKMKSlpcXk0jwOmiU79LALMAl3PHvaf+0pW MmGSEnPjDJCkd7Kit4h7eLJvkg== X-Google-Smtp-Source: ABdhPJyAOCGDj1qaSczJ9tlFNl4QXH/NCYtmOjrrS69NKLy68n1a3HBKwskLzM+LwY9ORriDJtSslg== X-Received: by 2002:a2e:8346:: with SMTP id l6mr1264611ljh.0.1597408483313; Fri, 14 Aug 2020 05:34:43 -0700 (PDT) Received: from localhost.localdomain (h-98-128-180-79.NA.cust.bahnhof.se. [98.128.180.79]) by smtp.gmail.com with ESMTPSA id 12sm1733799lju.67.2020.08.14.05.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 05:34:42 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Subject: [PATCH] cpuidle: psci: Allow PM domain to be initialized even if no OSI mode Date: Fri, 14 Aug 2020 14:34:36 +0200 Message-Id: <20200814123436.61851-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200814_083447_499762_B5767009 X-CRM114-Status: GOOD ( 20.71 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:241 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Benjamin Gaignard , Stephen Boyd , Daniel Lezcano , "Rafael J . Wysocki" , Lina Iyer , Bjorn Andersson , linux-arm-kernel@lists.infradead.org, Lukasz Luba Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org If the PSCI OSI mode isn't supported or fails to be enabled, the PM domain topology with the genpd providers isn't initialized. This is perfectly fine from cpuidle-psci point of view. However, since the PM domain topology in the DTS files is a description of the HW, no matter of whether the PSCI OSI mode is supported or not, other consumers besides the CPUs may rely on it. Therefore, let's always allow the initialization of the PM domain topology to succeed, independently of whether the PSCI OSI mode is supported. Consequentially we need to track if we succeed to enable the OSI mode, as to know when a domain idlestate can be selected. Note that, CPU devices are still not being attached to the PM domain topology, unless the PSCI OSI mode is supported. Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci-domain.c | 49 +++++++++++++-------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index b6e9649ab0da..55653c110e3a 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -28,6 +28,7 @@ struct psci_pd_provider { static LIST_HEAD(psci_pd_providers); static bool psci_pd_allow_domain_state; +static bool psci_osi_mode_enabled; static int psci_pd_power_off(struct generic_pm_domain *pd) { @@ -37,7 +38,7 @@ static int psci_pd_power_off(struct generic_pm_domain *pd) if (!state->data) return 0; - if (!psci_pd_allow_domain_state) + if (!psci_pd_allow_domain_state || !psci_osi_mode_enabled) return -EBUSY; /* OSI mode is enabled, set the corresponding domain state. */ @@ -190,7 +191,7 @@ static void psci_pd_remove(void) } } -static int psci_pd_init_topology(struct device_node *np, bool add) +static int psci_pd_init_topology(struct device_node *np) { struct device_node *node; struct of_phandle_args child, parent; @@ -203,9 +204,7 @@ static int psci_pd_init_topology(struct device_node *np, bool add) child.np = node; child.args_count = 0; - - ret = add ? of_genpd_add_subdomain(&parent, &child) : - of_genpd_remove_subdomain(&parent, &child); + ret = of_genpd_add_subdomain(&parent, &child); of_node_put(parent.np); if (ret) { of_node_put(node); @@ -216,14 +215,21 @@ static int psci_pd_init_topology(struct device_node *np, bool add) return 0; } -static int psci_pd_add_topology(struct device_node *np) +static void psci_pd_try_set_osi_mode(void) { - return psci_pd_init_topology(np, true); -} + int ret; -static void psci_pd_remove_topology(struct device_node *np) -{ - psci_pd_init_topology(np, false); + if (!psci_has_osi_support()) + return; + + /* Try to enable OSI mode. */ + ret = psci_set_osi_mode(); + if (ret) { + pr_warn("failed to enable OSI mode: %d\n", ret); + return; + } + + psci_osi_mode_enabled = true; } static void psci_cpuidle_domain_sync_state(struct device *dev) @@ -249,10 +255,6 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) if (!np) return -ENODEV; - /* Currently limit the hierarchical topology to be used in OSI mode. */ - if (!psci_has_osi_support()) - return 0; - /* * Parse child nodes for the "#power-domain-cells" property and * initialize a genpd/genpd-of-provider pair when it's found. @@ -273,17 +275,15 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) return 0; /* Link genpd masters/subdomains to model the CPU topology. */ - ret = psci_pd_add_topology(np); + ret = psci_pd_init_topology(np); if (ret) goto remove_pd; - /* Try to enable OSI mode. */ - ret = psci_set_osi_mode(); - if (ret) { - pr_warn("failed to enable OSI mode: %d\n", ret); - psci_pd_remove_topology(np); - goto remove_pd; - } + /* + * If OSI mode isn't supported, the topology isn't used by CPUs, but + * it may still be used by other consumers. Leave it initialized. + */ + psci_pd_try_set_osi_mode(); pr_info("Initialized CPU PM domain topology\n"); return 0; @@ -291,8 +291,7 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) put_node: of_node_put(node); remove_pd: - if (pd_count) - psci_pd_remove(); + psci_pd_remove(); pr_err("failed to create CPU PM domains ret=%d\n", ret); return ret; }