Skip to content

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

Open
RyanTheTide wants to merge 6 commits into
integration/aurorafrom
deadweight/callerless-functions
Open

RyanTheTide wants to merge 6 commits into
integration/aurorafrom
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

Assisted-by: LLM (Claude:Opus 5.5)

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.

Assisted-by: LLM (Gemini 4 Neon)

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