From: Ulf Hansson <ulf.hansson@linaro.org>
To: linux-mmc@vger.kernel.org, Ulf Hansson <ulf.hansson@linaro.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
Ludovic Barre <ludovic.barre@st.com>,
Baolin Wang <baolin.wang7@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Chaotian Jing <chaotian.jing@mediatek.com>,
Shawn Lin <shawn.lin@rock-chips.com>,
mirq-linux@rere.qmqm.pl
Subject: [PATCH 10/12] mmc: core: Convert to mmc_poll_for_busy() for HPI commands
Date: Tue, 4 Feb 2020 09:54:47 +0100 [thread overview]
Message-ID: <20200204085449.32585-11-ulf.hansson@linaro.org> (raw)
In-Reply-To: <20200204085449.32585-1-ulf.hansson@linaro.org>
Rather than open coding the polling loop in mmc_interrupt_hpi(), let's
convert to use mmc_poll_for_busy().
Note that, moving to mmc_poll_for_busy() for HPI also improves the
behaviour according to below.
- Adds support for polling via the optional ->card_busy() host ops.
- Require R1_READY_FOR_DATA to be set in the CMD13 response before exiting
the polling loop.
- Adds a throttling mechanism to avoid CPU hogging when polling.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/mmc/core/mmc_ops.c | 20 +++++---------------
drivers/mmc/core/mmc_ops.h | 1 +
2 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 4d8f90d01740..87d54a559b31 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -471,6 +471,8 @@ static int mmc_busy_status(struct mmc_card *card, bool retry_crc_err,
case MMC_BUSY_ERASE:
err = R1_STATUS(status) ? -EIO : 0;
break;
+ case MMC_BUSY_HPI:
+ break;
default:
err = -EINVAL;
}
@@ -829,6 +831,7 @@ int mmc_bus_test(struct mmc_card *card, u8 bus_width)
static int mmc_send_hpi_cmd(struct mmc_card *card)
{
+ unsigned int busy_timeout_ms = card->ext_csd.out_of_int_time;
struct mmc_command cmd = {};
unsigned int opcode;
int err;
@@ -850,7 +853,8 @@ static int mmc_send_hpi_cmd(struct mmc_card *card)
return err;
}
- return 0;
+ /* Let's poll to find out when the HPI request completes. */
+ return mmc_poll_for_busy(card, busy_timeout_ms, MMC_BUSY_HPI);
}
/**
@@ -864,7 +868,6 @@ int mmc_interrupt_hpi(struct mmc_card *card)
{
int err;
u32 status;
- unsigned long prg_wait;
if (!card->ext_csd.hpi_en) {
pr_info("%s: HPI enable bit unset\n", mmc_hostname(card->host));
@@ -898,19 +901,6 @@ int mmc_interrupt_hpi(struct mmc_card *card)
}
err = mmc_send_hpi_cmd(card);
- if (err)
- goto out;
-
- prg_wait = jiffies + msecs_to_jiffies(card->ext_csd.out_of_int_time);
- do {
- err = mmc_send_status(card, &status);
-
- if (!err && R1_CURRENT_STATE(status) == R1_STATE_TRAN)
- break;
- if (time_after(jiffies, prg_wait))
- err = -ETIMEDOUT;
- } while (!err);
-
out:
return err;
}
diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h
index 8cd05fb583da..38dcfeeaf6d5 100644
--- a/drivers/mmc/core/mmc_ops.h
+++ b/drivers/mmc/core/mmc_ops.h
@@ -13,6 +13,7 @@
enum mmc_busy_cmd {
MMC_BUSY_CMD6,
MMC_BUSY_ERASE,
+ MMC_BUSY_HPI,
};
struct mmc_host;
--
2.17.1
next prev parent reply other threads:[~2020-02-04 8:55 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-04 8:54 [PATCH 00/12] mmc: core: Improve code for polling and HW busy detect Ulf Hansson
2020-02-04 8:54 ` [PATCH 01/12] mmc: core: Throttle polling rate for CMD6 Ulf Hansson
2020-02-12 13:51 ` Ludovic BARRE
2020-02-12 14:18 ` Ulf Hansson
2020-02-12 14:24 ` Ludovic BARRE
2020-02-04 8:54 ` [PATCH 02/12] mmc: core: Drop unused define Ulf Hansson
2020-02-04 8:54 ` [PATCH 03/12] mmc: core: Extend mmc_switch_status() to rid of __mmc_switch_status() Ulf Hansson
2020-02-04 8:54 ` [PATCH 04/12] mmc: core: Drop redundant in-parameter to __mmc_switch() Ulf Hansson
2020-02-04 8:54 ` [PATCH 05/12] mmc: core: Split up mmc_poll_for_busy() Ulf Hansson
2020-02-04 8:54 ` [PATCH 06/12] mmc: core: Enable re-use of mmc_blk_in_tran_state() Ulf Hansson
2020-02-04 8:54 ` [PATCH 07/12] mmc: core: Update CMD13 busy check for CMD6 commands Ulf Hansson
2020-02-04 8:54 ` [PATCH 08/12] mmc: core: Convert to mmc_poll_for_busy() for erase/trim/discard Ulf Hansson
2020-02-04 8:54 ` [PATCH 09/12] mmc: core: Drop redundant out-parameter to mmc_send_hpi_cmd() Ulf Hansson
2020-02-04 8:54 ` Ulf Hansson [this message]
2020-02-04 8:54 ` [PATCH 11/12] mmc: core: Fixup support for HW busy detection for HPI commands Ulf Hansson
2020-02-04 8:54 ` [PATCH 12/12] mmc: core: Re-work the error path for the eMMC sanitize command Ulf Hansson
2020-02-11 22:29 ` kbuild test robot
2020-02-11 13:17 ` [PATCH 00/12] mmc: core: Improve code for polling and HW busy detect Baolin Wang
2020-02-13 6:23 ` Baolin Wang
2020-02-13 11:08 ` Ulf Hansson
2020-02-13 14:42 ` Ludovic BARRE
2020-02-14 14:21 ` Ulf Hansson
2020-02-18 23:38 ` Ulf Hansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200204085449.32585-11-ulf.hansson@linaro.org \
--to=ulf.hansson@linaro.org \
--cc=adrian.hunter@intel.com \
--cc=baolin.wang7@gmail.com \
--cc=chaotian.jing@mediatek.com \
--cc=linus.walleij@linaro.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ludovic.barre@st.com \
--cc=mirq-linux@rere.qmqm.pl \
--cc=shawn.lin@rock-chips.com \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).