Bug 2166209 - MacBookPro14,1 Keyboard Non-Working During Boot
Summary: MacBookPro14,1 Keyboard Non-Working During Boot
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: dracut
Version: 37
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Pavel Valena
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-02-01 07:23 UTC by Jonathan Steffan
Modified: 2024-03-14 13:18 UTC (History)
22 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-03-28 11:06:21 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
hardware specifics (20.85 KB, text/plain)
2023-02-01 07:44 UTC, Jonathan Steffan
no flags Details
dracut patch which should fix this (499 bytes, patch)
2023-02-01 08:20 UTC, Hans de Goede
no flags Details | Diff
gendiff dracut-057 against rawhide source (633 bytes, patch)
2023-02-18 07:14 UTC, Jonathan Steffan
no flags Details | Diff

Description Jonathan Steffan 2023-02-01 07:23:19 UTC
1. Please describe the problem:

During boot, the keyboard does not work.

The keyboard works during the live image and anaconda. If you choose to encrypt the disk, upon rebooting you are unable to enter your luks passphrase.

https://ask.fedoraproject.org/t/cannot-enter-luks-password-on-macbook-pro-2017-the-built-in-keyboard-does-not-work/20343/4

2. What is the Version-Release number of the kernel:

6.0.16-300.fc37.x86_64


3. Did it work previously in Fedora? If so, what kernel version did the issue
   *first* appear?  Old kernels are available for download at
   https://koji.fedoraproject.org/koji/packageinfo?packageID=8 :

I had the issue in F36 and waited for the F37 release to test further. Based on the Ask Fedora, this has been an issue since F35 or earlier.


4. Can you reproduce this issue? If so, please provide the steps to reproduce
   the issue below:

Install F37 Workstation and configure full disk encryption.
Unable to use keyboard input when luks passphrase is required using the laptop hardware.


5. Does this problem occur with the latest Rawhide kernel? To install the
   Rawhide kernel, run ``sudo dnf install fedora-repos-rawhide`` followed by
   ``sudo dnf update --enablerepo=rawhide kernel``:

Yes, kernel-6.2.0-0.rc6.44.fc38.x86_64 has the same issue.


6. Are you running any modules that not shipped with directly Fedora's kernel?:

No.


7. Please attach the kernel logs. You can get the complete kernel log
   for a boot with ``journalctl --no-hostname -k > dmesg.txt``. If the
   issue occurred on a previous boot, use the journalctl ``-b`` flag.

N/A


To debug, I attached an USB connected keyboard to input the luks passphrase.

I've been able to get the keyboard working by enabling the spi_pxa2xx_platform driver. It's currently being built as a module, but is not available during boot.

1) If you can attach an external keyboard and boot, update the initramfs using dracut:

```
# echo 'add_drivers+=" spi_pxa2xx_platform "' > /etc/dracut.conf.d/spi_pxa2xx_platform.conf
# dracut -f /boot/initramfs-`uname -r`.img `uname -r`
```

Reboot and the keyboard works.


2) Build a custom kernel with the following patch:

```
diff --git a/kernel-x86_64-fedora.config b/kernel-x86_64-fedora.config
index 94bfe19ba..9aced94dd 100644
--- a/kernel-x86_64-fedora.config
+++ b/kernel-x86_64-fedora.config
@@ -6828,7 +6828,7 @@ CONFIG_SPI_MUX=m
 # CONFIG_SPI_MXIC is not set
 # CONFIG_SPI_NXP_FLEXSPI is not set
 # CONFIG_SPI_OC_TINY is not set
-CONFIG_SPI_PXA2XX=m
+CONFIG_SPI_PXA2XX=y
 # CONFIG_SPI_ROCKCHIP is not set
 # CONFIG_SPI_SC18IS602 is not set
 # CONFIG_SPI_SIFIVE is not set
```

Install and boot the kernel, then the keyboard works for luks passphrase input.

Comment 1 Jonathan Steffan 2023-02-01 07:44:36 UTC
Created attachment 1941475 [details]
hardware specifics

`lshw` running the rawhide kernel

Comment 2 Hans de Goede 2023-02-01 08:19:54 UTC
Thank you for your detailed bugreport.

I see that you have already found the dracut.conf workaround yourself.

I believe that the right fix for this is to make dracut treat the spi_pxa2xx_platform module the same as the i8042 driver for ps2 keyboards and make dracut include it in the initrd when either hostonly=n, or when it is loaded on the machine.

I'll attach a quick test patch for this, to apply run:

cd /
sudo patch -p0 < dracut-test-patch

Drop your custom /etc/dracut.conf.d./spi_pxa2xx_platform.conf file and then regenerate an initrd, and see if that initrd still works.

