Received: by 10.192.165.148 with SMTP id m20csp1615336imm; Wed, 25 Apr 2018 22:53:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx48E5yGFgXa6Pb5+x47JpfDWmwuVUIjiySOVXRwcaRBAk0xyrKHbEIG5ES7Fs5hvO1fe6fae X-Received: by 10.98.155.141 with SMTP id e13mr21515816pfk.157.1524722020503; Wed, 25 Apr 2018 22:53:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524722020; cv=none; d=google.com; s=arc-20160816; b=fl1T2mLv55+btIgyWO13zrXhYgi5vOC4Zsxmx62PFhPTYl65hKB9QuvTC+lidNrIS/ I6mwpwva6vbwwXGJwwNJDvv0d7ZYUA2Z9LIWoSkSgCpwZOTXNs6TSBntTc2A4mKSpU+X vmI52N0588Z0GWpBGOQmHAYYAFemRBiPChl7v073wxlVe+oGJrgSzO1eXT/OkbP+dBns 56/UKYDtqKVyCOmCFx2KDZ9LO7c2Ltgi7NxeXTeuvNpDN+B1MlMiiTnWgN4lkEbpNVq3 Tr0mCmmoTuyyFHmdcp2dMH4YSGGBp6bElhxrvV0lUq5LjD5Cy3SK2Wli2eGBPJaHX/g8 ymTA== 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:cc :references:to:subject:arc-authentication-results; bh=GrPuTOQW27tND9ipf6xnja/g/2QQ/VoSIrncudbQM4U=; b=LEqxlHGu1V4jGp9YXbDICXGIujVPyUulvUmD6zqH/3aRhQipcc23REkATz9ATzHaao jmHh0gOSRDxkuqwEUT7+g3UyQIkHwdVGTqzq479y9jboPXwmG7UsR0U09gKZX3GMNqFf V1Qo4H1WwFuDivo7ESzMwOs2p4VfzIes93MXUa2lE4gYqPjEGQz7ZJc9xBYy4ZMeJfnu li+IC3nPy/dzFi1iXJwade+J7gEQoQDMl4J83dMqQR1w3+jF3tyQv4w28rF7mPfcPQRG 5KPLs4mOAV8opxT4hctoOI/5jd7DPaddxJDIEE23EIoOEy0IDThPmmE9h1wJ94uH+9Uc R6xw== 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 b63si14384965pga.397.2018.04.25.22.53.26; Wed, 25 Apr 2018 22:53:40 -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 S1753007AbeDZFwW (ORCPT + 99 others); Thu, 26 Apr 2018 01:52:22 -0400 Received: from mail.sysgo.com ([176.9.12.79]:46128 "EHLO mail.sysgo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752895AbeDZFwT (ORCPT ); Thu, 26 Apr 2018 01:52:19 -0400 Subject: Re: [PATCH] i2c: at91: Read all available bytes at once To: Ludovic Desroches References: <20180418124055.21333-1-david.engraf@sysgo.com> <20180425150853.GU13305@rfolt0960.corp.atmel.com> Cc: nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org From: David Engraf Message-ID: Date: Thu, 26 Apr 2018 07:52:17 +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: 8bit 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 >> -- Mit freundlichen Grüßen/Best regards, David Engraf Product Engineer SYSGO AG Office Mainz Am Pfaffenstein 14 / D-55270 Klein-Winternheim / Germany Phone: +49-6136-9948-0 / Fax: +49-6136-9948-10 E-mail: david.engraf@sysgo.com _________________________________________________________________________________ Web: https://www.sysgo.com Blog: https://www.sysgo.com/blog Events: https://www.sysgo.com/events Newsletter: https://www.sysgo.com/newsletter _________________________________________________________________________________ Handelsregister/Commercial Registry: HRB Mainz 90 HRB 8066 Vorstand/Executive Board: Etienne Butery (CEO), Kai Sablotny (COO) Aufsichtsratsvorsitzender/Supervisory Board Chairman: Marc Darmon USt-Id-Nr./VAT-Id-No.: DE 149062328