From nobody Fri Oct 3 08:51:12 2025 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77E8030499B for ; Wed, 3 Sep 2025 13:06:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756904787; cv=none; b=kywqc6IPQU/boGqte4z2a8e9BUaaZGKpjbhctYEYE3B4BJeZOgqroeXdprnJi8Or0uv/1oqjmeuJ0FjvED0OarShr2j7B42Kwr2p4JfjjE5c2OXWTGU1IdVA3itSHiuVRCfR2Ooc+zfS5f8xfqiwfNA1kJxzaZ10movoTwxWHXk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756904787; c=relaxed/simple; bh=ZSYgiNmAKV3p8BUF1bCLjSthybct+I4PA/kpVGiQY/I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c1AUPGNpG6lPctbGkVRFlBy7+fYkiuCQ8UFOmNBSDrjotgh4sTWwPkyyTWGtmyrKdiz2pHb1lBQkuGKSX1AG8lDFS3dFsHcIfR5pchG8c5VaW1NjXu6hvpIAkuAXRk3SGNHygMxtwzZNJ865o6/ekt7+cW5+i1xtal16BwJTbz0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from dude02.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::28]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1utnBl-00006Z-R7; Wed, 03 Sep 2025 15:06:13 +0200 From: Marco Felsch Date: Wed, 03 Sep 2025 15:06:14 +0200 Subject: [PATCH 06/11] dmaengine: imx-sdma: make use of devm_add_action_or_reset to unregiser the dma_device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250903-v6-16-topic-sdma-v1-6-ac7bab629e8b@pengutronix.de> References: <20250903-v6-16-topic-sdma-v1-0-ac7bab629e8b@pengutronix.de> In-Reply-To: <20250903-v6-16-topic-sdma-v1-0-ac7bab629e8b@pengutronix.de> To: Vinod Koul , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Jiada Wang Cc: dmaengine@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Marco Felsch X-Mailer: b4 0.14.2 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::28 X-SA-Exim-Mail-From: m.felsch@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Make use of the devm_add_action_or_reset() to register a custom devm_ release hook. This is required since we want to turn of the IRQs before doing the dma_async_device_unregister(). This removes the last goto error handling within the probe function and further trims the remove() function. Instead of freeing the irq, we can disable it and let the devm-irq do the job to free the irq, since the only purpose was to have the irqs disabled before calling dma_async_device_unregister(). Signed-off-by: Marco Felsch --- drivers/dma/imx-sdma.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 5a571d3f33158813e0c56484600a49b19a6a72e2..f6bb2f88a62781c0431336c365f= a30c46f1401ad 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -2232,6 +2232,14 @@ static struct dma_chan *sdma_xlate(struct of_phandle= _args *dma_spec, ofdma->of_node); } =20 +static void sdma_dma_device_unregister_action(void *data) +{ + struct sdma_engine *sdma =3D data; + + disable_irq(sdma->irq); + dma_async_device_unregister(&sdma->dma_device); +} + static int sdma_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; @@ -2358,10 +2366,12 @@ static int sdma_probe(struct platform_device *pdev) return ret; } =20 + devm_add_action_or_reset(dev, sdma_dma_device_unregister_action, sdma); + ret =3D of_dma_controller_register(np, sdma_xlate, sdma); if (ret) { dev_err(dev, "failed to register controller\n"); - goto err_register; + return ret; } =20 spba_bus =3D of_find_compatible_node(NULL, NULL, "fsl,spba-bus"); @@ -2388,11 +2398,6 @@ static int sdma_probe(struct platform_device *pdev) } =20 return 0; - -err_register: - dma_async_device_unregister(&sdma->dma_device); - - return ret; } =20 static void sdma_remove(struct platform_device *pdev) @@ -2400,8 +2405,6 @@ static void sdma_remove(struct platform_device *pdev) struct sdma_engine *sdma =3D platform_get_drvdata(pdev); int i; =20 - devm_free_irq(&pdev->dev, sdma->irq, sdma); - dma_async_device_unregister(&sdma->dma_device); /* Kill the tasklet */ for (i =3D 0; i < MAX_DMA_CHANNELS; i++) { struct sdma_channel *sdmac =3D &sdma->channel[i]; --=20 2.47.2