* [U-Boot] [PATCH 1/1] efi_driver: set block size for EFI block device
@ 2019-10-24 20:49 Heinrich Schuchardt
2019-10-25 4:34 ` AKASHI Takahiro
0 siblings, 1 reply; 4+ messages in thread
From: Heinrich Schuchardt @ 2019-10-24 20:49 UTC (permalink / raw)
To: u-boot
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 <xypron.glpk@gmx.de>
---
lib/efi_driver/efi_block_device.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
index cf02341931..9de526a95b 100644
--- a/lib/efi_driver/efi_block_device.c
+++ b/lib/efi_driver/efi_block_device.c
@@ -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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 1/1] efi_driver: set block size for EFI block device
2019-10-24 20:49 [U-Boot] [PATCH 1/1] efi_driver: set block size for EFI block device Heinrich Schuchardt
@ 2019-10-25 4:34 ` AKASHI Takahiro
2019-10-25 6:37 ` Heinrich Schuchardt
0 siblings, 1 reply; 4+ messages in thread
From: AKASHI Takahiro @ 2019-10-25 4:34 UTC (permalink / raw)
To: u-boot
On Thu, Oct 24, 2019 at 08:49:00PM +0000, Heinrich Schuchardt wrote:
> 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 <xypron.glpk@gmx.de>
> ---
> lib/efi_driver/efi_block_device.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
> index cf02341931..9de526a95b 100644
> --- a/lib/efi_driver/efi_block_device.c
> +++ b/lib/efi_driver/efi_block_device.c
> @@ -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);
I don't think that this is the best place to put them.
Better to initialise log2blksz in blk_create_device().
-Takahiro Akashi
> /* 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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 1/1] efi_driver: set block size for EFI block device
2019-10-25 4:34 ` AKASHI Takahiro
@ 2019-10-25 6:37 ` Heinrich Schuchardt
2019-10-25 6:54 ` AKASHI Takahiro
0 siblings, 1 reply; 4+ messages in thread
From: Heinrich Schuchardt @ 2019-10-25 6:37 UTC (permalink / raw)
To: u-boot
On 10/25/19 6:34 AM, AKASHI Takahiro wrote:
> On Thu, Oct 24, 2019 at 08:49:00PM +0000, Heinrich Schuchardt wrote:
>> 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 <xypron.glpk@gmx.de>
>> ---
>> lib/efi_driver/efi_block_device.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
>> index cf02341931..9de526a95b 100644
>> --- a/lib/efi_driver/efi_block_device.c
>> +++ b/lib/efi_driver/efi_block_device.c
>> @@ -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);
>
> 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:1491
drivers/scsi/scsi.c:548
drivers/mmc/mmc.c:2586
drivers/block/ide.c:485
drivers/block/ide.c:530
drivers/block/ide.c:688
drivers/ata/sata.c:100
drivers/nvme/nvme.c:681
disk/part.c:560
disk/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
>
> -Takahiro Akashi
>
>
>> /* 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
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 1/1] efi_driver: set block size for EFI block device
2019-10-25 6:37 ` Heinrich Schuchardt
@ 2019-10-25 6:54 ` AKASHI Takahiro
0 siblings, 0 replies; 4+ messages in thread
From: AKASHI Takahiro @ 2019-10-25 6:54 UTC (permalink / raw)
To: u-boot
On Fri, Oct 25, 2019 at 08:37:11AM +0200, Heinrich Schuchardt wrote:
> On 10/25/19 6:34 AM, AKASHI Takahiro wrote:
> >On Thu, Oct 24, 2019 at 08:49:00PM +0000, Heinrich Schuchardt wrote:
> >>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 <xypron.glpk@gmx.de>
> >>---
> >> lib/efi_driver/efi_block_device.c | 6 ++++++
> >> 1 file changed, 6 insertions(+)
> >>
> >>diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
> >>index cf02341931..9de526a95b 100644
> >>--- a/lib/efi_driver/efi_block_device.c
> >>+++ b/lib/efi_driver/efi_block_device.c
> >>@@ -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);
> >
> >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:1491
> drivers/scsi/scsi.c:548
> drivers/mmc/mmc.c:2586
> drivers/block/ide.c:485
> drivers/block/ide.c:530
> drivers/block/ide.c:688
> drivers/ata/sata.c:100
> drivers/nvme/nvme.c:681
> disk/part.c:560
> disk/part.c:637
>
> 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
> Once all boards use CONFIG_DM and CONFIG_BLK we can clean up the code.
>
> Best regards
>
> Heinrich
>
> >
> >-Takahiro Akashi
> >
> >
> >> /* 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
> >>
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-10-25 6:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-24 20:49 [U-Boot] [PATCH 1/1] efi_driver: set block size for EFI block device Heinrich Schuchardt
2019-10-25 4:34 ` AKASHI Takahiro
2019-10-25 6:37 ` Heinrich Schuchardt
2019-10-25 6:54 ` AKASHI Takahiro
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.