Re: [PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-02-04 Thread Rob Herring
On Mon, Jan 29, 2018 at 04:01:38PM -0800, Frank Rowand wrote:
> On 01/29/18 06:42, Rob Herring wrote:
> > On Sun, Jan 28, 2018 at 8:53 PM,   wrote:
> >> From: Frank Rowand 
> >>
> >> 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 device tree (aka expanded device tree, EDT) now
> > 
> > Not really a fan of a new acronym.
> > 
> >> belongs to devicetree code, which is thus responsible for freeing
> >> the EDT.
> >>
> >> These ownership changes prevent early freeing of the duplicated FDT
> >> or the EDT, 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.
> 
> I should have reversed the cause and effect in that sentence to
> instead be:
> 
>   The changes to drivers/of/unittest.c require the test overlays
>   to be in FDT form instead of unflattened devicetree form.  Move
>   overlay fragments from artificial locations in
>   drivers/of/unittest-data/tests-overlay.dtsi into one
>   devicetree source file per overlay and thus create
>   one FDT per overlay.
> 
> 
> > Why the rearranging? That should be a separate patch.
> Bisectability.
> 
> I can make the changes to the devicetree files in a second patch.
> After the first patch, there will be 29 self test fails.
> 
> I will make the change unless you respond back to this saying not to.

One patch is fine for me. Unit test is special.

Rob


Re: [PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-02-04 Thread Rob Herring
On Mon, Jan 29, 2018 at 04:01:38PM -0800, Frank Rowand wrote:
> On 01/29/18 06:42, Rob Herring wrote:
> > On Sun, Jan 28, 2018 at 8:53 PM,   wrote:
> >> From: Frank Rowand 
> >>
> >> 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 device tree (aka expanded device tree, EDT) now
> > 
> > Not really a fan of a new acronym.
> > 
> >> belongs to devicetree code, which is thus responsible for freeing
> >> the EDT.
> >>
> >> These ownership changes prevent early freeing of the duplicated FDT
> >> or the EDT, 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.
> 
> I should have reversed the cause and effect in that sentence to
> instead be:
> 
>   The changes to drivers/of/unittest.c require the test overlays
>   to be in FDT form instead of unflattened devicetree form.  Move
>   overlay fragments from artificial locations in
>   drivers/of/unittest-data/tests-overlay.dtsi into one
>   devicetree source file per overlay and thus create
>   one FDT per overlay.
> 
> 
> > Why the rearranging? That should be a separate patch.
> Bisectability.
> 
> I can make the changes to the devicetree files in a second patch.
> After the first patch, there will be 29 self test fails.
> 
> I will make the change unless you respond back to this saying not to.

One patch is fine for me. Unit test is special.

Rob


Re: [PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-01-29 Thread Frank Rowand
On 01/29/18 07:05, Geert Uytterhoeven wrote:
> On Mon, Jan 29, 2018 at 3:42 PM, Rob Herring  wrote:
>> On Sun, Jan 28, 2018 at 8:53 PM,   wrote:
>>> From: Frank Rowand 
>>>
>>> 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 device tree (aka expanded device tree, EDT) now
>>
>> Not really a fan of a new acronym.
> 
> FWIW, it has already sneaked in:
> 
> $ git grep -w EDT -- drivers/of
> drivers/of/unittest.c:   * will create pointers to the passed in FDT in the 
> EDT.

Rob will be glad to know that this comment is removed by this patch series.

:-)


> Gr{oetje,eeting}s,
> 
> Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds
> 



Re: [PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-01-29 Thread Frank Rowand
On 01/29/18 07:05, Geert Uytterhoeven wrote:
> On Mon, Jan 29, 2018 at 3:42 PM, Rob Herring  wrote:
>> On Sun, Jan 28, 2018 at 8:53 PM,   wrote:
>>> From: Frank Rowand 
>>>
>>> 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 device tree (aka expanded device tree, EDT) now
>>
>> Not really a fan of a new acronym.
> 
> FWIW, it has already sneaked in:
> 
> $ git grep -w EDT -- drivers/of
> drivers/of/unittest.c:   * will create pointers to the passed in FDT in the 
> EDT.

Rob will be glad to know that this comment is removed by this patch series.

:-)


> Gr{oetje,eeting}s,
> 
> Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds
> 



Re: [PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-01-29 Thread Frank Rowand
On 01/29/18 06:42, Rob Herring wrote:
> On Sun, Jan 28, 2018 at 8:53 PM,   wrote:
>> From: Frank Rowand 
>>
>> 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 device tree (aka expanded device tree, EDT) now
> 
> Not really a fan of a new acronym.
> 
>> belongs to devicetree code, which is thus responsible for freeing
>> the EDT.
>>
>> These ownership changes prevent early freeing of the duplicated FDT
>> or the EDT, 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.

I should have reversed the cause and effect in that sentence to
instead be:

  The changes to drivers/of/unittest.c require the test overlays
  to be in FDT form instead of unflattened devicetree form.  Move
  overlay fragments from artificial locations in
  drivers/of/unittest-data/tests-overlay.dtsi into one
  devicetree source file per overlay and thus create
  one FDT per overlay.


> Why the rearranging? That should be a separate patch.
Bisectability.

I can make the changes to the devicetree files in a second patch.
After the first patch, there will be 29 self test fails.

I will make the change unless you respond back to this saying not to.


>>   - 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.
> 
> For this?
> 
>>   - 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 overlay
>> EDT 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.
>>
>> Errors while developing the patch exposed inadequate error messages
>> to debug problems when overlay devicetree fragment nodes contain
>> an invalid target path.  Improved the messages in find_target_node().
> 
> Sounds like another separate patch.

Will do.


> 
> Rob
> 



Re: [PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-01-29 Thread Frank Rowand
On 01/29/18 06:42, Rob Herring wrote:
> On Sun, Jan 28, 2018 at 8:53 PM,   wrote:
>> From: Frank Rowand 
>>
>> 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 device tree (aka expanded device tree, EDT) now
> 
> Not really a fan of a new acronym.
> 
>> belongs to devicetree code, which is thus responsible for freeing
>> the EDT.
>>
>> These ownership changes prevent early freeing of the duplicated FDT
>> or the EDT, 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.

I should have reversed the cause and effect in that sentence to
instead be:

  The changes to drivers/of/unittest.c require the test overlays
  to be in FDT form instead of unflattened devicetree form.  Move
  overlay fragments from artificial locations in
  drivers/of/unittest-data/tests-overlay.dtsi into one
  devicetree source file per overlay and thus create
  one FDT per overlay.


> Why the rearranging? That should be a separate patch.
Bisectability.

I can make the changes to the devicetree files in a second patch.
After the first patch, there will be 29 self test fails.

I will make the change unless you respond back to this saying not to.


>>   - 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.
> 
> For this?
> 
>>   - 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 overlay
>> EDT 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.
>>
>> Errors while developing the patch exposed inadequate error messages
>> to debug problems when overlay devicetree fragment nodes contain
>> an invalid target path.  Improved the messages in find_target_node().
> 
> Sounds like another separate patch.

Will do.


> 
> Rob
> 



Re: [PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-01-29 Thread Geert Uytterhoeven
On Mon, Jan 29, 2018 at 3:42 PM, Rob Herring  wrote:
> On Sun, Jan 28, 2018 at 8:53 PM,   wrote:
>> From: Frank Rowand 
>>
>> 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 device tree (aka expanded device tree, EDT) now
>
> Not really a fan of a new acronym.

FWIW, it has already sneaked in:

$ git grep -w EDT -- drivers/of
drivers/of/unittest.c:   * will create pointers to the passed in FDT in the EDT.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-01-29 Thread Geert Uytterhoeven
On Mon, Jan 29, 2018 at 3:42 PM, Rob Herring  wrote:
> On Sun, Jan 28, 2018 at 8:53 PM,   wrote:
>> From: Frank Rowand 
>>
>> 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 device tree (aka expanded device tree, EDT) now
>
> Not really a fan of a new acronym.

FWIW, it has already sneaked in:

$ git grep -w EDT -- drivers/of
drivers/of/unittest.c:   * will create pointers to the passed in FDT in the EDT.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-01-29 Thread Rob Herring
On Sun, Jan 28, 2018 at 8:53 PM,   wrote:
> From: Frank Rowand 
>
> 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 device tree (aka expanded device tree, EDT) now

Not really a fan of a new acronym.

> belongs to devicetree code, which is thus responsible for freeing
> the EDT.
>
> These ownership changes prevent early freeing of the duplicated FDT
> or the EDT, 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.

Why the rearranging? That should be a separate patch.

>
>   - 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.

For this?

>   - 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 overlay
> EDT 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.
>
> Errors while developing the patch exposed inadequate error messages
> to debug problems when overlay devicetree fragment nodes contain
> an invalid target path.  Improved the messages in find_target_node().

Sounds like another separate patch.

Rob


Re: [PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-01-29 Thread Rob Herring
On Sun, Jan 28, 2018 at 8:53 PM,   wrote:
> From: Frank Rowand 
>
> 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 device tree (aka expanded device tree, EDT) now

Not really a fan of a new acronym.

> belongs to devicetree code, which is thus responsible for freeing
> the EDT.
>
> These ownership changes prevent early freeing of the duplicated FDT
> or the EDT, 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.

Why the rearranging? That should be a separate patch.

>
>   - 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.

For this?

>   - 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 overlay
> EDT 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.
>
> Errors while developing the patch exposed inadequate error messages
> to debug problems when overlay devicetree fragment nodes contain
> an invalid target path.  Improved the messages in find_target_node().

Sounds like another separate patch.

Rob


Re: [PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-01-29 Thread Frank Rowand
On 01/28/18 19:21, Masahiro Yamada wrote:
> Hi Frank,
> 
> 2018-01-29 11:53 GMT+09:00  :
>> From: Frank Rowand 
>> diff --git a/drivers/of/unittest-data/Makefile 
>> b/drivers/of/unittest-data/Makefile
>> index df697976740a..2b7ee68c908e 100644
>> --- a/drivers/of/unittest-data/Makefile
>> +++ b/drivers/of/unittest-data/Makefile
>> @@ -3,6 +3,21 @@ DTC_FLAGS_testcases := -Wno-interrupts_property
>>  obj-y += testcases.dtb.o
>>
>>  obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \
>> +   overlay_0.dtb.o \
>> +   overlay_1.dtb.o \
>> +   overlay_2.dtb.o \
>> +   overlay_3.dtb.o \
>> +   overlay_4.dtb.o \
>> +   overlay_5.dtb.o \
>> +   overlay_6.dtb.o \
>> +   overlay_7.dtb.o \
>> +   overlay_8.dtb.o \
>> +   overlay_9.dtb.o \
>> +   overlay_10.dtb.o \
>> +   overlay_11.dtb.o \
>> +   overlay_12.dtb.o \
>> +   overlay_13.dtb.o \
>> +   overlay_15.dtb.o \
>> overlay_bad_phandle.dtb.o \
>> overlay_bad_symbol.dtb.o \
>> overlay_base.dtb.o
>> @@ -14,6 +29,7 @@ DTC_FLAGS_overlay := -@
>>  DTC_FLAGS_overlay_bad_phandle := -@
>>  DTC_FLAGS_overlay_bad_symbol := -@
>>  DTC_FLAGS_overlay_base := -@
>> +DTC_FLAGS_testcases := -@
>>
> 
> This overwrites '-Wno-interrupts_property' a few lines above.
> 
> Perhaps, do you want to do like this?
> 
>  DTC_FLAGS_testcases += -@
> 
> or
> 
>  DTC_FLAGS_testcases := -Wno-interrupts_property -@

Yes, thanks for catching that!  I'll fix it.

-Frank




Re: [PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-01-29 Thread Frank Rowand
On 01/28/18 19:21, Masahiro Yamada wrote:
> Hi Frank,
> 
> 2018-01-29 11:53 GMT+09:00  :
>> From: Frank Rowand 
>> diff --git a/drivers/of/unittest-data/Makefile 
>> b/drivers/of/unittest-data/Makefile
>> index df697976740a..2b7ee68c908e 100644
>> --- a/drivers/of/unittest-data/Makefile
>> +++ b/drivers/of/unittest-data/Makefile
>> @@ -3,6 +3,21 @@ DTC_FLAGS_testcases := -Wno-interrupts_property
>>  obj-y += testcases.dtb.o
>>
>>  obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \
>> +   overlay_0.dtb.o \
>> +   overlay_1.dtb.o \
>> +   overlay_2.dtb.o \
>> +   overlay_3.dtb.o \
>> +   overlay_4.dtb.o \
>> +   overlay_5.dtb.o \
>> +   overlay_6.dtb.o \
>> +   overlay_7.dtb.o \
>> +   overlay_8.dtb.o \
>> +   overlay_9.dtb.o \
>> +   overlay_10.dtb.o \
>> +   overlay_11.dtb.o \
>> +   overlay_12.dtb.o \
>> +   overlay_13.dtb.o \
>> +   overlay_15.dtb.o \
>> overlay_bad_phandle.dtb.o \
>> overlay_bad_symbol.dtb.o \
>> overlay_base.dtb.o
>> @@ -14,6 +29,7 @@ DTC_FLAGS_overlay := -@
>>  DTC_FLAGS_overlay_bad_phandle := -@
>>  DTC_FLAGS_overlay_bad_symbol := -@
>>  DTC_FLAGS_overlay_base := -@
>> +DTC_FLAGS_testcases := -@
>>
> 
> This overwrites '-Wno-interrupts_property' a few lines above.
> 
> Perhaps, do you want to do like this?
> 
>  DTC_FLAGS_testcases += -@
> 
> or
> 
>  DTC_FLAGS_testcases := -Wno-interrupts_property -@

Yes, thanks for catching that!  I'll fix it.

-Frank




Re: [PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-01-28 Thread Masahiro Yamada
Hi Frank,

2018-01-29 11:53 GMT+09:00  :
> From: Frank Rowand 
> diff --git a/drivers/of/unittest-data/Makefile 
> b/drivers/of/unittest-data/Makefile
> index df697976740a..2b7ee68c908e 100644
> --- a/drivers/of/unittest-data/Makefile
> +++ b/drivers/of/unittest-data/Makefile
> @@ -3,6 +3,21 @@ DTC_FLAGS_testcases := -Wno-interrupts_property
>  obj-y += testcases.dtb.o
>
>  obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \
> +   overlay_0.dtb.o \
> +   overlay_1.dtb.o \
> +   overlay_2.dtb.o \
> +   overlay_3.dtb.o \
> +   overlay_4.dtb.o \
> +   overlay_5.dtb.o \
> +   overlay_6.dtb.o \
> +   overlay_7.dtb.o \
> +   overlay_8.dtb.o \
> +   overlay_9.dtb.o \
> +   overlay_10.dtb.o \
> +   overlay_11.dtb.o \
> +   overlay_12.dtb.o \
> +   overlay_13.dtb.o \
> +   overlay_15.dtb.o \
> overlay_bad_phandle.dtb.o \
> overlay_bad_symbol.dtb.o \
> overlay_base.dtb.o
> @@ -14,6 +29,7 @@ DTC_FLAGS_overlay := -@
>  DTC_FLAGS_overlay_bad_phandle := -@
>  DTC_FLAGS_overlay_bad_symbol := -@
>  DTC_FLAGS_overlay_base := -@
> +DTC_FLAGS_testcases := -@
>

This overwrites '-Wno-interrupts_property' a few lines above.

Perhaps, do you want to do like this?

 DTC_FLAGS_testcases += -@

or

 DTC_FLAGS_testcases := -Wno-interrupts_property -@





-- 
Best Regards
Masahiro Yamada


Re: [PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-01-28 Thread Masahiro Yamada
Hi Frank,

2018-01-29 11:53 GMT+09:00  :
> From: Frank Rowand 
> diff --git a/drivers/of/unittest-data/Makefile 
> b/drivers/of/unittest-data/Makefile
> index df697976740a..2b7ee68c908e 100644
> --- a/drivers/of/unittest-data/Makefile
> +++ b/drivers/of/unittest-data/Makefile
> @@ -3,6 +3,21 @@ DTC_FLAGS_testcases := -Wno-interrupts_property
>  obj-y += testcases.dtb.o
>
>  obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \
> +   overlay_0.dtb.o \
> +   overlay_1.dtb.o \
> +   overlay_2.dtb.o \
> +   overlay_3.dtb.o \
> +   overlay_4.dtb.o \
> +   overlay_5.dtb.o \
> +   overlay_6.dtb.o \
> +   overlay_7.dtb.o \
> +   overlay_8.dtb.o \
> +   overlay_9.dtb.o \
> +   overlay_10.dtb.o \
> +   overlay_11.dtb.o \
> +   overlay_12.dtb.o \
> +   overlay_13.dtb.o \
> +   overlay_15.dtb.o \
> overlay_bad_phandle.dtb.o \
> overlay_bad_symbol.dtb.o \
> overlay_base.dtb.o
> @@ -14,6 +29,7 @@ DTC_FLAGS_overlay := -@
>  DTC_FLAGS_overlay_bad_phandle := -@
>  DTC_FLAGS_overlay_bad_symbol := -@
>  DTC_FLAGS_overlay_base := -@
> +DTC_FLAGS_testcases := -@
>

This overwrites '-Wno-interrupts_property' a few lines above.

Perhaps, do you want to do like this?

 DTC_FLAGS_testcases += -@

or

 DTC_FLAGS_testcases := -Wno-interrupts_property -@





-- 
Best Regards
Masahiro Yamada


[PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-01-28 Thread frowand . list
From: Frank Rowand 

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 device tree (aka expanded device tree, EDT) now
belongs to devicetree code, which is thus responsible for freeing
the EDT.

These ownership changes prevent early freeing of the duplicated FDT
or the EDT, 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 overlay
EDT 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.

Errors while developing the patch exposed inadequate error messages
to debug problems when overlay devicetree fragment nodes contain
an invalid target path.  Improved the messages in find_target_node().

Signed-off-by: Frank Rowand 
---

Dependency, a patch already applied by robh for next:

  From: Masahiro Yamada 
  Subject: [PATCH] of: unittest: refactor Makefile
  
https://lkml.kernel.org/r/<1515153330-11810-1-git-send-email-yamada.masah...@socionext.com>

Created on 4.15.

I will respin this patch on top of 4.15-rc1.

There are checkpatch warnings.  I have reviewed them and feel they
can be ignored.  They are "line over 80 characters" for either
pre-existing long lines, or lines in devicetree source files.


 drivers/of/of_private.h |   1 +
 drivers/of/overlay.c| 124 ++--
 drivers/of/resolver.c   |   6 -
 drivers/of/unittest-data/Makefile   |  16 ++
 drivers/of/unittest-data/overlay_0.dts  |  14 ++
 drivers/of/unittest-data/overlay_1.dts  |  14 ++
 drivers/of/unittest-data/overlay_10.dts |  34 
 drivers/of/unittest-data/overlay_11.dts |  34 
 drivers/of/unittest-data/overlay_12.dts |  14 ++
 drivers/of/unittest-data/overlay_13.dts |  14 ++
 drivers/of/unittest-data/overlay_15.dts |  35 
 drivers/of/unittest-data/overlay_2.dts  |  14 ++
 drivers/of/unittest-data/overlay_3.dts  |  14 ++
 drivers/of/unittest-data/overlay_4.dts  |  23 +++
 drivers/of/unittest-data/overlay_5.dts  |  14 ++
 drivers/of/unittest-data/overlay_6.dts  |  15 ++
 drivers/of/unittest-data/overlay_7.dts  |  15 ++
 drivers/of/unittest-data/overlay_8.dts  |  15 ++
 drivers/of/unittest-data/overlay_9.dts  |  15 ++
 drivers/of/unittest-data/tests-overlay.dtsi | 213 
 drivers/of/unittest.c   | 296 ++--
 include/linux/of.h  |   7 -
 22 files changed, 558 insertions(+), 389 deletions(-)
 create mode 100644 drivers/of/unittest-data/overlay_0.dts
 create mode 100644 drivers/of/unittest-data/overlay_1.dts
 create mode 100644 drivers/of/unittest-data/overlay_10.dts
 create mode 100644 drivers/of/unittest-data/overlay_11.dts
 create mode 100644 drivers/of/unittest-data/overlay_12.dts
 create mode 100644 drivers/of/unittest-data/overlay_13.dts
 create mode 100644 drivers/of/unittest-data/overlay_15.dts
 create mode 100644 drivers/of/unittest-data/overlay_2.dts
 create mode 100644 

[PATCH 1/2] of: change overlay apply input data from EDT to FDT

2018-01-28 Thread frowand . list
From: Frank Rowand 

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 device tree (aka expanded device tree, EDT) now
belongs to devicetree code, which is thus responsible for freeing
the EDT.

These ownership changes prevent early freeing of the duplicated FDT
or the EDT, 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 overlay
EDT 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.

Errors while developing the patch exposed inadequate error messages
to debug problems when overlay devicetree fragment nodes contain
an invalid target path.  Improved the messages in find_target_node().

Signed-off-by: Frank Rowand 
---

Dependency, a patch already applied by robh for next:

  From: Masahiro Yamada 
  Subject: [PATCH] of: unittest: refactor Makefile
  
https://lkml.kernel.org/r/<1515153330-11810-1-git-send-email-yamada.masah...@socionext.com>

Created on 4.15.

I will respin this patch on top of 4.15-rc1.

There are checkpatch warnings.  I have reviewed them and feel they
can be ignored.  They are "line over 80 characters" for either
pre-existing long lines, or lines in devicetree source files.


 drivers/of/of_private.h |   1 +
 drivers/of/overlay.c| 124 ++--
 drivers/of/resolver.c   |   6 -
 drivers/of/unittest-data/Makefile   |  16 ++
 drivers/of/unittest-data/overlay_0.dts  |  14 ++
 drivers/of/unittest-data/overlay_1.dts  |  14 ++
 drivers/of/unittest-data/overlay_10.dts |  34 
 drivers/of/unittest-data/overlay_11.dts |  34 
 drivers/of/unittest-data/overlay_12.dts |  14 ++
 drivers/of/unittest-data/overlay_13.dts |  14 ++
 drivers/of/unittest-data/overlay_15.dts |  35 
 drivers/of/unittest-data/overlay_2.dts  |  14 ++
 drivers/of/unittest-data/overlay_3.dts  |  14 ++
 drivers/of/unittest-data/overlay_4.dts  |  23 +++
 drivers/of/unittest-data/overlay_5.dts  |  14 ++
 drivers/of/unittest-data/overlay_6.dts  |  15 ++
 drivers/of/unittest-data/overlay_7.dts  |  15 ++
 drivers/of/unittest-data/overlay_8.dts  |  15 ++
 drivers/of/unittest-data/overlay_9.dts  |  15 ++
 drivers/of/unittest-data/tests-overlay.dtsi | 213 
 drivers/of/unittest.c   | 296 ++--
 include/linux/of.h  |   7 -
 22 files changed, 558 insertions(+), 389 deletions(-)
 create mode 100644 drivers/of/unittest-data/overlay_0.dts
 create mode 100644 drivers/of/unittest-data/overlay_1.dts
 create mode 100644 drivers/of/unittest-data/overlay_10.dts
 create mode 100644 drivers/of/unittest-data/overlay_11.dts
 create mode 100644 drivers/of/unittest-data/overlay_12.dts
 create mode 100644 drivers/of/unittest-data/overlay_13.dts
 create mode 100644 drivers/of/unittest-data/overlay_15.dts
 create mode 100644 drivers/of/unittest-data/overlay_2.dts
 create mode 100644 drivers/of/unittest-data/overlay_3.dts
 create mode 100644 drivers/of/unittest-data/overlay_4.dts
 create