From patchwork Thu Aug 3 19:02:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13340782 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 4998BC04A6A for ; Thu, 3 Aug 2023 19:03:04 +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:References:In-Reply-To: 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: List-Owner; bh=ztvqh+xtyp/zDU2e+PybHS9Cv53PBpQKFSQQEabm5FE=; b=0TIgaOWLZqA1Ly OnqcBcD2BdERFVDUQg2DtvWNc17IbLbjN8pUlXrraUc904CeKXAlnX5WU98twbQvDtO7kOdWsANA0 ZqrDBs1WMrwQ70cBDRez7lKgA1zQMjF0QdJGpXpq6O9pgCo/oRmNZRhr3kxT1HQ7zG88F3GZSYOBj LrmI+we5dS2piBTRlnxYXJxo00nbZ6/3G3YnLcTIo+tbngfki/2fnW8vJy9ittmZXhQ0+nEJNUt+j PZQzM23z41FGXbMBGwRCSE/xqJ5ECJ3jn7ZcdIlNXqkC8ZiLUNDewzutOE1T6t0TMtOF95QraCZ5K sWnumbJQOMZE1IZGCo0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRdaq-00Ah3S-2F; Thu, 03 Aug 2023 19:02:40 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRdai-00AgwP-1L for linux-arm-kernel@lists.infradead.org; Thu, 03 Aug 2023 19:02:34 +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 E0ED3113E; Thu, 3 Aug 2023 12:03:12 -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 C59D03F6C4; Thu, 3 Aug 2023 12:02:28 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jens Wiklander , Lucian Paul-Trifu , Marc Bonnici , Coboy Chen Subject: [PATCH RFT 06/12] firmware: arm_ffa: Implement the FFA_NOTIFICATION_GET interface Date: Thu, 3 Aug 2023 20:02:10 +0100 Message-ID: <20230803-ffa_v1-1_notif-v1-6-6613ff2b1f81@arm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803-ffa_v1-1_notif-v1-0-6613ff2b1f81@arm.com> References: <20230803-ffa_v1-1_notif-v1-0-6613ff2b1f81@arm.com> MIME-Version: 1.0 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=QiYypOJbkBWHgSGa313TRfX1qAeCKQxgXXJlIzrlCb4=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBky/iN718+JjDcXSIQ5FtP9ojxFvsvrNBlWnUpj ykv/F2Jav+JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZMv4jQAKCRAAQbq8MX7i mOMhEAC9njZpnCHhAp9dXLNaxwkN9GRPwSNRxSfrqdGGB9ELXYXKVYNdQxjLCs9w+HQBeMhu3PO GdqB1/IzaHrq9C+U/fPTREEVy+QdGVjEOorcp3FgFIm5EL+FKuIYXY4qnK1yblPbngl9iC/WPbn MpJisF4XHUZ0E1fi6XXRtt0oQe5iYr1Z65OKtl/Jeojt9Ig/A/RJm9/M7+wwE4/yYmdjlrQSwNF 1G06QJK98gSfDahUTnyxov3diHEGnAOLtus/cMttRcvMcvBI/UcAAEOyPWsVsba/IsGLPmM+9Kp hArXdwdwG+DGXXuOT7l2U1jZcNl3dXL92Eij/1sGNBUTRIaU3SgldzC7J7+9kFRi4kfWXnAuQzH PHwy/tctFZHYBPMILmo/QNKd3w6xG9UJFPhEE4UVJeJy3IANEgomJXA0nhWR+zvEPSZRyP5yGUx PHUjqNTOWxQFaTKNPJ8eI3ZS53D4jGsIapfFgzK9nRQ/jMjkZC4JExsSviXn/FvMc1mhz6d1P6k 6dI7YNjSji1B5+eKJx5BdiWWGegwt93hZX49FR5S4g6CqG5bGi3tKwL0/df4Fk0j1tTn4PsiW1/ lni5aa845TzS/3Ha//Thaa6gvfvIvMnNlICi5R04J0GtP6THy3GZSIQSSZlaMg8D3mPE4XJSaP7 Bkva6i1a nJmYebA== 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-20230803_120232_546072_C28D7524 X-CRM114-Status: GOOD ( 11.55 ) 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 492f5bfa3751..6cad91ee57eb 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -581,6 +581,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) @@ -624,6 +632,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;