0

My system is an Intel nuc (NUC6CAYH), running Debian 11. I'm trying to install a kernel module to interact with the programmable LEDs via acpi. I have successfully installed this module on an identical system under Ubuntu 20.04 LTS, but it fails to install on Debian 11.

The driver is here: https://github.com/milesp20/intel_nuc_led

My install procedure:

git clone https://github.com/milesp20/intel_nuc_led.git
cd intel_nuc_led
sudo make dkms-deb
sudo dpkg -i /var/lib/dkms/intel-nuc-led/1.0/deb/intel-nuc-led-dkms_1.0_all.deb

The output of the last command:

Selecting previously unselected package intel-nuc-led-dkms.
(Reading database ... 89355 files and directories currently installed.)
Preparing to unpack .../intel-nuc-led-dkms_1.0_all.deb ...
Unpacking intel-nuc-led-dkms (1.0) ...
Setting up intel-nuc-led-dkms (1.0) ...
Removing old intel-nuc-led-1.0 DKMS files...

------------------------------
Deleting module version: 1.0
completely from the DKMS tree.
------------------------------
Done.
Loading new intel-nuc-led-1.0 DKMS files...
Building for 5.10.0-10-amd64
Building for architecture x86_64
Building initial module for 5.10.0-10-amd64
Error! Bad return status for module build on kernel: 5.10.0-10-amd64 (x86_64)
Consult /var/lib/dkms/intel-nuc-led/1.0/build/make.log for more information.
dpkg: error processing package intel-nuc-led-dkms (--install):
 installed intel-nuc-led-dkms package post-installation script subprocess returned error exit status 10
Errors were encountered while processing:
 intel-nuc-led-dkms

And, looking at that log file:

DKMS make.log for intel-nuc-led-1.0 for kernel 5.10.0-10-amd64 (x86_64)
Tue 21 Dec 2021 02:26:47 PM EST
make: Entering directory '/usr/src/linux-headers-5.10.0-10-amd64'
  CC [M]  /var/lib/dkms/intel-nuc-led/1.0/build/nuc_led.o
/var/lib/dkms/intel-nuc-led/1.0/build/nuc_led.c: In function ‘init_nuc_led’:
/var/lib/dkms/intel-nuc-led/1.0/build/nuc_led.c:475:75: error: passing argument 4 of ‘proc_create’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  475 |         acpi_entry = proc_create("nuc_led", nuc_led_perms, acpi_root_dir, &proc_acpi_operations);
      |                                                                           ^~~~~~~~~~~~~~~~~~~~~
      |                                                                           |
      |                                                                           struct file_operations *
In file included from /var/lib/dkms/intel-nuc-led/1.0/build/nuc_led.c:36:
/usr/src/linux-headers-5.10.0-10-common/include/linux/proc_fs.h:109:122: note: expected ‘const struct proc_ops *’ but argument is of type ‘struct file_operations *’
  109 | struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct proc_ops *proc_ops);
      |                                                                                                   ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [/usr/src/linux-headers-5.10.0-10-common/scripts/Makefile.build:285: /var/lib/dkms/intel-nuc-led/1.0/build/nuc_led.o] Error 1
make[1]: *** [/usr/src/linux-headers-5.10.0-10-common/Makefile:1846: /var/lib/dkms/intel-nuc-led/1.0/build] Error 2
make: *** [/usr/src/linux-headers-5.10.0-10-common/Makefile:185: __sub-make] Error 2
make: Leaving directory '/usr/src/linux-headers-5.10.0-10-amd64'

So, to recap, it builds and installs fine on Ubuntu 20.04 LTS using kernel 5.4.0-91, but fails on Debian 11 using kernel 5.10.0-10.

Thanks.

1
  • 1
    I assume you're looking for a more elaborate answer than "because it's a PoC, unmaintained kernel module that's has only been tested on 4.4.x kernels"? Commented Dec 23, 2021 at 8:25

1 Answer 1

3

Breaking changes in Linux kernel v5.6

This relates to changes in the Linux kernel as regards the proc_create API that were introduced with the release of version 5.6, but the required code changes to get it to build with versions released since then are thankfully quite minimal.

Put simply, the fourth argument of proc_create was changed from struct file_operations *proc_fops to struct proc_ops *proc_ops. Looking deeper, we can see that it removes the owner member of the struct entirely and renames the read and write members to proc_read and proc_write.

To make this build on your kernel, open the nuc_led.c file and replace lines 446-450 with the following code snippet (or continue to read the next section of this response for a link to a patch file that includes these changes along with several more to the module's build system and DKMS configurations):

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
static struct proc_ops proc_acpi_operations = {
    .proc_read     = acpi_proc_read,
    .proc_write    = acpi_proc_write,
};
#else
static struct file_operations proc_acpi_operations = {
    .owner    = THIS_MODULE,
    .read     = acpi_proc_read,
    .write    = acpi_proc_write,
};
#endif

Further observations

As regards this cited use case specifically, and not the broader issue of the breaking changes in kernel release version 5.6 which this answer may also help provide a solution to, I had some additional observations about the linked repository in the question, namely:

  1. It has open pull requests which address this issue in similar fashion to my own solution that have gone years without even a comment from the repository owner, leading me to conclude that,
  2. This module is de facto abandonware, and (most critically),
  3. It falls into several known bad practices regarding the DKMS system and its configuration.

A review of the Makefile and corresponding dkms.conf file in the repository led me to a prima facie conclusion that it would not correctly build for multiple kernel versions other than the one used to boot the running system (though I got lazy and failed to test my assumption before proceeding with the edits provided below). They have been tested on Kubuntu 21.10 "Impish Indri" and built successfully on both the v5.15 and v5.16 kernels. I've consolidated them into a patch file shared via GitHub Gist so they can be easily applied inside a local clone of the repository with this command: curl https://gist.githubusercontent.com/RogueScholar/02624d2e8a6d9e286dbece73f48106db/raw/f6c0b1e82f970f2c3c74c5f91ec42059ba1e8f13/Add-conditional-for-proc_create-API-changes-in-kernel-5.6+.patch | git apply -v --index.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .