Skip to content

soc: apple: show the fabric and DCS clock-generator words in debugfs - #2143

Open
joshuaswarren wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
joshuaswarren:w73/move-pmgr-misc-debugfs
Open

joshuaswarren wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
joshuaswarren:w73/move-pmgr-misc-debugfs

Conversation

@joshuaswarren

Copy link
Copy Markdown
Contributor

[Joshua's agent]

Carried from omacom/linux-aurora#336 (scottjones approved it there:
omacom/linux-aurora#336 (review); rebased onto
aurora-edge).

Adds one read-only debugfs directory to apple-pmgr-misc:
apple-pmgr-misc-<device>/fabric_ps and dcs_ps, mode 0400, each the whole
clock-generator word of that system device (desired state in bits 3:0, actual
state in bits 7:4).

Why: on the 16-inch M1 Max a PMP request bit moved the DCS word from state 7
to 9 and the fabric word from 3 to 7, and the GPU read bandwidth from 241 to
368 GB/s. Finding that took a separate probe module. With these files any
measurement can record the memory-side state it ran in, next to its timing.

What it does: the show function reads the word through the same mapping the
driver already uses at probe and on resume, and writes nothing. The directory
is removed by a managed action when the device goes away. Without the debugfs,
nothing changes.

State: built on aurora-edge (139dfe6) with clang 18.1.8, ARCH=arm64
LLVM=1, defconfig with CONFIG_APPLE_PMGR_MISC=m; apple-pmgr-misc.o compiles
clean and the strings are present. The same two words, at the same addresses
and through a non-posted mapping, were read on a 16-inch M1 Max by a throwaway
module (fabric 0x333, DCS 0x777 at idle, unchanged over 20 samples a
second). This patch itself has not been booted yet, so it goes in as a draft
until a boot test runs.

Read only: apple-pmgr-misc gets one debugfs directory with the whole clock-generator word of the fabric and DCS system devices (fabric_ps and dcs_ps, mode 0400, the desired state in bits 3:0 and the actual state in bits 7:4). It reads the words through the mapping the driver already uses and writes nothing. A performance measurement can then record the memory-side state it ran in next to its timing.

Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>

(cherry picked from commit b50e681fb588da49c7fcbf71bd6a7b499600a6c4; include conflict resolved keeping the regmap include aurora-edge added)
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

GREEN on 4718d69
Model: opencode-go/muse-spark-1.3-contributor

Review at exact head 4718d69, branch w73/move-pmgr-misc-debugfs, one commit on asl/aurora-edge 139dfe6.

Code does what the text says: DEFINE_SHOW_ATTRIBUTE read-only show, files created mode 0400, removal via devm managed action, no writes anywhere (36 insertions, apple-pmgr-misc.c only, plus two includes). Init runs only on successful probe. State line honest: built with clang, never booted, draft. No internal names, paths, or tooling in the body. The M1 Max numbers in the Why paragraph are measured claims from the throwaway module, stated as such.

No findings.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, a read-only view of these two words is handy next to any bandwidth measurement.

  1. The PR targets aurora-edge. Please retarget it to integration/aurora. The patch applies there with small offsets.
  2. Nit: the if (!ret) before apple_pmgr_misc_debugfs_init() tests a value that is always 0 at that point. It can go.

The code is otherwise fine as a 0400 debugfs read with devm cleanup and no writes.

Row on any Mac where apple-pmgr-misc binds (an M1 Pro or M1 Max is fine):

  • Boot, then read fabric_ps and dcs_ps 20 times. They should return words with desired state in bits 3:0 and actual state in bits 7:4, with no SError or oops.
  • Unbind and rebind the driver. The directory should disappear and come back.

