Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp355020ybz; Wed, 29 Apr 2020 01:15:24 -0700 (PDT) X-Google-Smtp-Source: APiQypI3KWWANtTmBusYb8psNipdUPHOOZYl14MNasX/eI9JZBF4JtpTBbDgMWJ/zUzsjeEdLP7Q X-Received: by 2002:a17:906:1fd6:: with SMTP id e22mr1564450ejt.150.1588148124444; Wed, 29 Apr 2020 01:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588148124; cv=none; d=google.com; s=arc-20160816; b=dPcfvOv7OllfY/32tszF2Foa6jDM0Urlq8jSSLTDfqf+U+ewv2hkLOmmFMBpoU3LY/ MfJ6KgIk16u6JTxLaLAsu96pHaB7qG0cf0bFIXshAeQ69x830gkNBfOgEQCO1n6rmU4S N1c4guPqpba7PHMKmczXtEDjiuqZd9bh2iYCL17YXfepzx+Cwj3C48LyYZyyYt4kEpO9 2DRKdpPXO9lzMkMo9O1LQHYasuyNxp7K6gFoI5M9b00nxKsp09ylfXUggx8IX9qsAZy/ 9WF2+8O+XSyK2bX7k6zNGaCNUnqEDDcIT66I/bXg5AFiZcufQm+kKl40JqZniDedAoxT fJTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=IPSkkkPA2hL4I9IaaW2/U4FTJ5JvgbvBwuRBFt1B1tQ=; b=PbPl/oEMDn9CsACSY7t7wTHjQmJ/Hg2JGOO4XMPgFnAU3wAhZSoToElp1DE+tuMymj AZ0ANse5Wy+v5HnVK23LPxtR8J772KPYXfuEaqMK+c60ooxGqqULQwq00kIVDYVEWP9R MgLD2qWouVRjlYSaOWaVK0BhTvLK4H/1BwwF+rDVhJBpC67ofFVu190Ekt9qArbYktmV YtQTFuFSLPXbdlxO1yjB1x572QlaIkT3ehthG28YJH6Nu4TOmHoKdASutgC40RJxpUqg bzaqIvUGVtHD6oIIEskUSCMvzsAuVdXOQd1MHLPakm2Ip3YA8G0xKyWgFfkei0Zjct3a fdNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si3690655ejc.247.2020.04.29.01.15.00; Wed, 29 Apr 2020 01:15:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726447AbgD2INg convert rfc822-to-8bit (ORCPT + 99 others); Wed, 29 Apr 2020 04:13:36 -0400 Received: from twspam01.aspeedtech.com ([211.20.114.71]:57593 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726355AbgD2INg (ORCPT ); Wed, 29 Apr 2020 04:13:36 -0400 Received: from mail.aspeedtech.com (twmbx02.aspeed.com [192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 03T82qFe086043; Wed, 29 Apr 2020 16:02:52 +0800 (GMT-8) (envelope-from ryan_chen@aspeedtech.com) Received: from TWMBX02.aspeed.com (192.168.0.24) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.620.29; Wed, 29 Apr 2020 16:12:46 +0800 Received: from TWMBX02.aspeed.com ([fe80::997d:c0a7:f01f:e1a7]) by TWMBX02.aspeed.com ([fe80::997d:c0a7:f01f:e1a7%12]) with mapi id 15.00.0620.020; Wed, 29 Apr 2020 16:12:45 +0800 From: Ryan Chen To: Wolfram Sang CC: Brendan Higgins , Benjamin Herrenschmidt , Joel Stanley , Andrew Jeffery , "linux-i2c@vger.kernel.org" , "openbmc@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" , "linux-aspeed@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v0 linux master] i2c/busses: Avoid i2c interrupt status clear race condition. Thread-Topic: [PATCH v0 linux master] i2c/busses: Avoid i2c interrupt status clear race condition. Thread-Index: AQHWHdeQ1mqTBOPAdE+n+yVhmYVsFKiPNOCAgACLErA= Date: Wed, 29 Apr 2020 08:12:45 +0000 Message-ID: <56add9c6e6b5410986325a1360466e4b@TWMBX02.aspeed.com> References: <20200429033737.2781-1-ryan_chen@aspeedtech.com> <20200429075357.GA1957@kunai> In-Reply-To: <20200429075357.GA1957@kunai> Accept-Language: zh-TW, en-US Content-Language: zh-TW X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.2.87] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 03T82qFe086043 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org -----Original Message----- From: Wolfram Sang [mailto:wsa@the-dreams.de] Sent: Wednesday, April 29, 2020 3:54 PM To: Ryan Chen Cc: Brendan Higgins ; Benjamin Herrenschmidt ; Joel Stanley ; Andrew Jeffery ; linux-i2c@vger.kernel.org; openbmc@lists.ozlabs.org; linux-arm-kernel@lists.infradead.org; linux-aspeed@lists.ozlabs.org; linux-kernel@vger.kernel.org Subject: Re: [PATCH v0 linux master] i2c/busses: Avoid i2c interrupt status clear race condition. On Wed, Apr 29, 2020 at 11:37:37AM +0800, ryan_chen wrote: > In AST2600 there have a slow peripheral bus between CPU and i2c > controller. > Therefore GIC i2c interrupt status clear have delay timing, when CPU > issue write clear i2c controller interrupt status. > To avoid this issue, the driver need have read after write clear at > i2c ISR. > > Signed-off-by: ryan_chen v0? is it a prototype? [Ryan Chen] It is not prototype it is official patch. And is there maybe a Fixes: tag for it? [Ryan Chen] Yes it is a fix patch. > --- > drivers/i2c/busses/i2c-aspeed.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/i2c/busses/i2c-aspeed.c > b/drivers/i2c/busses/i2c-aspeed.c index 07c1993274c5..f51702d86a90 > 100644 > --- a/drivers/i2c/busses/i2c-aspeed.c > +++ b/drivers/i2c/busses/i2c-aspeed.c > @@ -603,6 +603,7 @@ static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id) > /* Ack all interrupts except for Rx done */ > writel(irq_received & ~ASPEED_I2CD_INTR_RX_DONE, > bus->base + ASPEED_I2C_INTR_STS_REG); > + readl(bus->base + ASPEED_I2C_INTR_STS_REG); > irq_remaining = irq_received; > > #if IS_ENABLED(CONFIG_I2C_SLAVE) > @@ -645,9 +646,11 @@ static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id) > irq_received, irq_handled); > > /* Ack Rx done */ > - if (irq_received & ASPEED_I2CD_INTR_RX_DONE) > + if (irq_received & ASPEED_I2CD_INTR_RX_DONE) { > writel(ASPEED_I2CD_INTR_RX_DONE, > bus->base + ASPEED_I2C_INTR_STS_REG); > + readl(bus->base + ASPEED_I2C_INTR_STS_REG); > + } > spin_unlock(&bus->lock); > return irq_remaining ? IRQ_NONE : IRQ_HANDLED; } > -- > 2.17.1 >