Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1056304imu; Thu, 20 Dec 2018 09:22:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/V7mDn/Cl5CbPN06y6RWgMJoM6NpsRSv1BsZWpinjODlNwSjVO0V4UP3s3LlPB8XvvmnKv5 X-Received: by 2002:a62:62c5:: with SMTP id w188mr25409281pfb.160.1545326571678; Thu, 20 Dec 2018 09:22:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545326571; cv=none; d=google.com; s=arc-20160816; b=r5HsOcH0AfNYZ/88aR3OnAjvHDyrSdNyj77GgAjdEEVEpns7V+K0NG84dSSFKjs6vK sZOyqavYTN5w3o70g0UQ94cpk1CC2H09v0PkTjqAfBulrAuH6fDF1f6rDYuWE4enYO0F lS0X9DCZB9IqmweVWixdrnATtxUt2PUbvziLObRonHxYmu1dfnrtKOr+e93rO0MOSM93 RufI7Y9FUpJwKTk76e/nOkPbBtx7ewV4T/S5w0h3U0iKFNSK3e7bfSWFwVb6x0GojoEc Mo+57QTqp5QQ0VZdTydfPpYyeKsMKNuvSyJyiWI4r1I5vWnl+OXFzuc+MwyLh+K7m2nF dynw== 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=hSPuEWRRK7wMhu9OfMbHsNDR/FeXcaBZmoLhSCUdMRs=; b=jhKJaOApmHfAIkrOG3Slx/b0jqPww1d1tRlIFFuiRxfsqHamXIoT6+oFrn/pP/ZZx3 qQ9/URvAo26xnfgNuTQvMT9fooNqgkTbeWhwWBHz+OmVH/g9wfmXdRLPCoLpseZtFegd /syY939KpGFRjo8LlbjX4GgRsP7xQd6UpfRMEUQFTsudHHs1wMCRfsUkMIXElVNM/I5v nnUHacXVA0UOXOm1YMNuvQvuHNBNNXB4VfXGdAYCgPmXXnnaBYuh9gOAay3+OY/tsvGw 3LPkZNnDJpB2qtzFhF4apNlVNtb4vBc2vI6At7yHjfrre7Q/oYThd0wCx/dNJHEcGO1W MiNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OumhfZUk; 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 197si125916pgb.564.2018.12.20.09.22.36; Thu, 20 Dec 2018 09:22:51 -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=OumhfZUk; 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 S2387741AbeLTRQs (ORCPT + 99 others); Thu, 20 Dec 2018 12:16:48 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:38148 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732885AbeLTRQs (ORCPT ); Thu, 20 Dec 2018 12:16:48 -0500 Received: by mail-wr1-f67.google.com with SMTP id v13so2562703wrw.5 for ; Thu, 20 Dec 2018 09:16:46 -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=hSPuEWRRK7wMhu9OfMbHsNDR/FeXcaBZmoLhSCUdMRs=; b=OumhfZUkI/U0KQevVpk3cMXgzj5YsX8TR7OYR4S4/L8vudzJ4rsoT0Kz6uG1MhPmy7 2kLJWgPV4opvutrosIuL9SLIy/zR9txHWAR8peb7+v8VyYjD0QfQojKY8eVv7DzETQy7 vAVPgLwyJwKtEggfm0B51PoclvvQmGRJPxBiE= 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=hSPuEWRRK7wMhu9OfMbHsNDR/FeXcaBZmoLhSCUdMRs=; b=HUT5tFq5UN3jAifzAXEGJ6tTumugpDpTaER9sgKFkxz9n03nzpVaDE1uSMgf7oueym MGj/2xyHjCtIF0Y98LWjt2Alg2ejwgnC9F/eYBDUyqt+Ww/hN/yVRU/RtLD6rv598fn8 0S9fSNHhlRlBSBTu7Ie+U/q7M+7IwMj26VGzjn5jcaRm4JcTWoVkiaUGVUWZJjel9K98 1dzdkl1F8EAXq2uLFHe6wA5LWUjeGLGltnHuAq130wGxSwy0OR1hwkS58Eq/p7t8UY+h 2VKiiMqGZms/aCaldXbiBOqHmu6cZ5q9jAPzk5CeObPLJj4myXhVtabA6iuVOa/81o+5 DY3Q== X-Gm-Message-State: AA+aEWbOc/xrRS51FSFw9NkE0qTfzni3X6LD8dMbkfSkoYgKBnPIqziQ iffR4b2rY854/kKJWOZxPHG9ec4qPJI= X-Received: by 2002:adf:e78f:: with SMTP id n15mr24059134wrm.115.1545326205755; Thu, 20 Dec 2018 09:16:45 -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 v132sm8379247wme.20.2018.12.20.09.16.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 09:16:44 -0800 (PST) Subject: Re: [PATCH v10 16/27] drivers: firmware: psci: Prepare to use OS initiated suspend mode To: Ulf Hansson Cc: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Linux PM , "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Linux ARM , linux-arm-msm , Linux Kernel Mailing List References: <20181129174700.16585-1-ulf.hansson@linaro.org> <20181129174700.16585-17-ulf.hansson@linaro.org> <20e1c04b-870f-3213-835d-28724ef4f530@linaro.org> From: Daniel Lezcano Message-ID: Date: Thu, 20 Dec 2018 18:16:43 +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: 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 20/12/2018 16:41, Ulf Hansson wrote: > On Thu, 20 Dec 2018 at 15:09, Daniel Lezcano wrote: >> >> 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 ? > > The existing psci_power_state, also defined as a per cpu variable, > contains fixed values reflecting the corresponding > arm,psci-suspend-param for the idle state in question. > > This isn't sufficient, when using the hierarchical CPU topology in DT > and when OSI mode is supported, because of the way we vote with the > PSCI CPU suspend parameter. Parts of this parameter shall inform about > what state to allow for the cluster, while other parts tells the state > for the CPU. > > The new "domain states" per CPU variable, gets dynamically changed > when actively used by following patches that implements the PSCI PM > domain support. Depending on what state the PM domain picks, the genpd > ->power_off() callback sets a new "domain states" value, reflecting > the state for the cluster. > > Does it makes sense? If you like, I can try to update the changelog to > clarify this? Yes, it makes sense. May be give a pointer or an information about the parameter encoding in addition to the description above can help. >>> 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. > > You are right. This rather belongs to patch 24, as its intent is to > deal with CPU hotplug. > >> >> - 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 }; > > We shouldn't need to explicitly set static variables to zero, as that > should be managed by the compiler. Yeah, that was the purpose of the *very explicit* words, that is tell the reader, the initialization relies on the static variables being set to zero. > Let me simply remove the call to psci_set_domain_state(0) and instead > consider it for patch 24. Yes, sure. -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog