From patchwork Thu Apr 18 10:29:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13634485 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 46C64C4345F for ; Thu, 18 Apr 2024 10:29:52 +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: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:In-Reply-To:References: List-Owner; bh=NbGnZASPefAhiQcw3YW+Keiv+4Svx6nzurt3ujcrL1Y=; b=SDSxyyj9h89lw3 mTi07Zvod7jRJJXVZozXp5F1mGGCe4BkbZxsmV3FC9vB8tLE5hAkuCINFf1YDfMeD7QiRbqoWbmQc UNPQiZjD68U93U3tcKGkLuNppdYW6q4LCgG/HU2N22J+YN0wITF4xUPNLVFYlk3K0LgVzM2vxstrh gK3mJLj/mepi2dPcI7MZMB2qOQu2Cy4i1YQ/naigneT1vE6gpyZLvCz5XRvpCr7p0CMtSC5z9v3EY rq+LPxh4k7Om6k4xiHXP6sEbCa4GH7NDbjFcbQoSwEYH8CPFRHwUL93S4umko4b4KQ423QERJmay5 raTLpYFPYDaIONKGEsPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxP1Q-00000001o9r-3N3t; Thu, 18 Apr 2024 10:29:40 +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 1rxP1N-00000001o9J-3QB3 for linux-arm-kernel@lists.infradead.org; Thu, 18 Apr 2024 10:29:38 +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 6187A339; Thu, 18 Apr 2024 03:30:04 -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 0DB083F64C; Thu, 18 Apr 2024 03:29:35 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Jens Wiklander Subject: [PATCH] firmware: arm_ffa: Fix kernel warning about incorrect SRI/NPI Date: Thu, 18 Apr 2024 11:29:32 +0100 Message-ID: <20240418102932.3093576-1-sudeep.holla@arm.com> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240418_032937_915745_5332D8BD X-CRM114-Status: GOOD ( 12.38 ) 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 If the firmware returns incorrect SRI/NRI number, we fail to set it up in the kernel which is absolutely fine. However, we don't reset the stashed value of sched_recv or notif_pend IRQs. When we call ffa_notifications_cleanup() in case of failures to setup the notifications, we end up calling free_percpu_irq() from ffa_uninit_pcpu_irq() which results in the following warning: | genirq: Flags mismatch irq 6. 00004401 (ARM-FFA-NPI) vs. 00004400 (IPI) | ARM FF-A: Error registering percpu NPI nIRQ 6 : -16 | ARM FF-A: Notification setup failed -16, not enabled | ------------[ cut here ]------------ | Trying to free already-free IRQ 6 | WARNING: CPU: 2 PID: 1 at kernel/irq/manage.c:2476 __free_percpu_irq+0x6c/0x138 | Modules linked in: | CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.9.0-rc3 #211 | Hardware name: FVP Base RevC (DT) | pstate: 614000c9 (nZCv daIF +PAN -UAO -TCO +DIT -SSBS BTYPE=--) | pc : __free_percpu_irq+0x6c/0x138 | lr : __free_percpu_irq+0x6c/0x138 | Call trace: | __free_percpu_irq+0x6c/0x138 | free_percpu_irq+0x48/0x84 | ffa_notifications_cleanup+0x78/0x164 | ffa_notifications_setup+0x368/0x3c0 | ffa_init+0x2b4/0x36c | do_one_initcall+0xe0/0x258 | do_initcall_level+0x8c/0xac | do_initcalls+0x54/0x94 | do_basic_setup+0x1c/0x28 | kernel_init_freeable+0x108/0x174 | kernel_init+0x20/0x1a4 | ret_from_fork+0x10/0x20 Fix the same by resetting the stashed copy of IRQ values to 0 in case of any failure to set them up properly. Cc: Jens Wiklander Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 2 ++ 1 file changed, 2 insertions(+) Hi, I just rushed to officially respond to [1] as applied before testing it. Though this is issue with firmware, it exposed an issue in the cleanup path in the driver. Currently SPMC in hafnium returns 6 as NPI which is already used as IPI by the non-secure Linux world. Regards, Sudeep diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 018eddf40ca2..b64e8ee64bc2 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1435,6 +1435,7 @@ static int ffa_init_pcpu_irq(void) if (ret) { pr_err("Error registering percpu SRI nIRQ %d : %d\n", drv_info->sched_recv_irq, ret); + drv_info->sched_recv_irq = 0; return ret; } } @@ -1446,6 +1447,7 @@ static int ffa_init_pcpu_irq(void) if (ret) { pr_err("Error registering percpu NPI nIRQ %d : %d\n", drv_info->notif_pend_irq, ret); + drv_info->notif_pend_irq = 0; return ret; } }