From patchwork Thu Jan 5 12:06:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 9498955 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B37A9606B5 for ; Thu, 5 Jan 2017 12:07:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93BD827F07 for ; Thu, 5 Jan 2017 12:07:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81D782832D; Thu, 5 Jan 2017 12:07:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F95527F17 for ; Thu, 5 Jan 2017 12:07:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751335AbdAEMHj (ORCPT ); Thu, 5 Jan 2017 07:07:39 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:10124 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762610AbdAEMHh (ORCPT ); Thu, 5 Jan 2017 07:07:37 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OJB005O030HTP30@mailout4.w1.samsung.com>; Thu, 05 Jan 2017 12:07:29 +0000 (GMT) Received: from eusmges1.samsung.com (unknown [203.254.199.239]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170105120728eucas1p2893338aaefb9e84d43670da99a3b990a~W3sE1QSpG0888008880eucas1p2K; Thu, 5 Jan 2017 12:07:28 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1.samsung.com (EUCPMTA) with SMTP id 85.3D.32567.2073E685; Thu, 5 Jan 2017 12:07:30 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170105120727eucas1p2b9452792b7d13d551974305b478a26e2~W3sD7cQIZ0409804098eucas1p2j; Thu, 5 Jan 2017 12:07:27 +0000 (GMT) X-AuditID: cbfec7ef-f79336d000007f37-61-586e37027b8d Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 5E.BA.03557.E273E685; Thu, 5 Jan 2017 12:08:14 +0000 (GMT) Received: from AMDC2768.DIGITAL.local ([106.120.43.17]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OJB00JJW30F9E40@eusync4.samsung.com>; Thu, 05 Jan 2017 12:07:27 +0000 (GMT) From: Andrzej Hajda To: linux-i2c@vger.kernel.org Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , Wolfram Sang , Krzysztof Kozlowski , Javier Martinez Canillas , linux-samsung-soc@vger.kernel.org Subject: [PATCH] i2c: exynos5: fix arbitration lost handling Date: Thu, 05 Jan 2017 13:06:53 +0100 Message-id: <1483618013-10721-1-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrIIsWRmVeSWpSXmKPExsWy7djPc7pM5nkRBvcWWFrcWneO1WLjjPWs Fm/ermGyOH9+A7tFx98vjBYzzu9jslh75C67xcoTs5gdODw2repk89jSf5fdo2/LKkaPk6ee sHh83iQXwBrFZZOSmpNZllqkb5fAlf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BzUwSU86cA5sk LGAjMf3NbbAiFgFViae9l1m7GDk4eAWcJSZ8K4VYJidx81wn8wRG7gWMDKsYRVJLi3PTc4sN 9YoTc4tL89L1kvNzNzECg3TbsZ+bdzBe2hh8iFGAg1GJh/fGj5wIIdbEsuLK3EOMEhzMSiK8 84zyIoR4UxIrq1KL8uOLSnNSiw8xmgLtnsgsJZqcD4ygvJJ4QxNDc0tDI2MLC3MjIyVx3pIP V8KFBNITS1KzU1MLUotg+pg4OKUaGB0WOzU4LpmbKWj35HHjzAcabxNuC65zDgg2WGP5vPzJ fneetDPXlzt6bGIrOCJmPdMpUGOhvEfyars3PzY/Sz3h65nBvNC3yGb9jd/m4qoynVMVm3e/ usvx9+PShvu5p5kuFd8oDLE8tE3u8IENa24zyRy/PfXfHLem5F8h079X7I3pex0x+4sSS3FG oqEWc1FxIgAqkhTYaAIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170105120727eucas1p2b9452792b7d13d551974305b478a26e2 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?QW5kcnplaiBIYWpkYRtTUlBPTC1LZXJuZWwgKFRQKRvsgrw=?= =?UTF-8?B?7ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?QW5kcnplaiBIYWpkYRtTUlBPTC1LZXJuZWwgKFRQKRtTYW1z?= =?UTF-8?B?dW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170105120727eucas1p2b9452792b7d13d551974305b478a26e2 X-RootMTR: 20170105120727eucas1p2b9452792b7d13d551974305b478a26e2 References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case of arbitration lost adequate interrupt sometimes is not signaled. As a result transfer timeouts and is not retried, as it should. To avoid such cases code is added to check transaction status in case of every interrupt. Signed-off-by: Andrzej Hajda Reviewed-by: Andi Shyti Tested-by: Andi Shyti --- Hi, I am not I2C specialist, this patch is a result of debugging issues with SiI8620 MHL driver on TM2 device. I guess the main problem is with SiI8620 chip, but exynos5 i2c is also guilty - with i2c-gpio driver it works correctly - there is only one arbitration lost at 1st transaction (which is properly handled - transfer is repeated succesfully). In case of exynos5 there are much more arbitration losts. Lowering bus speed decreases frequency of losts but do not eliminate them. Any help/hint, what could cause such issues? I guess increasing adap.retries should also decrease fail probability, currently for exynos5 it is set to 3. Regards Andrzej --- drivers/i2c/busses/i2c-exynos5.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c index bea6071..a01c1ae 100644 --- a/drivers/i2c/busses/i2c-exynos5.c +++ b/drivers/i2c/busses/i2c-exynos5.c @@ -130,12 +130,32 @@ /* I2C_TRANS_STATUS register bits */ #define HSI2C_MASTER_BUSY (1u << 17) #define HSI2C_SLAVE_BUSY (1u << 16) + +/* I2C_TRANS_STATUS register bits for Exynos5 variant */ #define HSI2C_TIMEOUT_AUTO (1u << 4) #define HSI2C_NO_DEV (1u << 3) #define HSI2C_NO_DEV_ACK (1u << 2) #define HSI2C_TRANS_ABORT (1u << 1) #define HSI2C_TRANS_DONE (1u << 0) +/* I2C_TRANS_STATUS register bits for Exynos7 variant */ +#define HSI2C_MASTER_ST_MASK 0xf +#define HSI2C_MASTER_ST_IDLE 0x0 +#define HSI2C_MASTER_ST_START 0x1 +#define HSI2C_MASTER_ST_RESTART 0x2 +#define HSI2C_MASTER_ST_STOP 0x3 +#define HSI2C_MASTER_ST_MASTER_ID 0x4 +#define HSI2C_MASTER_ST_ADDR0 0x5 +#define HSI2C_MASTER_ST_ADDR1 0x6 +#define HSI2C_MASTER_ST_ADDR2 0x7 +#define HSI2C_MASTER_ST_ADDR_SR 0x8 +#define HSI2C_MASTER_ST_READ 0x9 +#define HSI2C_MASTER_ST_WRITE 0xa +#define HSI2C_MASTER_ST_NO_ACK 0xb +#define HSI2C_MASTER_ST_LOSE 0xc +#define HSI2C_MASTER_ST_WAIT 0xd +#define HSI2C_MASTER_ST_WAIT_CMD 0xe + /* I2C_ADDR register bits */ #define HSI2C_SLV_ADDR_SLV(x) ((x & 0x3ff) << 0) #define HSI2C_SLV_ADDR_MAS(x) ((x & 0x3ff) << 10) @@ -437,6 +457,7 @@ static irqreturn_t exynos5_i2c_irq(int irqno, void *dev_id) int_status = readl(i2c->regs + HSI2C_INT_STATUS); writel(int_status, i2c->regs + HSI2C_INT_STATUS); + trans_status = readl(i2c->regs + HSI2C_TRANS_STATUS); /* handle interrupt related to the transfer status */ if (i2c->variant->hw == HSI2C_EXYNOS7) { @@ -460,8 +481,13 @@ static irqreturn_t exynos5_i2c_irq(int irqno, void *dev_id) i2c->state = -ETIMEDOUT; goto stop; } + + switch (trans_status & HSI2C_MASTER_ST_MASK) { + case HSI2C_MASTER_ST_LOSE: + i2c->state = -EAGAIN; + goto stop; + } } else if (int_status & HSI2C_INT_I2C) { - trans_status = readl(i2c->regs + HSI2C_TRANS_STATUS); if (trans_status & HSI2C_NO_DEV_ACK) { dev_dbg(i2c->dev, "No ACK from device\n"); i2c->state = -ENXIO;