Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp294155pxp; Fri, 11 Mar 2022 04:37:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyupePV2EEDd32zLsyewVw9gv+OT1lvx/jLS4N/gkrv0J/p/foe4mjEHlzLzI263gpr6Mor X-Received: by 2002:a17:907:971c:b0:6d6:e503:131b with SMTP id jg28-20020a170907971c00b006d6e503131bmr8152105ejc.121.1647002263999; Fri, 11 Mar 2022 04:37:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647002263; cv=none; d=google.com; s=arc-20160816; b=KnlT2lrt/9rkm9pj4dZ6+CjMWODKAfOtWAycp9jo+VwJwwCJOOJ/8YXIO5RKnjHh6F yebRMNzaBlsuY6yzY1HLjujyWiKgcTjgWf5nk9nnkwDOiRrKNDVgydQTGpmGYMmzMIo0 SXsCvVN0uytLIup6m/EZVGVYJeItFNatZZhIhgKLyUVg5gZW/pafbhyGP7tCw26XWWCs Q/BFwH3ZOo32oyfJ8Hqh7Nx0dZyJtu83IrUXG3bP2Ca/kI1R8UOHHLJbs80gGKdgRfeW gIHXRGQtLAxTQu1WpDXE+k8LvlL/U3rX90/neP9ANGRRQ8NANgJ30nVblbTT3dDbMRIl njnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vCtsPZXyweeEFNQL7JH4zK8eOpdzrzd6axeCouyesuY=; b=OZnW2kPoV4C59zyjsKEKyOeN4dYMGBGoN1YfKKOLoA8k1vzAKtVBH5SwW422RxdcQz pGMly6MgXWpOHH2fgcte5VPaKI/yYuE/RXj9LFahMYiYHoKZzTAR9pTL46pwYDrtvsFh xiXRhXJGZoz7bzfy6KVwgXKchi+tWDrvbNtC00xm6odAceRn1rYJLybt+9nIEZRGjCgw ZM/N/nMZ5HmD6b9wpUCTLmTz0uWyV+Gzi0oB0/YWXxOrjEKsdn6dGO3FH53DKYdD4t6M o/IgaZmJfEaKWSiONp9jN8u4DtNq5MV6TYZHmpoOGQ58XPhM32MO56ncmwCCUobjKw8k R4hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vCKvCEYU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e17-20020a170906505100b006cf834b30e3si4928862ejk.598.2022.03.11.04.37.20; Fri, 11 Mar 2022 04:37:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vCKvCEYU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243422AbiCJOZ2 (ORCPT + 99 others); Thu, 10 Mar 2022 09:25:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243253AbiCJOVb (ORCPT ); Thu, 10 Mar 2022 09:21:31 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 053A1B6D3A; Thu, 10 Mar 2022 06:20:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 94F9D61CFD; Thu, 10 Mar 2022 14:20:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 945DFC36AE2; Thu, 10 Mar 2022 14:20:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646922020; bh=hgyMPXKpyrjFSr7gjjGkb1FgtZRbJo9afPZLy+xNAuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vCKvCEYUngvrSFjzT3tQ/u9yt9b5sZRCx2DeoxiESKXAN3DjI8w36OBBeRY5MmJkC aOLkZly8C4pGCH9LuO5npMNsQwUbs+3YPnyfoei3ucr38CDys/JWoNCPYW58oFL5UC lTBu9DTXjy9fy7/84FqqPzbWFuQUrpUo680vUJDk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Lorenzo Pieralisi , Will Deacon , Catalin Marinas Subject: [PATCH 4.14 12/31] arm/arm64: smccc/psci: add arm_smccc_1_1_get_conduit() Date: Thu, 10 Mar 2022 15:18:25 +0100 Message-Id: <20220310140807.892834978@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220310140807.524313448@linuxfoundation.org> References: <20220310140807.524313448@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland commit 6b7fe77c334ae59fed9500140e08f4f896b36871 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/psci.c | 15 +++++++++++++++ include/linux/arm-smccc.h | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -64,6 +64,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; --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -89,6 +89,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