* [PATCH 1/1] mtd: mtdpart: Support MTD_SIZE_REMAINING with unallocated memory area
@ 2025-02-20 14:58 Alexander Stein
2025-02-28 20:23 ` Tom Rini
2025-04-22 10:37 ` [REGRESSION] " Francesco Dolcini
0 siblings, 2 replies; 6+ messages in thread
From: Alexander Stein @ 2025-02-20 14:58 UTC (permalink / raw)
To: u-boot; +Cc: Alexander Stein
If there is an unallocated memory area before the last, filling parting
the size calculation for MTD_SIZE_REMAINING does not take this hole
into account.
Fix this by calculating the remaining size just based on total size
and partition offset.
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
drivers/mtd/mtdpart.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 4886392a1cf..4bc0960bb3c 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -207,7 +207,7 @@ int mtd_parse_partitions(struct mtd_info *parent, const char **_mtdparts,
{
struct mtd_partition partition = {}, *parts;
const char *mtdparts = *_mtdparts;
- uint64_t cur_off = 0, cur_sz = 0;
+ uint64_t cur_off = 0;
int nparts = 0;
int ret, idx;
u64 sz;
@@ -236,8 +236,7 @@ int mtd_parse_partitions(struct mtd_info *parent, const char **_mtdparts,
return ret;
if (parts[idx].size == MTD_SIZE_REMAINING)
- parts[idx].size = parent->size - cur_sz;
- cur_sz += parts[idx].size;
+ parts[idx].size = parent->size - parts[idx].offset;
sz = parts[idx].size;
if (sz < parent->writesize || do_div(sz, parent->writesize)) {
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 1/1] mtd: mtdpart: Support MTD_SIZE_REMAINING with unallocated memory area
2025-02-20 14:58 [PATCH 1/1] mtd: mtdpart: Support MTD_SIZE_REMAINING with unallocated memory area Alexander Stein
@ 2025-02-28 20:23 ` Tom Rini
2025-04-22 10:37 ` [REGRESSION] " Francesco Dolcini
1 sibling, 0 replies; 6+ messages in thread
From: Tom Rini @ 2025-02-28 20:23 UTC (permalink / raw)
To: u-boot, Alexander Stein
On Thu, 20 Feb 2025 15:58:07 +0100, Alexander Stein wrote:
> If there is an unallocated memory area before the last, filling parting
> the size calculation for MTD_SIZE_REMAINING does not take this hole
> into account.
> Fix this by calculating the remaining size just based on total size
> and partition offset.
>
>
> [...]
Applied to u-boot/next, thanks!
--
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* [REGRESSION] [PATCH 1/1] mtd: mtdpart: Support MTD_SIZE_REMAINING with unallocated memory area
2025-02-20 14:58 [PATCH 1/1] mtd: mtdpart: Support MTD_SIZE_REMAINING with unallocated memory area Alexander Stein
2025-02-28 20:23 ` Tom Rini
@ 2025-04-22 10:37 ` Francesco Dolcini
2025-04-22 13:05 ` Alexander Stein
1 sibling, 1 reply; 6+ messages in thread
From: Francesco Dolcini @ 2025-04-22 10:37 UTC (permalink / raw)
To: Alexander Stein, Tom Rini; +Cc: u-boot
Hello Tom, Alexander
On Thu, Feb 20, 2025 at 03:58:07PM +0100, Alexander Stein wrote:
> If there is an unallocated memory area before the last, filling parting
> the size calculation for MTD_SIZE_REMAINING does not take this hole
> into account.
> Fix this by calculating the remaining size just based on total size
> and partition offset.
>
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
This change introduced a regression on colibri imx7 and imx6ull.
```
Booting from NAND...
Partition size must be a multiple of 2048
Could not parse device nand0
Failed parsing MTD partitions from mtdparts!
Partition ubi not found!
```
Reverting commit 1ca97ee90392 ("mtd: mtdpart: Support MTD_SIZE_REMAINING
with unallocated memory area") on top of current master fixes the issue.
Any suggestion? I have not looked at the code, I just did a git bisect.
Francesco
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [REGRESSION] [PATCH 1/1] mtd: mtdpart: Support MTD_SIZE_REMAINING with unallocated memory area
2025-04-22 10:37 ` [REGRESSION] " Francesco Dolcini
@ 2025-04-22 13:05 ` Alexander Stein
2025-04-22 13:07 ` Francesco Dolcini
0 siblings, 1 reply; 6+ messages in thread
From: Alexander Stein @ 2025-04-22 13:05 UTC (permalink / raw)
To: Tom Rini, Francesco Dolcini; +Cc: u-boot
Hi Francesco,
Am Dienstag, 22. April 2025, 12:37:32 CEST schrieb Francesco Dolcini:
> Hello Tom, Alexander
>
> On Thu, Feb 20, 2025 at 03:58:07PM +0100, Alexander Stein wrote:
> > If there is an unallocated memory area before the last, filling parting
> > the size calculation for MTD_SIZE_REMAINING does not take this hole
> > into account.
> > Fix this by calculating the remaining size just based on total size
> > and partition offset.
> >
> > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
>
> This change introduced a regression on colibri imx7 and imx6ull.
>
> ```
> Booting from NAND...
> Partition size must be a multiple of 2048
> Could not parse device nand0
> Failed parsing MTD partitions from mtdparts!
> Partition ubi not found!
> ```
>
> Reverting commit 1ca97ee90392 ("mtd: mtdpart: Support MTD_SIZE_REMAINING
> with unallocated memory area") on top of current master fixes the issue.
>
> Any suggestion? I have not looked at the code, I just did a git bisect.
How does your mtdparts look like?
Best regards
Alexander
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [REGRESSION] [PATCH 1/1] mtd: mtdpart: Support MTD_SIZE_REMAINING with unallocated memory area
2025-04-22 13:05 ` Alexander Stein
@ 2025-04-22 13:07 ` Francesco Dolcini
2025-04-25 3:31 ` Weijie Gao (高惟杰)
0 siblings, 1 reply; 6+ messages in thread
From: Francesco Dolcini @ 2025-04-22 13:07 UTC (permalink / raw)
To: Alexander Stein; +Cc: Tom Rini, Francesco Dolcini, u-boot
On Tue, Apr 22, 2025 at 03:05:58PM +0200, Alexander Stein wrote:
> Am Dienstag, 22. April 2025, 12:37:32 CEST schrieb Francesco Dolcini:
> > On Thu, Feb 20, 2025 at 03:58:07PM +0100, Alexander Stein wrote:
> > > If there is an unallocated memory area before the last, filling parting
> > > the size calculation for MTD_SIZE_REMAINING does not take this hole
> > > into account.
> > > Fix this by calculating the remaining size just based on total size
> > > and partition offset.
> > >
> > > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> >
> > This change introduced a regression on colibri imx7 and imx6ull.
> >
> > ```
> > Booting from NAND...
> > Partition size must be a multiple of 2048
> > Could not parse device nand0
> > Failed parsing MTD partitions from mtdparts!
> > Partition ubi not found!
> > ```
> >
> > Reverting commit 1ca97ee90392 ("mtd: mtdpart: Support MTD_SIZE_REMAINING
> > with unallocated memory area") on top of current master fixes the issue.
> >
> > Any suggestion? I have not looked at the code, I just did a git bisect.
>
> How does your mtdparts look like?
$ grep mtdparts configs/colibri_imx7_defconfig
CONFIG_MTDPARTS_DEFAULT="mtdparts=gpmi-nand:512k(mx7-bcb),1536k(u-boot1)ro,1536k(u-boot2)ro,512k(u-boot-env),-(ubi)"
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [REGRESSION] [PATCH 1/1] mtd: mtdpart: Support MTD_SIZE_REMAINING with unallocated memory area
2025-04-22 13:07 ` Francesco Dolcini
@ 2025-04-25 3:31 ` Weijie Gao (高惟杰)
0 siblings, 0 replies; 6+ messages in thread
From: Weijie Gao (高惟杰) @ 2025-04-25 3:31 UTC (permalink / raw)
To: francesco@dolcini.it, alexander.stein@ew.tq-group.com
Cc: trini@konsulko.com, u-boot@lists.denx.de
On Tue, 2025-04-22 at 15:07 +0200, Francesco Dolcini wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>
>
> On Tue, Apr 22, 2025 at 03:05:58PM +0200, Alexander Stein wrote:
> > Am Dienstag, 22. April 2025, 12:37:32 CEST schrieb Francesco
> > Dolcini:
> > > On Thu, Feb 20, 2025 at 03:58:07PM +0100, Alexander Stein wrote:
> > > > If there is an unallocated memory area before the last, filling
> > > > parting
> > > > the size calculation for MTD_SIZE_REMAINING does not take this
> > > > hole
> > > > into account.
> > > > Fix this by calculating the remaining size just based on total
> > > > size
> > > > and partition offset.
> > > >
> > > > Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com
> > > > >
> > >
> > > This change introduced a regression on colibri imx7 and imx6ull.
> > >
> > > ```
> > > Booting from NAND...
> > > Partition size must be a multiple of 2048
> > > Could not parse device nand0
> > > Failed parsing MTD partitions from mtdparts!
> > > Partition ubi not found!
> > > ```
> > >
> > > Reverting commit 1ca97ee90392 ("mtd: mtdpart: Support
> > > MTD_SIZE_REMAINING
> > > with unallocated memory area") on top of current master fixes the
> > > issue.
> > >
> > > Any suggestion? I have not looked at the code, I just did a git
> > > bisect.
> >
> > How does your mtdparts look like?
>
> $ grep mtdparts configs/colibri_imx7_defconfig
> CONFIG_MTDPARTS_DEFAULT="mtdparts=gpmi-nand:512k(mx7-bcb),1536k(u-
> boot1)ro,1536k(u-boot2)ro,512k(u-boot-env),-(ubi)"
>
I just reproduced this issue with a rather simple mtdparts:
mtdparts=2048k(bl2),-(ubi)
After printing some log, I beliebve this is caused by the mtd partition
offset value:
```
spi-nand: spi_nand spi_nand@0: 128 MiB, block size: 128 KiB, page size:
2048, OOB size: 64
parent->writesize = 0x800
parent->size = 0x8000000
parts[0]: name = bl2, offset = 0xffffffffffffffff, size = 0x200000
parts[1]: name = ubi, offset = 0xffffffffffffffff, size = 0x8000001
Partition size must be a multiple of 2048
Could not parse device spi-nand0
Failed parsing MTD partitions from mtdparts!
Partition ubi not found!
```
The mtd partition offset has not been updated when calculating the mtd
partition size:
```
if (parts[idx].size == MTD_SIZE_REMAINING)
parts[idx].size = parent->size -
parts[idx].offset;
```
It's also easy to solve: calculate the offset before calculating the
size
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-04-25 3:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-20 14:58 [PATCH 1/1] mtd: mtdpart: Support MTD_SIZE_REMAINING with unallocated memory area Alexander Stein
2025-02-28 20:23 ` Tom Rini
2025-04-22 10:37 ` [REGRESSION] " Francesco Dolcini
2025-04-22 13:05 ` Alexander Stein
2025-04-22 13:07 ` Francesco Dolcini
2025-04-25 3:31 ` Weijie Gao (高惟杰)
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.