Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp849648pxu; Mon, 23 Nov 2020 05:51:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJWokjauIv1czIIPNUJiFSe3LAhEYTHxryE0EKcm1WNbjDwyflghW+gdsUuHouexNQFLi2 X-Received: by 2002:a17:906:4a91:: with SMTP id x17mr5983745eju.126.1606139493100; Mon, 23 Nov 2020 05:51:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606139493; cv=none; d=google.com; s=arc-20160816; b=PI9zcs63ushs3jNEL4rhFU99MSt7bm7BkENicg/b/plUPzdQBYFH3kAhPNf5GqzAku 7MSNsgQIiPm1mUWw1EnmCgV0fZzD61ioxoavXKpyODc/Cst8WyXn9MMsDH0gpV6Gr2ox eokWNRlfzrrxHeC+HHQ7v4khc1EIcm7v40pYLzl76MglVQIznme6eOB45XRLrXCDpMs4 VhOPOiDiAhapbzrr5UWcpUBi0cNfvHoaTYtgDAgwd/ruWo8MSb6N0EIGyJzq23b6FLWu 8RRd2pOjnzSeJOAgl7916bGobxd00UgLgciuPoMk/BZU7m5/e4y7gRL8ensl4dgTTp0c Nx7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=aHGCKgDULPCnv6G7EU180tUiDqcgJSq30li7/BI22bo=; b=nPSKAULgiosUD48fK/d0ZgHeFdPwQlj6DSE9SyVLQh8Awa1jLazgafOWhZXFeCtxQo Hgdf99QZ0eUMfdYUxNOhGAbwJ4UhKgEnPbP3KBPQ0v7DsurCGXG26mtJIXODqi86hfPi qJU8x1Tn63UAe1VFsHSidG6gphsmowrk1f3M5XCp0J5Pr7zxrAT9nMnCPd74gN3RaAiP 7Z79Pk2WYkWUx0XxYMG0wCEGek1UjdltLig3zps+I4TKctyUI/AKiuOEoyykjbVq/mY4 gJrdQoaXVj6D6TX61zuhk/p2YF490qqBr0KVCppzK6JqwkFffyG4XPIeJ/nkFkCNYa4K wJ6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mi0OYwcc; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j90si6877889edc.189.2020.11.23.05.51.08; Mon, 23 Nov 2020 05:51:33 -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=@kernel.org header.s=default header.b=mi0OYwcc; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388217AbgKWNrM (ORCPT + 99 others); Mon, 23 Nov 2020 08:47:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:37064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387562AbgKWNrM (ORCPT ); Mon, 23 Nov 2020 08:47:12 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8103E206F1; Mon, 23 Nov 2020 13:47:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606139231; bh=80Rr48NihEeoN1SyHrOo/D+OnblcJZRgbQGwWtnsfX4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mi0OYwccnn2+NkOQIx3xnpCOr9lsqwjEIp3ELOufhIw5KhxHH3OIpvEMsqAsumuD5 ZAku4nEPbrYRvW8qbZCvw+w1Rb+j0P7X0dGRoyNIXk2l37GjegzO7b7ErZdt9I4gF/ azpRn9+K3f/XOtNGjaZpnuFS1aE4FWYZzCt0RXr8= Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1khCBR-00Cxpa-FP; Mon, 23 Nov 2020 13:47:09 +0000 Date: Mon, 23 Nov 2020 13:47:08 +0000 Message-ID: <87o8jo5go3.wl-maz@kernel.org> From: Marc Zyngier To: David Brazdil Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, James Morse , Julien Thierry , Suzuki K Poulose , Catalin Marinas , Will Deacon , Dennis Zhou , Tejun Heo , Christoph Lameter , Mark Rutland , Lorenzo Pieralisi , Quentin Perret , Andrew Scull , Andrew Walbran , kernel-team@android.com Subject: Re: [PATCH v2 02/24] psci: Accessor for configured PSCI function IDs In-Reply-To: <20201116204318.63987-3-dbrazdil@google.com> References: <20201116204318.63987-1-dbrazdil@google.com> <20201116204318.63987-3-dbrazdil@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: dbrazdil@google.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, dennis@kernel.org, tj@kernel.org, cl@linux.com, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, qperret@google.com, ascull@google.com, qwandor@google.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 16 Nov 2020 20:42:56 +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 | 14 ++++++-------- > include/linux/psci.h | 10 ++++++++++ > 2 files changed, 16 insertions(+), 8 deletions(-) > > diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c > index 213c68418a65..d835f3d8b121 100644 > --- a/drivers/firmware/psci/psci.c > +++ b/drivers/firmware/psci/psci.c > @@ -58,16 +58,14 @@ 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) > +{ > + WARN_ON(fn >= PSCI_FN_MAX); If we are going to warn on something that is out of bounds, maybe we shouldn't perform the access at all? And maybe check for lower bound as well? > + return psci_function_id[fn]; > +} > + > #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.299.gdc1121823c-goog > > Thanks, M. -- Without deviation from the norm, progress is not possible.