Repository navigation
pinctrl: apple: do not arm a masked interrupt in set_type - #233
Closed
ryzensnyper wants to merge 1 commit into
Closed
ryzensnyper wants to merge 1 commit into
ryzensnyper wants to merge 1 commit into
Conversation
apple_gpio_irq_set_type() wrote the trigger mode into the pin while the IRQ core had the interrupt masked. The mode field is also the hardware mask, so the masked level interrupt was live, mask_irq() then skipped the hardware, and an asserted line re-fired forever on CPU0. On the iPhone 8 Plus this hung touchscreen module reloads (5 of 8); with the fix 20 of 20 reloads were clean. Every board with Apple GPIO pinctrl uses this driver. Assisted-by: LLM Signed-off-by: Dugs <dugahol@protonmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
Retest on the exact submitted revisions: #234 head
This matches the earlier runs on |
Contributor
|
Thanks @ryzensnyper! This is on main unchanged, with you as author, in 06e093e (tag |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
apple_gpio_irq_set_type()writes the trigger mode into the pin's MODE field unconditionally. On Apple GPIO that field is also the interrupt mask (IN_IRQ_OFF= masked). So a type change on an interrupt the IRQ core holds masked or disabled arms the pin in hardware anyway. That happens onrequest_irq()withIRQF_NO_AUTOEN, or onirq_set_irq_type()while the line is disabled.When that level line asserts,
handle_level_irq()callsmask_ack_irq(). There is noirq_mask_ack, andmask_irq()skips the hardware becauseirqd_irq_masked()is already set, so only the ack happens. The interrupt re-fires forever and wedges the CPU servicing the bank (RCU stall, no backtrace from that CPU).Fix
Write MODE in
set_typeonly when the interrupt is unmasked.apple_gpio_irq_unmask()already applies the stored trigger type. The patch iskernel/patches/drivers/pinctrl/0006-pinctrl-apple-Do-not-arm-a-masked-interrupt-in-set_t.patch.How it was found and tested
On the iPhone 8 Plus (D21), reloading
apple_z2hung the phone 5 of 8 times (plus 1 of 1 with the mailbox IRQ moved to CPU3). First boots never hung.A logging build read the pin register around power-on:
GRP 0(routed to CPU0),MODE 3(level-low armed) andirqd_irq_masked=1. The hang followed within about 5 ms of the controller pulling the line low.GRP 7(unrouted) until the firstirq_startup, which is why first boots never hung.MODE 7while masked, the line goes low with no storm, and 20 of 20 reloads were clean with default IRQ affinities (10 with the logging build, 10 with the final series). Touch worked after every reload.Test procedure:
orchard build <project> --device d21, boot over checkm8/PongoOS, then on the devicermmod apple_z2; modprobe apple_z2ten times, reading/dev/input/event1after each reload.Other devices
This is the pinctrl driver for every Apple SoC Orchard supports, so any board whose driver changes an IRQ type while the line is masked is affected. I have tested only D21.
Tests
python -m unittest discover -s tests: 930 tests. The 4test_ramCLI errors also fail on unmodifiedmainon my host, because the free-disk check fails there. Nothing else fails.The device testing was on a build from
eab974c.mainhas moved since, but not indrivers/pinctrl.Related: #234 (D21 touch) uses this fix for its reload numbers.
🤖 Generated with Claude Code