Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4913007ybl; Mon, 9 Dec 2019 19:41:35 -0800 (PST) X-Google-Smtp-Source: APXvYqzJktJC5XwarVikTjjcPGopwrq87YqxEWB9/m6n6YH0fxNazLmKlfRs0ebrnE6ddVCWC1Rq X-Received: by 2002:aca:4a41:: with SMTP id x62mr2211744oia.148.1575949295430; Mon, 09 Dec 2019 19:41:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575949295; cv=none; d=google.com; s=arc-20160816; b=oFxygxKr/Xx9aZI1k+V9Q14nj6Pg4PEohLAS+DTNkRC1l5VKiku+AzD4O3i/pquuYd KLRXf5+xWmXxlT+noLQxYfXcG9GmwfK4w3Lv+bWWu+ZbLWTji0qR28XjPNFQvaZQySOo xpNDnAGN3Zp6DhIKBF4HAAgtonxf/PmVPBP4x6hbF3woMoN4HCyZys2QBuh+w1mUQyu0 DRbDzGMGC+S9adVcxtGrgF1gOFONkuCGE962qtAMXR1QnExU9CAVVpHb7IXgpoS+sPZj cDBFr2xbfhTpmjK9HJYxA08P1LTgcPei08ZV7Ca5e0im5Asr/2ZzP+iMjCvwR34DFNB6 UK0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=q0+UEjuXl6w4ag7uFIrQR1sKOwmkgpNuqOWNyxco3F0=; b=lGE0S7K84Oe5O8tkrZiZxacyKfoF+qHSfG6MLFPftnTP2V3GvzK1gfHqCvZCBrJs3b sg8OjBJe9epPmAOH4zKPD7+1x9fG92QlZT1jMxOAKFY/O3jozEt433YojC1ZWC7AzPW0 gJbRgaeRPGgjs2VEoKBNP0AM7zJnXOoKbRkUJmDpLDsdcE6eL6rY4rlGj8xKxHNsjC2O rwTQf21k1bLhmeEfv3SBNrGxoIEdyI9IGq2UJwsFsKu1GJLGZ4hKptLVm/tBKaQt+1N6 QrOMj9wgWtHz3aIUpSFFnR+pxpiDCUf9HfXtGymvPAPLm4+qePBpXzWvpWXug+UYqKew +tDQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si1251934oic.72.2019.12.09.19.41.21; Mon, 09 Dec 2019 19:41:35 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726971AbfLJDkr (ORCPT + 99 others); Mon, 9 Dec 2019 22:40:47 -0500 Received: from foss.arm.com ([217.140.110.172]:55832 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726623AbfLJDkq (ORCPT ); Mon, 9 Dec 2019 22:40:46 -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 848601045; Mon, 9 Dec 2019 19:40:45 -0800 (PST) Received: from entos-d05.shanghai.arm.com (entos-d05.shanghai.arm.com [10.169.40.35]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C032A3F52E; Mon, 9 Dec 2019 19:40:39 -0800 (PST) From: Jianyong Wu To: netdev@vger.kernel.org, yangbo.lu@nxp.com, john.stultz@linaro.org, tglx@linutronix.de, pbonzini@redhat.com, sean.j.christopherson@intel.com, maz@kernel.org, richardcochran@gmail.com, Mark.Rutland@arm.com, will@kernel.org, suzuki.poulose@arm.com, steven.price@arm.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Steve.Capper@arm.com, Kaly.Xin@arm.com, justin.he@arm.com, jianyong.wu@arm.com, nd@arm.com, Mark Rutland , Catalin Marinas Subject: [RFC PATCH v9 1/8] arm/arm64: smccc/psci: add arm_smccc_1_1_get_conduit() Date: Tue, 10 Dec 2019 11:40:19 +0800 Message-Id: <20191210034026.45229-2-jianyong.wu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191210034026.45229-1-jianyong.wu@arm.com> References: <20191210034026.45229-1-jianyong.wu@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland SMCCC callers are currently amassing a collection of enums for the SMCCC conduit, and are having to dig into the PSCI driver's internals in order to figure out what to do. Let's clean this up, with common SMCCC_CONDUIT_* definitions, and an arm_smccc_1_1_get_conduit() helper that abstracts the PSCI driver's internal state. We can kill off the PSCI_CONDUIT_* definitions once we've migrated users over to the new interface. Signed-off-by: Mark Rutland Acked-by: Lorenzo Pieralisi Acked-by: Will Deacon Signed-off-by: Catalin Marinas --- drivers/firmware/psci/psci.c | 15 +++++++++++++++ include/linux/arm-smccc.h | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index f82ccd39a913..5f31f1bea1af 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -57,6 +57,21 @@ struct psci_operations psci_ops = { .smccc_version = SMCCC_VERSION_1_0, }; +enum arm_smccc_conduit arm_smccc_1_1_get_conduit(void) +{ + if (psci_ops.smccc_version < SMCCC_VERSION_1_1) + return SMCCC_CONDUIT_NONE; + + switch (psci_ops.conduit) { + case PSCI_CONDUIT_SMC: + return SMCCC_CONDUIT_SMC; + case PSCI_CONDUIT_HVC: + return SMCCC_CONDUIT_HVC; + default: + return SMCCC_CONDUIT_NONE; + } +} + typedef unsigned long (psci_fn)(unsigned long, unsigned long, unsigned long, unsigned long); static psci_fn *invoke_psci_fn; diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h index 552cbd49abe8..701fa1da6b4a 100644 --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -107,6 +107,22 @@ #include #include + +enum arm_smccc_conduit { + SMCCC_CONDUIT_NONE, + SMCCC_CONDUIT_SMC, + SMCCC_CONDUIT_HVC, +}; + +/** + * arm_smccc_1_1_get_conduit() + * + * Returns the conduit to be used for SMCCCv1.1 or later. + * + * When SMCCCv1.1 is not present, returns SMCCC_CONDUIT_NONE. + */ +enum arm_smccc_conduit arm_smccc_1_1_get_conduit(void); + /** * struct arm_smccc_res - Result from SMC/HVC call * @a0-a3 result values from registers 0 to 3 -- 2.17.1