Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3345029ybg; Fri, 25 Oct 2019 02:46:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXHnRpD4Hk9owxjrx8LgdVZlR61I7iPytcBfblt8v45uT1e3f7ypYxuxjA2JlGDJslXo4B X-Received: by 2002:a17:906:1ec6:: with SMTP id m6mr2521502ejj.6.1571996768089; Fri, 25 Oct 2019 02:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571996768; cv=none; d=google.com; s=arc-20160816; b=uXN8LEitt0hmpZ1JutuHn4g1M8BZl27QHEGrduLoL8Ea/pl4pkpU15ZinN9FyeuhHN eF4b1SRHOdtcwbWdOgbzpeg+6FiW99+owftsrGw1Hp+aPPACm5JNsYSt0NDbkJkW27Df OvHXxEx+KetVNTbZyAZAK4fr2T8iNbjyopwb9YSsPkSxmupdIwM3s3u3TM5iOQ5k6Ibq vnewIOoOm5SBb88r5h/aY80XhLRIQ8DfP13Zsz/qRGhTVQgjdwve3dmLo020TNqKlmr9 m+gktkdiOnfnitKTN4X8IFtUin4ElIoFNKMEU39iaZVVgXZIvDBrTlgiI/a/1vL6zkev 1OtA== 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=i5drUKZoQS62noNu8cFGJcmPIXmEIFJMyC1hQmUL52XIAKNwyzD+2Hq71lqRwWaKWW dl7rva+G/1GNPcBG6oX3HOVPzaSxp2/pfK9JnXOFG74fTR/5k+yykp7P5M/n8J7tBXBK LUoaD6KCVcYlFMkbjYcSgBCjlkhkcG5cDYbXPXb1ZVQGPUyFp/XTV6jq+wZ6+6D/slnT l8xzsfolt+WxqjaZVJOgLQRhTf8m5M60qE/rMpKDQzpfpl2RpBL6KOYMkjPBEUCpRyEk fkY3qZIYw6t3alaef9GrpduB/ypubLQRTrPx/vyZh4xPbdlgVbEXj5OgzmUaNSM6yYGT On8Q== 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 a16si865422eje.336.2019.10.25.02.45.43; Fri, 25 Oct 2019 02:46:08 -0700 (PDT) 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 S2393386AbfJXLCp (ORCPT + 99 others); Thu, 24 Oct 2019 07:02:45 -0400 Received: from foss.arm.com ([217.140.110.172]:47418 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389995AbfJXLCo (ORCPT ); Thu, 24 Oct 2019 07:02:44 -0400 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 1F28C4A7; Thu, 24 Oct 2019 04:02:29 -0700 (PDT) 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 C5A9C3F71A; Thu, 24 Oct 2019 04:02:23 -0700 (PDT) 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 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 v6 1/7] arm/arm64: smccc/psci: add arm_smccc_1_1_get_conduit() Date: Thu, 24 Oct 2019 19:02:03 +0800 Message-Id: <20191024110209.21328-2-jianyong.wu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191024110209.21328-1-jianyong.wu@arm.com> References: <20191024110209.21328-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