Skip to content

Conversation

tomaszduda23
Copy link

The fuel gauge SRAM may become ready during the suspend-to-resume transition. In this case, the system can enter standby before SRAM is ready, and the mem-avail interrupt will never fire. As a result, the driver misses the readiness event and its state becomes inconsistent.

Ensure that the SRAM is ready before suspending to avoid this issue.

A theoretical race condition may still exist, depending on the suspend ordering of related drivers, but this change prevents the common case of missed readiness.

@barni2000 barni2000 requested a review from vldly August 29, 2025 19:45
Copy link
Member

@barni2000 barni2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove [PATCH] from the commit title and please add Signed-off-by:
git commit -s --amend

@tomaszduda23 tomaszduda23 changed the title [PATCH] qcom_fg: handle SRAM readiness across suspend/resume qcom_fg: handle SRAM readiness across suspend/resume Aug 29, 2025
@minlexx
Copy link

minlexx commented Aug 30, 2025

If this driver was taken from 8996 kernel, maybe it should be sent to 8996 kernel repo, where we all can then sync it from again..?

@barni2000
Copy link
Member

If this driver was taken from 8996 kernel, maybe it should be sent to 8996 kernel repo, where we all can then sync it from again..?

8996 was get it from sdm845 so it should be sent back there maybe.
I have updated the driver from the sdm845 repo https://github.com/msm8953-mainline/linux/commits/barni2000/6.16.3/upgrade_fg/drivers/power/supply/qcom_fg.c

vldly
vldly previously requested changes Aug 31, 2025
@tomaszduda23
Copy link
Author

there is another fix qcom_fg.PATCH.
It requires

+static int qcom_fg_suspend(struct device *dev)
+{
+       struct qcom_fg_chip *chip = dev_get_drvdata(dev);
+
+       mutex_lock(&chip->lock);
+       chip->suspended = true;
+       mutex_unlock(&chip->lock);
+       flush_delayed_work(&chip->sram_release_access_work);
+
+       return 0;
+}

…mption-proof

power: supply: qcom_fg: simplify synchronization for SRAM accesses

The fuel gauge SRAM may become ready during the suspend-to-resume
transition. In this case, the system can enter standby before SRAM is
ready, and the mem-avail interrupt will never fire. As a result, the
driver misses the readiness event and its state becomes inconsistent.

Introduce single mutex lock to ensure no races occur between release
work thread. Additionally ensure that SRAM access is released before
system is suspended.

Signed-off-by: Tomasz Duda <[email protected]>
Signed-off-by: Vladimir Lypak <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants