With the device isolation feature, the control registers reset to
the "all ports disabled" value and so require explicit programming
by pre-boot firmware. Apparently if firmware forgets to do this,
we can end up skipping all leaf nodes in the discovery walk due to
the CMN_CHILD_NODE_ISOLATED flag, and thus dereferencing dtc[0]
uninitialised in arm_cmn_set_state(). While this should only ever
be an "early platform bringup" kind of issue, it's not too hard to
fail a bit more politely in this case, so we may as well.
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
drivers/perf/arm-cmn.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
index 4779472ecfb8..d88339ecf672 100644
--- a/drivers/perf/arm-cmn.c
+++ b/drivers/perf/arm-cmn.c
@@ -2779,6 +2779,11 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
}
}
+ if (cmn->num_dtcs == 0) {
+ dev_err(cmn->dev, "No DTCs found! Has firmware failed to program device isolation registers?\n");
+ return -ENODEV;
+ }
+
/* Correct for any nodes we added or skipped */
cmn->num_dns = dn - cmn->dns;
--
2.54.0.dirty