aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Zyngier <[email protected]>2023-01-05 09:08:34 +0000
committerWill Deacon <[email protected]>2023-01-06 17:13:08 +0000
commitcef139299fd86098c6e3dbd389d1d0b2462d7710 (patch)
tree8e76b3fb322d364eaf5cd9b30f1e2835306363da
parentf3dc61cde80d48751999c4cb46daf3b2185e6895 (diff)
firmware/psci: Don't register with debugfs if PSCI isn't available
Contrary to popular belief, PSCI is not a universal property of an ARM/arm64 system. There is a garden variety of systems out there that don't (or even cannot) implement it. I'm the first one deplore such a situation, but hey... On such systems, a "cat /sys/kernel/debug/psci" results in fireworks, as no invocation callback is registered. Check for the invoke_psci_fn and psci_ops.get_version pointers before registering with the debugfs subsystem, avoiding the issue altogether. Fixes: 3137f2e60098 ("firmware/psci: Add debugfs support to ease debugging") Reported-by: Hector Martin <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Cc: Dmitry Baryshkov <[email protected]> Cc: Mark Brown <[email protected]> Cc: Ulf Hansson <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Lorenzo Pieralisi <[email protected]> Reviewed-by: Hector Martin <[email protected]> Acked-by: Dmitry Baryshkov <[email protected]> Acked-by: Mark Rutland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
-rw-r--r--drivers/firmware/psci/psci.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
index e7bcfca4159f..447ee4ea5c90 100644
--- a/drivers/firmware/psci/psci.c
+++ b/drivers/firmware/psci/psci.c
@@ -440,6 +440,9 @@ static const struct file_operations psci_debugfs_ops = {
static int __init psci_debugfs_init(void)
{
+ if (!invoke_psci_fn || !psci_ops.get_version)
+ return 0;
+
return PTR_ERR_OR_ZERO(debugfs_create_file("psci", 0444, NULL, NULL,
&psci_debugfs_ops));
}