diff mbox series

[v2] mmc: block: Use .card_busy() to detect busy state in card_busy_detect

Message ID 1623134576-212150-1-git-send-email-shawn.lin@rock-chips.com (mailing list archive)
State New, archived
Headers show
Series [v2] mmc: block: Use .card_busy() to detect busy state in card_busy_detect | expand

Commit Message

Shawn Lin June 8, 2021, 6:42 a.m. UTC
No need to send CMD13 if host driver supports .card_busy().

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>

---

Changes in v2:
- fix build issue

 drivers/mmc/core/block.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Ulf Hansson July 2, 2021, 3 p.m. UTC | #1
On Tue, 8 Jun 2021 at 08:43, Shawn Lin <shawn.lin@rock-chips.com> wrote:
>
> No need to send CMD13 if host driver supports .card_busy().
>
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>

Shawn, I just sent a small series that moves the mmc block layer into
using the common mmc_poll_for_busy() code. I think $subject patch is
better to be discussed as an improvement on top in that series.

I already have some thoughts about it, but I will be awaiting to
provide you with some comment around it, until there is a new version
from you.

Kind regards
Uffe

>
> ---
>
> Changes in v2:
> - fix build issue
>
>  drivers/mmc/core/block.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index 88f4c215..379614a9 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -417,10 +417,17 @@ static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms,
>         unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
>         int err = 0;
>         u32 status;
> +       bool busy;
>
>         do {
>                 bool done = time_after(jiffies, timeout);
>
> +               if (card->host->ops->card_busy) {
> +                       busy = card->host->ops->card_busy(card->host);
> +                       status = busy ? 0 : R1_READY_FOR_DATA | R1_STATE_TRAN << 9;
> +                       goto cb;
> +               }
> +
>                 err = __mmc_send_status(card, &status, 5);
>                 if (err) {
>                         dev_err(mmc_dev(card->host),
> @@ -431,7 +438,7 @@ static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms,
>                 /* Accumulate any response error bits seen */
>                 if (resp_errs)
>                         *resp_errs |= status;
> -
> +cb:
>                 /*
>                  * Timeout if the device never becomes ready for data and never
>                  * leaves the program state.
> --
> 2.7.4
>
>
>
Shawn Lin July 5, 2021, 12:45 a.m. UTC | #2
On 2021/7/2 23:00, Ulf Hansson wrote:
> On Tue, 8 Jun 2021 at 08:43, Shawn Lin <shawn.lin@rock-chips.com> wrote:
>>
>> No need to send CMD13 if host driver supports .card_busy().
>>
>> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> 
> Shawn, I just sent a small series that moves the mmc block layer into
> using the common mmc_poll_for_busy() code. I think $subject patch is
> better to be discussed as an improvement on top in that series.
> 
> I already have some thoughts about it, but I will be awaiting to
> provide you with some comment around it, until there is a new version
> from you.

Sure, I will take a close look at your patch-set.

Thanks.

> 
> Kind regards
> Uffe
> 
>>
>> ---
>>
>> Changes in v2:
>> - fix build issue
>>
>>   drivers/mmc/core/block.c | 9 ++++++++-
>>   1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
>> index 88f4c215..379614a9 100644
>> --- a/drivers/mmc/core/block.c
>> +++ b/drivers/mmc/core/block.c
>> @@ -417,10 +417,17 @@ static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms,
>>          unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
>>          int err = 0;
>>          u32 status;
>> +       bool busy;
>>
>>          do {
>>                  bool done = time_after(jiffies, timeout);
>>
>> +               if (card->host->ops->card_busy) {
>> +                       busy = card->host->ops->card_busy(card->host);
>> +                       status = busy ? 0 : R1_READY_FOR_DATA | R1_STATE_TRAN << 9;
>> +                       goto cb;
>> +               }
>> +
>>                  err = __mmc_send_status(card, &status, 5);
>>                  if (err) {
>>                          dev_err(mmc_dev(card->host),
>> @@ -431,7 +438,7 @@ static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms,
>>                  /* Accumulate any response error bits seen */
>>                  if (resp_errs)
>>                          *resp_errs |= status;
>> -
>> +cb:
>>                  /*
>>                   * Timeout if the device never becomes ready for data and never
>>                   * leaves the program state.
>> --
>> 2.7.4
>>
>>
>>
> 
> 
>
diff mbox series

Patch

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 88f4c215..379614a9 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -417,10 +417,17 @@  static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms,
 	unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
 	int err = 0;
 	u32 status;
+	bool busy;
 
 	do {
 		bool done = time_after(jiffies, timeout);
 
+		if (card->host->ops->card_busy) {
+			busy = card->host->ops->card_busy(card->host);
+			status = busy ?	0 : R1_READY_FOR_DATA | R1_STATE_TRAN << 9;
+			goto cb;
+		}
+
 		err = __mmc_send_status(card, &status, 5);
 		if (err) {
 			dev_err(mmc_dev(card->host),
@@ -431,7 +438,7 @@  static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms,
 		/* Accumulate any response error bits seen */
 		if (resp_errs)
 			*resp_errs |= status;
-
+cb:
 		/*
 		 * Timeout if the device never becomes ready for data and never
 		 * leaves the program state.