mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <ahmad@a3f.at>
Cc: barebox@lists.infradead.org,
	Michael Graichen <michael.graichen@hotmail.com>,
	Steffen Trumtrar <s.trumtrar@pengutronix.de>,
	Yann Sionneau <ysionneau@kalray.eu>
Subject: Re: [PATCH] mci: sdhci: arasan: fix probing eMMC without no-sd
Date: Wed, 4 Jan 2023 11:30:36 +0100	[thread overview]
Message-ID: <20230104103036.GO11668@pengutronix.de> (raw)
In-Reply-To: <20230103220317.466767-1-ahmad@a3f.at>

On Tue, Jan 03, 2023 at 11:03:17PM +0100, Ahmad Fatoum wrote:
> Usual procedure when calling the detect callback of a MCI host driver is
> to assume the connected card is a SD-Card and on timeout, treat it as
> MMC instead. The Arasan driver failed to do this properly leading to the
> need to specify no-sd to get eMMCs working. This is because the driver
> only handled software timeouts gracefully: The MCI host itself may also
> report timeout and it should not be treated as an error and instead
> should be silently passed along as -ETIMEDOUT, so the MCI core can check
> against it and fall back to eMMC after a failed probe for SD.
> 
> Reported-by: Michael Graichen <michael.graichen@hotmail.com>
> Reported-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> Cc: Yann Sionneau <ysionneau@kalray.eu>
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
>  drivers/mci/arasan-sdhci.c | 24 +++++++++++++-----------
>  1 file changed, 13 insertions(+), 11 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/mci/arasan-sdhci.c b/drivers/mci/arasan-sdhci.c
> index 22389503becf..00a8ceed6836 100644
> --- a/drivers/mci/arasan-sdhci.c
> +++ b/drivers/mci/arasan-sdhci.c
> @@ -136,16 +136,17 @@ static void arasan_sdhci_set_ios(struct mci_host *mci, struct mci_ios *ios)
>  static int arasan_sdhci_wait_for_done(struct arasan_sdhci_host *host, u32 mask)
>  {
>  	u64 start = get_time_ns();
> -	u16 stat;
> -	u16 error;
> +	u32 stat;
>  
>  	do {
> -		stat = sdhci_read16(&host->sdhci, SDHCI_INT_NORMAL_STATUS);
> +		stat = sdhci_read32(&host->sdhci, SDHCI_INT_STATUS);
> +
> +		if (stat & SDHCI_INT_TIMEOUT)
> +			return -ETIMEDOUT;
> +
>  		if (stat & SDHCI_INT_ERROR) {
> -			error = sdhci_read16(&host->sdhci,
> -					     SDHCI_INT_ERROR_STATUS);
>  			dev_err(host->mci.hw_dev, "SDHCI_INT_ERROR: 0x%08x\n",
> -				error);
> +				stat);
>  			return -EPERM;
>  		}
>  
> @@ -159,8 +160,11 @@ static int arasan_sdhci_wait_for_done(struct arasan_sdhci_host *host, u32 mask)
>  	return 0;
>  }
>  
> -static void print_error(struct arasan_sdhci_host *host, int cmdidx)
> +static void print_error(struct arasan_sdhci_host *host, int cmdidx, int ret)
>  {
> +	if (ret == -ETIMEDOUT)
> +		return;
> +
>  	dev_err(host->mci.hw_dev,
>  		"error while transferring data for command %d\n", cmdidx);
>  	dev_err(host->mci.hw_dev, "state = 0x%08x , interrupt = 0x%08x\n",
> @@ -210,10 +214,8 @@ static int arasan_sdhci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
>  	sdhci_write16(&host->sdhci, SDHCI_COMMAND, command);
>  
>  	ret = arasan_sdhci_wait_for_done(host, mask);
> -	if (ret == -EPERM)
> +	if (ret)
>  		goto error;
> -	else if (ret)
> -		return ret;
>  
>  	sdhci_read_response(&host->sdhci, cmd);
>  	sdhci_write32(&host->sdhci, SDHCI_INT_STATUS, mask);
> @@ -223,7 +225,7 @@ static int arasan_sdhci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
>  
>  error:
>  	if (ret) {
> -		print_error(host, cmd->cmdidx);
> +		print_error(host, cmd->cmdidx, ret);
>  		arasan_sdhci_reset(host, BIT(1)); // SDHCI_RESET_CMD
>  		arasan_sdhci_reset(host, BIT(2)); // SDHCI_RESET_DATA
>  	}
> -- 
> 2.38.1
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2023-01-04 10:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03 22:03 Ahmad Fatoum
2023-01-04 10:30 ` Sascha Hauer [this message]

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=20230104103036.GO11668@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=ahmad@a3f.at \
    --cc=barebox@lists.infradead.org \
    --cc=michael.graichen@hotmail.com \
    --cc=s.trumtrar@pengutronix.de \
    --cc=ysionneau@kalray.eu \
    /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