Skip to content

Force SPI PIO on MacBook8,1 so the built-in keyboard works - #9735

Open
jeissonneira wants to merge 5 commits into
omacom:quattrofrom
jeissonneira:fix/macbook81-spi-pio
Open

jeissonneira wants to merge 5 commits into
omacom:quattrofrom
jeissonneira:fix/macbook81-spi-pio

Conversation

@jeissonneira

Copy link
Copy Markdown

Summary

On MacBook8,1 (12-inch Early 2015) the installer already loads applespi and the PXA SPI modules. That is not enough. The GSPI controller (00:15.4) does transfers through the companion DesignWare DMA engine (00:15.0), and on this board those DMA transfers never complete. applespi times out with -110, IRQ 21 stays at zero, and the built-in keyboard and trackpad never work. #1954.

Force the controller into PIO and it probes immediately. dw_dmac_pci is builtin, so the switch is a kernel parameter:

initcall_blacklist=dw_pci_driver_init

Deep/S3 then wedges the same SPI device until reboot, so sleep defaults to s2idle.

Same shape as the ASUS Panther Lake backlight leaf: detect the machine, write a Limine drop-in. No new package. No vendored C.

Changes

  • install/hardware/apple/fix-spi-keyboard.sh — on MacBook8,1 only, write /etc/limine-entry-tool.d/macbook81-spi-pio.conf. Other SPI MacBooks are unchanged.
  • Migration 1788318101.sh for existing installs. Idempotent. Rebuilds the UKI. No-ops on anything that is not MacBook8,1.
  • test/shell.d/macbook81-spi-pio-test.sh
  • Manual note: USB keyboard for the installer itself; glass keys after the first reboot.

Tested

MacBook8,1 (A1534, Early 2015), Core M-5Y31, Omarchy 4.0.2, kernel 7.1.9-arch1-2. Keyboard and trackpad work at LUKS, at the login screen, and after lid close.

The same PIO cmdline is what matthiasjg documented on #1954; the original reporter and two other MacBook8,1s confirmed it.

Speakers, camera, and Bluetooth stay out of this PR.

Fixes #1954

The installer already loads applespi for this model, but DesignWare DMA on
00:15.0 never completes GSPI transfers, so the keyboard and trackpad time
out with -110. Blacklist the builtin dw_dmac_pci initcall so spi-pxa2xx
uses PIO, and default sleep to s2idle because deep/S3 wedges the same
device until reboot.
@Jackwwg83

Copy link
Copy Markdown

Independent confirmation on a second MacBook8,1, plus some register-level measurements of why the DMA path is dead — in case they help the review or the upstream quirk.

Setup: MacBook8,1 (A1534), Omarchy 4.0.0.alpha, kernel 7.1.9-arch1-2, limine UKI, LUKS root. Applied initcall_blacklist=dw_pci_driver_init (via /etc/default/limine, before seeing this PR).

Result after cold boot: pxa2xx_spi_pci 0000:00:15.4: no DMA channels available, using PIO → applespi … modeswitch done. at t=1.4 s; keyboard and trackpad registered; touchpad_dimensions=-5087x-182+10666+6271; 0 timeouts; idle IRQ 21 rate 0/s, CPU 97% idle. Internal keyboard works at the LUKS prompt. The same switch at runtime (unbind dw_dmac_pci → rebind pxa2xx_spi_pci) flips the machine between "-110 every 200 ms, no touchpad" and "works" deterministically, in both directions.

What the failure looks like at the register level (driver bound, applespi retrying, read from a small probe module):

  • SSCR1 = 0x00701dc0 → TSRE|RSRE|TRAIL set, TIE|RIE clear (DMA mode). SSSR = 0x0000f024 → TFS=1, TFL=0, BSY=0. The controller is asserting its TX DMA request and nothing ever moves — the DesignWare engine never services the request at all, rather than starting a transfer that doesn't finish.
  • The SSP and its IRQ path are fine: with the driver unbound, driving SSCR0/SSCR1/SSDR by hand clocks data out (FIFO drains, RX fills), and setting TIE asserts PCI INTx (STATUS bit 3). A sniffer request_irq()'d on GSI 16–23 caught that interrupt on GSI 21 (100k+ hits in 2 s). So IRQ routing, IOMMU, interrupt remapping, PWM_LPSS etc. are not involved. intel_iommu=off was also tested: no effect.
  • One more firmware inconsistency worth knowing: ACPI _PRT gives the DMA engine (00:15.0, INTB) GSI 20, but the PCH routing register D21IR = 0x5554 routes INTB → PIRQF = GSI 21. Linux waits for dw_dmac completions on IRQ 20; this board would deliver them on 21. So even if DMA moved data, its completion interrupt could never reach the driver here.

