Received: by 10.192.165.148 with SMTP id m20csp2033898imm; Thu, 26 Apr 2018 05:33:12 -0700 (PDT) X-Google-Smtp-Source: AIpwx49iC9aQiQmcVKiNXd6wwyvhqjKYj1vIqqqG1Ltwn6Lc424OJ23n9OdqPx2Onfc14QCMyiGJ X-Received: by 10.98.64.130 with SMTP id f2mr26503778pfd.83.1524745992118; Thu, 26 Apr 2018 05:33:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524745992; cv=none; d=google.com; s=arc-20160816; b=lY/wn294Quga2IbhEfUQA6caxbUBDiU9yBpPbyzvqT2aicgMOftBvYuJG+qoopI1EF UAshyQSVZxr2vsIB3kDHaxwVsY3XvmkdiIvwF7Ahg9ZDa1An6ANADhpP2ExyW8A7Fydd j1XZ1/kcnCyir9R9WPV7As6Jh4oORZvU86pm5wwznxMugFS/+5n1pMVF3AI4Lr9gaZjj c3V1PrE/aLeV6UMchrDbs/sKD5KyZOKA1VTB97ajOC1fUwUiJ8hPkCX1b/TF3YDp0vN4 YuOv09+Zqx4XlIa7Zm36r+IXNJwTB3iWJqbel/vM1MJZzt7CJntPcmkZbFOewDYdhyQT jdhg== 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=F2B4t5Iq/RwLyRZ1X+GbARmCVS0PL5DkZLr82wnIMjk=; b=u+HTw+kRKjixTyhTYGnZkBBxDNWoAlL2epnyglSRGjBFzgMrBHmg4VXJ8wTGaq5ZL+ tPGbrpu4BRLsYK7GX7HUMFDxJpm7UGhx3jApp1qKW3HHHaDDDahrMyCtEWnyFX/kcBcx rk1BacIy8GKoVgFw0+X1mBRbzWo+inSRO/XiPIHpBmWbpD02gYpNd69gJsVtt9hTFw+o sATR8P4+kyqirEgbsSCv8rLr7agt4YoJzEH8C4VGi1YIDruz/lQtuLgi4S+RVHvGQduJ NATavlj/aZnK/yGCugQ35wUNHg1nnWNmR/sALNKtG3eiM1wZqPqj7tYXwhh5ZkuFKvfc 1DHA== 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 8-v6si18668109plc.342.2018.04.26.05.32.57; Thu, 26 Apr 2018 05:33:12 -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 S1755680AbeDZMa6 (ORCPT + 99 others); Thu, 26 Apr 2018 08:30:58 -0400 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:57173 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751713AbeDZMaz (ORCPT ); Thu, 26 Apr 2018 08:30:55 -0400 X-IronPort-AV: E=Sophos;i="5.49,330,1520924400"; d="scan'208";a="13311564" 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 05:30:54 -0700 Received: from localhost (10.10.76.4) by chn-sv-exch02.mchp-main.com (10.10.76.38) with Microsoft SMTP Server id 14.3.352.0; Thu, 26 Apr 2018 05:30:53 -0700 Date: Thu, 26 Apr 2018 14:30:09 +0200 From: Ludovic Desroches To: David Engraf CC: , , , , , Subject: Re: [PATCH v2] i2c: at91: Read all available bytes at once Message-ID: <20180426123009.GZ13305@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: <20180426082558.GX13305@rfolt0960.corp.atmel.com> <20180426095314.12758-1-david.engraf@sysgo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20180426095314.12758-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 On Thu, Apr 26, 2018 at 11:53:14AM +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. > > This patch polls RXRDY and reads all available bytes at > once. > > Signed-off-by: David Engraf Acked-by: Ludovic Desroches Thanks a lot David. Regards Ludovic > --- > drivers/i2c/busses/i2c-at91.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c > index bfd1fdff64a9..9caee5b79eac 100644 > --- a/drivers/i2c/busses/i2c-at91.c > +++ b/drivers/i2c/busses/i2c-at91.c > @@ -518,8 +518,16 @@ 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 by polling RXRDY usable w/ and w/o > + * FIFO. With FIFO enabled we could also read RXFL and avoid polling > + * RXRDY. > + */ > + do { > + at91_twi_read_next_byte(dev); > + } while (at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_RXRDY); > + } > > /* > * When a NACK condition is detected, the I2C controller sets the NACK, > -- > 2.14.1 >