of: change overlay apply input data from unflattened to FDT
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>
This commit is contained in:

committed by
Frank Rowand

parent
581e929018
commit
39a751a4cb
@@ -1,8 +1,22 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
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
|
||||
@@ -10,10 +24,14 @@ obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \
|
||||
targets += $(foreach suffix, dtb dtb.S, $(patsubst %.dtb.o,%.$(suffix),$(obj-y)))
|
||||
|
||||
# enable creation of __symbols__ node
|
||||
DTC_FLAGS_overlay := -@
|
||||
DTC_FLAGS_overlay_bad_phandle := -@
|
||||
DTC_FLAGS_overlay_bad_symbol := -@
|
||||
DTC_FLAGS_overlay_base := -@
|
||||
DTC_FLAGS_overlay += -@
|
||||
DTC_FLAGS_overlay_bad_phandle += -@
|
||||
DTC_FLAGS_overlay_bad_symbol += -@
|
||||
DTC_FLAGS_overlay_base += -@
|
||||
DTC_FLAGS_testcases += -@
|
||||
|
||||
# suppress warnings about intentional errors
|
||||
DTC_FLAGS_testcases += -Wno-interrupts_property
|
||||
|
||||
.PRECIOUS: \
|
||||
$(obj)/%.dtb.S \
|
||||
|
14
drivers/of/unittest-data/overlay_0.dts
Normal file
14
drivers/of/unittest-data/overlay_0.dts
Normal file
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
/* overlay_0 - enable using absolute target path */
|
||||
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/test-unittest0";
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
14
drivers/of/unittest-data/overlay_1.dts
Normal file
14
drivers/of/unittest-data/overlay_1.dts
Normal file
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
/* overlay_1 - disable using absolute target path */
|
||||
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/test-unittest1";
|
||||
__overlay__ {
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
};
|
34
drivers/of/unittest-data/overlay_10.dts
Normal file
34
drivers/of/unittest-data/overlay_10.dts
Normal file
@@ -0,0 +1,34 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
/* overlay_10 */
|
||||
/* overlays 8, 9, 10, 11 application and removal in bad sequence */
|
||||
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus";
|
||||
__overlay__ {
|
||||
|
||||
/* suppress DTC warning */
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
test-unittest10 {
|
||||
compatible = "unittest";
|
||||
status = "okay";
|
||||
reg = <10>;
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
test-unittest101 {
|
||||
compatible = "unittest";
|
||||
status = "okay";
|
||||
reg = <1>;
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
34
drivers/of/unittest-data/overlay_11.dts
Normal file
34
drivers/of/unittest-data/overlay_11.dts
Normal file
@@ -0,0 +1,34 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
/* overlay_11 */
|
||||
/* overlays 8, 9, 10, 11 application and removal in bad sequence */
|
||||
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus";
|
||||
__overlay__ {
|
||||
|
||||
/* suppress DTC warning */
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
test-unittest11 {
|
||||
compatible = "unittest";
|
||||
status = "okay";
|
||||
reg = <11>;
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
test-unittest111 {
|
||||
compatible = "unittest";
|
||||
status = "okay";
|
||||
reg = <1>;
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
14
drivers/of/unittest-data/overlay_12.dts
Normal file
14
drivers/of/unittest-data/overlay_12.dts
Normal file
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
/* overlay_12 - enable using absolute target path (i2c) */
|
||||
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest12";
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
14
drivers/of/unittest-data/overlay_13.dts
Normal file
14
drivers/of/unittest-data/overlay_13.dts
Normal file
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
/* overlay_13 - disable using absolute target path (i2c) */
|
||||
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest13";
|
||||
__overlay__ {
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
};
|
35
drivers/of/unittest-data/overlay_15.dts
Normal file
35
drivers/of/unittest-data/overlay_15.dts
Normal file
@@ -0,0 +1,35 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
/* overlay_15 - mux overlay */
|
||||
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus";
|
||||
__overlay__ {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
test-unittest15 {
|
||||
reg = <11>;
|
||||
compatible = "unittest-i2c-mux";
|
||||
status = "okay";
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
i2c@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
reg = <0>;
|
||||
|
||||
test-mux-dev {
|
||||
reg = <32>;
|
||||
compatible = "unittest-i2c-dev";
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
14
drivers/of/unittest-data/overlay_2.dts
Normal file
14
drivers/of/unittest-data/overlay_2.dts
Normal file
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
/* overlay_2 - enable using label */
|
||||
|
||||
fragment@0 {
|
||||
target = <&unittest2>;
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
14
drivers/of/unittest-data/overlay_3.dts
Normal file
14
drivers/of/unittest-data/overlay_3.dts
Normal file
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
/* overlay_3 - disable using label */
|
||||
|
||||
fragment@0 {
|
||||
target = <&unittest3>;
|
||||
__overlay__ {
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
};
|
23
drivers/of/unittest-data/overlay_4.dts
Normal file
23
drivers/of/unittest-data/overlay_4.dts
Normal file
@@ -0,0 +1,23 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
/* overlay_4 - test insertion of a full node */
|
||||
|
||||
fragment@0 {
|
||||
target = <&unittestbus>;
|
||||
__overlay__ {
|
||||
|
||||
/* suppress DTC warning */
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
test-unittest4 {
|
||||
compatible = "unittest";
|
||||
status = "okay";
|
||||
reg = <4>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
14
drivers/of/unittest-data/overlay_5.dts
Normal file
14
drivers/of/unittest-data/overlay_5.dts
Normal file
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
/* overlay_5 - test overlay apply revert */
|
||||
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/test-unittest5";
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
15
drivers/of/unittest-data/overlay_6.dts
Normal file
15
drivers/of/unittest-data/overlay_6.dts
Normal file
@@ -0,0 +1,15 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
/* overlay_6 */
|
||||
/* overlays 6, 7 application and removal in sequence */
|
||||
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/test-unittest6";
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
15
drivers/of/unittest-data/overlay_7.dts
Normal file
15
drivers/of/unittest-data/overlay_7.dts
Normal file
@@ -0,0 +1,15 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
/* overlay_7 */
|
||||
/* overlays 6, 7 application and removal in sequence */
|
||||
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/test-unittest7";
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
15
drivers/of/unittest-data/overlay_8.dts
Normal file
15
drivers/of/unittest-data/overlay_8.dts
Normal file
@@ -0,0 +1,15 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
/* overlay_8 */
|
||||
/* overlays 8, 9, 10, 11 application and removal in bad sequence */
|
||||
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/test-unittest8";
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
15
drivers/of/unittest-data/overlay_9.dts
Normal file
15
drivers/of/unittest-data/overlay_9.dts
Normal file
@@ -0,0 +1,15 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
/* overlay_9 */
|
||||
/* overlays 8, 9, 10, 11 application and removal in bad sequence */
|
||||
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/test-unittest8";
|
||||
__overlay__ {
|
||||
property-foo = "bar";
|
||||
};
|
||||
};
|
||||
};
|
@@ -113,218 +113,5 @@
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/* test enable using absolute target path */
|
||||
overlay0 {
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/test-unittest0";
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/* test disable using absolute target path */
|
||||
overlay1 {
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/test-unittest1";
|
||||
__overlay__ {
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/* test enable using label */
|
||||
overlay2 {
|
||||
fragment@0 {
|
||||
target = <&unittest2>;
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/* test disable using label */
|
||||
overlay3 {
|
||||
fragment@0 {
|
||||
target = <&unittest3>;
|
||||
__overlay__ {
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/* test insertion of a full node */
|
||||
overlay4 {
|
||||
fragment@0 {
|
||||
target = <&unittestbus>;
|
||||
__overlay__ {
|
||||
|
||||
/* suppress DTC warning */
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
test-unittest4 {
|
||||
compatible = "unittest";
|
||||
status = "okay";
|
||||
reg = <4>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/* test overlay apply revert */
|
||||
overlay5 {
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/test-unittest5";
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/* test overlays application and removal in sequence */
|
||||
overlay6 {
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/test-unittest6";
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
overlay7 {
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/test-unittest7";
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/* test overlays application and removal in bad sequence */
|
||||
overlay8 {
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/test-unittest8";
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
overlay9 {
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/test-unittest8";
|
||||
__overlay__ {
|
||||
property-foo = "bar";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
overlay10 {
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus";
|
||||
__overlay__ {
|
||||
|
||||
/* suppress DTC warning */
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
test-unittest10 {
|
||||
compatible = "unittest";
|
||||
status = "okay";
|
||||
reg = <10>;
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
test-unittest101 {
|
||||
compatible = "unittest";
|
||||
status = "okay";
|
||||
reg = <1>;
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
overlay11 {
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus";
|
||||
__overlay__ {
|
||||
|
||||
/* suppress DTC warning */
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
test-unittest11 {
|
||||
compatible = "unittest";
|
||||
status = "okay";
|
||||
reg = <11>;
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
test-unittest111 {
|
||||
compatible = "unittest";
|
||||
status = "okay";
|
||||
reg = <1>;
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/* test enable using absolute target path (i2c) */
|
||||
overlay12 {
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest12";
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/* test disable using absolute target path (i2c) */
|
||||
overlay13 {
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus/test-unittest13";
|
||||
__overlay__ {
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/* test mux overlay */
|
||||
overlay15 {
|
||||
fragment@0 {
|
||||
target-path = "/testcase-data/overlay-node/test-bus/i2c-test-bus";
|
||||
__overlay__ {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
test-unittest15 {
|
||||
reg = <11>;
|
||||
compatible = "unittest-i2c-mux";
|
||||
status = "okay";
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
i2c@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
reg = <0>;
|
||||
|
||||
test-mux-dev {
|
||||
reg = <32>;
|
||||
compatible = "unittest-i2c-dev";
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user