Upstream is converging on the same answer: fourdollars' series "spi: pxa2xx: MacBook8,1 quirk, runtime PM, and LPSS S3 resume state fixes" (v14, 2026-07-18) adds the DMI quirk in-kernel. Until that reaches Arch's linux, the initcall blacklist in this PR is the right shape. +1 on mem_sleep_default=s2idle too — this box defaults to [deep].

@ken3yang

Copy link
Copy Markdown

I can confirm the fix worked on my Macbook 8,1 ( Macbbok 12-inch 2015)

@roydq

roydq commented Sep 26, 2026

Copy link
Copy Markdown

Confirming on another MacBook8,1 (Omarchy 4.0.4, linux-omarchy 7.2.5-3, Limine + LUKS). Same symptoms: -110 timeouts and IRQ 20/21 stuck at 0. linux-lts 6.18.49 fails identically, and neither intremap=off nor pinning 00:15.4 runtime PM to on helped. CONFIG_DW_DMAC_PCI=y is still set in linux-omarchy, so a modprobe.d blacklist has no effect. initcall_blacklist=dw_pci_driver_init fixes it: the SPI controller falls back to PIO, modeswitch done, and the keyboard and trackpad work from the LUKS prompt onward.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at abba2c44f500717fe1e28f9efd7e3873c94c9b73. The software side is clean. What's left is a test on a real MacBook8,1, which no worker can stand in for.

What ran, on a disposable Omarchy worker:

  • My own reproduction, separate from the PR's test. With the DMI product stubbed to MacBook8,1, current quattro writes no PIO drop-in and has no migration. This head writes /etc/limine-entry-tool.d/macbook81-spi-pio.conf from both the install leaf and migrations/1788318101.sh, and the migration rebuilds the UKI. Rerunning the migration does nothing, and so does a second user after reboot with no marker. MacBook9,1, MacBook10,1, MacBook8,10 and MacBookPro13,1 get nothing.
  • dw_pci_driver_init is a builtin initcall in the shipped kernel (linux-omarchy 7.2.5-3, CONFIG_DW_DMAC_PCI=y), so initcall_blacklist reaches the driver it names.
  • test/shell.d/macbook81-spi-pio-test.sh passes (9/9).
  • ./test/cli and ./test/shell on this head merged into current quattro: the only failures (one CLI test about the vscode theme, 8 shell test files) also fail on quattro without this change.

Second opinion: Codex Medium reviewed the diff. It found the change proportionate and scoped by exact equality to MacBook8,1, and the migration's env overrides follow the T2 migration 1785944594.sh. It raised three edge cases. None needs a change here:

  • limine-mkinitcpio can return zero after a per-kernel failure. That is the limine package's helper and applies to every migration that rebuilds, not just this one.
  • A KERNEL_CMDLINE[default]= assignment (rather than +=) in /etc/default/limine would override the drop-in. Stock Omarchy uses +=, so only a hand-edited config is affected, the same as the existing ASUS and T2 drop-ins.
  • A retry after a failed rebuild checks the running command line only for the blacklist, not for s2idle. This needs the blacklist already applied by hand and an interrupted rebuild, and the next kernel update rebuilds the image with both parameters anyway.

It also noted that the PR's own test checks for strings rather than behaviour. The reproduction above covers the behaviour.

What it waits on: a confirmation on MacBook8,1 hardware at this exact commit. The confirmations here and on #1954 back the parameter itself. For the fix to count as verified, though, it has to be confirmed at this commit by the account that reported the bug. @jpumfrey, you opened #1954. Could you run this commit's migration on your MacBook8,1? If you still have matthiasjg's parameter in /etc/default/limine or another drop-in, remove it first so it doesn't mask the result:

curl -fsSL https://raw.githubusercontent.com/jeissonneira/omarchy/abba2c44f500717fe1e28f9efd7e3873c94c9b73/migrations/1788318101.sh -o /tmp/1788318101.sh
bash -euo pipefail /tmp/1788318101.sh
reboot

After the reboot, please report whether the built-in keyboard works at the LUKS prompt and after a lid close, along with the output of:

cat /proc/cmdline
journalctl -k -b | grep -E 'pxa2xx|applespi'

#12685, a draft roll-up of the Intel Mac work, carries this same change with extra handling for customised config. It describes itself as not yet merge-ready. #9880 and #12684 also edit install/hardware/apple/fix-spi-keyboard.sh, so whichever lands second will need a small rebase.

@gpakosz

gpakosz commented Oct 18, 2026 •

Copy link
Copy Markdown

I confirm that installing Omarchy from scratch with omarchy-4.0.5.iso and then running

curl -fsSL https://raw.githubusercontent.com/jeissonneira/omarchy/abba2c44f500717fe1e28f9efd7e3873c94c9b73/migrations/1788318101.sh -o /tmp/1788318101.sh
bash -euo pipefail /tmp/1788318101.sh
reboot

Makes the trackpad and keyboard work on my Intel MacBook.

$  cat /proc/cmdline
journalctl -k -b | grep -E 'pxa2xx|applespi'
cryptdevice=PARTUUID=18bd5c35-ac59-411e-8166-81eb04cd85c2:root root=/dev/mapper/root zswap.enabled=0 rootflags=subvol=@ rw rootfstype=btrfs resume=/dev/mapper/root resume_offset=1972633 systemd.tty.term.console=dumb initramfs_async=0 quiet splash loglevel=0 systemd.show_status=false rd.udev.log_level=0 vt.global_cursor_default=0 initcall_blacklist=dw_pci_driver_init mem_sleep_default=s2idle
Oct 18 18:08:36 potato kernel: pxa2xx_spi_pci 0000:00:15.4: no DMA channels available, using PIO
Oct 18 18:08:36 potato kernel: applespi spi-APP000D:00: Received corrupted packet (crc mismatch)
Oct 18 18:08:36 potato kernel: applespi spi-APP000D:00: modeswitch done.

@omarchybot

Copy link
Copy Markdown
Collaborator

Checked again at abba2c44f500717fe1e28f9efd7e3873c94c9b73. The head has not moved since the last review. What's new is @gpakosz's confirmation at this exact commit: the migration run after a fresh 4.0.5 install, the keyboard and trackpad working, both parameters on /proc/cmdline, and pxa2xx_spi_pci falling back to PIO followed by applespi … modeswitch done. That is a fourth MacBook8,1 where this works, and the first test of this commit's migration on real hardware. Thank you.

What else was checked: quattro still has no PIO workaround and no migration, so it does not fix this. Since the last review it has added a || true guard to the DMI read in install/hardware/apple/fix-spi-keyboard.sh. This head still merges into current quattro without conflicts, and the merged file keeps that guard. The second opinion, Codex Medium, could not reach GitHub this run. It reviewed the cached diff, agreed that quattro does not fix the bug and that the change sits only inside the MacBook8,1 branch, and found nothing new. It may not have reached that view independently of this review.

What it waits on: marking a hardware fix as verified takes a confirmation at this commit from the person who reported the bug, @jpumfrey on #1954, or from a maintainer. #1954 is closed now, so that confirmation may never come. Until it does, the call is the maintainer's, with gpakosz's confirmation and the earlier ones in front of them.

@jpumfrey

Copy link
Copy Markdown

Apologies for the delay. Tested abba2c4 on my MacBook8,1 (Omarchy 4.0.6, kernel 7.2.8) with my own workarounds removed. The migration wrote macbook81-spi-pio.conf. The controller now uses PIO with no -110 timeouts, and the built-in keyboard works at LUKS, after login and after s2idle suspend. Confirmed fixed, thanks @jeissonneira!

@omarchybot

Copy link
Copy Markdown
Collaborator

Checked again at abba2c44f500717fe1e28f9efd7e3873c94c9b73. The head has not moved. What's new is @jpumfrey's report: they opened #1954, removed their own workarounds, and confirmed this commit on their MacBook8,1. The migration wrote the drop-in, the controller uses PIO with no -110 timeouts, and the keyboard works at LUKS, after login and after s2idle suspend. Thank you for coming back to it.

