Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp642814pxu; Thu, 26 Nov 2020 07:57:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyL0RpRGkcFQu+I2YHKHh4Plrpip0/X35Z1k+55SasTwapcTai5jmYBfH5fVeOkcsstoh5f X-Received: by 2002:a50:ee97:: with SMTP id f23mr3099498edr.333.1606406240251; Thu, 26 Nov 2020 07:57:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606406240; cv=none; d=google.com; s=arc-20160816; b=K6JgtEeW4xL9bzugLXO5SJqRO+voOof4P+a8UZWjNkIQl++DfskMKGJMseYBhVtrz7 flVa9IULMNyID7b97Kfru255r5rj/zLmtwlHO+NhQuKXMaLYy9TsJmtzOC6IrtPVNOIC 06nn+f57lEa679xMPyBkiRbaR4I+NSSjNY4NBDk05J7TzrrxKN/QJ1KGYf/2DOAoGmNq gFhQd9LuppE6bYvATIHAQeE400lLowxn0HLgIGfQaDlomajpKGxKCwyync80AfLMYw/W eLWAQPATvh0tbw60VATx5DX2agLy/a9BwxauJRq/Wy7XEBpyFCLaLOoHEM4G2PKEXa9c m1lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GRbbAoAyT+twJ6DWAMnVPh0yMfbGrEWPbKn8Cs93LQs=; b=kB8XV3b2brCUAUq1qLvnFxkIWl19Zp6tGiXcVol1sIwcFfMll4gNpFjBexA84hjChj HpHy4ykUk6Ov0eYCn8OPaZv/BfCBLYS9ns2+A/yG+N8sua1uNfQ/wFxoMT48VPfZY/mM 5i9E5XaQ+auFnqvnsMA2fNHAARF+W+3SCLUVj8NXmEgz4OLQQDrrXF84PYkOotaxpsNl LoVuGBe1l4QI68XCPmx2XfAl5tKajmnh/WjGyngeb028YA46InIi+zevNff8rzdvnowf iH/1in840yJVOFVAPN7LNHJH6NU2HvISZMYZd5pVO2U5/E1faPF3hJihOpUCqR+ftIwt +6xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RIxckPoe; 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 n16si3279384ejb.509.2020.11.26.07.56.58; Thu, 26 Nov 2020 07:57:20 -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=RIxckPoe; 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 S2391353AbgKZPyd (ORCPT + 99 others); Thu, 26 Nov 2020 10:54:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391347AbgKZPyc (ORCPT ); Thu, 26 Nov 2020 10:54:32 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AD71C0617A7 for ; Thu, 26 Nov 2020 07:54:32 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id p22so2566314wmg.3 for ; Thu, 26 Nov 2020 07:54:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GRbbAoAyT+twJ6DWAMnVPh0yMfbGrEWPbKn8Cs93LQs=; b=RIxckPoe2SCexeONFtE4DSkvr9AstiWpnehcv0VL5bhqQYEg6F/oOLEITVaQ1YoEfP hGk3BAB/mFs/TVGkOysWFzWL2o2OJ63MAD9vHn6ziIvpoT6iU7Kp+f3yRtPmRLGrK3uL 0deZiq22+yVHN3uu+0OcZirO1XVk48C0r0exGjyDri75/b+No5iT5S4xp4Jb/F2siD20 9mbZCjgyOtXgQaVY+Md/r07NG7gzIABxytKiAfgC6hHFqf47OWj1AJA/CygIdN1Nz3RG QjClGrsnaR32TvHvOZhfrzbfM8Kl2yeEXRKWMhh3KYMG0WT+diIy8djka0sD24s2czFl LSkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GRbbAoAyT+twJ6DWAMnVPh0yMfbGrEWPbKn8Cs93LQs=; b=EtqK9QdN0twbeliZ0QgKWclM7wWb7QQK48nGdspUS9jvDKBdIBmp01Ha7EPO5020FQ Y9AuCc++MYcYOQupz36bQR2K5wWZUgiGe1U9SAwbBMgnj4FS+XUgLmXTGrUiFpzRldqq zRC5ITxRzzEDdOuJc3gr6KxfkTWDDPNVDly2TQNdWIvXeQO8rIuyLE1VkwUaUfxR2c1+ nPB/c4LQ8prPgeFY7ew3FdYhXwMFxnqT2/wnGHS5bJWc59s3lBSp6Gqaq10U5zyBFs80 mCUhWU6PdgC4giELVj7rqpCoqzVssMOXRF/4U8x/PwMa9Cbi1FjTrdlPrPHDtf2uC8I4 6szw== X-Gm-Message-State: AOAM531dFYxywC4GmSnlQnsp3Z7WCUt6TUYm2K79wpkAxIiqpAWNAW33 wAp5UYiq2xRPEMskr8iLkrF2hg== X-Received: by 2002:a1c:31c6:: with SMTP id x189mr4071224wmx.50.1606406070792; Thu, 26 Nov 2020 07:54:30 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:f008:704d:8d4b:9951]) by smtp.gmail.com with ESMTPSA id q1sm9612864wrj.8.2020.11.26.07.54.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Nov 2020 07:54:29 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Cc: Jonathan Corbet , Catalin Marinas , Will Deacon , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Dennis Zhou , Tejun Heo , Christoph Lameter , Mark Rutland , Lorenzo Pieralisi , Sudeep Holla , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, David Brazdil Subject: [PATCH v3 02/23] psci: Accessor for configured PSCI function IDs Date: Thu, 26 Nov 2020 15:54:00 +0000 Message-Id: <20201126155421.14901-3-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201126155421.14901-1-dbrazdil@google.com> References: <20201126155421.14901-1-dbrazdil@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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]; +} + #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