Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp402539rdb; Thu, 5 Oct 2023 09:06:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF75ITMFjHgsLZcl13pzBR4Rytdbb6RWULyN+qO4BXzOXV4faWf9UaOCQ3h+i3kBcnQDous X-Received: by 2002:a05:6a00:2314:b0:68f:cb69:8e7f with SMTP id h20-20020a056a00231400b0068fcb698e7fmr6592378pfh.7.1696521973241; Thu, 05 Oct 2023 09:06:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696521973; cv=none; d=google.com; s=arc-20160816; b=Z8+FANoKqqb79jlOZiHmPQgU2kGW6GmJyyIb2c8f9EXY75jDvEFuVOk76jqsy/xOXt wGs/U7exPKhFM6KusCWr8Eoa2WiGb50NMAMj/8b58PEUy0syIBS6NjtMKjD0u6TPd7rF 0jjHA+NvgnrHQt7hfaoGImJqvcQWsDIjeb7wPS24c7obO/YQmh7vYRb2PaNDDQlu91CX wwkdaxlqq2LxeQZ+gEQ/7vI9NSMLJjtQkun88h9usukkKOlF2ForSA9MhWTPvW9+0htg s48AFUCyYRl3C0qYCqKVFW41URsY7IyOUvE7g2GvF0bHvJC4Qg9x3JMeLPGEitLqSp4b Ru7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=Tv3FntbeVPyVE6jWt1kTAHu1ZEVQQ35hz7TED+X2gNM=; fh=iZJRvoZuVJp3Jcg3UWu0imuTLbH0nKChof8pDyzNHj4=; b=Uabj9jgTrHXvuE1SUI5O5P2KfjPNRAQWyHmjMjslLkJ3X7n4IO24hXLxJPC4t83crF Uwic1MvkHBQ+qUFz2kIbPSsJHRWD4Bs+08xthyInHhh3FKm8wqiueorQUnlQlP+hS90y Zv5sjdTxHB5lsBSRj70rydxz9vGBnJ6MdTyl1wH0FqrpGF1Bcj5rS16vKi995cGQoT0Y ji6mNDnMoCL1/3zsqiyErPiDAplhAR3omp8/xvpdTgVM6QYIjPBDkC048qKENbpSkzHU bmTdtZgJxQDV1+xsz1SisBgH/XhrbFcoFYQtSL0e1ityHN7ip9xyLfRtpm3Dvtd8wdE+ Zliw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l8-20020a056a00140800b0068ffeb6a949si1651267pfu.73.2023.10.05.09.06.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:06:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C42E480A2670; Thu, 5 Oct 2023 09:05:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237084AbjJEQFC (ORCPT + 99 others); Thu, 5 Oct 2023 12:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234733AbjJEQDY (ORCPT ); Thu, 5 Oct 2023 12:03:24 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D11C03869 for ; Thu, 5 Oct 2023 07:45:12 -0700 (PDT) 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 23273150C; Thu, 5 Oct 2023 07:45:51 -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 6D3DD3F641; Thu, 5 Oct 2023 07:45:11 -0700 (PDT) From: Sudeep Holla Date: Thu, 05 Oct 2023 15:44:56 +0100 Subject: [PATCH v4 03/17] firmware: arm_ffa: Implement the notification bind and unbind interface MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231005-ffa_v1-1_notif-v4-3-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=2207; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=tCh7LbKeNAevFd5uQSx03qEkiVl/aQEeXvD/r/UF4UU=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlHsvwFDa1dLaZiLdaBoo+tK3/uFpNRlVXwQfJU v79YnQB7lKJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZR7L8AAKCRAAQbq8MX7i mLWQD/wLXEyJRAXmNV7481V9rRrEOHvJ36UfKSIWMkvKASOA5tN91M1Orlf6679gmfJJDBvv8SP X8CpzgeqIgLndGOcvlgUc6sKgXdT2QHLzGMqSlp1zh6NNBzuH0CCY9YjZ+CGIHBB+vWPPL47OQR VcuIKfuU9VXpea+xynjlRpwkoqgjz/YGTSL19m3GOfUW6GSzopPt0aAVibxZK7PQBGRnqYbKMcO NkgOexysE6f9G4lhGDOJfhErVsR4D3jNpMh5UZfLxCi1Jd7Ehjxo8qT2SmQQ9Kf79rwsRbGakpv j/sU7v5lEMsDfKRyJPc9QT+mGcVv4FpPNySXQDWLWk35gS7Vk1hZxkkocYP1z/6HYsJMkhCSsyJ 4mGhqnGr9KiRwMhuUNBBi4vJjI4tXqCP+QahymeH4WfnlAt4P70SMXy4TTadgIPeoloJYQQa298 TG0iIjeHhIsvuVombabM1TmrG5EGsfhwomwXxhzl6KAojYWradn5YXCbOWOfoTJXeueuxfvASH6 p/YqWegmTZ7RtKxys24QRT1RvxOnCj5phnY8nqFHrkicnZL8uiHewpV4UN6yNvPdSdEwEIP96mC jXGiYEKjH2d9OYaTf779pGMbGf6ha1eNRMyOeoa/Vq6iilHIcNcBSoqvxabFOqVMo9FFGz2/BYJ eN6H/Li3w/s+KLw== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 05 Oct 2023 09:05:30 -0700 (PDT) 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 c2ab6f4cf296..20f8f4ca8e89 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) || -- 2.42.0