Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2703525ybc; Mon, 25 Nov 2019 02:47:20 -0800 (PST) X-Google-Smtp-Source: APXvYqyojl8B0Zk1VVkC2XBJ7PjoyOr5+OhZfHln2QIea91rhWBOXZw7mGH7n79lET5xx6e3GSUR X-Received: by 2002:a17:906:2898:: with SMTP id o24mr12929312ejd.102.1574678840784; Mon, 25 Nov 2019 02:47:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574678840; cv=none; d=google.com; s=arc-20160816; b=pxXnvsUOlYDw3Pv7ZZTl6WcGaHdXuDjsHGyiw14XkBfWmumZWx7yym7bcFkfDJSZB5 819Ekq4d0LhL5OZfwRhuSL03X59F4W5bzZyHnoYurs3RL2INqsxC59nt9aT3mufpsb05 Axu9q3ji2QkiBYy61KiUUJ97hHaFeh7riqKgenk+kOIjPMxjhpCkAOioL8xF7JvjTMcd XPIsu8Ie51aeGMD+PjtezLF+WfoiU+4W42ALW56K38lCUVV4lPQRGGZcKQdJR8mRyqsr fteIou4iM7XilyEE8llWLMmGJH7ePpylk2GvoY04tqOLSL3YXqJ9Y90jquLGBZmPEeZw WfRA== 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=PnDBvJX0BIX0ahrP8fDBBwZy8lDc8fQqiyZJDM8sx1YhLa9DFsuhHAenJ7DhFcUx1D 1qtaFK8XFJk0WR3a+zsy+S38ubUHp/QfQApL9vXnWE3VNYTzeFyaeEaQlhZCO+FmkZxg k9SCQy8LSm0BhnGo0Iz2Tb0yUVvd2WN9mO3t5HBMuOuA3kOFgKBYBpg+Cr5V1uv7HfHf YiF/H+sScBOSvkz1W4yvQpihErtBenS51Edqvc2y8JIHFXdQWQ3msj1Ul/lYl0UWAJ3G BiSzRKqGrPH3PaIG+pR08pionvBN27YTRaDeHG1yZ+bEn0HPjsSJRf2RuBeTXxQY0Oxa xAfA== 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 q15si3982174ejm.31.2019.11.25.02.46.57; Mon, 25 Nov 2019 02:47:20 -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 S1727612AbfKYKpj (ORCPT + 99 others); Mon, 25 Nov 2019 05:45:39 -0500 Received: from foss.arm.com ([217.140.110.172]:48018 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727594AbfKYKpi (ORCPT ); Mon, 25 Nov 2019 05:45:38 -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 EC8A855D; Mon, 25 Nov 2019 02:45:37 -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 56E063F52E; Mon, 25 Nov 2019 02:45:32 -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 v8 1/8] arm/arm64: smccc/psci: add arm_smccc_1_1_get_conduit() Date: Mon, 25 Nov 2019 18:44:59 +0800 Message-Id: <20191125104506.36850-2-jianyong.wu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191125104506.36850-1-jianyong.wu@arm.com> References: <20191125104506.36850-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