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 · 44 comments
Open

Patched touchbar driver not working in kernel 6.0 #189

marc-git opened this issue Dec 20, 2022 · 44 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 <[email protected]>
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 <[email protected]>
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.

@almas
Copy link

almas commented May 11, 2024

You can try https://github.com/almas/macbook12-spi-driver/tree/touchbar-driver-hid-driver
I have successfully installed this driver with kernel 6.5.0-28-generic.

@stefand
Copy link

stefand commented May 11, 2024

@almas I don't think this will help on pre-T2 macs. The changes you made to the module are the already discussed build fix, but I don't see anything that would fix the regression introdced by kernel commit e04955db6a.

@almas
Copy link

almas commented May 11, 2024

@stefand I don't know much about it.
Did you see the BrianValente commits?
At least Touchbar is turned on and working without problems for me on Ubuntu 22.04.4 LTS MBP 14.3 A1707 (T1).
Here is my note about it:
https://gist.github.com/almas/5f75adb61bccf604b6572f763ce63e3e

@marc-git
Copy link
Contributor Author

marc-git commented Jun 2, 2024

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

@stefand Still nothin?

@marc-git
Copy link
Contributor Author

marc-git commented Jun 2, 2024

fix.txt

updated my fork again to keep it compiling. Still not working, even with suggestions from @gjvanderheiden to change the usbmuxd rules

@marc-git
Copy link
Contributor Author

@stefand still no answer on t2linux. I wonder if @roadrunner2 would know what is causing this. My MBP is running slower and slower on the newer OSes so I am switching to Linux more often and its getting on my nerves now.

What are the options here? I guess:

  • start a t1linux repo and try to draw in efforts there
  • try to merge some fix to the t2linux kernel that detects t1 and leaves it alone?
  • suffer the pain
  • any more ideas?

@stefand
Copy link

stefand commented Jun 19, 2024

No answer. Sadly I don't have the time to follow up. The only thing I checked is if a 6.8 kernel magically fixed the bug. The result is as expected no, the dark touch bar is not fixed. The commit that causes the regression still reverts cleanly though.

Since the macbook is just a tool to an end I've reverted the commit locally.

@radbirb
Copy link

radbirb commented Jul 24, 2024

@stefand still no answer on t2linux. I wonder if @roadrunner2 would know what is causing this. My MBP is running slower and slower on the newer OSes so I am switching to Linux more often and its getting on my nerves now.

What are the options here? I guess:

* start a t1linux repo and try to draw in efforts there

* try to merge some fix to the t2linux kernel that detects t1 and leaves it alone?

* suffer the pain

* any more ideas?

I think a t1linux project would be a good idea solely to document stuff (like audio now mostly working with davidjo's driver on touchbar macs), not sure if we'd be able to pull in support like t2linux unfortunately :l, the 2016/2017 macbooks are at worst a year (or two) away from losing any form of official support on both proprietary operating systems. (Monterey/Windows 10 in mid 2025, Ventura in 2026), and if you have a touchbar macbook you're basically damned to a far more hassled experience on Linux (moving aside the touchbar, the bcm43602 STILL still half functions with the .txt file, and the .txt file isn't even read on Fedora/Fedora-based distros for some reason, and drowning in suspend or having everything break in said resuming with the "fix" is still a major issue on these laptops regardless of touchbar or not). If we want these laptops to remain usable/up-to-date within the next 3 years, we'd probably have to figure out something soon, so I think starting such a project now wouldn't be a bad idea.

I wish I had the skillset to contribute in a meaningful manner, but I don't see myself having this laptop (MBP2016/13in+TB) around for much longer, especially as my butterfly keyboard deteriorates further and further.

(Note: I also primarily use Linux on mine (Currently EndeavourOS/Arch), but I keep it docked and hooked up so I can work around most of the issues, though undocked i find myself reverting back to Monterey to avoid dealing with half assed WiFi and borked suspend)

@cctfubeet
Copy link

On my 14,2 Macbook Pro the touchbar wasn't lighting up either on the latest kernels, so i had to use stock Fedora 38 for some time, but it suddenly started working on newer kernels and other distros (Void and Artix). The only remarkable change i made on my system was installing unsupported macOS Sonoma through OpenCore Legacy Patcher. Could it be firmware related?

@stefand
Copy link

stefand commented Aug 16, 2024

