linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: imx: remove unnecessary delay at startup
@ 2022-03-14  9:59 Ian Dannapel
  2022-03-14 10:13 ` Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Dannapel @ 2022-03-14  9:59 UTC (permalink / raw)
  To: linux
  Cc: kernel, shawnguo, s.hauer, festevam, linux-imx, linux-i2c,
	linux-arm-kernel, linux-kernel, Michael.Glembotzki,
	Erik.Schumacher, Ian Dannapel

a delay on the startup of the i2c imx controller is not required or defined in the specs.
By removing it, the user can see a latency decrease from up to 150μs in communication.
Additional info: https://lore.kernel.org/all/20220304132037.GA15901@pengutronix.de/

Signed-off-by: Ian S. Dannapel <iansdannapel@gmail.com>
---
 drivers/i2c/busses/i2c-imx.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 3576b63a6c03..019dda5301df 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -602,12 +602,6 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx, bool atomic)
 	imx_i2c_write_reg(i2c_imx->hwdata->i2sr_clr_opcode, i2c_imx, IMX_I2C_I2SR);
 	imx_i2c_write_reg(i2c_imx->hwdata->i2cr_ien_opcode, i2c_imx, IMX_I2C_I2CR);
 
-	/* Wait controller to be stable */
-	if (atomic)
-		udelay(50);
-	else
-		usleep_range(50, 150);
-
 	/* Start I2C transaction */
 	temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
 	temp |= I2CR_MSTA;
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: imx: remove unnecessary delay at startup
  2022-03-14  9:59 [PATCH] i2c: imx: remove unnecessary delay at startup Ian Dannapel
@ 2022-03-14 10:13 ` Uwe Kleine-König
  2022-03-15  5:59   ` Oleksij Rempel
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2022-03-14 10:13 UTC (permalink / raw)
  To: Ian Dannapel
  Cc: linux, Erik.Schumacher, shawnguo, s.hauer, linux-kernel,
	Michael.Glembotzki, linux-imx, kernel, festevam,
	linux-arm-kernel, linux-i2c


[-- Attachment #1.1: Type: text/plain, Size: 1091 bytes --]

Hello,

On Mon, Mar 14, 2022 at 10:59:18AM +0100, Ian Dannapel wrote:
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 3576b63a6c03..019dda5301df 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -602,12 +602,6 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx, bool atomic)
>  	imx_i2c_write_reg(i2c_imx->hwdata->i2sr_clr_opcode, i2c_imx, IMX_I2C_I2SR);
>  	imx_i2c_write_reg(i2c_imx->hwdata->i2cr_ien_opcode, i2c_imx, IMX_I2C_I2CR);
>  
> -	/* Wait controller to be stable */
> -	if (atomic)
> -		udelay(50);
> -	else
> -		usleep_range(50, 150);
> -
>  	/* Start I2C transaction */
>  	temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
>  	temp |= I2CR_MSTA;

This contradicts statements made in
43309f3b521302bb66c4c9e66704dd3675e4d725.

Maybe the sleep/delay should be done conditionally on the busy bit?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: imx: remove unnecessary delay at startup
  2022-03-14 10:13 ` Uwe Kleine-König
@ 2022-03-15  5:59   ` Oleksij Rempel
  2022-03-15  7:44     ` Wolfram Sang
  0 siblings, 1 reply; 4+ messages in thread
From: Oleksij Rempel @ 2022-03-15  5:59 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Ian Dannapel, linux, Erik.Schumacher, shawnguo, s.hauer,
	linux-kernel, Michael.Glembotzki, linux-imx, kernel, festevam,
	linux-arm-kernel, linux-i2c

On Mon, Mar 14, 2022 at 11:13:37AM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> On Mon, Mar 14, 2022 at 10:59:18AM +0100, Ian Dannapel wrote:
> > diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> > index 3576b63a6c03..019dda5301df 100644
> > --- a/drivers/i2c/busses/i2c-imx.c
> > +++ b/drivers/i2c/busses/i2c-imx.c
> > @@ -602,12 +602,6 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx, bool atomic)
> >  	imx_i2c_write_reg(i2c_imx->hwdata->i2sr_clr_opcode, i2c_imx, IMX_I2C_I2SR);
> >  	imx_i2c_write_reg(i2c_imx->hwdata->i2cr_ien_opcode, i2c_imx, IMX_I2C_I2CR);
> >  
> > -	/* Wait controller to be stable */
> > -	if (atomic)
> > -		udelay(50);
> > -	else
> > -		usleep_range(50, 150);
> > -
> >  	/* Start I2C transaction */
> >  	temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
> >  	temp |= I2CR_MSTA;
> 
> This contradicts statements made in
> 43309f3b521302bb66c4c9e66704dd3675e4d725.
> 
> Maybe the sleep/delay should be done conditionally on the busy bit?

Maybe. I do not see what exact problem is this sleep addressing. How
exact the can get stable? Is it addressing some clock issue or wading
until something happening on the bus?

Regards,
Oleskij
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: imx: remove unnecessary delay at startup
  2022-03-15  5:59   ` Oleksij Rempel
@ 2022-03-15  7:44     ` Wolfram Sang
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2022-03-15  7:44 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Uwe Kleine-König, Ian Dannapel, linux, Erik.Schumacher,
	shawnguo, s.hauer, linux-kernel, Michael.Glembotzki, linux-imx,
	kernel, festevam, linux-arm-kernel, linux-i2c


[-- Attachment #1.1: Type: text/plain, Size: 441 bytes --]


> Maybe. I do not see what exact problem is this sleep addressing. How
> exact the can get stable? Is it addressing some clock issue or wading
> until something happening on the bus?

Yeah, it is really hard to see why it is there. And given that the
introducing commit is from 2009, we can't really expect an active
userbase reporting breakage. So, although it may be a useless delay, I'd
like to see an opt-in approach for not using it.


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-15  7:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-14  9:59 [PATCH] i2c: imx: remove unnecessary delay at startup Ian Dannapel
2022-03-14 10:13 ` Uwe Kleine-König
2022-03-15  5:59   ` Oleksij Rempel
2022-03-15  7:44     ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).