Skip to contentSkip to conversation

libfdt: A few overlay fixes

PATCH In review Maxime Ripard 2 participants 11 messages Oct 6, 2016 – Oct 11, 2016 3 messages not in the archive

lore
Share & tools
lore
#0 lore raw

cover libfdt: A few overlay fixes

Hi David,

Here are a few patches to fix the things you requested and a few bugs encountered while doing so.

Let me know what you think,
Maxime

Maxime Ripard (4):
libfdt: Add BADPHANDLE error string
libfdt: overlay: Report a bad overlay for mismatching local fixups
libfdt: overlay: Fix symbols and fixups nodes condition
tests: overlay: Move back the bad fixup tests

 libfdt/fdt_overlay.c  |  9 +++++----
 libfdt/fdt_strerror.c |  1 +
 tests/run_tests.sh    | 14 +++++++-------
 3 files changed, 13 insertions(+), 11 deletions(-)
Signature · 1 line
2.9.3

A message that is not in the archive (sent off-list or not yet received): 20161006113959.30865-1-maxime.ripard-wi1+55ScJUtKEb57/[email protected]

#2 lore raw

PATCH 1/4 libfdt: Add BADPHANDLE error string

The BADPHANDLE error was missing a string, leading to an <unknown error> string being returned if you were to call fdt_strerror.

---
 libfdt/fdt_strerror.c | 1 +
 1 file changed, 1 insertion(+)
