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: 247730 Delivered-To: patches@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp334207ilo; Fri, 14 Aug 2020 05:34:43 -0700 (PDT) X-Received: by 2002:a2e:80d3:: with SMTP id r19mr1297212ljg.310.1597408483780; Fri, 14 Aug 2020 05:34:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597408483; cv=none; d=google.com; s=arc-20160816; b=dplKoirf5E7r3mSgWueT5L3bhi9b3HQckmuKdpJNQWPSL0ZsttQzK/VFW3Z5dW+Fkq K7kEipnlAdSLa8i8lg/aTLcHRVQZTl5enA4E8P54sOCl2yGg8pfGNkDbJ1QaTnmQKVM6 QA77zGHsUQA7wywixaTpa3a7sIIedbdYZb3WOLyXpga/AmN7gB3N+Dq04t8zi4Hb8Mha I+hxe7NrP3AGPDSjSSKzjhXM5L2TyCyvKKgw0DOSZ/jsb1hGE6yz2d/nygxTGB45MMPy bO9fvVfqcVtoG5yqcSHWyJvqwUQCfe8g4EyloWPx1wuiIaWFUyJKQYzIgdptC71qMJz9 Ritw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=8aVoGCMCcv9Pur2tl+i/JV47L57zCbtcAw9hM4hvPuc=; b=noMzAWBTdgsAcJ2xCUf4sSR6rVSgAybKK37zVdTePIkdogJRdriKAQysK6VNxodmJq vDfw1fGDW/E2S30XYXw5qu+3vwKjdXmOKLrbqwFsRmicD/XYknFJ0KoP6Kro26H+0toM jOm4H6ZB3hYFXPpdlUW6cjCidDXhgsoQ3hCtbJ89e6/vZuDVDw1oOB/RvjPf7PjHq8/p pH5D+sugjGl2Ts0dQeKQi4Zh2iHt2M5enR4C7WzWLkxGx2FqGXTXirLb4E7drjTxSGgD z9jNYQVd9iVJJz37bKStCDi+kpG4u59HUBoamNfpFTC8ENte37Y7HyRHK0mZSA7SYfno nrCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="x/Zvl0ou"; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r26sor4332237ljg.51.2020.08.14.05.34.43 for (Google Transport Security); Fri, 14 Aug 2020 05:34:43 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="x/Zvl0ou"; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=NWYW+VMOC0s/LO6oNnLToIs+ZJug42XdDqdMsWSKJQvkgZh2WVdU7Vxna4Eqw+D7ep GabzPDgyNFbMhfq1ZtmS67MWDv186dOgDhmrT/NYIhNorEQWM6jDlX+k+84+HCmbECDT c4sMzJ9Zi9pe3kUAAorxpWqJcMFHSSSDbIUsAT36X4tYjJRIGCE+9jkEaRxvjPbopxan wwIhmRSRpFeTtWAuXn7L197tk16v0OCXv/CJyvFA4aF2bUFN3tq/vBlNLFlsw8sSvPgp 5AMIeOfNlAofJAJN9ILz5AiaLVl1JHXftxYoY8lRxgsqzsc+XhGFk1HBqkgEKCrAPQti tgnA== X-Gm-Message-State: AOAM533tvQeyVGww71SGTmucmsO8jWwdGvm9ft/8MXGkhhfDVrwZ4k9P QX4aNidfxokZdN/SeRB8hltfHMLI 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) Return-Path: 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 Cc: "Rafael J . Wysocki" , Daniel Lezcano , Lina Iyer , Lukasz Luba , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Benjamin Gaignard , Ulf Hansson , linux-arm-kernel@lists.infradead.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 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(-) -- 2.25.1 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; }