From patchwork Wed Oct 16 16:20:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremie Samuel X-Patchwork-Id: 3054341 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3E397BF924 for ; Wed, 16 Oct 2013 16:22:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CFAB0204AE for ; Wed, 16 Oct 2013 16:22:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 652A0204AC for ; Wed, 16 Oct 2013 16:22:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932481Ab3JPQWe (ORCPT ); Wed, 16 Oct 2013 12:22:34 -0400 Received: from co202.xi-lite.net ([149.6.83.202]:33749 "EHLO co202.xi-lite.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932534Ab3JPQW3 (ORCPT ); Wed, 16 Oct 2013 12:22:29 -0400 Received: from localhost (localhost [127.0.0.1]) by co202.xi-lite.net (Postfix) with ESMTP id 00BC84809BF; Wed, 16 Oct 2013 18:22:29 +0200 (CEST) X-Virus-Scanned: amavisd-new at fw.aswsp.net Received: from co202.xi-lite.net ([127.0.0.1]) by localhost (fw.aswsp.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id r6q_Za49Pva8; Wed, 16 Oct 2013 18:22:28 +0200 (CEST) Received: from HCAS2.aswsp.lan (unknown [193.34.35.150]) by co202.xi-lite.net (Postfix) with ESMTPS id E4DE64809B6; Wed, 16 Oct 2013 18:22:28 +0200 (CEST) Received: from jerk.parrot.biz (46.218.109.88) by smtp.aswsp.com (193.34.32.148) with Microsoft SMTP Server id 14.2.342.3; Wed, 16 Oct 2013 18:22:52 +0200 From: Jeremie Samuel To: Chris Ball CC: , =?UTF-8?q?Gr=C3=A9gor=20Boirie?= , Matthieu Castet , Jeremie Samuel Subject: [PATCH 2/8] sdhci: Turn tuning timeout timer into delayed work Date: Wed, 16 Oct 2013 18:20:52 +0200 Message-ID: <1381940458-12628-3-git-send-email-jeremie.samuel.ext@parrot.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1381940458-12628-1-git-send-email-jeremie.samuel.ext@parrot.com> References: <1381940458-12628-1-git-send-email-jeremie.samuel.ext@parrot.com> MIME-Version: 1.0 X-Originating-IP: [46.218.109.88] 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.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Same as previous patch Signed-off-by: Jeremie Samuel --- drivers/mmc/host/sdhci.c | 46 ++++++++++++++++++++++----------------------- include/linux/mmc/sdhci.h | 2 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index b312ec6..03c9995 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -52,7 +52,7 @@ static void sdhci_finish_data(struct sdhci_host *); static void sdhci_finish_command(struct sdhci_host *); static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode); -static void sdhci_tuning_timer(unsigned long data); +static void sdhci_tuning_timeout_work(struct work_struct *wk); static void sdhci_enable_preset_value(struct sdhci_host *host, bool enable); #ifdef CONFIG_PM_RUNTIME @@ -267,7 +267,7 @@ static void sdhci_reinit(struct sdhci_host *host) if (host->flags & SDHCI_USING_RETUNING_TIMER) { host->flags &= ~SDHCI_USING_RETUNING_TIMER; - del_timer_sync(&host->tuning_timer); + flush_delayed_work(&host->tuning_timeout_work); host->flags &= ~SDHCI_NEEDS_RETUNING; host->mmc->max_blk_count = (host->quirks & SDHCI_QUIRK_NO_MULTIBLOCK) ? 1 : 65535; @@ -1380,7 +1380,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) present_state = sdhci_readl(host, SDHCI_PRESENT_STATE); /* - * Check if the re-tuning timer has already expired and there + * Check if the re-tuning timeout has already expired and there * is no on-going data transfer. If so, we need to execute * tuning procedure before sending command. */ @@ -2002,32 +2002,33 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) out: /* * If this is the very first time we are here, we start the retuning - * timer. Since only during the first time, SDHCI_NEEDS_RETUNING - * flag won't be set, we check this condition before actually starting - * the timer. + * timeout workqueue. Since only during the first time, + * SDHCI_NEEDS_RETUNING flag won't be set, we check this condition + * before actually starting the timeout worqueue. */ if (!(host->flags & SDHCI_NEEDS_RETUNING) && host->tuning_count && (host->tuning_mode == SDHCI_TUNING_MODE_1)) { host->flags |= SDHCI_USING_RETUNING_TIMER; - mod_timer(&host->tuning_timer, jiffies + + schedule_delayed_work(&host->tuning_timeout_work, host->tuning_count * HZ); /* Tuning mode 1 limits the maximum data length to 4MB */ mmc->max_blk_count = (4 * 1024 * 1024) / mmc->max_blk_size; } else { host->flags &= ~SDHCI_NEEDS_RETUNING; - /* Reload the new initial value for timer */ + /* Reload the new initial value for timeout workqueue */ if (host->tuning_mode == SDHCI_TUNING_MODE_1) - mod_timer(&host->tuning_timer, jiffies + + schedule_delayed_work(&host->tuning_timeout_work, host->tuning_count * HZ); } /* * In case tuning fails, host controllers which support re-tuning can - * try tuning again at a later time, when the re-tuning timer expires. + * try tuning again at a later time, when the re-tuning timeout + * workqueue expires. * So for these controllers, we return 0. Since there might be other * controllers who do not have this capability, we return error for * them. SDHCI_USING_RETUNING_TIMER means the host is currently using - * a retuning timer to do the retuning for the card. + * a retuning timeout workqueue to do the retuning for the card. */ if (err && (host->flags & SDHCI_USING_RETUNING_TIMER)) err = 0; @@ -2212,12 +2213,12 @@ static void sdhci_timeout_work(struct work_struct *wk) spin_unlock_irqrestore(&host->lock, flags); } -static void sdhci_tuning_timer(unsigned long data) +static void sdhci_tuning_timeout_work(struct work_struct *wk) { struct sdhci_host *host; unsigned long flags; - host = (struct sdhci_host *)data; + host = container_of(wk, struct sdhci_host, tuning_timeout_work.work); spin_lock_irqsave(&host->lock, flags); @@ -2564,7 +2565,7 @@ int sdhci_suspend_host(struct sdhci_host *host) /* Disable tuning since we are suspending */ if (host->flags & SDHCI_USING_RETUNING_TIMER) { - del_timer_sync(&host->tuning_timer); + flush_delayed_work(&host->tuning_timeout_work); host->flags &= ~SDHCI_NEEDS_RETUNING; } @@ -2572,7 +2573,7 @@ int sdhci_suspend_host(struct sdhci_host *host) if (ret) { if (host->flags & SDHCI_USING_RETUNING_TIMER) { host->flags |= SDHCI_NEEDS_RETUNING; - mod_timer(&host->tuning_timer, jiffies + + schedule_delayed_work(&host->tuning_timeout_work, host->tuning_count * HZ); } @@ -2676,7 +2677,7 @@ int sdhci_runtime_suspend_host(struct sdhci_host *host) /* Disable tuning since we are suspending */ if (host->flags & SDHCI_USING_RETUNING_TIMER) { - del_timer_sync(&host->tuning_timer); + flush_delayed_work(&host->tuning_timeout_work); host->flags &= ~SDHCI_NEEDS_RETUNING; } @@ -3034,13 +3035,13 @@ int sdhci_add_host(struct sdhci_host *host) if (caps[1] & SDHCI_DRIVER_TYPE_D) mmc->caps |= MMC_CAP_DRIVER_TYPE_D; - /* Initial value for re-tuning timer count */ + /* Initial value for re-tuning timeout count */ host->tuning_count = (caps[1] & SDHCI_RETUNING_TIMER_COUNT_MASK) >> SDHCI_RETUNING_TIMER_COUNT_SHIFT; /* - * In case Re-tuning Timer is not disabled, the actual value of - * re-tuning timer will be 2 ^ (n - 1). + * In case Re-tuning Timeout is not disabled, the actual value of + * re-tuning timeout will be 2 ^ (n - 1). */ if (host->tuning_count) host->tuning_count = 1 << (host->tuning_count - 1); @@ -3219,10 +3220,9 @@ int sdhci_add_host(struct sdhci_host *host) if (host->version >= SDHCI_SPEC_300) { init_waitqueue_head(&host->buf_ready_int); - /* Initialize re-tuning timer */ - init_timer(&host->tuning_timer); - host->tuning_timer.data = (unsigned long)host; - host->tuning_timer.function = sdhci_tuning_timer; + /* Initialize re-tuning timeout work */ + INIT_DELAYED_WORK(&host->tuning_timeout_work, + sdhci_tuning_timeout_work); } sdhci_init(host, 0); diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h index 98cf934..2b0f4f3 100644 --- a/include/linux/mmc/sdhci.h +++ b/include/linux/mmc/sdhci.h @@ -180,7 +180,7 @@ struct sdhci_host { unsigned int tuning_count; /* Timer count for re-tuning */ unsigned int tuning_mode; /* Re-tuning mode supported by host */ #define SDHCI_TUNING_MODE_1 0 - struct timer_list tuning_timer; /* Timer for tuning */ + struct delayed_work tuning_timeout_work; /* Work for tuning timeouts */ unsigned long private[0] ____cacheline_aligned; };