From patchwork Thu Oct 5 14:44:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13410162 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 3CE6AE92707 for ; Thu, 5 Oct 2023 14:45:57 +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:To:In-Reply-To:References:Message-Id: MIME-Version:Subject:Date:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7ETDgLKUkhXWbsYs1UPUTz2ZN9iDqsm9Uzqp2tlFqno=; b=BfodggHJSbQR1K VQOad/cwW5cS2PWpX0NuCmVTNJ+zZp8UOBtJ9AU+0vo3Yc+wenYij3/uYYk0BUutyCTXLAfetFKPJ 3twk8S6TW1zd1Hbg66ifyvMdRc3vke8tvWLYcSK1/qp+KHrwnky4NlEyQtAGj4S0L1P7KTLmf7WxF WngxrqiEx/KTMPo2vb6JuxH/f7IF/FaU7wlmMfp8owXVJhU0NZgDZr2j1rbiu4ucJPPIPJ29j20D/ xzystWED1Ib2znpDsf8FyYEBF0QtUWpEHvwpjr4Qk9fm3WjlfXtYrUYQj+2VWIN+IO/wfRVu9WmQm g9h2vv6oR0p0l4+DOWsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qoPbT-003lhx-1J; Thu, 05 Oct 2023 14:45:27 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qoPbJ-003lbm-0F for linux-arm-kernel@lists.infradead.org; Thu, 05 Oct 2023 14:45:25 +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 B8444152B; Thu, 5 Oct 2023 07:45:54 -0700 (PDT) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0E3F83F641; Thu, 5 Oct 2023 07:45:14 -0700 (PDT) From: Sudeep Holla Date: Thu, 05 Oct 2023 15:44:59 +0100 Subject: [PATCH v4 06/17] firmware: arm_ffa: Implement the FFA_NOTIFICATION_GET interface MIME-Version: 1.0 Message-Id: <20231005-ffa_v1-1_notif-v4-6-cddd3237809c@arm.com> References: <20231005-ffa_v1-1_notif-v4-0-cddd3237809c@arm.com> In-Reply-To: <20231005-ffa_v1-1_notif-v4-0-cddd3237809c@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Marc Bonnici , Jens Wiklander , Coboy Chen , Lorenzo Pieralisi , Olivier Deprez X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2442; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=JcT3Ibz8prcH4LEIf0QXidGEqQ8ig8451gBfq+wr8D4=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlHsvxvFGznmnDBqCTWy0NqxVWxtJHCRuDBexLt 2bYjTzDE3OJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZR7L8QAKCRAAQbq8MX7i mERnD/4qCvT3/HHxEq/b26JmL747hInAIaYIfi/Td6/7hwAKc2U4VIbtgn31Q0N7BZqt6uPqV1Z MsN/KoXXC80NrC7hIewgMZvSbz6Qyqd6iM1O87L/9YHjWM2tqsFAu2BP7eQqhvkJROEUYtvNeSK JVYdpJo9CwznRP91qloacnqHJlWhIT0ijwEN3zJzsRiQ5f9jPHAml3B4j6SokSNdhmqrnJqNMK5 t9/gwH2aAMbB6bOI6+fdizycB2HOu9/YLMW6JgsjhGitHgNj7q+7mZzeQ24F+vdGcvS/rAHJvTW fNFQlvLo927ZLqLRzBeSFHAv28cDK59Y2l5+2QmsDukXZwDbcf478OAqxWq6SnRTJzLvZwx9Rbx cMkupybn+cuV/Y5eOG4bh0t7txXL4ElvmELHOZrg+HlBuEwNoc6SiEi3/T2baSKSkEWpbMRBb72 hy9VECbyvs+IcizjiQopX19+J0OEMkTpkL+WFOiyJEBrnHDACfdSuGlZf44KePvCTTUyDGWKttd OTIvugwJSoRNpyLayc6QLbQWDDgl0bYO9dTeNNUZOx4HQAJldZ1dBlHF66Apewk91pfo7oQ9EAx AhnfDhPYiczjb22X6q6NU9BNIBLKQomgJuqqZaA4fXfUVSHOPP+oWsZJGPl8q0iJy5pXDrxd0ZY I+vqGuQmy4LPt+w== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231005_074517_244042_C7CCDAD7 X-CRM114-Status: GOOD ( 10.86 ) 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 framework provides an interface to the receiver to determine the identity of the notification. A receiver endpoint must use the FFA_NOTIFICATION_GET interface to retrieve its pending notifications and handle them. Add the support for FFA_NOTIFICATION_GET to allow the caller(receiver) to fetch its pending notifications from other partitions in the system. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 4edb3cb48014..7a0ac4f496bb 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -593,6 +593,14 @@ static int ffa_notification_bitmap_destroy(void) ((u32)(FIELD_GET(NOTIFICATION_HIGH_MASK, (x)))) #define NOTIFICATION_BITMAP_LOW(x) \ ((u32)(FIELD_GET(NOTIFICATION_LOW_MASK, (x)))) +#define PACK_NOTIFICATION_BITMAP(low, high) \ + (FIELD_PREP(NOTIFICATION_LOW_MASK, (low)) | \ + FIELD_PREP(NOTIFICATION_HIGH_MASK, (high))) + +#define RECEIVER_VCPU_MASK GENMASK(31, 16) +#define PACK_NOTIFICATION_GET_RECEIVER_INFO(vcpu_r, r) \ + (FIELD_PREP(RECEIVER_VCPU_MASK, (vcpu_r)) | \ + FIELD_PREP(RECEIVER_ID_MASK, (r))) static int ffa_notification_bind_common(u16 dst_id, u64 bitmap, u32 flags, bool is_bind) @@ -636,6 +644,35 @@ int ffa_notification_set(u16 src_id, u16 dst_id, u32 flags, u64 bitmap) return 0; } +struct ffa_notify_bitmaps { + u64 sp_map; + u64 vm_map; + u64 arch_map; +}; + +static int ffa_notification_get(u32 flags, struct ffa_notify_bitmaps *notify) +{ + ffa_value_t ret; + u16 src_id = drv_info->vm_id; + u16 cpu_id = smp_processor_id(); + u32 rec_vcpu_ids = PACK_NOTIFICATION_GET_RECEIVER_INFO(cpu_id, src_id); + + invoke_ffa_fn((ffa_value_t){ + .a0 = FFA_NOTIFICATION_GET, .a1 = rec_vcpu_ids, .a2 = flags, + }, &ret); + + if (ret.a0 == FFA_ERROR) + return ffa_to_linux_errno((int)ret.a2); + else if (ret.a0 != FFA_SUCCESS) + return -EINVAL; /* Something else went wrong. */ + + notify->sp_map = PACK_NOTIFICATION_BITMAP(ret.a2, ret.a3); + notify->vm_map = PACK_NOTIFICATION_BITMAP(ret.a4, ret.a5); + notify->arch_map = PACK_NOTIFICATION_BITMAP(ret.a6, ret.a7); + + return 0; +} + static int ffa_run(struct ffa_device *dev, u16 vcpu) { ffa_value_t ret;