From patchwork Thu Jan 26 23:37:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 9540375 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 A155560429 for ; Thu, 26 Jan 2017 23:40:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9618428305 for ; Thu, 26 Jan 2017 23:40:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A9732830A; Thu, 26 Jan 2017 23:40:11 +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=-1.9 required=2.0 tests=BAYES_00 autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2522B28305 for ; Thu, 26 Jan 2017 23:40:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cWteD-0007A4-8J; Thu, 26 Jan 2017 23:40:09 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cWtcZ-0003rz-HV for linux-arm-kernel@bombadil.infradead.org; Thu, 26 Jan 2017 23:38:27 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cWtcU-0001gy-CR for linux-arm-kernel@lists.infradead.org; Thu, 26 Jan 2017 23:38:26 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 76EE27DD34; Thu, 26 Jan 2017 23:37:34 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0QNbXvN032353; Thu, 26 Jan 2017 18:37:34 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id BEE4A80F99; Fri, 27 Jan 2017 00:37:31 +0100 (CET) From: Gerd Hoffmann To: linux-rpi-kernel@lists.infradead.org Subject: [PATCH 13/13] mmc: bcm2835: use bcm2835_read_wait_sdcmd in bcm2835_finish_command Date: Fri, 27 Jan 2017 00:37:26 +0100 Message-Id: <1485473846-24537-14-git-send-email-kraxel@redhat.com> In-Reply-To: <1485473846-24537-1-git-send-email-kraxel@redhat.com> References: <1485473846-24537-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 26 Jan 2017 23:37:34 +0000 (UTC) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170126_233822_810167_4DBDA989 X-CRM114-Status: GOOD ( 17.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Wahren , Ulf Hansson , Florian Fainelli , Scott Branden , Stephen Warren , Ray Jui , Lee Jones , linux-mmc@vger.kernel.org, open list , Eric Anholt , "maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE..." , Gerd Hoffmann , "moderated list:BROADCOM BCM2835 ARM ARCHITECTURE" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Gerd Hoffmann --- drivers/mmc/host/bcm2835.c | 56 +--------------------------------------------- 1 file changed, 1 insertion(+), 55 deletions(-) diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c index 82caddc..64a2334 100644 --- a/drivers/mmc/host/bcm2835.c +++ b/drivers/mmc/host/bcm2835.c @@ -152,7 +152,6 @@ struct bcm2835_host { unsigned int blocks; /* remaining PIO blocks */ int irq; /* Device IRQ */ - u32 cmd_quick_poll_retries; u32 ns_per_fifo_word; /* cached registers */ @@ -782,62 +781,10 @@ static void bcm2835_finish_command(struct bcm2835_host *host) struct device *dev = &host->pdev->dev; struct mmc_command *cmd = host->cmd; u32 sdcmd; - u32 retries; dev_dbg(dev, "finish_command(%x)\n", readl(host->ioaddr + SDCMD)); - /* Poll quickly at first */ - - retries = host->cmd_quick_poll_retries; - if (!retries) { - /* Work out how many polls take 1us by timing 10us */ - struct timeval start, now; - int us_diff; - - retries = 1; - do { - int i; - - retries *= 2; - - do_gettimeofday(&start); - - for (i = 0; i < retries; i++) { - cpu_relax(); - sdcmd = readl(host->ioaddr + SDCMD); - } - - do_gettimeofday(&now); - us_diff = (now.tv_sec - start.tv_sec) * 1000000 + - (now.tv_usec - start.tv_usec); - } while (us_diff < 10); - - host->cmd_quick_poll_retries = - ((retries * us_diff + 9) * CMD_DALLY_US) / 10 + 1; - retries = 1; /* We've already waited long enough this time */ - } - - retries = host->cmd_quick_poll_retries; - for (sdcmd = readl(host->ioaddr + SDCMD); - (sdcmd & SDCMD_NEW_FLAG) && !(sdcmd & SDCMD_FAIL_FLAG) && retries; - retries--) { - cpu_relax(); - sdcmd = readl(host->ioaddr + SDCMD); - } - - if (!retries) { - unsigned long wait_max; - - /* Wait max 100 ms */ - wait_max = jiffies + msecs_to_jiffies(100); - while (time_before(jiffies, wait_max)) { - usleep_range(1, 10); - sdcmd = readl(host->ioaddr + SDCMD); - if (!(sdcmd & SDCMD_NEW_FLAG) || - (sdcmd & SDCMD_FAIL_FLAG)) - break; - } - } + sdcmd = bcm2835_read_wait_sdcmd(host, 100, true); /* Check for errors */ if (sdcmd & SDCMD_NEW_FLAG) { @@ -1435,7 +1382,6 @@ static int bcm2835_probe(struct platform_device *pdev) host = mmc_priv(mmc); host->mmc = mmc; host->pdev = pdev; - host->cmd_quick_poll_retries = 0; host->pio_timeout = msecs_to_jiffies(500); host->pio_limit = 1; host->max_delay = 1; /* Warn if over 1ms */