On which Linux kernel version(s) is it working? I tested an unmodified 6.9 and it still needs the revert. I am running 6.10 now, but with e04955db reverted. I didn't (yet) test 6.10 without this change.

It is possible that a firmware update improved something, but I find it unlikely, though not impossible, that an officially unsupported OSX version would bring a firmware update for this hardware.

Also even with "bad" kernel versions the touch bar started up randomly. My gut feeling says it works 10% of boots, so if you booted 3 or 4 times a lucky streak is certainly possible.

@cctfubeet
Copy link

I'm running latest stock kernel on Void Linux (6.6.46_1).
For testing i made a fresh install, updated it, and installed the driver without early module loading, which made it not light up, but setting it up on dracut made it work again.
I also tested it in Artix with kernel 6.4 with the same results.
Cannot remember the exact kernel versions in which it worked, but stock Fedora 38 and Fedora 40 also worked.
Seems to work every time i boot, as i haven't experienced the touch bar not lighting up except for my past experiences.

@stefand
Copy link

stefand commented Aug 22, 2024

Fwiw it is still broken for me on 6.10. I have to revert the mentioned commit.

@cctfubeet
Copy link

Tried it again using Gentoo's kernel binary version 6.6.47 and the issue came back again, could only make it work once.

@stefand
Copy link

stefand commented Aug 22, 2024

So that rules out that MacOS sonoma did anything?

This might be a race condition. I am not familiar with Dracut, but I think what it changes for this particular case is that it puts the touch bar driver into the initrd. In my case the apple-ibridge and apple-ib-tb modules are not in the initrd and are loaded in the boot process when udev (or rather systemd-udev) loads a bunch of drivers. That is likely to change the module load order and might change the order in which USB devices are initialized.

@skbtwiz
Copy link

skbtwiz commented Sep 25, 2024

How hard would it be to just write a bunch of dkms modules that take care of the wifi .txt fixes as well as reverting the commit for the touchbar? In my humble opinion the largest barrier to entry for working on linux on T1 macbooks is how everyone has to first read through this entire thread, as well as the wifi thread etc. Roadrunner's informational page is long outdated, and there is no updated, well documented source of all the latest information for getting linux working on T1 macbooks. I have a MBP 13,2 sitting unused ready for active development. If there's enough interest I wouldn't be opposed to starting the repo myself. We can focus on first tackling this barrier to entry, and then hopefully we will see more interested people. T1 macbooks are near death in terms of official OS's, now is the time to get the linux effort going. I will most definitely need help though.

@foice
Copy link

foice commented Sep 29, 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.

I am happy to read that it works for you on 6.1, but I am not able to compile it on 6.1.0-25 from Debian 12 fresh install.

DKMS make.log for applespi-0.1 for kernel 6.1.0-25-amd64 (x86_64)
dom 29 set 2024, 15:56:36, CEST
make -C /lib/modules/6.1.0-25-amd64/build M=/var/lib/dkms/applespi/0.1/build modules
make[1]: Entering directory '/usr/src/linux-headers-6.1.0-25-amd64'
  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 ‘int (*)(struct acpi_device *)’ from incompatible pointer type ‘void (*)(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[2]: *** [/usr/src/linux-headers-6.1.0-25-common/scripts/Makefile.build:255: /var/lib/dkms/applespi/0.1/build/apple-ibridge.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/usr/src/linux-headers-6.1.0-25-common/Makefile:2034: /var/lib/dkms/applespi/0.1/build] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.1.0-25-amd64'
make: *** [Makefile:16: all] Error 2

any clue what is this compilation error? I have experience on kernel module compilation, but I made sure I have the linux-header package at least.

@foice
Copy link

foice commented Sep 29, 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

Can you post how to fix that trivial error with the

/var/lib/dkms/applespi/0.1/build/apple-ibridge.c:905:35: error: initialization of ‘int (*)(struct acpi_device *)’ from incompatible pointer type ‘void (*)(struct acpi_device *)’ [-Werror=incompatible-pointer-types]
  905 |                 .remove         = appleib_remove,
      |                                   ^~~~~~~~~~~~~~
/

It is not trivial at all here ;)

@almas
Copy link

almas commented Sep 29, 2024

@foice
Copy link

foice commented Sep 29, 2024

Thanks for the tip. Tried but no success

 DKMS make.log for applespi-0.1 for kernel 6.1.0-25-amd64 (x86_64)
