Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3425875yba; Mon, 29 Apr 2019 02:01:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxf6OrcWwzuUpZ/Ne5XoKXkfvDqW/F1V2lxUGwUMpwZOnokoRkzCYvacVVt2OAWdZPrHeh1 X-Received: by 2002:a17:902:6ac2:: with SMTP id i2mr37946318plt.260.1556528511765; Mon, 29 Apr 2019 02:01:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556528511; cv=none; d=google.com; s=arc-20160816; b=Cx76IWsSZ075gTMPHg2hfjCtUmsR7pvwLhPorUff626wN9IwKOEuLARmyb3dFozeZc uX0p/Wl9qzLQ85EJZL+MxHzwqgrIngUe1ewy5Sl6DpinJ00R6tn9RaRjmkZvP1sRyL5+ qwJYmLSDczDaLDjbyMuj481VvymmT/AA0F+kIfu1wSdjslBjiQejT+CcajEuHmI2dYoT StOJUF3CoSlFhL1b0BDmWYtc1zRq5fETFFsfnI+Wcnow+HLfO/z7H49+vIEp59ta8wXf 62O3OW/xyS8AnSRNF5ofKxKrkPBbK0SR/Kc0A25+eZTqZ9jUvgYJUYKYx5elz7Gwl+r5 IkUg== 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=IB8kSOS22V0bk3y1W2wbXXHN8qK+K9lfCVOwReB5R2g=; b=ViK6gsyZEZHviNU7nr0dLKKvtZPUlM2ixp7rBQ3ETp6nTnoDy+R5UWycHeMF4wfJf2 0DDwlsmcslB8NyF6n+ZLBUBDQDFhRlHHJ34yF8DZUIHmIouKqPQ81DsXgI6eC0dTppLe R4xitR2JuO9/zjwfT+QTYJ7yWk6ecF9w4E/kbhkvRuRuxVUP8TmyrbYi5s7FkM3iceGS OD3duhafZqgVcuQjhyTEk7Kfn/F8qUniiRqiUogvU63Oo4485vBZWrWre14BSPcpsBQu l5jNHRySoB9pnGLOa2GJ8pU4u5j7gog75tGtQ3zUwncUz5vdAzdltca2WrSTNSqd/Kmp pBsw== 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 n126si2725010pfn.198.2019.04.29.02.01.36; Mon, 29 Apr 2019 02:01:51 -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 S1727660AbfD2JAl (ORCPT + 99 others); Mon, 29 Apr 2019 05:00:41 -0400 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:30235 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727525AbfD2JAl (ORCPT ); Mon, 29 Apr 2019 05:00:41 -0400 X-IronPort-AV: E=Sophos;i="5.60,409,1549954800"; d="scan'208";a="30867583" 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; 29 Apr 2019 02:00:40 -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; Mon, 29 Apr 2019 02:00:39 -0700 Date: Mon, 29 Apr 2019 11:00:05 +0200 From: Ludovic Desroches To: Raag Jadav CC: , , , , Subject: Re: [PATCH] i2c: at91: handle TXRDY interrupt spam Message-ID: <20190429090005.f6ydghzu5n5yruav@M43218.corp.atmel.com> Mail-Followup-To: Raag Jadav , linux-i2c@vger.kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <1556005008-6318-1-git-send-email-raagjadav@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1556005008-6318-1-git-send-email-raagjadav@gmail.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > 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 > >