Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1672589pxb; Fri, 24 Sep 2021 09:24:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhBxucmVFWS1qaf+w5vqacsnGQgE+UYRPXbmoooOGYhO5HXEogSIlFLRYBkQkP/i4hLCkK X-Received: by 2002:a05:6e02:921:: with SMTP id o1mr8619383ilt.289.1632500665686; Fri, 24 Sep 2021 09:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632500665; cv=none; d=google.com; s=arc-20160816; b=CL0o/Nl2PqZvGz08kSA5EixBJ7IcdpqWAQvJd2s110VTjEnrhEmdYXEwwYxYnb02BS ZV6TmmODzj9FYEw3VSKFFXfiBvTw0Uo8RB4aAaknz8pN1rfZ+QUrJTRUB7nBuYUarvnz HqUQeiatYvULptuUKi5SQHGWh+5+v94sbSthA8vp1K5aqsTZAqRKQ/8NYtd6U9yA/A9G zTvn61F3Zgr9UCGMilbdoUzM7BSuJHBj2h/7dOSWD5THYhKtWPqbM/Qn94l8XEA0bwbn S/t0uSsHVERc7/Q1nNab407ojPlKkoF63Ny7N2PJYRuj3eJ2UdMvAt8Ie8aDHiZIXUD+ OOiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=6Z/i5I5PYsaAhLTRnI3YjH88xFptFtNKjvb6pW8/jNQ=; b=PZQm06DjC8dBG4QtpFABN8FG3DjH+oU4LLQ4Dd9V8pZhjngJoXQ2T67DyZ2eySshf8 2gM9OdC5Kfj8t+FuuircJuNmrCXnl9qBtLpCsUMIRKMwTCqiVgsAZ1BAVOrBs8J52fUL Q/rDFWJNAf3/rvhrDQUUgZhiTztadDMncTF/lno4K8m1Y8dyYsI+cytDdzfglauMLx2B AdsRfFXOPsNfwt6Nr74+NX/Gxbq/rEI7tXycs7PEJ5BqaEzBf2JJmYspE0ltfTLb2+Zl Ck+g8UPMNdGEZM51h+yGcfDbC9S2itO3BLjQKAeyP7S3ujFUV526DkxSzuzEJo+X69UY p0vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@megous.com header.s=mail header.b=jQokJeTa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=megous.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l11si11454938ilv.110.2021.09.24.09.24.05; Fri, 24 Sep 2021 09:24:25 -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; dkim=pass header.i=@megous.com header.s=mail header.b=jQokJeTa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=megous.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245109AbhIXLRc (ORCPT + 99 others); Fri, 24 Sep 2021 07:17:32 -0400 Received: from vps.xff.cz ([195.181.215.36]:34182 "EHLO vps.xff.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245092AbhIXLRb (ORCPT ); Fri, 24 Sep 2021 07:17:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megous.com; s=mail; t=1632482157; bh=34Gdmo0642tbeuZPW9xMHWN5BVp3DeIPofJxo02CEC4=; h=From:To:Subject:Date:From; b=jQokJeTan2xkic0EAF1IeKF14DZmV7zjr4hNZFk1T6rBw8XSKtUGEPAlS79EUSQrc OZ9A4xtrYQpuiReKJp2o2NoBOMJIxlTWuZ1DwiCOi4JTQvmdc33rImPQqXDIoasBGf d5R698DmaF140KY0y+FGkxOZTnFZ1ukzvhBJtaKc= From: Ondrej Jirman To: Heiko Stuebner , Wolfram Sang , Krzysztof Kozlowski , Ondrej Jirman , linux-arm-kernel@lists.infradead.org (moderated list:ARM/Rockchip SoC support), linux-rockchip@lists.infradead.org (open list:ARM/Rockchip SoC support), linux-i2c@vger.kernel.org (open list:I2C SUBSYSTEM HOST DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [RESEND PATCH] i2c: rk3x: Handle a spurious start completion interrupt flag Date: Fri, 24 Sep 2021 13:15:27 +0200 Message-Id: <20210924111528.2924251-1-megous@megous.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In a typical read transfer, start completion flag is being set after read finishes (notice ipd bit 4 being set): trasnfer poll=0 i2c start rk3x-i2c fdd40000.i2c: IRQ: state 1, ipd: 10 i2c read rk3x-i2c fdd40000.i2c: IRQ: state 2, ipd: 1b i2c stop rk3x-i2c fdd40000.i2c: IRQ: state 4, ipd: 33 This causes I2C transfer being aborted in polled mode from a stop completion handler: trasnfer poll=1 i2c start rk3x-i2c fdd40000.i2c: IRQ: state 1, ipd: 10 i2c read rk3x-i2c fdd40000.i2c: IRQ: state 2, ipd: 0 rk3x-i2c fdd40000.i2c: IRQ: state 2, ipd: 1b i2c stop rk3x-i2c fdd40000.i2c: IRQ: state 4, ipd: 13 i2c stop rk3x-i2c fdd40000.i2c: unexpected irq in STOP: 0x10 Clearing the START flag after read fixes the issue without any obvious side effects. This issue was dicovered on RK3566 when adding support for powering off the RK817 PMIC. Signed-off-by: Ondrej Jirman --- Re-sending, because originally, maintainers script did not pick up rockchip mailing list, to send this patch to. drivers/i2c/busses/i2c-rk3x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c index 819ab4ee517e..02ddb237f69a 100644 --- a/drivers/i2c/busses/i2c-rk3x.c +++ b/drivers/i2c/busses/i2c-rk3x.c @@ -423,8 +423,8 @@ static void rk3x_i2c_handle_read(struct rk3x_i2c *i2c, unsigned int ipd) if (!(ipd & REG_INT_MBRF)) return; - /* ack interrupt */ - i2c_writel(i2c, REG_INT_MBRF, REG_IPD); + /* ack interrupt (read also produces a spurious START flag, clear it too) */ + i2c_writel(i2c, REG_INT_MBRF | REG_INT_START, REG_IPD); /* Can only handle a maximum of 32 bytes at a time */ if (len > 32) -- 2.33.0