All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/1] blk: set log2blksz in blk_create_device()
@ 2019-10-25 10:15 Heinrich Schuchardt
  2019-10-30  1:49 ` Simon Glass
  0 siblings, 1 reply; 3+ messages in thread
From: Heinrich Schuchardt @ 2019-10-25 10:15 UTC (permalink / raw)
  To: u-boot

The ext4 file system requires log2blksz to be set. So when setting the
block size on the block descriptor we should fill this field too.

This fixes a problem with EFI block devices providing ext4 partitions, cf.
https://lists.denx.de/pipermail/u-boot/2019-October/387702.html.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 drivers/block/blk-uclass.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index e8f58b3f5e..ca8978f0e1 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -580,6 +580,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
 	desc = dev_get_uclass_platdata(dev);
 	desc->if_type = if_type;
 	desc->blksz = blksz;
+	desc->log2blksz = LOG2(desc->blksz);
 	desc->lba = lba;
 	desc->part_type = PART_TYPE_UNKNOWN;
 	desc->bdev = dev;
--
2.23.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 1/1] blk: set log2blksz in blk_create_device()
  2019-10-25 10:15 [U-Boot] [PATCH 1/1] blk: set log2blksz in blk_create_device() Heinrich Schuchardt
@ 2019-10-30  1:49 ` Simon Glass
  2019-10-30  6:35   ` Heinrich Schuchardt
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Glass @ 2019-10-30  1:49 UTC (permalink / raw)
  To: u-boot

Hi Heinrich,

On Fri, 25 Oct 2019 at 04:15, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> The ext4 file system requires log2blksz to be set. So when setting the
> block size on the block descriptor we should fill this field too.
>
> This fixes a problem with EFI block devices providing ext4 partitions, cf.
> https://lists.denx.de/pipermail/u-boot/2019-October/387702.html.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  drivers/block/blk-uclass.c | 1 +
>  1 file changed, 1 insertion(+)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

But I wonder if blk_create_device() should change to take log2blksz as
its parameter and calculate blksz?


> diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
> index e8f58b3f5e..ca8978f0e1 100644
> --- a/drivers/block/blk-uclass.c
> +++ b/drivers/block/blk-uclass.c
> @@ -580,6 +580,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
>         desc = dev_get_uclass_platdata(dev);
>         desc->if_type = if_type;
>         desc->blksz = blksz;
> +       desc->log2blksz = LOG2(desc->blksz);
>         desc->lba = lba;
>         desc->part_type = PART_TYPE_UNKNOWN;
>         desc->bdev = dev;
> --
> 2.23.0
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 1/1] blk: set log2blksz in blk_create_device()
  2019-10-30  1:49 ` Simon Glass
@ 2019-10-30  6:35   ` Heinrich Schuchardt
  0 siblings, 0 replies; 3+ messages in thread
From: Heinrich Schuchardt @ 2019-10-30  6:35 UTC (permalink / raw)
  To: u-boot

On 10/30/19 2:49 AM, Simon Glass wrote:
> Hi Heinrich,
>
> On Fri, 25 Oct 2019 at 04:15, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>
>> The ext4 file system requires log2blksz to be set. So when setting the
>> block size on the block descriptor we should fill this field too.
>>
>> This fixes a problem with EFI block devices providing ext4 partitions, cf.
>> https://lists.denx.de/pipermail/u-boot/2019-October/387702.html.
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> ---
>>   drivers/block/blk-uclass.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> But I wonder if blk_create_device() should change to take log2blksz as
> its parameter and calculate blksz?

CD-ROM mode 2 has 2336 data bytes,
CD-ROM XA Mode 2, Form 2 has 2324 data bytes
according to https://en.wikipedia.org/wiki/CD-ROM.

So we cannot assume that blksz is a power of two in the general case.

LOG2() is behaving a bit erratically for numbers that are not a power of
two (in contrast to what ilog2() does):

LOG2(2048) = 11
LOG2(2049) = 11
LOG2(2324) = 15
LOG2(2336) = 15
LOG2(3072) = 11
LOG2(4096) = 12

ilog2(2048) = 11
ilog2(2049) = 11
ilog2(2324) = 11
ilog2(2336) = 11
ilog2(3072) = 11
ilog2(4096) = 12

But if we ever add an ISO 9660 file system driver, we will not be able
to use log2blksz anyway. So I think we can stick with LOG2().

Best regards

Heinrich

>
>
>> diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
>> index e8f58b3f5e..ca8978f0e1 100644
>> --- a/drivers/block/blk-uclass.c
>> +++ b/drivers/block/blk-uclass.c
>> @@ -580,6 +580,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
>>          desc = dev_get_uclass_platdata(dev);
>>          desc->if_type = if_type;
>>          desc->blksz = blksz;
>> +       desc->log2blksz = LOG2(desc->blksz);
>>          desc->lba = lba;
>>          desc->part_type = PART_TYPE_UNKNOWN;
>>          desc->bdev = dev;
>> --
>> 2.23.0
>>
>
> Regards,
> Simon
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-30  6:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25 10:15 [U-Boot] [PATCH 1/1] blk: set log2blksz in blk_create_device() Heinrich Schuchardt
2019-10-30  1:49 ` Simon Glass
2019-10-30  6:35   ` Heinrich Schuchardt

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.