From patchwork Wed Mar 14 16:58:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 131689 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410824edg; Wed, 14 Mar 2018 09:59:39 -0700 (PDT) X-Received: by 10.46.60.23 with SMTP id j23mr3800935lja.18.1521046779621; Wed, 14 Mar 2018 09:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046779; cv=none; d=google.com; s=arc-20160816; b=XZdlZRMzUkJetNZE1ibLiXH8pRVUXopKmLr2tHixC1tBdxMZiUeGLdNx/N/mwSgJ6m 8KdJEpneaHKBQ7ACOploU0Ol6KgwHHaeD8D7nIHAY1j/EV2OBJLQ0DxusYeHNxIw/2or U1Kh4fGTRoagTb1CJCtSMLf6EgeDmeCzIbineLjenLn7Aii0TYiF0sHSWa50gG/hiS4+ fHQBcnSirYorsvg9LMxTvAdpYB6Y1uEaKZbHs3G5PK3YWTusoFfJ1zXnkdRoM52SxwzJ lySkRmbBQzCmI0kkcYnQ0ziCdC0m9NR81CCxDzj7iszQb+lHYH+aNzfre8f63zXSbrNu VJ+w== 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:arc-authentication-results; bh=Ast09lSxwhE28SWe0BPPBHYfUP0z3fhspWiO7rL6yzA=; b=LqZbJJI3iyobrKwvp0MkA8MLy30is5bF6+Vb9t33KZrTsUwsGreHJxI8q7vXXwnf4H Xx8gQbR3aKXmxrNa4u5cTSMOUKmm0xr8ChGLqonUTXHG/mTOLg8akLKZLi2Je3M2u5k5 +ASl7aMkLoTScUXEhLK/N4Z45sc0F+hoihCig+nFHlSkCilWDmKaeQBBq8vLcYUWzRGP BEI4c0Ys/VpM+24YT2ftZM6qNs/E99waaHb5hB0eJ9r1MYIa9GrSor7WUSxdka+YLpwT S4W0CMBV8Mn5kwE2MIBe+HfsBwgpaYI0jd/bbpYx7U16ioAZTzpxOZ8rYLx9U3mbA5Tq HUEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bJsp5eRl; 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 q37-v6sor859929lfi.12.2018.03.14.09.59.39 for (Google Transport Security); Wed, 14 Mar 2018 09:59:39 -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=bJsp5eRl; 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=Ast09lSxwhE28SWe0BPPBHYfUP0z3fhspWiO7rL6yzA=; b=bJsp5eRlmCMocTNQ0XY0nAB/13CIzu81IWmweUGbKsK8ozyRxYPacnWimkKl48EXPE GAqSWKOQ9UMM3xsRUbOu+JtVAvrmofhA9IHumg6d+AcoEeg7KDO8LwDqEtVchdU6Jl2u /J8NkshQUjwp2swIoGuyQuO+E7Sfth0iRWAKg= 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=Ast09lSxwhE28SWe0BPPBHYfUP0z3fhspWiO7rL6yzA=; b=bkAK2nDabcwwlLSwRQzq+rgg+91DM/q0KMDwZPms7csA4e/3nrpidFGjZE3ctUl5kB H/m35wnxlT+0+EG8suy8UWhdDBUGl8Kai9bdLaHpPZeIhd/PTcDtQoKspCgxzXt2c124 i32zTHA9xlWfKFqYRqELulG7ayIkLLbzQfUUFMmaYz9ugPfZ8/+tg2HhYoa723ALOaJy h+T9cYNhyN5DSpYSYhhqNZKjlQH2yTN+5GnasXubU1rAn3pGba1XLpU89PMsCZZ3O1q0 8EtLk9ufMZY/7omJjVcJuj+hh5NcVd2mj4rJiv3K4HTh9MFr4lcQpw6xQyLg2x7nDSb0 7KCQ== X-Gm-Message-State: AElRT7FFsstQe4lLpoTceq6+UCciF/2Bydb+A1DuHZhc+cy5GjCgtGhy wqoTN+TCaQkbkjIm7Nx1zFzqWiJW X-Google-Smtp-Source: AG47ELvEEHwelkTNoXneR4eZQC4jFrF+I2Vrwl6pGfqZ4XbkGzZEG0okk0FFvlQg9Z1os7B1ZF4dpA== X-Received: by 2002:a19:4f5d:: with SMTP id a29-v6mr3821778lfk.97.1521046779274; Wed, 14 Mar 2018 09:59:39 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:38 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 20/25] drivers: firmware: psci: Introduce psci_dt_topology_init() Date: Wed, 14 Mar 2018 17:58:30 +0100 Message-Id: <1521046715-30683-21-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> In case the hierarchical layout is used in DT, we want to initialize the corresponding PM domain topology for the CPUs, by using the generic PM domain (aka genpd) infrastructure. At first glance, it may seem feasible to hook into the existing psci_dt_init() function, although because it's called quite early in the boot sequence, allocating the dynamic data structure for a genpd doesn't work. Therefore, let's export a new init function for PSCI, psci_dt_topology_init(), which the ARM machine code should call from a suitable initcall. Succeeding to initialize the PM domain topology, which means at least one instance of a genpd becomes created, allows us to continue to enable the PSCI OS initiated mode for the platform. If everything turns out fine, let's print a message in log to inform the user about the changed mode. In case of any failures, we stick to the default PSCI Platform Coordinated mode. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci.c | 31 +++++++++++++++++++++++++++++++ include/linux/psci.h | 2 ++ 2 files changed, 33 insertions(+) -- 2.7.4 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 463f78c..45d55fc 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -723,6 +723,37 @@ int __init psci_dt_init(void) return ret; } +int __init psci_dt_topology_init(void) +{ + struct device_node *np; + int ret; + + if (!psci_has_osi_support()) + return 0; + + np = of_find_matching_node_and_match(NULL, psci_of_match, NULL); + if (!np) + return -ENODEV; + + /* Initialize the CPU PM domains based on topology described in DT. */ + ret = psci_dt_init_pm_domains(np); + if (ret <= 0) + goto out; + + /* Enable OSI mode. */ + ret = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, + PSCI_1_0_SUSPEND_MODE_OSI, 0, 0); + if (ret) { + pr_info("failed to enable OSI mode: %d\n", ret); + goto out; + } + + pr_info("OSI mode enabled.\n"); +out: + 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 8b1b3b5..298a044 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -53,8 +53,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)