Received: by 10.192.165.148 with SMTP id m20csp859224imm; Wed, 25 Apr 2018 08:45:05 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqP8v4KkjAb0qaJD+JEEIzlzhpEbyoVrzP+rXL5LuJ8Ko5KDPZ3IELpeMgl9EyzmXjbPhXB X-Received: by 2002:a17:902:d687:: with SMTP id v7-v6mr2350850ply.201.1524671105271; Wed, 25 Apr 2018 08:45:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524671105; cv=none; d=google.com; s=arc-20160816; b=LMnD6siusfsBAMd5dbC3QdfLIbaqDAl2ycTeNFgKi78gbfzPRyrVK8BuRmnXQ1Muwb IZu1dACwt0fGo3sK34+nt+6Nl+EHXCIJM9WVLNoWpIygZTIwYtE6KyQpO3VQrpnIXQaP EJEqI6LsiA3fns2R8+0sbWPaNz0OOt14JWcb0HXP7QVbB37aFyt66okpUKHwErt9LqE1 Ocassw5x7cqFSYLFLcQx9/MbhEhD+XKQZXWqfG9cC5e9+B4CYWLMcW3PvwOUysVdLxqH GGE770+shTaqpRtJevlXV2tHPu1oVGUH6/NoTGTwLkn+VAPz2qqzp4Pv4vx3B+3svX5t Bu1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:date:message-id:from :references:to:subject:arc-authentication-results; bh=m15I/0FwgyeHsDxhoD+n1vz2LlAmBllg0/q5daxRInA=; b=HJSJiFa1YxeZODm4p+WNlAbzYIMkzlVm89yYlX8rIFQIB2D8jhp55rohrmBwUxhezB pUGPCZiaZjKuBgADW7PfVek5X78YtAX6G4ARy00nmvhgof9uNlVgOTjlxHVv5K7Pcw+x jCeyoL6y5oemRaRtt9Bs47h2d/y6tBLLkF+l/u7UV6gk8Flub3xhjFnXd1/h9huuwdvh ZPxarJG6FeO2+bthBlXrYlf62rTo40gFhl8I5RCFUNnYSrfmojFW1Zf7W7AJYI0d9+GJ MMnoYGebDqQEjroy1lsYDVKPy3o5tKhlIBk8omys8wMbCRrb6dXi3XBrUln+bUSsAc0l E/4Q== 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 73si15684819pfb.204.2018.04.25.08.44.49; Wed, 25 Apr 2018 08:45:05 -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 S1755099AbeDYPnM (ORCPT + 99 others); Wed, 25 Apr 2018 11:43:12 -0400 Received: from mail.sysgo.com ([176.9.12.79]:57668 "EHLO mail.sysgo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754949AbeDYPnL (ORCPT ); Wed, 25 Apr 2018 11:43:11 -0400 Subject: Re: [PATCH] i2c: at91: Read all available bytes at once To: 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> From: David Engraf Message-ID: Date: Wed, 25 Apr 2018 17:43:09 +0200 MIME-Version: 1.0 In-Reply-To: <20180425150853.GU13305@rfolt0960.corp.atmel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Best regards - David > Regards > > Ludovic > >> + } >> >> /* >> * When a NACK condition is detected, the I2C controller sets the NACK, >> -- >> 2.14.1 >>