Re: [PATCH v6] i2c: imx: support DMA defer probing
From: Carlos Song <hidden>
Date: 2024-12-24 02:55:25
Also in:
imx, linux-i2c, lkml
-----Original Message----- From: Andi Shyti <andi.shyti@kernel.org> Sent: Tuesday, December 24, 2024 7:14 AM To: Carlos Song <redacted> Cc: o.rempel@pengutronix.de; kernel@pengutronix.de; shawnguo@kernel.org; s.hauer@pengutronix.de; festevam@gmail.com; linux-i2c@vger.kernel.org; imx@lists.linux.dev; linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; Clark Wang [off-list ref]; Ahmad Fatoum [off-list ref] Subject: [EXT] Re: [PATCH v6] i2c: imx: support DMA defer probing Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button Hi Carlos, ...quoted
@@ -1802,6 +1803,18 @@ static int i2c_imx_probe(struct platform_device*pdev)quoted
if (ret == -EPROBE_DEFER) goto clk_notifier_unregister; + /* As we can always fall back to PIO, let's ignore the error setting upDMA. */quoted
+ ret = i2c_imx_dma_request(i2c_imx, phy_addr); + if (ret) { + if (ret == -EPROBE_DEFER) + goto clk_notifier_unregister; + else if (ret == -ENODEV) + dev_dbg(&pdev->dev, "Only use PIO mode\n"); + else + dev_err(&pdev->dev, "Failed to setup DMA (%pe),only use PIO mode\n",quoted
+ ERR_PTR(ret));My question here is not just about the use of dev_err vs dev_err_probe, but why don't we exit the probe if we get an error. We should use PIO only in case of ENODEV, in all the other cases I think we should just leave. E.g. why don't we exit if we meet ret == -ENOMEM?
Hi, Andi Thank you! From my point, I2C is critical bus so it should be available as much as possible. -ENOMEM or other unknown errors all are from i2c_imx_dma_request(). So error happened in enable DMA mode process. As I comment at previous mail[1]: DMA mode should be optional for i2c-imx[2], i2c-imx can accept DMA mode not enabled. Even though DMA mode can not be enabled by some known/unknown issue, I2C still can work in PIO mode in all time for all cases. As a result, don't exit the I2C probe and only print error to show i2c DMA error. This patch just is used to make i2c-imx can support defer probe to use DMA resources as much as possible. If meet a DMA error then exit i2c probe, which means binding I2C to DMA, this is not what we expect. Once the DMA encounters a problem, the entire I2C bus and peripherals will not be able to start, this is not a small damage, so we use current logic. [1]: https://lore.kernel.org/imx/AM0PR0402MB39374E34FD6133B5E3D414D7E82F2@AM0PR0402MB3937.eurprd04.prod.outlook.com/ (local) [2]: commit ce1a78840ff7ab846065d5b65eaac959bafe1949 Author: Yao Yuan [off-list ref] Date: Tue Nov 18 18:31:06 2014 +0800 i2c: imx: add DMA support for freescale i2c driver Add dma support for i2c. This function depend on DMA driver. You can turn on it by write both the dmas and dma-name properties in dts node. DMA is optional, even DMA request unsuccessfully, i2c can also work well. Signed-off-by: Yuan Yao [off-list ref] Signed-off-by: Wolfram Sang [off-list ref] Carlos
Andi