Revert "power: supply: qcom_battmgr: Register the power supplies after PDR is up"
authorJohan Hovold <johan+linaro@kernel.org>
Tue, 23 Jan 2024 16:00:53 +0000 (17:00 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Fri, 26 Jan 2024 21:45:58 +0000 (22:45 +0100)
commitd0266d7ab1618482d58015d67a5220e590333298
treeefc9b6edbce51b04a9e66ee57541865a794a4b4e
parent6613476e225e090cc9aad49be7fa504e290dd33d
Revert "power: supply: qcom_battmgr: Register the power supplies after PDR is up"

This reverts commit b43f7ddc2b7a5a90447d96cb4d3c6d142dd4a810.

The offending commit deferred power-supply class device registration
until the service-started notification is received.

This triggers a NULL pointer dereference during boot of the Lenovo
ThinkPad X13s and SC8280XP CRD as battery status notifications can be
received before the service-start notification:

Unable to handle kernel NULL pointer dereference at virtual address 00000000000005c0
...
Call trace:
 _acquire+0x338/0x2064
 acquire+0x1e8/0x318
 spin_lock_irqsave+0x60/0x88
 _supply_changed+0x2c/0xa4
 battmgr_callback+0x1d4/0x60c [qcom_battmgr]
 pmic_glink_rpmsg_callback+0x5c/0xa4 [pmic_glink]
 qcom_glink_native_rx+0x58c/0x7e8
 qcom_glink_smem_intr+0x14/0x24 [qcom_glink_smem]
 __handle_irq_event_percpu+0xb0/0x2d4
 handle_irq_event+0x4c/0xb8

As trying to serialise this is non-trivial and risks missing
notifications, let's revert to registration during probe so that the
driver data is all set up once the service goes live.

The warning message during resume in case the aDSP firmware is not
running that motivated the change can be considered a feature and should
not be suppressed.

Fixes: b43f7ddc2b7a ("power: supply: qcom_battmgr: Register the power supplies after PDR is up")
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20240123160053.18331-1-johan+linaro@kernel.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/qcom_battmgr.c