Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp2009641pxu; Fri, 9 Oct 2020 05:50:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/04PRqFGwa7flzc4lUrwTA5mpTr4Hhjr/W1sDq7MwKUHVBfs8WWTlJDJeFqCUC5fJD9ri X-Received: by 2002:a50:da84:: with SMTP id q4mr14113838edj.238.1602247826306; Fri, 09 Oct 2020 05:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602247826; cv=none; d=google.com; s=arc-20160816; b=Yh4kCqR8O3vKws7+fGy1Ozca3H8inxpfIMAq83VXP9TYoDM0aiP0aYexVqjqbrZr51 bVkKv9tZSQ5E3VGMUjaMia+WJaCyowhAdgjG3Nd6d7WAYVBZY7PJNdD8Xeo7YreMOA9d G3o8Lx2zLOoEf2kJu0cBf360a1n49lBD0hoSIUA4WkSuyZna4yIYtFKjpddYES+kt/Fi urGXzr0tLM1D9feukTAhNnyfJnlaXn0Soe5C9UuBGPW58s7tSKGPzmiBG7qQUuz8MMo9 G0v2QHTLYlQplybP8+VSTWRZD4KRpf6P+0oq0DUO2cQe9ad3dDq7Y+o2hqRdkATbIUET Zg9A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cAeU9w/xyGIWDRsSrKzQQOALMENHSiPe1/hNOygtJJo=; b=SxIiySL1yh1UWd9V5q9w5tjiZX0WNwDyu5Wf7Q1NQejUy2hpkkNcPe1a/ZSyAwyE8z 6K7HCOw3Kz8YlOT0mVUVZ9icvcHKFi0eIZRFuOyxKp1JC+0O+dlmMV5ic3buZlx0Gf04 J4qRENplqP5kYBW8pE4HGHn5FD/0iEFX8yGfPoG/B0GG45cjEPaE3r7bmB0rdnPkafwO 8EVQNAqUXY3MVtOrXjXYMXB0kmKIj2g1KZU1/h3TNX2iHgCaBR1chFqqeVYEC57oaf0k qtX1/GqzEylX3Q6oiGaej0iAjkdZxgtThfvHy3HiPg/J6JwNn7S22Yqv4KxJgFpyLxWe I/Dw== 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 f12si7716468edx.121.2020.10.09.05.50.01; Fri, 09 Oct 2020 05:50:26 -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 S2387973AbgJILHc (ORCPT + 99 others); Fri, 9 Oct 2020 07:07:32 -0400 Received: from mailout05.rmx.de ([94.199.90.90]:54346 "EHLO mailout05.rmx.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732362AbgJILHb (ORCPT ); Fri, 9 Oct 2020 07:07:31 -0400 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 mailout05.rmx.de (Postfix) with ESMTPS id 4C74zL0hc2z9yDC; Fri, 9 Oct 2020 13:07:26 +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 4C74y91xJRz2TTLj; Fri, 9 Oct 2020 13:06:25 +0200 (CEST) Received: from N95HX1G2.wgnetz.xx (192.168.54.145) by mta.arri.de (192.168.100.104) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 9 Oct 2020 13:05:05 +0200 From: Christian Eggers To: Oleksij Rempel , Oleksij Rempel , Shawn Guo , Sascha Hauer , Fabio Estevam , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , "David Laight" CC: Pengutronix Kernel Team , NXP Linux Team , , , , Christian Eggers , Krzysztof Kozlowski , Subject: [PATCH v6 3/3] i2c: imx: Don't generate STOP condition if arbitration has been lost Date: Fri, 9 Oct 2020 13:03:20 +0200 Message-ID: <20201009110320.20832-4-ceggers@arri.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201009110320.20832-1-ceggers@arri.de> References: <20201009110320.20832-1-ceggers@arri.de> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [192.168.54.145] X-RMX-ID: 20201009-130633-4C74y91xJRz2TTLj-0@kdin02 X-RMX-SOURCE: 217.111.95.66 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If arbitration is lost, the master automatically changes to slave mode. I2SR_IBB may or may not be reset by hardware. Raising a STOP condition by resetting I2CR_MSTA has no effect and will not clear I2SR_IBB. So calling i2c_imx_bus_busy() is not required and would busy-wait until timeout. Signed-off-by: Christian Eggers Tested (not extensively) on Vybrid VF500 (Toradex VF50): Tested-by: Krzysztof Kozlowski Acked-by: Oleksij Rempel Cc: stable@vger.kernel.org # Requires trivial backporting, simple remove # the 3rd argument from the calls to # i2c_imx_bus_busy(). --- drivers/i2c/busses/i2c-imx.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 69ce5eea9b5a..e98356f3db84 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -615,6 +615,8 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx, bool atomic) /* Stop I2C transaction */ dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__); temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); + if (!(temp & I2CR_MSTA)) + i2c_imx->stopped = 1; temp &= ~(I2CR_MSTA | I2CR_MTX); if (i2c_imx->dma) temp &= ~I2CR_DMAEN; @@ -778,9 +780,12 @@ static int i2c_imx_dma_read(struct imx_i2c_struct *i2c_imx, */ dev_dbg(dev, "<%s> clear MSTA\n", __func__); temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); + if (!(temp & I2CR_MSTA)) + i2c_imx->stopped = 1; temp &= ~(I2CR_MSTA | I2CR_MTX); imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR); - i2c_imx_bus_busy(i2c_imx, 0, false); + if (!i2c_imx->stopped) + i2c_imx_bus_busy(i2c_imx, 0, false); } else { /* * For i2c master receiver repeat restart operation like: @@ -905,9 +910,12 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs, dev_dbg(&i2c_imx->adapter.dev, "<%s> clear MSTA\n", __func__); temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); + if (!(temp & I2CR_MSTA)) + i2c_imx->stopped = 1; temp &= ~(I2CR_MSTA | I2CR_MTX); imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR); - i2c_imx_bus_busy(i2c_imx, 0, atomic); + if (!i2c_imx->stopped) + i2c_imx_bus_busy(i2c_imx, 0, atomic); } else { /* * For i2c master receiver repeat restart operation like: -- Christian Eggers Embedded software developer Arnold & Richter Cine Technik GmbH & Co. Betriebs KG Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRA 57918 Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRB 54477 Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; Markus Zeiler