All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick DELAUNAY <patrick.delaunay@foss.st.com>
To: Alain Volmat <alain.volmat@foss.st.com>,
	<uboot-stm32@st-md-mailman.stormreply.com>,
	<u-boot@lists.denx.de>
Cc: <patrice.chotard@foss.st.com>, <jorge@foundries.io>, <hs@denx.de>,
	<oleksandr.suvorov@foundries.io>
Subject: Re: [PATCH v4 3/4] i2c: stm32: do not set the STOP condition on error
Date: Mon, 12 Sep 2022 14:03:41 +0200	[thread overview]
Message-ID: <a7e847dc-c1a0-3652-bf82-f6246516e769@foss.st.com> (raw)
In-Reply-To: <20220912084201.1826979-4-alain.volmat@foss.st.com>

Hi,

On 9/12/22 10:42, Alain Volmat wrote:
> Current function stm32_i2c_message_xfer is sending a STOP
> whatever the result of the transaction is.  This can cause issues
> such as making the bus busy since the controller itself is already
> sending automatically a STOP when a NACK is generated.
>
> Thanks to Jorge Ramirez-Ortiz for diagnosing and proposing a first
> fix for this. [1]
>
> [1] https://lore.kernel.org/u-boot/20220815145211.31342-2-jorge@foundries.io/
>
> Reported-by: Jorge Ramirez-Ortiz, Foundries <jorge@foundries.io>
> Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> ---
>   drivers/i2c/stm32f7_i2c.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c
> index 0ec67b5c12..2db7f44d44 100644
> --- a/drivers/i2c/stm32f7_i2c.c
> +++ b/drivers/i2c/stm32f7_i2c.c
> @@ -483,9 +483,9 @@ static int stm32_i2c_message_xfer(struct stm32_i2c_priv *i2c_priv,
>   		}
>   	}
>   
> -	/* End of transfer, send stop condition */
> -	mask = STM32_I2C_CR2_STOP;
> -	setbits_le32(&regs->cr2, mask);
> +	/* End of transfer, send stop condition if appropriate */
> +	if (!ret && !(status & (STM32_I2C_ISR_NACKF | STM32_I2C_ISR_ERRORS)))
> +		setbits_le32(&regs->cr2, STM32_I2C_CR2_STOP);
>   
>   	return stm32_i2c_check_end_of_message(i2c_priv);
>   }



Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Tested-by: Patrick Delaunay <patrick.delaunay@foss.st.com> 
[stm32mp157c-dk2]

@Jorge: can you test also for your use-case, thanks


Thanks
Patrick


  parent reply	other threads:[~2022-09-12 12:04 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12  8:41 [PATCH v4 0/4] i2c: stm32: cleanup & stop handling fix Alain Volmat
2022-09-12  8:41 ` [PATCH v4 1/4] i2c: stm32: fix comment and remove unused AUTOEND bit Alain Volmat
2022-09-12  8:47   ` Heiko Schocher
2022-09-12  8:52   ` Patrice CHOTARD
2022-09-15 15:18   ` Patrick DELAUNAY
2022-09-12  8:41 ` [PATCH v4 2/4] i2c: stm32: remove unused stop parameter in start & reload handling Alain Volmat
2022-09-12  8:48   ` Heiko Schocher
2022-09-12  8:52   ` Patrice CHOTARD
2022-09-15 15:25   ` Patrick DELAUNAY
2022-09-12  8:42 ` [PATCH v4 3/4] i2c: stm32: do not set the STOP condition on error Alain Volmat
2022-09-12  8:52   ` Patrice CHOTARD
2022-09-12  9:02   ` Heiko Schocher
2022-09-12 12:03   ` Patrick DELAUNAY [this message]
2022-09-15 15:28   ` Patrick DELAUNAY
2022-09-15 15:30   ` Patrick DELAUNAY
2022-09-12  8:42 ` [PATCH v4 4/4] i2c: stm32: fix usage of rise/fall device tree properties Alain Volmat
2022-09-12  8:51   ` Patrice CHOTARD
2022-09-12  9:10   ` Heiko Schocher
2022-09-12 12:04   ` Patrick DELAUNAY
2022-09-15 15:48   ` Patrick DELAUNAY

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a7e847dc-c1a0-3652-bf82-f6246516e769@foss.st.com \
    --to=patrick.delaunay@foss.st.com \
    --cc=alain.volmat@foss.st.com \
    --cc=hs@denx.de \
    --cc=jorge@foundries.io \
    --cc=oleksandr.suvorov@foundries.io \
    --cc=patrice.chotard@foss.st.com \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-stm32@st-md-mailman.stormreply.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.