Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7260172yba; Thu, 2 May 2019 07:03:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZ3Bk/HA+ataMn7Hf35r8R1HvUA0U/+ybl2TKgjcOuUvmH9pKKkw788UUmlMjdNg1PKPHN X-Received: by 2002:a63:1301:: with SMTP id i1mr4099157pgl.226.1556805798646; Thu, 02 May 2019 07:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556805798; cv=none; d=google.com; s=arc-20160816; b=T3d2QMpd6NGSy8Fa8BbPNxMuuSSQqQ8YZJiCmYYlL3CxrGsvVAklUXWiSElK1MVgdM 8bYSnDNKSLlJovB2H0XD2ZrpHUvPBTeGfB8toRK0s9AM0poOqiNbAoM+uTQ+/oe3y8oX FvKxOKIgGBqldrSl46VJwozVnb+EWdDMA3Dc+HVga9mQ7+DiXWdF9VvgHrmLXR71J7KR ijkkf+E7ZuquiwVYMBaiIPM1eMeQ6dOix5HZ+cr/6i0EpDguimVld/kaWistHZs71f68 +9HEm3zP9tymzZ8FnMOqybQd9AItdLZ1o+iqAXaGcbjFL963UqdG40EQjrprmbGVk4Ek Ix9g== 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; bh=CTNcuXZCGLEww597AXdqA+fhQyS4B4rzvgdy91YNZqI=; b=NQwN8z35V/p3CrCQCk3TuWHQLAOIag8Ry19gfNi5cJOepsxRRXcjPu1s/PRIPw1BgY AJDm1ReMaKKUoGhQto8c+0StC0RWs+cXC0HRDT/KVB3YML6iXUKeJqPo8IgFmlhQvQdG tuharzRJ8WyUCt9VxUXs++Df0P058Avu/v0+Y24ztKFXNwqXgPldL7tBv3I0j/yYm7Cy U882tAI4bJtg1plJ0Zf3UR7HBL4jIg5FhJh3c8/8XFza3LS7cmXO15hT0xvZhx6hqqRi v/Q4SLvNrZQB+kk7Yjb428BUleyEnfWKo86PHq2Kvb1OMuaH3KiK7xQEW6qcRbA3xw8C fcTQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=microchip.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bb2si13810541plb.383.2019.05.02.07.03.01; Thu, 02 May 2019 07:03:18 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726357AbfEBOB4 (ORCPT + 99 others); Thu, 2 May 2019 10:01:56 -0400 Received: from esa3.microchip.iphmx.com ([68.232.153.233]:4669 "EHLO esa3.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726197AbfEBOBz (ORCPT ); Thu, 2 May 2019 10:01:55 -0400 Received-SPF: Pass (esa3.microchip.iphmx.com: domain of Ludovic.Desroches@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa3.microchip.iphmx.com; envelope-from="Ludovic.Desroches@microchip.com"; x-sender="Ludovic.Desroches@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa3.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa3.microchip.iphmx.com; envelope-from="Ludovic.Desroches@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa3.microchip.iphmx.com; dkim=none (message not signed) header.i=none; spf=Pass smtp.mailfrom=Ludovic.Desroches@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dmarc=pass (p=none dis=none) d=microchip.com X-IronPort-AV: E=Sophos;i="5.60,421,1549954800"; d="scan'208";a="31761172" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 02 May 2019 07:01:54 -0700 Received: from localhost (10.10.76.4) by chn-sv-exch07.mchp-main.com (10.10.76.108) with Microsoft SMTP Server id 14.3.352.0; Thu, 2 May 2019 07:01:53 -0700 Date: Thu, 2 May 2019 16:01:16 +0200 From: Ludovic Desroches To: Raag Jadav CC: , , , Subject: Re: [PATCH] i2c: at91: handle TXRDY interrupt spam Message-ID: <20190502140116.rim72idpgvq4h4vc@M43218.corp.atmel.com> Mail-Followup-To: Raag Jadav , linux-kernel@vger.kernel.org, alexandre.belloni@bootlin.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <1556005008-6318-1-git-send-email-raagjadav@gmail.com> <20190429090005.f6ydghzu5n5yruav@M43218.corp.atmel.com> <20190429223332.GA3908@pc> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20190429223332.GA3908@pc> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 30, 2019 at 04:03:32AM +0530, Raag Jadav wrote: > External E-Mail > > > On Mon, Apr 29, 2019 at 11:00:05AM +0200, Ludovic Desroches wrote: > > Hello Raag, > > > > On Tue, Apr 23, 2019 at 01:06:48PM +0530, Raag Jadav wrote: > > > External E-Mail > > > > > > > > > Performing i2c write operation while SDA or SCL line is held > > > or grounded by slave device, we go into infinite at91_twi_write_next_byte > > > loop with TXRDY interrupt spam. > > > > Sorry but I am not sure to have the full picture, the controller is in > > slave or master mode? > > > > SVREAD is only used in slave mode. When SVREAD is set, it means that a read > > access is performed and your issue concerns the write operation. > > > > Regards > > > > Ludovic > > Yes, even though the datasheet suggests that SVREAD is irrelevant in master mode, > TXRDY and SVREAD are the only ones being set in status register upon reproducing the issue. > Couldn't think of a better way to handle such strange behaviour. > Any suggestions would be appreciated. I have the confirmation that you can't rely on the SVREAD flag when in master mode. This flag should always have the same value. I am trying to understand what could lead to your situation. Can you give me more details. What kind of device it is? What does lead to this situation? Does it happen randomly or not? Regards Ludovic > > Cheers, > Raag > > > > > > > > > Signed-off-by: Raag Jadav > > > --- > > > drivers/i2c/busses/i2c-at91.c | 6 +++++- > > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c > > > index 3f3e8b3..b2f5fdb 100644 > > > --- a/drivers/i2c/busses/i2c-at91.c > > > +++ b/drivers/i2c/busses/i2c-at91.c > > > @@ -72,6 +72,7 @@ > > > #define AT91_TWI_TXCOMP BIT(0) /* Transmission Complete */ > > > #define AT91_TWI_RXRDY BIT(1) /* Receive Holding Register Ready */ > > > #define AT91_TWI_TXRDY BIT(2) /* Transmit Holding Register Ready */ > > > +#define AT91_TWI_SVREAD BIT(3) /* Slave Read */ > > > #define AT91_TWI_OVRE BIT(6) /* Overrun Error */ > > > #define AT91_TWI_UNRE BIT(7) /* Underrun Error */ > > > #define AT91_TWI_NACK BIT(8) /* Not Acknowledged */ > > > @@ -571,7 +572,10 @@ static irqreturn_t atmel_twi_interrupt(int irq, void *dev_id) > > > at91_disable_twi_interrupts(dev); > > > complete(&dev->cmd_complete); > > > } else if (irqstatus & AT91_TWI_TXRDY) { > > > - at91_twi_write_next_byte(dev); > > > + if ((status & AT91_TWI_SVREAD) && (dev->buf_len == 0)) > > > + at91_twi_write(dev, AT91_TWI_IDR, AT91_TWI_TXRDY); > > > + else > > > + at91_twi_write_next_byte(dev); > > > } > > > > > > /* catch error flags */ > > > -- > > > 2.7.4 > > > > > > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel >