From patchwork Tue Jul 9 23:19:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 2825478 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 A47ADC0AB2 for ; Tue, 9 Jul 2013 23:20:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE63D20113 for ; Tue, 9 Jul 2013 23:20:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C7F1120121 for ; Tue, 9 Jul 2013 23:20:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753999Ab3GIXUk (ORCPT ); Tue, 9 Jul 2013 19:20:40 -0400 Received: from mail-ve0-f201.google.com ([209.85.128.201]:63006 "EHLO mail-ve0-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752509Ab3GIXTa (ORCPT ); Tue, 9 Jul 2013 19:19:30 -0400 Received: by mail-ve0-f201.google.com with SMTP id ox1so553389veb.2 for ; Tue, 09 Jul 2013 16:19:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=xodBAurIxaay1evGDZ2SVU5+/aVqnOIj0lobuFUCyew=; b=j2bY0nHBbq6fsc6ZgH3rWhqNVfXhRV6WAa2wmdU6ATMwdYxybSPwXlF8LgS/u9INu0 IHXEf1FnYf0ttMUGEyxpJpcQ3c3Q9E0Vqw69s8T10KM3P02C91W4qaLmXeTGhRb83yUG 8K1vCyXrX2x98kEXy1gdntGInU0VKHtGFVpDBR5TexTYUI9YF0bD9UdBz7Ia7L3pgcWK 87CBgX/fN/RltQ1yO28yJ2fLDPl7mPBmB6ZCALE0AM67x96UvOr7OFLqyMUHzJXOKv/u QqTewxh54PNNGXIWBZ9ga1XnFwXT63nZC++jpkBsgtfQbpbUoto+yoz1gghfSPRGDnz8 7PdQ== X-Received: by 10.236.92.7 with SMTP id i7mr15222751yhf.52.1373411968670; Tue, 09 Jul 2013 16:19:28 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id t25si14497711yhg.6.2013.07.09.16.19.28 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Tue, 09 Jul 2013 16:19:28 -0700 (PDT) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.162.34]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 7FD6F5A41DB; Tue, 9 Jul 2013 16:19:28 -0700 (PDT) Received: by tictac.mtv.corp.google.com (Postfix, from userid 121310) id 354AB8025A; Tue, 9 Jul 2013 16:19:28 -0700 (PDT) From: Doug Anderson To: Chris Ball Cc: Olof Johansson , Jaehoon Chung , Seungwon Jeon , James Hogan , Grant Grundler , Alim Akhtar , Abhilash Kesavan , Tomasz Figa , Doug Anderson , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/5] mmc: dw_mmc: Invalidate cache of current_speed after suspend/resume Date: Tue, 9 Jul 2013 16:19:17 -0700 Message-Id: <1373411961-23812-2-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 1.8.3 In-Reply-To: <1373411961-23812-1-git-send-email-dianders@chromium.org> References: <1373391071-6312-1-git-send-email-dianders@chromium.org> <1373411961-23812-1-git-send-email-dianders@chromium.org> X-Gm-Message-State: ALoCoQnSUfmJdpYKaerhdfL8UsrGtlJRjm/aW2oEI/tWRH2DZ5j1Te3bgzLmUcMQkuERR6MO1QgZhIZAdbZlXyprtHKd8o3QPTNttdNkqQbOqOtuNmjHg36dhGgPahl9ydlZNKJ5BCpfSanNudzEeB5nz0+0pfBL2dwI5uSMPwXhjjF/zUNRbNEj7oiqmq904iCwoHYWQLF1UeqcTlNRrU+vFzhvvEpJqQ== 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 The dw_mmc driver keeps a cache of the current slot->clock in order to avoid doing a whole lot of work every time set_ios() is called. However, after suspend/resume the register values are bogus so we need to ensure that the cached value is invalidated. In many cases we got by without this since the core mmc code fiddles with the clock a lot. If we've got a card present we're probably running it at something like 50MHz and the core will temporarily switch us to 400kHz after resume. One case that didn't work (for me) is the case of having no card in the slot. The slot is initted to 400kHz at boot time. After suspend/resume the slot thinks it's still at 400kHz (due to the cache) so doesn't adjust timing. When it tries to send the command at probe time it just times out and gets left in a bad state. Invalidating the current_speed also means that we don't need to call: dw_mci_setup_bus(slot, true); ...to force an update of the clock in the case when the slot was left powered. Signed-off-by: Doug Anderson --- Changes in v2: - Fix typo (some -> come) - Use ~0 instead of 0xFFFFFFFF; add comment about value drivers/mmc/host/dw_mmc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index bc3a1bc..7a5ce6a 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -2488,13 +2488,19 @@ int dw_mci_resume(struct dw_mci *host) DW_MCI_ERROR_FLAGS | SDMMC_INT_CD); mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); + /* + * Invalidate the 'current_speed' value since CLKDIV has come up in + * default state and our cache is incorrect; set to something we know + * slot->clock won't be. + */ + host->current_speed = ~0; + for (i = 0; i < host->num_slots; i++) { struct dw_mci_slot *slot = host->slot[i]; if (!slot) continue; if (slot->mmc->pm_flags & MMC_PM_KEEP_POWER) { dw_mci_set_ios(slot->mmc, &slot->mmc->ios); - dw_mci_setup_bus(slot, true); } ret = mmc_resume_host(host->slot[i]->mmc);