From patchwork Tue Oct 6 10:51:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Eggers X-Patchwork-Id: 11818471 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6CE906CA for ; Tue, 6 Oct 2020 11:03:10 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 392CD2080A for ; Tue, 6 Oct 2020 11:03:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="wJo1czQy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 392CD2080A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arri.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=iY1POGyH7Lv6hHCMxaa+TwmnQcZGUY0/oEnVOVpLliw=; b=wJo1czQyqNEysx9vHKkgupDls Nusp1euQGMOw86HmoAAB/vrOQ0wx9E/kslSsRw8bffcIWo4C4R0CKyFETamBYVviBLskH4eGQa5/W 3eSBNNWwKaJ0r/my4cVw69byIRaFYBSufq/i2f9gRDANTK1RhVEjrBJ3kfVlLMCnvCnTeskHDmO6z NdpVhnYzaf6NoAMNI3v0tVVHYJwFOhQptK1MA9f1XzuienkEd6eeVZdNGLwqaJ0B8VO5sr8rCzu6F qQRZpxTN3/aZn6l+MNxEHB0Ob8UV4lrNzsgf9OfsBKAcJCUVGlD+Lu7V7ZU1LsjfTFKfbnGAVvlLz 8LtHEhI0A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPkkE-0001Ts-M5; Tue, 06 Oct 2020 11:02:58 +0000 Received: from mailout06.rmx.de ([94.199.90.92]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPkkA-0001S0-22 for linux-arm-kernel@lists.infradead.org; Tue, 06 Oct 2020 11:02:55 +0000 Received: from kdin02.retarus.com (kdin02.dmz1.retloc [172.19.17.49]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout06.rmx.de (Postfix) with ESMTPS id 4C5F1Q4PpGz9x3G; Tue, 6 Oct 2020 13:02:50 +0200 (CEST) Received: from mta.arri.de (unknown [217.111.95.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by kdin02.retarus.com (Postfix) with ESMTPS id 4C5F0M619cz2TTMT; Tue, 6 Oct 2020 13:01:55 +0200 (CEST) Received: from N95HX1G2.wgnetz.xx (192.168.54.97) by mta.arri.de (192.168.100.104) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 6 Oct 2020 12:53:19 +0200 From: Christian Eggers To: Oleksij Rempel , Shawn Guo , Sascha Hauer , Fabio Estevam , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [PATCH v3 2/3] i2c: imx: Check for I2SR_IAL after every byte Date: Tue, 6 Oct 2020 12:51:34 +0200 Message-ID: <20201006105135.28985-3-ceggers@arri.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201006105135.28985-1-ceggers@arri.de> References: <20201006060528.drh2yoo2dklyntez@pengutronix.de> <20201006105135.28985-1-ceggers@arri.de> MIME-Version: 1.0 X-Originating-IP: [192.168.54.97] X-RMX-ID: 20201006-130201-4C5F0M619cz2TTMT-0@kdin02 X-RMX-SOURCE: 217.111.95.66 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201006_070254_255554_8C6C997B X-CRM114-Status: GOOD ( 15.05 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [94.199.90.92 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [94.199.90.92 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, NXP Linux Team , Pengutronix Kernel Team , Christian Eggers , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Arbitration Lost (IAL) can happen after every single byte transfer. If arbitration is lost, the I2C hardware will autonomously switch from master mode to slave. If a transfer is not aborted in this state, consecutive transfers will not be executed by the hardware and will timeout. Signed-off-by: Christian Eggers Cc: stable@vger.kernel.org --- drivers/i2c/busses/i2c-imx.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 745f4071155a..bf0e94814222 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -490,6 +490,16 @@ static int i2c_imx_trx_complete(struct imx_i2c_struct *i2c_imx, bool atomic) dev_dbg(&i2c_imx->adapter.dev, "<%s> Timeout\n", __func__); return -ETIMEDOUT; } + + /* check for arbitration lost */ + if (i2c_imx->i2csr & I2SR_IAL) { + dev_dbg(&i2c_imx->adapter.dev, "<%s> Arbitration lost\n", __func__); + i2c_imx_clear_irq(i2c_imx, I2SR_IAL); + + i2c_imx->i2csr = 0; + return -EAGAIN; + } + dev_dbg(&i2c_imx->adapter.dev, "<%s> TRX complete\n", __func__); i2c_imx->i2csr = 0; return 0;