power: qpnp-bms: Fix SoC being stuck upon resume
There is a problem with soc being stuck upon resuming from sleep.
If report soc is called before calculate soc finished, but after
the soc is unbound, the BMS will try to keep reporting the old soc.
Fix this issue by only setting the unbound soc flag after a new
calculated soc is added. When this flag is set, reported soc can
change by 1% per 20 seconds that it has been asleep. Also, switch
the scale_soc_while_charging function to make use of the RTC so that
the time spent during sleep is counted as catch up time.
Also, protect report soc with mutexes so a race condition does not
invalidate last_soc.
CRs-Fixed: 480859
Change-Id: I05584a30e680401357bd08ed8c3dc89f812520f3
Signed-off-by:
Xiaozhe Shi <xiaozhes@codeaurora.org>
Loading
Please register or sign in to comment