From patchwork Wed May 30 02:12:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 10437513 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 04270602BF for ; Wed, 30 May 2018 02:12:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E69A128892 for ; Wed, 30 May 2018 02:12:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB77A28895; Wed, 30 May 2018 02:12:58 +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=-6.4 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_WEB autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D4DF28892 for ; Wed, 30 May 2018 02:12:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751469AbeE3CM5 (ORCPT ); Tue, 29 May 2018 22:12:57 -0400 Received: from lucky1.263xmail.com ([211.157.147.130]:47595 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755320AbeE3CM5 (ORCPT ); Tue, 29 May 2018 22:12:57 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.225]) by lucky1.263xmail.com (Postfix) with ESMTP id 7103D1F5B4D; Wed, 30 May 2018 10:12:54 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 507CC3B5; Wed, 30 May 2018 10:12:53 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: ulf.hansson@linaro.org X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <7837441a9baa6165486f09a8e74ccb46> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 26305URO052; Wed, 30 May 2018 10:12:54 +0800 (CST) From: Shawn Lin To: Ulf Hansson Cc: linux-mmc@vger.kernel.org, Martin Hicks , Shawn Lin Subject: [PATCH v3 8/9] mmc: block: Use mmc_poll_for_busy() for polling busy in mmc block layer Date: Wed, 30 May 2018 10:12:49 +0800 Message-Id: <1527646369-134384-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527646231-132327-1-git-send-email-shawn.lin@rock-chips.com> References: <1527646231-132327-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch removes card_busy_detect() and use mmc_poll_for_busy() instead. Signed-off-by: Shawn Lin --- Changes in v3: - remove mmc_host_is_spi() from mmc_blk_card_busy() as mmc_poll_for_busy() has considered it. Changes in v2: None drivers/mmc/core/block.c | 50 ++++++++---------------------------------------- 1 file changed, 8 insertions(+), 42 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 69c4847..4186bc2 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -949,46 +949,9 @@ static inline bool mmc_blk_in_tran_state(u32 status) (R1_CURRENT_STATE(status) == R1_STATE_TRAN); } -static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms, - struct request *req, u32 *resp_errs) +static inline bool mmc_blk_in_busy_state(u32 status) { - unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms); - int err = 0; - u32 status; - - do { - bool done = time_after(jiffies, timeout); - - err = __mmc_send_status(card, &status, 5); - if (err) { - pr_err("%s: error %d requesting status\n", - req->rq_disk->disk_name, err); - return err; - } - - /* Accumulate any response error bits seen */ - if (resp_errs) - *resp_errs |= status; - - /* - * Timeout if the device never becomes ready for data and never - * leaves the program state. - */ - if (done) { - pr_err("%s: Card stuck in wrong state! %s %s status: %#x\n", - mmc_hostname(card->host), - req->rq_disk->disk_name, __func__, status); - return -ETIMEDOUT; - } - - /* - * Some cards mishandle the status bits, - * so make sure to check both the busy - * indication and the card state. - */ - } while (!mmc_blk_in_tran_state(status)); - - return err; + return !(mmc_blk_in_tran_state(status)); } static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host, @@ -1636,7 +1599,9 @@ static int mmc_blk_fix_state(struct mmc_card *card, struct request *req) mmc_blk_send_stop(card, timeout); - err = card_busy_detect(card, timeout, req, NULL); + err = mmc_poll_for_busy(card, timeout, true, false, false, NULL, + &mmc_blk_in_busy_state, false); + mmc_retune_release(card->host); @@ -1857,10 +1822,11 @@ static int mmc_blk_card_busy(struct mmc_card *card, struct request *req) u32 status = 0; int err; - if (mmc_host_is_spi(card->host) || rq_data_dir(req) == READ) + if (rq_data_dir(req) == READ) return 0; - err = card_busy_detect(card, MMC_BLK_TIMEOUT_MS, req, &status); + err = mmc_poll_for_busy(card, MMC_BLK_TIMEOUT_MS, true, false, false, + &status, &mmc_blk_in_busy_state, false); /* * Do not assume data transferred correctly if there are any error bits