Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp581061pxp; Wed, 9 Mar 2022 08:32:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZJ5GxZQSF+ZpQtBIGMV9swPzl12E68XRETz/lTUPtkuBYtq8xHEWq1k2izBNWU54gjssE X-Received: by 2002:a50:9fe1:0:b0:416:a97:e962 with SMTP id c88-20020a509fe1000000b004160a97e962mr237718edf.315.1646843547151; Wed, 09 Mar 2022 08:32:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646843547; cv=none; d=google.com; s=arc-20160816; b=VQOYhpfQiVXqyYPy5l0Za8FzylwHpKsAdDEu8lEecITYOJ2+noB+0FrXtAgZ6u0db6 a/14ysobY06mEBdlMH9b3vLk6oTxgEKqb6cev4pV54eYjZofk1UOil0mircdzMviXcCp OG99Rr5snCAzXkaxlGwQ0zoRa1oS2z74EcxIU/vwInRxk8CA4BuXi8Mbn8aBPoJ8890S 8pvdMuu3aISRgBHITnvnpArj4OZb+vS4ArZu8/hmU73ybdObUjjt3UDZ6euHW5Ml0xtK 3lhzA0MqBzXjm+evOgv7eWgMhpbEK46X3Sf0q/JQxbbxjOsGt4kZhuPax6quQNhsBEZ5 ADdw== 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=sIlogqEMh/cRCmLuWHLVmEFKn668REcQt9fCO+rYwrhVdvy02P2AAmeCjRKyBNeUUy k17b/QZPjJJBvnxOkvAaneJ1XADpWi2J7K51EdltmyxlJ4MpzQlwpdej2zjigrwlpoLi DYtIVpzvF5x9S0RjSXBw2iMTCzXIoYxbDE1CxsXgIaQ0c/bChuC6XJvebtU273ECUd1a q6UubtQ4RQWTH0oW6Hj9mNymUEeZW1QMi0S/Y1eovTJIPPO7ocVfcGj1oFoXuCwPAIEx ObEmWhu0ZPWuUJocHqO5Zi0edL5UEgmi/865huT00Ko/z4Pq0RgNhXzrqNCygNTziRfu LvsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0wWupqOP; 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 v17-20020aa7d651000000b00415fdcd8479si1567587edr.41.2022.03.09.08.31.46; Wed, 09 Mar 2022 08:32:27 -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=0wWupqOP; 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 S234267AbiCIQEy (ORCPT + 99 others); Wed, 9 Mar 2022 11:04:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234257AbiCIQCy (ORCPT ); Wed, 9 Mar 2022 11:02:54 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2584517F6BE; Wed, 9 Mar 2022 08:01:53 -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 8C92B61672; Wed, 9 Mar 2022 16:01:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D543C340E8; Wed, 9 Mar 2022 16:01:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646841712; bh=hgyMPXKpyrjFSr7gjjGkb1FgtZRbJo9afPZLy+xNAuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0wWupqOPD2EtS0Tbjf8YveJhxWeuG7CeOyAbNDRliN6QdLpHv+KrT7zRQ7DeesM6h +YCR0u3gVv7nuwfYERKSwaZLJICBQrYOJh3oqirvOCvjxjq+aPQuN0GctQ9ACYddAX pOzBYBFBUgynVhoC/nx5OXrGQEOK13fcgdc1OOKs= 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.9 18/24] arm/arm64: smccc/psci: add arm_smccc_1_1_get_conduit() Date: Wed, 9 Mar 2022 16:59:31 +0100 Message-Id: <20220309155856.837348646@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220309155856.295480966@linuxfoundation.org> References: <20220309155856.295480966@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