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

Heinrich Schuchardt xypron.glpk at gmx.de
Mon Oct 11 12:07:12 CEST 2021



On 10/1/21 13:48, Peter Robinson wrote:
> On Fri, Oct 1, 2021 at 6:03 AM AKASHI Takahiro
> <takahiro.akashi at linaro.org> 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.
>
> Is it not also supported on UFS, and I believe it may also be an
> option in the NVME spec too.

An NVMe device may expose multiple namespaces. blk_create_devicef() is
called for each namespace.

A SCSI device may have multiple LUNs. blk_create_devicef() is called for
each LUN.

This is what the tree shown by 'dm tree' with on NVMe namespace and one LUN.

Class  Index Driver         Name
---------------------------------------------------------------------
root       0 root_driver    root_driver
simple_bus 0 simple_bus     |- soc
spi        1 sifive_spi     |  |- spi at 10050000
mmc        0 mmc_spi        |  |  `- mmc at 0
blk        0 mmc_blk        |  |     `- mmc at 0.blk
pci        0 pcie_sifive    |  |- pcie at e00000000
pci        1 pci_bridge_drv |  |  `- pci_0:0.0
pci        2 pci_bridge_drv |  |     `- pci_1:0.0
pci        5 pci_bridge_drv |  |        |- pci_2:3.0
ahci       0 ahci_pci       |  |        |  `- ahci_pci
scsi       0 ahci_scsi      |  |        |     `- ahci_scsi
blk        2 scsi_blk       |  |        |        `- ahci_scsi.id0lun0
pci        6 pci_bridge_drv |  |        |- pci_2:4.0
nvme       0 nvme           |  |        |  `- nvme#0
blk        1 nvme-blk       |  |        |     `- nvme#0.blk#1

Namespaces and LUNs are modeled as block devices (class = 'blk').

Best regards

Heinrich

>
>> Signed-off-by: AKASHI Takahiro <takahiro.akashi at 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);
>>   #endif
>>
>>   cleanup:
>> --
>> 2.33.0
>>


More information about the U-Boot mailing list