From: Andre Przywara <andre.przywara-5wv7dgnIgG8@public.gmane.org>
To: David Gibson
<david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>,
Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH v3 1/3] checks: Add interrupt provider test
Date: Tue, 2 Jun 2020 12:04:17 +0100 [thread overview]
Message-ID: <20200602110419.22488-2-andre.przywara@arm.com> (raw)
In-Reply-To: <20200602110419.22488-1-andre.przywara-5wv7dgnIgG8@public.gmane.org>
An interrupt provider (an actual interrupt-controller node or an
interrupt nexus) should have both #address-cells and #interrupt-cells
properties explicitly defined.
Add an extra test for this. We check for the #interrupt-cells property
already, but this does not cover every controller so far, only those that
get referenced by an interrupts property in some node. Also we miss
interrupt nexus nodes.
A missing #address-cells property is less critical, but creates
ambiguities when used in interrupt-map properties, so warn about this as
well now.
This removes the now redundant warning in the existing interrupts test.
Signed-off-by: Andre Przywara <andre.przywara-5wv7dgnIgG8@public.gmane.org>
---
checks.c | 32 ++++++++++++++++++++++++++------
tests/bad-interrupt-controller.dts | 7 +++++++
tests/run_tests.sh | 1 +
3 files changed, 34 insertions(+), 6 deletions(-)
create mode 100644 tests/bad-interrupt-controller.dts
diff --git a/checks.c b/checks.c
index 4b3c486..23faca5 100644
--- a/checks.c
+++ b/checks.c
@@ -1547,6 +1547,28 @@ static bool node_is_interrupt_provider(struct node *node)
return false;
}
+
+static void check_interrupt_provider(struct check *c,
+ struct dt_info *dti,
+ struct node *node)
+{
+ struct property *prop;
+
+ if (!node_is_interrupt_provider(node))
+ return;
+
+ prop = get_property(node, "#interrupt-cells");
+ if (!prop)
+ FAIL(c, dti, node,
+ "Missing #interrupt-cells in interrupt provider");
+
+ prop = get_property(node, "#address-cells");
+ if (!prop)
+ FAIL(c, dti, node,
+ "Missing #address-cells in interrupt provider");
+}
+WARNING(interrupt_provider, check_interrupt_provider, NULL);
+
static void check_interrupts_property(struct check *c,
struct dt_info *dti,
struct node *node)
@@ -1602,12 +1624,8 @@ static void check_interrupts_property(struct check *c,
return;
}
+ /* Validity already verified by another test. */
prop = get_property(irq_node, "#interrupt-cells");
- if (!prop) {
- FAIL(c, dti, irq_node, "Missing #interrupt-cells in interrupt-parent");
- return;
- }
-
irq_cells = propval_cell(prop);
if (irq_prop->val.len % (irq_cells * sizeof(cell_t))) {
FAIL_PROP(c, dti, node, prop,
@@ -1615,7 +1633,8 @@ static void check_interrupts_property(struct check *c,
irq_prop->val.len, (int)(irq_cells * sizeof(cell_t)));
}
}
-WARNING(interrupts_property, check_interrupts_property, &phandle_references);
+WARNING(interrupts_property, check_interrupts_property, &phandle_references,
+ &interrupt_cells_is_cell, &interrupt_provider);
static const struct bus_type graph_port_bus = {
.name = "graph-port",
@@ -1828,6 +1847,7 @@ static struct check *check_table[] = {
&deprecated_gpio_property,
&gpios_property,
&interrupts_property,
+ &interrupt_provider,
&alias_paths,
diff --git a/tests/bad-interrupt-controller.dts b/tests/bad-interrupt-controller.dts
new file mode 100644
index 0000000..62fa118
--- /dev/null
+++ b/tests/bad-interrupt-controller.dts
@@ -0,0 +1,7 @@
+/dts-v1/;
+
+/ {
+ intc: interrupt-controller {
+ interrupt-controller;
+ };
+};
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index eccb85d..294585b 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -714,6 +714,7 @@ dtc_tests () {
check_tests "$SRCDIR/bad-graph.dts" graph_endpoint
run_sh_test "$SRCDIR/dtc-checkfails.sh" deprecated_gpio_property -- -Wdeprecated_gpio_property -I dts -O dtb "$SRCDIR/bad-gpio.dts"
check_tests "$SRCDIR/bad-interrupt-cells.dts" interrupts_property
+ check_tests "$SRCDIR/bad-interrupt-controller.dts" interrupt_provider
run_sh_test "$SRCDIR/dtc-checkfails.sh" node_name_chars -- -I dtb -O dtb bad_node_char.dtb
run_sh_test "$SRCDIR/dtc-checkfails.sh" node_name_format -- -I dtb -O dtb bad_node_format.dtb
run_sh_test "$SRCDIR/dtc-checkfails.sh" property_name_chars -- -I dtb -O dtb bad_prop_char.dtb
--
2.14.1
next prev parent reply other threads:[~2020-06-02 11:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-02 11:04 [PATCH v3 0/3] dtc: checks: Validate interrupt-map properties Andre Przywara
[not found] ` <20200602110419.22488-1-andre.przywara-5wv7dgnIgG8@public.gmane.org>
2020-06-02 11:04 ` Andre Przywara [this message]
[not found] ` <20200602110419.22488-2-andre.przywara-5wv7dgnIgG8@public.gmane.org>
2020-06-08 19:48 ` [PATCH v3 1/3] checks: Add interrupt provider test Rob Herring
2020-06-10 5:10 ` David Gibson
[not found] ` <20200610051057.GM494336-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2020-06-11 20:04 ` Rob Herring
2020-06-02 11:04 ` [PATCH v3 2/3] checks: Validate interrupt-map properties Andre Przywara
[not found] ` <20200602110419.22488-3-andre.przywara-5wv7dgnIgG8@public.gmane.org>
2020-06-08 20:12 ` Rob Herring
2020-06-02 11:04 ` [RFC PATCH v3 3/3] checks: interrupt-map: Dump entries on error Andre Przywara
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=20200602110419.22488-2-andre.przywara@arm.com \
--to=andre.przywara-5wv7dgnigg8@public.gmane.org \
--cc=david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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 read-only IMAP folder(s) and NNTP newsgroup(s).