Repository navigation
Conversation
…a dark one The SMC wakes the AP when a charger or a cable comes or goes, and has no mask for it: macOS writes none, and leaves such a wake a dark one. A charger that drops and renegotiates its contract under the sleep's load woke a K116s five times in six hours with the lid closed (wake record USB-C_plug each time). Every one was a full resume, with user space suspending again ten seconds later. Take a wake for acattach, acdetach or USB-C_plug alone as a dark wake when the lid reads closed, as the lid's own closing already is. Signed-off-by: Jens Axboe <axboe@kernel.dk>
apple_sleep_smc_woke_alone() reads the wake status the common wake arming saved, which a SoC with its own wake never fills: on T6050 it is always false, and no wake is ever taken as a dark one. Use the status T6050's wake reads at its start: only the SMC's lines latched, and nothing in the GFX word. Seen on a K116s, where a wake for USB-C_plug alone with the lid closed logged SMC.OutboxNotEmpty as the only source and was still a full wake. Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
Thanks for this series, and for the clear write-up of the charger case and the two options for the fourth commit. On that question, we would prefer the handshake over the timed wait. We avoid sleep or retry loops where a completion or status exists, and two are added in
For the first, giving the saved lane's sleep notice the same reply timeout an atomic command gets (your second option) waits on the SMC's own answer instead of on silence. For the second, The first commit and the T6050 wake-status fix look good to us. If useful, we can run sleep rows on our M1 Pro, M2, M4 Pro and A18 Pro. |
A dark wake suspends again as soon as every device has resumed. The SMC's .prepare then finds a command of the wake still in flight and refuses with -EBUSY: on a K116s, both dark wakes for a charger plugged back in ended that way, and user space took over ten seconds later. Take the mutex and so wait for that command to complete. Signed-off-by: Jens Axboe <axboe@kernel.dk>
The saved lane keeps a log word for the ordinary handler, which echoes
it after the wake. The SMC takes no AP idle notice while a log word is
owed: when it logs inside the committed part of the entry, the notice
times out and the entry panics, past the last step it can undo.
A dark wake that suspends again within two seconds does that on a
K116s, with either kind of log word:
- A charger plugged back in during a sleep, the SMC still logging its
contract. 3 of 9 such runs ended in the panic; in the one with the
lane's packets recorded, eight syslog words had reached it just
before the notice. In a run with eight such words echoed, the SMC
answered the notice in 166 us, as it does in every other sleep.
- Dark wakes in a row with no charger: 3 panics in about 120, with the
syslog words already echoed. The lane held one packet, the OSLOG
counter:
macsmc: sleep notice: AP IDLE: -110 after 817327 us
Kernel panic - not syncing: Apple committed SMC notice failed after
peer stop: -110
Echo a word on the saved lane when the ordinary handler would answer
it with its echo and nothing else: a syslog record's word and the OSLOG
counter. A syslog record echoed there is not printed, as with the words
the receive path acknowledges ahead of the ordered queue.
With both echoed, 200 dark wakes in a row went back to sleep.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
e3ec989 to
07262f5
Compare
|
Ryan, thanks. v2 is pushed. Neither wait survives, and the timeout I offered as the second option was wrong too: with a serial console on the machine I found the cause. What happens After the commit the SMC is read on the saved lane, which keeps a log word for the ordinary handler and does not echo it. The SMC takes no AP idle notice while a log word is owed. A dark wake that suspends again within two seconds has the SMC still logging, so now and then a word lands in the committed part and the notice times out. I saw it with both kinds of log word:
With eight such words echoed on the lane, in another run,
This is the counter v2
The 5 s reply timeout is not in the series and I withdraw it: it raised the wait for SMC key replies, which were never slow. Tests (K116s, firmware 27.2)
The rows by RTC alarm use a test switch that makes each alarm wake a dark one and arms the next alarm; it is not in the series. The charger runs had the debug cable in, so the other machine was a second 5 V source on the port next to the charger's. Without test code and with the syslog echo only: Seen once each in those runs, not fixed here
Yes to the sleep rows on your M1 Pro, M2, M4 Pro and A18 Pro, for commit 1: it changes what a port-only wake with the lid closed does on every board that reports the lid. |
The SMC wakes the AP when a charger or a cable comes or goes, and has no mask for it: macOS writes none and leaves such a wake a dark one. On Linux each is a full resume. A charger that drops and renegotiates its contract under the sleep's load woke a K116s five times in six hours with the lid closed, and user space suspended again ten seconds later each time. This is the series mentioned on #2201.
Four commits, on
integration/aurora:acattach,acdetachorUSB-C_plugalone, with the lid reading closed, sets the dark wake as the lid's own closing already does.apple_sleep_smc_woke_alone()read a wake status that T6050's own wake never fills, so it was always false there and no wake was ever taken as dark. It now uses the status T6050's wake reads..preparewaits out a command in flight. A dark wake suspends again at once and found a command of the wake still running: -EBUSY, and user space took over. It now takes the mutex.What changes on other boards
Testing
K116s, firmware 27.2, on
integration/aurora0abc2f3 + #2201 and my other K116s commits; the K116s needs #2201 to sleep at all. On this base the series is build-tested only.The rows by RTC alarm use a test switch that makes each alarm wake a dark one; it is not in the series. The captures are in the v2 comment below.
Not fixed here, each seen once
wifibt.Not seen: a wake record of
acattachoracdetach(every one wasUSB-C_plug), MagSafe, and a J714s or J716c.checkpatch is clean on all four.