From patchwork Mon May 11 19:44:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 6383691 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E5BDFBEEE1 for ; Mon, 11 May 2015 19:47:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0302820C0A for ; Mon, 11 May 2015 19:47:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED9EB20C03 for ; Mon, 11 May 2015 19:47:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yrtda-0004fB-6X; Mon, 11 May 2015 19:45:14 +0000 Received: from mail-ig0-x22d.google.com ([2607:f8b0:4001:c05::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YrtdU-0003O7-Bq for linux-arm-kernel@lists.infradead.org; Mon, 11 May 2015 19:45:09 +0000 Received: by igbpi8 with SMTP id pi8so80532780igb.1 for ; Mon, 11 May 2015 12:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=SzEVG/fg4TBL6T9BD7iP9KvD0hpjfww8bJjvSTlVE54=; b=OyZ62tovuByBJj2KB/oFxVxYinXmkZDA0A4rjguUUsq/XlGOGR1V7Qtqkd798dRt/m kNISp6qmXuJdsUlub9B8FW89pd0bdZnkDfulyCIxuuNWz+eh/nBnnfVsp95bvFgfXmni J5R7Su9+0wHjDPbVzQLcu1j4A6JsyjmhywzVw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-type:content-transfer-encoding; bh=SzEVG/fg4TBL6T9BD7iP9KvD0hpjfww8bJjvSTlVE54=; b=moqX3l19UV0afvOm5eYknXwv+tQ/2JrKaFD3iptdPuW6w/aBsSVnLxhp2HMji0DQBu 778WVm2TELPaN0X9ICf5BROXSRLzbPbn6NsVXZgl76OOoSO5kOBmRrZh/lsoFdPvTDOV BUdKnvIDW8wyQlj60jJPA/oHJFusC1bS3b3ywBi8AWq5AbJ8TBrIEsnElA2NXhnU2a/V cmxpbL7jvaMlrnYZBYArPlOxrjgZPBgcv5flqu0BF7mWfQCYPjHmoJlSvvF6nzb/t4hQ 8zJjoIPTo/X3kWBuDIwXJWAlJDPyTwY0cw+I1M2ILtx/g4bj7T85WY3hR9qF1WSX9h4i cJGg== X-Gm-Message-State: ALoCoQk3t3H7xz7745eWHSPTTxHXucWmAw+wGNX7nziaUjmXi3zH1mn36w5hGFiGVnC4QUPXgtyw X-Received: by 10.107.153.8 with SMTP id b8mr15381654ioe.3.1431373485992; Mon, 11 May 2015 12:44:45 -0700 (PDT) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by mx.google.com with ESMTPSA id 16sm10351962ion.20.2015.05.11.12.44.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 May 2015 12:44:44 -0700 (PDT) From: Doug Anderson To: Wolfram Sang Subject: [PATCH v2] i2c: rk3x: Increase wait timeout to 1 second Date: Mon, 11 May 2015 12:44:28 -0700 Message-Id: <1431373468-18302-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150511_124508_471882_646A2F0D X-CRM114-Status: GOOD ( 14.13 ) X-Spam-Score: -0.8 (/) Cc: Addy Ke , Dmitry Torokhov , Heiko Stuebner , Max Schwarz , Doug Anderson , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-i2c@vger.kernel.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Although unlikely, it is remotely possible for an i2c command to need more than 200ms complete. Unlike smbus, i2c devices can clock stretch for an unspecified amount of time. The longest time I've seen specified for a device is 144ms (bq27541 battery gas), but one could imagine a device taking a bit slower. 1 second "ought to be enough for anyone." The above is not the only justifcation for going above 200ms for a timeout, though. It turns out that if you've got a large number of printks going out to a serial console, interrupts on a CPU can be disabled for hundreds of milliseconds. That's not a great situation to be in to start with (maybe we should put a cap in vprintk_emit()) but it's pretty annoying to start seeing unexplained i2c timeouts. Note that to understand why we can timeout when printk has interrupts disabled, you need to understand that on current Linux ARM kernels interrupts are routed to a single CPU in a multicore system. Thus, you can get: 1. CPU1 is running rk3x_i2c_xfer() 2. CPU0 calls vprintk_emit(), which disables all IRQs on CPU0. 3. I2C interrupt is ready but is set to only run on CPU0, where IRQs are disabled. 4. CPU1 timeout expires. I2C interrupt is still ready, but CPU0 is still sitting in the same vprintk_emit() 5. CPU1 sees that no interrupt happened in 200ms, so timeout. A normal system shouldn't see i2c timeouts anyway, so increasing the timeout should help people debugging without hurting other people excessively. Signed-off-by: Doug Anderson Tested-by: Caesar Wang Acked-by: Uwe Kleine-König --- Changes in v2: - Update commit message as per Uwe drivers/i2c/busses/i2c-rk3x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c index 019d542..72e97e30 100644 --- a/drivers/i2c/busses/i2c-rk3x.c +++ b/drivers/i2c/busses/i2c-rk3x.c @@ -72,7 +72,7 @@ enum { #define REG_INT_ALL 0x7f /* Constants */ -#define WAIT_TIMEOUT 200 /* ms */ +#define WAIT_TIMEOUT 1000 /* ms */ #define DEFAULT_SCL_RATE (100 * 1000) /* Hz */ enum rk3x_i2c_state {