> -----Original Message----- > From: Andi Shyti <andi.shyti@xxxxxxxxxx> > Sent: Tuesday, December 24, 2024 7:14 AM > To: Carlos Song <carlos.song@xxxxxxx> > Cc: o.rempel@xxxxxxxxxxxxxx; kernel@xxxxxxxxxxxxxx; shawnguo@xxxxxxxxxx; > s.hauer@xxxxxxxxxxxxxx; festevam@xxxxxxxxx; linux-i2c@xxxxxxxxxxxxxxx; > imx@xxxxxxxxxxxxxxx; linux-arm-kernel@xxxxxxxxxxxxxxxxxxx; > linux-kernel@xxxxxxxxxxxxxxx; Clark Wang <xiaoning.wang@xxxxxxx>; Ahmad > Fatoum <a.fatoum@xxxxxxxxxxxxxx> > 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, > > ... > > > @@ -1802,6 +1803,18 @@ static int i2c_imx_probe(struct platform_device > *pdev) > > if (ret == -EPROBE_DEFER) > > goto clk_notifier_unregister; > > > > + /* As we can always fall back to PIO, let's ignore the error setting up > DMA. */ > > + 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", > > + 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@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/ [2]: commit ce1a78840ff7ab846065d5b65eaac959bafe1949 Author: Yao Yuan <yao.yuan@xxxxxxxxxxxxx> 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 <yao.yuan@xxxxxxxxxxxxx> Signed-off-by: Wolfram Sang <wsa@xxxxxxxxxxxxx> Carlos > > Andi