Repository navigation
Conversation
This was referenced Nov 14, 2026
The T6040 part had a copy of the generic driver's PMU register write over the SPMI controller's AP queue, with a test for the mapping in front. Move the write to the private header, on the controller's base and with the PMU's USID as an argument, and call it from both. The device accesses, their order and the reply poll are the same in both. The compiler now keeps the controller's base in a register where it used to load it again from the driver's state after each access, so the two commit functions are a few loads shorter. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The T6040 part had copies of the two helpers that take a window and its tunable table from the node a loader fills for the storage PCIe block. Let the generic driver's pair take the device instead of its own state, declare it in the private header and use it from the part. Both run at probe only. The windows, the tunable properties and the order they are taken in are the same for the T8140 and for the T6040. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The file's opening comment still explained why the T6040 controller was a driver of its own next to the generic one, and several comments named functions the generic driver no longer has. Describe the part as it is now, with suspend-to-RAM offered only to a system booted with t6040_sleep.allow_entry=1, name the generic driver's functions, and say in sleep.c that a SoC may bring a part. List the private header next to the driver's sources. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The drivers/soc/apple/sleep-t6040.c part of "soc: apple: sleep: t6040, drm: apple: say what the wake leaves undone", which goes with the sleep controller changes; the rest of that commit is with the display changes. Four comments still read as open work: a register of each CPU complex that could be written at the wake, the energy accumulators that could be set again, and the conditional retention of the display domains. The J616s wakes with all 14 CPUs and its displays without them. Say what could be done there, that this driver does not, and what was measured. The comment over the display power words also described a device tree without the apple,display-power node as the present state; the boot object publishes it. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…e and the WD2 arm The T6040 part still had its own copies of three helpers the T8140 sequences have as well: raising a power word (the target, then AUTO_ENABLE once it reads on), writing a tunable table only where a word changes, and arming WD2. Each pair was the same statements on a different base pointer. Keep one inline copy of each in sleep-internal.h and call it from both. No access, value or order changes on either SoC; the compiler inlines them differently into their callers than before. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…uest A comment on the wake stub still pointed at the T8132 one by a pull request number. Name the stub. No functional change. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The S2R state printed at debug level reads the hardware S2R-lo entry counter in MiniPMGR. It was mapped and unmapped around each read, and one caller is the dry run at the commit point, which runs with interrupts off and one CPU up: ioremap() and iounmap() may sleep there. Map the counter once at probe with the other fixed windows and read it through that mapping. The registers read and their order are the same; the dry run no longer maps or unmaps anything. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The refusal log of .begin said whether the device tree has an s2r-mailbox property, while the blocker count asks whether a mailbox with the boot object's magic is mapped. After a bad magic, or a mailbox dropped at a hibernation restore, the log read "s2r-mailbox yes" next to the blocker it counted. Log the mapped mailbox. Its comment spoke of interrupts being off; its only caller is .begin. When the first regmap read of a display CPU word fails, the warning printed the polled value uninitialised: start it at 0. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The PM core reaches .begin and .enter of a suspend to RAM only after .valid accepted the state (sleep_state_supported(), on every path into suspend_devices_and_enter()), and .valid accepts it only with allow_entry, a read-only parameter. .begin still tested allow_entry, and .enter tested it again together with apple_sleep_power_loss(), which is true on the one path that reaches it: dry run level 0 after .begin set pm_suspend_via_firmware(). Drop the three tests. Say in the comments that a dry run, a suspend to RAM as well, needs allow_entry too, so the CPU power ops registered at probe cover it; .begin only tries again if that registration failed. No register access changes. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…dd nothing - struct t6040_sleep_watch.name was written at probe and never read. - ans_bridge_quiesced kept whether the commit found ANS's fabric bridge armed, only for one debug line after the wake. The bridge is still quiesced as before; t6040_ans_bridge_quiesce() returns nothing. - t6040_sleep_total_blockers() was a one-line wrapper with one caller. - t6040_tunable_apply_changed() tested for a NULL table that cannot be NULL there: the storage PCIe raise runs only with apcie_st.valid, which requires both PHY-IP tables. - The BUILD_BUG_ON() on the size of t6040_axi2af[] compared the array with the size it was declared with. Size the array by its initialiser, so that the check catches a missing or extra domain. No register access changes. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…light The preflight mapped the PMP's PTD block (68 KiB) and the DART's GAPF block at probe only to print six of their registers, under offsets with no names. Both blocks belong to other drivers, which can show their own state. Drop the two windows and their lines; nothing on the sleep path used them. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The T6040 part defined the GP PCIe port and PHY registers a second time under GP_* names, with the values of the APCIE_PORT_* and APCIE_PHY_CTRL_* definitions it already shares with the T8140 sequences: the same port block. Use the shared names, and add the port status register and its ready bit (+0x804 bit 0, PORT_STATUS in pcie-apple.c) next to them. Bit 11 of a power word had three names (PS_BUSY in both files, PS_PARENT_MISSING in sleep.c, SOC_EAST_PARENT_MISSING here), bit 12 two (PS_UNLATCH, PS_RESET_REQ) and bit 10 two (PS_DEV_DISABLE, SOC_EAST_DEV_DISABLE). Keep one each in sleep-internal.h; bit 11 is PS_BUSY, as the PMGR power state driver calls it. No functional change: both objects are unchanged. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Give the numbers of the T6040 part their names: the power word's active state 0xf and minimum state field 19:16 (PS_ACTIVE, PS_MIN, as in the PMGR power state driver, now in sleep-internal.h; the AGX gate's "level" field is the same PS_MIN), the clock-gated words the commit writes, the keep-alive bit, the DCS dynamic power gate bits, the ATC PHY sleep entry registers, the PCIe clock generator bits that already had names, dart-dcp's transaction count field, and PS_STRIDE where the stride was spelled 8. Loops over the DCS, ATC and GP port windows are bounded by the arrays they walk. The masks written as hexadecimal literals (0xeffffcff, 0xfffffcf0 | 0x300) and the (x & ~M) | M forms become the expressions they stand for. No functional change: the object is unchanged. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
- The AGX gate, quiesce timeout, FAB2_SOC, WDT address and display CPU gate definitions sat between unrelated blocks or next to their first use; put each with its block. - The clock quiesce had two block comments and the CPM voters' "not written on entry" note two copies; keep one of each. - The comment on ANS's storage link quiesce floated above another function under an "ENTRY:" label; put it on the function it describes. The wake return repeated the storage link raise's own comment; refer to it instead. - Index the axi2af domain table with an enum and designated initialisers, instead of three bare positions. - The external debug blocks use the CPU's cluster and core helpers and the cluster table's size. - Move the preflight below the function it calls, so that the forward declaration goes. No functional change: the object is unchanged. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The driver's state was "sleep" in some functions and "s" in the others, where a seq_file was "s" too. Call the state "s" and the seq_file "m" throughout. No functional change. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Steps on one block were named both t6040_sleep_<verb>_<block>() and t6040_<block>_<verb>(). Keep t6040_sleep_* for the driver's own frame (suspend operations, probe, mapping, blockers, the commit and the wake return) and name each step on a block t6040_<block>_<verb>(), as most of them already were. No functional change: the object is unchanged but for the symbol names. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The T6040 part printed 37 messages with pr_*() and a hand-written "t6040-sleep: " prefix, next to dev_*() messages that print as "apple-sleep <node>:". One driver had two prefixes. dev_*() allocates nothing either, and the T8140 sequences use it at the same points. Print every message through dev_*() with the driver's device. Only the log call sites change. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
… code - cluster-ctl has five words, not three: the CPU complexes and the internal and external display's complexes, which the commit polls; +0xc is one of them, not a status word. - The wake does not poll the complexes, and puts the display complexes back to the nibble the commit found. - The GP PCIe host is not left to cold-recover: the commit stops its ports and the wake restores their clocks. - The summary of the wake return omitted the stopped CPUs, the AIC, the keep-alive bits and WD2, and spoke of three complexes. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Several comments explained a step by how it was found: register map names of another driver, a boot argument, the structure of another operating system's routines, register values read at one point in time, and what went wrong on a board before the step was there. Say instead what the hardware expects and what happens without the step, in the present tense, and drop the capitals used for emphasis. The warning on a busy SOC-East retention word names the bit as the code now does. No functional change. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Sort the includes, include what is used (linux/cpumask.h, linux/device.h, linux/cacheflush.h) instead of linux/cpu.h, linux/slab.h, linux/smp.h and asm/cacheflush.h, and fix what checkpatch --strict reports: block comment style, lines over 100 columns, a missing blank line, two multiple assignments, an alignment and a line ending in an open parenthesis. Left as they are: udelay() in atomic context, the SMC key name pmVC, and the extern of the wake entry, which goes with the entry itself. No functional change: the object is unchanged. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Whether .begin started a suspend to RAM was a file-scope variable, declared in the middle of the file. Keep it in struct t6040_sleep with the rest of the driver's state. No functional change. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The comments on the hibernation callbacks retold how the restore came
about ("our restored state", "the upstream teardown") instead of what
the SMC needs, and the two WKTP comments named power management
settings and constants, quoted an SMC log line and cited a measurement.
Say what each step is for: the SMC keeps running while the image is
written, the boot that loads the image restarts it, and the restore
resets the transport and repeats the probe handshake. For WKTP, say
which value goes when and what the SMC does without the 0.
Comments only, no functional change.
Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
<linux/suspend.h> was included twice. apple_smc_freeze() tested the driver data for NULL, but PM callbacks run only on a bound device, whose probe has set it. No functional change. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
apple_smc_restore() is a PM callback, not a probe: dev_err_probe() there would record a deferral reason against a bound device, and its five messages had no trailing newline. Print them with dev_err() and the error code, and return the error as before. No functional change beyond the log text. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The hibernation callbacks, the PM notifier and its registration sat in three #ifdef CONFIG_HIBERNATION blocks, with forward declarations only because the notifier was defined after probe. Define the notifier before probe, register it under IS_ENABLED(CONFIG_HIBERNATION), and set the callbacks with pm_sleep_ptr() like the others, so that every configuration compiles the same code. Without CONFIG_HIBERNATION the PM core never calls .freeze, .thaw, .poweroff or .restore, and pm_hibernate_is_restored() is false there. With it the object code is unchanged. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Every power-off and reboot printed its progress at KERN_EMERG, and the reboot notifier added a line about the PMU flag cell. Print the request at info level again, a refused off1 attempt as a warning, the final failure as an error and the accepted off1 at debug level, and drop the PMU flag line. An accepted off1 that does not cut the power still ends in the WARN after 5 s. Only log calls change. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
aic_sleep_init() returns before register_syscore() when the IRQ_CFG buffer could not be allocated, so the test of that buffer guarding the registration was always true, and the same test in aic_syscore_suspend() never so. The comment on the registration also claimed a resume from disk resyncs the masks on every SoC, while the syscore is registered only where the sleep save is set up. Drop both tests and the comment. The registration and the save are unchanged. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Five comments told the wake's writes step by step. Say what the block needs instead: the global word has to be back before the pins, a pin takes its word in three writes after a power loss, and a block that loses every pin is saved whole except the reserved pins. Comments only, no functional change. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The DCP's hibernation notifier handles the end of a restore and of an aborted hibernation, but not PM_RESTORE_PREPARE, and nothing says why. The restored kernel rebuilds its firmware session on the DCP firmware state the boot loader left for it. A kernel that loads an image with this driver bound would have started the DCP itself and left it in a different state. Refusing the restore here would block a resume that the boot kernel does not need to be stopped from, and cannot be exercised without a restore, so only the requirement is written down. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The T6040 PHY exported its tunnel pixel clock as apple_atc_dp_tunnel_rate() only when phy-apple-atc is not built. With both PHY drivers in one kernel the T6040 tunnel had no provider: the ATC driver's symbol refuses a PHY that is not its own, so the clock of a Thunderbolt DisplayPort tunnel was never started. Export apple_t6040_dp_tunnel_rate() unconditionally, as for T6050, and let the display fabric call it on T6040 and T6041 for the clock, and for the stop of a split tunnel. The rate call starts everything there, so the separate "open" step is left out on those SoCs. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The warm restart of the internal and of an external display processor repeat the same first half: the idled firmware is returned through the power-cycled return, its AFK endpoints are started again and the framebuffer's hard power state is put back on. Move that half into one helper; both callers keep their own preparation before it and their own steps after it, in the same order. dcp_hib_recommit() carried the whole recommit in one function of about ninety lines. Split it into the power-on step, the case of a CRTC that is off and the case of a CRTC that is on. The modeset locking and the retry stay in the caller, the power-on is made once per call as before. No change in behaviour. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
iomfb.c names nothing from linux/clk.h, linux/iommu.h, linux/kref.h or linux/soc/apple/dp-tunnel.h. Drop them. The object file is identical before and after. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…an error The drivers/gpu/drm/apple/dcp.c part of "soc: apple: rtkit: report an idle that kept the firmware's memory apart from an error", which goes with the display changes; the rest of that commit is with the hibernation core changes. A co-processor may acknowledge the idle request of its IOP side with a power state other than idle (the low byte 1 or 2): it is asleep with its firmware and memory kept, which is what the caller wants after the AP side has idled. apple_rtkit_idle() returned -EINVAL for it, the same value as a bad argument or a stale state, and the display driver had to accept -EINVAL as success. Return APPLE_RTKIT_IDLE_RETAINED (-EALREADY) for exactly that acknowledgment. Timeouts and failures of the AP side are returned as before. Every other caller of apple_rtkit_idle(), apple_rtkit_idle_with() and apple_rtkit_sleep_stop() treats any non-zero value as a failure and only forwards or prints it, so for them only the printed number changes. The display driver now accepts the new value instead of -EINVAL and fails on any other error, -EINVAL from the transport included. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The host test extracts dcp_route_clock_rate() from the display fabric and builds it on its own. The fabric now calls the T6040 PHY's own tunnel clock symbol on T6040 and T6041, so the test needs that helper and a model of the symbol. Extract dcp_fabric_t6040_tunnel_clock() with the other fabric functions, stub apple_t6040_dp_tunnel_rate() and add a case that runs both machines through DP IN 0 and 1: the rate reaches the T6040 symbol with the right adapter, neither the ATC nor the T6050 provider is called, and a clock that fails to start leaves the route's rate alone. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The DP-to-HDMI converter's rails are SMC GPIOs that outlive a kernel, so the first probe looks at whether the converter was left powered and power-cycles it once. That check is per machine on purpose: struct apple_dcp is allocated again by every probe attempt, so a flag kept in it would let a deferred probe power-cycle a converter the attempt before had just powered, costing 250 ms and a second log line. Document that ownership at the flag and make the test-and-set atomic, so that two probes of the same machine cannot both take the first look. The sequence is otherwise unchanged. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
hdmi_converter_fresh records that the DP-to-HDMI converter was just
powered up for a link, so the next link start takes it as it is. It is
written by dcp_hdmi_converter_power() and by the connect path, and read
by the connect path, with different locking:
writer context hpd_mutex
dcp_hdmi_converter_power(false), unplug HPD irq thread not held
dcp_hdmi_converter_power(false), sleep sleep path not held,
HPD irq disabled
dcp_hdmi_converter_power(true), relink resume path not held,
HPD irq disabled
dcp_hdmi_converter_power(true), connect connect path held
clear after the check, connect connect path held
reader: test before powering, connect connect path held
The sleep and relink writers cannot overlap the HPD irq thread, which is
disabled (and so synchronised) around them. The unplug write can overlap
a connect in another context, so the flag was accessed concurrently
without a lock.
Taking hpd_mutex in dcp_hdmi_converter_power() is not an option: the
connect path calls it with the mutex held, and the function sleeps up to
450 ms (250 ms power-off, 100 ms settle) with the converter rails. The flag
is a single bool whose users order themselves by the callers above, so
mark every access with READ_ONCE() and WRITE_ONCE(). The generated code
is identical to before; HDMI behaviour does not change.
Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…ation The drivers/gpu/drm/apple/dcp.c part of "soc: apple: drop the restore callbacks' checks for an abandoned hibernation", which goes with the display changes; the rest of that commit is with the sleep controller changes. An abandoned hibernation resumed its devices with PMSG_RESTORE, so every restore callback that must not act on a state it never lost began with a pm_hibernate_is_restored() check, and most forwarded to their thaw. The PM core now sends PMSG_RECOVER there, which reaches the thaw callbacks, so the check and the forward go from macsmc, the RTKit helper, apple-dart, the sn201202x Type-C controller, the SPMI, GPIO and NVMe restore paths, both PCIe restore callbacks, the DCP and AOP restores, the t6040 USB2 PHY's two and the RTC; cs42l84's restore passes that the codec lost its state. Each callback runs for a restored kernel exactly as before. For an abandoned hibernation the old path was already the thaw or nothing, and the thaw now runs on its own: macsmc, the RTKit helper, apple-dart, sn201202x, NVMe and cs42l84 forwarded to the same function (cs42l84's resume asks pm_resume_via_firmware(), which hibernation_snapshot() has cleared); PCIe's restore_noirq did for a bridge without hibernation tunnelling what its thaw_noirq does, and the same call with it; the AOP, t6040, RTC, GPIO and SPMI restores did nothing and have no thaw. DCP keeps its power-off-failed branch (PMSG_RESTORE after a failed platform power-off, which only a platform with hibernation ops reaches) and loses the abandoned one, whose only other effect was a log line. One path changes: macsmc's thaw, after the SMC was handed over and the image could not be entered, calls apple_smc_restore() to start a new session, and its own check sent that back to the thaw, which did nothing. It now starts the session as the comment says it should. The flag keeps its other users, which are not restore callbacks: the AIC syscore resume, the dockchannel receive interrupt, the SEP's PM notifier. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…em is back After a suspend-to-RAM the fixed HDMI output of a desktop 26.x processor is connected again from the restart work while the DRM resume sets the modes on the same processor. When the converter has not found its sink yet, the link was released and connected again up to three times right there, each connection waiting up to 2 s for its configuration, and the DRM resume waited behind it: "resume of devices" took 4.96-5.00 s instead of 3.2 s on the J616s with an HDMI and a DP display. Run those starts from a freezable work item when the link is set up again after a sleep, so they come once the system is back. A mutex keeps them apart from the starts of the HPD interrupt, and every path that stops the link (suspend-to-idle, the prepare of a hibernation or a T6040 suspend-to-RAM, unbind, remove) cancels a pending one first. The first connection stays where it was, so the order in which the external processors connect after a sleep does not change. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Drain the GPU before the hibernation image and boot its firmware again after resume; keep the G17 firmware objects that must be rebuilt after a cold restart. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The sleep path reads and writes the GPU's PMGR power-state word, found as
the first power-domains entry and its parent's syscon. On T6041 that
entry is the PMP report entry pmp-gfx, whose own domain is the PMGR's
gfx word: the lookup took the report node and its parent, which is no
syscon, so every call failed with -EPROBE_DEFER. The sleep's lowering
was skipped quietly, and the wake gave up on the GPU at its first step
("GPU firmware did not come back: Error(517)", every real T6040 S2R).
Follow a non-PMGR entry's own power-domains, at most two hops, to the
PMGR state word.
Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…e other steps asahi_g17_commit_prepare() still took power-domains[0] as the PMGR state word. On T6040 that is the PMP report entry pmp-gfx, so the commit stop mapped the PMP report region at the entry's index (0xd) and, with commit_lower_ps set, would have lowered a word in it instead of the GPU's domain. Share the lookup that follows the entry down to the PMGR word with the regmap steps, and fix its comment: the entry stands in front of the word on T6040, not on T6041. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The commit stop reads the GPU's PMGR word only when it lowers the domain (commit_lower_ps), yet asahi_g17_commit_finish() handed its saved copy back whenever the stop ran. With the parameter off that copy was 0, and the raise after the wake restored neither the automatic power state nor its enable: the GPU's domain stayed forced on after every S2R. Read the word when the commit is prepared; the stop still reads it again right before it lowers the domain. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…ntry The GPU withdraws its PMP request in its own stop (at the sleep's commit, after the firmware idled) and makes it again after the raise, for the entry apple,pmp-report-entry names. T6040 has no such property: its GPU's power domain is the entry pmp-gfx itself. The request was then never marked as withdrawn by the commit, so the PMP report's sleep withdrew it in the noirq phase while the GPU firmware still ran, before its stop. Use the power domain when it is a PMP v2 report entry and the property is absent. Only T6040 has the GPU behind such an entry. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…7 GPU The hibernation gate had two module parameters: hibernate_republish could refuse hibernation with a G17 GPU bound, and hibernate_cold_init allowed it, and the restore of an image, with a GPU that has no restore path. The gate now always does what their defaults did: a GPU with a restore path lets the system hibernate, any other bound GPU refuses it, and an image is never restored while a GPU is bound. The GPU's stop at the sleep's commit left a progress mark with the sleep controller after each step. The marks are off by default: drop them. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
… entry is its domain The series had put the commit stop's last step, lowering the GPU's PMGR word and its bridge, behind a parameter that was off by default. That skipped it on the T8140 too, where it is the GPU driver's to do. Decide it from the device tree instead. Where the GPU's power domain is the PMP's report entry itself (T6040), the sleep controller lowers the word behind the entry in its own commit and the GPU's stop ends with the withdrawn request. Where the entry is only named next to a PMGR domain (T8140), the stop lowers the word and the bridge as before the series. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The hibernation drain (priority 20) runs ahead of the PMP's notifier (10) and of both display notifiers, the global one (10) and the per-device one (-5); the comment named only one of them. Pass the hibernate callback to the bound/unbound counters as a truth value without comparing it to NULL, and separate the PMP report shim from the function above it with a blank line, as checkpatch asks. No functional change. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The kick ring reset cited an observation, the T6040 sleep_restart flag argued from T8140, and the doc comment of coprocessors_halted() had been fused into that of firmware_cold(). State what the firmware does, and give each function its own doc comment. Comments only. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…lace The render and the compute kick queue return their ring to the state of a freshly installed queue after the GPU firmware was cold-restarted across a hibernation by two functions with the same body: they differ only in a check that the queue has the engine of its type. That check can not fail: the engine of a kick queue is fixed when it is built, and the constructors for the two types refuse the other engine. Replace both functions by one that clears the ring, restarts the timestamp and drops the parent, in the same order as before. Hardware test: resume from disk (S4 round trip) with a render and a compute client holding queues across the hibernation; both must submit their first job after the resume without a timeout. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The wait for the PMP to take the held power state requests after a resume from hibernation is a one-line wrapper around the PMP report call. It sat in the CLPC wrapper file, next to the performance controller calls that it has nothing to do with. Move it to the file that already holds the GPU's PMP request and the sleep-time power state word. The symbol keeps its name and its behaviour. Hardware test: none for behaviour (same call, same arguments); a resume from disk shows the "PMP requests acknowledged" line as before. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The statistics sysfs shim also owned the hibernation gate, the G17 drain notifier and the G17 statistics and thaw notifier, registered from the probe of each device. Move them into g17/hibernate.c, next to the other G17 sleep code, and register the gate once at module load instead of when the first device binds. The chain is the same for every event: - gate, priority 30: refuses hibernation with an unrestorable GPU bound and refuses restoring an image with any GPU bound. With no device bound it does nothing, so keeping it registered from module load to unload changes no outcome. Registering it can no longer fail at probe time. - G17 drain, priority 20, registered per device ahead of the display and PMP notifiers. - G17 statistics epoch and thaw, priority -10, below the PMP restore. Per device they are still registered before the gate counts the device and unregistered after it stops counting it, and the notifier bodies are unchanged. The priorities are named in one place. Hardware test: S4 round trip (drain at hibernate, cold republish after the resume, "GPU firmware republished after resume" in the log), a refused hibernation path (a PM_HIBERNATION_PREPARE failure after the GPU drain, for example by a failing later notifier, must reopen submission), S2R (statistics resume), and unloading and reloading the aurora module. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
After a hibernation image is restored, the republish walked every GPU page table it knows (the kernel VMs, the global render VM and every live execution context) and cleaned each table page and each RAM page the tables map to the point of coherency, for a UAT walker and firmware that do not snoop the CPU caches. With large client mappings that took about one second of every resume (25 GiB in 1.04 s on a J616s). The arm64 restore already cleans every page it loaded to the point of coherency before it jumps to the restored kernel: the pages loaded in place through swsusp_clean_restored_image(), the ones that go through the restore_pblist copy in the copy loop itself. Those cover every page table and every page they map. The walk was kept as a second guard for a restore that only cleans to the point of unification; the image is restored by the same kernel, so that restore does not exist here. Drop the walk with the per-context VM references it needed. What is not in the image (the no-map handoff region and the TTBAT) is still rewritten from host state and cleaned as before. Hardware test: resume from disk with a Vulkan render and a Vulkan compute client running across it; both continue without an error and no GPU fault is logged. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…ifier After a resume from disk the boot loader has cold-restarted the GPU firmware and the PMP. The PM_POST_HIBERNATION notifier re-booted the firmware against the restored host state with the device mutex held, and that includes waiting for the PMP to run again, about two seconds after its restore. The notifier, and hibernate() with it, returned only after the whole re-boot (2.5 s measured on the M4 Pro). Run the re-boot in a work item instead and let the notifier return at once. Userspace is already thawed when the notifier runs, so the mutex alone cannot keep the cold firmware out of sight once the notifier drops it. Give the device lock a restore barrier: the notifier closes it with the mutex held, and the lock does not return while it is closed (it waits on a condition variable, which releases the mutex). Only the restore work takes the mutex past the barrier; it opens the barrier with the mutex held when the re-boot ends, on success and on failure, and the end of the thaw (destroying queues the cold firmware never knew, reopening publication, or losing the device) then runs as before. Every locker (admission, the event worker, runtime PM, sysfs and debugfs readers) waits for the re-boot exactly as it waited for the mutex before. A new sleep, freeze or image restore waits for the restore work first (its PM_*_PREPARE notifiers flush it), and so does device shutdown, which also opens a barrier left by a restore cancelled before it ran and loses the device. The statistics epoch the PM_POST_HIBERNATION notifier ends is ended by the restore work while it runs. The barrier is closed only on the cold path: a firmware that kept running (aborted hibernation, failed image write) is still thawed in the notifier, and an image restore does not thaw at all. Hardware test: with vkcube and a Vulkan compute loop running, hibernate and resume; dmesg shows "GPU firmware cold after resume; re-booting it" and the PM core's "hibernation exit" before "GPU firmware republished after resume in N ms", both clients continue, and reads of /sys/bus/platform/devices/28a600000.gpu/agx_stats during the first two seconds return once the re-boot ends. Then hibernate again through systemd right after a resume (it starts about 15 s later), and suspend to RAM once: both start only after the republish line and resume with the clients running. Open: a hibernation requested while the re-boot still runs (within about 2.5 s of the resume, which the systemd path does not reach) waits for the restore work as intended, but that re-boot then fails with -EBUSY and the device is lost. Fixed by "drm/asahi: g17: take the compute channel claim through the preparation gate" later in this series. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…tion A republish of the GPU firmware after a resume from disk that fails loses the device with one line, "GPU firmware republish after resume failed: Error(16)", and nothing says which of its steps returned the error. Several of them can return EBUSY. Log the step that failed: the mailbox and shared-content resets, the fabric bridge, the coprocessor start, the kernel-window relink, the opening handshake, and the compute, render and closed-context resets of the live work. No functional change. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…n gate A compute command whose owner's channel is already bound and installed is claimed in the scheduler's readiness check under the channel's own lock only. Every other builder and publisher enters the preparation gate first, which a hibernation freeze and a firmware recovery close and join. After a resume from disk the gate stays closed until the cold firmware has been republished, but this claim ignored it: a client that prepared a command in that window claimed its channel, and the cold reset of the compute queues then refused the claimed queue with -EBUSY, losing the device. It showed with a Vulkan compute client running while a second hibernation was requested right after the first resume: GPU republish: compute queue reset failed: Error(16) Take the claim under a preparation lease (Gate::admit_claim): a closed gate refuses it, and the command waits for the reopen as on the slow path; a freeze that closes the gate while a claim is being taken joins it before it checks that the queues are quiescent. Add KUnit cases for the claim admission. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
fbalazsy
force-pushed
the
j616s/split-gpu
branch
from
November 14, 2026 18:46
13cefb9 to
a05f8d4
Compare
Contributor
Author
|
Closing: this stack is based on integration/aurora from 2026-11-14 and now conflicts with the sleep and spin-table work that landed since. I will rework the J616s (T6040) support on top of the current tree and open a new, smaller series. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 8/9 of the split of #1477 into smaller pull requests. Depends on #1914: GitHub cannot stack pull requests from a fork, so this one also carries the commits of #1903, #1904, #1909, #1910, #1911, #1912, #1913, #1914; its own are the last 16, from e07783f on (42 files changed, 2917 insertions(+), 158 deletions(-)).
The G17 GPU (T6040) across hibernation and suspend-to-RAM: the firmware republished after a resume from disk off the PM notifier, the GPU's power word handled at the sleep's commit, the PMP handover, the compute channel claim taken through the preparation gate, and the failing step named when a republish fails.
Open item (not fixed here, a separate pull request will follow): with a second hibernation requested right after the first resume, placements in the GPU kernel window could fail with -EBUSY afterwards; never seen with a single hibernation through systemd. Details in #1477.
Tested: the stack as a whole on the J616s (hibernation and suspend-to-RAM; results in #1477, whose tree is the tree at the top of this stack). Each part of the stack was built on its own (asahi config, LLVM, Rust) for the directories the series touches, and runs the host tests, KUnit and the other checks here. The commits are those of #1477 restricted to this part's files, in the same order; where a commit of #1477 spanned parts, each piece says in its message which commit it comes from.
Not tested: this part on hardware without the parts above it in the stack; T8140 and the other SoCs whose paths these commits share; a dock on the current base; the KVM guest across the sleeps; a USB4/Thunderbolt device.