Commit 2eb46da2 authored by Grant Likely's avatar Grant Likely

of/selftest: Use the resolver to fixup phandles

The selftest data ends up causing duplicate phandles in the live tree
for the time that the testcase data is inserted into the live tree. This
is obviously a bad situation because anything attempting to read the
tree while the selftests are running make resolve phandles to one of the
testcase data nodes. Fix the problem by using the of_resolve_phandles()
function to eliminate duplicates.
Signed-off-by: default avatarGrant Likely <grant.likely@linaro.org>
Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Cc: Gaurav Minocha <gaurav.minocha.os@gmail.com>
parent 7941b27b
......@@ -11,6 +11,7 @@ config OF_SELFTEST
bool "Device Tree Runtime self tests"
depends on OF_IRQ && OF_EARLY_FLATTREE
select OF_DYNAMIC
select OF_RESOLVE
help
This option builds in test cases for the device tree infrastructure
that are executed once at boot time, and the results dumped to the
......
......@@ -25,7 +25,7 @@ static struct selftest_results {
int failed;
} selftest_results;
#define NO_OF_NODES 2
#define NO_OF_NODES 3
static struct device_node *nodes[NO_OF_NODES];
static int last_node_index;
static bool selftest_live_tree;
......@@ -765,6 +765,7 @@ static int __init selftest_data_add(void)
extern uint8_t __dtb_testcases_begin[];
extern uint8_t __dtb_testcases_end[];
const int size = __dtb_testcases_end - __dtb_testcases_begin;
int rc;
if (!size) {
pr_warn("%s: No testcase data to attach; not running tests\n",
......@@ -785,6 +786,12 @@ static int __init selftest_data_add(void)
pr_warn("%s: No tree to attach; not running tests\n", __func__);
return -ENODATA;
}
of_node_set_flag(selftest_data_node, OF_DETACHED);
rc = of_resolve_phandles(selftest_data_node);
if (rc) {
pr_err("%s: Failed to resolve phandles (rc=%i)\n", __func__, rc);
return -EINVAL;
}
if (!of_allnodes) {
/* enabling flag for removing nodes */
......
......@@ -13,3 +13,38 @@ node-remove {
#include "tests-interrupts.dtsi"
#include "tests-match.dtsi"
#include "tests-platform.dtsi"
/*
* phandle fixup data - generated by dtc patches that aren't upstream.
* This data must be regenerated whenever phandle references are modified in
* the testdata tree.
*
* The format of this data may be subject to change. For the time being consider
* this a kernel-internal data format.
*/
/ { __local_fixups__ {
fixup = "/testcase-data/testcase-device2:interrupt-parent:0",
"/testcase-data/testcase-device1:interrupt-parent:0",
"/testcase-data/interrupts/interrupts-extended0:interrupts-extended:60",
"/testcase-data/interrupts/interrupts-extended0:interrupts-extended:52",
"/testcase-data/interrupts/interrupts-extended0:interrupts-extended:44",
"/testcase-data/interrupts/interrupts-extended0:interrupts-extended:36",
"/testcase-data/interrupts/interrupts-extended0:interrupts-extended:24",
"/testcase-data/interrupts/interrupts-extended0:interrupts-extended:8",
"/testcase-data/interrupts/interrupts-extended0:interrupts-extended:0",
"/testcase-data/interrupts/interrupts1:interrupt-parent:0",
"/testcase-data/interrupts/interrupts0:interrupt-parent:0",
"/testcase-data/interrupts/intmap1:interrupt-map:12",
"/testcase-data/interrupts/intmap0:interrupt-map:52",
"/testcase-data/interrupts/intmap0:interrupt-map:36",
"/testcase-data/interrupts/intmap0:interrupt-map:16",
"/testcase-data/interrupts/intmap0:interrupt-map:4",
"/testcase-data/phandle-tests/consumer-a:phandle-list-bad-args:12",
"/testcase-data/phandle-tests/consumer-a:phandle-list-bad-args:0",
"/testcase-data/phandle-tests/consumer-a:phandle-list:56",
"/testcase-data/phandle-tests/consumer-a:phandle-list:52",
"/testcase-data/phandle-tests/consumer-a:phandle-list:40",
"/testcase-data/phandle-tests/consumer-a:phandle-list:24",
"/testcase-data/phandle-tests/consumer-a:phandle-list:8",
"/testcase-data/phandle-tests/consumer-a:phandle-list:0";
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment