From patchwork Fri Sep 29 15:02:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13404516 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 D79ABE71D46 for ; Fri, 29 Sep 2023 15:04:23 +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=Z/Y7LVHWSRYfbRSmKZ6VWmljzYTXKIoq0EYrpkwWjOk=; b=mKah8DdKRaG4yY 3CPPVSVPQju2sj8ovJky7SXXz4DMOk0dlBW/wjMoAvpIVTwiYtPQbhoLqfmkdqeGyQS42gA/qE7rI iu0alifT8TbH6EXxbhGjwfDv93DtdOavBGYIjFD6sCL4aedcdIXcjCj2vMKhyS+0sKf1v67oov3XN reQJe1m/+9X4+qTPEjk5+WGyrkNF48MKiXSNHSz7JBgQe7Pp4GZqVWqQR/yth6oI7tO/e9rYYrQsR CUN3RwV4K9OnxX1HP+dlcnjtJBnzOmWziWGI95/Dlf1THbhBZUsdyuKrLd2R6T82WEtPux4WZ74DI Wth2GQuQt/GjRvh95xlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qmF1k-0088Ma-1j; Fri, 29 Sep 2023 15:03:36 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qmF1T-0088Cp-0Y for linux-arm-kernel@lists.infradead.org; Fri, 29 Sep 2023 15:03:20 +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 A80311063; Fri, 29 Sep 2023 08:03:56 -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 4F9973F5A1; Fri, 29 Sep 2023 08:03:17 -0700 (PDT) From: Sudeep Holla Date: Fri, 29 Sep 2023 16:02:52 +0100 Subject: [PATCH v3 03/17] firmware: arm_ffa: Implement the notification bind and unbind interface MIME-Version: 1.0 Message-Id: <20230929-ffa_v1-1_notif-v3-3-c8e4f15190c8@arm.com> References: <20230929-ffa_v1-1_notif-v3-0-c8e4f15190c8@arm.com> In-Reply-To: <20230929-ffa_v1-1_notif-v3-0-c8e4f15190c8@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=2207; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=6dM7t7UcezChOGHUwYllL2LxWCmWJi8qtz0lRrVzNQ8=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlFucuri2NvMBd2IjxYNO/D03XgYBmvOLA9YjLc idNzqIiTE+JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZRbnLgAKCRAAQbq8MX7i mNOuD/4+jcPMdjdx5iTpJDFKJIU+T08pss3uCcdy0GEF9cddo335kSH2rAbXlNk4XHH150kw9K6 NInTCOWpnCVvD+Wk6I7pKYDd/tzKh1KVjCDpRtRLx7g1B8ihjnxthRTCrPfW59G3VnS/QSV9KJG GlGLfx9VBDIazIYaHrHEkvvKEla+rLU/MkLR8tsFSFssXmpA/GflTEHkhO0oqLgst4InUYFW7Rw aTBrbwjOWCFmuqr7xV8IaoLNaNAzZV6bh1pFziLwX+yLxZCUBQV/zo/ptQGaVLTj110JE6GCv/h +QUPZrnjOClVOffWhXtHa1mwQ7a0Pt+sMymCaSszK4xddfnOuHwm0/DavXf2qMHMiovdQYf5yro K7NqxivFAX+2WLsp4vLXyqXhIlq71OuQrVlxv5NVzrw3tgAGJQPxmKV4i1pqrq3QII8mDYYHLj3 a/nDOfABp7AhYVGZBAUQq5njecxdmJl+k3V2W1jAS5+TahyPrgEQG+U/aJVQf2h6YXnFaEig7Ar zFLcB4iIldYmZT6ZY4bLawjD5CKPEsbKa7ya9kYh8EM/4oU9WsCMawjgAgO9EL4i6j7pRRj5aAR NXnyPYf3dTdYpQTGzZxstOj6dAf/08kehdTyFTkQM80QG4peBrh9Azl8ldq6hTjmO4joZS7G0Ig qiCKLrfOcFW9VFQ== 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-20230929_080319_302275_391FBF19 X-CRM114-Status: GOOD ( 13.81 ) 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 A receiver endpoint must bind a notification to any sender endpoint before the latter can signal the notification to the former. The receiver assigns one or more doorbells to a specific sender. Only the sender can ring these doorbells. A receiver uses the FFA_NOTIFICATION_BIND interface to bind one or more notifications to the sender. A receiver un-binds a notification from a sender endpoint to stop the notification from being signaled. It uses the FFA_NOTIFICATION_UNBIND interface to do this. Allow the FF-A driver to be able to bind and unbind a given notification ID to a specific partition ID. This will be used to register and unregister notification callbacks from the FF-A client drivers. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index efa4e7fb15e3..26bf9c4e3b5f 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -587,6 +587,35 @@ static int ffa_notification_bitmap_destroy(void) return 0; } +#define NOTIFICATION_LOW_MASK GENMASK(31, 0) +#define NOTIFICATION_HIGH_MASK GENMASK(63, 32) +#define NOTIFICATION_BITMAP_HIGH(x) \ + ((u32)(FIELD_GET(NOTIFICATION_HIGH_MASK, (x)))) +#define NOTIFICATION_BITMAP_LOW(x) \ + ((u32)(FIELD_GET(NOTIFICATION_LOW_MASK, (x)))) + +static int ffa_notification_bind_common(u16 dst_id, u64 bitmap, + u32 flags, bool is_bind) +{ + ffa_value_t ret; + u32 func, src_dst_ids = PACK_TARGET_INFO(dst_id, drv_info->vm_id); + + func = is_bind ? FFA_NOTIFICATION_BIND : FFA_NOTIFICATION_UNBIND; + + invoke_ffa_fn((ffa_value_t){ + .a0 = func, .a1 = src_dst_ids, .a2 = flags, + .a3 = NOTIFICATION_BITMAP_LOW(bitmap), + .a4 = NOTIFICATION_BITMAP_HIGH(bitmap), + }, &ret); + + if (ret.a0 == FFA_ERROR) + return ffa_to_linux_errno((int)ret.a2); + else if (ret.a0 != FFA_SUCCESS) + return -EINVAL; + + return 0; +} + static void ffa_set_up_mem_ops_native_flag(void) { if (!ffa_features(FFA_FN_NATIVE(MEM_LEND), 0, NULL, NULL) ||