From patchwork Thu Apr 11 12:57:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13625941 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 4536FCD1299 for ; Thu, 11 Apr 2024 12:58:09 +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=ZXFrXWzQVb/grz57qLl4L3fOJl20iVfWsBquxoou+Ys=; b=AxQvCowUOa0+ES lbKeEU4WUM0ByOS9PcyAqAhKETQ9/B6SJfHHAGymyrun4rXEctAy/H1WSME6kV2ZFub0ElAz6O8mu xj9DtSOflD5Rg6xG+CLa0/pgQkyWpgEZKHLo/Po12Majf/kTtn0HCN6ksZ7tlZ22O4UglBGg9mZqq MUBOj/drQIcs/JGub7dUZF6L2r2UDlQ8bQjIlMxmjoaA/Hr3W6ZcWsWv+MuNKmnGKRySBDhymdWT8 xVkxQ5QccRHkDcH69/T2QN6VLIKnM0HGB/oZNHu5lUuE3AtuThPb0hX9Mf/IhAEmHrTY0m26L01gt FnrXG/bXdoLDQesPIzPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruu03-0000000C2hF-1tIR; Thu, 11 Apr 2024 12:57:55 +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 1rutzy-0000000C2eb-0iDV for linux-arm-kernel@lists.infradead.org; Thu, 11 Apr 2024 12:57:51 +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 EADCB1596; Thu, 11 Apr 2024 05:58:16 -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 8BEE83F64C; Thu, 11 Apr 2024 05:57:46 -0700 (PDT) From: Sudeep Holla Date: Thu, 11 Apr 2024 13:57:33 +0100 Subject: [PATCH v2 2/3] firmware: arm_ffa: Refactor SRI handling in prepartion to add NPI support MIME-Version: 1.0 Message-Id: <20240411-ffa_npi_support-v2-2-927a670254e6@arm.com> References: <20240411-ffa_npi_support-v2-0-927a670254e6@arm.com> In-Reply-To: <20240411-ffa_npi_support-v2-0-927a670254e6@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=4797; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=YkB4WStiavLKbfkF66XQA+E56jOJurekZRpAQYR/JBY=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmF95HWcVrAH5wJsCTe9iJZ49Hg1VJ8LPxQh/Jy 6cbes64/KGJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZhfeRwAKCRAAQbq8MX7i mNGLEACFGgmAQlIY89a2gCkbSx1OsXO8NGMZ0rmXjiaoJ0HR1hmpryE9XABMTR9wNyTlMF/+1cf eGzPqKdvQTZe1LcIAsMXG8Z02e3C9l/S2rA+ZhUVAQPGZO63kgQbzmgVhK3hQoGPj9hlt9xZU/w JVyAvmnuUU/MEFzqbMyNlAqO2miEvlkCyItki8oD9T6ZaDcr2ROH/+TTWKgaaBfIq7jsyuBOJg6 qFRQwU1m3kbHkiOl9qX4Ay88SF1RWKxlhr9qvAvZttRE4DSKH7fO5HmgvGiBr8z7h/NVNM1HSZn q8rAhY10CNkN1O6D89LdBQPMQKsJduQZk+pp8z9uwrJKI0V5hgul9K5BvFnCDZcpHnrBz+9DBdw sEUieGWa5hVkb/U1gz7EuXlKjtqlVSdyID87kbALTFhpUDy3pkZfT68zg4C8y3d+MnFQ6EO9fFL bXfRWSZz6EVlrJN7iKX+gTRFL/0CyY6fu8CYzqQ3Ja6cmf1LXCg3jeEdu0JgtnORUGMVEJNXm70 L4eYMhZc6BGEs3fyuCl+slMypiD9Fha9wgmlpOgAwv7SgtA0hMpYMcOieFSlbuIaVozJzcm5YrD C5XPU2Hl8OT+7ArmxwNzc/QmayOiZontTH/1Dl0QSdYCqYyYFgcCGp9FV05CbpXgaXiDIS2Xlsl r/eR13j3ahlfg9w== 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-20240411_055750_329803_46D93DB7 X-CRM114-Status: GOOD ( 15.94 ) 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), refactor the code around SRI handling so that NPI support can reuse some of it. This change shouldn't have any functionality impact. It neither adds the support for NPIs nor changes any SRI support. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 47 +++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 4a576af7b8fd..1ef5d6752c35 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -105,7 +105,7 @@ struct ffa_drv_info { struct ffa_pcpu_irq __percpu *irq_pcpu; struct workqueue_struct *notif_pcpu_wq; struct work_struct notif_pcpu_work; - struct work_struct irq_work; + struct work_struct sched_recv_irq_work; struct xarray partition_info; DECLARE_HASHTABLE(notifier_hash, ilog2(FFA_MAX_NOTIFICATIONS)); struct mutex notify_lock; /* lock to protect notifier hashtable */ @@ -1291,12 +1291,12 @@ 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 ffa_sched_recv_irq_handler(int irq, void *irq_data) { struct ffa_pcpu_irq *pcpu = irq_data; struct ffa_drv_info *info = pcpu->info; - queue_work(info->notif_pcpu_wq, &info->irq_work); + queue_work(info->notif_pcpu_wq, &info->sched_recv_irq_work); return IRQ_HANDLED; } @@ -1306,15 +1306,23 @@ 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_irq_map(u32 id) { - int ret, irq, sr_intid; + char *err_str; + int ret, irq, intid; - /* 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); + if (id == FFA_FEAT_NOTIFICATION_PENDING_INT) + err_str = "Notification Pending Interrupt"; + else if (id == FFA_FEAT_SCHEDULE_RECEIVER_INT) + err_str = "Schedule Receiver Interrupt"; + else + err_str = "Unknown ID"; + + /* The returned intid is assumed to be SGI donated to NS world */ + ret = ffa_features(id, 0, &intid, NULL); if (ret < 0) { if (ret != -EOPNOTSUPP) - pr_err("Failed to retrieve scheduler Rx interrupt\n"); + pr_err("Failed to retrieve FF-A %s %u\n", err_str ,id); return ret; } @@ -1329,12 +1337,12 @@ static int ffa_sched_recv_irq_map(void) oirq.np = gic; oirq.args_count = 1; - oirq.args[0] = sr_intid; + oirq.args[0] = intid; 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, intid, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH); #endif } @@ -1347,12 +1355,11 @@ static int ffa_sched_recv_irq_map(void) return irq; } -static void ffa_sched_recv_irq_unmap(void) +static void ffa_irq_unmap(unsigned int irq) { - if (drv_info->sched_recv_irq) { - irq_dispose_mapping(drv_info->sched_recv_irq); - drv_info->sched_recv_irq = 0; - } + if (!irq) + return; + irq_dispose_mapping(irq); } static int ffa_cpuhp_pcpu_irq_enable(unsigned int cpu) @@ -1402,13 +1409,14 @@ 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, ffa_sched_recv_irq_handler, "ARM-FFA-SRI", + irq_pcpu); if (ret) { pr_err("Error registering notification IRQ %d: %d\n", irq, ret); return ret; } - INIT_WORK(&drv_info->irq_work, ffa_sched_recv_irq_work_fn); + INIT_WORK(&drv_info->sched_recv_irq_work, ffa_sched_recv_irq_work_fn); INIT_WORK(&drv_info->notif_pcpu_work, notif_pcpu_irq_work_fn); drv_info->notif_pcpu_wq = create_workqueue("ffa_pcpu_irq_notification"); if (!drv_info->notif_pcpu_wq) @@ -1428,7 +1436,8 @@ 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_irq_unmap(drv_info->sched_recv_irq); + drv_info->sched_recv_irq = 0; if (drv_info->bitmap_created) { ffa_notification_bitmap_destroy(); @@ -1452,7 +1461,7 @@ static void ffa_notifications_setup(void) drv_info->bitmap_created = true; } - irq = ffa_sched_recv_irq_map(); + irq = ffa_irq_map(FFA_FEAT_SCHEDULE_RECEIVER_INT); if (irq <= 0) { ret = irq; goto cleanup;