With that, this is a small, safe addition.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[Joshua's agent]

Base branch: Retargeting to integration/aurora now (rebases cleanly; small line offsets only per your note).

Nit: Dropping the useless if (!ret) before apple_pmgr_misc_debugfs_init() in the next push.

Evidence: Move context from q62/q78 inventory: CI was green on the w73 move branch at 4718d69becb1; this is the aurora-silicon reopen (#2143).

Hardware row (M1 Pro/Max class): after boot, for i in $(seq 20); do cat /sys/kernel/debug/apple-pmgr-misc/fabric_ps /sys/kernel/debug/apple-pmgr-misc/dcs_ps; sleep 0.1; done — bits 3:0 desired / 7:4 actual, no SError; then unbind/rebind apple-pmgr-misc and confirm debugfs dir respawns.

@joshuaswarren
joshuaswarren changed the base branch from aurora-edge to integration/aurora November 19, 2026 15:29
ret is always 0 after the DCS init succeeds.

Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[Joshua's agent] Follow-up: pushed 6b67ea0 — removed the tautological if (!ret) before apple_pmgr_misc_debugfs_init() (ret is always 0 there). Base is already integration/aurora. M1 Pro/Max debugfs row still on the w7C list.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, 6b67ea0 and the retarget cover both points. The code looks good to me. What's left is CI on the new head (still queued) and the M1 Pro/Max debugfs read and rebind row. We can run that row on our M1 Pro if that helps.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Row on a 16-inch M1 Pro (J316s, T6000) at this head (6b67ea0), done.

Kernel: integration/aurora 0abc2f3 with this PR merged (plus #2240, #1881 and #1065, which touch other drivers), built with PROVE_LOCKING, DEBUG_LOCKDEP and DEBUG_ATOMIC_SLEEP.

  • The directory is apple-pmgr-misc-28e20c000.power-management/ and holds fabric_ps and dcs_ps, both mode 0400.
  • I read both files 20 times at idle, 20 times under stress-ng --cpu 8 --vm 2 --vm-bytes 2G, and 20 times after one s2idle (RTC wake). That is 120 reads, and every one returned the same words: fabric 0x00000333 (desired 3, actual 3) and DCS 0x00000666 (desired 6, actual 6). On this machine PMP owns both p-states (the boot log says PMP manages fabric and DCS p-states), so it makes sense that neither word moved under load.
  • After the row started, dmesg had no SError, oops, WARN or lockdep report, and debug_locks stayed 1.
  • Unbind/rebind could not be run, and that part of my earlier request does not apply. The driver keeps suppress_bind_attrs = true ("The governor's workers and holders would outlive an unbind."), so /sys/bus/platform/drivers/apple-pmgr-misc/ has no bind or unbind file. The devm action that removes the directory only runs if a later probe step fails. That is fine for a read-only 0400 file.

One observation: bits 11:8 carry the same value as the two documented nibbles here (0x333, 0x666). If that field has a meaning, it could go in the comment above the show function. Otherwise the comment is accurate.

From our side, this is ready to leave draft once CI is green.

Raw reads and log
dirs: /sys/kernel/debug/apple-pmgr-misc-28e20c000.power-management
-r--------. 1 root root 0 dcs_ps
-r--------. 1 root root 0 fabric_ps
bind attrs: unbind=absent bind=absent
s2idle via rtc1: ok=1
idle:   dcs_ps 0x00000666 x20; fabric_ps 0x00000333 x20
load:   dcs_ps 0x00000666 x20; fabric_ps 0x00000333 x20
resume: dcs_ps 0x00000666 x20; fabric_ps 0x00000333 x20
dmesg since row start: 0 SError/oops/WARN/lockdep lines, debug_locks=1

Assisted-by: LLM (Claude:Opus 5.5)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T01:00:33.286717Z 6b67ea0 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

Thanks for running the row on the 16-inch M1 Pro. The 120 stable reads across idle, load and one s2idle, plus the clean dmesg and debug_locks=1, cover what we asked, and your bind/unbind note is right: suppress_bind_attrs = true removes that path, and the devm action covers a failed probe.

On bits 11:8: we have no documentation for that field, so we will not annotate a meaning we cannot support. What we can say from the code: the driver consumes only bits 3:0 (desired) and 7:4 (actual) and never writes above bit 7, so the two documented nibbles are the only ones with a verified meaning. On your words (0x333, 0x666) bits 11:8 match bits 7:4, and we have not yet seen a state where they diverge, so we cannot even confirm the mirror is stable rather than a property of the two states you sampled. If your side has a document naming that field, we will add it in a follow-up.

Agreed on leaving draft until CI on 6b67ea0 is green; we will flip it then.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

Cross-model agent review of 6b67ea0 (independent of the authoring model). Carries scottjones's approval of the omacom source (#336); CI on this head is fully green (kunit, rust-build, source, host-tests, DWC3/ATC matrix).

Reviewed the 35-line patch:

  • Reads only: apple_pmgr_misc_ps_show uses readl_relaxed on the same APPLE_CLKGEN_PSTATE mapping the driver already owns; no write path, no side effect. Mode 0400 root-only is right for a debug surface.
  • Cleanup: devm_add_action_or_reset removes the directory on probe failure or detach; suppress_bind_attrs plus the devm action cover both failure and normal removal paths.
  • The second commit removes a tautological init guard; the diff is additive elsewhere, so the carry is faithful to the approved source.
  • Per-device files use &misc->devices[i] as seq_file private, matching DEV_MAX and the per-device base checks; the names array order matches the device order.

No findings. The PR is already non-draft and, per the thread, the draft flip was gated on CI green at 6b67ea0 — that condition is met. Ready for maintainer review.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train adversarial review (MERGETRAIN-LINUX2) at 6b67ea0: NO BLOCKERS.

Code read only, nothing built here. Before the merge it still needs Dj's verdict at this head; the missing rows are listed below.

Full review

#2143 soc: apple: show the fabric and DCS clock-generator words in debugfs @6b67ea0f

VERDICT: NO BLOCKERS

Code checks out (merged onto 24dc422, apple-pmgr-misc.c):

  • :744-770: read-only readl_relaxed on the mapping the driver already owns (devices[i].base, set at :733 from devm_platform_ioremap_resource_byname). Mode 0400, no write path.
  • names[DEV_MAX] matches DEV_MAX == 2 (:55-57), and files are created only for mapped devices.
  • The init at :800 runs after both apple_pmgr_init_device calls. The one later failure, apple_pmgr_dcs_init at :819-821, makes devm remove the directory before the devm iomaps are unmapped (reverse order).
  • debugfs_create_file proxies the fops, so removal waits for any open reader.
  • An ERR_PTR directory, when debugfs is off, is handled by debugfs itself.
  • f881285 on the base does not interact with this.

Nits:

  • 4718d69: the human Signed-off-by sits above a "(cherry picked from ...)" paragraph, so git does not parse it as a trailer (%(trailers) comes back empty). Leave the pushed history alone.
  • No KUnit or host test was added. The change is trivial.

Missing rows:

  • Ryan's J316s (T6000) row covers it: 120 reads at idle, under load and after s2idle, no SError or lockdep report.
  • Unbind/rebind is impossible (suppress_bind_attrs).
  • Other PMGR-misc SoCs (t8103, t8112, t602x, t8122, t6040, if bound) have not read these words through this file. A single cat row on one non-T6000 Mac (M2 or J616s) would close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants