Repository navigation
power: supply: max17042_battery: wait out the alert after a failed read too - #180
Conversation
…ad too The MAX77759 sleep added at the end of max17042_thread_handler() is skipped when the Status read fails: the handler returns early, the oneshot interrupt is unmasked while ALRT is still asserted, and an I2C error during an alert would burst as before. Move the sleep to a common exit, so both paths wait one task period. Tested on a Pixel 7 (7.3.0-rc6), with only this change on top of the kernel it ran before: with the cable out for 15 minutes, seven alerts (RepSOC reaching 99 % on the cable, then six steps down to 93 %) fired the gauge's interrupt once each, as before this change, and the gauge read as before. The failed-read path itself wasn't triggered. Suggested-by: Derek Ross <derekross@gmail.com> Assisted-by: Claude Opus 5.5 Signed-off-by: Alejandro Garcia <skipper.pelygro@gmail.com>
|
@nesmeck thanks for the patch, I ran it on the 8 Pro as you asked on #170. Kernel on the phone: With both patches: 25 minutes, capacity 73 % to 78 % in five 1 % steps, and the interrupt count went up by exactly 5, one per step, under a second after each capacity change. Voltage 4.136 to 4.180 V, temperature 36.2 to 36.3 C, current about +320 to +520 mA, no I2C errors in dmesg. Same phone, same setup, the original module (neither patch): 13 minutes, two steps, 954 interrupts. The first step gave +207 and +280 within one second, the second +344 and +123. So the burst you describe is there without the fix and gone with it. What I didn't test: the failed-read path itself, same as you, I can't trigger an I2C error safely. And these were charging steps: the phone was on the cable for nearly all of it (near the end of the control run the gauge briefly read Discharging, -309 mA, during the second step, with the cable still in, I haven't looked into why), so the discharge steps you ran aren't covered. I can repeat it with the cable out if you want that too. The two logs are in my notes and I can post them. |
|
Thank you, @nesmeck, for sending the common exit so quickly, and @Somnius for the run on the Pixel 8 Pro. A before/after on the same phone and setup is the clearest evidence we could ask for: 954 interrupts over two steps without the fixes, 5 over five steps with both. The change is what I suggested on #170. The failed Status read now goes to the same exit as the normal path, so the MAX77759 waits one task period either way, and the other gauges this driver serves still skip the sleep. Our gate passes on today's Because this touches the Pixel 7 Pro's gauge, I also compared the compiled handler before and after. On the normal path the instructions are identical. The only difference is that the failed-read branch now jumps to the task-period sleep instead of straight to the return. So nothing my phone runs day to day changes, and the new path is one that none of us can trigger safely. I'll still put it on my Pixel 7 Pro with my next push, as our rule for shared drivers asks, and check that a 1 % step still fires the gauge's interrupt once. I'll merge it after that. @Somnius, no need for a cable-out run on my account. @nesmeck's discharge steps on the Pixel 7 cover that direction, on the same gauge. The brief "Discharging" with the cable in during your control run came from the unpatched module, so it's not something this PR has to answer. If it shows up again with the fix loaded, a separate issue would be the right place for it. |
|
Thanks a lot, @Somnius. That's a clean confirmation: five 1 % steps with exactly five interrupts and both patches in, against 954 interrupts in two steps without them, on a different phone and pack. Your charging steps complement my Pixel 7 run, which was unplugged and discharging. Between the two, both directions are covered, so I don't think you need to repeat it with the cable out. About the "Discharging, -309 mA with the cable still in": I saw the same on the Pixel 7, and on mine the cause was the charger's input limit, not the gauge.
So it may be the same effect on the 8 Pro, if the input dropped back to the register's limit while the phone drew more. Reading 0x25/0x87 (bits 1:0: 1 SDP, 2 CDP, 3 DCP) and the charger's input limit would tell. It's unrelated to this patch, though. 🤖 Generated with Claude Code |
Follow-up to #170, as suggested there.
max17042_thread_handler()returned early when the Status read failed, so it skipped the MAX77759's wait. An I2C error during an alert would then unmask the oneshot interrupt while ALRT was still asserted, and the alert would burst as before #170. The read failure now goes to a common exit (goto out), and the MAX77759 sleep sits there, so both paths wait one task period. Nothing else changes: the sleep is still gated onMAXIM_DEVICE_TYPE_MAX77759.Tested on a Pixel 7 (
7.3.0-rc6-omamobile-push1-gd50ff8bdd671): the kernel it ran before, with only this commit added.@Somnius, as you offered on #170: a run on the Pixel 8 Pro would be very welcome (the interrupt count per 1 % step, with the gauge readings unchanged).
Checks:
tools/kernel-pr-check --build OUT --merge origin/omamobilepasses everything:🤖 Generated with Claude Code