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: 6383681 Return-Path: X-Original-To: patchwork-linux-rockchip@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 EF168BEEE1 for ; Mon, 11 May 2015 19:45:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E7A1820C0B for ; Mon, 11 May 2015 19:45:29 +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 0BD8120C0A for ; Mon, 11 May 2015 19:45:29 +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 1Yrtdn-0004lc-RL; Mon, 11 May 2015 19:45:27 +0000 Received: from mail-ie0-x232.google.com ([2607:f8b0:4001:c03::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YrtdU-0003O6-7j for linux-rockchip@lists.infradead.org; Mon, 11 May 2015 19:45:09 +0000 Received: by iecmd7 with SMTP id md7so39873550iec.3 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=PELw/34xkppI6yAOK+NYrpcHaPFPn3mLLNnnCEZQ2yeDUE4WuMyalwjd3oVpkqWmj4 nzTsqlmus7DOIvwDVdy4qF0LYGtHrDLl5mfWFLUHOLRtupkvc+lQtpSsz4OejlQOtsyU Ttdr/XHSP5tibEuT6a/Lp/MczPEyf5KjshRF0Qr8NJG3QRlBErH7IA1rmG8e8/vG4tmf sEAHiKl5VxrVgiqvndD2JDbE+toNmyzlZhtEVV4BhkB7ewSzK1HwK4ZjGsaAAmgxEuyi rn21BOkd4xZFKHYNZHxqgjtjBrgxRWcyqksMARfpsng+iwFB8FvYk0DSAM7k75388uz5 qLkg== X-Gm-Message-State: ALoCoQkoUebNynN1fWWpz8WrvAxaBZ2teDSa8g1nwmdnn3NvhVgPs9NUejdzQRSefzwCKrSakOfE 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_389858_4F60DC45 X-CRM114-Status: GOOD ( 12.58 ) 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-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=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 {