Received: by 10.192.165.148 with SMTP id m20csp822551imm; Wed, 25 Apr 2018 08:11:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx49baDgshSn56FLlOqC4g545BIi7OS9Ic5/t+rnVel17AMFdlL/vIQw0SsfLs3SLkRYZx5PT X-Received: by 10.98.98.65 with SMTP id w62mr28384117pfb.256.1524669107341; Wed, 25 Apr 2018 08:11:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524669107; cv=none; d=google.com; s=arc-20160816; b=lC/9m7gW3S1JkX6K9AdfhP/94G0Q6PX/yJvW3m+j3AlGCxIo9TFZkOeSi5a4XLdE1x +pfd2leUSdPo65YobMiqmzU+Rfsojy7TxdAF2SJp2QlDTuVHOM5IPWgZ3xE9Ot5LKvM5 EOzNbwtR1jDRjGXlCRXMHOLuONUVxk/RlG3fzZMWC4Tm7U5M2QEdsJ0NUZWRa2ti6J3e XZXLlgrT60pnZkNANjEPHwdiL/H3UnVIOxvqk6VWIM3nniDOZjTH2QM+vscLI6Be88yz YJJ/qY8sug7/EdxkrRnwFZ0xRsgkF3GO+lxuEigwHwnskr/rN8FmNAKRDLrisWPTongk kFjQ== 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=L6QschGcUDq7I6RUlt5lSQ8Xew/PU+UPMwUSmojU+pM=; b=0/7BVrjCxp/LQ4czeWLpl4Kthcm/FB+WXS/Bkq1vgCII3oITyD8Y+MFRHLYftlF2dR MiijV73wDjWJDnU50+ccQrenHTrVSKIO2HsLn3dmW1dT0RlZRtTeePMO0hCnmA/LbEyr rKXH0meNhGpKmffmRrjbVQN/jV3adu0Zh/eR3FhOH47fOeItRSkljIHpuXe09TQKC5Ml WGELBYmmmZAKx6ffKVVqnkRPlPxKBI2NCFssD9+r88BfVg0BgEYl6/IdeL2Vb0W9mk/8 W0frBkZacGOIE/GMTfk+Y5bmujA9f1jz17hfZQkB+ZBZxBadR/46bovwi/hIstCdIrr0 pXmQ== 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 o32-v6si15908425pld.369.2018.04.25.08.11.31; Wed, 25 Apr 2018 08:11:47 -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 S1755213AbeDYPJ6 (ORCPT + 99 others); Wed, 25 Apr 2018 11:09:58 -0400 Received: from esa6.microchip.iphmx.com ([216.71.154.253]:12572 "EHLO esa6.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755206AbeDYPJz (ORCPT ); Wed, 25 Apr 2018 11:09:55 -0400 X-IronPort-AV: E=Sophos;i="5.49,326,1520924400"; d="scan'208";a="10901281" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 25 Apr 2018 08:09:38 -0700 Received: from localhost (10.10.76.4) by chn-sv-exch03.mchp-main.com (10.10.76.49) with Microsoft SMTP Server id 14.3.352.0; Wed, 25 Apr 2018 08:09:37 -0700 Date: Wed, 25 Apr 2018 17:08:53 +0200 From: Ludovic Desroches To: David Engraf CC: , , , , , Subject: Re: [PATCH] i2c: at91: Read all available bytes at once Message-ID: <20180425150853.GU13305@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> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20180418124055.21333-1-david.engraf@sysgo.com> 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 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? Regards Ludovic > + } > > /* > * When a NACK condition is detected, the I2C controller sets the NACK, > -- > 2.14.1 >