Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1242074imu; Thu, 20 Dec 2018 12:41:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/WEXtFnmvkgPHV+nWj0wWWsQPU7ju37D561Qp3eT9aDotr8n9dlb7Xw/qMUrRDoXdJjOyx+ X-Received: by 2002:a63:62c4:: with SMTP id w187mr19332125pgb.230.1545338480038; Thu, 20 Dec 2018 12:41:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545338480; cv=none; d=google.com; s=arc-20160816; b=Y6zJn4NA18DPow4nkWiaHqVNqD9P05vMcD3BZuwPsuid5vt5zfCmCVutzc5uXwcyk9 XVm7MoanpCog9RdsVhK+ek2kXcAvCBfWY79Hk+wD9NZiiaNdkqLp8mZCzKbidnMMOlYh 3+ofuOXQspbwZK66Mc134bZmzHCZAI1k5GLcS29hiJfogam/+NOx9pxPi3EIjd47i1U8 N0Clxw3GmFJeDCUSREhr8+i9vtlYCnqL+RFFHDp9i9H00XLFB7evqDA/mc4LiQeXjstH gUQ7o6FjkIpIkfBoj3fuKbRzePHx7Ug4xGSLcG2B3vvEMrQUdmtjDwNrJBzMV6/n2ucj S4Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=MXCduRLidV5Y2s88Gyg/N4BgSVPqPJlaFtjfZoolwFI=; b=bf9VxZulUK+rVqlTJDNMgVLOMakhdtAkttiu9uaia826lLEJcyIGR8rLahCv5cqhzG iPohVZlmOXtf0BJUCZUtjYL5bcQfgKIrkkhVVnQj43XKeMLSsKrd55GWoVTDHfhg2IwI zJGQA/9ocXPOzacOWY2RMF2zaOzonqEnZ7wpexdz36kSXeVwhNjjIpu5ZwB2mhsDi+l0 wkkotC9lCId1QurSS66KA4jB/Z8r10bQEKc6CvPudCBoLbgB7ZyLsz5mBqyXCYnIs+w5 /D3BPM86ijzv64tQ+D36gKh53b1l7VH8JUnQ3vLGkS0q/Ly0kxnfEveuJCPngADkaXng VSXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OAt5atSd; 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 v34si19138348plg.205.2018.12.20.12.41.04; Thu, 20 Dec 2018 12:41:19 -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=OAt5atSd; 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 S1733175AbeLTOJF (ORCPT + 99 others); Thu, 20 Dec 2018 09:09:05 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43337 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731255AbeLTOJE (ORCPT ); Thu, 20 Dec 2018 09:09:04 -0500 Received: by mail-wr1-f65.google.com with SMTP id r10so1897129wrs.10 for ; Thu, 20 Dec 2018 06:09:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=MXCduRLidV5Y2s88Gyg/N4BgSVPqPJlaFtjfZoolwFI=; b=OAt5atSd5KMTOh+hCSw3lA8Vm1wj2zZPhIuXG3JC6DUfIw9JUEo+wUF0yRm4k6UKI1 PwGV9lU1Sb4sdg1g2lK1AugYY5l+/UXO/+i1YCMMcRvcrGWVzEieae2kYF7tlGBmT6ZU q5XNVY9yCn0YyOyux//IJPou4zxCN9TDqwpJU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=MXCduRLidV5Y2s88Gyg/N4BgSVPqPJlaFtjfZoolwFI=; b=d12UfyOmd9TkNkTnEKR1w/Re+Vyg5M99Sr6t3bRtPLaLURRiWaR5OBVehZHAtRrqhh Wx2lBiGvI43g1W/I5lb6FJpYUNgrWPoj1GsIlqENW8GbLx3BAO92IHWkVeAk9nJfODte Aqp9Em7AEhwPKz8KOC7pGUucIFShGerQJeznTRQV11tMuJX+EKpe6rNRkd4AanizGXTq nRfBPvv/XGp72z5ruf+cngsIVs4C0q7OUveK8cSN1fSMQqsQfsfCRsf3duuRBBz/EXM0 4Pc+MGFHxsblXuzAx+x7jozAbifR7OuD8zKaRMJBxyuHcEg7/rkw9rRZhr3pu/8D7VCn XvYw== X-Gm-Message-State: AA+aEWakgHZlGmrYLfAydsH2FaMDjuDZGwLb7hQOmCv/P3sBUM2u4+DL DVdgPKNduiIc8lfJ70L3yJa94GN0mLo= X-Received: by 2002:adf:900f:: with SMTP id h15mr22696475wrh.18.1545314941239; Thu, 20 Dec 2018 06:09:01 -0800 (PST) Received: from [192.168.0.40] (55.183.88.92.rev.sfr.net. [92.88.183.55]) by smtp.googlemail.com with ESMTPSA id c15sm1207011wml.27.2018.12.20.06.08.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 06:09:00 -0800 (PST) Subject: Re: [PATCH v10 16/27] drivers: firmware: psci: Prepare to use OS initiated suspend mode To: Ulf Hansson , "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20181129174700.16585-1-ulf.hansson@linaro.org> <20181129174700.16585-17-ulf.hansson@linaro.org> From: Daniel Lezcano Message-ID: <20e1c04b-870f-3213-835d-28724ef4f530@linaro.org> Date: Thu, 20 Dec 2018 15:08:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181129174700.16585-17-ulf.hansson@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/11/2018 18:46, Ulf Hansson wrote: > 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 are created by ORing the bits for PM domain's 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 the variable. What are the domain states ? What values can they have ? > Cc: Lina Iyer > Co-developed-by: Lina Iyer > Signed-off-by: Ulf Hansson > --- > > Changes in v10: > - Use __this_cpu_read|write() rather than this_cpu_read|write(). > > --- > 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 4f0cbc95e41b..8dbcdecc2ae4 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); I think this change is ambiguous: - if it is a change of the state because of the cpu_on, then I was expecting a similar change in cpu_off and the change only if invoke_psci_fn() succeeds. - if it is a change to take opportunity of the code path to initialize the domain state, I suggest to remove it from there and make it very explicit with static DEFINE_PER_CPU(u32, domain_state) = { 0 }; > } > > @@ -409,15 +422,17 @@ int psci_cpu_init_idle(struct cpuidle_driver *drv, 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 > @@ -425,11 +440,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; > } > > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog