Subject: Keyboard detection before ‘cryptsetup’ runs

From: [email-masked] (Ludovic Courtès)
Date: Sun, 18 Mar 2018 16:03:06 +0100

Hi Danny,

[email-masked] (Ludovic Courtès) skribis:

> Something annoying is that my external USB keyboard doesn’t work while
> in the initrd (when I type my passphrase).  I can see that it’s detected
> early on, before I type my passphrase:

While experimenting with this on the bare metal, it became clear that
it’s a timing issue: the keyboard is detected right after the cryptsetup
is displayed, so ‘load-needed-linux-modules’ didn’t have a chance to
load the relevant modules.

Similarly, if I boot with ‘--repl’, and I manually type
(load-needed-linux-modules …) from there, then the keyboard’s module
gets loaded as expected.  That’s because the device showed up in the
meantime and the kernel created a /sys entry for it.

In essence, we want a mini-udev and something akin to “udevadm settle”.
Merely calling ‘load-needed-linux-modules’ once isn’t enough.

One way to do that would be to have a separate thread that calls
‘load-needed-linux-modules’ as appropriate.  Ideally it would use
inotify on /sys like udev does, but a poor programmer’s version could
simply call ‘load-needed-linux-modules’ every half a second or so.

Alternately, before passing control to user code (pre-mount actions,
etc.), we could do a “settle” kind of thing: call
‘load-linux-modules-from-directory’ every 0.5 seconds until its result
is the same as before.  There’s still a risk of missing devices, and
those devices will never show up later because nobody’s monitoring /sys.
But then again, “udevadm settle” must have the same problem: it can’t
really know whether things have settled, I guess.

WDYT?

Thanks,
Ludo’.