Skip to content

Apple platform: small independent fixes (DART page tables, SMC, PWM, LEDs, SPMI, tipd, AVD, ALSA, tas2764) - #368

Merged
RyanTheTide merged 17 commits into
aurora-silicon:integration/aurorafrom
jgoyvaerts:m4pro/small-fixes
Oct 23, 2026
Merged

RyanTheTide merged 17 commits into
aurora-silicon:integration/aurorafrom
jgoyvaerts:m4pro/small-fixes

Conversation

@jgoyvaerts

Copy link
Copy Markdown
Contributor

Sixteen small fixes found while bringing up the MacBook Pro J616s (M4 Pro). None needs T6040 support; each is
independent and can be taken or dropped on its own.

  • iommu/io-pgtable-dart: refuse a multi-page map that runs past the output address size.
  • mfd: macsmc: bound the atomic write poll (power-off/reboot hung forever on a silent SMC).
  • pwm: apple: refuse a 0 Hz input clock (later period maths divides by it).
  • leds: pwm: turn PWM LEDs off at shutdown (the keyboard backlight stayed lit after power-off).
  • power: supply: macsmc-power: return threshold read errors, refuse thresholds outside 0..100.
  • Input: macsmc-input: set up wakeup before registering the SMC notifier.
  • soc: apple: pmgr-misc: check devm_platform_ioremap_resource_byname() with IS_ERR().
  • spmi: apple: fail a command whose reply word names another opcode or target.
  • soc: apple: rtkit: log unknown oslog messages at debug level instead of warning.
  • HID: magicmouse: validate the MTP touchpad dimensions, close the device on errors.
  • usb: typec: tipd: clear a failed partner registration, report a failed role change.
  • usb: typec: tipd: sn201202x: look up the USB role switch before waking the chip (probe deferral no longer
    cycles the chip through S0).
  • media: apple: avd: reset at once on a VP decode error instead of waiting for the watchdog.
  • media: v4l2-mem2mem: cancel the job work before freeing the device (also worth sending to linux-media).
  • ALSA: pcm_dmaengine: report an XRUN when the DMA channel reports DMA_ERROR.
  • ASoC: tas2764: do not decode an unreadable interrupt latch as faults.

