Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1034687imm; Wed, 20 Jun 2018 10:27:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKkTpFq7EuNmsVgOCwt7dbJdk128mzhbbfImD01hiYLXTnGH1rbYoYTinKAtVpZsZVoSElm X-Received: by 2002:a63:7f15:: with SMTP id a21-v6mr19567600pgd.21.1529515645134; Wed, 20 Jun 2018 10:27:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515645; cv=none; d=google.com; s=arc-20160816; b=WYLjPUbZyvgGq/BR6MkfHAQUwS7vHLzd6SzMkTETyfgRrL8u72usQijAwQMa7/X9QN WzPBFVJCVflLD6470dgbWQcb/EAODhCLEX7OEZttbZGl2VGCCxX1gT1rRvA+qVfwyl2F mvw2jmfptrFLvwmkr47PeUoNuveKiW54Rsd5TdEJag5oNoFyk7V5TvfBmGbu5+PtlzjG lidym1wfmnEJOkNPXgJgPy62EVugVIW+zy6yV2hgBM2OOS+0t1J3uvaTYgA6EJMd/5BW B00NjEEXLkIyOsFLAAIzq8dWND6+xkpFEiraFg2ZGCw8D1uKEmDGP0jv9z2vRoApp77m yh/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=7/fxm1AKVizOXQknbpAI2N51c69eELd8rPbu3jzZtbE=; b=V3p+N+2fgTrDSZ9Vf6ij+S/7YvL5mSWwOJwve0QyhBZV5+eLY4ss/GkyeLXlhr3YoP 0yYJv/5ScqCNc0RpP1GEWgNxg+uCSXeKrPL3JXUy0d7yXW5gYINMH+JmC9JkteQ1EDv1 4L3Gl9CseomUFDuxoOiGFm6t3Uhig+MT0MeTPM2UuZXXs7CWuhVLnywQy9/N4zmb4fPN LdawOYvVfz3j4ah9ISJFxoUftwCV+F1XZNup6oi48CeJwk+iFZ1RW4itV7Vbq8qcYIXg +ekIEOa5G34yhGW87+X+8mxn4eaeHpsqlf3KoBQiJscObcAS1+h/3ItsEB4hxZMh/scq HqrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bReuTrLr; 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 6-v6si2728343pfb.204.2018.06.20.10.27.11; Wed, 20 Jun 2018 10:27:25 -0700 (PDT) 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=bReuTrLr; 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 S932996AbeFTRZJ (ORCPT + 99 others); Wed, 20 Jun 2018 13:25:09 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:34242 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932674AbeFTRXL (ORCPT ); Wed, 20 Jun 2018 13:23:11 -0400 Received: by mail-lf0-f67.google.com with SMTP id e13-v6so504381lfc.1 for ; Wed, 20 Jun 2018 10:23:10 -0700 (PDT) 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=7/fxm1AKVizOXQknbpAI2N51c69eELd8rPbu3jzZtbE=; b=bReuTrLrm8ygiBOgjl6MARfBuQGcn7wxebgSmffuWDknXNqjcktDDJC9JVeFhivxdT Bds9hIiSkFKakweH7n+2MtfsTaIh1XuQx5p1VN54QQ62CpGG7+XvUvZCEtXgZC/hAQeA ALy5UPbu5+NOfj5nA0dHa5W5XwE2Y1VXqAclY= 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=7/fxm1AKVizOXQknbpAI2N51c69eELd8rPbu3jzZtbE=; b=kQOIqdvaPDIJO6xIKrCN8do5HjpEJ6DzReSxIojXKVSlg1topgyHeDRjTpYHNplZTW N1mhefUm1hJRlT+l6t+8cbf3f8NuwPbNsJ+3AK5awhHwz95Dnpkk5AETcUohQPhNYm9e b8+UyILAOgIHKM7ZCEDN+O6yQ1PRzjEIG4tqa8ZNv7h9tLBS0/c3UazKplrA6VfmmNag +qn2TYF3XuDHyV4tSZ/HZZFgcmM/LwvgjJcqZe1eumvUe9HGWKZPk9TF/Z0/Vy4ttswJ dmwBqOR1HlTeLFjGsku+kAKy7Y6W/hpmc90/soSlCALfkbC+4/Cq3UZ3wuALWAvfvZgk HLOw== X-Gm-Message-State: APt69E3ZNU+olCCWEE4X4P/wQQTQbeJXQwFKquNkRhOOGbcF4AhT3KKi hE9hz6DTjpn07tvu5AOIBESKNw== X-Received: by 2002:a2e:5c89:: with SMTP id q131-v6mr8812218ljb.77.1529515389928; Wed, 20 Jun 2018 10:23:09 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id b2-v6sm514441lji.85.2018.06.20.10.23.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:23:09 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , 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 v8 19/26] drivers: firmware: psci: Prepare to use OS initiated suspend mode Date: Wed, 20 Jun 2018 19:22:19 +0200 Message-Id: <20180620172226.15012-20-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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/psci.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index e8f4f8444ff1..40b2b8945018 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/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; } -- 2.17.1