Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7387894imu; Mon, 3 Dec 2018 12:05:09 -0800 (PST) X-Google-Smtp-Source: AFSGD/W3G8cQz6VW/ziDj9ynZvpT3p52YeUcE8WuHZwV5HiIoIokXMCiP+6JdOmQJebL+SvYaIMj X-Received: by 2002:a62:3006:: with SMTP id w6mr17427811pfw.258.1543867509066; Mon, 03 Dec 2018 12:05:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543867509; cv=none; d=google.com; s=arc-20160816; b=AmRM1qUGleDytdVD6IZhE7Y6rthAo/llNmwTTeFhP1A0Y86wzVcL5Mnj5SfJoNO1O3 lg9wVw9jPQUuP8Ga9F38rOjsvvzprzWiEGCd5yGDryaCqRtRVK/1mkxOfYIgfi8TOxdG eu8/tNM/Ki46tZr+NiwUqDu3EA5K0+Pz/GQg3sLXRfOLfJbi1Oq2VVonq3xYAIUPUZEL JNF7mB0hcDHGgHfB3gTJw+4ojzsR7CQoQV9zp0P17yOscqf72SJJo51+C1CBa80tj0X4 jvQXKAgeNQwIr2pz9z/y0B5zsSZ+iRV1ahOOIe+85hW8rDDMMX7H2Bo70F6CehMKDDIt wphA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=bf+z+8qehLYtJhnusBsqq29RivmbzznY8dlUEsV+e1I=; b=g5zpt1w0MjW3Q0wnFeU1UzVsWd40TETtDqRdB4iMkBzl/ZTgTEJ3+cLmqC4A8hvHSs MK7BTIPzf+PBGJDjKVTD5Z3XiVMgvApBoC+g8STo8wv8nU65xbWHHUdu8jaUGq35aMTt xuoWFMkaWHhASCrlxL9HWMRu2i3KCGu4kbFhvL3pv7oAHBXrVs3N+aKqE44C2uZWqyIq 7jfFRrA203R/wdAYtTEZeugSDoX2Kzoe/vJrEjDD+6oVL/sTKGM+GdeWdMEwmPPXCdee qqKut0BxQT2LD009Ox49kI30LvlMWT9d1D5EdQvXJfozwE+oZWrvSafzMrtlIrIddeil SXbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S9RmZEpB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si14971810plq.138.2018.12.03.12.04.50; Mon, 03 Dec 2018 12:05:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S9RmZEpB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725963AbeLCUEO (ORCPT + 99 others); Mon, 3 Dec 2018 15:04:14 -0500 Received: from mail-vk1-f194.google.com ([209.85.221.194]:45765 "EHLO mail-vk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725903AbeLCUEO (ORCPT ); Mon, 3 Dec 2018 15:04:14 -0500 Received: by mail-vk1-f194.google.com with SMTP id n126so3206661vke.12 for ; Mon, 03 Dec 2018 12:04:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bf+z+8qehLYtJhnusBsqq29RivmbzznY8dlUEsV+e1I=; b=S9RmZEpBZosF5Ig8wF96BidnqcdsnIYuovzaRdhHxyRph1huFrZEa1TLi5Tyr+pyUY n2hI/0rGQlKRABTh3iviTjxzeUdh9CrBQKsmCrmwnaulJlaBLj5Ze2JcOS0HxG0f4KYf LdjQEvr5i3CLXc4Deq1zvigks0gdz4/qrk4rQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bf+z+8qehLYtJhnusBsqq29RivmbzznY8dlUEsV+e1I=; b=FDy37FyUSMf6TfOniiuUPmTtq4UNuiN6sZ+LXCJIu6kBzkB9uSD3dj61+rDDiWIpub dwTHfdLUyB5QVyfteG6FI3wYGC6dQXZ2soF7vYA2jjoG8mulAx4RWKRZY2fLyZPQ0491 bT1zatEi7dyMocdkqG00pcBiJ+r33ybYFmoyRoDs2PiregBC5Ju6fdodxUot3pkW4D9d R7U/zHV2I1F7lcbSOLeJDgXmeY+BKUvKVlRDN5j48UI7x+U06zItsaDUSZ2vnclDP28A yrGUTsfYITVLXjwS7hMCeRxKogT4eqgMWEgSaXdZlAkmfqqm/Cp+DTLny5RDJNVQ+ane 0aPw== X-Gm-Message-State: AA+aEWadmHu57LNFcSrFvds8L8d+eDd3wj4fH08tQhBqWQQRNQC+Nr7v cFqG4jDbLnMRa1Nyd7PExFnPPcAgUcSek/A/UYhQ8Q== X-Received: by 2002:a1f:1881:: with SMTP id 123mr7504408vky.40.1543867451014; Mon, 03 Dec 2018 12:04:11 -0800 (PST) MIME-Version: 1.0 References: <20181129174700.16585-1-ulf.hansson@linaro.org> <20181129174700.16585-19-ulf.hansson@linaro.org> <20181203163717.GN18262@codeaurora.org> In-Reply-To: <20181203163717.GN18262@codeaurora.org> From: Ulf Hansson Date: Mon, 3 Dec 2018 21:03:34 +0100 Message-ID: Subject: Re: [PATCH v10 18/27] drivers: firmware: psci: Add support for PM domains using genpd To: Lina Iyer Cc: "Rafael J. Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , Linux PM , "Raju P.L.S.S.S.N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Linux ARM , linux-arm-msm , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 3 Dec 2018 at 17:37, Lina Iyer wrote: > > On Thu, Nov 29 2018 at 10:49 -0700, Ulf Hansson wrote: > >When the hierarchical CPU topology layout is used in DT, we need to setup > >the corresponding PM domain data structures, as to allow a CPU and a group > >of CPUs to be power managed accordingly. Let's enable this by deploying > >support through the genpd interface. > > > >Additionally, when the OS initiated mode is supported by the PSCI FW, let's > >also parse the domain idle states DT bindings as to make genpd responsible > >for the state selection, when the states are compatible with > >"domain-idle-state". Otherwise, when only Platform Coordinated mode is > >supported, we rely solely on the state selection to be managed through the > >regular cpuidle framework. > > > >If the initialization of the PM domain data structures succeeds and the OS > >initiated mode is supported, we try to switch to it. In case it fails, > >let's fall back into a degraded mode, rather than bailing out and returning > >an error code. > > > >Due to that the OS initiated mode may become enabled, we need to adjust to > >maintain backwards compatibility for a kernel started through a kexec call. > >Do this by explicitly switch to Platform Coordinated mode during boot. > > > >To try to initiate the PM domain data structures, the PSCI driver shall > >call the new function, psci_dt_init_pm_domains(). However, this is done > >from following changes. > > > >Cc: Lina Iyer > >Co-developed-by: Lina Iyer > >Signed-off-by: Ulf Hansson > >--- > > > >Changes in V10: > > - Enable the PM domains to be used for both PC and OSI mode. > > - Fixup error paths. > > - Move the management of kexec started kernels into this patch. > > - Rewrite changelog. > > > >--- > > drivers/firmware/psci/Makefile | 2 +- > > drivers/firmware/psci/psci.c | 7 +- > > drivers/firmware/psci/psci.h | 6 + > > drivers/firmware/psci/psci_pm_domain.c | 262 +++++++++++++++++++++++++ > > 4 files changed, 275 insertions(+), 2 deletions(-) > > create mode 100644 drivers/firmware/psci/psci_pm_domain.c > > > >diff --git a/drivers/firmware/psci/Makefile b/drivers/firmware/psci/Makefile > >index 1956b882470f..ff300f1fec86 100644 > >--- a/drivers/firmware/psci/Makefile > >+++ b/drivers/firmware/psci/Makefile > >@@ -1,4 +1,4 @@ > > # SPDX-License-Identifier: GPL-2.0 > > # > >-obj-$(CONFIG_ARM_PSCI_FW) += psci.o > >+obj-$(CONFIG_ARM_PSCI_FW) += psci.o psci_pm_domain.o > > obj-$(CONFIG_ARM_PSCI_CHECKER) += psci_checker.o > >diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c > >index 623591b541a4..19af2093151b 100644 > >--- a/drivers/firmware/psci/psci.c > >+++ b/drivers/firmware/psci/psci.c > >@@ -704,9 +704,14 @@ static int __init psci_1_0_init(struct device_node *np) > > if (err) > > return err; > > > >- if (psci_has_osi_support()) > >+ if (psci_has_osi_support()) { > > pr_info("OSI mode supported.\n"); > > > >+ /* Make sure we default to PC mode. */ > >+ invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, > >+ PSCI_1_0_SUSPEND_MODE_PC, 0, 0); > >+ } > >+ > > return 0; > > } > > > >diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h > >index 7d9d38fd57e1..8cf6d7206fab 100644 > >--- a/drivers/firmware/psci/psci.h > >+++ b/drivers/firmware/psci/psci.h > >@@ -11,4 +11,10 @@ void psci_set_domain_state(u32 state); > > bool psci_has_osi_support(void); > > int psci_dt_parse_state_node(struct device_node *np, u32 *state); > > > >+#ifdef CONFIG_CPU_IDLE > >+int psci_dt_init_pm_domains(struct device_node *np); > >+#else > >+static inline int psci_dt_init_pm_domains(struct device_node *np) { return 0; } > >+#endif > >+ > > #endif /* __PSCI_H */ > >diff --git a/drivers/firmware/psci/psci_pm_domain.c b/drivers/firmware/psci/psci_pm_domain.c > >new file mode 100644 > >index 000000000000..d0dc38e96f85 > >--- /dev/null > >+++ b/drivers/firmware/psci/psci_pm_domain.c > >@@ -0,0 +1,262 @@ > >+// SPDX-License-Identifier: GPL-2.0 > >+/* > >+ * PM domains for CPUs via genpd - managed by PSCI. > >+ * > >+ * Copyright (C) 2018 Linaro Ltd. > >+ * Author: Ulf Hansson > >+ * > >+ */ > >+ > >+#define pr_fmt(fmt) "psci: " fmt > >+ > >+#include > >+#include > >+#include > >+#include > >+#include > >+ > >+#include "psci.h" > >+ > >+#ifdef CONFIG_CPU_IDLE > >+ > >+struct psci_pd_provider { > >+ struct list_head link; > >+ struct device_node *node; > >+}; > >+ > >+static LIST_HEAD(psci_pd_providers); > >+static bool osi_mode_enabled; > >+ > >+static int psci_pd_power_off(struct generic_pm_domain *pd) > >+{ > >+ struct genpd_power_state *state = &pd->states[pd->state_idx]; > >+ u32 *pd_state; > >+ u32 composite_pd_state; > >+ > >+ /* If we have failed to enable OSI mode, then abort power off. */ > >+ if (psci_has_osi_support() && !osi_mode_enabled) > >+ return -EBUSY; > >+ > >+ if (!state->data) > >+ return 0; > >+ > >+ /* When OSI mode is enabled, set the corresponding domain state. */ > >+ pd_state = state->data; > >+ composite_pd_state = *pd_state | psci_get_domain_state(); > This should not be needed. The domain_state should be 0x0 being set > after coming out of idle. > >+ psci_set_domain_state(composite_pd_state); > The three lines can be summarized as: > psci_set_domain_state(*state->data); Sure, let me change accordingly and thanks for spotting this! Kind regards Uffe