dom 29 set 2024, 16:57:25, CEST
make -C /lib/modules/6.1.0-25-amd64/build M=/var/lib/dkms/applespi/0.1/build modules
make[1]: Entering directory '/usr/src/linux-headers-6.1.0-25-amd64'
  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-ib-als.c: In function ‘appleals_config_iio’:
/var/lib/dkms/applespi/0.1/build/apple-ib-als.c:463:36: warning: passing argument 1 of ‘iio_device_alloc’ makes pointer from integer without a cast [-Wint-conversion]
  463 |         iio_dev = iio_device_alloc(sizeof(als_dev));
      |                                    ^~~~~~~~~~~~~~~
      |                                    |
      |                                    long unsigned int
In file included from /usr/src/linux-headers-6.1.0-25-common/include/linux/iio/buffer.h:10,
                 from /var/lib/dkms/applespi/0.1/build/apple-ib-als.c:32:
/usr/src/linux-headers-6.1.0-25-common/include/linux/iio/iio.h:724:49: note: expected ‘struct device *’ but argument is of type ‘long unsigned int’
  724 | struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv);
      |                                  ~~~~~~~~~~~~~~~^~~~~~
/var/lib/dkms/applespi/0.1/build/apple-ib-als.c:463:19: error: too few arguments to function ‘iio_device_alloc’
  463 |         iio_dev = iio_device_alloc(sizeof(als_dev));
      |                   ^~~~~~~~~~~~~~~~
/usr/src/linux-headers-6.1.0-25-common/include/linux/iio/iio.h:724:17: note: declared here
  724 | struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv);
      |                 ^~~~~~~~~~~~~~~~
In file included from /var/lib/dkms/applespi/0.1/build/apple-ib-als.c:36:
/var/lib/dkms/applespi/0.1/build/apple-ib-als.c:485:72: error: ‘struct iio_dev’ has no member named ‘id’
  485 |         iio_trig = iio_trigger_alloc("%s-dev%d", iio_dev->name, iio_dev->id);
      |                                                                        ^~
