From patchwork Fri Sep 29 15:02:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13404504 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 83E6DE71D47 for ; Fri, 29 Sep 2023 15:04:12 +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=UxMzbA7TwfXIx8sqrMbR2IrJwBNGHdZx2c3eIkU2PHs=; b=mVGnY6mmEFupwe z23qAyftyDDiWj9JFuBdRuUx/kwM/BUMNNERUcGKAB1DKbaDd0/uhEPSbGC/m2LnRQkQ9Q0OmukvA KLvSmcdLG59He1JyOLxlUqwycM9kXat/pmvmYjxRcmx2qLyt2occ0/LMwxXvQnBA+FP3VXF8aJoYw BOIMai80d22PwPj1ukrQP8b8OlLD61BDwtFgqlora41ztPvqle7NMzrG8qbEbYM/9i1arnCofvi5O NKhtKu7RWF5zznQ2In1fWmuRi6yiPWsmLCZd398GE9jYpJEGHUnE6Z/dt3FfHHNdmPopcJX9E1NAC xLgFF77TL4e2fT61tJng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qmF1n-0088PV-2c; Fri, 29 Sep 2023 15:03:39 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qmF1Y-0088Gh-2c for linux-arm-kernel@lists.infradead.org; Fri, 29 Sep 2023 15:03:26 +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 3996CDA7; Fri, 29 Sep 2023 08:04:00 -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 D75F33F5A1; Fri, 29 Sep 2023 08:03:20 -0700 (PDT) From: Sudeep Holla Date: Fri, 29 Sep 2023 16:02:55 +0100 Subject: [PATCH v3 06/17] firmware: arm_ffa: Implement the FFA_NOTIFICATION_GET interface MIME-Version: 1.0 Message-Id: <20230929-ffa_v1-1_notif-v3-6-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=2442; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=WcMcF7+EWspNtIEKv7vhK+PdYzYtK3Hl6T1/APp/RSo=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlFucv9DdfP5qDeC0S7ZKdLh/2EacPtt+fAel+o gzGvF/3OYaJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZRbnLwAKCRAAQbq8MX7i mGymD/9pOqUOteL/bKSdzoY3NQCakLGj4XiCROjEievu5tUdHy0Zb3ttZk2FNhwO0U4GTs+zN7q JMY1pBn0Whe/TMy9uoR6QMHY6DydUrmxF8i/Xbg7acJwrYzP/EKGbHrD6nHsIzaw0fbVrZTqC5W LrCV8D0042hPxLhPqFuOrSa8Wi2xtDsE9HI0rV41qzg28H6SKgJnGLwavnGvlpsiAb9hjeNrrBC eO2ZS/vJ+VoZ10DcHBJrmOCXPVkzVM1KSd9nkazpTsP4Gg4NxFIQLNiCA24RT29pJm1F6Mz+1cZ qxPRFroeIabsRziknlj+JG2p/ezP4ZysriTfCWnUeZUIQAqxn5d1Xop+gz2dWqS5sg8ZkdHy9wa Waq9Ys3Mn/bEwq+JCFTqrN0bDJsdtsddVA/rahCLcpDrl0WoLDP1zmJlhf0JfD+JVEia/yhQ8Rn 9mWF/AJvGd8/xdy+e/iL76A+H34ZXxNZ5rP2/QmxJC3Ph2encmrjrISyXwXhuAzNwk9084Fa9ES 2rgkFA6HujhRSgn1MhgUDkGDnUJmLF57TS0LBZvuWspwiK7WEqM2G/sl2VN6ihtJIvaKqDfVSf5 dZm5IZsQJyr2LqWGDrPh+MiyyQMfHZ5qsHsD1tF2uccVe9AukepEBy0x29Bi6VSTfwjyt1PkpTd 9T/z+j/ZK2XvPBQ== 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_080324_939648_1835786D X-CRM114-Status: GOOD ( 11.18 ) 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 b0d1ddfe0230..02eedb7bc171 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;