From patchwork Thu Nov 14 12:13:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianyong Wu X-Patchwork-Id: 179404 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp10974057ilf; Thu, 14 Nov 2019 04:14:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwZtTghhxGmaXqngQFbvjl2n4Da5+Ngy4zO3i3imSaBAQJNaxaDVsyT1/IgFFNHaiGOlsDa X-Received: by 2002:aa7:c65a:: with SMTP id z26mr834609edr.261.1573733669284; Thu, 14 Nov 2019 04:14:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573733669; cv=none; d=google.com; s=arc-20160816; b=xIBi5b3mr2u+lcgM0avDNUHnkEqP9gaYzk3Aq/DnNfB0fcU0w5ZQDOhPeH2GuYbG2z 0YpuIa3XuUzeivHH2bRtDGbgiW1lCkPiNnZ7VsUy43TGyy2ztQjOMR7vwryamHvmZNmw WMuz3+lxRDUG0q0hS6Hb4wauwpFg+s6afOJMRFCI4UpBal81hZP5f2u9pKnTK6STd517 41/gbWEQegdqH1T7LAfxEYdv41ZeaIo8c0ASFsyUVY39uWAlkWaDz0FF+WkK0060Yy3j ywVFbF83Vjts2qIRvIr1/r0S4Q71rUGmNsUGCX13OweUwhSGWwkSu39J+ifwuRmxWtxk zWRg== 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=eV8a3vZ6pxerVA7dy4+hdctIx5LvYtUSRxjjaexDphE10I/EVScadaqdKV3u6/mMGH 1n1Vo6SQQTHT53nlyIlqg5EgHH3pOlFSEF5+6Pixnto2wYjJe51NaLsxC5eziwCSMscx GCjmUqgFFL1xiC/cPj6Cbo930Si5vw/gfqNXGmJTnkdEXqC7pEd8zV5aPXyaJibAal5E t7VM0VKdxhxVRhrV8Shxf1RHNWI+kjBDz6hOR0Fb4OSiI4uqYdwjI9ZjE9ips64hlf7V Fku5uhVAMqdxFe/vi4ol/Nxn7vcEAQymBdP7AoohbHeOD8vsbV32D/7ZU5ykEONpzMq7 yNAg== 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 z26si3183427ejb.223.2019.11.14.04.14.29; Thu, 14 Nov 2019 04:14:29 -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 S1727044AbfKNMOY (ORCPT + 26 others); Thu, 14 Nov 2019 07:14:24 -0500 Received: from foss.arm.com ([217.140.110.172]:41846 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbfKNMOX (ORCPT ); Thu, 14 Nov 2019 07:14:23 -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 3BB1F328; Thu, 14 Nov 2019 04:14:23 -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 04BFD3F6C4; Thu, 14 Nov 2019 04:14:15 -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 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 v7 1/7] arm/arm64: smccc/psci: add arm_smccc_1_1_get_conduit() Date: Thu, 14 Nov 2019 20:13:52 +0800 Message-Id: <20191114121358.6684-2-jianyong.wu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191114121358.6684-1-jianyong.wu@arm.com> References: <20191114121358.6684-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(+) -- 2.17.1 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