Re: [systemd-devel] Preventing automatic driver loading on live boot disk

2022-11-18 Thread Vadim Lebedev
Awesome, thanks!

On Fri, Nov 18, 2022 at 12:04 PM Lennart Poettering 
wrote:

> On Do, 17.11.22 21:41, Andrei Borzenkov (arvidj...@gmail.com) wrote:
>
> > On 17.11.2022 20:48, Lennart Poettering wrote:
> > > On Do, 17.11.22 18:17, Vadim Lebedev (vadiml1...@gmail.com) wrote:
> > >
> > > > Awesome, thanks, it is EXTREMELY useful
> > > >   | Find the right one and denylist it.
> > > > One more question:  how do I  'denylist'  the offending alias?
> > >
> > > Via the "blacklist" stanza in the modprobe configuration files, like
> > > you already are using.
> > >
> >
> > Care to provide example how to use "blacklist" stanza to denylist only
> > specific PCI ID? Because kmod documentation does not explain it.
>
> Oh, right "blacklist" actually works differently than I was
> remembering. But this should work:
>
> alias pci:v8086dA0EDsv17AAsd22D5bc0Csc03i30 letsmaskthisone
>
> if you do that, then the kernel requesting that modalias will tell
> modprobe to load letsmaskthisone.ko but that does not exist, so it
> will fail and not load anything.
>
> Lennart
>
> --
> Lennart Poettering, Berlin
>


Re: [systemd-devel] Preventing automatic driver loading on live boot disk

2022-11-18 Thread Lennart Poettering
On Do, 17.11.22 21:41, Andrei Borzenkov (arvidj...@gmail.com) wrote:

> On 17.11.2022 20:48, Lennart Poettering wrote:
> > On Do, 17.11.22 18:17, Vadim Lebedev (vadiml1...@gmail.com) wrote:
> >
> > > Awesome, thanks, it is EXTREMELY useful
> > >   | Find the right one and denylist it.
> > > One more question:  how do I  'denylist'  the offending alias?
> >
> > Via the "blacklist" stanza in the modprobe configuration files, like
> > you already are using.
> >
>
> Care to provide example how to use "blacklist" stanza to denylist only
> specific PCI ID? Because kmod documentation does not explain it.

Oh, right "blacklist" actually works differently than I was
remembering. But this should work:

alias pci:v8086dA0EDsv17AAsd22D5bc0Csc03i30 letsmaskthisone

if you do that, then the kernel requesting that modalias will tell
modprobe to load letsmaskthisone.ko but that does not exist, so it
will fail and not load anything.

Lennart

--
Lennart Poettering, Berlin


Re: [systemd-devel] Preventing automatic driver loading on live boot disk

2022-11-17 Thread Andrei Borzenkov

On 17.11.2022 20:48, Lennart Poettering wrote:

On Do, 17.11.22 18:17, Vadim Lebedev (vadiml1...@gmail.com) wrote:


Awesome, thanks, it is EXTREMELY useful
  | Find the right one and denylist it.
One more question:  how do I  'denylist'  the offending alias?


Via the "blacklist" stanza in the modprobe configuration files, like
you already are using.



Care to provide example how to use "blacklist" stanza to denylist only 
specific PCI ID? Because kmod documentation does not explain it.


bor@bor-Latitude-E5450:~/src/kmod$ grep -r denylist .
bor@bor-Latitude-E5450:~/src/kmod$




Re: [systemd-devel] Preventing automatic driver loading on live boot disk

2022-11-17 Thread Lennart Poettering
On Do, 17.11.22 18:17, Vadim Lebedev (vadiml1...@gmail.com) wrote:

> Awesome, thanks, it is EXTREMELY useful
>  | Find the right one and denylist it.
> One more question:  how do I  'denylist'  the offending alias?

Via the "blacklist" stanza in the modprobe configuration files, like
you already are using.

Lennart

--
Lennart Poettering, Berlin


Re: [systemd-devel] Preventing automatic driver loading on live boot disk

2022-11-17 Thread Vadim Lebedev
Awesome, thanks, it is EXTREMELY useful
 | Find the right one and denylist it.
One more question:  how do I  'denylist'  the offending alias?

Thanks
Vadim

