From patchwork Mon Apr 18 07:13:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaotian Jing X-Patchwork-Id: 8868371 Return-Path: X-Original-To: patchwork-linux-mediatek@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C3DAEBF29F for ; Mon, 18 Apr 2016 07:14:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE6522021A for ; Mon, 18 Apr 2016 07:14:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2228E201B4 for ; Mon, 18 Apr 2016 07:14:07 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1as3Nm-00070N-Ei; Mon, 18 Apr 2016 07:14:06 +0000 Received: from [210.61.82.183] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1as3Nk-0006vv-Bq; Mon, 18 Apr 2016 07:14:05 +0000 Received: from mtkhts07.mediatek.inc [(172.21.101.69)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1342066135; Mon, 18 Apr 2016 15:13:33 +0800 Received: from mhfsdcap03.gcn.mediatek.inc (10.17.3.153) by mtkhts07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.266.1; Mon, 18 Apr 2016 15:13:31 +0800 From: Chaotian Jing To: Ulf Hansson Subject: [PATCH] mmc: mediatek: fix request blocked by cancel_delayed_work Date: Mon, 18 Apr 2016 15:13:29 +0800 Message-ID: <1460963609-16179-1-git-send-email-chaotian.jing@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160418_001404_559563_B4BCBD7B X-CRM114-Status: GOOD ( 14.99 ) X-Spam-Score: -1.1 (-) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicolas Boichat , srv_heupstream@mediatek.com, linux-mmc@vger.kernel.org, Douglas Anderson , linux-kernel@vger.kernel.org, Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, Sascha Hauer , Matthias Brugger , linux-mediatek@lists.infradead.org, Chaotian Jing Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 there are 2 points will cause could not call mmc_request_done() and eventually cause the caller thread blocked. A. if card was busy, cancel_delayed_work() will return false because the delay work has not been scheduled, in this case, need put mod_delayed_work() in front of msdc_cmd_is_ready() B. if a request really need more than 5s(Some Sandisk TF card), it will use cancel_delayed_work() to cancel itself, and also return false, so use in_interrupt() to avoid this case Signed-off-by: Chaotian Jing --- drivers/mmc/host/mtk-sd.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c index b17f30d..1511b1b 100644 --- a/drivers/mmc/host/mtk-sd.c +++ b/drivers/mmc/host/mtk-sd.c @@ -724,7 +724,7 @@ static void msdc_request_done(struct msdc_host *host, struct mmc_request *mrq) bool ret; ret = cancel_delayed_work(&host->req_timeout); - if (!ret) { + if (!ret && in_interrupt()) { /* delay work already running */ return; } @@ -824,7 +824,12 @@ static inline bool msdc_cmd_is_ready(struct msdc_host *host, } if (mmc_resp_type(cmd) == MMC_RSP_R1B || cmd->data) { - tmo = jiffies + msecs_to_jiffies(20); + /* + * 2550ms is from EXT_CSD[248], after switch to hs200, + * using CMD13 to polling card status, it will get response + * of 0x800, but EMMC still pull-low DAT0. + */ + tmo = jiffies + msecs_to_jiffies(2550); /* R1B or with data, should check SDCBUSY */ while ((readl(host->base + SDC_STS) & SDC_STS_SDCBUSY) && time_before(jiffies, tmo)) @@ -847,6 +852,7 @@ static void msdc_start_command(struct msdc_host *host, WARN_ON(host->cmd); host->cmd = cmd; + mod_delayed_work(system_wq, &host->req_timeout, DAT_TIMEOUT); if (!msdc_cmd_is_ready(host, mrq, cmd)) return; @@ -858,7 +864,6 @@ static void msdc_start_command(struct msdc_host *host, cmd->error = 0; rawcmd = msdc_cmd_prepare_raw_cmd(host, mrq, cmd); - mod_delayed_work(system_wq, &host->req_timeout, DAT_TIMEOUT); sdr_set_bits(host->base + MSDC_INTEN, cmd_ints_mask); writel(cmd->arg, host->base + SDC_ARG);