lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20241126-fat-orthodox-eel-5389b4-mkl@pengutronix.de>
Date: Tue, 26 Nov 2024 13:22:24 +0100
From: Marc Kleine-Budde <mkl@...gutronix.de>
To: Carlos Song <carlos.song@....com>
Cc: Frank Li <frank.li@....com>, 
	"o.rempel@...gutronix.de" <o.rempel@...gutronix.de>, "kernel@...gutronix.de" <kernel@...gutronix.de>, 
	"andi.shyti@...nel.org" <andi.shyti@...nel.org>, "shawnguo@...nel.org" <shawnguo@...nel.org>, 
	"s.hauer@...gutronix.de" <s.hauer@...gutronix.de>, "festevam@...il.com" <festevam@...il.com>, 
	"imx@...ts.linux.dev" <imx@...ts.linux.dev>, "linux-i2c@...r.kernel.org" <linux-i2c@...r.kernel.org>, 
	"linux-arm-kernel@...ts.infradead.org" <linux-arm-kernel@...ts.infradead.org>, "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] i2c: imx: support DMA defer probing

On 26.11.2024 12:07:59, Carlos Song wrote:
> 
> 
> > -----Original Message-----
> > From: Marc Kleine-Budde <mkl@...gutronix.de>
> > Sent: Tuesday, November 26, 2024 6:24 PM
> > To: Carlos Song <carlos.song@....com>
> > Cc: Frank Li <frank.li@....com>; o.rempel@...gutronix.de;
> > kernel@...gutronix.de; andi.shyti@...nel.org; shawnguo@...nel.org;
> > s.hauer@...gutronix.de; festevam@...il.com; imx@...ts.linux.dev;
> > linux-i2c@...r.kernel.org; linux-arm-kernel@...ts.infradead.org;
> > linux-kernel@...r.kernel.org
> > Subject: [EXT] Re: [PATCH v2] i2c: imx: support DMA defer probing
> > 
> > On 26.11.2024 10:15:27, Carlos Song wrote:
> > > > >  static void i2c_imx_dma_callback(void *arg) @@ -1803,6 +1804,13
> > > > > @@ static int i2c_imx_probe(struct platform_device *pdev)
> > > > >  	if (ret == -EPROBE_DEFER)
> > > > >  		goto clk_notifier_unregister;
> > > > >
> > > > > +	/* Init DMA config if supported */
> > > > > +	ret = i2c_imx_dma_request(i2c_imx, phy_addr);
> > > > > +	if (ret == -EPROBE_DEFER) {
> > > > > +		dev_err(&pdev->dev, "DMA not ready, go defer probe!\n");
> > > > > +		goto clk_notifier_unregister;
> > > > > +	}
> > > >
> > > > Don't spam the logs if the driver defers probing, it's not a error.
> > > > And it looks strange to ignore all other errors here. Either add a
> > > > comment here, something like "continue without DMA", or let the
> > > > function return
> > > > 0 in case the driver should continue and propagate the error if the
> > > > caller should take care of it.
> > > >
> > >
> > > Hi,
> > > Thank you for your suggestion! I agree with you.
> > > I will change to this logic:
> > > 	ret = i2c_imx_dma_request(i2c_imx, phy_addr);
> > > 	if (ret) {
> > > 		if (ret == -EPROBE_DEFER)
> > > 			goto clk_notifier_unregister;
> > > 		dev_info(&pdev->dev, "use pio mode\n");
> > > 	}
> > >
> > > Ret = 0  ----->  enable DMA successfully  -------> no print
> > > Ret!=0  ----->  defer probe ---------> no print and try again
> > > Ret!=0  ----->  fail to enable DMA ------> remind now is using pio
> > > mode
> > >
> > > Do you think the logic is acceptable?
> > 
> > Yes, the other option is to move the logic into i2c_imx_dma_request() and let it
> > return 0 in case of DMA or fallback to PIO, or an error in case of probe defer or a
> > fatal error.
> > 
> > This way the probe function will look like this:
> > 
> >      ret = i2c_imx_dma_request(i2c_imx, phy_addr);
> >      if (ret)
> >                 return dev_err_probe(&pdev->dev, ret, "Failed to setup
> > DMA\n");
> > 
> 
> Sorry, I have some different ideas...
> 1. DMA mode should be optional for i2c-imx, because i2c-imx can accept DMA mode not enabled, because it still can work in CPU mode.

ACK

>   If we use return dev_err_probe(), we have to return error at i2c_imx_dma_request() for "some fatal error", it will cause i2c_adapter can not be registered, then kill i2c adapter register.

i2c_imx_dma_request should only return an error if PIO mode is not an
option.

>   If we always return 0 at i2c_imx_dma_request(), dev_err_probe will not work forever. So from my point, if DMA is not working well, just output a log to remind now i2c is always
>   working at CPU mode, we have no DMA, this is enough.

ACK

> 2. when really defer probe, return dev_err_probe will return defer probe directly, but we still need to goto clk_notifier_unregister branch to free irq, clk_notifier_unregister and disable runtime pm.
>   So we still need more judgement at probe function to handle this.

Not quite "dev_err_probe()" will not defer probe directly, the return in
"return dev_err_probe();" does. This should work:

        ret = i2c_imx_dma_request(i2c_imx, phy_addr);
        if (ret) {
                dev_err_probe(&pdev->dev, ret, "Failed to setup  DMA\n");
                goto clk_notifier_unregister;
        }
        

> So I prefer this logic:

This also works, LGTM!

> ret = i2c_imx_dma_request(i2c_imx, phy_addr);
> if (ret) {
> 	if (ret == -EPROBE_DEFER)
> 		goto clk_notifier_unregister;
> 	dev_info(&pdev->dev, "use pio mode\n");
> }

regards,
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   |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