Skip to content

iommu/apple-dart, drm/asahi, soc: apple: sparse and kernel-doc fixes - #2830

Merged
RyanTheTide merged 3 commits into
integration/aurorafrom
code-health/soc-iommu-asahi-20261123
Nov 22, 2026
Merged

RyanTheTide merged 3 commits into
integration/aurorafrom
code-health/soc-iommu-asahi-20261123

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Problem

A W=1 + sparse build of the integration/aurora tip reports:

  • iommu/apple-dart: "too long token expansion" at the four places that take max(FIELD_GET(..READ_PORTS..), FIELD_GET(..WRITE_PORTS..)). sparse stops checking those expressions.
  • drm/asahi/g17/sync_scope.c: comparing the __rcu dma_fence::ops pointer directly (different address spaces).
  • soc/apple/clpc.c: kernel-doc reports apple_clpc_hw.pmp_agent as undocumented.

Change

  • apple-dart: read the two port counts into locals, then take max().
  • g17 sync_scope: use rcu_access_pointer(fence->ops), as dma_fence_is_array() and the g18 sync_input.c do.
  • clpc: document pmp_agent.

No functional change.

Testing

  • W=1 C=2 build of drivers/iommu/, clpc.o and sync_scope.o with the fleet79 config: no warnings left from these files.
  • Generated code: clpc.o is identical. In apple-dart.o only instruction order and register width around the two ubfx changed; the readl() barrier and its fake dependency are still there. In sync_scope.o there is one extra-instruction difference from the READ_ONCE() in rcu_access_pointer().
  • checkpatch --strict: clean.

Tracking issue: #2827

Still to run

Nothing hardware-specific. The apple-dart KUnit suite would be a cheap extra check.

Details

Logs (lab store): traces/ci/20261123-code-health/logs/w1-sparse.log (before), soc-iommu-after.log (after).

Assisted-by: LLM (Claude:Opus 5.5)

max(FIELD_GET(...READ_PORTS, params), FIELD_GET(...WRITE_PORTS, params))
expands past sparse's token limit, so sparse reports "too long token
expansion" and stops checking the rest of the expression. Read the two
port counts into locals first and take max() of those.

No functional change.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
dma_fence::ops is __rcu. asahi_g17_is_scope() compared it directly,
which sparse reports as a comparison between different address spaces.
Use rcu_access_pointer(), as dma_fence_is_array() and the g18
sync_input code do.

No functional change.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
W=1 kernel-doc reports the struct member as undocumented. Describe it:
the PMC floor voter agent of the PMP that apple_clpc_gpu_limited()
reads when @pmp_backoff is set.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at c0e1ac8.

  1. apple-dart.c:7291/7872, apple-dart-sleep.c:367, apple-dart-cio-power.h:30: the 3-bit FIELD_GET() results now go into unsigned int locals before max(). The values and the !ports || ports > 4 checks are the same, and readl() is still done once per function. No max(FIELD_GET sites are left in drivers/iommu/apple-dart*.
  2. g17/sync_scope.c:50: dma_fence::ops is const struct dma_fence_ops __rcu * (dma-fence.h:75). rcu_access_pointer() is the right accessor for a comparison that doesn't dereference, the same as dma_fence_is_array()/dma_fence_is_chain() (dma-fence.h:772/783).
  3. clpc.c:93: the new @pmp_agent line matches the field order (struct lines 124-125) and its only use, apple_pmc_floor_read(..., hw->pmp_agent) at line 706.

Looks good.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial pre-PR checklist (§1–§6) review at c0e1ac84782a45e74ab5ab5ff94264dd84cf635e:

  • Technical / semantics check:
    • iommu/apple-dart (a6615613): splitting max(FIELD_GET(...READ_PORTS...), FIELD_GET(...WRITE_PORTS...)) into unsigned int rports / wports across all 4 sites (apple-dart-cio-power.h:30-32, apple-dart-sleep.c:367-369, apple-dart.c:7291-7293, apple-dart.c:7872-7874) preserves exact 3-bit unsigned extraction (GENMASK(18, 16) / GENMASK(22, 20)), single readl(), and the !ports || ports > 4 bounds check with no truncation or signedness change. No max(FIELD_GET sites remain in drivers/iommu/apple-dart*.
    • drm/asahi/g17/sync_scope.c (7ce3f99f): dma_fence::ops is const struct dma_fence_ops __rcu * (include/linux/dma-fence.h:75). Using rcu_access_pointer(fence->ops) == &scope_ops matches upstream dma_fence_is_array() / dma_fence_is_chain() (dma-fence.h:772,783) and is strictly safer (adds READ_ONCE() without dereferencing). No other raw fence->ops reads exist in sync_scope.c.
    • soc/apple/clpc.c (c0e1ac84): @pmp_agent accurately documents its sole use (apple_pmc_floor_read(clpc->pmc, clpc->hw->pmp_agent) at line 706 when pmp_backoff is set), and all 18 members of struct apple_clpc_hw are now documented.
  • §1 No model gating / §2 Production-ready / §3 Safety: Pass — no model gates, no hacks, no safety limits weakened.
  • §4 Clean-room & attribution: Pass — all 3 commits carry human author/committer (Ryan Murray <ryan@aurorasilicon.org>), human Signed-off-by, zero AI trailers in commits, and Assisted-by: in the PR body.
  • §5 Evidence: Pass — W=1 C=2 clean, objdump verified, checkpatch --strict clean, all 7/7 CI checks green (host-tests, source, rust-build, kunit, and all 3 DWC3/ATC build variants), mergeable (clean).
  • §6 Naming: Pass.

Verdict: APPROVE — ready for MERGETRAIN-LINUX4.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merge-train adversarial review (MERGETRAIN-LINUX4) at c0e1ac8: no blockers. Merges clean on integration/aurora, alone and together with #2828-#2832.

Full review

VERDICT: NO BLOCKERS

Blockers: none.

Checked:

  • apple-dart.c:7291-7293 and :7872-7874, apple-dart-sleep.c:367-369, and apple-dart-cio-power.h:30-32: each
    max() now runs on two unsigned int locals, each holding a 3-bit FIELD_GET. Before, the arguments were
    the FIELD_GET results of a u32 (params, or s->params[1], which is u32 per cio-power.h:15), so there is
    no truncation or signedness change. readl() is still called once per function, and the
    !ports || ports > 4 checks are unchanged.
  • g17/sync_scope.c:50: in this tree, dma_fence::ops is const struct dma_fence_ops __rcu *
    (include/linux/dma-fence.h:75). rcu_access_pointer() is the same compare as dma_fence_is_array() and
    dma_fence_is_chain() (:772/:783). No functional change.
  • clpc.c:93: the doc line for @pmp_agent matches the member at :125 and its use at :706.

Nits: none.
earlier review: nothing open.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide
RyanTheTide merged commit a9626a1 into integration/aurora Nov 22, 2026
7 checks passed
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Post-merge check at cdce3146 (#2828-#2831 merged onto integration/aurora 120d6aa, fleet79 config, LLVM arm64).

In apple-dart.o the four max() sites now compare the port counts in 32-bit registers; values and the range checks are the same (3-bit fields). The only other difference there is the KUnit LINE constants in apple_dart_fw_leaf_test. rcu_access_pointer() is the right accessor in sync_scope: fence->ops is __rcu and the pointer is only compared, as dma_fence_is_chain() does; the object gains one re-read of fence->ops in asahi_g17_scope_create, which is harmless. clpc.o is identical. sparse goes from 9 errors to 0 across dart and sync_scope, and kernel-doc on clpc.c is clean (2 -> 0).

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