Received: by 10.192.165.148 with SMTP id m20csp1747258imm; Thu, 26 Apr 2018 01:28:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp+3yxTQEiItcpLJdEVifYN6M/RmI5gLvCMIhuCrxzb+IHooTQOHUh4PsrKxArWB2tkcaNA X-Received: by 2002:a17:902:b492:: with SMTP id y18-v6mr9349420plr.2.1524731290617; Thu, 26 Apr 2018 01:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524731290; cv=none; d=google.com; s=arc-20160816; b=GA/0ysF/pyol/JlCK8ThNuISa2KJx8RdLSa0WT5K6RF05iTgiaFj4w4fK8uvZogI+g 19sXg4OoAyM09TLnKlli2FICuj2CwGI1qAY+6x8BjLKhAyCkAq5Uc8+aUZnztgrwlegA ske/uTxK+EteVwKyVLgel5mi38hVOX9vaCRxLSwkfyB6s8ErXalvf8tiDfpxrw7l9j2z WFI896b0wCTeHisS+RUaJVA1/W+qYG8CqQKHcQC6cRzCy5LXAQge1dHeub0cxNO8kh8r v3FZBaSGUQNm69UmGWcoucoWMV9t3EUoL9LLKmYNRjskwKp75ZxTy/ZYHurdpDTWvr8l Jr0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:arc-authentication-results; bh=WffHzaqU0h3QLNT12WdEH0JRCQTaps3mGgENFqqZRAE=; b=mi8wc6hAixgxv8KwatatRcoeA4tC/+EDxBYD2bE5u6FzAB2VLdiLXrLnw9zmtSYBDk zaKxHbcDkwFKZzICDAtJF1SAHevR2N1EGtcx7x8CB3CxBCNVNaV3NRpLsa30y6HeB0n1 VE7YxDIpux1mtKhJWEe+9DYaAbAiCEaV7RF80vUBkkqjLQea5xuKj59oen1rPNhQzL+v sSStJ9GP0n9Ztd8XittSpUpnElvA8JTEsl115y8KQnGiGH89RcHWIfuwI+Ic61+4VWP6 7TbmmIieMb5jxAB+IqAhlEjqNQv2A+ulDz3H24rF9E9ELJPnQSlo96UO0KohVS33wlVj hrKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1si10344881pgs.24.2018.04.26.01.27.55; Thu, 26 Apr 2018 01:28:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753700AbeDZI0t (ORCPT + 99 others); Thu, 26 Apr 2018 04:26:49 -0400 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:61426 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752018AbeDZI0o (ORCPT ); Thu, 26 Apr 2018 04:26:44 -0400 X-IronPort-AV: E=Sophos;i="5.49,330,1520924400"; d="scan'208";a="13306487" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 26 Apr 2018 01:26:43 -0700 Received: from localhost (10.10.76.4) by chn-sv-exch07.mchp-main.com (10.10.76.108) with Microsoft SMTP Server id 14.3.352.0; Thu, 26 Apr 2018 01:26:43 -0700 Date: Thu, 26 Apr 2018 10:25:58 +0200 From: Ludovic Desroches To: David Engraf CC: , , , , Subject: Re: [PATCH] i2c: at91: Read all available bytes at once Message-ID: <20180426082558.GX13305@rfolt0960.corp.atmel.com> Mail-Followup-To: David Engraf , nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20180418124055.21333-1-david.engraf@sysgo.com> <20180425150853.GU13305@rfolt0960.corp.atmel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi David, On Wed, Apr 25, 2018 at 05:43:09PM +0200, David Engraf wrote: > Hi Ludovic, > > Am 25.04.2018 um 17:08 schrieb Ludovic Desroches: > > Hi David, > > > > On Wed, Apr 18, 2018 at 02:40:55PM +0200, David Engraf wrote: > > > With FIFO enabled it is possible to read multiple bytes > > > at once in the interrupt handler as long as RXRDY is > > > set. This may also reduce the number of interrupts. > > > > > > Signed-off-by: David Engraf > > > --- > > > drivers/i2c/busses/i2c-at91.c | 8 ++++++-- > > > 1 file changed, 6 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c > > > index bfd1fdff64a9..d01c2b2384bd 100644 > > > --- a/drivers/i2c/busses/i2c-at91.c > > > +++ b/drivers/i2c/busses/i2c-at91.c > > > @@ -518,8 +518,12 @@ static irqreturn_t atmel_twi_interrupt(int irq, void *dev_id) > > > * the RXRDY interrupt first in order to not keep garbage data in the > > > * Receive Holding Register for the next transfer. > > > */ > > > - if (irqstatus & AT91_TWI_RXRDY) > > > - at91_twi_read_next_byte(dev); > > > + if (irqstatus & AT91_TWI_RXRDY) { > > > + /* read all available bytes at once when FIFO is used */ > > > + do { > > > + at91_twi_read_next_byte(dev); > > > + } while (at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_RXRDY); > > > > You can avoid this check by using the RXFL field to know the number of > > data you can read. Did you try to use it? If yes, did you notice some issues? > > I did a quick test by reading RXFL and it worked as well but I decided to > use the more readable solution by polling RXRDY. Also I don't need to check > if the FIFO has been enabled. > > If you prefer using RXFL I can create a new patch. Honestly, I have no strong opinion about it. As you said you approach is simple and easy to read. About performances, I assume that both solutions are pretty the same for small number of data. If the number increases, using the RXFL field should give better results. So I would say, maybe add a note in the commit log or in the code to keep in mind there is this solution to go further. Otherwise Acked-by: Ludovic Desroches Regards Ludovic > > Best regards > - David > > > > Regards > > > > Ludovic > > > > > + } > > > /* > > > * When a NACK condition is detected, the I2C controller sets the NACK, > > > -- > > > 2.14.1 > > > >