[PATCH v4] i2c: imx: support DMA defer probing
Marc Kleine-Budde
mkl at pengutronix.de
Wed Nov 27 00:42:40 PST 2024
On 27.11.2024 16:38:18, carlos.song at nxp.com wrote:
> From: Carlos Song <carlos.song at nxp.com>
>
> Return -EPROBE_DEFER when dma_request_slave_channel() because DMA driver
> have not ready yet.
>
> Move i2c_imx_dma_request() before registering I2C adapter to avoid
> infinite loop of .probe() calls to the same driver, see "e8c220fac415
> Revert "i2c: imx: improve the error handling in i2c_imx_dma_request()""
> and "Documentation/driver-api/driver-model/driver.rst".
>
> Use CPU mode to avoid stuck registering i2c adapter when DMA resources
> are unavailable.
>
> Signed-off-by: Carlos Song <carlos.song at nxp.com>
> Signed-off-by: Clark Wang <xiaoning.wang at nxp.com>
> ---
> Change for V4:
> - Output "Only use PIO mode" log in debug level when no DMA configure.
> Change for V3:
> - According to Marc's comment, remove error print when defer probe.
> Add info log when DMA has not been enabled and add error log when
> DMA error, both won't stuck the i2c adapter register, just for reminding,
> i2c adapter is working only in PIO mode.
> Change for V2:
> - According to Frank's comments, wrap at 75 char and Simplify fix code
> at i2c_imx_dma_request().
> - Use strict patch check, fix alignment warning at i2c_imx_dma_request()
> ---
> drivers/i2c/busses/i2c-imx.c | 31 +++++++++++++++++++++++--------
> 1 file changed, 23 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 5ed4cb61e262..b11d66d56c55 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -397,17 +397,16 @@ static void i2c_imx_reset_regs(struct imx_i2c_struct *i2c_imx)
> }
>
> /* Functions for DMA support */
> -static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
> - dma_addr_t phy_addr)
> +static int i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx, dma_addr_t phy_addr)
> {
> struct imx_i2c_dma *dma;
> struct dma_slave_config dma_sconfig;
> - struct device *dev = &i2c_imx->adapter.dev;
> + struct device *dev = i2c_imx->adapter.dev.parent;
Why is this change needed? What's the purpose?
> int ret;
>
> dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);
This means you bind the allocated memory to the parent device, not the
i2c device anymore.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20241127/64f5783b/attachment.sig>
More information about the linux-arm-kernel
mailing list