From patchwork Wed Feb 22 11:04:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 9586613 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 8C0EE6020B for ; Wed, 22 Feb 2017 11:04:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 681CC28683 for ; Wed, 22 Feb 2017 11:04:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CC1E288C4; Wed, 22 Feb 2017 11:04:45 +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 7F5D1288BC for ; Wed, 22 Feb 2017 11:04:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754543AbdBVLEo (ORCPT ); Wed, 22 Feb 2017 06:04:44 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:46557 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754381AbdBVLEm (ORCPT ); Wed, 22 Feb 2017 06:04:42 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OLR00JGEW3R7DA0@mailout1.w1.samsung.com>; Wed, 22 Feb 2017 11:04:39 +0000 (GMT) Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170222110439eucas1p2ab0cf0ab9dd98afb7d30e24319e3ab9f~lly7K9oTa0789907899eucas1p2D; Wed, 22 Feb 2017 11:04:39 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges5.samsung.com (EUCPMTA) with SMTP id 68.F6.17477.6407DA85; Wed, 22 Feb 2017 11:04:38 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170222110438eucas1p2329ece7afd9e22ba185da64ccf4b2981~lly6iSrHi3098130981eucas1p2v; Wed, 22 Feb 2017 11:04:38 +0000 (GMT) X-AuditID: cbfec7f5-f79d06d000004445-10-58ad70460504 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 6E.FD.06687.B907DA85; Wed, 22 Feb 2017 11:06:03 +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 <0OLR00L2UW3PZ310@eusync4.samsung.com>; Wed, 22 Feb 2017 11:04:38 +0000 (GMT) From: Andrzej Hajda To: Wolfram Sang , Krzysztof Kozlowski , Javier Martinez Canillas , linux-i2c@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , Andi Shyti Subject: [PATCH v2] i2c: exynos5: fix arbitration lost handling Date: Wed, 22 Feb 2017 12:04:34 +0100 Message-id: <1487761474-11547-1-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFIsWRmVeSWpSXmKPExsWy7djPc7puBWsjDA72mlrcWneO1WL7kWes FhtnrGe1ePN2DZPF+fMb2C06/n5htJhxfh+Txdojd9ktVp6YxezA6bFpVSebx5b+u+wefVtW M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CcRiaJpa+/sIJUsQloSvzdfBOsSkTgAKPEtrP/2EEcZoGtjBIL pjQxg1QJC9hLPLr8AMxmEVCV2Dh3GSOIzSvgLHFrVz/UPjmJm+c6mScwci9gZFjFKJJaWpyb nltsqFecmFtcmpeul5yfu4kRGLTbjv3cvIPx0sbgQ4wCHIxKPLwP3NdECLEmlhVX5h5ilOBg VhLhFUhaGyHEm5JYWZValB9fVJqTWnyI0RRo+URmKdHkfGBE5ZXEG5oYmlsaGhlbWJgbGSmJ 85Z8uBIuJJCeWJKanZpakFoE08fEwSnVwDjVMzP7xwzRn+//Bv1Kyw+be1zQt07vOZ/JXI1/ S21OJ2+RynQ2VxZa+P7urPbvs3eXcy1uPpAlVv/53++6OcaLVZeEKMy+vrntUJ7QP/kv9vFN XztsBJTMTrudfX6JSUJg0VuvPbFu++ZdqZnq/Ug9Z9MKhxf7bjDc+aemYhzI0s3k+b+3P1eJ pTgj0VCLuag4EQD9ZhfWcAIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170222110438eucas1p2329ece7afd9e22ba185da64ccf4b2981 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: 20170222110438eucas1p2329ece7afd9e22ba185da64ccf4b2981 X-RootMTR: 20170222110438eucas1p2329ece7afd9e22ba185da64ccf4b2981 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 Tested-by: Andi Shyti Reviewed-by: Andi Shyti --- Hi Wolfram, I have postponed this patch because I was looking for better solution, but it seems that this patch together with 'disable fifo-almost-empty...' patch solves the issue of arbitration lost completely. The patch has been adjusted according to your comment. Regards Andrzej v2: - replaced switch with if clause, - commit message fits 75 chars limit. drivers/i2c/busses/i2c-exynos5.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c index 00e81e3..cbd93ce 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,12 @@ static irqreturn_t exynos5_i2c_irq(int irqno, void *dev_id) i2c->state = -ETIMEDOUT; goto stop; } + + if ((trans_status & HSI2C_MASTER_ST_MASK) == 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;