Hardware tested on: Apple MacBook Pro (16-inch, M4 Pro, 2024), J616s / T6040, macOS 26.x firmware, booted by our own loader (not aurora's m1n1) with our private T6040 device tree.

How tested: Each fix runs in our daily kernel on the J616s (aurora-wip 7.1.12 base plus our series). Seen on hardware:
the keyboard backlight now goes dark at power-off; the VP9 decode-error reset (browser VP9 streams); the sn201202x
deferral (no repeated wake cycles at boot); the tas2764 latch read on the speaker amps. The others are code-review fixes
that never fired on this machine.

Not tested / limits: The DART output-size check, SMC atomic timeout, zero PWM clock, magicmouse dimension checks, SPMI reply
mismatch, tipd partner failure and v4l2-mem2mem cancel paths were found by review and never triggered. No other Mac
was tested.

Base: integration/aurora (44d5afc). Built and checked there (aurora's defconfig, W=1 on every touched object, checkpatch --strict). Hardware testing was done on our daily tree, which is based on aurora-wip (Linux 7.1.12) and runs this code.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K4TC3f2CpzFxhnEziL9wcg

dart_map_pages() checks only that the first physical address fits the
output address size. A multi-page request that starts below the limit
and runs past it is accepted, and the pages beyond the limit get
truncated output addresses in their PTEs.

Check the whole range: refuse the request with -ERANGE when pgcount
pages from paddr do not fit below 1 << oas.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
apple_smc_write_atomic() is used with interrupts off (power-off and
reboot through macsmc-reboot) and polled RTKit until the reply came,
with no limit: an SMC that never answers hung the CPU in the reboot
path for good.

Poll with read_poll_timeout_atomic() for at most SMC_TIMEOUT_MS and
return -ETIMEDOUT after that. A timed-out command is not cancelled and
still owns the shared-memory buffer, so leave atomic_pending set and
refuse further atomic writes with -EBUSY instead of reusing the buffer.
A reply with the wrong sequence number does not tell whether the
command finished either; treat it the same way.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
apple_pwm_probe() only checked the clock rate against NSEC_PER_SEC. A
clock that reports 0 Hz passed and every later period and duty cycle
computation divided by it. Refuse it at probe time as well.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
The LED class turns an LED off only when it is unregistered, which
does not happen at power-off or reboot, so a PWM LED keeps its last
duty cycle while the machine goes down. On the Apple laptops the
keyboard backlight stays lit after the screen has gone dark.

Add a shutdown hook that disables sysfs writes (under led_access, as
led_sysfs_disable() requires), drains the brightness work and applies
zero duty once.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
The charge control end threshold getter ignored the result of the SMC
read and reported whatever was in the buffer when the read failed.
Return the error instead.

Writes outside 0..100 to the start or end threshold were passed on to
the key-specific code, which clamps some of them silently. Refuse them
with -EINVAL.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
The wakeup source was initialised after the SMC notifier was
registered and was never torn down. Initialise it with
devm_device_init_wakeup() before the notifier, so that on removal the
notifier is unregistered (and its running callbacks drained) while the
input device and the wakeup source still exist.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
devm_platform_ioremap_resource_byname() returns an error pointer, never
NULL. A PMGR node without the "fabric-ps" or "dcs-ps" register range,
which both are optional, therefore had its error pointer dereferenced by
the following readl_relaxed().

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
Coprocessor firmware on newer SoCs sends oslog message types this
driver does not handle. Nothing acts on them and they are harmless, but
each one logs a warning. Log them at debug level, like the oslog
notifications already are.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
magicmouse_open() returned without hid_hw_close() when the multitouch
request or the dimensions request failed, and published geometry from
a dimensions report without checking it. Check the report ID, require
a positive span on both axes and a nonzero size and resolution before
setting any axis, and close the device on every error path.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
tps6598x_connect() left an ERR_PTR in tps->partner when
typec_register_partner() failed. Its "already connected" check then
treated the port as connected, so no later connect could register the
partner. Clear it, as the cd321x path does.

tps6598x_dr_set() ignored the result of tps6598x_set_data_role(), so a
role switch that failed was reported to the Type-C class as done.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
The AVD firmware reports a VP's error interrupt as a bare slot number.
The IRQ handler only logged it and left the job to the watchdog, so
every decode error (seen with VP9 streams from a web browser) stalled
the decoder for the whole watchdog timeout.

The VP that reported the error has stopped, and the PP is only started
on a VP done, so the job cannot complete. Run the watchdog at once: it
resets the AVD and fails only that frame, and it ignores a job the
hardware does not own.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
v4l2_m2m_release() freed the m2m device while its job_work could still
be queued or running, for example when a driver is unbound right after
a job was scheduled. The worker then runs on freed memory. Cancel it
first.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
snd_dmaengine_pcm_pointer() handles DMA_IN_PROGRESS and DMA_PAUSED and
treats every other status as position 0. A channel that reports
DMA_ERROR has stopped moving data, but the PCM core keeps seeing a
valid position at the start of the buffer, so the stream neither
advances nor ends: playback stalls silently until the application
gives up.

Return SNDRV_PCM_POS_XRUN for DMA_ERROR, so the core stops the stream
with an XRUN and user space can recover by preparing it again.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
The IRQ handler reads the six interrupt latch registers with
snd_soc_component_read() into a u8 array. On a failed read that
function returns the negative errno, which truncates to a byte with
most bits set: the handler then logs over-temperature, over-current and
most other faults that never happened, and the context bytes are
garbage.

Read the latches with regmap_read() and return IRQ_NONE, with a
rate-limited error, when one of them cannot be read.

Fixes: dae191f ("ASoC: tas2764: Add IRQ handling")
Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
The reply word carries the opcode and the target ID of the command it
answers. When they do not match the command just sent, the FIFO is out
of step with the commands, and the data that follows belongs to another
transaction.

Fail the command with -EIO and mark the controller as failed, as after
a timeout, instead of returning that data to the caller.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
tipd_init() defers until the connector's USB role switch (the dwc3) is
registered, but only after it has woken the chip, switched it to S0
and set its interrupt mask, and the deferral then puts the chip back
to sleep. With both drivers loaded by udev at boot that cycle could
repeat several times. Look the role switch up in sn201202x_probe() and
defer there instead, before the chip is touched. A connector without a
role switch, or one whose remote node is disabled, gives NULL and the
probe continues as before.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
This reverts commit d5a8234. integration/aurora now has the same
check in ce32dd5 ("soc: apple: pmgr-misc: sleep under PMP only
while it runs, quieter probe"), which also returns the error instead of
false. Without this revert the branch conflicts with it.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Assisted-by: LLM
@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

integration/aurora now has the same pmgr-misc IS_ERR() check (ce32dd5), so I added a revert of d5a8234 on top; the branch merges cleanly with the 7.3 integration again.

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