From patchwork Wed Apr 10 11:39:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13624125 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 B82D2CD128A for ; Wed, 10 Apr 2024 11:40:18 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=R3aw7ng0IDljZtHGn3FuSc38nFWoP1eN4El0db8cd1M=; b=U5/fK9FCeWd9hU 1Q7HzM1BwZdALJdMlnD+nMg50LLxFtr2vyezyHmYAn37yNApnmPl/wo1Z/y+tBBiiG65R8K7lElEG TRFEwVCa30rz9+pVJuel/O1WnsLOU6GFLTr6aaFbRSorx2r/tTBQH8EO86TX4m16BxiYpik4t+6L9 J4Vi2uMUMW8gmJ6eIyl8pTY9rNZMYe7MUSutnRmNyv4VseddqJSpr4MvDrQVxgVOfq8XccrfIqOao pm1RbNt6O4wq3DOHHGPKNiVgmrKLo0GXXRa+c3smnkdceWYzwBPLS6YMhJTinrpzLT30JdRma7N9W QdSIOuVL9rspiwmCSGqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWJF-00000006gP7-1jDr; Wed, 10 Apr 2024 11:40:09 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWJC-00000006gNL-1y24 for linux-arm-kernel@lists.infradead.org; Wed, 10 Apr 2024 11:40:08 +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 312A41480; Wed, 10 Apr 2024 04:40:32 -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 6E5B93F6C4; Wed, 10 Apr 2024 04:40:01 -0700 (PDT) From: Sudeep Holla Date: Wed, 10 Apr 2024 12:39:46 +0100 Subject: [PATCH 1/3] firmware: arm_ffa: Skip creation of the notification bitmaps MIME-Version: 1.0 Message-Id: <20240410-ffa_npi_support-v1-1-1a5223391bd1@arm.com> References: <20240410-ffa_npi_support-v1-0-1a5223391bd1@arm.com> In-Reply-To: <20240410-ffa_npi_support-v1-0-1a5223391bd1@arm.com> To: linux-arm-kernel@lists.infradead.org Cc: Marc Bonnici , Olivier Deprez , Lorenzo Pieralisi , Bertrand Marquis , Jens Wiklander , Sudeep Holla X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1919; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=yYE2AimCAKquv8X253zD5tNeVF9AH66uvZSRJabNqIM=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmFnqPZpBEmcHhE5lKgy/AqXZ8Q7NUDM/B81Vvd ZP/HhylzyCJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZhZ6jwAKCRAAQbq8MX7i mGj4D/93Vq7ZXpKnECeCcQF2j1T/xqRunE6E18GdyEYJdICVn3h5cDHKsfkkK6obEq+USFU0OWf iy97gb+uVidAMUOPJrWHRqS71iLm3qa2H1mHIXY0kwZc2a4YRug8uFcb4oGSVOUAbL+SfjWVBYT q2Iv8X76hQSoHMxTH9VWP9q9+2+uKUmLWuy+e/O36L+HULC9Eugj223p2qxLodX4dg+fehFNU/s jZNUTcD67SOQgAUJPmnHsRLmGdE94drMjJwEhREXZydopgvUReFM1vBahH5deB1Tw4iiRmZa1jK Z04dBfU/LaCNfNh0eBYznDmrpum3Zik/V6T+YIar4BujT+8WTghTJI3Ae2ad2jow7PAIxjns+fD upSErhCmf7JQjx/Sa6a7Cgrjr88bGmdTGcXqC0nAY1n4Dw78cXBRr7MVbzov+bADY7BRF0QDi8q GSwgeX+4dZrSMUalUzilvPIzkyHMJCWkykVIy9qxueRp8Blky1sxw7hYh93lEZeSPBVEXH4u18M uN8cLHyRDL/2m8M3aHZ7kFEZtAduxxByTnPIch+RU5ibTOsYkBVQdRFeo3xPTQ+hu0QC5xhv7Q6 UKDIKU37k0f5ow0YVBO+XG7sjyICulkiOClHyrUeOloF5wVTjRrRmdBrh6Nts8x2XdoFYMmPLjx KKMbgeWwztawLOQ== 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-20240410_044006_700984_22F7E840 X-CRM114-Status: GOOD ( 12.07 ) 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 From: Jens Wiklander When the FF-A driver is running inside a guest VM under an hypervisor, the driver/guest VM doesn't have the permission/capability to request the creation of notification bitmaps. For a VM, the hypervisor reserves memory for its VM and hypervisor framework notification bitmaps and the SPMC reserves memory for its SP and SPMC framework notification bitmaps before the hypervisor initializes it. The hypervisor does not initialize a VM if memory cannot be reserved for all its notification bitmaps. So the creation of all the necessary bitmaps are already done when the driver initialises and hence it can be skipped. We rely on FFA_FEATURES(FFA_NOTIFICATION_BITMAP_CREATE) to fail when running in the guest to handle this in the driver. Signed-off-by:Jens Wiklander [sudeep.holla: Updated the commit message] Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index f2556a8e9401..4a576af7b8fd 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1442,17 +1442,15 @@ static void ffa_notifications_setup(void) int ret, irq; ret = ffa_features(FFA_NOTIFICATION_BITMAP_CREATE, 0, NULL, NULL); - if (ret) { - pr_info("Notifications not supported, continuing with it ..\n"); - return; - } + if (!ret) { + ret = ffa_notification_bitmap_create(); + if (ret) { + pr_info("Notification bitmap create error %d\n", ret); + return; + } - ret = ffa_notification_bitmap_create(); - if (ret) { - pr_info("Notification bitmap create error %d\n", ret); - return; + drv_info->bitmap_created = true; } - drv_info->bitmap_created = true; irq = ffa_sched_recv_irq_map(); if (irq <= 0) { From patchwork Wed Apr 10 11:39:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13624128 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 7524BCD11C2 for ; Wed, 10 Apr 2024 11:40:29 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LDH8KAVH2HjONTFzRGQvEPAbRRRCzBgL059/v304Fkw=; b=1YvSC5wXSzmDbQ UQTtlrxDqf7yhz7b16Eksy2FmGGjJ2lyb3M9SVY6PTUfV5z/XcHt5vDvjM00zwLgsMHZo/+eUYU6J W4JnDlQ5ipPQVIuLYgQyNrmBUSOwXnGMaxPy6WI++L1rwYEO7V35w+a4rmGzBcfCWA/nt/j0viZwU ipqGMEAGq2OtMdVTVR6zHFlGbmEF5Yxbd3m80yRz7+BiNui7YgJcY0HDJOypTmZI2CGk19Xh267mZ jbfAGPfQxADf7xKKhdNz7d6C7e9YBXR0WXybopqhNGCpHnaImWjR1gOhNnXNiNMDZtVd9UzL1b86d lcBeCXTEtEoNyc3MNUOQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWJN-00000006gRy-2H8O; Wed, 10 Apr 2024 11:40:17 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWJC-00000006gNQ-25AA for linux-arm-kernel@lists.infradead.org; Wed, 10 Apr 2024 11:40:09 +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 486321595; Wed, 10 Apr 2024 04:40:33 -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 860B63F6C4; Wed, 10 Apr 2024 04:40:02 -0700 (PDT) From: Sudeep Holla Date: Wed, 10 Apr 2024 12:39:47 +0100 Subject: [PATCH 2/3] firmware: arm_ffa: Rename the references to SRI to include NPI MIME-Version: 1.0 Message-Id: <20240410-ffa_npi_support-v1-2-1a5223391bd1@arm.com> References: <20240410-ffa_npi_support-v1-0-1a5223391bd1@arm.com> In-Reply-To: <20240410-ffa_npi_support-v1-0-1a5223391bd1@arm.com> To: linux-arm-kernel@lists.infradead.org Cc: Marc Bonnici , Olivier Deprez , Lorenzo Pieralisi , Bertrand Marquis , Jens Wiklander , Sudeep Holla X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4747; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=RYDS53McaJkVRqrNrlYk3FHNqmglBrU65hzxtjX3i3c=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmFnqP5ZYYLQ3TQ3p4K1GEBJfpHFu+Qqd2elL76 7KYSwRCBpKJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZhZ6jwAKCRAAQbq8MX7i mJIdEACfskFudMVmmuKdfMBkWhkcMjl5vou3nBjTouuBpmCU6l5DPNHQ1+3leU9N4IuSkZtXFX/ +b2ltDkYqcSrr5P9BW6hY3DsGiPUt7l1rnN3oLOV9rArNGz6h72ygsCgkOiwvquNea4wgoOrrFV A2ALKYyAQPNmDPHcNA8calYjMZzsstNjNwZN0YvJ0+6tvmCg/ioE2fiN9dk/LM5Asb4kDpZeOPR DfFQWEfDZ964BRiFL1B6Y0VBVFSSuMF6h+Lnu+2VoVFDrruFVEDEz9bThqPMQNvEiECxcXPtoIE EcBbnijL50pxzu7Zmy8TK/D1y+Af/kXJqZiAfueGoJKtXhrgHVg1NHxHLvMpN0nt6NijVFzxEJ9 jpgb56sxMLSLV/iytHE6V1kLc8jnCnbVKvivJa0C+NGunYYjmX79UOR6YCJq1KVSo/eCYifUo/k 8dUyYFIc/tYvX55kFwjXMVVUJYmOrd1IB+0O3ju+5WArtUq0U2hrbMriZErs1i2gjD2nYY/sWOa xDER6qlrCxuiEfmX4BRRI5xbnVlVbDodcWeNgtwqQuqjae2d60bLK+CEFL40kctjR9RwcNNwwBg XhSymnJ8K3qJbd3DyHEPLxApNacrqXebuCpCxZ/qZjSKM3UZufkvmfKplmplajH+/GB8eqEpL/D 6vPc0WmaEsRlCNA== 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-20240410_044006_699891_746062EC X-CRM114-Status: GOOD ( 17.22 ) 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 In preparation to support handling of Notification Pending Interrupt(NPI) in addition to the existing support for Schedule Reciever Interrupt(SRI), rename all the references to SRI to reflect that it can be either SRI or NRI. This change is just cosmetic and doesn't impact any features yet. It also doesn't add the support for NPIs yet. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 41 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 4a576af7b8fd..c299cb9e6889 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -100,7 +100,8 @@ struct ffa_drv_info { bool mem_ops_native; bool bitmap_created; bool notif_enabled; - unsigned int sched_recv_irq; + /* Schedule Receiver(SRI) or Notification pending interrupt(NPI) */ + unsigned int sr_or_np_irq; unsigned int cpuhp_state; struct ffa_pcpu_irq __percpu *irq_pcpu; struct workqueue_struct *notif_pcpu_wq; @@ -1291,7 +1292,7 @@ static void ffa_partitions_cleanup(void) #define FFA_FEAT_SCHEDULE_RECEIVER_INT (2) #define FFA_FEAT_MANAGED_EXIT_INT (3) -static irqreturn_t irq_handler(int irq, void *irq_data) +static irqreturn_t sri_handler(int irq, void *irq_data) { struct ffa_pcpu_irq *pcpu = irq_data; struct ffa_drv_info *info = pcpu->info; @@ -1306,12 +1307,12 @@ static void ffa_sched_recv_irq_work_fn(struct work_struct *work) ffa_notification_info_get(); } -static int ffa_sched_recv_irq_map(void) +static int ffa_sr_or_np_irq_map(void) { - int ret, irq, sr_intid; + int ret, irq, intr_id; - /* The returned sr_intid is assumed to be SGI donated to NS world */ - ret = ffa_features(FFA_FEAT_SCHEDULE_RECEIVER_INT, 0, &sr_intid, NULL); + /* The returned intr_id is assumed to be SGI donated to NS world */ + ret = ffa_features(FFA_FEAT_SCHEDULE_RECEIVER_INT, 0, &intr_id, NULL); if (ret < 0) { if (ret != -EOPNOTSUPP) pr_err("Failed to retrieve scheduler Rx interrupt\n"); @@ -1329,12 +1330,12 @@ static int ffa_sched_recv_irq_map(void) oirq.np = gic; oirq.args_count = 1; - oirq.args[0] = sr_intid; + oirq.args[0] = intr_id; irq = irq_create_of_mapping(&oirq); of_node_put(gic); #ifdef CONFIG_ACPI } else { - irq = acpi_register_gsi(NULL, sr_intid, ACPI_EDGE_SENSITIVE, + irq = acpi_register_gsi(NULL, intr_id, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH); #endif } @@ -1347,23 +1348,23 @@ static int ffa_sched_recv_irq_map(void) return irq; } -static void ffa_sched_recv_irq_unmap(void) +static void ffa_sr_or_np_irq_unmap(void) { - if (drv_info->sched_recv_irq) { - irq_dispose_mapping(drv_info->sched_recv_irq); - drv_info->sched_recv_irq = 0; + if (drv_info->sr_or_np_irq) { + irq_dispose_mapping(drv_info->sr_or_np_irq); + drv_info->sr_or_np_irq = 0; } } static int ffa_cpuhp_pcpu_irq_enable(unsigned int cpu) { - enable_percpu_irq(drv_info->sched_recv_irq, IRQ_TYPE_NONE); + enable_percpu_irq(drv_info->sr_or_np_irq, IRQ_TYPE_NONE); return 0; } static int ffa_cpuhp_pcpu_irq_disable(unsigned int cpu) { - disable_percpu_irq(drv_info->sched_recv_irq); + disable_percpu_irq(drv_info->sr_or_np_irq); return 0; } @@ -1379,8 +1380,8 @@ static void ffa_uninit_pcpu_irq(void) drv_info->notif_pcpu_wq = NULL; } - if (drv_info->sched_recv_irq) - free_percpu_irq(drv_info->sched_recv_irq, drv_info->irq_pcpu); + if (drv_info->sr_or_np_irq) + free_percpu_irq(drv_info->sr_or_np_irq, drv_info->irq_pcpu); if (drv_info->irq_pcpu) { free_percpu(drv_info->irq_pcpu); @@ -1402,7 +1403,7 @@ static int ffa_init_pcpu_irq(unsigned int irq) drv_info->irq_pcpu = irq_pcpu; - ret = request_percpu_irq(irq, irq_handler, "ARM-FFA", irq_pcpu); + ret = request_percpu_irq(irq, sri_handler, "ARM-FFA-SRI", irq_pcpu); if (ret) { pr_err("Error registering notification IRQ %d: %d\n", irq, ret); return ret; @@ -1428,7 +1429,7 @@ static int ffa_init_pcpu_irq(unsigned int irq) static void ffa_notifications_cleanup(void) { ffa_uninit_pcpu_irq(); - ffa_sched_recv_irq_unmap(); + ffa_sr_or_np_irq_unmap(); if (drv_info->bitmap_created) { ffa_notification_bitmap_destroy(); @@ -1452,13 +1453,13 @@ static void ffa_notifications_setup(void) drv_info->bitmap_created = true; } - irq = ffa_sched_recv_irq_map(); + irq = ffa_sr_or_np_irq_map(); if (irq <= 0) { ret = irq; goto cleanup; } - drv_info->sched_recv_irq = irq; + drv_info->sr_or_np_irq = irq; ret = ffa_init_pcpu_irq(irq); if (ret) From patchwork Wed Apr 10 11:39:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13624127 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 1FB6CCD128A for ; Wed, 10 Apr 2024 11:40:29 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qKggTccfub7T1G1oXm2MYcgTawwQQsWJyy0aSD2TNSI=; b=2ZfHU7vwkk1Lfi h3RoEDL0QTS8WGdQF5bU/AlAUl10NG/nCv/mTHsI1xug/JpL86nICAIsT6bOEDxcmB4b5NBFRUiEO p9npZcNLRUZ4VQEMKtGxQwcATzBn5iuqLOs/vWkdRbsUaVDanqF/PrDKnCH/NlCoVOPoDj6wxdTqX +iW0UrS06hImOHWZ2J2EIpnFikDxBYbz2ifEEnZBq9pEt+RrAI74zEAF8RNLciTChW3i3t8c/3hOO 4XIl4ysAl8fKyfhIJPjWE4w58PLnUPj5sBa1r/sdqWIEsTgPD5Zbuc8SXA0dXSlXGwKLP/stgqWWK eApbbIGi9gBN6riMA1wA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWJO-00000006gSL-27uH; Wed, 10 Apr 2024 11:40:18 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWJC-00000006gNT-49OX for linux-arm-kernel@lists.infradead.org; Wed, 10 Apr 2024 11:40:09 +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 5F99C1596; Wed, 10 Apr 2024 04:40:34 -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 9D6643F6C4; Wed, 10 Apr 2024 04:40:03 -0700 (PDT) From: Sudeep Holla Date: Wed, 10 Apr 2024 12:39:48 +0100 Subject: [PATCH 3/3] firmware: arm_ffa: Add support for handling notification pending interrupt(NPI) MIME-Version: 1.0 Message-Id: <20240410-ffa_npi_support-v1-3-1a5223391bd1@arm.com> References: <20240410-ffa_npi_support-v1-0-1a5223391bd1@arm.com> In-Reply-To: <20240410-ffa_npi_support-v1-0-1a5223391bd1@arm.com> To: linux-arm-kernel@lists.infradead.org Cc: Marc Bonnici , Olivier Deprez , Lorenzo Pieralisi , Bertrand Marquis , Jens Wiklander , Sudeep Holla X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4124; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=oaerHtW21WfH1I6iThYJxby/im1n07tjFTafbtiE+Ik=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmFnqQrId4d0/yt6FTDUc034kkgJIGD0IY8LYbE t40sML0gnWJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZhZ6kAAKCRAAQbq8MX7i mNlxD/44eGcCcMuYRClaDDp44vwtnl//dIyjsFQZY07T6q8ts8cVx4aUH6uFp3VVozqyfLmspRV o3cbIzhV8LvrV2cKRt1UhGZTySwQqp0nAGmBX7dAwXwcC3kt4sBmUSeqzA6jEqKE9eg89IsM74o xmNvcVv51rzO+8QzLxnrwpkatWSAwrH5zakh/QTtmrc56iV/6Uafq36JxwlGHBMrRFVFs9PK7xf UPZZ1QQyC0H/KUOa31j3OKjLOQzwc45gw5waw9431xbaUN1CGQfQas/dhgvrjTUalQweVtGcgUL j1FgfIE0fqqZgbOCi6OGW5ojbyACmoVKVwOGGzFFXbYm8sPvtdtiDL4b3KTbbjSmfsgN66yIsdi 7hpy5pM0O2gze5jLRGlMfS2rSt/Dg3kGZfexOQ52aokLPPeT29YyQuXlrkzKYOovPqSoxLjg/R7 fWhdwWg9KpT53X4NKd1HYGyBK2q9I5cKdY/+CKmH41nSMcflBDrVxUpgEg2ftvIhXkMiEGJy5VL 6mEgTu6rnoUZzTx3gXxRnNxbGh8jKMkcN0i01vfP/ig3nFrS7kC42Ft4N8aAIiw4IVBtPJEtknB RV+ikDkoBb4bhcsUNTxX5lgchNkhyXO67CjUYxzko9zA/Pljv5OyOKeoX49rUetZz0mgPlpS8zb RFfIN5sw0TD64WA== 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-20240410_044007_258851_FF5A8A8A X-CRM114-Status: GOOD ( 18.40 ) 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 FF-A uses the notification pending interrupt to inform the receiver that it has a pending notification. This is a virtual interrupt and is used by the following type of receivers: 1. A guest/VM running under a hypervisor. 2. An S-EL1 SP running under a S-EL2 SPMC. The rules that govern the properties of the NPI are the same as the rules for the SRI with couple of exceptions. If the SRI is not supported, then an attempt to discover NPI will be made in the driver. The handling of NPI is also same as the handling of notification for the self/primary VM with ID 0 except the absence of global notification. Co-Developed-by: Jens Wiklander Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 43 +++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index c299cb9e6889..d50b41a815b9 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -100,6 +100,8 @@ struct ffa_drv_info { bool mem_ops_native; bool bitmap_created; bool notif_enabled; + /* Flag to indicate it is Notification pending interrupt */ + bool irq_is_npi; /* Schedule Receiver(SRI) or Notification pending interrupt(NPI) */ unsigned int sr_or_np_irq; unsigned int cpuhp_state; @@ -1138,6 +1140,15 @@ ffa_self_notif_handle(u16 vcpu, bool is_per_vcpu, void *cb_data) &info->notif_pcpu_work); } +static irqreturn_t npi_handler(int irq, void *irq_data) +{ + struct ffa_pcpu_irq *pcpu = irq_data; + + ffa_self_notif_handle(smp_processor_id(), true, pcpu->info); + + return IRQ_HANDLED; +} + static const struct ffa_info_ops ffa_drv_info_ops = { .api_version_get = ffa_api_version_get, .partition_info_get = ffa_partition_info_get, @@ -1307,16 +1318,24 @@ static void ffa_sched_recv_irq_work_fn(struct work_struct *work) ffa_notification_info_get(); } -static int ffa_sr_or_np_irq_map(void) +static int ffa_sr_or_np_irq_map(bool *irq_is_npi) { int ret, irq, intr_id; /* The returned intr_id is assumed to be SGI donated to NS world */ ret = ffa_features(FFA_FEAT_SCHEDULE_RECEIVER_INT, 0, &intr_id, NULL); - if (ret < 0) { - if (ret != -EOPNOTSUPP) - pr_err("Failed to retrieve scheduler Rx interrupt\n"); + if (ret && ret != -EOPNOTSUPP) { + pr_err("Failed to retrieve scheduler Rx interrupt\n"); return ret; + } else if (ret) { + ret = ffa_features(FFA_FEAT_NOTIFICATION_PENDING_INT, 0, + &intr_id, NULL); + if (ret) { + if (ret != -EOPNOTSUPP) + pr_err("Failed to retrieve notification pending interrupt\n"); + return ret; + } + *irq_is_npi = true; } if (acpi_disabled) { @@ -1389,7 +1408,7 @@ static void ffa_uninit_pcpu_irq(void) } } -static int ffa_init_pcpu_irq(unsigned int irq) +static int ffa_init_pcpu_irq(void) { struct ffa_pcpu_irq __percpu *irq_pcpu; int ret, cpu; @@ -1403,9 +1422,15 @@ static int ffa_init_pcpu_irq(unsigned int irq) drv_info->irq_pcpu = irq_pcpu; - ret = request_percpu_irq(irq, sri_handler, "ARM-FFA-SRI", irq_pcpu); + if (drv_info->irq_is_npi) + ret = request_percpu_irq(drv_info->sr_or_np_irq, npi_handler, + "ARM-FFA-NPI", irq_pcpu); + else + ret = request_percpu_irq(drv_info->sr_or_np_irq, sri_handler, + "ARM-FFA-SRI", irq_pcpu); if (ret) { - pr_err("Error registering notification IRQ %d: %d\n", irq, ret); + pr_err("Error registering NPI/SRI IRQ %d: %d\n", + drv_info->sr_or_np_irq, ret); return ret; } @@ -1453,7 +1478,7 @@ static void ffa_notifications_setup(void) drv_info->bitmap_created = true; } - irq = ffa_sr_or_np_irq_map(); + irq = ffa_sr_or_np_irq_map(&drv_info->irq_is_npi); if (irq <= 0) { ret = irq; goto cleanup; @@ -1461,7 +1486,7 @@ static void ffa_notifications_setup(void) drv_info->sr_or_np_irq = irq; - ret = ffa_init_pcpu_irq(irq); + ret = ffa_init_pcpu_irq(); if (ret) goto cleanup;