From: Peter A. Bigot <pab@pabigot.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] mmc: restore capacity when switching to partition 0
Date: Wed, 03 Sep 2014 10:59:51 -0500 [thread overview]
Message-ID: <54073AF7.1040306@pabigot.com> (raw)
In-Reply-To: <54073836.6090809@wwwdotorg.org>
On 09/03/2014 10:48 AM, Stephen Warren wrote:
> On 09/02/2014 05:31 PM, Peter A. Bigot wrote:
>> The capacity and lba for an MMC device with part_num 0 reflects the
>> whole device. When mmc_switch_part() successfully switches to a
>> partition, the capacity is changed to that partition. As partition 0
>> does not physically exist, attempts to switch back to the whole device
>> will indicate an error, but the capacity setting for the whole device
>> must still be restored to match the partition.
>
>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>
>> @@ -594,10 +594,15 @@ int mmc_switch_part(int dev_num, unsigned int
>> part_num)
>> ret = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF,
>> (mmc->part_config & ~PART_ACCESS_MASK)
>> | (part_num & PART_ACCESS_MASK));
>> - if (ret)
>> - return ret;
>>
>> - return mmc_set_capacity(mmc, part_num);
>> + /*
>> + * Set the capacity if the switch succeeded or was intended
>> + * to return to representing the raw device.
>> + */
>> + if ((ret == 0) || ((ret == -ENODEV) && (part_num == 0)))
>> + ret = mmc_set_capacity(mmc, part_num);
>> +
>> + return ret;
>> }
>
> I think this wouldn't be needed without patch 1/2, since without that
> patch, no partition switching should ever happen if HW partitions
> don't exist, and hence this patch shouldn't be required.
Not so.
In SPL mode, the mmc device passed in to the environment code is set up
for partition 0. In the failure case, u-boot is configured to expect an
environment in partition 2, and so invokes mmc_switch_part to go to
partition 2 to see if it's a valid partition. In my case that fails
because the partition size is zero, but regardless the mmc_switch_part
back to mmc->part_num fails because the mmc_switch() call rejects the
attempt with an error.
Without this second patch, you end up with mmc->part_num left at zero
but the capacity/lba fields configured for partition 2 which does not
exist and has size zero, and SPL is unable to locate u-boot.img to continue.
Please review the details in the meta-ti discussion.
I'll respond to the comments on patch 1 separately.
Peter
next prev parent reply other threads:[~2014-09-03 15:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-02 23:31 [U-Boot] [PATCH 0/2] fix issue with mmc partition management Peter A. Bigot
2014-09-02 23:31 ` [U-Boot] [PATCH 1/2] env_mmc: remove condition on call to mmc_switch_part Peter A. Bigot
2014-09-03 15:46 ` Stephen Warren
2014-09-03 16:03 ` Peter A. Bigot
2014-09-03 16:32 ` [U-Boot] [PATCH v2] env_mmc: correct fini partition to match init partition Peter A. Bigot
2014-09-03 16:52 ` Stephen Warren
2014-09-03 17:30 ` Peter A. Bigot
2014-09-03 17:46 ` Stephen Warren
2014-09-03 17:55 ` Peter A. Bigot
2014-09-03 17:22 ` [U-Boot] [PATCH v3] " Peter A. Bigot
2014-09-09 15:25 ` Igor Grinberg
2014-09-14 13:21 ` Dmitry Lifshitz
2014-10-02 11:09 ` Pantelis Antoniou
2014-09-02 23:31 ` [U-Boot] [PATCH 2/2] mmc: restore capacity when switching to partition 0 Peter A. Bigot
2014-09-03 15:48 ` Stephen Warren
2014-09-03 15:59 ` Peter A. Bigot [this message]
2014-09-03 16:05 ` Stephen Warren
2014-09-03 16:36 ` Peter A. Bigot
2014-09-11 17:45 ` Tom Rini
2014-10-02 11:07 ` Pantelis Antoniou
2014-09-11 15:57 ` [U-Boot] [PATCH 0/2] fix issue with mmc partition management Tom Rini
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=54073AF7.1040306@pabigot.com \
--to=pab@pabigot.com \
--cc=u-boot@lists.denx.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