Skip to content

drm/apple: let sparse check the IOMFB template; static ops and annotation fixes - #2828

Merged
RyanTheTide merged 2 commits into
integration/aurorafrom
code-health/drm-apple-sparse-20261123
Nov 22, 2026
Merged

RyanTheTide merged 2 commits into
integration/aurorafrom
code-health/drm-apple-sparse-20261123

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Problem

A W=1 + sparse build of drivers/gpu/drm/apple on the integration/aurora tip gives about 190 sparse errors in iomfb_template.c, plus a few real warnings. The template errors are bogus. iomfb_v14_7_tpl.h and iomfb_v26_6_desktop.h use #pragma push_macro/pop_macro to keep the outer template instance's DCP_FW when they are first included from inside one (through dcp-internal.h). sparse doesn't implement those pragmas, so it saw DCP_FW_VER undefined and DCP_FW unexpanded in every instance. That means sparse has never really checked the IOMFB template.

Change

  1. Each template instance (iomfb_v12_3.c, iomfb_v13_3.c, iomfb_v14_7_tpl.c, iomfb_h17p.c, iomfb_v26_6_desktop.c) now includes dcp-internal.h with its other per-version headers, before it defines DCP_FW. The existing comment in those files already asks for this. The include guards then make the template's own include a no-op.
  2. apple_drm_ops and dcp_playback_ops become static (the PCM ops also const). ext_plane_disable() gets a __le32 * buffer pointer. dcp_crtc_next_flip_seq() moves above the kernel-doc of dcp_crtc_send_page_flip_event(), which it had split from its function.

No functional change.

Testing

  • W=1 C=2 build of drivers/gpu/drm/apple/ with the fleet79 config (clang 22, rustc 1.97.1): no compiler, sparse or kernel-doc warnings from the driver. The one remaining sparse report is a false "division by zero" in dcp_backlight_test.c through div_u64().
  • Generated code: llvm-objdump -d of iomfb_v12_3/v13_3/v14_7_tpl/h17p/v27/v26_6_desktop.o, dcp.o and dcpext_drm.o is identical before and after. In apple_drv.o and audio.o only the layout changed (the ops tables moved to local rodata, and functions were reordered); every function has the same size.
  • checkpatch --strict: clean.

Tracking issue: #2827

Still to run

Nothing hardware-specific: the object code is unchanged. Any fleet boot with this in the tree covers it.

Details

The remaining sparse output for the whole directory after this change:

drivers/gpu/drm/apple/dcp_backlight_test.c: note: in included file (through include/linux/time64.h, ...):
include/linux/math64.h:28:31: warning: division by zero

Logs (lab store): traces/ci/20261123-code-health/logs/w1-sparse.log (before) and drm-apple-after.log (after).

Assisted-by: LLM (Claude:Opus 5.5)

…late

iomfb_template.c includes dcp-internal.h, which pulls in
iomfb_v14_7_tpl.h and iomfb_v26_6_desktop.h. When that happens for the
first time inside a template instance, those headers rely on
the push_macro/pop_macro pragmas to keep the instance's DCP_FW and
DCP_FW_VER. sparse does not implement these pragmas, so for every
instance it saw DCP_FW_VER undefined and DCP_FW unexpanded, and gave up
on iomfb_template.c with ~190 bogus errors (incomplete struct
dcp_swap_submit_req_DCP_FW, undefined preprocessor identifier
DCP_FW_VER). The template was effectively never checked.

Include dcp-internal.h with the other per-version headers, before each
instance defines DCP_FW, as the existing comment already asks. The
headers' include guards then make the template's own include a no-op.

No functional change: the generated code of every iomfb_* object is
identical before and after.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
- apple_drm_ops and dcp_playback_ops are only used in their own file:
  make them static (and const for the PCM ops, which
  snd_pcm_set_ops() takes as const).
- ext_plane_disable() fills the scanout buffer with cpu_to_le32()
  values: type the pointer __le32.
- dcp_crtc_next_flip_seq() was inserted between the kernel-doc comment
  of dcp_crtc_send_page_flip_event() and its function. Move it above the
  comment so the documentation is attached to the right function again.

No functional change.

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

Copy link
Copy Markdown
Contributor Author

Review at ba15aed.

