Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1242245imu; Thu, 20 Dec 2018 12:41:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/WyA5mLmYJGXX1w6sf2bn4fkv3F+n/RSC0RTpxnOdF+ygSuNeoaKYNv9ovA/sMmFhIx/JEi X-Received: by 2002:a63:4611:: with SMTP id t17mr7865603pga.119.1545338492540; Thu, 20 Dec 2018 12:41:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545338492; cv=none; d=google.com; s=arc-20160816; b=dn+GINME+H79Wy8bE1FOu4Ur5ao9u9mwALP8NFmWuw7lhgwHHTeVyzHPJJm+hZy+2Z yVBNVlfRqZezUKQ0/4CWpBUvBKDKDjYpkCxXgNUfNxsv/CofinJqDODz4mUOcijjZ2T1 DCeYk/QRVkhjP5nCygP6WgCjzn+RHQHUUrzW7XAPsE6Lgn6u8WZuThfWds+HCPNK9KW6 XHk8GpvlWUl8WHlXODGW2qJIdiSGPi3VIHP8GM7DKFMJHlM8slVM3IqrVqVIWoA94u+E SeQnWas62dwh2Ir0xAFIKVIn9uMax/8ZZQnWIBR6g3opqSQTUK9mWC7+EuBDs6cykWaK Yhhg== 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=Hq5fNvnqcKLZYKprqkFMFjWqTZS/AiLTdVGUsHsuR8c=; b=XGGDeiHF126FdFI3xrQIcZZcFb+iiAlaJ79GDpr1YHAdAwTmtxn9H4oLGv0G66JESe dBjY2PCr7Hzg9LaSJ+XchwXNlEPvFer1AACDW2eymHdI7LxjPTm+FXIMORKemkpDJRlq AYc3HZy5KIfI+C/gW8XZSQWBkYn3Yzrwqlt5LsFvqZDbhFR/zd3y2Qvh0/8KG2NocrKr JXIavZ08VimhZ0mdh4uSRF0xSrTQtCnAmlJztupWwK8FkA7vhIEmJCBzRovxvnC9kPjT 2NiECFN1ALoFNDC+mY5+DDrLDhOfIYu5Z4Di7/GijpapujxUPzRYJyscbNTXWTbFDek8 vOUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aEnARfrR; 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 p11si18482380plo.363.2018.12.20.12.41.16; Thu, 20 Dec 2018 12:41:32 -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=aEnARfrR; 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 S1732817AbeLTOT3 (ORCPT + 99 others); Thu, 20 Dec 2018 09:19:29 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36858 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731279AbeLTOT2 (ORCPT ); Thu, 20 Dec 2018 09:19:28 -0500 Received: by mail-wr1-f65.google.com with SMTP id u4so1947954wrp.3 for ; Thu, 20 Dec 2018 06:19:26 -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=Hq5fNvnqcKLZYKprqkFMFjWqTZS/AiLTdVGUsHsuR8c=; b=aEnARfrRojPdKsQyHVTrmsOAbJWqTAaLrlOEb8nUgjsrKcHOoFWwyr7SeEIQumz11d 0ibw4KZA/OD+/YQHPY4ZROW9oMUT0cPGR2AnMm1e85Cd/jjSp+Hbq/qp7xJE6Mr5ynyd tSO1CgMX6RSlXUUvn+cgzvzH9xT76fFJKDHwA= 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=Hq5fNvnqcKLZYKprqkFMFjWqTZS/AiLTdVGUsHsuR8c=; b=oGfZMGIOXZLUc69mLFY8TYQlS3Vz3X505WaAttvK6mPY5RoOrT6BXoidRcToInHK92 jlC4hvaQiUQNyhxvQTwtA1KkikHUmkUIPyoPPCPcuWxBXjPBwKS9wJIINpHq7jRQT+Ah yBCcjzToM733q8qtca8Io+VDIVHL7vl5aYejay5yayef/bQTS6DAEH5pylfzqx/99jcR mhihKVnELM7kcJycG1ODAvzabKcoHpBZ5wUYxemrKpglxzcHtDhQO9T8N9kjOB9/IGLM YzuFRS5qghU6dvq6G7WDOWn1RpBq5AVDIEsby5FDdsxLULtkXt4/Wtp2AodTSPj39sTK vLUA== X-Gm-Message-State: AA+aEWaDr3lmGAEXtN3aSPBSIfbLpAxqJkou1BnztHnqe+rHYxLVKgmt Kd4OiKqJ1qNUOW8W72gOzdAarDRJMkY= X-Received: by 2002:adf:ce02:: with SMTP id p2mr24704743wrn.185.1545315565566; Thu, 20 Dec 2018 06:19:25 -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 h129sm18428162wma.0.2018.12.20.06.19.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 06:19:24 -0800 (PST) Subject: Re: [PATCH v10 17/27] drivers: firmware: psci: Prepare to support PM domains 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-18-ulf.hansson@linaro.org> From: Daniel Lezcano Message-ID: Date: Thu, 20 Dec 2018 15:19:23 +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-18-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: > Following changes are about to implement support for PM domains to PSCI. > Those changes are mainly going to be implemented in a new separate file, > hence a couple of the internal PSCI functions needs to be shared to be > accessible. So, let's do that via adding new PSCI header file. > > Moreover, the changes deploying support for PM domains, needs to be able to > switch the PSCI FW into the OS initiated mode. For that reason, let's add a > new function that deals with this and share it via the new PSCI header > file. > > Signed-off-by: Ulf Hansson > --- > > Changes in v10: > - New patch. Re-places the earlier patch: "drivers: firmware: psci: > Share a few internal PSCI functions". > > --- > drivers/firmware/psci/psci.c | 28 +++++++++++++++++++++------- > drivers/firmware/psci/psci.h | 14 ++++++++++++++ > 2 files changed, 35 insertions(+), 7 deletions(-) > create mode 100644 drivers/firmware/psci/psci.h > > diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c > index 8dbcdecc2ae4..623591b541a4 100644 > --- a/drivers/firmware/psci/psci.c > +++ b/drivers/firmware/psci/psci.c > @@ -34,6 +34,8 @@ > #include > #include > > +#include "psci.h" > + > /* > * While a 64-bit OS can make calls with SMC32 calling conventions, for some > * calls it is necessary to use SMC64 to pass or return 64-bit values. > @@ -90,23 +92,35 @@ static u32 psci_function_id[PSCI_FN_MAX]; > static DEFINE_PER_CPU(u32, domain_state); > static u32 psci_cpu_suspend_feature; > > -static inline u32 psci_get_domain_state(void) > +u32 psci_get_domain_state(void) > { > return __this_cpu_read(domain_state); > } > > -static inline void psci_set_domain_state(u32 state) > +void psci_set_domain_state(u32 state) > { > __this_cpu_write(domain_state, state); > } > > +bool psci_set_osi_mode(void) > +{ > + int ret; > + > + ret = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, > + PSCI_1_0_SUSPEND_MODE_OSI, 0, 0); > + if (ret) > + pr_warn("failed to enable OSI mode: %d\n", ret); > + > + return !ret; > +} Please keep the convention with the error code (0 => success) In the next patch it can be called: if (psci_has_osi_support()) osi_mode_enabled = psci_set_osi_mode() ? false : true; > + > static inline bool psci_has_ext_power_state(void) > { > return psci_cpu_suspend_feature & > PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK; > } > > -static inline bool psci_has_osi_support(void) > +bool psci_has_osi_support(void) > { > return psci_cpu_suspend_feature & PSCI_1_0_OS_INITIATED; > } > @@ -285,10 +299,7 @@ static int __init psci_features(u32 psci_func_id) > psci_func_id, 0, 0); > } > > -#ifdef CONFIG_CPU_IDLE > -static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); > - > -static int psci_dt_parse_state_node(struct device_node *np, u32 *state) > +int psci_dt_parse_state_node(struct device_node *np, u32 *state) > { > int err = of_property_read_u32(np, "arm,psci-suspend-param", state); > > @@ -305,6 +316,9 @@ static int psci_dt_parse_state_node(struct device_node *np, u32 *state) > return 0; > } > > +#ifdef CONFIG_CPU_IDLE It would be nicer if you can remove the CONFIG_CPU_IDLE by replacing it with a specific one (eg. CONFIG_PSCI_IDLE) and make it depend on CONFIG_CPU_IDLE, so the config options stay contained in their respective subsystems directory. > +static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); > + > static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, > struct device_node *cpu_node, int cpu) > { > diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h > new file mode 100644 > index 000000000000..7d9d38fd57e1 > --- /dev/null > +++ b/drivers/firmware/psci/psci.h > @@ -0,0 +1,14 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > + > +#ifndef __PSCI_H > +#define __PSCI_H > + > +struct device_node; > + > +bool psci_set_osi_mode(void); > +u32 psci_get_domain_state(void); > +void psci_set_domain_state(u32 state); > +bool psci_has_osi_support(void); > +int psci_dt_parse_state_node(struct device_node *np, u32 *state); > + > +#endif /* __PSCI_H */ > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog