Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp708033pxu; Thu, 26 Nov 2020 09:35:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrW1H2QtOkkOU52+YR0f763AmDSgXOAIF9CuKGojQFFCmQ75uw3uRa/Yc3jhmzI2+FrMG4 X-Received: by 2002:a50:858a:: with SMTP id a10mr3590754edh.190.1606412148293; Thu, 26 Nov 2020 09:35:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606412148; cv=none; d=google.com; s=arc-20160816; b=DsfeRvjFWcV/kYpTx0tw2yZdQPLdYek5E5zYD4XZln8sEgZmRN/Brix2Ael6fin7e0 ho2UZlqQUMZrnssDhYKaeqDC/QJ26xCdgE8MKWO8k6jrIZKlR0uVniEI9BJ4S/Hr4TJe q2kSAOc1oqFc6Y6U1JtUu5B4pEwWV76kwN/VC442PL13c6RFlbnikPKRETIJ1FG+m1yv E+DPZ4WjjEvfyMjpYfbV1L6T1T7/G8u7k+4Jcfo7FHI08NfjG3MHb8miUoZYEm2QLOXZ 8MXVxLwMwv6JjecqxVrGBKXwmEXWT1eLgigZZgvHA/zo9Jua7mXZBbQrjCpsi5smuQ6h vZxg== 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:dkim-signature; bh=eNmmYIntQD41kP5Sy+k/QWgGU3OC7ECA76To2f6sO84=; b=ZCBUu3PNB1oDvCGUIk2EJVczUOILsffnU/Pm7U1rAx0ibJSK3a7Vnf4O+A6B8coukS 2nf12SVBoHeHbcvM6flraQzDOWAhay5eOXe+0LSTOahOf/oVSkACyq3ca6SrvyVm4cF0 aXyFQyjnQh8HoFYzcMe+Ma6aUFHMlXdf/lxUoWS2vQBckCbN7IRfU2sa3ElD5aP0DoFZ IVUgNY8WPCSk61mcYkXr+w4ZZ2O9YmtmY5dOF7J+CKZSs8Wx87D4RRhPOsH3lea6mkBM X7pD+ZVZ1elJLP7Bfd6Q6LqClB+ZM0AergpNVAwx+8JSs7HKkbUpx5yhcchclZ/9GmBA qloA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OTwG7pth; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e18si3593277ejq.261.2020.11.26.09.35.24; Thu, 26 Nov 2020 09:35:48 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=OTwG7pth; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404417AbgKZR3e (ORCPT + 99 others); Thu, 26 Nov 2020 12:29:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404413AbgKZR3e (ORCPT ); Thu, 26 Nov 2020 12:29:34 -0500 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23260C0617A7 for ; Thu, 26 Nov 2020 09:29:34 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id s13so3143833wmh.4 for ; Thu, 26 Nov 2020 09:29:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=eNmmYIntQD41kP5Sy+k/QWgGU3OC7ECA76To2f6sO84=; b=OTwG7pthwmbnQa4O4pEKQm3r7t+DfZH8/A814vskFeIwb1FswL2ou7mn064m+b6JOW ATuWhxu9ybb+JUMtcNuHn9iSPGGKMpNnuEvEaS18eW3zmdEEu55d6WTGi+7xbSMgFQWp EAe58Ogmc6EQdiNxH5da82B8tRgtKqIKsJQ4UgW/7kqj5a6FUqk0iqGtQnHOdRj/rJLI 74XACjmqHWKIsHrhYhyE9sV6/lq+bvG/IH/hWft2e+793kU22Nu/UEN/rrbVQK6wZ+3m fqp/0IH4Z77e15TKRtrkLfcPNbbvcsWtK3G4DfrNsxurhbPDGuxcE766h35FrLx42G5m jhHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=eNmmYIntQD41kP5Sy+k/QWgGU3OC7ECA76To2f6sO84=; b=BmSJXKX3TynnTr1XjA2zJ1cUw1r2wbJ+sC1LnEbFLf4SnNRg6VhzrlQwO6UyRuybgr wqGYpwzRiwcvCI/LEacgFWAgWcj/evHEOqB3/kKrBDkncrRbLrKMVPgz750Gsrx3pkZn 97KVTKdSgdxplP+9kfr5rvLtniETwy39qrA8EnKkJggSUAdrNpmvFr/778V8CC4ZZvqz 31msQvI6f47CRcCvRHLQAvw0wdPnQtnRtW9csXc2v43ufU+D9JQPc/RziQvDvInLViVF 75byKJdbi5c3SZM85ZnOCRflY0gpH7jB57P+uACImKEc+i5yOATXZtsYINPqXU243o0w sb4A== X-Gm-Message-State: AOAM532oo9GWbKDIxLXNa2oN9bA7KuC0hOq8kqcmOo30yAKq8H4lyQkt ReBMwSSaHK2eF+dpnA3Tyism+g== X-Received: by 2002:a7b:c319:: with SMTP id k25mr4627247wmj.65.1606411772607; Thu, 26 Nov 2020 09:29:32 -0800 (PST) Received: from google.com ([2a01:4b00:8523:2d03:4ca8:e54e:96f6:f182]) by smtp.gmail.com with ESMTPSA id c64sm9074091wmd.41.2020.11.26.09.29.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 09:29:31 -0800 (PST) Date: Thu, 26 Nov 2020 17:29:30 +0000 From: David Brazdil To: Mark Rutland 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: <20201126172930.i63yemxpc5r3mqpq@google.com> References: <20201126155421.14901-1-dbrazdil@google.com> <20201126155421.14901-3-dbrazdil@google.com> <20201126172450.GC38486@C02TD0UTHF1T.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201126172450.GC38486@C02TD0UTHF1T.local> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hey Mark, On Thu, Nov 26, 2020 at 05:24:50PM +0000, Mark Rutland wrote: > 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? Sure, sounds easy enough and 2) is in line with how I structured the handlers in KVM. Thanks, David