From patchwork Mon May 13 19:22:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 164060 Delivered-To: patches@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1728465ili; Mon, 13 May 2019 12:23:26 -0700 (PDT) X-Received: by 2002:a2e:41c:: with SMTP id 28mr12895750lje.69.1557775406521; Mon, 13 May 2019 12:23:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775406; cv=none; d=google.com; s=arc-20160816; b=i/qlOZDdp397FsX6KdByBNeG2JqDrxrE2AsemnKntp74wJrMvFeplFiYgj2LUrokvi mtYPnl9yPSZxfjHyngXHx5Ms6MzNJ1GaBANzeevbKJuA1jkJhImdpkTClgycYC98/Ksk AWJDf0SryHFeQDolbLJijfVyXRDlKlXO6wNV0xKZ0b7KP3aR8D238UFCM2YwmxyXSuz1 ZmzWI3JtQFyOS97kv2/Hor7lt7ypQ5540QWGoByOczbQM8xybe+XvZBmKU5+EaLbPV3S ukjQXHHwmZucZSh3obSCAsEZ4xq8ZCw0I/8Wex/lTM5Z+AWd7AojEs2S0M0nqo4XAP6J hY/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XTy06JPjF+Flbr9WT5p68Fa18r9/HEAcUQNjh0fiSxI=; b=TtCDOhi45dZ89JLWm6N8LgfyBx2JMH8t8dLrZR/Ci/NiaVj4agvkQDYFy1G3FCqOt+ 9ly/MnnxP8gZzXswtu9Gqgw5BpRoy7oJmhT7S0ybtHuO3s5MyauvYEveuAavuRHCLbhy bYUi06lFkh44o5BCXgsUDUuF71C1DBejj1NunK+IWiO0gvFDZF5bPCIBeLpijG5zo+s1 nmkrwt3FM+1aq+XdeE/jzKpy2cotvrou5xrwt26tLgrlDfuv1WlZzCbdLbSM8d+8IZQu BvVA+LcBRLSvndcmPR4EOMjv6sw1J1UdUU2/yVdsVWdGWeqxovJgNrNtBDKziwL6ytdx dJpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xNwX3XNe; 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 65sor3934294lfa.34.2019.05.13.12.23.26 for (Google Transport Security); Mon, 13 May 2019 12:23:26 -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=xNwX3XNe; 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:in-reply-to:references; bh=XTy06JPjF+Flbr9WT5p68Fa18r9/HEAcUQNjh0fiSxI=; b=xNwX3XNe/fEpvPHbUQrZ5x+LqEpdA/RH0mdOzfdRzVQASPFEcNy/mFD0OfHWCToaZ0 PrLL4rnH27RSud7LIy378Wj4Wj8Hh9/Xt0I8VfOlVZRAh/O3hbwv62GHEi7+LF8SOLO2 tt3BCSJoO1lX0RHEpuYlTM6SspGottirXeynSYFliz9YP8Y+Zzt7m+A613Qa7wbd7vf9 9Bq4pR31rg1WKJVhfAuJ5QPRwmYRPdi4ueAQ4ADAi0B9GO8o48sWaERmDbLHwHzGEjEy 1VAPQLLEoIZKP/kHIeO1MNUF7XhwAH5ChUeHgtbVhjw8ggkBEECcBqw/N9bFX+WErUR/ 8B/Q== 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; bh=XTy06JPjF+Flbr9WT5p68Fa18r9/HEAcUQNjh0fiSxI=; b=TqBWwvq2hR0UEPBGekAon/Yw4yZBy0la7u0Laub6uB6p8PRE5NsMoIpW2WOzqtUgRX LtSe8m9bw7N2aSK8otXuGs+uX+J36tKaXuOxDNHVLIa86sXpoZjQUbU6/dc0j9X3wlMC XiGWgooW8ErIhHjizpcC6qy+Nw3fCMBNRdg04p1wQhLHUcI/w+mOhAYQ6n/Q7l5xIAFw UwAOE2lA9k4JHL5oBfFGpEYWBnGngVm9JzyU2wHnejPKhT89QqhoQ8zuYn4KWWTXtIX5 2B98yinLop6+6reF2fXB0DpAKfu/Z8UvMAPWBeqxTgMSbl7vR5+h3E+5zF4rVcY8W6pt rBUg== X-Gm-Message-State: APjAAAUt1c89H/6jpvY0Dj5fJ6cYU5F3htY4XYsCOpY4/9UzHI2k85SX bUCYgUFgoaOsCR1Q3Jezbfo8baXH X-Google-Smtp-Source: APXvYqy6lylq/7RbTmCodW9mEbVCUkckcxopczjrEblxG06MxFPhpTcYSizZjnHDtDbPl63l4lZbOw== X-Received: by 2002:ac2:410e:: with SMTP id b14mr7738149lfi.100.1557775406156; Mon, 13 May 2019 12:23:26 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q21sm3449365lfa.84.2019.05.13.12.23.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 12:23:25 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson , Lina Iyer Subject: [PATCH 11/18] drivers: firmware: psci: Introduce psci_dt_topology_init() Date: Mon, 13 May 2019 21:22:53 +0200 Message-Id: <20190513192300.653-12-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513192300.653-1-ulf.hansson@linaro.org> References: <20190513192300.653-1-ulf.hansson@linaro.org> To be able to initiate the PM domain data structures for PSCI at a specific point during boot, let's export a new init function, psci_dt_topology_init(). If CONFIG_CPU_IDLE is set, it calls psci_dt_init_pm_domains(), which performs the actual initialization. Note that, it may seem like feasible idea to hook into the existing psci_dt_init() function, rather than adding a new separate init function. However, this doesn't work because psci_dt_init() is called early in the boot sequence, when allocating dynamic data structures isn't yet possible. Subsequent changes calls this new init function. Finally, following changes on top needs to know whether the hierarchical PM domain topology is used or not. Therefore, let's store this information in an internal PSCI flag. Co-developed-by: Lina Iyer Signed-off-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes: - Moved some code inside "#ifdef CONFIG_CPU_IDLE". - Updated changelog. --- drivers/firmware/psci/psci.c | 30 ++++++++++++++++++++++++++++++ include/linux/psci.h | 2 ++ 2 files changed, 32 insertions(+) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index bfef300b7ebe..28745234b53f 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -297,6 +297,7 @@ static int __init psci_features(u32 psci_func_id) #ifdef CONFIG_CPU_IDLE static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); static DEFINE_PER_CPU(u32, domain_state); +static bool psci_dt_topology; static inline u32 psci_get_domain_state(void) { @@ -480,6 +481,19 @@ static const struct cpuidle_ops psci_cpuidle_ops __initconst = { CPUIDLE_METHOD_OF_DECLARE(psci, "psci", &psci_cpuidle_ops); #endif + +static int __init _psci_dt_topology_init(struct device_node *np) +{ + int ret; + + /* Initialize the CPU PM domains based on topology described in DT. */ + ret = psci_dt_init_pm_domains(np); + psci_dt_topology = ret > 0; + + return ret; +} +#else +static inline int _psci_dt_topology_init(struct device_node *np) { return 0; } #endif static int psci_system_suspend(unsigned long unused) @@ -758,6 +772,22 @@ int __init psci_dt_init(void) return ret; } +int __init psci_dt_topology_init(void) +{ + struct device_node *np; + int ret; + + np = of_find_matching_node_and_match(NULL, psci_of_match, NULL); + if (!np) + return -ENODEV; + + /* Initialize the topology described in DT. */ + ret = _psci_dt_topology_init(np); + + of_node_put(np); + return ret; +} + #ifdef CONFIG_ACPI /* * We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's diff --git a/include/linux/psci.h b/include/linux/psci.h index 4f29a3bff379..16beccccbbcc 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -55,8 +55,10 @@ extern struct psci_operations psci_ops; #if defined(CONFIG_ARM_PSCI_FW) int __init psci_dt_init(void); +int __init psci_dt_topology_init(void); #else static inline int psci_dt_init(void) { return 0; } +static inline int psci_dt_topology_init(void) { return 0; } #endif #if defined(CONFIG_ARM_PSCI_FW) && defined(CONFIG_ACPI)