All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Geert Uytterhoeven <geert@linux-m68k.org>,
	Rob Herring <rob.herring@calxeda.com>
Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/9] dt: Handle passed/built-in DT selection in early_init_dt_scan()
Date: Thu, 21 Nov 2013 12:33:26 +0000	[thread overview]
Message-ID: <CACxGe6vfREzoMEc6GH1XUJK9ino1-mX38p85GGxMyFQbq-w6Fg@mail.gmail.com> (raw)
In-Reply-To: <CACxGe6uanzatY-CB-X6vgapYmy168F5M_Qy8rXZZ+o78LjgFXw@mail.gmail.com>

On Thu, Nov 21, 2013 at 12:23 PM, Grant Likely
<grant.likely@secretlab.ca> wrote:
> On Thu, Nov 21, 2013 at 12:21 PM, Grant Likely
> <grant.likely@secretlab.ca> wrote:
>> On Tue, 19 Nov 2013 12:12:26 +0100, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>>> Let early_init_dt_scan() fall-back to the built-in DT if no DT was passed,
>>> or if it's invalid, so architectures don't have to duplicate this logic.
>>>
>>> Suggested-by: Rob Herring <rob.herring@calxeda.com>
>>> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
>>> ---
>>>  drivers/of/fdt.c       |   24 +++++++++++++++++-------
>>>  include/linux/of_fdt.h |    1 +
>>>  2 files changed, 18 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>>> index 2fa024b97c43..a797cd43bc8b 100644
>>> --- a/drivers/of/fdt.c
>>> +++ b/drivers/of/fdt.c
>>> @@ -868,18 +868,28 @@ void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align)
>>>
>>>  bool __init early_init_dt_scan(void *params)
>>>  {
>>> -     if (!params)
>>> -             return false;
>>> -
>>>       /* Setup flat device-tree pointer */
>>>       initial_boot_params = params;
>>>
>>> -     /* check device tree validity */
>>> -     if (be32_to_cpu(initial_boot_params->magic) != OF_DT_HEADER) {
>>> -             initial_boot_params = NULL;
>>> -             return false;
>>> +     /* check passed device tree validity */
>>> +     if (initial_boot_params &&
>>> +         be32_to_cpu(initial_boot_params->magic) == OF_DT_HEADER) {
>>> +             pr_info("FDT at %p\n", initial_boot_params);
>>> +             goto found;
>>> +     }
>>> +
>>> +     /* check built-in device tree validity */
>>> +     initial_boot_params = &__dtb_start;
>>> +     if (__dtb_end != (void *)&__dtb_start &&
>>> +         be32_to_cpu(initial_boot_params->magic) == OF_DT_HEADER) {
>>> +             pr_info("Compiled-in FDT at %p\n", initial_boot_params);
>>> +             goto found;
>>
>> __dtb_start is in an init section which is discarded after initcalls.
>> For this to work, the dtb needs to be copied into a region of allocated
>> memory. The dtb section can also potentially contain multiple .dtb
>> blobs. In the use case that you care about you are probably only
>> thinking about one, but it is entirely possible for device drivers to
>> have a dtb linked in which may break this if it gets linked in a
>> different order. The specific example I'm thinking about is I want to
>> have the DT selftest code load an overlay to get testcase data from a
>> dtb blob.
>>
>> The other concern I have here is that I don't really want this to be the
>> default on a lot of platforms. ARM and PowerPC for instance should only
>> get the default dtb from the boot wrapper. It needs to be configurable
>> in some way.
>>
>> Instead of using __dtb_start, it would probably solve both of the above
>> problems if the build-in DTB has a specific label identifying it as the
>> default DT.
>
> Er, not quite. It still doesn't solve the init section discard
> problem. That still needs solving.

Okay, I've got one more comment on this. I know that some
architectures use unflatten_and_copy_devicetree() to sort out the dtb
copy problem. My point here is that for this to become generic code
then early_init_dt_scan() needs to grow the ability to differentiate
between a DT that needs to be copied (built in) vs. a DT that is
already in safe memory. The contents of
unflatten_and_copy_devicetree() could even be rolled into
unflatten_devicetree() if there is a common way to indicate whether or
not the DT needs to be copied that early_init_dt_scan() can
manipulate. ie. a global flag.

g.

  reply	other threads:[~2013-11-21 12:33 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-12 19:42 [PATCH 00/17] <asm/sections.h> related cleanups Geert Uytterhoeven
2013-11-12 19:42 ` [PATCH 01/17] alpha: Use Kbuild logic to include <asm-generic/sections.h> Geert Uytterhoeven
2013-11-12 21:23   ` Richard Henderson
2013-11-12 19:42 ` [PATCH 02/17] cris: " Geert Uytterhoeven
2013-11-15 16:52   ` Jesper Nilsson
2013-11-12 19:42 ` [PATCH 03/17] m32r: " Geert Uytterhoeven
2013-11-12 19:42 ` [PATCH 04/17] mn10300: " Geert Uytterhoeven
2013-11-12 19:42 ` [PATCH 05/17] score: " Geert Uytterhoeven
2013-11-15 18:05   ` Lennox Wu
2013-11-12 19:42 ` [PATCH 06/17] frv: Remove unused declarations of __start___ex_table and __stop___ex_table Geert Uytterhoeven
2013-11-12 19:42 ` [PATCH 07/17] ia64: Remove duplicate declarations of __per_cpu_start[] and __per_cpu_end[] Geert Uytterhoeven
2013-11-12 19:42   ` Geert Uytterhoeven
2013-11-12 19:42 ` [PATCH 08/17] microblaze: Remove _fdt_start casts Geert Uytterhoeven
2013-11-12 19:42   ` Geert Uytterhoeven
2013-11-13 10:08   ` Michal Simek
2013-11-12 19:42 ` [PATCH 09/17] microblaze: Remove duplicate declarations of _stext[] and _etext[] Geert Uytterhoeven
2013-11-12 19:42   ` Geert Uytterhoeven
2013-11-12 19:42 ` [PATCH 10/17] tile: Remove tile-specific _sinitdata and _einitdata Geert Uytterhoeven
2013-11-14  0:09   ` Chris Metcalf
2013-11-14  0:09     ` Chris Metcalf
2013-11-14  8:31     ` Geert Uytterhoeven
2013-11-14  8:31       ` Geert Uytterhoeven
2013-11-14 14:55       ` Chris Metcalf
2013-11-14 14:55         ` Chris Metcalf
2014-07-09 18:33         ` Geert Uytterhoeven
2014-07-10 19:49           ` Chris Metcalf
2014-07-10 20:14             ` Geert Uytterhoeven
2013-11-12 19:42 ` [PATCH 11/17] kernel/param: Consolidate __{start,stop}___param[] in <linux/moduleparam.h> Geert Uytterhoeven
2013-11-14  4:01   ` Rusty Russell
2013-11-14  4:01     ` Rusty Russell
2013-11-14  4:01     ` Rusty Russell
2013-11-12 19:42 ` [PATCH 12/17] nosave: Consolidate __nosave_{begin,end} in <asm/sections.h> Geert Uytterhoeven
2013-11-12 19:42 ` [PATCH 13/17] openrisc: Refactor or32_early_setup() Geert Uytterhoeven
2013-11-12 19:42   ` Geert Uytterhoeven
2013-11-12 19:42   ` Geert Uytterhoeven
2013-11-15  9:59   ` Jonas Bonn
2013-11-15  9:59     ` Jonas Bonn
2013-11-15  9:59     ` Jonas Bonn
2013-11-12 19:42 ` [PATCH 14/17] dt: Consolidate __dtb_start declarations in <linux/of_fdt.h> Geert Uytterhoeven
2013-11-13  5:41   ` Vineet Gupta
2013-11-13  5:41     ` Vineet Gupta
2013-11-13 15:51   ` Rob Herring
2013-11-13 15:51     ` Rob Herring
     [not found]     ` < 1384859554-27268-1-git-send-email-geert@linux-m68k.org>
     [not found]       ` <20131121122148. 1B43DC40A2C@trevor.secretlab.ca>
     [not found]         ` < CAMuHMdXfsB_Ewz9sUPZaAjFaQGTGeqMiD8mJ0tCoH1uFLYGoxw@mail.gmail.com>
     [not found]           ` < CAL_JsqJVteJuaD0PRMHSR9cVcMJTSNj4wXtYiftG=-pYSR9vsQ@mail.gmail.com>
     [not found]           ` < 20131121155348.66751C406A3@trevor.secretlab.ca>
2013-11-13 17:20     ` Geert Uytterhoeven
2013-11-13 17:34       ` Rob Herring
2013-11-13 18:40         ` Geert Uytterhoeven
2013-11-19 11:12     ` [PATCH 1/9] dt: Handle passed/built-in DT selection in early_init_dt_scan() Geert Uytterhoeven
2013-11-19 11:12       ` Geert Uytterhoeven
2013-11-19 11:12       ` [PATCH 2/9] arc: Use NULL as the default DTB Geert Uytterhoeven
2013-11-20  4:58         ` Vineet Gupta
2013-11-19 11:12       ` [PATCH 3/9] c6x: Remove duplicate DT selection logic Geert Uytterhoeven
2013-11-19 11:12       ` [PATCH 4/9] metag: " Geert Uytterhoeven
2013-11-19 11:12         ` Geert Uytterhoeven
2013-11-19 13:14         ` James Hogan
2013-11-19 13:14           ` James Hogan
2013-11-19 13:14           ` James Hogan
2013-11-19 11:12       ` [PATCH 5/9] microblaze: Use NULL as the default DTB Geert Uytterhoeven
2013-11-19 11:12         ` Geert Uytterhoeven
2013-11-19 11:12       ` [PATCH 6/9] mips: Remove unused dt_setup_arch() Geert Uytterhoeven
2013-11-19 11:12       ` [PATCH 7/9] mips: Use NULL as the default DTB Geert Uytterhoeven
2013-11-19 11:12       ` [PATCH 8/9] openrisc: Remove duplicate DT selection logic Geert Uytterhoeven
2013-11-19 11:12         ` Geert Uytterhoeven
2013-11-19 11:12       ` [PATCH 9/9] xtensa: Use NULL as the default DTB Geert Uytterhoeven
2013-11-19 13:27       ` [PATCH 1/9] dt: Handle passed/built-in DT selection in early_init_dt_scan() James Hogan
2013-11-19 13:27         ` James Hogan
2013-11-20 20:50       ` Rob Herring
2013-11-21 12:21       ` Grant Likely
2013-11-21 12:21         ` Grant Likely
2013-11-21 12:21         ` Grant Likely
2013-11-21 12:23         ` Grant Likely
2013-11-21 12:33           ` Grant Likely [this message]
2013-11-21 13:42         ` Geert Uytterhoeven
2013-11-21 15:53           ` Grant Likely
2013-11-21 17:49             ` Geert Uytterhoeven
2013-11-27 15:32               ` Grant Likely
2013-11-27 15:32                 ` Grant Likely
2013-11-21 17:38           ` Rob Herring
2013-11-21 17:38             ` Rob Herring
2013-11-21 17:42             ` Geert Uytterhoeven
2013-11-27 15:35               ` Grant Likely
2013-11-19 13:24   ` [PATCH 14/17] dt: Consolidate __dtb_start declarations in <linux/of_fdt.h> James Hogan
2013-11-19 13:24     ` James Hogan
2013-11-19 13:24     ` James Hogan
2013-11-12 19:42 ` [PATCH RFC 15/17] microblaze: Convert from _fdt_start to __dtb_start Geert Uytterhoeven
2013-11-12 19:42   ` Geert Uytterhoeven
2013-11-13 10:19   ` Michal Simek
2013-11-13 13:40     ` Michal Simek
2013-11-13 14:02       ` Geert Uytterhoeven
2013-11-13 14:21         ` Michal Simek
2013-11-13 16:14       ` Rob Herring
2013-11-14 16:29         ` Michal Simek
2013-11-12 19:42 ` [PATCH RFC 16/17] c6x: " Geert Uytterhoeven
2013-11-12 23:38   ` Mark Salter
2013-11-12 23:38     ` Mark Salter
2013-11-12 19:42 ` [PATCH 17/17] um: Remove unused declarations from <as-layout.h> Geert Uytterhoeven
2013-11-12 19:51   ` Richard Weinberger
2013-11-12 19:52     ` Geert Uytterhoeven
2013-11-12 19:54 ` [PATCH 00/17] <asm/sections.h> related cleanups Geert Uytterhoeven
2013-11-12 19:54   ` Geert Uytterhoeven
2013-11-12 19:56 ` [PATCH 1/2] openrisc: Use the declarations provided by <asm/sections.h> Geert Uytterhoeven
2013-11-12 19:56   ` Geert Uytterhoeven
2013-11-12 19:56   ` Geert Uytterhoeven
2013-11-12 19:56   ` [PATCH 2/2] openrisc: Remove unused declaration of __initramfs_start Geert Uytterhoeven
2013-11-12 19:56     ` Geert Uytterhoeven
2013-11-12 19:56     ` Geert Uytterhoeven
2013-11-13  5:25 ` [PATCH 00/17] <asm/sections.h> related cleanups Vineet Gupta
2013-11-13  5:25   ` Vineet Gupta
2013-11-20 18:55 ` [PATCH 06/17] frv: Remove unused declarations of __start___ex_table and __stop___ex_table David Howells
2013-11-20 18:56 ` [PATCH 04/17] mn10300: Use Kbuild logic to include <asm-generic/sections.h> David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACxGe6vfREzoMEc6GH1XUJK9ino1-mX38p85GGxMyFQbq-w6Fg@mail.gmail.com \
    --to=grant.likely@secretlab.ca \
    --cc=devicetree@vger.kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rob.herring@calxeda.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.