Skip to content

apple: remove exported functions with no caller (-145) - #2369

Merged
DjDeveloperr merged 9 commits into
mainfrom
deadweight/callerless-functions
Dec 1, 2026
Merged

DjDeveloperr merged 9 commits into
mainfrom
deadweight/callerless-functions

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Several exported functions in our Apple drivers have no caller anywhere in the tree (C or Rust). Most are the first version of an interface that a second version replaced. There is also one #if 0 block.

Change

Six commits, one per subsystem, net -145 lines, no functional change:

  • iommu/apple-dart: apple_dart_m5_restore() and the fields only it read. It came in with the T6050 S2R work (5ce3491) without a caller; the v27 lease replaced it. Nothing ever wrote those fields, so it would have restored zeros.
  • phy/apple/atc: apple_atcphy_sleep_finish() and _finish_flush(). dwc3-apple uses only _finish_async()/_finish_done() since a667121.
  • soc/apple/sleep: apple_sleep_smc_register(). macsmc uses apple_sleep_smc_register_saved().
  • soc/apple/rtkit: devm_apple_rtkit_free(), which has no user.
  • soc/apple/pmp-display: apple_pmp_j713_gpu_check(), which has had no user since it was added (1ae4d49).
  • media/apple/isp: the #if 0 conditional coprocessor reset. The unconditional isp_reset_coproc() after it replaced it.

Not included: typec_mux_prepare() has no in-kernel caller, but the host test tools/testing/selftests/drivers/gpu/apple-dcp/quiesce.py exercises it.

Testing

  • Combined fleet build of all eleven deadweight code branches stacked on 0abc2f3 (DEBUG_INFO off): make Image modules dtbs RC=0, 5,909 modules, modpost reports no undefined symbols, and the only warnings are ones the baseline already had in untouched files.
  • Fleet config, make prepare + W=1 single-object builds before and after: apple-dart.o, atc.o, sleep.o, rtkit.o, pmp-display.o, isp-fw.o and dcp.o, plus the callers macsmc.o and dwc3-apple.o. RC=0, no new warnings.
  • The 36 host tests that read the touched files (tools/asahi/*-tests.py, selftests/drivers/apple, selftests/drivers/gpu/apple-dcp): 25 pass. The other 10 fail with the same exit codes on the unpatched tree, and the run.py runner times out, so there are no new failures.
    git grep -n -w <symbol> on 0abc2f3 finds only each function's definition, its export, its header prototype and its stub.

Still to run

Nothing build-side.

Caller grep per symbol
apple_dart_m5_restore: apple-dart.c:7769 (def), :7820 (export), dart.h:195, :233
apple_atcphy_sleep_finish: atc.c:7580, :7587, apple-atc.h:45, :74
apple_atcphy_sleep_finish_flush: atc.c:7622, :7629, apple-atc.h:51, :87
apple_sleep_smc_register: sleep.c:1787, :1803, sleep.h:43, :247
devm_apple_rtkit_free: rtkit.c:3474, :3478, rtkit.h:151
apple_pmp_j713_gpu_check: pmp-display.c:539, :543, pmp-display.h:47
m5_streams|m5_gapf|m5_diag|m5_error_mask|m5_protect|m5_lock|m5_released|m5_changed|m5_failed: only apple-dart.c:378/380 (decl) and inside apple_dart_m5_restore

apple_dart_m5_restore() came in with the T6050 suspend-to-RAM work
(5ce3491) without a caller, and nothing has called it since. The
firmware 27 display sleep restores its DARTs through the v27 lease
(apple-dart-v27-late.inc). Nothing ever writes the fields the function
restores (m5_streams, m5_gapf, m5_diag, m5_error_mask, m5_protect,
m5_lock), and m5_changed is only ever cleared, so even with a caller it
would have restored zeros. Remove the function, its declaration and
stub, and the fields only it used. m5_sleep_owner, m5_disp_streams and
m5_display stay; the v27 code uses them.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The dwc3 glue finishes a sleep with apple_atcphy_sleep_finish_async()
and polls apple_atcphy_sleep_finish_done() since a667121 ("usb:
dwc3: apple: keep USB teardown out of the PM notifier chain"). That
removed the last caller of apple_atcphy_sleep_finish() and
apple_atcphy_sleep_finish_flush(). Remove both exports and their stubs.
The static atcphy_sleep_finish() stays; the finish work runs it.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
macsmc registers its sleep notices through
apple_sleep_smc_register_saved(), which takes the full ops table.
Nothing calls the older apple_sleep_smc_register(), which only took
the late notice and refused to run once saved ops were registered.
Remove it and its stub.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
No driver frees a devm RTKit instance early: nothing in the tree, C or
Rust, calls devm_apple_rtkit_free(). Remove it.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
apple_pmp_j713_gpu_check() was added beside the GPU prepare and get
helpers but has never had a caller. Remove it; pmp_power_check() keeps
its display callers.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
isp_firmware_boot_stage1() carries an #if 0 block that reset the
coprocessor only when a GPIO word read back a marker, disabled because
it did not work well with system sleep. The unconditional
isp_reset_coproc() right after it replaced it. Drop the block and the
commented-out variable it needed.

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

Copy link
Copy Markdown
Contributor Author

No blockers.

All six removed exports and the nine m5_* fields have no reference left at the head. I also checked the current integration/aurora: each symbol's count is the same as at this PR's parent, so no caller was added in the 398 newer commits, and the branch merges cleanly. apple_rtkit_free_wrapper() is still used by both devm init paths (rtkit.c:3448, :3467), so removing devm_apple_rtkit_free() leaves nothing unused. late_notice is still set through apple_sleep_smc_register_saved() (sleep.c:1802). Removing the #if 0 block in isp-fw.c is independent of #2382's change to the same file. All CI passes. Build-only, so it can leave draft.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 22, 2026 10:09
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

One problem found by checking open PRs against this removal; everything else holds at the current integration/aurora (the branch still merges cleanly and every removed symbol has no reference left in the merged tree).

  • apple_atcphy_sleep_finish() and apple_atcphy_sleep_finish_flush() are still used by open soc: apple: sleep: T6040 (M4 Pro, J616s) suspend-to-RAM #2215 (T6040 suspend-to-RAM). Its head adds apple_typec_phy_sleep_finish() and apple_typec_phy_sleep_finish_flush() as static inlines in include/linux/phy/apple-atc.h (lines 271-286 there) that call both. A three-way merge of soc: apple: sleep: T6040 (M4 Pro, J616s) suspend-to-RAM #2215 with this branch has no textual conflict, but the merged header still calls the two functions after this PR removed their declarations and definitions. Every file that includes apple-atc.h then fails to build with an implicit declaration error. Please either keep these two exports in this PR, or agree with soc: apple: sleep: T6040 (M4 Pro, J616s) suspend-to-RAM #2215 that it drops those wrappers first. They have no caller outside the header there either, so dropping them may be the simpler fix.

The other four removals (apple_dart_m5_restore, apple_pmp_j713_gpu_check, devm_apple_rtkit_free, apple_sleep_smc_register) and the #if 0 block have no user in any open PR.

Assisted-by: LLM (Claude:Opus 5.5)

@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.

Formal §1–§6 pre-PR review at verified live head 5996b85e1212f26c581e95b7f1a7cf16bbcefd3e against live integration/aurora (70a00e583b03, not superseded).

Verified Clean

  • Caller & dead-helper audit on live integration/aurora (70a00e583b03): All six removed exports (apple_dart_m5_restore plus its 9 unread/unwritten m5_* fields in struct apple_dart, apple_atcphy_sleep_finish, apple_atcphy_sleep_finish_flush, apple_sleep_smc_register, devm_apple_rtkit_free, apple_pmp_j713_gpu_check) and the #if 0 block in drivers/media/platform/apple/isp/isp-fw.c have zero callers on live integration/aurora. All retained helpers (apple_dart_state_retained, apple_dart_m5_streams_unowned in apple-dart-v27-late.inc:384, apple_rtkit_free_wrapper, pmp_power_check, s->smc.late_notice) keep active callers.
  • Attribution (§4): All 6 commits carry human author/committer and human Signed-off-by: only (zero AI commit trailers); PR body discloses assistance.

Blockers Before APPROVE

  1. Unresolved silent build breakage with open PR #2215 (7e229ab510a7, non-draft):
    • Verified on live #2215: it adds static inline wrappers apple_typec_phy_sleep_finish() and apple_typec_phy_sleep_finish_flush() to include/linux/phy/apple-atc.h calling apple_atcphy_sleep_finish() and apple_atcphy_sleep_finish_flush().
    • Because the edits land in non-overlapping regions of include/linux/phy/apple-atc.h, a 3-way merge of #2369 and #2215 produces no textual conflict and fails to compile every translation unit that includes <linux/phy/apple-atc.h>.
    • Please either drop commit 6090c7283e84 (phy: apple: atc: remove the synchronous sleep finish and its flush) from #2369 or update #2215 to remove those unused wrappers first.
  2. §6 Stale base / missing live CI coverage:
    • Head 5996b85e1212 is still based on 0abc2f385e54 (2026-11-19). Live integration/aurora added .github/workflows/pmgr-pwrstate-kunit.yml on 2026-11-23 (triggered by include/linux/soc/apple/**, which this PR modifies), and it has not run on this head.
    • Please rebase/merge onto live integration/aurora (70a00e583b03) so pmgr-pwrstate-kunit, sep-source, and host-tests all run green against the current tree.

Non-Blocking Note

  • include/linux/soc/apple/sleep.h lines 40–46 are adjacent to PR #2384's edits; keep merge-train ordering in mind once both are ready.

@github-actions github-actions Bot added area:media Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at 50ed245d: not ready yet

Check Detail
CI at head ok 34 checks passed
Review no approved by DjDeveloperr, but GitHub does not count it yet (code owner from Core or Omarchy Mac needed, or approval went stale)
Requested changes ok none
Hardware row at head no no line with the head SHA 50ed245d, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:media, area:platform

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@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.

Verdict: FINISH, then merge at 5996b85e1212

Blockers:

  1. include/linux/phy/apple-atc.h: commit 6090c728 removes apple_atcphy_sleep_finish() and apple_atcphy_sleep_finish_flush(), but open #2215 (T6040 suspend-to-RAM) adds static inline wrappers in the same header that call them. The edits don't overlap, so the two PRs merge without a text conflict, and then every file that includes <linux/phy/apple-atc.h> fails to build. Fix: drop 6090c728 from this PR (it can go once #2215 settles), or remove the wrappers from #2215 first.

Checked: no Apple material, no runtime change beyond removing exported functions that have no caller. The fleet build of all eleven deadweight branches has no undefined symbols, and the W=1 single-object builds of the callers are clean. CI green. This replaces my earlier review. The stale base isn't a blocker; GitHub reports the PR mergeable.

Evidence

Read the diff (-145) and checked #2215 at 5467f0f9 for the two functions.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 24, 2026 19:41

Superseded by the review at 5996b85

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 26, 2026
…flush"

This reverts commit 6090c72.

Review follow-up: open #2215 (T6040 suspend-to-RAM) still calls
apple_atcphy_sleep_finish() and apple_atcphy_sleep_finish_flush(). The
two PRs do not conflict in text, so landing both would break every file
that includes <linux/phy/apple-atc.h>. Keep the two exports until #2215
has settled; their removal can follow it.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
# Conflicts:
#	drivers/soc/apple/sleep.c
#	include/linux/soc/apple/sleep.h
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Fixed at df87001 (normal push: a revert plus a merge of main).

Blocker 1 (apple_atcphy_sleep_finish()/_flush() still used by open #2215): commit 6090c72 is reverted on this branch (ac05cfa), so both exports stay until #2215 settles. Their removal can follow it.
Merge with main: conflict in include/linux/soc/apple/sleep.h/sleep.c. Main added apple_sleep_smc_gen1_keys() right next to the apple_sleep_smc_register() this PR removes. gen1_keys is kept, and register is still dropped: it still has no caller on main. I checked each removed export on current main (apple_dart_m5_restore, apple_pmp_j713_gpu_check, apple_sleep_smc_register, devm_apple_rtkit_free): no users outside their own definition and header.
Testing: the full fleet-config kernel 7.3.0-aurora-fixa3 (LLVM=1, Rust) builds with this head merged on top of six other PR heads, with no undefined symbols at modpost.

@RyanTheTide
RyanTheTide requested review from a team as code owners November 27, 2026 07:13
@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) and removed area:usb Area from CODEOWNERS (bot) merge-conflict Conflicts with the base branch (bot) ci-failing A check failed at the PR head (bot) labels Nov 27, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: FINISH, then merge at df870017

Blockers:

  1. Branch is CONFLICTING (DIRTY) with main; forward-merge main (no force push) and re-run CI to green.
  2. Missing exact-head boot smoke row after resolving the conflict.

Checked:

  • Prior blocker resolved: ac05cfac cleanly reverts 6090c728, keeping apple_atcphy_sleep_finish() and apple_atcphy_sleep_finish_flush() intact while #2215 is open; the remaining removals drop genuinely uncalled exported helpers across Apple drivers (+1/-116), and 27/27 CI checks passed before main moved.
  • Checked for Apple material, tool attribution, private serials, and gating: clean.
Evidence
  • Head: df87001778e0 (base: main, mergeable: CONFLICTING, +1/-116 across 9 files).

Keep main’s error-returning apple_dart_power_dark declaration while removing the unused apple_dart_m5_restore declaration.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label Nov 30, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The forward merge resolves the main conflict and the PR diff leaves the ATC PHY header and exports intact. The previous build receipt predates this head. Keep the current build and host checks pending and post an exact-head boot smoke result before landing the cleanup.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I am withdrawing my separate boot-smoke request. The current diff leaves the ATC exports intact and removes unused functions and disabled code. The build and host checks are the direct evidence for the remaining unused-caller and linkage risk.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 30, 2026

@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.

Merged main into 50ed245. The ATC sleep exports used by #2215 remain, as does the error-returning apple_dart_power_dark declaration. The four removed exports have no remaining callers on the merged source. All five changed arm64 driver objects compiled. This resolves my earlier code finding. Because I pushed this merge, another eligible reviewer must approve the last push.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: MERGE at 50ed245d202d

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: Code reviewed in the earlier App review at this head (6122195489).

Follow-ups (not blocking): Reviewer withdrew boot-smoke ask; build/host checks suffice

@github-actions github-actions Bot removed the changes-requested A reviewer requested changes (bot) label Dec 1, 2026
@DjDeveloperr
DjDeveloperr merged commit e6ed678 into main Dec 1, 2026
39 of 64 checks passed
@DjDeveloperr
DjDeveloperr deleted the deadweight/callerless-functions branch December 1, 2026 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:media Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants