Received: by 10.192.165.148 with SMTP id m20csp1829302imm; Thu, 26 Apr 2018 02:56:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx48GEHCKBnsq/LzepHweMA9a4DUIFo25kkXdsfIeExeQsrBvzrqSJmUP8J1XNx5Lsv1kD085 X-Received: by 10.101.97.200 with SMTP id j8mr26906758pgv.443.1524736562544; Thu, 26 Apr 2018 02:56:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524736562; cv=none; d=google.com; s=arc-20160816; b=RfLDeV08xOzp74B9A7l0NKzIbMh0adbWzwpz2DZqiZm4ICUAy+5ioPMn5F+RMHqP1A mUDFM2A1NO/z9odEpcrdYjmt7vP6aaYwofWFgq56MNldynj/oedEi5LMK2Hvc0uI5+zH 5JKZDuOxsblNvnkjvqcOSQYzlGmAoYvA7q12MuRd/WMwZqjMMkJoPgQPg1yFvUumylYd O/+jc/9lraJsVYlYV2V7gjKANFuGxIGCBK6q7p56hAmoLDHGMky+N1fDi5irBfxYeQus tjwzrbeamt2aEKG+oj2a/sKsKUshfKzuBqRHqzQL/NcoRn7aUn/rtUtoFQwq/kWNzFY0 5lHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=CXY9/xtuiLkaiUwmpQ1jq47ZZEW4p1rbaXr+rSJ2VsY=; b=rP76hOcn2mP21PUl4CO8RmZGxlLXr1CXa0i2vInB1jUsX/W17Qu6AJb5jROI0aMpag phPCDgUk4XaFhYdMV8OmaNuOvlyjD4UVFaeZVMTc//lY4U/9jAGf1BdqlqSFCoidSACh Kn2u80atm6QhHDiLHUr7IheWREOoo5bsnlAPF+amsEE8pjRUPzQ9aS2lbiTyHC4WFQws 98AAzrkyFh1hUhibheYta9VHTDkVB472RJsClirXFF/XxYWWH50B89VthcASlwL+eD9s z1xN6nXbc775V/vT+OVJAcwfdH88ftnGaP+W65v4KEfMLpum2b4gCfez/Ha1BEskmBDa Wndg== 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 l1si5326491pgf.398.2018.04.26.02.55.48; Thu, 26 Apr 2018 02:56:02 -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 S1755557AbeDZJyH (ORCPT + 99 others); Thu, 26 Apr 2018 05:54:07 -0400 Received: from mail.sysgo.com ([176.9.12.79]:55510 "EHLO mail.sysgo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754959AbeDZJyA (ORCPT ); Thu, 26 Apr 2018 05:54:00 -0400 From: David Engraf To: ludovic.desroches@microchip.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, David Engraf Subject: [PATCH v2] i2c: at91: Read all available bytes at once Date: Thu, 26 Apr 2018 11:53:14 +0200 Message-Id: <20180426095314.12758-1-david.engraf@sysgo.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180426082558.GX13305@rfolt0960.corp.atmel.com> References: <20180426082558.GX13305@rfolt0960.corp.atmel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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