pobrn / qc71_laptop

Linux kernel platform driver for QC71 based laptops.
GNU General Public License v2.0
31 stars 11 forks source link

DKMS fails to rebuild on kernel upgrades #11

Closed anderson-m-souza closed 2 years ago

anderson-m-souza commented 2 years ago

Hi, thanks for sharing this tool!

I have both qc71_laptop and hid-ite8291r3 modules installed with the DKMS option described in the README.md files, and they work perfectly.

The only issue for me is that every time there is a kernel upgrade, the modules fails to rebuild. Here is the log from the pacman -Syu command:

Running 'pacman -Syu'
synchronizing package lists
starting full system upgrade
running '60-mkinitcpio-remove.hook'...
running '71-dkms-remove.hook'...
==> dkms remove --no-depmod hid-ite8291r3/0.0 -k 5.17.9-arch1-1
==> dkms remove --no-depmod qc71_laptop/0.0 -k 5.17.9-arch1-1
==> dkms remove --no-depmod vboxhost/6.1.34_OSE -k 5.17.9-arch1-1
==> depmod 5.17.9-arch1-1
transaction started
upgraded alacritty (0.10.1-1 -> 0.10.1-2)
upgraded linux (5.17.9.arch1-1 -> 5.18.arch1-1)
upgraded linux-headers (5.17.9.arch1-1 -> 5.18.arch1-1)
upgraded nvidia-utils (515.43.04-1 -> 515.43.04-2)
If you run into trouble with CUDA not being available, run nvidia-modprobe first.
upgraded nvidia (515.43.04-5 -> 515.43.04-6)
upgraded python-cryptography (37.0.0-1 -> 37.0.1-1)
upgraded webkit2gtk (2.36.2-1 -> 2.36.3-1)
transaction completed
running '20-systemd-sysusers.hook'...
running '30-systemd-daemon-reload.hook'...
running '30-systemd-udev-reload.hook'...
running '30-systemd-update.hook'...
running '60-depmod.hook'...
running '70-dkms-install.hook'...
==> dkms install --no-depmod vboxhost/6.1.34_OSE -k 5.18.0-arch1-1
==> dkms install --no-depmod hid-ite8291r3/0.0 -k 5.18.0-arch1-1
Error! Bad return status for module build on kernel: 5.18.0-arch1-1 (x86_64)
Consult /var/lib/dkms/hid-ite8291r3/0.0/build/make.l
og for more information.
==> WARNING: `dkms install --no-depmod hid-ite8291r3
/0.0 -k 5.18.0-arch1-1' exited 10
==> dkms install --no-depmod qc71_laptop/0.0 -k 5.18
.0-arch1-1
Error! Bad return status for module build on kernel:
 5.18.0-arch1-1 (x86_64)
Consult /var/lib/dkms/qc71_laptop/0.0/build/make.log
 for more information.
==> WARNING: `dkms install --no-depmod qc71_laptop/0
.0 -k 5.18.0-arch1-1' exited 10
==> depmod 5.18.0-arch1-1
running '90-mkinitcpio-install.hook'...
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'default'
  -> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img
==> Starting build: 5.18.0-arch1-1
  -> Running build hook: [base]
  -> Running build hook: [systemd]
  -> Running build hook: [autodetect]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: xhci_pci
  -> Running build hook: [filesystems]
  -> Running build hook: [keyboard]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating zstd-compressed initcpio image: /boot/initramfs-linux.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'fallback'
  -> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-fallback.img -S autodetect
==> Starting build: 5.18.0-arch1-1
  -> Running build hook: [base]
  -> Running build hook: [systemd]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: wd719x
==> WARNING: Possibly missing firmware for module: bfa
==> WARNING: Possibly missing firmware for module: qla1280
==> WARNING: Possibly missing firmware for module: aic94xx
==> WARNING: Possibly missing firmware for module: q
la2xxx
==> WARNING: Possibly missing firmware for module: q
ed
==> WARNING: Possibly missing firmware for module: x
hci_pci
  -> Running build hook: [filesystems]
  -> Running build hook: [keyboard]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating zstd-compressed initcpio image: /boot/i
nitramfs-linux-fallback.img
==> Image generation successful
running 'dbus-reload.hook'...
running 'update-desktop-database.hook'...
Running 'pacman -Syu --debug'
synchronizing package lists
starting full system upgrade
transaction started
upgraded iproute2 (5.17.0-3 -> 5.18.0-1)
transaction completed
running '30-systemd-update.hook'...

And the log from qc71_laptop (hid-ite8291r3 has the same log):

DKMS make.log for qc71_laptop-0.0 for kernel 5.18.0-arch1-1 (x86_64)
Sun May 29 04:24:00 PM -03 2022
make: Entering directory '/var/lib/dkms/qc71_laptop/0.0/build'
make -C /lib/modules/5.17.9-arch1-1/build M=/var/lib/dkms/qc71_laptop/0.0/build modules
make[1]: Entering directory '/var/lib/dkms/qc71_laptop/0.0/build'
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: *** /lib/modules/5.17.9-arch1-1/build: No such file or directory.  Stop.
make[1]: Leaving directory '/var/lib/dkms/qc71_laptop/0.0/build'
make: *** [Makefile:25: all] Error 2
make: Leaving directory '/var/lib/dkms/qc71_laptop/0.0/build'

