From patchwork Mon Apr 17 08:09:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jiajie.hao@mediatek.com X-Patchwork-Id: 9683639 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F219B600C5 for ; Mon, 17 Apr 2017 08:10:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E14CE262F2 for ; Mon, 17 Apr 2017 08:10:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D600F271CB; Mon, 17 Apr 2017 08:10:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5C67D262F2 for ; Mon, 17 Apr 2017 08:10:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2fkqxG6NgDYii3MUtxz7xuNyLv8uYB4L5K/T4QeEn3I=; b=h1Yifg5nODLbIx rj827En8WgddLu/72x8udvahIoLDTlsqGBYd7kIwzz6TcqEPXpY6DSGqmU7ZXhJyNuuvgOZKB38BN TbEz+DTrIg9S6B34fQy47i3vTFdFMgHsYhEi845qZ5HknkltSoZ2/R69LyoWy2Jt38Y9YIp0cCBmm B3aB0NPcnccY9NqTTNcAG9VIBEUNnAxuQ0xOVl8r+dmV/9fAuDw7l3HWa95+nunl7u3d59qd0qK2W YApwkk+M3V03HEWv1bVH+M3CNIL5t+Ukjw7tSJGlDFWi8wSXoLTp3rUdj9ytwDtd/+jSTCkfkwUPH qIodNi6dx268zP5G8t6g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d01kG-0006Wq-ES; Mon, 17 Apr 2017 08:10:48 +0000 Received: from [210.61.82.183] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d01kD-0006Td-Bw for linux-mediatek@lists.infradead.org; Mon, 17 Apr 2017 08:10:47 +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 505604849; Mon, 17 Apr 2017 16:10:20 +0800 Received: from mhfsdcap03.mhfswrd (10.17.3.153) by mtkhts07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.266.1; Mon, 17 Apr 2017 16:10:19 +0800 From: To: Subject: [PATCH] mmc: sdio: Fix sdio wait busy implement limitation Date: Mon, 17 Apr 2017 16:09:31 +0800 Message-ID: <1492416571-28843-2-git-send-email-jiajie.hao@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1492416571-28843-1-git-send-email-jiajie.hao@mediatek.com> References: <1492416571-28843-1-git-send-email-jiajie.hao@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170417_011045_556680_96D8C38C X-CRM114-Status: GOOD ( 11.72 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: srv_heupstream@mediatek.com, linux-arm-kernel@mediatek.com, linus.walleij@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, yong.mao@mediatek.com, linux-mediatek@lists.infradead.org, Jiajie Hao , eddie.huang@mediatek.com, chaotian.jing@mediatek.com Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jiajie Hao The host may issue an I/O abort by writing to the CCCR at any time during I/O read operation via CMD52. And host may need suspend transcation during write busy stage in SDIO suspend/resume scenario. From other side, a card may accept CMD52 during data transfer phase. Previous implement would block issuing above command in busy stage. It cause function driver can't implement as proper way and has no opportunity to do some coverage in error case via I/O abort etc. We need bypass some necessary operation during busy check stage. Change-Id: Ib5a4599a2a98cbcf441b564f5f6fbb10c8a59e1b Signed-off-by: Jiajie Hao --- drivers/mmc/core/core.c | 4 +++- drivers/mmc/core/sdio_ops.h | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 926e0fd..9c9a4bc 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -234,8 +234,10 @@ static void __mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) /* * For sdio rw commands we must wait for card busy otherwise some * sdio devices won't work properly. + * And bypass I/O abort, reset and bus suspend operations. */ - if (mmc_is_io_op(mrq->cmd->opcode) && host->ops->card_busy) { + if (mmc_is_io_op(mrq->cmd->opcode) && host->ops->card_busy && + !mmc_is_io_bypass(mrq->cmd->opcode, mrq->cmd->arg)) { int tries = 500; /* Wait aprox 500ms at maximum */ while (host->ops->card_busy(host) && --tries) diff --git a/drivers/mmc/core/sdio_ops.h b/drivers/mmc/core/sdio_ops.h index bed8a83..9896696 100644 --- a/drivers/mmc/core/sdio_ops.h +++ b/drivers/mmc/core/sdio_ops.h @@ -31,5 +31,15 @@ static inline bool mmc_is_io_op(u32 opcode) return opcode == SD_IO_RW_DIRECT || opcode == SD_IO_RW_EXTENDED; } +static inline bool mmc_is_io_bypass(u32 opcode, u32 arg) +{ + u32 addr; + + addr = (arg >> 9) & 0x1FFFF; + + return ((opcode == SD_IO_RW_DIRECT) && + (addr == SDIO_CCCR_ABORT || addr == SDIO_CCCR_SUSPEND)); +} + #endif