From patchwork Mon Dec 23 13:50:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 3396691 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7E9A29F37A for ; Mon, 23 Dec 2013 13:50:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B8CA20723 for ; Mon, 23 Dec 2013 13:50:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D56E72073D for ; Mon, 23 Dec 2013 13:50:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757447Ab3LWNug (ORCPT ); Mon, 23 Dec 2013 08:50:36 -0500 Received: from mail-pd0-f169.google.com ([209.85.192.169]:37682 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757446Ab3LWNuf (ORCPT ); Mon, 23 Dec 2013 08:50:35 -0500 Received: by mail-pd0-f169.google.com with SMTP id v10so5155925pde.14 for ; Mon, 23 Dec 2013 05:50:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=2Ka+dmLzAm0jhgcV/nohDjX+AFlPtNrQJ+g96qTDCYE=; b=IJZu9Yvhf3QeVlmFqmkc7BXHtK8ME0q4Yx7BUxuokafhnD2NBNhWaYR4Zu/Tvfpzif 0LeEvrF8ocwpdITng5plJYyLkUXPbtT4CEnhE5GQhBmnNkaAisFRZYvObK9iIuyy4g4i toZ3YwEMxz1b3u9zcdzdFBqBKQ8nvPIQAGwysry00nt+YsbXmkVhgXeKtAuZfRtISVF6 rH0TrUqQnP2H5JtFVRAxKABMAVFLAswO30uOO94K6kEi9+9MhbEqvy/l8IzXR5q0MmPR 7z9dsGX3NL4p7JvcFiLXPZnKeu5EQr5yYhOFT0Z5AsxpED9Qkl3XAfhk0MnJFHteIDpE ZRgQ== X-Received: by 10.68.91.3 with SMTP id ca3mr25817049pbb.20.1387806634513; Mon, 23 Dec 2013 05:50:34 -0800 (PST) Received: from localhost.localdomain ([101.245.121.84]) by mx.google.com with ESMTPSA id ja5sm34558887pbc.14.2013.12.23.05.50.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 23 Dec 2013 05:50:33 -0800 (PST) From: Barry Song <21cnbao@gmail.com> To: cjb@laptop.org Cc: linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, workgroup.linux@csr.com, Barry Song , Bin Shi Subject: [PATCH] mmc: sdhci: use time_after to replace mdelay-loop for timeout Date: Mon, 23 Dec 2013 21:50:08 +0800 Message-Id: <1387806608-3467-1-git-send-email-21cnbao@gmail.com> X-Mailer: git-send-email 1.8.2.3 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 From: Barry Song 1ms busy-loop might be wasted when the condition "if(sdhci_readl(host, SDHCI_PRESENT_STATE) & mask)" becomes false just after the if(). here we use time_after which will have no redundant busy-wait loop. Signed-off-by: Barry Song Cc: Bin Shi --- drivers/mmc/host/sdhci.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index aac92bd..52f5289 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1036,9 +1036,6 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) WARN_ON(host->cmd); - /* Wait max 10 ms */ - timeout = 10; - mask = SDHCI_CMD_INHIBIT; if ((cmd->data != NULL) || (cmd->flags & MMC_RSP_BUSY)) mask |= SDHCI_DATA_INHIBIT; @@ -1048,8 +1045,11 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) if (host->mrq->data && (cmd == host->mrq->data->stop)) mask &= ~SDHCI_DATA_INHIBIT; + /* Wait max 10 ms */ + timeout = jiffies + msecs_to_jiffies(10); + while (sdhci_readl(host, SDHCI_PRESENT_STATE) & mask) { - if (timeout == 0) { + if (time_after(jiffies, timeout)) { pr_err("%s: Controller never released " "inhibit bit(s).\n", mmc_hostname(host->mmc)); sdhci_dumpregs(host); @@ -1057,8 +1057,6 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) tasklet_schedule(&host->finish_tasklet); return; } - timeout--; - mdelay(1); } mod_timer(&host->timer, jiffies + 10 * HZ);