Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp169462ybz; Tue, 28 Apr 2020 20:59:20 -0700 (PDT) X-Google-Smtp-Source: APiQypLzJhTwxS2SNnsj3BXNyYTpnCgYdFxtHEnQmzSW8jnWtKrDjn4eOUPSyWYqiMxSBO5x+WBg X-Received: by 2002:a17:907:1199:: with SMTP id uz25mr775838ejb.131.1588132760235; Tue, 28 Apr 2020 20:59:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588132760; cv=none; d=google.com; s=arc-20160816; b=rmYNSjsupDOji5KYgjtunrX25NahYeopMTGRiv6C3gXyk8UXaAmo7SDHmC8LQvLmxS HiTZrVOAwWi0BjSLhz9kxcU1pnZzEsFJ/xeB6mdl5LovFrI3og6lZGwSUVFwOE9REFXI 4awxo4Ysby9BZsrzR4qRuGXrKn9loMvJ0MpVBnd9n7sSiAzO/rKePZM4xaVFbrOim5Fa mB+DwoZDPaw73r9Zgl6yMkax8d6vaQOy6/MYoA3gA6FJLwsOrS7DsyUsjbNxfq7OsN0V 5hO4ngT8U9rn9h9soEjMoZtcvF9VMSS1OYmkwamXxNj5RotfCK13JalKtEuSV5xeMMDJ qDmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=T2wSR9YZla+uNEIWPuf0WMLPnmXyutRu/b8S3UEEx5o=; b=gEojkBxclqpX8PFU2b/zPJuMPKWSFfaGZiTwotoganozcQc6HrQz+fufR7njku+Bk/ Kvq3PaFQ4JabHlpADV8PaWeYZObe/VcItGTmvWA/gLvfHejfedgr/IVjHuL7Nfn3i599 Wh9uhigygjwgv4cCmrLGI2FAoPZ5m9ycnasggt8nDRZGqHMLHdW5E1NQWLpAPAWGA8cX hJvvEGKUbDjmameGxcVMFm1nAc+znO2XV4qxFad0/UzbCtWnjxUpRkyyvnSk+8Q2wYv9 WSz2B/LBL0NkM8uGjfADyJm2sCY+WKOsLx6GV5n8TPKvGtPYxFKnhbgzT1vT3CVTKc7/ 8O/A== 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 c12si2922771edx.92.2020.04.28.20.58.56; Tue, 28 Apr 2020 20:59:20 -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 S1726678AbgD2D5a (ORCPT + 99 others); Tue, 28 Apr 2020 23:57:30 -0400 Received: from twspam01.aspeedtech.com ([211.20.114.71]:42883 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726548AbgD2D53 (ORCPT ); Tue, 28 Apr 2020 23:57:29 -0400 X-Greylist: delayed 1176 seconds by postgrey-1.27 at vger.kernel.org; Tue, 28 Apr 2020 23:57:28 EDT Received: from twspam01.aspeedtech.com (localhost [127.0.0.2] (may be forged)) by twspam01.aspeedtech.com with ESMTP id 03T3S2BK051729 for ; Wed, 29 Apr 2020 11:28:02 +0800 (GMT-8) (envelope-from ryan_chen@aspeedtech.com) Received: from mail.aspeedtech.com (twmbx02.aspeed.com [192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 03T3Rxv1051700; Wed, 29 Apr 2020 11:27:59 +0800 (GMT-8) (envelope-from ryan_chen@aspeedtech.com) Received: from localhost.localdomain (192.168.100.253) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.620.29; Wed, 29 Apr 2020 11:37:52 +0800 From: ryan_chen To: Brendan Higgins , Benjamin Herrenschmidt , Joel Stanley , Andrew Jeffery , , , , , CC: ryan_chen Subject: [PATCH v0 linux master] i2c/busses: Avoid i2c interrupt status clear race condition. Date: Wed, 29 Apr 2020 11:37:37 +0800 Message-ID: <20200429033737.2781-1-ryan_chen@aspeedtech.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.100.253] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 03T3Rxv1051700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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