From patchwork Wed Mar 14 16:58:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 131686 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410712edg; Wed, 14 Mar 2018 09:59:33 -0700 (PDT) X-Received: by 2002:a19:3bc6:: with SMTP id d67-v6mr4125785lfl.100.1521046773704; Wed, 14 Mar 2018 09:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046773; cv=none; d=google.com; s=arc-20160816; b=UuVodTmvDZEG3cp5AVT8M+V9pAQwAuVv/X8ONYpGQWRjNroQcyzGBy32+tgycEQYO8 Kot6OHEjsylm1yQFRJKwJzWi2XSFnVpmKdrVBeC3oXMjzu+SyxPFXz3DMSunhXUEpZYx tPNzQaYdfXczMYKvhvcCqkt5bYndG3KPzXKNxKTTRkg86efJ3grzHn7C7kxzboVKWy62 AJgwHrP3YeOEkcbhPry+SSH4LVurKVsWolBxiqffbK04ETVrilIXGhJ5ew8chJiKlH7t VjRmgari5yWhEMJjijVGGBc+gLwq8qT2TyccqYnpHRxT4LLIZg1E499EX+wx2mrFphKy dAtw== 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=LqXaA4QDC7qNZSEsWAQva5Zj3IoKB4FK/zAOA1rJ0+g=; b=gA5abVHZnIsMsaIRFoLcUvXAWPTL8B9IYwKJN0di9osh9K97kuXCKar02s5GsuA6TG CDgVUgdMjMcMeZyRTTSRqM8PQEzH99feLyKv3/DSH0nUBHKSQVUl/oa9phrdQIPg7qip mPsR4R21j9g7qWvHjjT2DmrMY2dTly+jyIUfdyo+i7NuFYhg+aB93GKFqiXXMjiYu+P6 28+lypGKHrJ5hgXS9TyekU9AbhW0elzWVp8FPgtM2DfKiywHKeIwgPuQaWamBM54Dhh4 VdKdmN5VkFlB0tZRNV5VzX/Wm8WaJYLqjbiN6+i4hTnltYKYOCoNyCE0ykdnNXYDHRTT 98Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CaeSA93B; 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 q17-v6sor866998lfd.29.2018.03.14.09.59.33 for (Google Transport Security); Wed, 14 Mar 2018 09:59:33 -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=CaeSA93B; 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=LqXaA4QDC7qNZSEsWAQva5Zj3IoKB4FK/zAOA1rJ0+g=; b=CaeSA93BsScWtu8p5IOaQ0fm29LZN5DKKFnYPsr84B2ub3UNz5SeYD84PyLjQWGtCO q0Q+1U6249+40h3L892EwlhuyPANDqdInPcGuqQCdpOityf/7dVyl/2tN+iFJOHQHd5G dikyFyKcKHdmLGhAl3KuZbCck7Xvkm78WNJes= 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=LqXaA4QDC7qNZSEsWAQva5Zj3IoKB4FK/zAOA1rJ0+g=; b=NGulcMb4nlBnSi7dTZHgexHzE+iTNsm+69cU/iC/Sds1ThFNhXpuID0ve/WC5GIorv ystS8BDLfjU2iZLODnweQC1qLmVwFh5cqWITTzKMEwH+tr8D9ij4aDEnwgKqU4401Kjc ekanOD40HV2XhAb6YWUFUoT92BZjjP0ADk4GwDD11vZBp3tYbQvzb3yoh+xmrYCAmsbT x0f003ru4R0tlrIvZOwn2nvl3xsDvTs7AVS1KwY9FoOg7C72wfJXEUwnLQuXsgc7MN73 CPbedCy5PVnofIa6ucbZSkyG72Jb6+SxGl3eINjhPLHn8FJPatVu1Cz0hYKMDJy2eKJ1 DzEw== X-Gm-Message-State: AElRT7HPXJiFPqoibgn2tAWtt0Pu5yW42ehVH74E5VneUM36BVtNdvkp 87EaXYANdcKvI/TneutMsAu35g86 X-Google-Smtp-Source: AG47ELsgpEr+HeYvWnb00y9+Rtp/YotOd6fahqWc/Jart3CXWlZSScHMjYs80FMUIODF9ogAllH0Pw== X-Received: by 2002:a19:d945:: with SMTP id q66-v6mr4136366lfg.62.1521046773371; Wed, 14 Mar 2018 09:59:33 -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.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:32 -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 17/25] drivers: firmware: psci: Prepare to use OS initiated suspend mode Date: Wed, 14 Mar 2018 17:58:27 +0100 Message-Id: <1521046715-30683-18-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> To enable the OS initiated mode, the CPU topology needs to be described using the hierarchical model in DT. When used, the idle state bits for the CPU needs to be created by ORing the bits for CPU's selected idle state with the bits for CPU's PM domain (CPU's cluster) idle state. Let's prepare the PSCI driver to deal with this, via introducing a per CPU variable called domain_state and by adding internal helpers to read/write the value of variable. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index e8f4f84..40b2b89 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -87,8 +87,19 @@ static u32 psci_function_id[PSCI_FN_MAX]; (PSCI_1_0_EXT_POWER_STATE_ID_MASK | \ PSCI_1_0_EXT_POWER_STATE_TYPE_MASK) +static DEFINE_PER_CPU(u32, domain_state); static u32 psci_cpu_suspend_feature; +static inline u32 psci_get_domain_state(void) +{ + return this_cpu_read(domain_state); +} + +static inline void psci_set_domain_state(u32 state) +{ + this_cpu_write(domain_state, state); +} + static inline bool psci_has_ext_power_state(void) { return psci_cpu_suspend_feature & @@ -187,6 +198,8 @@ static int psci_cpu_on(unsigned long cpuid, unsigned long entry_point) fn = psci_function_id[PSCI_FN_CPU_ON]; err = invoke_psci_fn(fn, cpuid, entry_point, 0); + /* Clear the domain state to start fresh. */ + psci_set_domain_state(0); return psci_to_linux_errno(err); } @@ -408,15 +421,17 @@ int psci_cpu_init_idle(unsigned int cpu) static int psci_suspend_finisher(unsigned long index) { u32 *state = __this_cpu_read(psci_power_state); + u32 composite_state = state[index - 1] | psci_get_domain_state(); - return psci_ops.cpu_suspend(state[index - 1], - __pa_symbol(cpu_resume)); + return psci_ops.cpu_suspend(composite_state, __pa_symbol(cpu_resume)); } int psci_cpu_suspend_enter(unsigned long index) { int ret; u32 *state = __this_cpu_read(psci_power_state); + u32 composite_state = state[index - 1] | psci_get_domain_state(); + /* * idle state index 0 corresponds to wfi, should never be called * from the cpu_suspend operations @@ -424,11 +439,14 @@ int psci_cpu_suspend_enter(unsigned long index) if (WARN_ON_ONCE(!index)) return -EINVAL; - if (!psci_power_state_loses_context(state[index - 1])) - ret = psci_ops.cpu_suspend(state[index - 1], 0); + if (!psci_power_state_loses_context(composite_state)) + ret = psci_ops.cpu_suspend(composite_state, 0); else ret = cpu_suspend(index, psci_suspend_finisher); + /* Clear the domain state to start fresh when back from idle. */ + psci_set_domain_state(0); + return ret; }