From patchwork Wed Aug 12 12:37:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olliver Schinagl X-Patchwork-Id: 7001231 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 F2D24C05AC for ; Wed, 12 Aug 2015 12:39:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED649203F1 for ; Wed, 12 Aug 2015 12:39:35 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A7EB02049E for ; Wed, 12 Aug 2015 12:39:34 +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 1ZPVHv-0001b2-L9; Wed, 12 Aug 2015 12:37:47 +0000 Received: from 7of9.schinagl.nl ([88.159.158.68]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZPVHr-0001Kc-QZ for linux-arm-kernel@lists.infradead.org; Wed, 12 Aug 2015 12:37:45 +0000 Received: from [10.180.0.220] (unknown [185.66.93.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by 7of9.schinagl.nl (Postfix) with ESMTPSA id 46587435F0; Wed, 12 Aug 2015 14:37:19 +0200 (CEST) Message-ID: <55CB3DFE.8060508@schinagl.nl> Date: Wed, 12 Aug 2015 14:37:18 +0200 From: Olliver Schinagl User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: Ulf Hansson , Maxime Ripard , =?UTF-8?B?RGF2aWQgTGFuemVuZMO2cmZlcg==?= , Hans de Goede , Chen-Yu Tsai , Arnd Bergmann , Peter Griffin , Michal Suchanek Subject: [PATCH v2] mmc: sunxi: fix timeout in sunxi_mmc_oclk_onoff X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150812_053744_111901_E85DACDB X-CRM114-Status: GOOD ( 21.35 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mmc@vger.kernel.org, "linux-kernel@vger.kernel.org" , linux-arm-kernel 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Hey all A few months ago, Michal Suchanek submitted the attached patch fixing the gating timeout issue. Until recently, about v4.0.0 I hadn't noticed any issues and ran all boards from SD card. Recently I upgraded to Hans's 4.2 tree where he added mmc: sunxi: Don't start commands while the card is busy which started to trigger the timeout very aggressively causing a pretty much unusable system. While reverting the commands patch also removed the problem for some reason, that is of course not the real fix. Applying Michal's patch on top of the commands patch appears to fix the issue on atleast the A20 Lime2. Attached I have Michal's original patch, rebased to 4.2.0-rc5, with Hans's patch applied before hand. Changed since v1 * Whitespace cleanup as suggested by Maxime Ripard, no functional changes from that patch Olliver From bb0436dd5e2b3f021f8fcff2c2d25b87b48ab569 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Sun, 24 May 2015 20:07:32 +0200 Subject: [PATCH 1/1] mmc: sunxi: fix timeout in sunxi_mmc_oclk_onoff The 250ms timeout is too short. On my system enabling the oclk takes under 50ms and disabling slightly over 100ms when idle. Under load disabling the clock can take over 350ms. This does not make mmc clock gating look like good option to have on sunxi but the system should not crash with mmc clock gating enabled nonetheless. This patch sets the timeout to 750ms and adds debug prints which show how long enabling/disabling the clock took so more data can be collected from other systems. Signed-off-by: Michal Suchanek Signed-off-by: Olliver Schinagl --- drivers/mmc/host/sunxi-mmc.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c index daa90b7..34d134c 100644 --- a/drivers/mmc/host/sunxi-mmc.c +++ b/drivers/mmc/host/sunxi-mmc.c @@ -210,6 +210,8 @@ #define SDXC_IDMAC_DES0_CES BIT(30) /* card error summary */ #define SDXC_IDMAC_DES0_OWN BIT(31) /* 1-idma owns it, 0-host owns it */ +#define SUNXI_OCLK_ONOFF_TIMEOUT 750 + struct sunxi_idma_des { u32 config; u32 buf_size; @@ -615,7 +617,7 @@ static irqreturn_t sunxi_mmc_handle_manual_stop(int irq, void *dev_id) static int sunxi_mmc_oclk_onoff(struct sunxi_mmc_host *host, u32 oclk_en) { - unsigned long expire = jiffies + msecs_to_jiffies(250); + unsigned long start, end; u32 rval; int ret; @@ -629,6 +631,8 @@ static int sunxi_mmc_oclk_onoff(struct sunxi_mmc_host *host, u32 oclk_en) if (oclk_en) rval |= SDXC_CARD_CLOCK_ON; + start = jiffies; + end = start + msecs_to_jiffies(SUNXI_OCLK_ONOFF_TIMEOUT); mmc_writel(host, REG_CLKCR, rval); rval = SDXC_START | SDXC_UPCLK_ONLY | SDXC_WAIT_PRE_OVER; @@ -636,15 +640,29 @@ static int sunxi_mmc_oclk_onoff(struct sunxi_mmc_host *host, u32 oclk_en) do { rval = mmc_readl(host, REG_CMDR); - } while (time_before(jiffies, expire) && (rval & SDXC_START)); + } while (time_before(jiffies, end) && (rval & SDXC_START)); + end = jiffies; /* clear irq status bits set by the command */ mmc_writel(host, REG_RINTR, mmc_readl(host, REG_RINTR) & ~SDXC_SDIO_INTERRUPT); if (rval & SDXC_START) { - dev_err(mmc_dev(host->mmc), "fatal err update clk timeout\n"); + dev_err(mmc_dev(host->mmc), + "fatal err update oclk timeout. Could not %s in %ims.\n", + oclk_en ? "enable" : "disable", + jiffies_to_msecs(end - start)); return -EIO; + } else { + int msecs = jiffies_to_msecs(end - start); + const char *ing = oclk_en ? "enabling" : "disabling"; + + if ((msecs > 150) || (oclk_en && (msecs > 50))) + dev_warn(mmc_dev(host->mmc), + "%s oclk took %ims", ing, msecs); + else + dev_dbg(mmc_dev(host->mmc), + "%s oclk took %ims", ing, msecs); } return 0; -- 2.1.4