2024-01-03 12:32:23

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH] power: supply: qcom_battmgr: Register the power supplies after PDR is up

Commit b43f7ddc2b7a ("power: supply: qcom_battmgr: Register the power
supplies after PDR is up") moved the devm_power_supply_register() calls
so that the power supply devices are not registered before we go through
the entire initialization sequence (power up the ADSP remote processor,
wait for it to come online, coordinate with userspace..).

Some firmware versions (e.g. on SM8550) seem to leave battmgr at least
partly initialized when exiting the bootloader and loading Linux. Check
if the power supply devices are registered before consuming the battmgr
notifications.

Fixes: b43f7ddc2b7a ("power: supply: qcom_battmgr: Register the power supplies after PDR is up")
Reported-by: Xilin Wu <[email protected]>
Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/power/supply/qcom_battmgr.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
index a12e2a66d516..7d85292eb839 100644
--- a/drivers/power/supply/qcom_battmgr.c
+++ b/drivers/power/supply/qcom_battmgr.c
@@ -1271,6 +1271,10 @@ static void qcom_battmgr_callback(const void *data, size_t len, void *priv)
struct qcom_battmgr *battmgr = priv;
unsigned int opcode = le32_to_cpu(hdr->opcode);

+ /* Ignore the pings that come before Linux cleanly initializes the battmgr stack */
+ if (!battmgr->bat_psy)
+ return;
+
if (opcode == BATTMGR_NOTIFICATION)
qcom_battmgr_notification(battmgr, data, len);
else if (battmgr->variant == QCOM_BATTMGR_SC8280XP)

---
base-commit: 0fef202ac2f8e6d9ad21aead648278f1226b9053
change-id: 20240103-topic-battmgr2-15c17fac6d35

Best regards,
--
Konrad Dybcio <[email protected]>



2024-01-03 12:32:51

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH] power: supply: qcom_battmgr: Register the power supplies after PDR is up

On 3.01.2024 13:32, Konrad Dybcio wrote:
> Commit b43f7ddc2b7a ("power: supply: qcom_battmgr: Register the power
> supplies after PDR is up") moved the devm_power_supply_register() calls
> so that the power supply devices are not registered before we go through
> the entire initialization sequence (power up the ADSP remote processor,
> wait for it to come online, coordinate with userspace..).
>
> Some firmware versions (e.g. on SM8550) seem to leave battmgr at least
> partly initialized when exiting the bootloader and loading Linux. Check
> if the power supply devices are registered before consuming the battmgr
> notifications.
>
> Fixes: b43f7ddc2b7a ("power: supply: qcom_battmgr: Register the power supplies after PDR is up")
> Reported-by: Xilin Wu <[email protected]>
> Signed-off-by: Konrad Dybcio <[email protected]>
> ---
Please ignore, I didn't update the commit title.

Konrad