From patchwork Wed Apr 17 09:09:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13633064 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6C6ACC4345F for ; Wed, 17 Apr 2024 09:09:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=0/GRSea8PKkAsdQfAW5SDEfmaoYhAZ/cSbnCwN29Ngs=; b=BV9enVgyQQRW+b 3k71dZ74L8v9wR5jaJYh3qQe+6duk0QUSa+uJi3Gg1/BBfi5xgGpNGU/H1IKysaeU7s7JPenT0d6/ 9IWbnA/u2zPr5k2SJFa7L9fmDQjo8lU/JjX2knbJt04T0/lpldlz6xLhApzQzuSq+RVkzaWA8Xfgr HmL7p4F5ypMc1fkw1eTlIsRQY63gERTxD/bsLMXHYP3AvfxAFJAitFOOidUciq31GDzDlae2zPKO7 vlgqxhi0VZaUitpYi1UZCWMR0IxqfY3piZeQLGbvmRd96R0+VwU3nDIp4V9L5rh5wahstf6hD60hX vWGy4JYVVK2cIf6Zlb+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rx1IK-0000000FLiO-17lQ; Wed, 17 Apr 2024 09:09:32 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rx1IG-0000000FLhr-3R7V for linux-arm-kernel@lists.infradead.org; Wed, 17 Apr 2024 09:09:30 +0000 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 84947339; Wed, 17 Apr 2024 02:09:53 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7AE763F64C; Wed, 17 Apr 2024 02:09:24 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Marc Bonnici , Olivier Deprez , Lorenzo Pieralisi , Bertrand Marquis , Jens Wiklander Subject: [PATCH v2] firmware: arm_ffa: Stash the partition properties for query purposes Date: Wed, 17 Apr 2024 10:09:21 +0100 Message-ID: <20240417090921.2866447-1-sudeep.holla@arm.com> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240417_020928_934184_ACE0F688 X-CRM114-Status: GOOD ( 14.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The properies obtained from the partition information descriptor as part of initial partitions discovery is useful as it contain info if the partition - Runs in AArch64 or AArch32 execution state - Can send and/or receive direct requests - Can send and receive indirect message - Does support receipt of notifications. These can be used for querying before attempting to do any of the above operations. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 2 ++ include/linux/arm_ffa.h | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) Changes in v2: - Made this independent/standalone patch - Moved properties to struct ffa_device - Added accessors for the ffa_drivers to use if they prefer to check certain properties - Dropped the check in the core ffa driver as it could be expensive to do such checks each time, now deferred to FFA drivers - Link to v1: https://lore.kernel.org/linux-arm-kernel/20240415-ffa_msg2_support-v1-1-a28c964b1b3f@arm.com/ -- 2.43.2 diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 9bc2e10381af..7dfc20186496 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1227,6 +1227,8 @@ static int ffa_setup_partitions(void) continue; } + ffa_dev->properties = tpbuf->properties; + if (drv_info->version > FFA_VERSION_1_0 && !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)) ffa_mode_32bit_set(ffa_dev); diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index c906f666ff5d..b8f10a0a89fa 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -126,6 +126,7 @@ /* FFA Bus/Device/Driver related */ struct ffa_device { u32 id; + u32 properties; int vm_id; bool mode_32bit; uuid_t uuid; @@ -221,12 +222,28 @@ struct ffa_partition_info { #define FFA_PARTITION_DIRECT_SEND BIT(1) /* partition can send and receive indirect messages. */ #define FFA_PARTITION_INDIRECT_MSG BIT(2) +/* partition can receive notifications */ +#define FFA_PARTITION_NOTIFICATION_RECV BIT(3) /* partition runs in the AArch64 execution state. */ #define FFA_PARTITION_AARCH64_EXEC BIT(8) u32 properties; u32 uuid[4]; }; +static bool ffa_partition_check_property(struct ffa_device *dev, u32 property) +{ + return dev->properties & property; +} + +#define ffa_partition_supports_notify_recv(dev) \ + ffa_partition_check_property(dev, FFA_PARTITION_NOTIFICATION_RECV) + +#define ffa_partition_supports_indirect_msg(dev) \ + ffa_partition_check_property(dev, FFA_PARTITION_INDIRECT_MSG) + +#define ffa_partition_supports_direct_recv(dev) \ + ffa_partition_check_property(dev, FFA_PARTITION_DIRECT_RECV) + /* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP} which pass data via registers */ struct ffa_send_direct_data { unsigned long data0; /* w3/x3 */