If I run dkms status imediatelly after the update, I have this output:

hid-ite8291r3/0.0: added
qc71_laptop/0.0: added
vboxhost/6.1.34_OSE, 5.18.0-arch1-1, x86_64: installed

The problem is I have to reboot every time the kernel updates, then run sudo dkms autoinstall, and reboot again to activate the modules.

I asked for help in the Arch Linux Forum, and described this issue, because I was expexting it to be a problem with my system. But a user suggested it may be a problem in the Makefile.

From my question in the Arch Linux Forum:

https://github.com/pobrn/hid-ite8291r3/ … akefile#L7

KDIR = /lib/modules/$(shell uname -r)/build

Gets the running kernels release from uname and uses that to build the directory path instead of the path to the target kernel.

https://github.com/pobrn/qc71_laptop/bl … le#L20-L21

KVER = $(shell uname -r) KDIR = /lib/modules/$(KVER)/build

Same problem

From https://docs.kernel.org/kbuild/modules.html

KDIR ?= /lib/modules/`uname -r`/build

Only set the variable KDIR if it is not set already.

I've noticed also that in the dkms.conf file it is assigned as KERNELDIR.

Do you think the issue could be related to any of these variable assignments? Or it might be something else?

Machine: Avell A60 MUV OS: Arch Linux Kernel version: 5.18.0-arch1-1

pobrn commented 2 years ago

Truth is that I don't really use dkms, so it is probably not correctly configured. Could you try the following change?

diff --git a/dkms.conf b/dkms.conf
index f608ed7..0ed0fb1 100644
--- a/dkms.conf
+++ b/dkms.conf
@@ -1,7 +1,6 @@
-MAKE="make -C ./ KERNELDIR=/lib/modules/${kernelver}/build"
-CLEAN="make -C ./ clean"
+MAKE="make KDIR=${kernel_source_dir}"
+CLEAN="make KDIR=${kernel_source_dir} clean"
 BUILT_MODULE_NAME=qc71_laptop
-BUILT_MODULE_LOCATION=./
 PACKAGE_NAME=qc71_laptop
 PACKAGE_VERSION=0.0
 DEST_MODULE_LOCATION=/kernel/drivers/platform/x86
anderson-m-souza commented 2 years ago

Thanks for the reply!

I've uninstalled the module, rebooted, and reinstalled with this patch.

sudo make dkmsinstall
[sudo] password:
mkdir -p /usr/src/qc71_laptop-0.0
cp Makefile dkms.conf battery.c debugfs.c ec.c events.c fan.c features.c hwmon.c hwmon_fan.c hwmon_pwm.c led_lightbar.c main.c misc.c pdev.c battery.h debugfs.h ec.h events.h fan.h features.h hwmon_fan.h hwmon.h hwmon_pwm.h led_lightbar.h misc.h pdev.h pr.h util.h wmi.h /usr/src/qc71_laptop-0.0/.
dkms add qc71_laptop/0.0
Creating symlink /var/lib/dkms/qc71_laptop/0.0/source -> /usr/src/qc71_laptop-0.0
dkms build qc71_laptop/0.0

Building module:
cleaning build area...
make -j12 KERNELRELEASE=5.18.0-arch1-1 KDIR=/usr/lib/modules/5.18.0-arch1-1/build....
cleaning build area...
dkms install qc71_laptop/0.0

qc71_laptop.ko.zst:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /usr/lib/modules/5.18.0-arch1-1/updates/dkms/
depmod....

Looks like it is working fine.

modinfo qc71_laptop
filename:       /lib/modules/5.18.0-arch1-1/updates/dkms/qc71_laptop.ko.zst
alias:          wmi:ABBC0F6F-8EA1-11D1-00A0-C90629100000
description:    QC71 laptop platform driver
author:         Barnabás Pőcze <pobrn@protonmail.com>
license:        GPL
srcversion:     9787F4858F17AC17AA54459
depends:        sparse-keymap,wmi
retpoline:      Y
name:           qc71_laptop
vermagic:       5.18.0-arch1-1 SMP preempt mod_unload
parm:           nohwmon:do not report to the hardware monitoring subsystem (default=false) (bool)
parm:           nolightbar:do not register the lightbar to the leds subsystem (default=false) (bool)
parm:           nobattery:do not expose battery related controls (default=false) (bool)
parm:           debugregs:expose various EC registers in debugfs (default=false) (bool)

I just don't know how to check if it will rebuild on kernel upgrades without waiting for one. I've tried before with the changes I mentioned by installing the packages linux-lts and linux-lts-headers, but even the hid-ite8291r3 which I didn't change rebuilt. So I don't know if I did the right way.

If you have any idea how I could test this. Or I can just wait and see if it will work too.

pobrn commented 2 years ago

Please test the latest version when you have a chance, then if it works, this can be closed.

anderson-m-souza commented 2 years ago

Thank you!

Just reinstalled both qc71_laptop and hid-ite8291r3, and tested on the new kernel upgrade. Both modules reinstalled during the upgrade.