firmware/psci: Don't register with debugfs if PSCI isn't available
authorMarc Zyngier <maz@kernel.org>
Thu, 5 Jan 2023 09:08:34 +0000 (09:08 +0000)
committerWill Deacon <will@kernel.org>
Fri, 6 Jan 2023 17:13:08 +0000 (17:13 +0000)
commitcef139299fd86098c6e3dbd389d1d0b2462d7710
tree8e76b3fb322d364eaf5cd9b30f1e2835306363da
parentf3dc61cde80d48751999c4cb46daf3b2185e6895
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 <marcan@marcan.st>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: Hector Martin <marcan@marcan.st>
Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20230105090834.630238-1-maz@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
drivers/firmware/psci/psci.c