Checked each change against the head:

  1. dcp-internal.h is now included before DCP_FW in every template instance that lacked it (iomfb_v12_3.c, v13_3.c, v14_7_tpl.c, h17p.c, v26_6_desktop.c). iomfb_v27.c:13 already included it. dcp-internal.h and the headers it pulls in have no DCP_FW-dependent content outside the guarded push/pop headers, and dcp.c/iomfb.c already include it with DCP_FW undefined. So the include guards turn the template's own include into a no-op, and the expansion is unchanged. That matches the identical objdump.
  2. apple_drm_ops (apple_drv.c:1932) is only used in that file (lines 1994 and 2010). dcp_playback_ops (audio.c:742) is only used by snd_pcm_set_ops() at line 1597, which takes a const pointer. Neither has an extern declaration in any header, so making them static hides nothing another file uses.
  3. dcpext_drm.c:293: ext->pixels and frame.pixels are void *, and every store is cpu_to_le32(), so __le32 * is the right type. There is no __force or __iomem involved.
  4. dcp.c: only the kernel-doc block moved. Its text is unchanged and it now sits directly above dcp_crtc_send_page_flip_event().

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 ba15aedee99e0178e911db0bc7a63c98da2e6bb7:

  • Technical / semantics check:
    • IOMFB template include order (d321d4b8): verified all iomfb_*.c files in drivers/gpu/drm/apple/ — all 6 files that #include "iomfb_template.c" now include dcp-internal.h before defining DCP_FW (iomfb_v27.c:13 already did; the remaining 5 — iomfb_v12_3.c, iomfb_v13_3.c, iomfb_v14_7_tpl.c, iomfb_h17p.c, iomfb_v26_6_desktop.c — are updated here). dcp-internal.h contains zero DCP_FW/DCP_FW_VER conditionals and pulls in the guarded iomfb_v14_7_tpl.h and iomfb_v26_6_desktop.h headers once while DCP_FW is undefined, making the re-include inside iomfb_template.c:32 a clean no-op without relying on #pragma push_macro in sparse. Matches the identical llvm-objdump -d across all 6 objects.
    • Static ops & annotations (ba15aede):
      • apple_drm_ops (apple_drv.c:1932) and dcp_playback_ops (audio.c:742) have zero references or extern declarations outside their defining files; snd_pcm_set_ops() takes const struct snd_pcm_ops *, so static const is sound.
      • ext_plane_disable() (dcpext_drm.c:293): ext->pixels (dcpext_drm.c:39) and frame.pixels (dcpext_scanout.h:9) are plain void * (4-byte aligned, checked at dcpext_drm.c:417) and the only store through dst is dst[i] = cpu_to_le32(0xff000000); (line 313). Typing dst as __le32 * fixes the endianness annotation with no __force/__iomem and zero runtime change.
      • dcp.c: moves dcp_crtc_next_flip_seq() above the kernel-doc block for dcp_crtc_send_page_flip_event(), reattaching all four matching @crtc/@e/@now/@start docs with no code change.
  • §1 No model gating / §2 Production-ready / §3 Safety: Pass.
  • §4 Clean-room & attribution: Pass — both 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 for drivers/gpu/drm/apple/ (save 1 unrelated div_u64 sparse false positive in dcp_backlight_test.c), llvm-objdump -d verified identical on iomfb_*.o, dcp.o, dcpext_drm.o and identical function sizes on apple_drv.o/audio.o, checkpatch --strict clean, Host tests/host-tests CI green, 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 ba15aed: no blockers. Merges clean on integration/aurora, alone and together with #2828-#2832.

Full review

VERDICT: NO BLOCKERS

Blockers: none.

Checked:

  • iomfb_template.h (lines 1-9) has no include guard and only takes effect under #ifdef DCP_FW_VER. Only the
    per-version .h files and the template .c files include it. dcp-internal.h:7-46 has no DCP_FW-dependent
    content of its own. The only headers it pulls in that hit iomfb_template.h are iomfb_v14_7_tpl.h:21-35 and
    iomfb_v26_6_desktop.h:22-36. Both have include guards and push/pop DCP_FW. So the patch only changes when
    v26_6_desktop.h (and, in h17p.c, the rest of dcp-internal.h) is first included. With GCC/Clang, push/pop
    makes the output the same. I did not repeat the objdump; it is plausible.
  • All 6 instances of #include "iomfb_template.c" now include dcp-internal.h before DCP_FW: v12_3.c:47,
    v13_3.c:47, v14_7_tpl.c:53, v26_6_desktop.c:59, h17p.c:277 (include at :16, DCP_FW at :267), and v27.c:339
    (already included it).
  • apple_drv.c:1932 apple_drm_ops is used only at :1994/:2010. audio.c:742 dcp_playback_ops is used only at
    :1597. Neither is written at runtime, none of the patched .c files is #included by another file, and there
    is no Rust or extern user. Making them static and const is safe.
  • dcpext_drm.c:293: ext->pixels (:39) and frame.pixels are void *, and the only store is
    cpu_to_le32() at :313. This is a type-only change.
  • dcp.c: the kernel-doc block moved unchanged and now sits directly above dcp_crtc_send_page_flip_event().

Nits: none.
Earlier reviews approved and left nothing open.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

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

dcp.o, dcpext_drm.o and the five IOMFB template objects disassemble identically before and after. apple_drv.o and audio.o differ only in function order and in relocations against .rodata, which is what making the ops static const should do. sparse C=2 on drivers/gpu/drm/apple goes from 331 errors / 406 warnings to 0 errors, with no warning left in the driver (the 3 remaining are in the vdso and math64 headers). kernel-doc on dcp.c goes from 4 warnings to 2; the 2 left are the older dcp_hold_resume_event return-value ones.

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