[U-Boot] [RFC] disk: part_dos: Fix part_test_dos() regression

Fabio Estevam festevam at gmail.com
Tue Oct 3 11:04:28 UTC 2017


On Tue, Oct 3, 2017 at 7:57 AM, Rob Clark <robdclark at gmail.com> wrote:

> btw, if I had to take a guess, I'd say that perhaps blksz is smaller
> than 'legacy_mbr', so maybe rather than allocating blksize, it should
> be DIV_ROUND_UP(sizeof(legacy_mbr), dev_desc->blksz).. or I guess that
> could be simplified to not use division if blksz is a power of two

Yes, it does seem to be size related as we are size constraint in SPL.

Just tried your suggestion:

--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -89,7 +89,9 @@ static int test_block_type(unsigned char *buffer)

 static int part_test_dos(struct blk_desc *dev_desc)
 {
-       ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, dev_desc->blksz);
+       ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr,
+                                DIV_ROUND_UP(sizeof(legacy_mbr),
+                                dev_desc->blksz));

        if (blk_dread(dev_desc, 0, 1, (ulong *)mbr) != 1)
                return -1;

and it does work for me :-)


More information about the U-Boot mailing list