mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <sha@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] mci: only write blocks when card out of programming mode
Date: Wed, 14 Dec 2022 11:55:37 +0100	[thread overview]
Message-ID: <c9ec86b6-dc82-ebc3-643e-18dd6fa9b997@pengutronix.de> (raw)
In-Reply-To: <20221214100329.GR29728@pengutronix.de>

Hi,

On 14.12.22 11:03, Sascha Hauer wrote:
> On Tue, Dec 13, 2022 at 03:12:04PM +0100, Ahmad Fatoum wrote:
>>  /**
>>   * @param p Command definition to setup
>>   * @param cmd Valid SD/MMC command (refer MMC_CMD_* / SD_CMD_*)
>> @@ -119,6 +141,69 @@ static int mci_set_blocklen(struct mci *mci, unsigned len)
>>  
>>  static void *sector_buf;
>>  
>> +static int mci_send_status(struct mci *mci, unsigned int *status)
>> +{
>> +	struct mci_host *host = mci->host;
>> +	struct mci_cmd cmd;
>> +	int ret;
>> +
>> +	cmd.cmdidx = MMC_CMD_SEND_STATUS;
>> +	cmd.resp_type = MMC_RSP_R1;
>> +	if (!mmc_host_is_spi(host))
>> +		cmd.cmdarg = mci->rca << 16;
> 
> cmd.cmdarg will be uninitialized for SPI MMC hosts.

Ouch. It seems CMD13 is valid for SPI hosts too, but they report
different bits. I have skipped this for SPI hosts in v2.

>> +	if (retries >=  timeout_ms) {
>> +		dev_err(&mci->dev, "Timeout waiting card ready\n");
>> +		return -ETIMEDOUT;
>> +	}
> 
> You could move this into the timeout test in the loop above.

Alright.

>> +
>> +	/*
>> +	 * With small UART FIFOs and slow CPUs, printing in the loop above
>> +	 * may take enough time to render the polling loop above unnecessary
>> +	 * falsifying the debugging info. Thus we report the retries here.
>> +	 */
> 
> People reading this code are likely aware of that, I think you can remove
> this comment.
> 
>> +	dev_info(&mci->dev, "Ready polling took %ums\n", retries);
> 
> dev_dbg()?

Both done in v2.

>> +	/*
>> +	 * Quoting eMMC Spec v5.1 (JEDEC Standard No. 84-B51):
>> +	 * Due to legacy reasons, a Device may still treat CMD24/25 during
>> +	 * prg-state (while busy is active) as a legal or illegal command.
>> +	 * A host should not send CMD24/25 while the Device is in the prg
>> +	 * state and busy is active.
>> +	 */
>> +	ret = mci_poll_until_ready(mci, 10 /* ms */);
> 
> Is 10ms enough? U-Boot has 1s here.

My line of thinking was that we got away without this so far, so if 10ms
isn't enough, there's probably something wrong elsewhere. That's little
consolation to users that would get breakage if they indeed need to wait
longer, so I bumped it to 1000ms.

Thanks,
Ahmad

> 
> Sascha
> 

-- 
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:[~2022-12-14 10:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13 14:12 Ahmad Fatoum
2022-12-14  9:47 ` Ahmad Fatoum
2022-12-14 10:03 ` Sascha Hauer
2022-12-14 10:55   ` Ahmad Fatoum [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=c9ec86b6-dc82-ebc3-643e-18dd6fa9b997@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=sha@pengutronix.de \
    /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