All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mmc: block: Use .card_busy() to detect busy state in card_busy_detect
@ 2021-06-08  6:42 Shawn Lin
  2021-07-02 15:00 ` Ulf Hansson
  0 siblings, 1 reply; 3+ messages in thread
From: Shawn Lin @ 2021-06-08  6:42 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, Shawn Lin

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(-)

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




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mmc: block: Use .card_busy() to detect busy state in card_busy_detect
  2021-06-08  6:42 [PATCH v2] mmc: block: Use .card_busy() to detect busy state in card_busy_detect Shawn Lin
@ 2021-07-02 15:00 ` Ulf Hansson
  2021-07-05  0:45   ` Shawn Lin
  0 siblings, 1 reply; 3+ messages in thread
From: Ulf Hansson @ 2021-07-02 15:00 UTC (permalink / raw)
  To: Shawn Lin; +Cc: linux-mmc

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
>
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mmc: block: Use .card_busy() to detect busy state in card_busy_detect
  2021-07-02 15:00 ` Ulf Hansson
@ 2021-07-05  0:45   ` Shawn Lin
  0 siblings, 0 replies; 3+ messages in thread
From: Shawn Lin @ 2021-07-05  0:45 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: shawn.lin, linux-mmc

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
>>
>>
>>
> 
> 
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-05  0:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08  6:42 [PATCH v2] mmc: block: Use .card_busy() to detect busy state in card_busy_detect Shawn Lin
2021-07-02 15:00 ` Ulf Hansson
2021-07-05  0:45   ` Shawn Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.