[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220118142013.GA556@axis.com>
Date: Tue, 18 Jan 2022 15:20:13 +0100
From: Vincent Whitchurch <vincent.whitchurch@...s.com>
To: Rob Herring <robh@...nel.org>
CC: "jdike@...toit.com" <jdike@...toit.com>,
"richard@....at" <richard@....at>,
"anton.ivanov@...bridgegreys.com" <anton.ivanov@...bridgegreys.com>,
kernel <kernel@...s.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-um@...ts.infradead.org" <linux-um@...ts.infradead.org>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>
Subject: Re: [PATCH 2/2] um: Add devicetree support
On Fri, Jan 14, 2022 at 02:49:09PM +0100, Rob Herring wrote:
> On Wed, Dec 08, 2021 at 04:11:23PM +0100, Vincent Whitchurch wrote:
> > --- /dev/null
> > +++ b/arch/um/kernel/dtb.c
> > @@ -0,0 +1,41 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +
> > +#include <linux/init.h>
> > +#include <linux/of_fdt.h>
> > +#include <linux/printk.h>
> > +#include <linux/memblock.h>
> > +#include <init.h>
> > +
> > +#include "um_arch.h"
> > +
> > +static char *dtb __initdata;
> > +
> > +void uml_dtb_init(void)
> > +{
> > + long long size;
> > + void *area;
> > +
> > + area = uml_load_file(dtb, &size);
> > + if (!area)
> > + return;
> > +
> > + if (!early_init_dt_scan(area)) {
> > + pr_err("invalid DTB %s\n", dtb);
> > + memblock_free(area, size);
> > + return;
> > + }
> > +
> > + unflatten_device_tree();
> > + early_init_fdt_scan_reserved_mem();
>
> These should be reversed. early_init_fdt_scan_reserved_mem() works on
> the flat tree. Reserved memory needs to be reserved before
> unflatten_device_tree() starts allocating memory. Though I imagine that
> doesn't really matter for UML.
I only tested dynamic allocation of reserved memory, and that,
unsuprisingly, works regardless of the order. But I'll send a patch to
change it.
> Also, does the dtb end up in permanently allocated memory (i.e. not
> init)? It needs to be if not.
The dtb is allocated with memblock_alloc() in arch/um/kernel/load_file.c
and is never freed (except on an error from early_init_dt_scan() as in
the above hunk), so I think this is already taken care of.
Powered by blists - more mailing lists