From patchwork Fri Feb 20 18:49:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Anderson X-Patchwork-Id: 5858221 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D71FE9F269 for ; Fri, 20 Feb 2015 18:49:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B51C5204B5 for ; Fri, 20 Feb 2015 18:49:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C260B2012E for ; Fri, 20 Feb 2015 18:49:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753994AbbBTStv (ORCPT ); Fri, 20 Feb 2015 13:49:51 -0500 Received: from mail-ie0-f179.google.com ([209.85.223.179]:37138 "EHLO mail-ie0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753570AbbBTStu (ORCPT ); Fri, 20 Feb 2015 13:49:50 -0500 Received: by iecrl12 with SMTP id rl12so10040940iec.4 for ; Fri, 20 Feb 2015 10:49:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=eMLAsZyZzVCAHNpwOESWnVZy0quG2KdrxvwGiZNg1A8=; b=AwCxL1h/CpWzc+iS63LYstHOKoPvnp8fGFVkFBueTvK3CcCxLCq2o+8ALYjQMHs3KV e7eHi+7TxpDKqkc/qV4mTy5CJrYawXXPM/lqoGEaH1NAfdQ1NNshGOyjJBQ1AgNDtic4 1/hsTR08Nwpf2gV97kdJm0g814HpGkLYzp1nI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=eMLAsZyZzVCAHNpwOESWnVZy0quG2KdrxvwGiZNg1A8=; b=Lruue7nGQZOTrBDKRcvtEKKwknY7axkfD6iqgTYOHorOkjeAUnRlTP/LGgWZdfQct3 HhZNdiUe45vdn2Br2nvYUwRLEMh8+Azhc/RIispT+csTzR8/a4nRaqk7vix/PzZtuXcm okssDcQ8PVp/1RPXWffvtLaM0J2Neuq7FpcgdNuQ4xjfoxBpkQ5X/uYCKLgr1Q2magu6 bkEVH3bSZju/Huo8/LrgVuwxRPbtqkNDhsJL5mJh2gqkEXUEAIH8GFFB759kllmZUn19 yvBvgDVen52PlXyJ78BkzHWt/AAeNdoQr5uho/AM1Mjl/umQj6HqIcHm3ZXrecdR8VhL Nj2w== X-Gm-Message-State: ALoCoQl61r6Ma/k4ps2oW8JNXXepmNC/X6qUJKUpjUrUbLyU7r3aytgO8b/EnYFQtjANRY95cqHf X-Received: by 10.50.234.194 with SMTP id ug2mr343179igc.39.1424458190336; Fri, 20 Feb 2015 10:49:50 -0800 (PST) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by mx.google.com with ESMTPSA id l20sm17408151iol.25.2015.02.20.10.49.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Feb 2015 10:49:49 -0800 (PST) From: Doug Anderson To: Jaehoon Chung , Seungwon Jeon , Ulf Hansson Cc: Alim Akhtar , Sonny Rao , Andrew Bresticker , Heiko Stuebner , Addy Ke , Alexandru Stan , javier.martinez@collabora.co.uk, Doug Anderson , chris@printf.net, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mmc: dw_mmc: Don't start commands while busy Date: Fri, 20 Feb 2015 10:49:39 -0800 Message-Id: <1424458179-5456-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 We've seen problems on some WiFi modules where we seem to send a CMD53 (which requires the data lines) while the module is asserting busy. We shouldn't do that. The Designware Databook says that before issuing a new data transfer command we should check for busy, so that's what we'll do. We'll leverage the existing dw_mmc knowledge about whether it should wait for the previous command to finish to know whether we should check for busy before sending the command. This means we won't end up incorrectly waiting for things like CMD52 (SDIO) or CMD13 (SD) which don't use the data line. Signed-off-by: Doug Anderson --- drivers/mmc/host/dw_mmc.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 4d2e3c2..a3fcc91 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -102,6 +102,7 @@ struct idmac_desc { static bool dw_mci_reset(struct dw_mci *host); static bool dw_mci_ctrl_reset(struct dw_mci *host, u32 reset); +static int dw_mci_card_busy(struct mmc_host *mmc); #if defined(CONFIG_DEBUG_FS) static int dw_mci_req_show(struct seq_file *s, void *v) @@ -335,6 +336,26 @@ static u32 dw_mci_prep_stop_abort(struct dw_mci *host, struct mmc_command *cmd) return cmdr; } +static void dw_mci_wait_while_busy(struct dw_mci *host, u32 cmd_flags) +{ + unsigned long timeout = jiffies + msecs_to_jiffies(500); + + /* + * Databook says that before issuing a new data transfer command + * we need to check to see if the card is busy. Data transfer commands + * all have SDMMC_CMD_PRV_DAT_WAIT set, so we'll key off that. + */ + if (cmd_flags & SDMMC_CMD_PRV_DAT_WAIT) { + while (dw_mci_card_busy(host->cur_slot->mmc)) { + if (time_after(jiffies, timeout)) { + dev_err(host->dev, "Busy; trying anyway\n"); + break; + } + udelay(10); + } + } +} + static void dw_mci_start_command(struct dw_mci *host, struct mmc_command *cmd, u32 cmd_flags) { @@ -345,6 +366,7 @@ static void dw_mci_start_command(struct dw_mci *host, mci_writel(host, CMDARG, cmd->arg); wmb(); + dw_mci_wait_while_busy(host, cmd_flags); mci_writel(host, CMD, cmd_flags | SDMMC_CMD_START); }