From: Shawn Lin <shawn.lin@rock-chips.com>
To: Ulf Hansson <ulf.hansson@linaro.org>,
linux-mmc@vger.kernel.org,
Adrian Hunter <adrian.hunter@intel.com>
Cc: shawn.lin@rock-chips.com,
Linus Walleij <linus.walleij@linaro.org>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
Avri Altman <avri.altman@wdc.com>,
Masami Hiramatsu <masami.hiramatsu@linaro.org>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 05/11] mmc: core: Enable eMMC sleep commands to use HW busy polling
Date: Fri, 7 May 2021 09:52:43 +0800 [thread overview]
Message-ID: <dcea3e14-4669-60ad-992f-a588a3c8c20f@rock-chips.com> (raw)
In-Reply-To: <20210504161222.101536-6-ulf.hansson@linaro.org>
On 2021/5/5 0:12, Ulf Hansson wrote:
> After the eMMC sleep command (CMD5) has been sent, the card start signals
> busy on the DAT0 line, which can be monitored to understand when it's
> allowed to proceed to power off the VCC regulator.
>
> When MMC_CAP_WAIT_WHILE_BUSY isn't supported by the host the DAT0 line
> isn't being monitored for busy completion, but instead we are waiting a
> fixed period of time. The time corresponds to the sleep timeout that is
> specified in the EXT_CSD register of the eMMC card. This is many cases
> suboptimal, as the timeout corresponds to the worst case scenario.
>
> To improve the situation add support for HW busy polling through the
> ->card_busy() host ops, when the host supports this.
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
> drivers/mmc/core/mmc.c | 25 ++++++++++++++++++++-----
> 1 file changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 63a7bd0b239c..13074aa1f605 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1905,6 +1905,14 @@ static int mmc_can_sleep(struct mmc_card *card)
> return card->ext_csd.rev >= 3;
> }
>
> +static int mmc_sleep_busy_cb(void *cb_data, bool *busy)
> +{
> + struct mmc_host *host = cb_data;
> +
> + *busy = host->ops->card_busy(host);
> + return 0;
> +}
> +
> static int mmc_sleep(struct mmc_host *host)
> {
> struct mmc_command cmd = {};
> @@ -1930,13 +1938,20 @@ static int mmc_sleep(struct mmc_host *host)
> goto out_release;
>
> /*
> - * If the host does not wait while the card signals busy, then we will
> - * will have to wait the sleep/awake timeout. Note, we cannot use the
> - * SEND_STATUS command to poll the status because that command (and most
> - * others) is invalid while the card sleeps.
> + * If the host does not wait while the card signals busy, then we can
> + * try to poll, but only if the host supports HW polling, as the
> + * SEND_STATUS cmd is not allowed. If we can't poll, then we simply need
> + * to wait the sleep/awake timeout.
> */
> - if (!use_r1b_resp || !(host->caps & MMC_CAP_WAIT_WHILE_BUSY))
> + if (host->caps & MMC_CAP_WAIT_WHILE_BUSY && use_r1b_resp)
> + goto out_release;
> +
> + if (!host->ops->card_busy) {
> mmc_delay(timeout_ms);
> + goto out_release;
> + }
> +
> + err = __mmc_poll_for_busy(card, timeout_ms, &mmc_sleep_busy_cb, host);
>
> out_release:
> mmc_retune_release(host);
>
next prev parent reply other threads:[~2021-05-07 1:52 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-04 16:12 [PATCH 00/11] Initital support for new power/perf features for SD cards Ulf Hansson
2021-05-04 16:12 ` [PATCH 01/11] mmc: core: Drop open coding when preparing commands with busy signaling Ulf Hansson
2021-05-06 12:50 ` Linus Walleij
2021-05-07 1:42 ` Shawn Lin
2021-05-04 16:12 ` [PATCH 02/11] mmc: core: Take into account MMC_CAP_NEED_RSP_BUSY for eMMC HPI commands Ulf Hansson
2021-05-06 12:51 ` Linus Walleij
2021-05-07 1:44 ` Shawn Lin
2021-05-04 16:12 ` [PATCH 03/11] mmc: core: Re-structure some code in __mmc_poll_for_busy() Ulf Hansson
2021-05-06 12:52 ` Linus Walleij
2021-05-07 1:48 ` Shawn Lin
2021-05-04 16:12 ` [PATCH 04/11] mmc: core: Extend re-use of __mmc_poll_for_busy() Ulf Hansson
2021-05-06 12:53 ` Linus Walleij
2021-05-07 1:51 ` Shawn Lin
2021-05-04 16:12 ` [PATCH 05/11] mmc: core: Enable eMMC sleep commands to use HW busy polling Ulf Hansson
2021-05-06 12:55 ` Linus Walleij
2021-05-07 1:52 ` Shawn Lin [this message]
2021-05-04 16:12 ` [PATCH 06/11] mmc: core: Prepare mmc_send_cxd_data() to be re-used for additional cmds Ulf Hansson
2021-05-06 12:56 ` Linus Walleij
2021-05-06 13:00 ` Linus Walleij
2021-05-07 7:30 ` Ulf Hansson
2021-05-07 1:53 ` Shawn Lin
2021-05-04 16:12 ` [PATCH 07/11] mmc: core: Drop open coding in mmc_sd_switch() Ulf Hansson
2021-05-06 12:57 ` Linus Walleij
2021-05-07 1:54 ` Shawn Lin
2021-05-04 16:12 ` [PATCH 08/11] mmc: core: Parse the SD SCR register for support of CMD48/49 and CMD58/59 Ulf Hansson
2021-05-06 13:01 ` Linus Walleij
2021-05-07 1:58 ` Shawn Lin
2021-05-04 16:12 ` [PATCH 09/11] mmc: core: Read the SD function extension registers for power management Ulf Hansson
2021-05-06 13:04 ` Linus Walleij
2021-05-07 2:06 ` Shawn Lin
2021-05-07 7:27 ` Ulf Hansson
2021-05-07 7:48 ` Shawn Lin
2021-05-07 11:36 ` Ulf Hansson
2021-05-04 16:12 ` [PATCH 10/11] mmc: core: Read performance enhancements registers for SD cards Ulf Hansson
2021-05-06 13:05 ` Linus Walleij
2021-05-04 16:12 ` [PATCH 11/11] mmc: core: Add support for Power Off Notification " Ulf Hansson
2021-05-06 13:07 ` Linus Walleij
2021-05-07 6:44 ` [PATCH 00/11] Initital support for new power/perf features " Avri Altman
2021-05-07 7:31 ` Ulf Hansson
2021-05-11 10:56 ` 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=dcea3e14-4669-60ad-992f-a588a3c8c20f@rock-chips.com \
--to=shawn.lin@rock-chips.com \
--cc=adrian.hunter@intel.com \
--cc=avri.altman@wdc.com \
--cc=linus.walleij@linaro.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=masami.hiramatsu@linaro.org \
--cc=ulf.hansson@linaro.org \
--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
all inboxes | Powered by JetHome®