Skip to content

soc: apple: clpc: link without the SMC driver (r2) - #2846

Open
RyanTheTide wants to merge 2 commits into
integration/aurorafrom
fix/clpc-link-without-smc-r2-20261123
Open

RyanTheTide wants to merge 2 commits into
integration/aurorafrom
fix/clpc-link-without-smc-r2-20261123

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Problem. APPLE_CLPC treats the SMC as optional (depends on MFD_MACSMC || !MFD_MACSMC), but the PHPC package-power read and the zETM High Power mode record call apple_smc_read()/apple_smc_write(), which have no stubs. A kernel with APPLE_CLPC=y and MFD_MACSMC unset fails to link. That includes the driver's own drivers/soc/apple/clpc.kunitconfig, so the CLPC KUnit suite does not build on integration/aurora (it blocks #2821).

Change. Same two commits as #2693, rebased on integration/aurora f5fae3c (279 commits on, incl. #2784 and #2816), plus Dj's review of #2693:

  • apple_clpc_read_power() and apple_clpc_send_high_power() test IS_ENABLED(CONFIG_MFD_MACSMC) first, so the SMC calls drop out at compile time.
  • New: probe takes the apple,smc phandle only when the SMC driver is built. Without it clpc->high_power stays false, so writing performance switches the profile like any other instead of failing with -ENODEV and leaving the low-power ceiling in place.
  • Second Fixes: for f04da7c, which added apple_smc_write().
  • The host test models the SMC driver being built.

No new gate: the guard is the Kconfig symbol of the optional dependency. Kernels with the SMC driver (all our distro and fleet configs) are unchanged.

Testing.

  • KUnit, arm64 qemu: stock clpc.kunitconfig (no SMC) links and passes 11/11; with MFD_MACSMC=y 13 pass, 1 skip (needs UCLAMP_TASK).
  • clpc.o built with the fleet config (RUST off for the one-object build): with MFD_MACSMC=y, tip and this head give the same normalized objdump -d (0 lines of diff, text 22025 bytes both). With MFD_MACSMC=n and ACPI_PLATFORM_PROFILE=y, tip has undefined apple_smc_read/apple_smc_write and still parses apple,smc; this head has neither.
  • tools/asahi/clpc-high-power-cleanup-tests.py and clpc-gpu-demand-tests.py pass; checkpatch --strict clean.

Still to run. Nothing on hardware: with the SMC driver the code is byte-for-byte the same.

Supersedes #2693 (fresh branch instead of a force push).

Review points from #2693 and where they went
  1. Blocker: performance fails with -ENODEV on a High Power machine when MFD_MACSMC=n. Fixed in apple_clpc_probe(): if (IS_ENABLED(CONFIG_MFD_MACSMC)) clpc->smc_np = of_parse_phandle(...), so clpc->high_power = clpc->smc_np && high_power is false. apple_clpc_profile_set() then never calls apple_clpc_send_high_power(), updates profile and clears low_power, and debugfs prints no smc high power line. The compile-time guards in both callers stay.
  2. Nit: second Fixes: f04da7cf87ff ("soc: apple: clpc: J714s: tell the SMC about High Power mode") added.
  3. Nit: fleet-config codegen proof: objdump comparison above (MFD_MACSMC=y: identical).

Objects (sha256 prefix, text, undefined SMC symbols, apple,smc strings):

smc-y-tip  e632a79aa3265c88 text=22025 undef=apple_smc_read,apple_smc_write strings=1
smc-y-head 11759455be9b7d80 text=22025 undef=apple_smc_read,apple_smc_write strings=1
smc-n-tip  e632a79aa3265c88 text=22025 undef=apple_smc_read,apple_smc_write strings=1
smc-n-head 89d1961683c3a673 text=20393 undef=(none)                         strings=0

(smc-y-head differs from smc-y-tip only in line-number data; the disassembly is the same.)

Assisted-by: LLM (Claude:Opus 5.5)

APPLE_CLPC treats the SMC as optional ("depends on MFD_MACSMC ||
!MFD_MACSMC"), but the PHPC package-power read and the zETM High Power
mode record call apple_smc_read()/apple_smc_write(), which have no
stubs. A kernel with APPLE_CLPC=y and MFD_MACSMC unset fails to link:

  clpc.c: undefined reference to `apple_smc_write'
  clpc.c: undefined reference to `apple_smc_read'

That includes the driver's own clpc.kunitconfig, which does not enable
the SMC.

Test IS_ENABLED(CONFIG_MFD_MACSMC) before looking the SMC up, so both
paths return -ENODEV and the calls drop out at compile time. Probe does
not take the apple,smc phandle either in such a kernel, so High Power
mode stays off and the performance profile switches like any other
(without that, a machine with apple,high-power-mode would fail every
write of "performance" with -ENODEV). The low-power profile then has only
its frequency ceiling, as it already does when the node has no apple,smc
phandle. Kernels with the SMC driver are unchanged.

Fixes: f04da7c ("soc: apple: clpc: J714s: tell the SMC about High Power mode")
Fixes: bdd3bc3 ("soc: apple: clpc: T6050 platform profiles after macOS's power modes")
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
apple_clpc_send_high_power() now tests IS_ENABLED(CONFIG_MFD_MACSMC)
before it talks to the SMC. The host test compiles the extracted
function against its own prelude, which had neither macro, so it
stopped building. Define both, with the SMC driver built in, so the
test keeps exercising the SMC path it checks.

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

Copy link
Copy Markdown
Contributor Author

Review at 69bc2c3.

Right fix. With depends on MFD_MACSMC || !MFD_MACSMC, MFD_MACSMC=m already forces APPLE_CLPC to m, so IS_ENABLED() (true for y and m) is the correct test, and the only configuration that changes is MFD_MACSMC=n. There the two apple_smc_*() callers fold away at compile time, and apple_clpc_smc() is still referenced, so no unused-function warning. Skipping the apple,smc phandle in probe is the important part: without it, high_power would stay true and performance would fail with -ENODEV and keep the low-power ceiling. Same object code with MFD_MACSMC=y, as the body shows, so no row is owed on the Macs. Trailers are human-only.

Not this PR: clpc->hw->high_power_machine ("apple,j714s") is still a board compatible deciding whether High Power mode exists. It's worth moving to a DT/ADT property the loader copies, like the Low Power ceiling.

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.

1 participant