From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Reding Date: Tue, 30 Jan 2018 13:09:06 +0100 Subject: [U-Boot] [PATCH] fdt: Fixup only valid memory banks In-Reply-To: <20180130124115.24d0d2fe@karo-electronics.de> References: <20180130103417.4815-1-thierry.reding@gmail.com> <20180130124115.24d0d2fe@karo-electronics.de> Message-ID: <20180130120906.GA14576@ulmo> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de On Tue, Jan 30, 2018 at 12:41:15PM +0100, Lothar Wa=C3=9Fmann wrote: > Hi, >=20 > On Tue, 30 Jan 2018 11:34:17 +0100 Thierry Reding wrote: > > From: Thierry Reding > >=20 > > Memory banks with address 0 and size 0 are empty and should not be > > passed to the OS via device tree. > >=20 > > Signed-off-by: Thierry Reding > > --- > > common/fdt_support.c | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > >=20 > > diff --git a/common/fdt_support.c b/common/fdt_support.c > > index 724452d75452..8b33f6773d27 100644 > > --- a/common/fdt_support.c > > +++ b/common/fdt_support.c > > @@ -457,7 +457,7 @@ int fdt_record_loadable(void *blob, u32 index, cons= t char *name, > > int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int ba= nks) > > { > > int err, nodeoffset; > > - int len; > > + int len, i; > > u8 tmp[MEMORY_BANKS_MAX * 16]; /* Up to 64-bit address + 64-bit size = */ > > =20 > > if (banks > MEMORY_BANKS_MAX) { > > @@ -489,6 +489,12 @@ int fdt_fixup_memory_banks(void *blob, u64 start[]= , u64 size[], int banks) > > if (!banks) > > return 0; > > =20 > > + for (i =3D 0; i < banks; i++) > > + if (start[i] =3D=3D 0 && size[i] =3D=3D 0) > > + break; > > + > > + banks =3D i; > > + > > len =3D fdt_pack_reg(blob, tmp, start, size, banks); > > =20 > > err =3D fdt_setprop(blob, nodeoffset, "reg", tmp, len); > > > Does an empty bank always imply the end of the list, or > Is it a valid scenario to have intervening empty banks? I think it's a fair assumption that there aren't going to be any holes. The vast majority of boards will only every initialize a single bank or perhaps two. There's a few odd ones (hisilicon/hikey for example) that adds more, but they are still all contiguous. Thierry -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: