From patchwork Wed Jun 20 17:22:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139387 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050943lji; Wed, 20 Jun 2018 10:23:10 -0700 (PDT) X-Received: by 2002:a2e:5818:: with SMTP id m24-v6mr15283543ljb.84.1529515390112; Wed, 20 Jun 2018 10:23:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515390; cv=none; d=google.com; s=arc-20160816; b=sBYsbpLYuqSryp3cD9kinfCHgjG/OUeWYnERkRrlDybH/sFXgGNwex/OuJrT6TuNMX Np1NWGXt4daY5iBN8tF0Penj9e5N8DX22lTV+FhTZWm9AlqpS+FlTsAvGICcpKlfMWqw YTZhwN1GaLO+KEa7NXEylYgi/x3ywfGWlhd5X2YrFg/jPhJ7C5Y3+3MOwt+dzP3wxYyI dMqkGaUe2ufuYLyXvKIYy0NOW4QWqLxIXHgCT6Kk9vYfGgcqem9R45CwWOVxGKDbgxvc 2ushYMO/Bius/q4AUWfNecKbz5IWRvg//9+FP9JuaMSLrJ+DpIub8fvvPUec34/8UtHz HEUg== 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=7/fxm1AKVizOXQknbpAI2N51c69eELd8rPbu3jzZtbE=; b=db7OlwdaNb2AsHDFCdi0cJ7TPFMkpfrIP26q3CWUcRjVf0139lQHWYiJuN9vPRrOcU TR/qYAmtrcckdQd90SNDbmmze1Mj22FJtioynPmll6vZkMK3hEHzZGWkWXuxNTCOvjqA t1hT+E1luNtL3kYYsJkvYnAI9AdSd072wpKLiqfXSa4j9F/LkVD/my7ou1yxLBdZhO+1 3p4XBOTjTBUG9KKpYm0P+CdpB2bsE8zxS9Y4/sJb78QeCWCIgRpVO32xcXZ12+f3M6LQ cGkjTS/zfwbwPBPH3//EVjl9f2q+gy0VSiJzmufi+Xl/oZhbqJWB8sUeXJ2gJDzHfnvG Ea3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bReuTrLr; 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 n4-v6sor687696ljh.98.2018.06.20.10.23.10 for (Google Transport Security); Wed, 20 Jun 2018 10:23:10 -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=bReuTrLr; 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=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=AmRrdONesOcy9jX7Q8c5oma90swiORelYIThsn1vY83jjSmHXBh98mtAsB4ERE2hfU eup4ugn/dMtMZ+Wm2h//Y5EDlGCOdwQ0qAZ0RO91nf6CTRFIjMzw8tlmo98ZnQY6KI7F v4cq6N9km88iyeTJXqqkvzAkNiYwjuKuhK1HU97Fef2c86wZouxnPc5nAKvNGbSlL64q 24SzbljC6tm6Lx4Ycy+ufm+yz3A3fBxPK78epQc7wNzoqCd2+ROcT0zA5Dg8w2HL64z4 drXfIQ9Win4jv5jJxb92xB+V8COHxGBQlumtDJUeu6GT4Q0ixsw/+nZbkg3/KGrzfw2m 6urw== X-Gm-Message-State: APt69E0GgJjuNl6i2RWIbj7jcbXBnE4T4qQdE7NyZ9ZgnOcm7TXhE2Re 7Ki56VUATlkX5KiOTVuppycgBqDq X-Google-Smtp-Source: ADUXVKIJo2YXgol7hsdEFgWgAY/YBNI7nk8q9PRx07agC9mkR5QY2YZjX/K7yb4J8x3kD2yJFJegrw== X-Received: by 2002:a2e:5c89:: with SMTP id q131-v6mr8812218ljb.77.1529515389928; Wed, 20 Jun 2018 10:23:09 -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 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> 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(-) -- 2.17.1 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; }