From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.135 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796290231; b=ZhWQNUDFLJH3bGzQArbtFDRRveqIB7nZ1HR15MbwB8xECsUB/hsWvge9X6y86f7nP2qh DCyPO5Nory5kzTd8k83CKRQ6pit/WYqlfa5PGS6R0SgjuxSMjMBwOKHdcL1cZ6BZEbopp vU7qmcNPJvY1zdE0mYdWMGVvXo8Q13J2S/fCOkK8PgohEwNJiPqcqeRzxdlMveHn4OOpU iAsE+k2c/VbALSI/4yg5gr/jcBYvZrW/pjDs9nGs9zC2gFjS3SGS4F7rtBhL9bA0IAdy6 Cw+tpykb3xbikPOVkmfQiVBq7UmzH9j0iMBWJX5cLDw4hV+yWctXAsZGknkEhM6e0rQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796290231; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer; bh=jw9q5dFLY03hpPaGvaFbIpbQVXZdtMYVcciR+TGVdaQ=; b=SOO6Wtao11FwL98jjDZdlcx9ALiasnMi344zsAXvdQ07Am76inyOjj3puydyBjBMWvCv Oj7t7ReWM/K3D2i8pDuzC3AMFm6gO1WfCi0S9tF3GGAPvgXtzAabLqqdm+6BeqB+p8kQM TKiUSL/58wuN5f6V8fymwRWRDOPRCvaTV8rkxSu+exKjqS+jZouQRxvhHXjImW3DxWp1e IPDnj4nSFcVJOSLN3+iqYdnsY6Q+2ZedvtuOWrAsLkTnVXCbTQOQie7FE5hJe8f75S+Ib 7eDw0A9HPEd68Z43cziDWF+m+ULUqjMj6Xi7whEPOWYXwRbXW+1NGvUSNvOfyXlj8vg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=CHjEM1dh; arc=none smtp.remote-ip=91.218.175.135 Received: from mta0.migadu.com (out-135.mta0.migadu.com [91.218.175.135]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 409F6606A330 for ; Thu, 3 Dec 2026 09:30:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 409F6606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=CHjEM1dh X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=e9qB7n18W40E2+IJ4moAQbZTOfYAPTijUfGmryShYDE=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796290229; v=1; x=1796895029; b=CHjEM1dhCCagAFAiMYczjHsVKtlXtk3Abf1XaiYsDfKuX1QR2q2psJtEqgiPqIjlPlpO/lNc lFq4VDBkGWQTcOxDQx5sD6IScuYhPJ4FGr1VmjrF8J7IJaajhyu+0rTZmsFZtTQn53oaNFZYfgy qCIojMqBqK0BC+n04tYwNE+8= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 5b15bc5b97ad0ff5; Thu, 03 Dec 2026 09:30:26 +0000 X-Mizu-Trace-ID: 5b15bc5b97ad0ff5 X-Migadu-Flow: FLOW_OUT From: Peng Fan Date: Thu, 03 Dec 2026 17:29:20 +0800 Subject: [PATCH v2 8/8] irqchip/imx-intmux: Factor out imx_intmux_teardown_channel() X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261203-imx-intmux-v2-8-a6db1eed3b5f@nxp.com> References: <20261203-imx-intmux-v2-0-a6db1eed3b5f@nxp.com> In-Reply-To: <20261203-imx-intmux-v2-0-a6db1eed3b5f@nxp.com> To: Thomas Gleixner , Radu Rendec , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Shengjiu Wang , Marc Zyngier Cc: linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Peng Fan X-Mailer: b4 0.14.3 From: Peng Fan The per-channel teardown sequence (detach the chained handler, dispose all child IRQ mappings, dispose the parent mapping) is open-coded in both the probe error path and imx_intmux_remove(). Factor it out into imx_intmux_teardown_channel() so the two paths cannot diverge. The helper takes the driver data directly: probe only calls platform_set_drvdata() after the channel loop, so re-fetching it via platform_get_drvdata() would dereference NULL on the error path. No functional change. Signed-off-by: Peng Fan --- drivers/irqchip/irq-imx-intmux.c | 44 ++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c index eeba45f312be..cce21ac8c21d 100644 --- a/drivers/irqchip/irq-imx-intmux.c +++ b/drivers/irqchip/irq-imx-intmux.c @@ -200,6 +200,21 @@ static void imx_intmux_irq_handler(struct irq_desc *desc) generic_handle_domain_irq(irqchip_data->domain, pos); } +static void imx_intmux_teardown_channel(struct intmux_data *data, int i) +{ + /* + * Mask the parent interrupt and wait for a handler that is already + * running to finish before its handler data, chip and mappings are + * torn down. irq_dispose_mapping() installs no_irq_chip before its + * own synchronize_irq(), which loses the GIC active-state check. + */ + disable_irq(data->irqchip_data[i].irq); + irq_set_chained_handler_and_data(data->irqchip_data[i].irq, NULL, NULL); + for (unsigned int hwirq = 0; hwirq < 32; hwirq++) + irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain, hwirq)); + irq_dispose_mapping(data->irqchip_data[i].irq); +} + static int imx_intmux_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -290,20 +305,8 @@ static int imx_intmux_probe(struct platform_device *pdev) return 0; out: - while (i--) { - /* - * Mask the parent interrupt and wait for a handler that is - * already running to finish before its data and mappings are - * torn down. - */ - disable_irq(data->irqchip_data[i].irq); - irq_set_chained_handler_and_data(data->irqchip_data[i].irq, - NULL, NULL); - for (unsigned int hwirq = 0; hwirq < 32; hwirq++) - irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain, - hwirq)); - irq_dispose_mapping(data->irqchip_data[i].irq); - } + while (i--) + imx_intmux_teardown_channel(data, i); pm_runtime_disable(&pdev->dev); pm_runtime_put_noidle(&pdev->dev); err_disable_clk: @@ -324,18 +327,7 @@ static void imx_intmux_remove(struct platform_device *pdev) /* disable all interrupt sources of this channel */ if (ret >= 0) writel_relaxed(0, data->regs + CHANIER(i)); - /* - * Mask the parent interrupt and wait for a handler that is - * already running to finish before its data and mappings are - * torn down. - */ - disable_irq(data->irqchip_data[i].irq); - irq_set_chained_handler_and_data(data->irqchip_data[i].irq, - NULL, NULL); - for (unsigned int hwirq = 0; hwirq < 32; hwirq++) - irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain, - hwirq)); - irq_dispose_mapping(data->irqchip_data[i].irq); + imx_intmux_teardown_channel(data, i); } pm_runtime_disable(&pdev->dev); -- 2.56.0