From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E97C0ECAAD5 for ; Thu, 8 Sep 2022 08:36:32 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 38C3D84AA0; Thu, 8 Sep 2022 10:36:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.b="LIG+CG18"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6A3E384AAC; Thu, 8 Sep 2022 10:36:27 +0200 (CEST) Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DB75F84424 for ; Thu, 8 Sep 2022 10:36:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jorge@foundries.io Received: by mail-wr1-x42d.google.com with SMTP id b17so11433356wrq.3 for ; Thu, 08 Sep 2022 01:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date; bh=dBQtDfsr5Kf+aGeKTr9AgkRbCALEdT2PwIcV/csDFlQ=; b=LIG+CG18e0LoBa6tCt4zNVcILLUth8DMNyPhUa1NtF2JvbO+CYO/hW4kLDP3CL+N29 ia2GozGTThx7et3VacICNME3MsTkWIdCb1cMb/PcJjNM6jCADLRLxP9VW/Lqkkv4QNOo ZuT+Y2YLuypO0P/NYj3EuDiNqb1729e8vOY9lJT6Fms2c1ZTdIzBf1N3+7j4lrIoK4nK litqSE+oC4jn6ezefyV2a8mFYavzO1YpY7ciZX2ThRvh+C9ZOmeBBxfYqvft4OYPQrV2 hctI7rlISjcf+l3Uo0mIazMkf1bXOEM+nAVvGsLEyvmDvNGG4r4LItF0xJSUvySYsvRQ 85ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date; bh=dBQtDfsr5Kf+aGeKTr9AgkRbCALEdT2PwIcV/csDFlQ=; b=jh20Kc0gIYdTKRIRFJmL9gweX+sjt/ghWoibt9wkFH4wIsUH5+8Bm+8ioqJTcHlDSL 1FiS6FH+y8CChy4kxp/q3PF7+8AhnxUz4Kge5yXfhzJ6nMUrn2wTXBgsZfTZe/VSlNwY pBK+tbdQaJuphbF3IviBd6qjMtBn4Ty5u+kUONwJR2jr6nSzLsYL2DzRtttMPJNlUKf0 wFWYOY/bjPa2mKGBIFoQ1OTKRfWdcckXZ/IEJJFyFxnVLA/Hf2aLA6nYdmZVg+7uwua1 Uq99c+cif415DjQVXIaVF0mML4rNACfBYCAcDnOu0zupVApTs65rznRco10VJ/m+7+Hi ZoKQ== X-Gm-Message-State: ACgBeo1+QuRLcxaTCWTnOj+NROiAQzzankwHOndVTGSAsQtC8KGiwHCi GQS8lyVzsKip7HaxGHSEm4ma0A== X-Google-Smtp-Source: AA6agR4+SHMUafSffcoHtLXpyNK+nN6Er1LT52FwLhy9UQ/pHPinEEWCVmTlfn8bvHa2TUewCmg73w== X-Received: by 2002:a05:6000:168c:b0:226:f4c2:d6db with SMTP id y12-20020a056000168c00b00226f4c2d6dbmr4254218wrd.659.1662626184336; Thu, 08 Sep 2022 01:36:24 -0700 (PDT) Received: from trex (131.red-83-60-92.dynamicip.rima-tde.net. [83.60.92.131]) by smtp.gmail.com with ESMTPSA id p24-20020a05600c205800b003a83ca67f73sm1962464wmg.3.2022.09.08.01.36.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Sep 2022 01:36:23 -0700 (PDT) From: "Jorge Ramirez-Ortiz, Foundries" X-Google-Original-From: "Jorge Ramirez-Ortiz, Foundries" Date: Thu, 8 Sep 2022 10:36:22 +0200 To: Alain Volmat Cc: uboot-stm32@st-md-mailman.stormreply.com, u-boot@lists.denx.de, patrice.chotard@foss.st.com, patrick.delaunay@foss.st.com, jorge@foundries.io, hs@denx.de, oleksandr.suvorov@foundries.io Subject: Re: [PATCH 3/3] i2c: stm32: only send a STOP upon transfer completion Message-ID: <20220908083622.GA117999@trex> References: <20220908080627.1762034-1-alain.volmat@foss.st.com> <20220908080627.1762034-4-alain.volmat@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220908080627.1762034-4-alain.volmat@foss.st.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On 08/09/22, 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. This can > be especially seen when the processing get slower (ex: enabling lots > of debug messages), ending up send 2 STOP (one automatically by the > controller and a 2nd one at the end of the stm32_i2c_message_xfer > function). um I debugged this - took me a couple of days - and I proposed a fix that has just been massaged a little in this PR. IMO the best thing to do is either adding me - or to be fair yourself since you invested almost zero time on it - as a co-author. The hard bit was to find the issue in the first place. what do you think? I'll try to find some time to test this. > > Signed-off-by: Alain Volmat > --- > drivers/i2c/stm32f7_i2c.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c > index 0ec67b5c12..8803979d3e 100644 > --- a/drivers/i2c/stm32f7_i2c.c > +++ b/drivers/i2c/stm32f7_i2c.c > @@ -477,16 +477,16 @@ static int stm32_i2c_message_xfer(struct stm32_i2c_priv *i2c_priv, > if (ret) > break; > > + /* End of transfer, send stop condition */ > + mask = STM32_I2C_CR2_STOP; > + setbits_le32(®s->cr2, mask); > + > if (!stop) > /* Message sent, new message has to be sent */ > return 0; > } > } > > - /* End of transfer, send stop condition */ > - mask = STM32_I2C_CR2_STOP; > - setbits_le32(®s->cr2, mask); > - > return stm32_i2c_check_end_of_message(i2c_priv); > } > > -- > 2.25.1 >