Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1691827ybz; Thu, 30 Apr 2020 03:55:30 -0700 (PDT) X-Google-Smtp-Source: APiQypIngcIKRgJaqsEHu5XerTi1F6dqQKuinx9Ebsy++HPKXaqNukRVTsWJhFR69fWePHDuGBUm X-Received: by 2002:a17:906:a390:: with SMTP id k16mr1951669ejz.219.1588244130157; Thu, 30 Apr 2020 03:55:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588244130; cv=none; d=google.com; s=arc-20160816; b=eZvnmX6Vbv9FyF6QIE7klHUbxopbDN+J9rMCrDFYmIVLnmSU7elGIDlW9C1lx2Ofmw fGf7i/RrIRZwOr56A7Fbqv2vCact0YNdPqbcOlX4uOn35Ev4E44ZtH8Lf8E75+Tk3HYi sLfHqkz06XASx/ieUvF2HtbT60fNTW5B39AfFG33/dfHyW0gjAhtV5wlyRs6Ge7IFAn+ DCAC47ocQ9YhpAIYLYUqaWlHBJtMeZjatX6f+2nB/dnooKqdRyyTsmFrjv/xL1+beqtA qhdACILJsa20y2H22KmXNlgtK509Oa5qWXyWDS0QOE1uDugHj7PE+vu8/DKEQGGCdlYn E2fg== 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:mime-version :references:in-reply-to:date:to:from:subject:message-id; bh=2Qc2gbJqPnrGSc0eR7cTYXr/Smd2uI2DC1kQ1e8VzME=; b=Cy/YNVMIDQbDi30qrLyS1AOz0OQF3F/NLnIFr8Rl+PfaMJ0B2pSdAytTfcKhQXiJXm 60HzoVctXh+Dg8Vyi21fKkWdjBmivF3+yY7UTwmjVM6exPEas+ubnw61+rNGarFDS/yU BfmW4fGDUuNdzH6GraCNkehSOxpiArvVVcZubcDvqvjeZ/ZCCl+u+p3Sp9HnsQHggxes fuexOsEZguP7L087WEMJnSQetWi8f8SUq4KII+eY0F05PurFXtlDOobXKlf8uEQea5vI 9vYGzMG9dxgCiElm0ssvrQazlVqgx2qi/Kr9eJk/Cf8mLEbu2DizipBp62rowTVowKcR beng== 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 r2si4966254edq.362.2020.04.30.03.55.07; Thu, 30 Apr 2020 03:55:30 -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 S1726765AbgD3Kxo (ORCPT + 99 others); Thu, 30 Apr 2020 06:53:44 -0400 Received: from kernel.crashing.org ([76.164.61.194]:50492 "EHLO kernel.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726405AbgD3Kxn (ORCPT ); Thu, 30 Apr 2020 06:53:43 -0400 Received: from localhost (gate.crashing.org [63.228.1.57]) (authenticated bits=0) by kernel.crashing.org (8.14.7/8.14.7) with ESMTP id 03UAqvDf025142 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 30 Apr 2020 05:53:01 -0500 Message-ID: <9b5fbaf29adccc5abb66c3d39ecc92a2d5f10d10.camel@kernel.crashing.org> Subject: Re: [PATCH v0 linux master] i2c/busses: Avoid i2c interrupt status clear race condition. From: Benjamin Herrenschmidt To: ryan_chen , Brendan Higgins , 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 Date: Thu, 30 Apr 2020 20:52:56 +1000 In-Reply-To: <20200429033737.2781-1-ryan_chen@aspeedtech.com> References: <20200429033737.2781-1-ryan_chen@aspeedtech.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-04-29 at 11:37 +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 Acked-by: Benjamin Herrenschmidt -- > --- > 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; > }