[U-Boot] mtd partitions go away
Heiko Schocher
hs at denx.de
Fri Nov 16 06:09:51 UTC 2018
Hello Boris,
Am 15.11.2018 um 17:47 schrieb Boris Brezillon:
> On Thu, 15 Nov 2018 16:15:51 +0100
> Boris Brezillon <boris.brezillon at bootlin.com> wrote:
>
>> Hi Heiko,
>>
>> On Thu, 15 Nov 2018 15:21:31 +0100
>> Boris Brezillon <boris.brezillon at bootlin.com> wrote:
>>
>>>
>>> Looks like spi_flash_mtd_register() is doing something really bad here
>>> [1]: memsetting the global sf_mtd_info object without testing if
>>> this object has already been registered, and then registering it again
>>> to the MTD layer. So any partition that had been attached to the mtd
>>> object through mtd_probe_devices() are lost, and mtdparts/mtdids are not
>>> parsed again because they haven't changed since the last time
>>> mtd_probe_devices() was called.
>>>
>>> [1]https://elixir.bootlin.com/u-boot/v2018.11/source/drivers/mtd/spi/sf_mtd.c#L76
>>
>> Can you try with the following diff applied?
>
> If the previous diff did not fix your problem, you can try this one
>
> --->8---
> diff --git a/drivers/mtd/mtd_uboot.c b/drivers/mtd/mtd_uboot.c
> index 5ca560c96879..af5ad25cc37a 100644
> --- a/drivers/mtd/mtd_uboot.c
> +++ b/drivers/mtd/mtd_uboot.c
> @@ -164,6 +164,7 @@ int mtd_probe_devices(void)
> /* Check if mtdparts/mtdids changed since last call, otherwise: exit */
> if ((!mtdparts && !old_mtdparts && !mtdids && !old_mtdids) ||
> (mtdparts && old_mtdparts && mtdids && old_mtdids &&
> + !mtd_dev_list_updated() &&
> !strcmp(mtdparts, old_mtdparts) &&
> !strcmp(mtdids, old_mtdids)))
> return 0;
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index fb6c779abbfe..7a15ded8c883 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -87,14 +87,17 @@ struct idr_layer {
>
> struct idr {
> struct idr_layer id[MAX_IDR_ID];
> + bool updated;
> };
>
> #define DEFINE_IDR(name) struct idr name;
>
> void idr_remove(struct idr *idp, int id)
> {
> - if (idp->id[id].used)
> + if (idp->id[id].used) {
> idp->id[id].used = 0;
> + idp->updated = true;
> + }
>
> return;
> }
> @@ -134,6 +137,7 @@ int idr_alloc(struct idr *idp, void *ptr, int start, int end, gfp_t gfp_mask)
> if (idl->used == 0) {
> idl->used = 1;
> idl->ptr = ptr;
> + idp->updated = true;
> return i;
> }
> i++;
> @@ -155,6 +159,16 @@ struct mtd_info *__mtd_next_device(int i)
> }
> EXPORT_SYMBOL_GPL(__mtd_next_device);
>
> +bool mtd_dev_list_updated(void)
> +{
> + if (mtd_idr.updated) {
> + mtd_idr.updated = false;
> + return true;
> + }
> +
> + return false;
> +}
> +
> #ifndef __UBOOT__
> static LIST_HEAD(mtd_notifiers);
>
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index 68e591532492..d20ebd820289 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -581,6 +581,7 @@ int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off,
> void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
> const uint64_t length, uint64_t *len_incl_bad,
> int *truncated);
> +bool mtd_dev_list_updated(void);
>
> /* drivers/mtd/mtd_uboot.c */
> int mtd_search_alternate_name(const char *mtdname, char *altname,
>
This does fix "mtd list"
=> mtd list
List of MTD devices:
* nand0
- type: NAND flash
- block size: 0x20000 bytes
- min I/O: 0x800 bytes
- OOB size: 64 bytes
- OOB available: 0 bytes
- ECC strength: 8 bits
- ECC step size: 512 bytes
- bitflip threshold: 6 bits
- 0x000000000000-0x000008000000 : "nand0"
- 0x000000000000-0x000008000000 : "ubi"
* nor0
- type: NOR flash
- block size: 0x10000 bytes
- min I/O: 0x1 bytes
- 0x000000000000-0x000000800000 : "nor0"
- 0x000000000000-0x000000010000 : "spl"
- 0x000000010000-0x0000000d0000 : "u-boot"
- 0x0000000d0000-0x0000000e0000 : "env"
- 0x0000000e0000-0x0000000f0000 : "env-red"
- 0x0000000f0000-0x000000800000 : "rescue"
=> sf probe
SF: Detected s25f064l with page size 256 Bytes, erase size 64 KiB, total 8 MiB
=> mtd list
List of MTD devices:
* nand0
- type: NAND flash
- block size: 0x20000 bytes
- min I/O: 0x800 bytes
- OOB size: 64 bytes
- OOB available: 0 bytes
- ECC strength: 8 bits
- ECC step size: 512 bytes
- bitflip threshold: 6 bits
- 0x000000000000-0x000008000000 : "nand0"
- 0x000000000000-0x000008000000 : "ubi"
* nor0
- type: NOR flash
- block size: 0x10000 bytes
- min I/O: 0x1 bytes
- 0x000000000000-0x000000800000 : "nor0"
- 0x000000000000-0x000000010000 : "spl"
- 0x000000010000-0x0000000d0000 : "u-boot"
- 0x0000000d0000-0x0000000e0000 : "env"
- 0x0000000e0000-0x0000000f0000 : "env-red"
- 0x0000000f0000-0x000000800000 : "rescue"
But problem with "ubi part" remains:
=> ubi part ubi
Partition ubi not found!
=>
Thanks for your help. I try to find time, to dig also into it, but
may only next week ...
bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
More information about the U-Boot
mailing list