All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci: Fix sdhci_card_busy()
@ 2016-06-23 11:00 Adrian Hunter
  2016-06-27  9:21 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Adrian Hunter @ 2016-06-23 11:00 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc

host->card_busy() was introduced for SD voltage switching which checks all
4 data lines.

Increasingly, host->card_busy is being used to poll the the busy signal
which is only data line 0 (DAT[0]).

The current logic in sdhci_card_busy() does not work in that case because
it returns false if any of the data lines is high.  It also ignores
possibilities:
	- data lines 1-3 are not connected and could show at any level
	- data lines 1-2 can be used by SDIO for other purposes

According to the SD specification, it is OK to check any of the data lines
for voltage switching, so change to use DAT[0] only.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---


 It would probably be better for this patch to go before
 "mmc: mmc: Use ->card_busy() to detect busy cards in __mmc_switch()"


 drivers/mmc/host/sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index ec14b5d61fc6..15bdbcb99170 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1811,10 +1811,10 @@ static int sdhci_card_busy(struct mmc_host *mmc)
 	struct sdhci_host *host = mmc_priv(mmc);
 	u32 present_state;
 
-	/* Check whether DAT[3:0] is 0000 */
+	/* Check whether DAT[0] is 0 */
 	present_state = sdhci_readl(host, SDHCI_PRESENT_STATE);
 
-	return !(present_state & SDHCI_DATA_LVL_MASK);
+	return !(present_state & SDHCI_DATA_0_LVL_MASK);
 }
 
 static int sdhci_prepare_hs400_tuning(struct mmc_host *mmc, struct mmc_ios *ios)
-- 
1.9.1


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

* Re: [PATCH] mmc: sdhci: Fix sdhci_card_busy()
  2016-06-23 11:00 [PATCH] mmc: sdhci: Fix sdhci_card_busy() Adrian Hunter
@ 2016-06-27  9:21 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2016-06-27  9:21 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: linux-mmc

On 23 June 2016 at 13:00, Adrian Hunter <adrian.hunter@intel.com> wrote:
> host->card_busy() was introduced for SD voltage switching which checks all
> 4 data lines.
>
> Increasingly, host->card_busy is being used to poll the the busy signal
> which is only data line 0 (DAT[0]).
>
> The current logic in sdhci_card_busy() does not work in that case because
> it returns false if any of the data lines is high.  It also ignores
> possibilities:
>         - data lines 1-3 are not connected and could show at any level
>         - data lines 1-2 can be used by SDIO for other purposes
>
> According to the SD specification, it is OK to check any of the data lines
> for voltage switching, so change to use DAT[0] only.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>
>
>  It would probably be better for this patch to go before
>  "mmc: mmc: Use ->card_busy() to detect busy cards in __mmc_switch()"
>

Thanks, applied for next and prior the above mentioned patch!
Kind regards
Uffe

>
>  drivers/mmc/host/sdhci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index ec14b5d61fc6..15bdbcb99170 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1811,10 +1811,10 @@ static int sdhci_card_busy(struct mmc_host *mmc)
>         struct sdhci_host *host = mmc_priv(mmc);
>         u32 present_state;
>
> -       /* Check whether DAT[3:0] is 0000 */
> +       /* Check whether DAT[0] is 0 */
>         present_state = sdhci_readl(host, SDHCI_PRESENT_STATE);
>
> -       return !(present_state & SDHCI_DATA_LVL_MASK);
> +       return !(present_state & SDHCI_DATA_0_LVL_MASK);
>  }
>
>  static int sdhci_prepare_hs400_tuning(struct mmc_host *mmc, struct mmc_ios *ios)
> --
> 1.9.1
>

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

end of thread, other threads:[~2016-06-27  9:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-23 11:00 [PATCH] mmc: sdhci: Fix sdhci_card_busy() Adrian Hunter
2016-06-27  9:21 ` Ulf Hansson

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.