What else was checked: current quattro (087f73d8) still has no PIO workaround and no migration 1788318101.sh, so it does not fix this. This head still merges into it without conflicts. Codex Medium reviewed the diff again and found nothing blocking. It agreed with the reading below, but it could not reach GitHub this run to read the new comment, so it only saw the code. It may not have reached that view independently of this review.

Why it is not marked verified yet: omabot records a reporter's confirmation only when the comment names the full commit, because a short prefix can be matched by another commit made on purpose. The comment says abba2c4, so the bot cannot record it as verified, even though it plainly means this commit. @jpumfrey, if you reply with the full hash, abba2c44f500717fe1e28f9efd7e3873c94c9b73, the PR can be labelled verified. There is no need to test again.

What it waits on: that reply, or the maintainer, who has the confirmations from @jpumfrey, @gpakosz, @Jackwwg83, @ken3yang and @roydq in front of them.

@MahdiBND

MahdiBND commented Nov 1, 2026

Copy link
Copy Markdown

This is a success story
I can confirm PIO cmdline fixed it on my macbook8,1
Also adding the parameter to installation menuentry fixed the keyboard in installation, too.

omarchybot and others added 3 commits November 2, 2026 05:53
limine-mkinitcpio reports a kernel it could not rebuild and still exits 0. The migration then wrote its machine-wide marker, so a boot image still missing the PIO parameter was never rebuilt again and the keyboard stayed dead. Check the rebuild output as quattro's other rebuild migrations do, and fail without the marker so it retries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
quattro's table-driven quirks test records every file the SPI keyboard leaf writes, and the MacBook8,1 row predates the PIO drop-in this branch adds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

I pushed three commits to this branch. The head is now cd66d1d2eeff0d951dc69626ed9b871d53558820.

What was wrong: limine-mkinitcpio reports a kernel it could not rebuild and still exits 0. When that happened, migrations/1788318101.sh wrote its machine-wide marker anyway. The boot image could be left without the PIO parameter, and with the marker in place the migration would never rebuild it again, so the keyboard would stay dead. The migration now reads the rebuild output, as quattro's other rebuild migrations do. If a kernel was skipped, it exits without the marker and runs again on the next omarchy-migrate. test/shell.d/macbook81-spi-pio-test.sh gains a case for this.

The branch also needed current quattro. Since 2026-10-27, quattro's table-driven test/shell.d/hardware-quirks-test.sh records every file the SPI keyboard leaf writes, and its MacBook8,1 row did not expect macbook81-spi-pio.conf, so this PR would have turned that test red once merged. I merged quattro into the branch, which merged cleanly, and added the drop-in to that row. The fix itself is unchanged.

What was checked: on a disposable Omarchy worker, macbook81-spi-pio-test.sh passes 10 of 10, and the new case fails with the migration reverted to abba2c44. hardware-quirks-test.sh passes, and ./test/cli is green. The full ./test/shell has 5 of 418 files failing: agent-account-exec, ascii, branding-about-animation, first-run and runtime-smoke. All 5 fail the same way on plain quattro, so they are not this PR's. Codex Medium raised the rebuild problem, and then reviewed the three commits and the merge and found no defects. It saw my reasoning first, so its agreement is not independent.

@MahdiBND, thanks for the report. It is one more MacBook8,1 where the PIO parameter fixes the keyboard. The installer's boot entry is in the ISO repository, not here, so that part would be a separate change there.

What it waits on: the maintainer. A worker cannot run MacBook8,1 hardware, so this is not labelled verified. Running the migration again on a machine that already has the fix would not run the changed code, so I am not asking anyone to retest. When a rebuild succeeds, the new head does exactly what abba2c44 did, and the confirmations from @jpumfrey, @gpakosz, @Jackwwg83, @ken3yang, @roydq and now @MahdiBND still describe the fix.

@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; both previous findings are addressed and no new actionable issues were found.

Summary

Adds a MacBook8,1-only boot setting to force SPI PIO and default sleep to s2idle.

  • MacBook8,1 boots with working built-in keyboard and trackpad.

No new actionable issues were found in the changes since the previous review. Tests were not run.

Reviews (2) · Last reviewed commit: "Drop the MacBook8,1 test file in favour ..." · Reviewed by Greptile

Comment thread test/shell.d/macbook81-spi-pio-test.sh Resolved
Comment thread test/shell.d/macbook81-spi-pio-test.sh Resolved
@geeknees

Copy link
Copy Markdown

MacBook8,1 (Early 2015 / Core M-5Y31) hardware validation on Omarchy edge, linux-omarchy 7.2.15-2-omarchy, Omarchy source 9f98609.

  • initcall_blacklist=dw_pci_driver_init is present in the running kernel command line. The built-in keyboard and trackpad work at the encrypted LUKS unlock prompt, on the desktop, and after suspend.
  • A custom ISO with the PIO workaround applied in its live boot path allowed keyboard input during installation; this does not establish that the upstream/unmodified ISO behaves the same way.
  • An independently implemented opt-in S3 LPSS register save/restore hook has been tested on this MacBook8,1. The journal shows three successful PM: suspend entry (deep) → PM: suspend exit cycles, including approximately 8 h 14 m and 27 h 32 m. Each cycle logged S3 LPSS context saved, LPSS restore 0000:00:15.4, and applespi OK after deep S3.
  • This S3 result requires the separate hook; it is not claimed as part of Force SPI PIO on MacBook8,1 so the built-in keyboard works #9735. I agree with keeping s2idle as the conservative default until the opt-in S3 path is reviewed.

Integration PoC and implementation for review: https://github.com/geeknees/omarchy/tree/macbook81/poc-2026-11

I intend to submit the S3 LPSS recovery as a separate opt-in change, rather than duplicate this PR's PIO fix. Thanks for your work on the root cause and the minimal PIO workaround.

AGENTS.md asks for the area's existing test file to be extended rather than a new *-test.sh added, and docs/testing.md gives migrations no suite test. hardware-quirks-test.sh already runs fix-spi-keyboard.sh on MacBook8,1 and expects the PIO drop-in there, and on MacBookPro13,2 and MacBookPro15,1 expects it absent, so the separate file only repeated that and tested the frozen migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

I pushed one commit to this branch. The head is now 1c3be3c178d4a26493e1ccd361c9504e8650f35c.

What changed: Greptile raised two points on cd66d1d2, and both are right under quattro's rules. AGENTS.md asks for the area's existing test file to be extended rather than a new *-test.sh added, and docs/testing.md says migrations get no suite test (since #16302). So this commit deletes test/shell.d/macbook81-spi-pio-test.sh. test/shell.d/hardware-quirks-test.sh already runs fix-spi-keyboard.sh on a MacBook8,1 and expects the PIO drop-in there, and on MacBookPro13,2 and MacBookPro15,1 it expects no drop-in. The install leaf and migrations/1788318101.sh are unchanged.

What was checked: on a disposable Omarchy worker, ./test/cli is green and hardware-quirks-test.sh passes at the new head. Both also pass with the head merged into current quattro (3b36b9e1), which merges without conflicts. With the drop-in removed from the leaf, the quirks test fails on the MacBook8,1 row, so the table does guard the fix.

Second opinion: Codex Medium and muse-wonder (via pi, thinking high) reviewed the commit. Both agreed that Greptile's points hold and that deleting the file is the proportionate answer. They had seen my reasoning first, so that agreement is not independent. Both also suggested two things I have left alone:

  • An assertion on the drop-in's text, since the table records which files a leaf writes but not what is in them. quattro checks its other limine drop-ins (Zenbook A16, Galaxy Book4 Edge 14) by name only, and a test that repeats the heredoc's text is the kind of snapshot docs/testing.md advises against. The maintainer can ask for one if they want it.
  • The migration counts a drop-in as complete once it has the initcall_blacklist parameter, even without mem_sleep_default=s2idle. Only a hand-made file at this PR's own path could miss s2idle, because every revision of this PR writes both parameters together.

@geeknees, thanks for the MacBook8,1 report. 9f98609 is a quattro commit, not one on this branch, so it shows the PIO parameter working on your machine rather than testing this head. A separate opt-in pull request for the S3 restore sounds right.

What it waits on: the maintainer. Since @jpumfrey's confirmation at abba2c44, this branch has gained only test changes, a merge of quattro, and the handling for a kernel that is not rebuilt. When the rebuild succeeds, a MacBook8,1 runs the same code jpumfrey and the others tested. It is still not labelled verified, because no hardware test names this head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working compatibility Make Omarchy work better on everything!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MacBook8,1: built-in keyboard/trackpad not working (applespi timeouts)

9 participants