libfdt/fdt_strerror.c +1 -0
index 3cb357f60454..e00fcb19df60 100644
@@ -69,6 +69,7 @@ static struct fdt_errtabent fdt_errtable[] = {
 
 	FDT_ERRTABENT(FDT_ERR_BADOFFSET),
 	FDT_ERRTABENT(FDT_ERR_BADPATH),
+	FDT_ERRTABENT(FDT_ERR_BADPHANDLE),
 	FDT_ERRTABENT(FDT_ERR_BADSTATE),
 
 	FDT_ERRTABENT(FDT_ERR_TRUNCATED),
Signature · 1 line
2.9.3
#3 lore raw

PATCH 2/4 libfdt: overlay: Report a bad overlay for mismatching local fixups

In reply to a message not in the archive

The __local_fixups__ node as a structure that mimics the structure of the main overlay part.

This means that if we have a child node somewhere in the local fixups sub-tree and if that node is not present in the main tree, the overlay is poorly formatted, and we should report it as such.

---
 libfdt/fdt_overlay.c | 2 ++
 1 file changed, 2 insertions(+)
libfdt/fdt_overlay.c +2 -0
index 322e7adb41b8..2f306e4717ec 100644
@@ -272,6 +272,8 @@ static int overlay_update_local_node_references(void *fdto,
 
 		tree_child = fdt_subnode_offset(fdto, tree_node,
 						fixup_child_name);
+		if (ret == -FDT_ERR_NOTFOUND)
+			return -FDT_ERR_BADOVERLAY;
 		if (tree_child < 0)
 			return tree_child;
 
Signature · 1 line
2.9.3
#4 lore raw

PATCH 3/4 libfdt: overlay: Fix symbols and fixups nodes condition

In reply to a message not in the archive

Some base device tree might not have any __symbols__ nodes, since they might not have any phandle at all.

Similarly, if an overlay doesn't use any base device tree phandles, its __fixups__ node will be empty.

In such cases, we don't want to stop the phandle parsing, but rather just ignore the error reported about the missing node.

If it's actually an issue for the overlay we're trying to apply on a given base device tree, it will be caught later on, but we cannot make the assumption that early in the application process.

---
 libfdt/fdt_overlay.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
libfdt/fdt_overlay.c +3 -4
index 2f306e4717ec..bb4140412971 100644
@@ -492,13 +492,12 @@ static int overlay_fixup_phandles(void *fdt, void *fdto)
 
 	/* We can have overlays without any fixups */
 	fixups_off = fdt_path_offset(fdto, "/__fixups__");
-	if (fixups_off == -FDT_ERR_NOTFOUND)
-		return 0;
-	if (fixups_off < 0)
+	if ((fixups_off < 0 && (fixups_off != -FDT_ERR_NOTFOUND)))
 		return fixups_off;
 
+	/* And base DTs without symbols */
 	symbols_off = fdt_path_offset(fdt, "/__symbols__");
-	if (symbols_off < 0)
+	if ((symbols_off < 0 && (symbols_off != -FDT_ERR_NOTFOUND)))
 		return symbols_off;
 
 	fdt_for_each_property_offset(property, fdto, fixups_off) {
Signature · 1 line
2.9.3
#5 lore raw

PATCH 4/4 tests: overlay: Move back the bad fixup tests

In reply to a message not in the archive

The bad fixups tests were meant to be usable even for a non-overlay-enabled dtc.

Move them out of that check.

---
 tests/run_tests.sh | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
tests/run_tests.sh +7 -7
index 10b41bca85cb..dc19f80b2fb6 100755
@@ -181,14 +181,14 @@ overlay_tests () {
         run_dtc_test -@ -I dts -O dtb -o overlay_base.dtb overlay_base.dts
         run_dtc_test -@ -I dts -O dtb -o overlay_overlay.dtb overlay_overlay_dtc.dts
         run_test overlay overlay_base.dtb overlay_overlay.dtb
-
-	# Bad fixup tests
-	for test in $BAD_FIXUP_TREES; do
-	    tree="overlay_bad_fixup_$test"
-	    run_dtc_test -I dts -O dtb -o $tree.dtb $tree.dts
-	    run_test overlay_bad_fixup overlay_base.dtb $tree.dtb
-	done
     fi
+
+    # Bad fixup tests
+    for test in $BAD_FIXUP_TREES; do
+	tree="overlay_bad_fixup_$test"
+	run_dtc_test -I dts -O dtb -o $tree.dtb $tree.dts
+	run_test overlay_bad_fixup overlay_base.dtb $tree.dtb
+    done
 }
 
 tree1_tests () {
Signature · 1 line
2.9.3
#6 lore raw
In reply to a message not in the archive
Quoted 6 lines · Maxime Ripard

Hi David,

Here are a few patches to fix the things you requested and a few bugs encountered while doing so.

Let me know what you think,

All applied, thanks.

Couple of other little errors to correct if you have time:

- BADOVERLAY is listed twice in the error string table (a hangover from when there was both BADFIXUP and BADOVERLAY, I guess)

- The testcases re-use the same file name for the intermediate dtbs. That's not a terrible problem, but it can make sorting out what's going on when there are multiple errors in a test run harder

- Generated dtb/dts files during the test should generally have a .test.dtb / .test.dts extension (makes gitignores and clean targets easier)

- In order for the apply_overlay function to be usable from the libfdt shared library, you'll need to add it to version.lds

Quoted 13 lines

Maxime

Maxime Ripard (4):
libfdt: Add BADPHANDLE error string
libfdt: overlay: Report a bad overlay for mismatching local fixups
libfdt: overlay: Fix symbols and fixups nodes condition
tests: overlay: Move back the bad fixup tests

 libfdt/fdt_overlay.c  |  9 +++++----
 libfdt/fdt_strerror.c |  1 +
 tests/run_tests.sh    | 14 +++++++-------
 3 files changed, 13 insertions(+), 11 deletions(-)
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

Hi David,

Quoted 9 lines · David Gibson
Quoted 6 lines · Maxime Ripard

Hi David,

Here are a few patches to fix the things you requested and a few bugs encountered while doing so.

Let me know what you think,

All applied, thanks.

It doesn't look like it's on the repo, did you push it?

Quoted 10 lines

Couple of other little errors to correct if you have time:

- BADOVERLAY is listed twice in the error string table (a hangover from when there was both BADFIXUP and BADOVERLAY, I guess)

- The testcases re-use the same file name for the intermediate dtbs. That's not a terrible problem, but it can make sorting out what's going on when there are multiple errors in a test run harder

Quoted 6 lines

- Generated dtb/dts files during the test should generally have a .test.dtb / .test.dts extension (makes gitignores and clean targets easier)

- In order for the apply_overlay function to be usable from the libfdt shared library, you'll need to add it to version.lds

I'll deal with those this week. Thanks!
Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#9 lore raw
Quoted 6 lines · Maxime Ripard

Hi David,

Quoted 3 lines · David Gibson
Quoted 2 lines · Maxime Ripard

Hi David,

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Here are a few patches to fix the things you requested and a few bugs encountered while doing so.

Let me know what you think,

All applied, thanks.

It doesn't look like it's on the repo, did you push it?

Oops, I did not.

Try now.

Quoted 20 lines
Quoted 10 lines

Couple of other little errors to correct if you have time:

- BADOVERLAY is listed twice in the error string table (a hangover from when there was both BADFIXUP and BADOVERLAY, I guess)

- The testcases re-use the same file name for the intermediate dtbs. That's not a terrible problem, but it can make sorting out what's going on when there are multiple errors in a test run harder

Quoted 6 lines

- Generated dtb/dts files during the test should generally have a .test.dtb / .test.dts extension (makes gitignores and clean targets easier)

- In order for the apply_overlay function to be usable from the libfdt shared library, you'll need to add it to version.lds

I'll deal with those this week. Thanks!
Maxime

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw
Quoted 12 lines · David Gibson
Quoted 11 lines · Maxime Ripard

Hi David,

Quoted 8 lines · David Gibson
Quoted 6 lines · Maxime Ripard

Hi David,

Here are a few patches to fix the things you requested and a few bugs encountered while doing so.

Let me know what you think,

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

All applied, thanks.

It doesn't look like it's on the repo, did you push it?

Oops, I did not.

Try now.

Yep, it's there now, thanks!
Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#12 lore raw
In reply to a message not in the archive

Hi,

Quoted 4 lines · David Gibson

- The testcases re-use the same file name for the intermediate dtbs. That's not a terrible problem, but it can make sorting out what's going on when there are multiple errors in a test run harder

I'm not sure how exactly you want me to fix that. All the overlays have a different name already. Or do you want me to rename the base device tree as well?

Thanks,
Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#13 lore raw
Quoted 11 lines · Maxime Ripard

Hi,

Quoted 4 lines · David Gibson

- The testcases re-use the same file name for the intermediate dtbs. That's not a terrible problem, but it can make sorting out what's going on when there are multiple errors in a test run harder

I'm not sure how exactly you want me to fix that. All the overlays have a different name already. Or do you want me to rename the base device tree as well?

Uh.. looking again the problem is less extensive than I thought.

It's just that the variants of the base tree compiled with and without -@ are given the same output name.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson