Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1154422pxu; Fri, 27 Nov 2020 00:38:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJzy1tiVw1OUCJYet0xsBCovOrpZULQ4C1hch5lF4bD5aY3CBDv2EdAAQav93UIzn9JjRKmW X-Received: by 2002:a05:6402:144b:: with SMTP id d11mr6279030edx.195.1606466315425; Fri, 27 Nov 2020 00:38:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606466315; cv=none; d=google.com; s=arc-20160816; b=a8zwlLtnFIOeL74bd8xpbc2V4xVzoPgCfKdlwaAbwFtWizWK3gJqDraiFm3+alz5Xe Y6yvS+YvVWcfx1bhXH6hORHyIme3brbqNYvRvOq+MrpXQDfADqhnrcPrlGUdOQngLBdT qS1B+ZrA/MNBD2eredYD6ZQ7Mf+9uqW1crBtWdwLo24HIyQ3mPK/LF5HzdHy6TvK7gHS xZDoGmMcteGH51g0kZM1Ysoo6qoe51QBMGg/cGe9mrCRdP+jur/7Z4faPEREou5RYBXY MoMxE2XOvVvEOaq9EGrNMpSNyeArF62z9lBDb++9mAH0eQwTfHE7V6Lza+RQXGvYGtVG Vs7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=AvNjNq8xEo8Yj77qKRAhhyr7DTydehzRDMyCoYjERHU=; b=UCcucA7M3bq1fgsz5f78HUuDbvcgJWfcPhuJMKY7ag3DTFLpPwL18j3Ne62qhmtS2M Y+Lq+uVud0VwQKXO8L32Lx6vsPjM+5Vn9ylCPjxBqT+neMB0QOmsr6i+YqNXhKzatKtZ 6QiJ48T2Pc+EYedRCfYSS/ndY+TOiYh8JIlmY9NQllDF8c3sMm/to+iiXTMHvAEIVWbX TK1lwkXYQijduD/ggY1Y/gstlEd0rOFdtxS8zcgrQ/OSlIR/2+FHJPPWn9Mycwbbi7Wm hx3G1h7QpiDGhH9DMjxyTHC7bb25OvhFtag/VcEPGMkKEoWViJMQOmxbM7cvYiVi7sdL hRlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w10si4634227edj.71.2020.11.27.00.38.12; Fri, 27 Nov 2020 00:38:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404192AbgKZRY5 (ORCPT + 99 others); Thu, 26 Nov 2020 12:24:57 -0500 Received: from foss.arm.com ([217.140.110.172]:41232 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726677AbgKZRY5 (ORCPT ); Thu, 26 Nov 2020 12:24:57 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AF47031B; Thu, 26 Nov 2020 09:24:56 -0800 (PST) Received: from C02TD0UTHF1T.local (unknown [10.57.30.234]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 350C13F23F; Thu, 26 Nov 2020 09:24:53 -0800 (PST) Date: Thu, 26 Nov 2020 17:24:50 +0000 From: Mark Rutland To: David Brazdil Cc: kvmarm@lists.cs.columbia.edu, Jonathan Corbet , Catalin Marinas , Will Deacon , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Dennis Zhou , Tejun Heo , Christoph Lameter , Lorenzo Pieralisi , Sudeep Holla , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com Subject: Re: [PATCH v3 02/23] psci: Accessor for configured PSCI function IDs Message-ID: <20201126172450.GC38486@C02TD0UTHF1T.local> References: <20201126155421.14901-1-dbrazdil@google.com> <20201126155421.14901-3-dbrazdil@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201126155421.14901-3-dbrazdil@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 26, 2020 at 03:54:00PM +0000, David Brazdil wrote: > Function IDs used by PSCI are configurable for v0.1 via DT/APCI. If the > host is using PSCI v0.1, KVM's host PSCI proxy needs to use the same IDs. > Expose the array holding the information with a read-only accessor. > > Signed-off-by: David Brazdil > --- > drivers/firmware/psci/psci.c | 16 ++++++++-------- > include/linux/psci.h | 10 ++++++++++ > 2 files changed, 18 insertions(+), 8 deletions(-) > > diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c > index 213c68418a65..40609564595e 100644 > --- a/drivers/firmware/psci/psci.c > +++ b/drivers/firmware/psci/psci.c > @@ -58,16 +58,16 @@ typedef unsigned long (psci_fn)(unsigned long, unsigned long, > unsigned long, unsigned long); > static psci_fn *invoke_psci_fn; > > -enum psci_function { > - PSCI_FN_CPU_SUSPEND, > - PSCI_FN_CPU_ON, > - PSCI_FN_CPU_OFF, > - PSCI_FN_MIGRATE, > - PSCI_FN_MAX, > -}; > - > static u32 psci_function_id[PSCI_FN_MAX]; > > +u32 psci_get_function_id(enum psci_function fn) > +{ > + if (WARN_ON_ONCE(fn < 0 || fn >= PSCI_FN_MAX)) > + return 0; > + > + return psci_function_id[fn]; > +} I'd really like if we could namespace this with a psci_0_1_* prefix before we expose it outside of the PSCI code. I appreciate that's a larger change, but I reckon we only need a couple of new patches: 1) Split the ops which consume the FN ids into separate psci_0_1_*() and psci_0_2_*() variants, with a common __psci_*() helper that takes the function ID as an argument. The 0_1 variants would read the function ID from a variable, and the 0_2 variants would hard-code the id. 2) Replace the psci_function_id array with: struct psci_0_1_function_ids { u32 suspend; u32 cpu_on; u32 cpu_off; u32 migrate; }; ... and remove enum psci_function entirely. 3) Add a helper which returns the entire psci_0_1_function_ids struct in one go. No warnings necessary. Does that sound OK to you? Thanks, Mark. > + > #define PSCI_0_2_POWER_STATE_MASK \ > (PSCI_0_2_POWER_STATE_ID_MASK | \ > PSCI_0_2_POWER_STATE_TYPE_MASK | \ > diff --git a/include/linux/psci.h b/include/linux/psci.h > index 2a1bfb890e58..5b49a5c82d6f 100644 > --- a/include/linux/psci.h > +++ b/include/linux/psci.h > @@ -21,6 +21,16 @@ bool psci_power_state_is_valid(u32 state); > int psci_set_osi_mode(bool enable); > bool psci_has_osi_support(void); > > +enum psci_function { > + PSCI_FN_CPU_SUSPEND, > + PSCI_FN_CPU_ON, > + PSCI_FN_CPU_OFF, > + PSCI_FN_MIGRATE, > + PSCI_FN_MAX, > +}; > + > +u32 psci_get_function_id(enum psci_function fn); > + > struct psci_operations { > u32 (*get_version)(void); > int (*cpu_suspend)(u32 state, unsigned long entry_point); > -- > 2.29.2.454.gaff20da3a2-goog >