Re: [RFC 01/22] part: call part_init() in blk_get_device_by_str() only for MMC

Heinrich Schuchardt
2021-10-01T07:56:19Z

On 10/1/21 08:41, Heinrich Schuchardt wrote:
>
>
> On 10/1/21 7:01 AM, AKASHI Takahiro wrote:
>> In blk_get_device_by_str(), the comment says: "Updates the partition
>> table
>> for the specified hw partition."
>> Since hw partition is supported only on MMC, it makes no sense to do so
>> for other devices.
>>
>> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
>> ---
>>   disk/part.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/disk/part.c b/disk/part.c
>> index a6a8f7052bd3..b330103a5bc0 100644
>> --- a/disk/part.c
>> +++ b/disk/part.c
>> @@ -427,7 +427,8 @@ int blk_get_device_by_str(const char *ifname,
>> const char *dev_hwpart_str,
>>        * Always should be done, otherwise hw partition 0 will return
>> stale
>>        * data after displaying a non-zero hw partition.
>>        */
>> -    part_init(*dev_desc);
>> +    if ((*dev_desc)->if_type == IF_TYPE_MMC)
>> +        part_init(*dev_desc);
>
> For an eMMC the following logical levels exist:
>
> * device
> * hardware partition
> * software partition
>
> Linux might show the following:
>
> /dev/mmcblk0 - user data area
> /dev/mmcblk0boot0 - boot hardware partition 0
> /dev/mmcblk0boot1 - boot hardware partition 1
> /dev/mmcblk0rpmb - replay protected memory block
>
> How are the different hardware partition modeled in the UEFI device path?

This is a list of block devices with their Linux name and the device
path in EDK II as seen on my MacchicatoBIN board:

/dev/mmcblk0
VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,00006EF00000000000)/eMMC(0x0)/Ctrl(0x0)

/dev/mmcblk0p1
VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,00006EF00000000000)/eMMC(0x0)/Ctrl(0x0)/HD(1,GPT,C53259E6-9B1D-40CD-B4EF-39520011EF2B,0x2000,0x3FE001)

/dev/mmcblk0p2
VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,00006EF00000000000)/eMMC(0x0)/Ctrl(0x0)/HD(2,GPT,A0AE9901-B847-4150-B947-6C8FF69529A7,0x400800,0xA8F7DF)

/dev/mmcblk0boot0
VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,00006EF00000000000)/eMMC(0x0)/Ctrl(0x1)

/dev/mmcblk0boot1
VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,00006EF00000000000)/eMMC(0x0)/Ctrl(0x2)

> Should each hardware partition be a separate udevice?

We need a udevice matching the hardware partition. These child devices
should be created when the eMMC device is probed.

Best regards

Heinrich

>
> For NOR flash we also have an extra level:
>
> => setenv mtdparts
> mtdparts=30bb0000.qspi:1m(U-Boot),512k(Env),512k(DTB),2m(User_FS),12m(Data_FS),4m(Factory_FS),34m(Ramdisk),10m(Linux)
>
> => mtd
>
> device nor0 <30bb0000.qspi>, # parts = 8
>  #: name                size            offset          mask_flags
>  0: U-Boot              0x00100000      0x00000000      0
>  1: Env                 0x00080000      0x00100000      0
>  2: DTB                 0x00080000      0x00180000      0
>  3: User_FS             0x00200000      0x00200000      0
>  4: Data_FS             0x00c00000      0x00400000      0
>  5: Factory_FS          0x00400000      0x01000000      0
>  6: Ramdisk             0x02200000      0x01400000      0
>  7: Linux               0x00a00000      0x03600000      0
>
> active partition: nor0,0 - (U-Boot) 0x00100000 @ 0x00000000
>
> Has part_info() to be called here too? What is the if_type?
> What are the devicepaths for these partitions?
>
> Best regards
>
> Heinrich
>
>>   #endif
>>
>>   cleanup:
>>