devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frank Rowand <frowand.list@gmail.com>
To: Rob Herring <robh+dt@kernel.org>
Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>,
	Pantelis Antoniou <panto@antoniou-consulting.com>,
	devicetree@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Subject: Re: [PATCH v4 1/4] of: change overlay apply input data from unflattened to FDT
Date: Thu, 1 Mar 2018 15:38:18 -0800	[thread overview]
Message-ID: <b627b147-b8b6-a6a6-35bb-b02e46879313@gmail.com> (raw)
In-Reply-To: <53b47afa-f7df-777a-6a96-d0b986a389fb@gmail.com>

On 03/01/18 14:36, Frank Rowand wrote:
> On 03/01/18 13:02, Rob Herring wrote:
>> On Thu, Mar 1, 2018 at 12:00 PM,  <frowand.list@gmail.com> wrote:
>>> From: Frank Rowand <frank.rowand@sony.com>
>>>
>>> Move duplicating and unflattening of an overlay flattened devicetree
>>> (FDT) into the overlay application code.  To accomplish this,
>>> of_overlay_apply() is replaced by of_overlay_fdt_apply().
>>>
>>> The copy of the FDT (aka "duplicate FDT") now belongs to devicetree
>>> code, which is thus responsible for freeing the duplicate FDT.  The
>>> caller of of_overlay_fdt_apply() remains responsible for freeing the
>>> original FDT.
>>>
>>> The unflattened devicetree now belongs to devicetree code, which is
>>> thus responsible for freeing the unflattened devicetree.
>>>
>>> These ownership changes prevent early freeing of the duplicated FDT
>>> or the unflattened devicetree, which could result in use after free
>>> errors.
>>>
>>> of_overlay_fdt_apply() is a private function for the anticipated
>>> overlay loader.
>>>
>>> Update unittest.c to use of_overlay_fdt_apply() instead of
>>> of_overlay_apply().
>>>
>>> Move overlay fragments from artificial locations in
>>> drivers/of/unittest-data/tests-overlay.dtsi into one devicetree
>>> source file per overlay.  This led to changes in
>>> drivers/of/unitest-data/Makefile and drivers/of/unitest.c.
>>>
>>>   - Add overlay directives to the overlay devicetree source files so
>>>     that dtc will compile them as true overlays into one FDT data
>>>     chunk per overlay.
>>>
>>>   - Set CFLAGS for drivers/of/unittest-data/testcases.dts so that
>>>     symbols will be generated for overlay resolution of overlays
>>>     that are no longer artificially contained in testcases.dts
>>>
>>>   - Unflatten and apply each unittest overlay FDT using
>>>     of_overlay_fdt_apply().
>>>
>>>   - Enable the of_resolve_phandles() check for whether the unflattened
>>>     overlay is detached.  This check was previously disabled because the
>>>     overlays from tests-overlay.dtsi were not unflattened into detached
>>>     trees.
>>>
>>>   - Other changes to unittest.c infrastructure to manage multiple test
>>>     FDTs built into the kernel image (access by name instead of
>>>     arbitrary number).
>>>
>>>   - of_unittest_overlay_high_level(): previously unused code to add
>>>     properties from the overlay_base devicetree to the live tree
>>>     was triggered by the restructuring of tests-overlay.dtsi and thus
>>>     testcases.dts.  This exposed two bugs: (1) the need to dup a
>>>     property before adding it, and (2) property 'name' is
>>>     auto-generated in the unflatten code and thus will be a duplicate
>>>     in the __symbols__ node - do not treat this duplicate as an error.
>>>
>>> Signed-off-by: Frank Rowand <frank.rowand@sony.com>
>>> ---

< snip >

>>> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
>>> index 7a9abaae874d..2d706039ac96 100644
>>> --- a/drivers/of/unittest.c
>>> +++ b/drivers/of/unittest.c

< snip >

>>> @@ -1263,25 +1264,19 @@ static void of_unittest_destroy_tracked_overlays(void)
>>>         } while (defers > 0);
>>>  }
>>>
>>> -static int of_unittest_apply_overlay(int overlay_nr, int unittest_nr,
>>> +static int __init of_unittest_apply_overlay(int overlay_nr, int unittest_nr,
>>>                 int *overlay_id)
>>
>> Why __init? Really, we want to move towards building the unittests as
>> a module and we don't want __init for that. Though maybe __init is a
>> nop for modules, I don't remember offhand.
> 
> It has to be a nop for modules.
> 
> __init makes sense when the unittests are an initcall.
> 
> 
>> In any case, seems like a separate change.
> 
> Correct.  It was a gratuitous clean up when I was making other changes
> to the function.  I'll remove it from this series.

Now I remember, after trying to remove the __init.  I get a modpost warning
when I build the kernel.

Before the patches, the old overlay tests did not apply the overlays from
overlay FDTs.  Instead the overlay fragment nodes were hand coded into
the testcases dts, and the overlay apply code just grabbed the fragment
nodes from the live testcases tree and called the overlay code to apply
the fragment nodes.

With the new FDT based overlay API, I was able to make the test overlays
actual overlay dts files and dtbs. This change involved changing
of_unittest_apply_overlay() to no longer call of_overlay_apply() (which
passed in a pointer to a node from the live testcases tree), but
instead call overlay_data_apply() (which handles finding the requested
fdt and applies it).  overlay_data_apply() is already an __init() function.

There are a few more functions that I would expect modpost to warn
about, but it does not.

> There is a mix of some functions being marked __init and some not,
> so that will be worth another patch someday.
> 
> 
>>
>> Rob
>>
> 
> 

  reply	other threads:[~2018-03-01 23:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-01 18:00 [PATCH v4 0/4] of: change overlay apply input data from unflattened frowand.list
2018-03-01 18:00 ` [PATCH v4 1/4] of: change overlay apply input data from unflattened to FDT frowand.list
2018-03-01 20:59   ` Laurent Pinchart
2018-03-01 21:13     ` Laurent Pinchart
2018-03-01 21:29     ` Frank Rowand
2018-03-01 21:02   ` Rob Herring
2018-03-01 22:36     ` Frank Rowand
2018-03-01 23:38       ` Frank Rowand [this message]
2018-03-01 18:00 ` [PATCH v4 2/4] of: Documentation: of_overlay_apply() replaced by of_overlay_fdt_apply() frowand.list
2018-03-01 18:00 ` [PATCH v4 3/4] of: convert unittest overlay devicetree source to sugar syntax frowand.list
2018-03-01 18:00 ` [PATCH v4 4/4] of: improve reporting invalid overlay target path frowand.list
2018-03-01 21:08 ` [PATCH v4 0/4] of: change overlay apply input data from unflattened Laurent Pinchart

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=b627b147-b8b6-a6a6-35bb-b02e46879313@gmail.com \
    --to=frowand.list@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pantelis.antoniou@konsulko.com \
    --cc=panto@antoniou-consulting.com \
    --cc=robh+dt@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).