DHowett / framework-laptop-kmod

Kernel module to expose more Framework Laptop stuff
Other
87 stars 11 forks source link

Laptop 16, kernel 6.6.38 w/ v3 patchset fails to load framework_laptop driver: `failed to find EC cros-ec-dev.` #19

Open whitslack opened 4 months ago

whitslack commented 4 months ago
$ uname -a
Linux Destructor 6.6.38-gentoo #4 SMP Fri Jul 12 04:38:25 EDT 2024 x86_64 AMD Ryzen 9 7940HS w/ Radeon 780M Graphics AuthenticAMD GNU/Linux

$ zgrep '^[^#].*_CROS_EC' /proc/config.gz 
CONFIG_MFD_CROS_EC_DEV=y
CONFIG_CROS_EC=y
CONFIG_CROS_EC_LPC=y
CONFIG_CROS_EC_PROTO=y

$ dmesg | grep -F -e cros_ec -e framework
[    2.129146] framework_laptop framework_laptop: framework_laptop: failed to find EC cros-ec-dev.
[    2.129377] framework_laptop: probe of framework_laptop failed with error -22
[    2.130883] cros_ec_lpcs cros_ec_lpcs.0: loaded with quirks 00000001
[    2.223334] cros_ec_lpcs cros_ec_lpcs.0: Chrome EC device registered

Is it okay for framework_laptop to be loading before cros_ec_lpcs? (My kernel doesn't support loadable modules, so I integrated your framework_laptop.c into my kernel tree in drivers/platform/x86/.)

Maybe there is a missing dependency specification somehow, or maybe I need to enable another piece of CrOS support that you didn't mention in your README? (I initially didn't have MFD_CROS_EC_DEV enabled, but I tried enabling it to see if it would solve my issue. It didn't.)

whitslack commented 4 months ago

I got it working by changing the return -EINVAL in framework_probe(…) to return -EPROBE_DEFER so that the kernel will try probing the device again later if it fails initially because the CrOS EC device has not yet been registered. I don't know if this is the Right Way™, but it works for me, although I still get the error message in the kernel log.

DHowett commented 2 months ago

I have always been suspicious of the way I hooked up the module dependencies here. I suspect that I should have relied on Chrome MFD's ability to load additional drivers, but I wanted it to work as an external module.

EPROBE_DEFER seems like an alright solution. Thanks. I'd happily look over a PR for that!