From patchwork Tue Oct 24 10:56:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13434222 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 5A771C07545 for ; Tue, 24 Oct 2023 10:57: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=jyX3MMGBeNQJ1KqV3afVf1VvGRX4bdh4ZimxfiFUeqc=; b=HJYue+cWmt/Inc lypaJiGbtAFVupa82XsmzwGWw0JbECbhl+ZVnft59CM9KWPSl4WLRl4BW+Or3l/luRMMltoF5hcst gKBQPmq1QnwPMv6+BZp8qSUDbqvI9A6kFPcA50acXXxIrE1BK8eYOYkuEfOBJYNBYnZ7w+xhMC53L GB2slNDBbp+y4+LDGlz5LiuJhWeW2odwT4LEhQ1ELvZPCMudhbiSpwJBlVhXVuZl7RcCVTSXu/1LT ey3FEP2thpWIcBXQzoqSuN22djvJ9FBPRLuIzcFhZj83M1OqB967459743oxtgekEMoRvByMxK3C4 N1jLcLpxufT5Xr+AUh7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvF5V-009bM1-1Q; Tue, 24 Oct 2023 10:56:41 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvF5M-009bGF-0F for linux-arm-kernel@lists.infradead.org; Tue, 24 Oct 2023 10:56:34 +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 D1C7215BF; Tue, 24 Oct 2023 03:57:11 -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 106D03F64C; Tue, 24 Oct 2023 03:56:29 -0700 (PDT) From: Sudeep Holla Date: Tue, 24 Oct 2023 11:56:20 +0100 Subject: [PATCH 4/4] firmware: arm_ffa: Fix FFA notifications cleanup path MIME-Version: 1.0 Message-Id: <20231024-ffa-notification-fixes-v1-4-d552c0ec260d@arm.com> References: <20231024-ffa-notification-fixes-v1-0-d552c0ec260d@arm.com> In-Reply-To: <20231024-ffa-notification-fixes-v1-0-d552c0ec260d@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jens Wiklander , Coboy Chen , Lorenzo Pieralisi X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2084; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=//JpqRCTG6133GyveR4ek+FR3WO6FNVPAfl35AD8fYY=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlN6LZAKdF6iJn1GsMxaobrUC4sNzZJsjmewCVP gjo4REtbPeJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZTei2QAKCRAAQbq8MX7i mObpD/4mSWyNNXZefkniqBQplfV6ySTNlgWi/ZjEF3LgcqkTPQ2IHYYUaJksssKwZCgiHaRWRt7 859lkifjOHGoqD+ndW9Ty+beHUyBZUEpr3NXikQEzSQQJBOjtXfK1pRiWoLHS6yppWa49XUx6CO o6HSA7AZZ88K/Gvui5yjjsHWnrveR+JjK1VTHQp4AN4YkrQJdNKLsxSaHX9RZAKbbtyYXK7c4XF Ya/jcFlV5ddHoRxy64ATyLq32XNYidYFQkwkdNljayIt/CsJTv83BHIxvysdCtmrGKL0w1skTVU acAeMcueb8M86oMhcPnWmSezEm+eQOuc/kN/k5vZEh/B5gkiJADmovLQ7wDkwbXYlaDu0EH/ody T+s/6Xm+AP6NrVU04y5EN9+Ua4zOek9haZ+4nHGePdMgeHAIpnguer9aet1YJHRvRKmGHbNH4vW Y8fwW+5pkeOiTbv3zVd/k+rk3o1FBnj2186MMLVuI4yEdTxD/xcIES1/N65Vp2g/97/Wo41o5Ab DL25Gd1mHGBkVGdvJYbIQtChqClYVMLDvxME6xAb6uCAbyF3XvJQR5RMGGaGeCqEji0vjx7eJG8 X527nLjYmcW4iKPmYkIIHjiY76YH+IctvETObLcDpqevYQwVq4eGxCSBa8sEBdA3jCG3imLK4tw VAoNnN0LsdysdiQ== 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-20231024_035632_209372_671E989C X-CRM114-Status: GOOD ( 11.34 ) 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 We allow the FF-A to be initialised successfully even when notification fails. When the notification fails, ffa_notifications_cleanup() gets called on the failure path. However, the driver information about the notifications like the irq, workqueues and cpu hotplug state for enabling and disabling percpu IRQ are not cleared. This may result in unexpected behaviour during CPU hotplug because of percpu IRQ being enabled and disabled or during the driver removal when ffa_notifications_cleanup() gets executed again. Fix the FFA notifications cleanup path by clearing all the notification related driver information. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index b097452597a2..e636181694aa 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1326,8 +1326,10 @@ static int ffa_sched_recv_irq_map(void) static void ffa_sched_recv_irq_unmap(void) { - if (drv_info->sched_recv_irq) + if (drv_info->sched_recv_irq) { irq_dispose_mapping(drv_info->sched_recv_irq); + drv_info->sched_recv_irq = 0; + } } static int ffa_cpuhp_pcpu_irq_enable(unsigned int cpu) @@ -1344,17 +1346,23 @@ static int ffa_cpuhp_pcpu_irq_disable(unsigned int cpu) static void ffa_uninit_pcpu_irq(void) { - if (drv_info->cpuhp_state) + if (drv_info->cpuhp_state) { cpuhp_remove_state(drv_info->cpuhp_state); + drv_info->cpuhp_state = 0; + } - if (drv_info->notif_pcpu_wq) + if (drv_info->notif_pcpu_wq) { destroy_workqueue(drv_info->notif_pcpu_wq); + 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->irq_pcpu) + if (drv_info->irq_pcpu) { free_percpu(drv_info->irq_pcpu); + drv_info->irq_pcpu = NULL; + } } static int ffa_init_pcpu_irq(unsigned int irq)