On 29-10-15 07:52:37, Martin Pitt wrote:
> The PCI device will exist whether or not the module was loaded; so you
> can just iterate over /sys/bus/pci/devices/* (* expands to the PCI bus
> IDs) and check the attributes in each directory; e. g. you probably want
> to pick out the ones with class == 0x030000 (graphics card), and perhaps
> vendor == 10DE (nvidia).
>

Yes, I use libpciaccess for that. Of course it doesn't work when the GPU
is disabled through an ACPI call (i.e. power saving mode in hybrid
graphics).

It usually works like this on boot:

The GPU is already enabled, the module is loaded, then the ACPI call
disables the GPU (i.e. the PCI device disappears), and the module is
unloaded.

> If you want to do that via an udev rule: I'm not entirely sure which
> kinds of events you get when the nvidia driver gets loaded. You can
> unload it, run
>
>   udevadm monitor -e --udev
>
> then load it, and see what kind of events you get. For sure you'll see
> an "add" event for SUBSYSTEM=="module", DEVPATH=="*/nvidia", but either
> on boot or when loading the module you should also see an "add" or
> "change" event for the graphics card itself.
>
> This is an initial sketch of a rule which selects a PCI card whose
> driver is nvidia:
>
>   ACTION=="add|change", SUBSYSTEM=="pci", DRIVER=="nvidia*", RUN+=
> "touch /run/nvidia-loaded-for-pci-id-$env{PCI_ID}"
>
> (using "nvidia*" here in case the modules might be called something like
> nvidia_123). You can use udev properties like $env{PCI_ID} and also
> attributes from sysfs like the above, with e. g. $attr{vendor}. See man
> udev(7) for other macros you can use in RUN clauses.
>
> Then you don't need the "remove" rule any more -- if /sys/modules/nvidia
> does not exist but your stamp in /run does exist, you know that it was
> once loaded but then removed.

Yes, that would work. I already have udev rules in place to start other
applications when an NVIDIA GPU is made available, so I can simply
create that file in /run and get rid of the whole parsing code.

This should be a huge help. Thanks a lot!

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1307069

Title:
  gpu-manager causing long startup delays

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-drivers-common/+bug/1307069/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to