If you can confirm that this change works, then I'll submit it to upstream dracut and coordinate with the Fedora dracut maintainer about getting this change into Fedora.

Comment 3 Hans de Goede 2023-02-01 08:20:45 UTC
Created attachment 1941480 [details]
dracut patch which should fix this

Comment 4 Jonathan Steffan 2023-02-01 08:40:21 UTC
Hans,

Thanks for the quick reply. I'm currently re-installing the hardware with the release live image, but unfortunately I don't have access to the patch you are suggesting.

Comment 5 Hans de Goede 2023-02-01 08:57:49 UTC
(In reply to Jonathan Steffan from comment #4)
> Thanks for the quick reply. I'm currently re-installing the hardware with
> the release live image, but unfortunately I don't have access to the patch
> you are suggesting.

The patch is attached to this bug, see the attachment list near the top of the bugzilla page.

Comment 6 Jonathan Steffan 2023-02-01 09:03:09 UTC
Hans,

I get the following message when accessing https://bugzilla.redhat.com/attachment.cgi?id=1941480

```
Sorry, you are not authorized to access attachment #1941480 [details]. 
```

Comment 7 Hans de Goede 2023-02-01 09:06:15 UTC
My bad, bugzilla has new defaults where it marks attachments as private by default and I remove the private mark from the comment assuming that would make the attachment non private, but it has its own private flag...

You should be able to access it now.

Comment 8 Jonathan Steffan 2023-02-01 09:25:58 UTC
Hans,

It works as expected. Thanks.

Comment 9 Jonathan Steffan 2023-02-01 09:31:48 UTC
(In reply to Jonathan Steffan from comment #8)
> Hans,
> 
> It works as expected. Thanks.

Sorry if it was not clear. The patch to /usr/lib/dracut/modules.d/90kernel-modules/module-setup.sh does fix the keyboard input issues.

Comment 10 Hans de Goede 2023-02-01 09:48:09 UTC
Thank you for testing.

When I can make some time for this I'll submit a pull-request to dracut upstream and see if I can get this included as a downstream Fedora patch for now.

Comment 11 Hans de Goede 2023-02-01 09:52:00 UTC
Changing component to dracut.

Fedora dracut maintainers see the attached patch (which directly patches an installed dracut) for a fix for this.

The logic behind the patch is that just like the i8042 module which is needed for ps/2 keyboards found on many PCs on some MacBooks the spi_pxa2xx_platform module is necessary because it is the driver for the bus (SPI in this case) to the keyboard.

The patched section honors the hostonly flag, so the module will only be included when necessary.

I think it would be good to add this as a downstream patch to Fedora for now.

I plan to submit a pull-req for this upstream, but I'm quite swamped with work. So if you have time I would not mind if you submit it upstream instead :)

Comment 12 Jonathan Steffan 2023-02-18 07:12:06 UTC
Dracut maintainers,

I tried applying this as a patch and have not yet understood how %autosetup works. %autosetup -S git_am seems to not like my patch.

```
diff --git a/dracut.spec b/dracut.spec
index 0f89845..f0c31c0 100644
--- a/dracut.spec
+++ b/dracut.spec
@@ -7,7 +7,7 @@
 %global __requires_exclude pkg-config
 
 # rpmdev-bumpspec and releng automation compatible variable
-%global baserelease 6
+%global baserelease 7
 
 Name: dracut
 Version: 057
@@ -45,6 +45,10 @@ Patch2: 1991-feat-dmsquash-live-add-new-dmsquash-live-autooverlay.patch
 # https://github.com/dracutdevs/dracut/pull/2037
 Patch3: 2037-Add-sysctl-to-initramfs-to-handle-modprobe-files.patch
 
+# Add spi-pxa2xx-platform for luks unlock input support for apple hardware
+# https://bugzilla.redhat.com/show_bug.cgi?id=2166209
+Patch4: rhbz-attachment-1941480-add-spi-pxa2xx-platform.patch
+
 BuildRequires: bash
 BuildRequires: git-core
 BuildRequires: pkgconfig(libkmod) >= 23
@@ -444,6 +448,9 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
 %{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
 
 %changelog
+* Fri Feb 17 2023 Jonathan Steffan <jsteffan> - 057-7
+- Add spi-pxa2xx-platform for luks unlock input support for apple hardware
+
 * Thu Jan 19 2023 Fedora Release Engineering <releng> - 057-6
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
```

Comment 13 Jonathan Steffan 2023-02-18 07:14:14 UTC
Created attachment 1944926 [details]
gendiff dracut-057 against rawhide source

Comment 14 Jonathan Steffan 2023-02-18 07:18:59 UTC
Checking patch test/container/Dockerfile-Fedora-latest...
Checking patch test/container/Dockerfile-OpenSuse-latest...
Applied patch man/dracut.cmdline.7.asc cleanly.
Applied patch modules.d/90dmsquash-live-autooverlay/create-overlay-genrules.sh cleanly.
Applied patch modules.d/90dmsquash-live-autooverlay/create-overlay.sh cleanly.
Applied patch modules.d/90dmsquash-live-autooverlay/module-setup.sh cleanly.
Applied patch pkgbuild/dracut.spec cleanly.
Applied patch test/TEST-16-DMSQUASH/create-root.sh cleanly.
Applied patch test/TEST-16-DMSQUASH/test-init.sh cleanly.
Applied patch test/TEST-16-DMSQUASH/test.sh cleanly.
Applied patch test/container/Dockerfile-Arch cleanly.
Applied patch test/container/Dockerfile-Debian cleanly.
Applied patch test/container/Dockerfile-Fedora-latest cleanly.
Applied patch test/container/Dockerfile-OpenSuse-latest cleanly.
+ /usr/lib/rpm/rpmuncompress /builddir/build/SOURCES/2037-Add-sysctl-to-initramfs-to-handle-modprobe-files.patch
+ /usr/bin/git am --reject -q
Checking patch modules.d/90kernel-modules/module-setup.sh...
Hunk #1 succeeded at 156 (offset 9 lines).
Applied patch modules.d/90kernel-modules/module-setup.sh cleanly.
+ /usr/lib/rpm/rpmuncompress /builddir/build/SOURCES/rhbz-attachment-1941480-add-spi-pxa2xx-platform.patch
+ /usr/bin/git am --reject -q
Checking patch modules.d/90kernel-modules/module-setup.sh...
Applied patch modules.d/90kernel-modules/module-setup.sh cleanly.
fatal: empty ident name (for <>) not allowed
error: Bad exit status from /var/tmp/rpm-tmp.fdnlur (%prep)
    Bad exit status from /var/tmp/rpm-tmp.fdnlur (%prep)

RPM build errors:
DEBUG: Child return code was: 1

Comment 15 Pavel Valena 2023-02-21 01:34:36 UTC
Hello,

I've created an upstream PR:
https://github.com/dracutdevs/dracut/pull/2218

as well as prepared upgrade with the change for Rawhide: https://src.fedoraproject.org/rpms/dracut/pull-request/29

(Note: MODIFIED usually means the change is commited in dist-git)

With the merge for Rawhide I'll build for F38 as well as for F37 (& will inform in devel ML).

Comment 16 Jonathan Steffan 2023-02-21 02:01:22 UTC
Pavel,

I can confirm the rawhide build fixes the issue with this hardware.

Testing process was:

1) usb boot rawhide live on the affected hardware https://koji.fedoraproject.org/koji/taskinfo?taskID=97742383
2) install w/enabling luks full disk encryption
3) first boot, no keyboard working; add usb external keyboard and finish boot
4) add copr pvalena/dracut and update dracut, dracut -f [...], reboot
5) keyboard is working as expected. lsinitrd confirms spi-pxa2xx-platform is included

Comment 17 Pavel Valena 2023-02-21 09:13:28 UTC
Thanks for checking!

There were further questions in the upstream PR: https://github.com/dracutdevs/dracut/pull/2218

Comment 18 Jonathan Steffan 2023-02-25 20:27:12 UTC
Pavel,

dracut-059-3 has landed in the Rawhide live composes. I can report that Fedora-Workstation-Live-Rawhide-20230225.n.0 (https://koji.fedoraproject.org/koji/buildinfo?buildID=2159709) installs and the keyboard works for LUKS passphrase input.

Fedora-Workstation-Live-38-20230225.n.0 (https://koji.fedoraproject.org/koji/buildinfo?buildID=2159762) still has the issue, but dracut was not yet listed in the Fedora 38 compose report. I'll keep an eye on the F38 compose for when dracut-059-3+ lands and report back.

I'm also glad to see upstream merged the change.

Comment 19 Jonathan Steffan 2023-03-26 23:42:02 UTC
Pavel,

I'm glad to report that Fedora-Workstation-Live-38-20230326.n.1 (https://koji.fedoraproject.org/koji/buildinfo?buildID=2175839) installs and the keyboard works for LUKS passphrase input.

Comment 20 Pavel Valena 2023-03-28 11:06:21 UTC
Thanks for the verification!

Comment 21 Ludek Smolik 2024-03-14 13:18:13 UTC
It still doesn't work for me (I have to use an external usb keyboard).
Macbook Pro 16"(2019), 6.7.6-201.fsync.fc39.x86_67


Note You need to log in before you can comment on or make changes to this bug.