From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7506FC433E6 for ; Tue, 1 Sep 2020 12:14:06 +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 3E646206EB for ; Tue, 1 Sep 2020 12:14:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZhldBD1W"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yhguxh/v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E646206EB 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+linux-arm-kernel=archiver.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:References:In-Reply-To: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:List-Owner; bh=boXFvM4I9ApM4sRzOHTsc2GsvxwaPYUfbdxEY+8nmhs=; b=ZhldBD1Wy3nqeJ2M1BRLgTt/W 7nR6DdgRjbrUQBeODOSzKzoSrfNHJs9BC24Pm4tBc4ozflz95az8pAWMMHNqe9lRJJyMDXBYSHsvg L2/gm4CjRNYuS8mr+Zjp9TPriYU0sj4OWFJ8x68GcDlXR1hSw9BtiilpvqYYz1zDcIAmLWJzV68A5 nsq/Fzz7PKJWYTQJ0kDh0H+CL4SEsH5ekxQ9DHEZsN6ea0XFUa8JTM7LE+voyEWt8C12Rk0Bqvjog XIpWp4QXtjth/CvsApShLPWmcCmr+PlLAw80BzE1eFyhMprGNHTqYitEl6qLARFQ7lBem+K561WSM o/W8CL+YQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kD59Z-0001fe-21; Tue, 01 Sep 2020 12:12:45 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kD59W-0001eb-AU for linux-arm-kernel@lists.infradead.org; Tue, 01 Sep 2020 12:12:43 +0000 Received: by mail-lj1-x244.google.com with SMTP id a15so1229252ljk.2 for ; Tue, 01 Sep 2020 05:12:40 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=5cU9q2qmzfSVfsoCjyVJEHGi6YkUuYbmq67VIQe2n0w=; b=yhguxh/vBJx2bdVfHod6sKwD+1nJ4mtd2exx8L4uSxfsblzwU8/UI4+al8NZ74PQO8 D5BQ/MeCvwpak00y3RoOKDziEzdlvWO0xu9r2e75mYpjG7AWWmozD57JqiVocyyudU7d +u+I64yVM0QGRK0L4ii7FD0oP9EgVBIscJQxRfLD89PfS+9jQTuL0gf7nAX61JRmxKo2 S/gS6p1LPrFTBBNR3D/MHdpakT1nbn1dss5lVYE8NDSfdGuVjJ25V3TvmUQ+YZDxm8cP eUfKpZJn4YmC55xnxQk8nDjIu04Ce5TCXFHwXc1bytsEsMFUg7DH1T7AA/Qfpho1tojP sdiQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=5cU9q2qmzfSVfsoCjyVJEHGi6YkUuYbmq67VIQe2n0w=; b=NyXFBoxRRrcYlkiajl9Sbwza6mH9Ermtmvm7hts1ToxjLcnk6FDBVikRf7gGUjfJkZ 4Y7kB3bMuJ4Y22kVK1GMqmNt0Xxxh3kQKq7isDSZVp+EGH170bO9TvfF19dtB2rI2geI gqSy/1JrtBFe+oj8FQ7fEgQ4vWkl87vHFEif02hncJc67App8JkvDMmZzC684V242Si/ uGBNzqMRB6O+a+pCqe4BRna9jusQDju4KWcqsZNcHhjDWsdIz25HPpJWYxozsU/OHqcB cko3ykHChyinWQB4wTvV8kuVE57GSfOxkJOAGOUekoow1Hhtb6IE2ID9/DntTvsduseP 97aQ== X-Gm-Message-State: AOAM531p9qAv+Fra4DxdlNl5VSxG7UmiXN1o11dyi5MDr4ChBl/3E0i8 dA7UTrxCJ0HdK5yWQu9gU4m39g== X-Google-Smtp-Source: ABdhPJwoffSXIieoiLOcYaunHNPEpTMob++deBrMhVsh7hnLRFyn++yNJrS0iqiCQfJehQt6yFzv4g== X-Received: by 2002:a2e:854c:: with SMTP id u12mr453343ljj.120.1598962359733; Tue, 01 Sep 2020 05:12:39 -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 u6sm241193ljg.105.2020.09.01.05.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 05:12:38 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Subject: [PATCH v2 2/2] cpuidle: psci: Allow PM domain to be initialized even if no OSI mode Date: Tue, 1 Sep 2020 14:12:26 +0200 Message-Id: <20200901121226.217568-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200901121226.217568-1-ulf.hansson@linaro.org> References: <20200901121226.217568-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-20200901_081242_398147_00E3C9D0 X-CRM114-Status: GOOD ( 24.23 ) 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: Mark Rutland , 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.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 --- Changes in v2: - Assign the genpd ->power_off() callback, only when the PSCI OSI mode has been successfully enabled. --- drivers/cpuidle/cpuidle-psci-domain.c | 57 ++++++++++++++------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index b6ab0415f450..256e7e35b5af 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -105,7 +105,7 @@ static void psci_pd_free_states(struct genpd_power_state *states, kfree(states); } -static int psci_pd_init(struct device_node *np) +static int psci_pd_init(struct device_node *np, bool use_osi) { struct generic_pm_domain *pd; struct psci_pd_provider *pd_provider; @@ -135,11 +135,14 @@ static int psci_pd_init(struct device_node *np) pd->free_states = psci_pd_free_states; pd->name = kbasename(pd->name); - pd->power_off = psci_pd_power_off; pd->states = states; pd->state_count = state_count; pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN; + /* Use the ->power_off() callback when OSI is enabled. */ + if (use_osi) + pd->power_off = psci_pd_power_off; + /* Use governor for CPU PM domains if it has some states to manage. */ pd_gov = state_count > 0 ? &pm_domain_cpu_gov : NULL; @@ -190,7 +193,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 +206,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 +217,20 @@ 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 bool 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 false; + + ret = psci_set_osi_mode(true); + if (ret) { + pr_warn("failed to enable OSI mode: %d\n", ret); + return false; + } + + return true; } static void psci_cpuidle_domain_sync_state(struct device *dev) @@ -244,14 +251,14 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; struct device_node *node; + bool use_osi; int ret = 0, pd_count = 0; if (!np) return -ENODEV; - /* Currently limit the hierarchical topology to be used in OSI mode. */ - if (!psci_has_osi_support()) - return 0; + /* If OSI mode is supported, let's try to enable it. */ + use_osi = psci_pd_try_set_osi_mode(); /* * Parse child nodes for the "#power-domain-cells" property and @@ -261,7 +268,7 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) if (!of_find_property(node, "#power-domain-cells", NULL)) continue; - ret = psci_pd_init(node); + ret = psci_pd_init(node, use_osi); if (ret) goto put_node; @@ -270,30 +277,24 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) /* Bail out if not using the hierarchical CPU topology. */ if (!pd_count) - return 0; + goto no_pd; /* 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(true); - if (ret) { - pr_warn("failed to enable OSI mode: %d\n", ret); - psci_pd_remove_topology(np); - goto remove_pd; - } - pr_info("Initialized CPU PM domain topology\n"); return 0; 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); +no_pd: + if (use_osi) + psci_set_osi_mode(false); return ret; } -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel