Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patched touchbar driver not working in kernel 6.0 #189

Open
marc-git opened this issue Dec 20, 2022 · 22 comments
Open

Patched touchbar driver not working in kernel 6.0 #189

marc-git opened this issue Dec 20, 2022 · 22 comments

Comments

@marc-git
Copy link
Contributor

The patched touchbar driver from @PatrickVerner is no longer working on the latest kernel. The compile error I get is
applespi.c:1810:38: error: invalid application of 'sizeof' to incomplete type 'struct efivar_entry'

Confused why this suddenly became a problem. Anyone want to hazard a guess at a solution?

@Sjd-Risca
Copy link

Yes, I can confirm the provided error but it is possible to easily overcome it as described by the following comment: roadrunner2/macbook12-spi-driver#67 (comment)

Still to be published a proper fix upstream to the repository, but at least it is possible quite easily to make it work.

@marc-git
Copy link
Contributor Author

marc-git commented Apr 10, 2023

yeah that's right. I forked it to remove the saving functionality.

@seedneus
Copy link

seedneus commented Jul 4, 2023

@marc-git I still can't compile it under 6.3.8-200.fc38...
"Deprecated feature: REMAKE_INITRD (/var/lib/dkms/applespi/0.1/source/dkms.conf)
Creating symlink /var/lib/dkms/applespi/0.1/source -> /usr/src/applespi-0.1

Building module:
Cleaning build area...
make -j4 KERNELRELEASE=6.3.8-200.fc38.x86_64...(bad exit status: 2)
Error! Bad return status for module build on kernel: 6.3.8-200.fc38.x86_64 (x86_64)
Consult /var/lib/dkms/applespi/0.1/build/make.log for more information.

@gjvanderheiden
Copy link

I used the macbook12-spi-driver-dkms from the AUR. It uses a patch.

@marc-git
Copy link
Contributor Author

Deprecated feature: REMAKE_INITRD (/var/lib/dkms/applespi/0.1/source/dkms.conf)

I can delete that from dkms.conf but it still won't work.

@marc-git
Copy link
Contributor Author

I used the macbook12-spi-driver-dkms from the AUR. It uses a patch.

that patch is not working for me in 6.6.13
what about you ?

@radbirb
Copy link

radbirb commented Feb 4, 2024

patch doesn't work for me on Fedora 39 (6.6.14) or openSUSE Tumbleweed (6.7.2). (note however, did work flawlessly on Debian Stable/6.1.0)
make log:

Sign command: /lib/modules/6.7.2-1-default/build/scripts/sign-file
Signing key: /var/lib/dkms/mok.key
Public certificate (MOK): /var/lib/dkms/mok.pub
Deprecated feature: REMAKE_INITRD (/var/lib/dkms/apple-ibridge/0.1/source/dkms.conf)

Building module:
Cleaning build area...
make -j4 KERNELRELEASE=6.7.2-1-default...(bad exit status: 2)
Error! Bad return status for module build on kernel: 6.7.2-1-default (x86_64)
Consult /var/lib/dkms/apple-ibridge/0.1/build/make.log for more information.
rad@susietosh:~/macbook12-spi-driver> sudo dkms install -m applespi -v 0.1Sign command: /lib/modules/6.7.2-1-default/build/scripts/sign-file
Signing key: /var/lib/dkms/mok.key
Public certificate (MOK): /var/lib/dkms/mok.pub
Deprecated feature: REMAKE_INITRD (/var/lib/dkms/applespi/0.1/source/dkms.conf)

Building module:
Cleaning build area...
make -j4 KERNELRELEASE=6.7.2-1-default...(bad exit status: 2)
Error! Bad return status for module build on kernel: 6.7.2-1-default (x86_64)
Consult /var/lib/dkms/applespi/0.1/build/make.log for more information.
rad@susietosh:~/macbook12-spi-driver> cat /var/lib/dkms/applespi/0.1/build/make.log 
DKMS make.log for applespi-0.1 for kernel 6.7.2-1-default (x86_64)
Sun Feb  4 04:24:31 AM +03 2024
make -C /lib/modules/6.7.2-1-default/build M=/var/lib/dkms/applespi/0.1/build modules
make[1]: Entering directory '/usr/src/linux-6.7.2-1-obj/x86_64/default'
  CC [M]  /var/lib/dkms/applespi/0.1/build/applespi.o
  CC [M]  /var/lib/dkms/applespi/0.1/build/apple-ibridge.o
  CC [M]  /var/lib/dkms/applespi/0.1/build/apple-ib-tb.o
  CC [M]  /var/lib/dkms/applespi/0.1/build/apple-ib-als.o
/var/lib/dkms/applespi/0.1/build/apple-ib-tb.c: In function ‘appletb_fill_report_info’:
/var/lib/dkms/applespi/0.1/build/apple-ib-tb.c:949:9: warning: enumeration value ‘HID_REPORT_TYPES’ not handled in switch [-Wswitch]
  949 |         switch (field->report->type) {
      |         ^~~~~~
/var/lib/dkms/applespi/0.1/build/apple-ibridge.c:905:35: error: initialization of ‘void (*)(struct acpi_device *)’ from incompatible pointer type ‘int (*)(struct acpi_device *)’ [-Werror=incompatible-pointer-types]
  905 |                 .remove         = appleib_remove,
      |                                   ^~~~~~~~~~~~~~
/var/lib/dkms/applespi/0.1/build/apple-ibridge.c:905:35: note: (near initialization for ‘appleib_driver.ops.remove’)
cc1: some warnings being treated as errors
make[3]: *** [/usr/src/linux-6.7.2-1/scripts/Makefile.build:244: /var/lib/dkms/applespi/0.1/build/apple-ibridge.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [/usr/src/linux-6.7.2-1/Makefile:1928: /var/lib/dkms/applespi/0.1/build] Error 2
make[1]: *** [../../../linux-6.7.2-1/Makefile:234: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-6.7.2-1-obj/x86_64/default'
make: *** [Makefile:16: all] Error 2

perhaps someone smarter than me would know a fix? in a last ditch effort I tried the t2linux fork (https://github.com/t2linux/apple-ib-drv), and I ran into the same issue.

@stefand
Copy link

stefand commented Feb 4, 2024

The build error with .remove is trivial to fix, but for me the touch bar doesn't work with 6.6 regardless. The driver detects it, registers the input device, but the touch bar just stays black. It worked ok on Linux 6.1 with the same driver.

It randomly worked twice, but I don't understand why and could not reproduce this.

fix.txt

@radbirb
Copy link

radbirb commented Feb 4, 2024

The build error with .remove is trivial to fix, but for me the touch bar doesn't work with 6.6 regardless. The driver detects it, registers the input device, but the touch bar just stays black. It worked ok on Linux 6.1 with the same driver.

It randomly worked twice, but I don't understand why and could not reproduce this.

fix.txt

Could this be due to usbmuxd binding to the chip? I've managed to get the touchbar working (thank you for the fix! the AUR package seems to work also) on 6.6.15 (Arch Linux LTS) and 6.7.3 (Arch), but it didn't work until I did the this workaround (see roadrunner2/macbook12-spi-driver#42 (comment)), ran into the same thing on 6.1.0 on Debian... so I'm not sure why it's not working for you, though I've yet to test on Fedora/OpenSUSE.

@stefand
Copy link

stefand commented Feb 4, 2024

I don't have usbmuxd running at all. I am now building a 6.1 kernel again to see if something else changed (like accidental deletion of the firmware from the efi boot partition). If things still work with the old kernel I'll try my luck with a bisect.

@stefand
Copy link

stefand commented Feb 6, 2024

With Linux 6.1.76 the touch bar is working with @marc-git 's driver. With 6.4 and 6.6 it doesn't work most of the time. So I have a baseline for bisecting.

A problem is that in "bad" kernels it is randomly starting up, and I haven't figured out why - I estimate that it works 10% of the time. So if the touch bar starts up I have to reboot a few times to make sure the kernel revision is really working and not randomly (un)lucky.

@gjvanderheiden
Copy link

Could this be due to usbmuxd binding to the chip?

I patched /usr/lib/udev/rules.d/39-usbmuxd.rules according to:
libimobiledevice/usbmuxd#138

Instead of using a new script to fix this issue. That works also. Without the patch it was not lighting up.

I used the macbook12-spi-driver-dkms from the AUR. It uses a patch.
that patch is not working for me in 6.6.13
what about you ?

I run Arch Linux, which is shipping the latest kernel version.It's been through server 6.6.x versions. It's on 6.7 by now and haven't had any issues with the TouchBar.

@marc-git
Copy link
Contributor Author

marc-git commented Feb 6, 2024

I run Arch Linux, which is shipping the latest kernel version.It's been through server 6.6.x versions. It's on 6.7 by now and haven't had any issues with the TouchBar.

Are you running with just different usbmuxd rules? No home brew spi drivers?

@gjvanderheiden
Copy link

gjvanderheiden commented Feb 7, 2024

Are you running with just different usbmuxd rules?

yes.
I used the file content @KiLLeRRaT posted in libimobiledevice/usbmuxd#138
This patch is supposed to be shipped in a new version of usbmuxd, but the last version is from 2020.

No home brew spi drivers?

just the one from the AUR package, which has a patch build in. So just yay -S macbook12-spi-driver-dkms

I deleted the generated stuff from the aur package and did a makepkg again, no errors. It is up to date, I update my system regularly.

So in order to get it to work I do:

  • update file /usr/lib/udev/rules.d/39-usbmuxd.rules
  • yay -S macbook12-spi-driver-dkms
  • add the modules to /etc/mkinitcpio.conf: MODULES=(intel_lpss_pci spi_pxa2xx_platform applespi apple-ib-tb)
  • run sudo mkinitcpio -P

@stefand
Copy link

stefand commented Feb 8, 2024

My bisect ended with this kernel commit as the first bad one:

8762069330316392331e693befd8a5b632833618 is the first bad commit
commit 8762069330316392331e693befd8a5b632833618
Merge: 6861eaf79155 833f7d4819a8
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Wed Feb 22 13:41:41 2023 -0800

    Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Suffice to say, this doesn't make much sense. Only with some unlucky random side effect would SCSI-related changes break a USB HID device.

I'll try to build the source branch of that merge and see if I can reproduce the issue. If that's the case I can bisect over the 142 commits the merge introduced.

@gjvanderheiden
Copy link

@stefand that took some effort 💪already

@stefand
Copy link

stefand commented Feb 10, 2024

So my previous bisect ended up with a non-sensical commit because the touch bar luckily worked 3 times with a "bad" kernel.

On a second attempt I ended up with this commit as breaking the touch bar on my system:

e04955db6a7c3fc4a1e6978649b61a6f5f8028e3 is the first bad commit
commit e04955db6a7c3fc4a1e6978649b61a6f5f8028e3
Author: Ronald Tschalär <ronald@innovation.ch>
Date:   Wed Jan 11 10:07:36 2023 +0000

    HID: Recognize sensors with application collections

This makes more sense - it talks about T2 macbooks pro. My MacBookPro14,3 has a touch bar, but not a T2 chip. That would also explain why the touch bar driver works fine for some people here.

@stefand
Copy link

stefand commented Feb 12, 2024

Reverting e04955db on a 6.6 kernel makes the touch bar come up reliably. I guess the problem only affects pre T2 macs. Sadly I don't know the USB technical details to figure out how to fix this properly.

Since the touch bar driver still lives out-of-tree it will be tricky to get the kernel devs to fix it. I'll try to get the attention of the t2linux people.

@gjvanderheiden
Copy link

@stefand I have MacBook 14,3 (A1707). In Mac OS System information, under hardware->Controller I see Apple T1 Security-chip. Firmware 14Y910. The AUR patch I use hasn't been updated, checked that too.

I do run with the I act like I'm Mac OS trick. Found here. I use rEFInd to be precise, shouldn't matter. Maybe that matters.

I boot into Mac OS (Ventura 13.6.4) from time to time too and run the updates in Mac OS. This sometimes updates firmware, could be something too. Though Ventura doesn't receive all the updates anymore.

I might be missing something completely here, but I just don't get why it's working on mine, except I'm on 6.7.4-arch-1 kernel version.

@stefand
Copy link

stefand commented Feb 12, 2024

@gjvanderheiden the touch bar works for me occasionally with an unmodified 6.6 kernel. I don't know if this is runtime luck or has something to do with how the kernel and/or driver are built.

I tried updating to 6.7, but it doesn't change the behavior.

Maybe the presence of usbmuxd influences things in a positive way, at least when the workaround discussed in this bug is used.

@marc-git
Copy link
Contributor Author

marc-git commented Feb 18, 2024

I'll try to get the attention of the t2linux people.

@stefand Any luck with them?

@stefand
Copy link

stefand commented Feb 18, 2024

@marc-git There is no response yet to the bug I filed.

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

No branches or pull requests

6 participants