efi_driver: set block size for EFI block device
PATCH 1/1 efi_driver: set block size for EFI block device
Copy the block size from the block IO protocol to the U-Boot block device descriptor. This information is used by the ext4 file system driver.
--- lib/efi_driver/efi_block_device.c | 6 ++++++ 1 file changed, 6 insertions(+)
lib/efi_driver/efi_block_device.c +6 -0
@@ -137,6 +137,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)struct efi_block_io *io = interface;int disks;struct efi_blk_platdata *platdata; +struct blk_desc *desc;EFI_PRINT ("%s: handle %p, interface %p\n" , __func__, handle, io);
@@ -174,6 +175,11 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)return ret;EFI_PRINT ("%s: block device '%s' created\n" , __func__, bdev->name); +/* Set block size */ + desc =dev_get_uclass_platdata (bdev); + desc->blksz = io->media->block_size; + desc->log2blksz =LOG2 (desc->blksz); +/* Create handles for the partions of the block device */ disks =efi_bl_bind_partitions (handle, bdev);EFI_PRINT ("Found %d partitions\n" , disks);
--
2.20.1
PATCH 1/1 efi_driver: set block size for EFI block device
Quoted 21 lines · Heinrich Schuchardt
Copy the block size from the block IO protocol to the U-Boot block device descriptor. This information is used by the ext4 file system driver.
Signed-off-by Heinrich Schuchardt <[email protected]>--- lib/efi_driver/efi_block_device.c | 6 ++++++ 1 file changed, 6 insertions(+)lib/efi_driver/efi_block_device.c +1
-0@@ -137,6 +137,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)struct efi_block_io *io = interface;int disks;struct efi_blk_platdata *platdata; +struct blk_desc *desc;EFI_PRINT ("%s: handle %p, interface %p\n" , __func__, handle, io);
lib/efi_driver/efi_block_device.c static int efi_bl_bind(efi_handle_t handle, void *interface) · line 181
Quoted 7 lines
lib/efi_driver/efi_block_device.c +4
-0@@ -174,6 +175,11 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)return ret;EFI_PRINT ("%s: block device '%s' created\n" , __func__, bdev->name); +/* Set block size */ + desc =dev_get_uclass_platdata (bdev); + desc->blksz = io->media->block_size; + desc->log2blksz =LOG2 (desc->blksz);
I don't think that this is the best place to put them. Better to initialise log2blksz in blk_create_device().
-Takahiro Akashi
Quoted 6 lines
lib/efi_driver/efi_block_device.c +0
-1/* Create handles for the partions of the block device */ disks =efi_bl_bind_partitions (handle, bdev);EFI_PRINT ("Found %d partitions\n" , disks); --2.20.1
PATCH 1/1 efi_driver: set block size for EFI block device
Quoted 25 lines · AKASHI Takahiro
Quoted 24 lines · Heinrich Schuchardt
Copy the block size from the block IO protocol to the U-Boot block device descriptor. This information is used by the ext4 file system driver.
Signed-off-by Heinrich Schuchardt <[email protected]>--- lib/efi_driver/efi_block_device.c | 6 ++++++ 1 file changed, 6 insertions(+)lib/efi_driver/efi_block_device.c +1
-0@@ -137,6 +137,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)struct efi_block_io *io = interface;int disks;struct efi_blk_platdata *platdata; +struct blk_desc *desc;EFI_PRINT ("%s: handle %p, interface %p\n" , __func__, handle, io);@@ -174,6 +175,11 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)return ret;EFI_PRINT ("%s: block device '%s' created\n" , __func__, bdev->name);
Quoted 7 lines
lib/efi_driver/efi_block_device.c static int efi_bl_bind(efi_handle_t handle, void *interface) · line 181
Quoted 4 lines
lib/efi_driver/efi_block_device.c +4
-0+/* Set block size */ + desc =dev_get_uclass_platdata (bdev); + desc->blksz = io->media->block_size; + desc->log2blksz =LOG2 (desc->blksz);I don't think that this is the best place to put them. Better to initialise log2blksz in
blk_create_device().
desc->blksz can only be set in the EFI code because it is only here that we know the block size.
log2blksz is currently set in:
common/usb_storage.c:1491drivers/scsi/scsi.c:548drivers/mmc/mmc.c:2586drivers/block/ide.c:485drivers/block/ide.c:530drivers/block/ide.c:688drivers/ata/sata.c:100drivers/nvme/nvme.c:681disk/part.c:560disk/part.c:637
blk_create_device() is only called if a board uses the driver model which unfortunately isn't true for all boards.
Once all boards use CONFIG_DM and CONFIG_BLK we can clean up the code.
Best regards
Heinrich
Quoted 11 lines
-Takahiro Akashi
Quoted 6 lines
lib/efi_driver/efi_block_device.c +0
-1/* Create handles for the partions of the block device */ disks =efi_bl_bind_partitions (handle, bdev);EFI_PRINT ("Found %d partitions\n" , disks); --2.20.1
PATCH 1/1 efi_driver: set block size for EFI block device
Quoted 50 lines · Heinrich Schuchardt
Quoted 25 lines · AKASHI Takahiro
Quoted 24 lines · Heinrich Schuchardt
Copy the block size from the block IO protocol to the U-Boot block device descriptor. This information is used by the ext4 file system driver.
Signed-off-by Heinrich Schuchardt <[email protected]>--- lib/efi_driver/efi_block_device.c | 6 ++++++ 1 file changed, 6 insertions(+)lib/efi_driver/efi_block_device.c +1
-0@@ -137,6 +137,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)struct efi_block_io *io = interface;int disks;struct efi_blk_platdata *platdata; +struct blk_desc *desc;EFI_PRINT ("%s: handle %p, interface %p\n" , __func__, handle, io);@@ -174,6 +175,11 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)return ret;EFI_PRINT ("%s: block device '%s' created\n" , __func__, bdev->name);Quoted 7 lines
lib/efi_driver/efi_block_device.c static int efi_bl_bind(efi_handle_t handle, void *interface) · line 181
Quoted 4 lines
lib/efi_driver/efi_block_device.c +4
-0+/* Set block size */ + desc =dev_get_uclass_platdata (bdev); + desc->blksz = io->media->block_size; + desc->log2blksz =LOG2 (desc->blksz);I don't think that this is the best place to put them. Better to initialise log2blksz in
blk_create_device().
desc->blkszcan only be set in the EFI code because it is only here that we know the block size.log2blksz is currently set in:
common/usb_storage.c:1491drivers/scsi/scsi.c:548drivers/mmc/mmc.c:2586drivers/block/ide.c:485drivers/block/ide.c:530drivers/block/ide.c:688drivers/ata/sata.c:100drivers/nvme/nvme.c:681disk/part.c:560disk/part.c:637
Quoted 2 lines
blk_create_device()is only called if a board uses the driver model which unfortunately isn't true for all boards.
?efi_bl_bind() always calls blk_create_device(). Modifying blk_create_device() should work for EFI.
Yes, there are couple of places to set log2blksz in drivers. But if any of them sets log2blksz to anything but LOG2(desc->blksz), it is a bug.
You should clean them up before your patch.
(As in the case that you have suggested me before)
Don't increase local hacks.
-Takahiro Akashi
Quoted 18 lines
Once all boards use
CONFIG_DMandCONFIG_BLKwe can clean up the code.Best regards
Heinrich
Quoted 11 lines
-Takahiro Akashi
Quoted 6 lines
lib/efi_driver/efi_block_device.c +0
-1/* Create handles for the partions of the block device */ disks =efi_bl_bind_partitions (handle, bdev);EFI_PRINT ("Found %d partitions\n" , disks); --2.20.1