Repository navigation
Conversation
|
Tested on my 8 Pro tonight. I built the charger module with this commit on top of the one already on the phone (same release,
Still a draft until it runs a few more charges, but the CHGIN part does what it says. |
derekross
left a comment
There was a problem hiding this comment.
Thanks, Lef. The 26,061 to 2 result is a good first sign, and it's useful that the description says exactly what wasn't measured.
One thing before this leaves draft: max77759_charger is also my 7 Pro's charger driver, and as written the new CHGIN handler and its wakeup source apply on every board that has the MAX77759, the 7 Pro, the Pixel 7 and akita included. I haven't seen a CHGIN storm on the 7 Pro, and the cause on your 8 Pro isn't known yet, so I'd rather this sat behind husky's board data, the per-board table the charger already has. If you think the 7 Pro needs it too, say why and I'll run it on mine first.
Two notes for the next round, not conditions. A read of CHG_DETAILS_00 while CHGIN bounces would tell whether the input really drops near the end of the charge or the interrupt fires without a change, which decides whether a debounce is the fix. And since your evidence charge was at the 4.45 V float, the follow-up at the published float would show whether it happens there at all.
On one husky boot the CHGIN interrupt fired about 26000 times, going by the unit start times nearly all near the end of a charge from a desktop USB port, while the battery kept charging at 333-500 mA. Why CHGIN bounced is not known yet. Each edge calls power_supply_changed(), and udev started a oneshot unit nearly 7000 times (up to about 10 a second, per-minute average). Send CHGIN through a delayed work that is queued only when it is not already pending: at most one power_supply_changed() a second, and the last state still goes out within a second. A real plug or unplug now reaches userspace about a second later. The driver holds a wakeup source of its own for 2 s from each CHGIN edge, so a change need not wait for the next resume. The psy's own wakeup source is not used, as the power supply core takes and drops it on its own. The other interrupts are unchanged. Signed-off-by: Lef <me@lefteros.com>
The CHGIN storm has only been seen on husky, and its cause is not known yet, so the debounce should not change the 7 Pro, the Pixel 7 or akita. Add a chgin_debounce flag to the per-board guard table and set it only in husky's. The guard table is now picked before the CHGIN work and wakeup source are set up, and both are set up only when the flag is on. On every other board CHGIN goes through irq_handler() and no wakeup source is registered, as before the debounce. Add a KUnit case that checks the flag is on for husky and off in the default table. Signed-off-by: Lef <me@lefteros.com>
83f0519 to
6cf1884
Compare
|
Fixed, thanks. The debounce is husky only now. I added a I don't have a reason to think the 7 Pro needs it, so I left it off there. Tested: the charger object builds clean with W=1 (clang, arm64), with and without On your two notes, both are fair and neither is done yet. I don't have a |
derekross
left a comment
There was a problem hiding this comment.
Thanks, Lef, that's the gate I asked for: on every board but husky, CHGIN goes through irq_handler() as before and no wakeup source is registered, and the teardown order is right.
One thing before it leaves draft: the gate is a second commit, and kernel PRs land commit by commit, so the first commit would sit on omamobile with the debounce on for every board, the 7 Pro included. Please fold the gate into the first commit, so the debounce arrives husky-only in one step.
And as you say, the attended charge at the published float with CHG_DETAILS_00 logged on each edge decides whether a debounce is the right fix. Small thing for the message: the wakeup source doesn't stop a logind suspend (only wakeup_count users see it), so "need not wait for the next resume" says a bit more than it does. It also conflicts with #277 and #267 at one line in probe; keep #277's stop_last line after guard_band = -2.
Draft for now, I haven't run this on the phone yet. It's built and tested on the desktop only.
On one 8 Pro boot the charger's CHGIN interrupt fired 26 061 times (irq
max77759-charger.2.auto:CHGINin/proc/interrupts), going by the unit start times almost all near the end of a charge from a desktop USB port (/proc/interruptsis only a per-boot total). The battery kept charging the whole time (+333 to 500 mA, status Charging), butonlineread 0 for about 11 minutes. Every CHGIN edge callspower_supply_changed(), and our udev rule in omamobile startedomamobile-charge-limit-apply.service6 968 times that boot, peaking around 10 a second (per-minute average). The SoC went from 53-54 C to 57-59 C over the same window and came back after. That's only a timing match, I didn't measure CPU per process.The other charger IRQs stayed small (AICL 156, CHG 174, DONE 1). Why CHGIN bounced is still unknown: I didn't read CHG_DETAILS_00 during the window. That needs a logged charge from the same port, and that's next.
What this does: CHGIN now goes through a delayed work that's only queued when it isn't already pending. So at most one
power_supply_changed()a second from CHGIN, and the last state still goes out within a second. The downside is that a real plug or unplug reaches userspace about 1 s later from CHGIN (another charger IRQ in the meantime can still report sooner). The other IRQs are unchanged. The driver holds its own wakeup source for 2 s from each edge, so a change shouldn't have to wait for the next resume (that only blocks suspend when userspace uses wakeup_count or autosleep, the same limit as the power supply core's own hold, and it's untested). I didn't use the psy's wakeup source because the power supply core takes and drops it on its own and it doesn't nest. The work is set up before the IRQs, so devm frees the IRQs first, then cancels the work, then drops the wakeup source.It doesn't change what
onlinereports. If the input really is at the edge, debouncingonlineitself would be a separate patch.The numbers came from my test kernel, which carries our charger series plus test-only patches, and that charge ran at a raised 4.45 V float (the run from derekross/omamobile#761 (comment)). So I can't say yet whether it happens at the stock float. The grey band is where
onlineread 0:This patch is on
omamobileand doesn't depend on #265, #266, #267 or #277. It merges cleanly with each of them:#265
#266
#267
#277
Tested:
max77759_charger.oon this branch: arm64 defconfig withCHARGER_MAX77759=m, clang r547379, LLVM=1, no warningscheckpatch.pl --strict: cleanomamobilehas no KUnit test for this driver yet (it comes with power: supply: max77759: add a guard table per board and one for husky #265), so I ran KUnit on power: supply: max77759: Pixel 8 Pro charge defender and husky float restore #277's head plus this patch: 37/37 pass. Those tests cover the guard, not the IRQ path.Not tested: anything on the phone. The check there is one charge from the same port with
/proc/interruptsand audevadm monitorcount, plus a plug/unplug to see the 1 s delay.The userspace side (start the unit on add only, keep systemd's start limit) is a separate omamobile PR: derekross/omamobile#1068