From patchwork Tue Dec 10 03:40:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianyong Wu X-Patchwork-Id: 181107 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp5237956ile; Mon, 9 Dec 2019 19:40:48 -0800 (PST) X-Google-Smtp-Source: APXvYqyC997EMDOc6wWrYZ62VBQevQwLwJ3E3iiI6/UUqC0zc+EBtCRgyRTQCMlHaiy5OwZWezit X-Received: by 2002:a9d:1d07:: with SMTP id m7mr24473206otm.261.1575949248727; Mon, 09 Dec 2019 19:40:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575949248; cv=none; d=google.com; s=arc-20160816; b=pZYBujRQ8EL1g1H6iKmej/6Lr0kftUjUUQ4gUtMNK4bxlpa7LKvsaYHsN2F/MyvmJJ YPlsfbawa+njGvcUBmCoeOrx3T7wR8ozyrmxzHIkEbGj+wDTvg3CzpRo1EOsDbYLVz2e uzFhXgyRBBy5VoFTrdfuYJwdkzneZZPasSI+eQY/RwHUHYSxJWvGVwZdDrSuV3H9bo4K 58Eh42386fQ32L8LcZJq1P5law8JbWUBRwFYtDLqR+pEJaqA7GaXPJykeO2dGv+Hkq3v YrLLuC3+HbQSSv2NNlukOziuDysjj+VU0lT75H2apZ6/1TbZoJc4uQCTnALuj57cuuP4 zNFQ== 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 z23si1231438otm.284.2019.12.09.19.40.48; Mon, 09 Dec 2019 19:40:48 -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 S1726987AbfLJDkr (ORCPT + 27 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(+) -- 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