On Thu, Nov 17, 2022 at 3:22 PM Lennart Poettering 
wrote:

> On Mi, 16.11.22 10:24, Vadim Lebedev (vadiml1...@gmail.com) wrote:
>
> > I'm preparing ubuntu-based live boot disk. It works fine mostly, but on
> > some machines equipped with Nvidia Quadro cards the default nouveau
> driver
> > causes problems (temporary freezes). I've determined that buy
> blacklisting
> > nouveau driver (in /etc/modprobe.d/blacklist.conf) I can fix the problem.
> > However this approach inhibits nouveau driver for every nvidia equipped
> > machine which is an overkill. Of course, i can detect the presence of the
> > Quadro card after the boot, blacklist it, do update-initramfs -u and
> reboot
> > but this approach modifies live boot disk and I would like to avoid
> that. I
> > wonder if there is a way to detect the presence of nvidia Quadro
> somewhere
> > very early in the boot sequence and prevent loading of the offending
> driver
> > and fall back to standard VESA driver.
>
> PCI drivers are loaded via a "modalias" string, which is synthesized
> from the PCI and USB vendor and product IDs (and other PCI
> info). Drivers declare in their kmod metadata which of these modalias
> strings they want to be responsible for.
>
> Do "modinfo nouveau" for example, which will show you this
> information:
>
> 
> …
> alias:  pci:v12D2d*sv*sd*bc03sc*i*
> alias:  pci:v10DEd*sv*sd*bc03sc*i*
> …
> 
>
> The "*" are wildcard expressions.
>
> Now, the kernel will never ask userspace for the "nouveau" driver but
> only for a driver for such a modalias string.
>
> You can denylist that string for your hw and thus disable the
> autoloading.
>
> Use "grep . /sys/bus/*/*/*/modalias" to get a list of the actual
> modalias strings requested on your system. The one nuveau.ko matched
> against will be among them. Find the right one and denylist it.
>
> Lennart
>
> --
> Lennart Poettering, Berlin
>


Re: [systemd-devel] Preventing automatic driver loading on live boot disk

2022-11-17 Thread Lennart Poettering
On Mi, 16.11.22 10:24, Vadim Lebedev (vadiml1...@gmail.com) wrote:

> I'm preparing ubuntu-based live boot disk. It works fine mostly, but on
> some machines equipped with Nvidia Quadro cards the default nouveau driver
> causes problems (temporary freezes). I've determined that buy blacklisting
> nouveau driver (in /etc/modprobe.d/blacklist.conf) I can fix the problem.
> However this approach inhibits nouveau driver for every nvidia equipped
> machine which is an overkill. Of course, i can detect the presence of the
> Quadro card after the boot, blacklist it, do update-initramfs -u and reboot
> but this approach modifies live boot disk and I would like to avoid that. I
> wonder if there is a way to detect the presence of nvidia Quadro somewhere
> very early in the boot sequence and prevent loading of the offending driver
> and fall back to standard VESA driver.

PCI drivers are loaded via a "modalias" string, which is synthesized
from the PCI and USB vendor and product IDs (and other PCI
info). Drivers declare in their kmod metadata which of these modalias
strings they want to be responsible for.

Do "modinfo nouveau" for example, which will show you this
information:


…
alias:  pci:v12D2d*sv*sd*bc03sc*i*
alias:  pci:v10DEd*sv*sd*bc03sc*i*
…


The "*" are wildcard expressions.

Now, the kernel will never ask userspace for the "nouveau" driver but
only for a driver for such a modalias string.

You can denylist that string for your hw and thus disable the
autoloading.

Use "grep . /sys/bus/*/*/*/modalias" to get a list of the actual
modalias strings requested on your system. The one nuveau.ko matched
against will be among them. Find the right one and denylist it.

Lennart

--
Lennart Poettering, Berlin


Re: [systemd-devel] Preventing automatic driver loading on live boot disk

2022-11-17 Thread Pascal
an udev specific rule may be...

Le mer. 16 nov. 2022 à 10:41, Andrei Borzenkov  a
écrit :

> On Wed, Nov 16, 2022 at 12:25 PM Vadim Lebedev 
> wrote:
> >
> > I'm preparing ubuntu-based live boot disk. It works fine mostly, but on
> some machines equipped with Nvidia Quadro cards the default nouveau driver
> causes problems (temporary freezes). I've determined that buy blacklisting
> nouveau driver (in /etc/modprobe.d/blacklist.conf) I can fix the problem.
> However this approach inhibits nouveau driver for every nvidia equipped
> machine which is an overkill. Of course, i can detect the presence of the
> Quadro card after the boot, blacklist it, do update-initramfs -u and reboot
> but this approach modifies live boot disk and I would like to avoid that. I
> wonder if there is a way to detect the presence of nvidia Quadro somewhere
> very early in the boot sequence and prevent loading of the offending driver
> and fall back to standard VESA driver.
> >
> > I've tried too create a service file:
> > [Unit]
> > Description=Disable Nouveau driver
> > DefaultDependencies=no
> > Before=kmod.service
> >
>
> Drivers for devices are usually loaded dynamically by udev. What does
> kmod.service do? I would guess you rather want
> Before=systemd-udevd.service.
>
> >
> > [Service]
> > Type=oneshot
> > ExecStart=/usr/bin/ocd-blacklist-nouveau.sh
> >
> > 
> > and the shell script
> > #!/bin/bash
> > set -x
> > if /usr/bin/lspci | /usr/bin/grep Quadro >/dev/null; then
> >/usr/bin/logger Found Nvidia Quadro device. Disabling Nouveau driver
> >echo blacklist nouveau >/etc/modprobe.d/blacklist-nouveau.conf
> > else
> >rm -f /etc/modprobe.d/blacklist-nouveau.conf
> > fi
> >
> > But it seems that the service is not executed...
> >
>
> For service to be executed something needs to cause this service to be
> executed - other unit dependency or explicit request to start. The
> mere presence of unit definition on disk does not mean systemd will
> try to activate it. You can manually create links of use usual install
> section
>
> [Install]
> WantedBy=default.target
>
> followed by "systemctl enable your.service".
>
> Or you could create a generator that runs before systemd begins
> activating any service.
>


Re: [systemd-devel] Preventing automatic driver loading on live boot disk

2022-11-16 Thread Andrei Borzenkov
On Wed, Nov 16, 2022 at 12:25 PM Vadim Lebedev  wrote:
>
> I'm preparing ubuntu-based live boot disk. It works fine mostly, but on some 
> machines equipped with Nvidia Quadro cards the default nouveau driver causes 
> problems (temporary freezes). I've determined that buy blacklisting nouveau 
> driver (in /etc/modprobe.d/blacklist.conf) I can fix the problem. However 
> this approach inhibits nouveau driver for every nvidia equipped machine which 
> is an overkill. Of course, i can detect the presence of the Quadro card after 
> the boot, blacklist it, do update-initramfs -u and reboot but this approach 
> modifies live boot disk and I would like to avoid that. I wonder if there is 
> a way to detect the presence of nvidia Quadro somewhere very early in the 
> boot sequence and prevent loading of the offending driver and fall back to 
> standard VESA driver.
>
> I've tried too create a service file:
> [Unit]
> Description=Disable Nouveau driver
> DefaultDependencies=no
> Before=kmod.service
>

Drivers for devices are usually loaded dynamically by udev. What does
kmod.service do? I would guess you rather want
Before=systemd-udevd.service.

>
> [Service]
> Type=oneshot
> ExecStart=/usr/bin/ocd-blacklist-nouveau.sh
>
> 
> and the shell script
> #!/bin/bash
> set -x
> if /usr/bin/lspci | /usr/bin/grep Quadro >/dev/null; then
>/usr/bin/logger Found Nvidia Quadro device. Disabling Nouveau driver
>echo blacklist nouveau >/etc/modprobe.d/blacklist-nouveau.conf
> else
>rm -f /etc/modprobe.d/blacklist-nouveau.conf
> fi
>
> But it seems that the service is not executed...
>

For service to be executed something needs to cause this service to be
executed - other unit dependency or explicit request to start. The
mere presence of unit definition on disk does not mean systemd will
try to activate it. You can manually create links of use usual install
section

[Install]
WantedBy=default.target

followed by "systemctl enable your.service".

Or you could create a generator that runs before systemd begins
activating any service.