From patchwork Tue Sep 19 17:40:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13391630 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 0F116CE79A8 for ; Tue, 19 Sep 2023 17:42:01 +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=/mvsFI+PAspA3oDbqATlkiYNZjDmRZayYUAfn17A5FA=; b=dDboFHYVOTvli8 PyrOGguZrobbj9BsMhMpsK2y6XQafuxUQPNitUQ6O+xudx37WRwnOFeVcq+ntkBxvkgrermSipDW5 VBBCr9yKog+5TRUVfbRFf4e43UqRuWEqpA7YWUki2SmKSPHXruPW1iw8dhwVJkIEme6Ke/a3a5lyp 8ShS4sYR239rowy+ndriyB702UppyZVZRETewwIqYYQ8III/YTDCps5noUeYw+49vttrP9D6ttcOd KLLZAZOmhK/KbNSKNTKDiTxtGA2geim8+c+Ks2398/99ztQ2Ykh8VcNioV9Ja8Hexjsfm5O6oUgBQ zUJxsqniyfiDubuakWBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qiejB-000xIo-0K; Tue, 19 Sep 2023 17:41:37 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qiej1-000xDD-29 for linux-arm-kernel@lists.infradead.org; Tue, 19 Sep 2023 17:41:29 +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 1CAC41FB; Tue, 19 Sep 2023 10:42:03 -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 C5A583F5A1; Tue, 19 Sep 2023 10:41:24 -0700 (PDT) From: Sudeep Holla Date: Tue, 19 Sep 2023 18:40:54 +0100 Subject: [PATCH RFT v2 06/18] firmware: arm_ffa: Implement the FFA_NOTIFICATION_GET interface MIME-Version: 1.0 Message-Id: <20230919-ffa_v1-1_notif-v2-6-6f3a3ca3923c@arm.com> References: <20230919-ffa_v1-1_notif-v2-0-6f3a3ca3923c@arm.com> In-Reply-To: <20230919-ffa_v1-1_notif-v2-0-6f3a3ca3923c@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Jens Wiklander , Marc Bonnici , 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=K2YvsILaFgpr4lZX+pTYFCZTBnlVK2W1JnRsJZazgIA=; b=owEBbAKT/ZANAwAIAQBBurwxfuKYAcsmYgBlCd06QXKkqx4Wz2xxAT7OvoEFG10hO4sIVYO1m jdo2RZiX+SJAjIEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZQndOgAKCRAAQbq8MX7i mIv9D/ibxw1xn1QD9eCMGeI6hx5YcyE9Rq6Jrrcn/9J+GfmOt1/ZLNNIzpcf4cICA7hwBGZCkdW td9eOsMYwiYiBR7lnJEKsPpPRMu38uTXQmOOBp5wUR7ap6NYOrV2L1Haik2ip2rjrDEZ1wiYKOf FS7P0661KKQJLrJyFnTqisEjL661m7cNVynYDxZBkjQychPMhfjrDu2dhbrSpgFN0BeiGQCepjL vYzRqwVeJacXpCeCLxe589xpQdV2+CNtJj/lLIkFHl9/XfqmPve7BBl+nNBonwcXaqaKU4FGt2q ETRf1UtD2lcsCfsGmixptpg55Jrkwysxl6zpFVBJwPfOd2vkmeHNwk6yvjeAExKYPQU1SBDFWK/ 1dv49RA/ryCZe7tNDF9ctSNTAWyO4tZ6N41TqUwsiyHsZVG8B+1YxV0FkO5V5Ic5ctrQ49dFWFL lpLTcjQtdT2F89djZsac2yU6fUrfZ1s+sUIUIJCdfGLzmhywVByVLkb31bUGuitj7YLFkQeNWTL Q25HUnvee5R28bkWi/miPN92q69Q8LR+YMW1z+8OT71Zdc9OAcbaKyAAN4YsdwpeW/P++opehLN nUJ42SioPPwCrxPQ7zYQYI4t4hTBsvSMSZzzuhOL3tCFFUhw/JE5mvD7FTg9TsuVw6Bv5PndhXw tkaTJzarr4Gd5 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-20230919_104127_798287_10A53E37 X-CRM114-Status: GOOD ( 11.24 ) 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 2aae838ba46a..acb58715687c 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;