/usr/src/linux-headers-6.1.0-25-common/include/linux/iio/trigger.h:166:61: note: in definition of macro ‘iio_trigger_alloc’
  166 |         __iio_trigger_alloc((parent), THIS_MODULE, (fmt), ##__VA_ARGS__)
      |                                                             ^~~~~~~~~~~
/usr/src/linux-headers-6.1.0-25-common/include/linux/iio/trigger.h:166:29: error: passing argument 1 of ‘__iio_trigger_alloc’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  166 |         __iio_trigger_alloc((parent), THIS_MODULE, (fmt), ##__VA_ARGS__)
      |                             ^~~~~~~~
      |                             |
      |                             char *
/var/lib/dkms/applespi/0.1/build/apple-ib-als.c:485:20: note: in expansion of macro ‘iio_trigger_alloc’
  485 |         iio_trig = iio_trigger_alloc("%s-dev%d", iio_dev->name, iio_dev->id);
      |                    ^~~~~~~~~~~~~~~~~
/usr/src/linux-headers-6.1.0-25-common/include/linux/iio/trigger.h:169:56: note: expected ‘struct device *’ but argument is of type ‘char *’
  169 | struct iio_trigger *__iio_trigger_alloc(struct device *parent,
      |                                         ~~~~~~~~~~~~~~~^~~~~~
cc1: some warnings being treated as errors
make[2]: *** [/usr/src/linux-headers-6.1.0-25-common/scripts/Makefile.build:255: /var/lib/dkms/applespi/0.1/build/apple-ib-als.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/var/lib/dkms/applespi/0.1/build/applespi.c: In function ‘applespi_setup_read_txfrs’:
/var/lib/dkms/applespi/0.1/build/applespi.c:590:13: error: ‘struct spi_transfer’ has no member named ‘delay_usecs’
  590 |         dl_t->delay_usecs = applespi->spi_settings.spi_cs_delay;
      |             ^~
/var/lib/dkms/applespi/0.1/build/applespi.c: In function ‘applespi_setup_write_txfrs’:
/var/lib/dkms/applespi/0.1/build/applespi.c:619:13: error: ‘struct spi_transfer’ has no member named ‘delay_usecs’
  619 |         wt_t->delay_usecs = SPI_RW_CHG_DELAY_US;
      |             ^~
/var/lib/dkms/applespi/0.1/build/applespi.c:622:13: error: ‘struct spi_transfer’ has no member named ‘delay_usecs’
  622 |         dl_t->delay_usecs = applespi->spi_settings.spi_cs_delay;
      |             ^~
/var/lib/dkms/applespi/0.1/build/applespi.c:626:13: error: ‘struct spi_transfer’ has no member named ‘delay_usecs’
  626 |         wr_t->delay_usecs = SPI_RW_CHG_DELAY_US;
      |             ^~
/var/lib/dkms/applespi/0.1/build/applespi.c: In function ‘applespi_get_saved_bl_level’:
/var/lib/dkms/applespi/0.1/build/applespi.c:1794:38: error: invalid application of ‘sizeof’ to incomplete type ‘struct efivar_entry’
 1794 |         efivar_entry = kmalloc(sizeof(*efivar_entry), GFP_KERNEL);
      |                                      ^
In file included from /usr/src/linux-headers-6.1.0-25-common/include/linux/string.h:293,
                 from /usr/src/linux-headers-6.1.0-25-common/include/linux/bitmap.h:11,
                 from /usr/src/linux-headers-6.1.0-25-common/include/linux/cpumask.h:12,
                 from /usr/src/linux-headers-6.1.0-25-common/include/linux/smp.h:13,
                 from /usr/src/linux-headers-6.1.0-25-common/include/linux/lockdep.h:14,
                 from /usr/src/linux-headers-6.1.0-25-common/include/linux/mutex.h:17,
                 from /usr/src/linux-headers-6.1.0-25-common/include/linux/kernfs.h:11,
                 from /usr/src/linux-headers-6.1.0-25-common/include/linux/sysfs.h:16,
                 from /usr/src/linux-headers-6.1.0-25-common/include/linux/kobject.h:20,
                 from /usr/src/linux-headers-6.1.0-25-common/include/linux/of.h:17,
                 from /usr/src/linux-headers-6.1.0-25-common/include/linux/irqdomain.h:35,
                 from /usr/src/linux-headers-6.1.0-25-common/include/linux/acpi.h:13,
                 from /var/lib/dkms/applespi/0.1/build/applespi.c:44:
/var/lib/dkms/applespi/0.1/build/applespi.c:1798:28: error: invalid use of undefined type ‘struct efivar_entry’
 1798 |         memcpy(efivar_entry->var.VariableName, EFI_BL_LEVEL_NAME,
      |                            ^~
/usr/src/linux-headers-6.1.0-25-common/include/linux/fortify-string.h:458:34: note: in definition of macro ‘__fortify_memcpy_chk’
  458 |         const size_t __p_size = (p_size);                               \
      |                                  ^~~~~~
/usr/src/linux-headers-6.1.0-25-common/include/linux/fortify-string.h:515:17: note: in expansion of macro ‘__struct_size’
  515 |                 __struct_size(p), __struct_size(q),                     \
      |                 ^~~~~~~~~~~~~
/var/lib/dkms/applespi/0.1/build/applespi.c:1798:9: note: in expansion of macro ‘memcpy’
 1798 |         memcpy(efivar_entry->var.VariableName, EFI_BL_LEVEL_NAME,
      |         ^~~~~~
/var/lib/dkms/applespi/0.1/build/applespi.c:1798:28: error: invalid use of undefined type ‘struct efivar_entry’
 1798 |         memcpy(efivar_entry->var.VariableName, EFI_BL_LEVEL_NAME,
      |                            ^~
/usr/src/linux-headers-6.1.0-25-common/include/linux/fortify-string.h:460:40: note: in definition of macro ‘__fortify_memcpy_chk’
  460 |         const size_t __p_size_field = (p_size_field);                   \
      |                                        ^~~~~~~~~~~~
/usr/src/linux-headers-6.1.0-25-common/include/linux/fortify-string.h:516:17: note: in expansion of macro ‘__member_size’
  516 |                 __member_size(p), __member_size(q),                     \
      |                 ^~~~~~~~~~~~~
/var/lib/dkms/applespi/0.1/build/applespi.c:1798:9: note: in expansion of macro ‘memcpy’
 1798 |         memcpy(efivar_entry->var.VariableName, EFI_BL_LEVEL_NAME,
      |         ^~~~~~
/var/lib/dkms/applespi/0.1/build/applespi.c:1798:28: error: invalid use of undefined type ‘struct efivar_entry’
 1798 |         memcpy(efivar_entry->var.VariableName, EFI_BL_LEVEL_NAME,
      |                            ^~
/usr/src/linux-headers-6.1.0-25-common/include/linux/fortify-string.h:469:27: note: in definition of macro ‘__fortify_memcpy_chk’
  469 |         __underlying_##op(p, q, __fortify_size);                        \
      |                           ^
/var/lib/dkms/applespi/0.1/build/applespi.c:1798:9: note: in expansion of macro ‘memcpy’
 1798 |         memcpy(efivar_entry->var.VariableName, EFI_BL_LEVEL_NAME,
      |         ^~~~~~
/var/lib/dkms/applespi/0.1/build/applespi.c:1800:21: error: invalid use of undefined type ‘struct efivar_entry’
 1800 |         efivar_entry->var.VendorGuid = EFI_BL_LEVEL_GUID;
      |                     ^~
/var/lib/dkms/applespi/0.1/build/applespi.c:1803:15: error: implicit declaration of function ‘efivar_entry_get’; did you mean ‘efi_mokvar_entry_next’? [-Werror=implicit-function-declaration]
 1803 |         sts = efivar_entry_get(efivar_entry, NULL, &efi_data_len, &efi_data);
      |               ^~~~~~~~~~~~~~~~
      |               efi_mokvar_entry_next
/var/lib/dkms/applespi/0.1/build/applespi.c: In function ‘applespi_save_bl_level’:
/var/lib/dkms/applespi/0.1/build/applespi.c:1830:15: error: implicit declaration of function ‘efivar_entry_set_safe’ [-Werror=implicit-function-declaration]
 1830 |         sts = efivar_entry_set_safe((efi_char16_t *)EFI_BL_LEVEL_NAME, efi_guid,
      |               ^~~~~~~~~~~~~~~~~~~~~
/var/lib/dkms/applespi/0.1/build/applespi.c: At top level:
/var/lib/dkms/applespi/0.1/build/applespi.c:2228:27: error: initialization of ‘void (*)(struct spi_device *)’ from incompatible pointer type ‘int (*)(struct spi_device *)’ [-Werror=incompatible-pointer-types]
 2228 |         .remove         = applespi_remove,
      |                           ^~~~~~~~~~~~~~~
/var/lib/dkms/applespi/0.1/build/applespi.c:2228:27: note: (near initialization for ‘applespi_driver.remove’)
cc1: some warnings being treated as errors
make[2]: *** [/usr/src/linux-headers-6.1.0-25-common/scripts/Makefile.build:255: /var/lib/dkms/applespi/0.1/build/applespi.o] Error 1
make[1]: *** [/usr/src/linux-headers-6.1.0-25-common/Makefile:2034: /var/lib/dkms/applespi/0.1/build] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.1.0-25-amd64'
make: *** [Makefile:16: all] Error 2

@stefand
Copy link

stefand commented Sep 29, 2024

foice, when I called the fix "trivial" I meant it for someone who is proficient in the C programming language. If you don't know the language it isn't easy of course.

I don't know why Almas' code fails for you, but I can try to describe what you need to change to fix your original error:

in apple-ibridge.c change

static int appleib_remove(struct acpi_device *acpi)
to
static void appleib_remove(struct acpi_device *acpi)

i.e., change the "int" to "void".

Then at the end of the function change
return 0;
to
return;

almas/macbook12-spi-driver@3355ca7#diff-984f3aa56499b4f3f2430ce4ff6da90aa14c970c7cf0acbc11790f566f619926 shows a diff that you can try to download and apply instead of hand editing.

@foice
Copy link

foice commented Oct 12, 2024

doing the opposite change of what you wrote did the trick, i.e. it works if I use the function as int. Then I did modprobe intel_lpss_pci spi_pxa2xx_platform applespi apple-ib-tb, it gave no errors, and rebooted. Now the touchbar works.

@marc-git
Copy link
Contributor Author

doing the opposite change of what you wrote did the trick, i.e. it works if I use the function as int. Then I did modprobe intel_lpss_pci spi_pxa2xx_platform applespi apple-ib-tb, it gave no errors, and rebooted. Now the touchbar works.

You're using Kernel 6.1.xx right? I think that is no longer relevant to the discussion here. We are looking at changes after the kernel modification that stefand rolls back.

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

10 participants