# Why doesn't Xorg automaticly use the NVIDIA driver?



## tuaris (Dec 13, 2020)

This is a fresh installation of 12.2-RELEASE (64-bit) with the most recent ports tree as of November 27, 2020.  I have x11/xorg version 7.7_3 and x11/nvidia-driver version 440.100_1 installed.  According to https://www.nvidia.com/en-us/drivers/unix/, either the 440 or 390 driver is the latest driver I can use with a GTX 780 Ti.  I've tried with both and have settled on 440.

These are the steps taken:


```
pkg install -y nvidia-driver
sysrc -f /boot/loader.conf nvidia-modeset_load="YES"
```

After reboot I can confirm the relevant NVIDIA kernel modules have loaded:


```
# dmesg | grep nvidia
nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  390.138  Thu May 14 04:04:42 PDT 2020
nvidia0: <GeForce GTX 780 Ti> on vgapci0
vgapci0: child nvidia0 requested pci_enable_io
vgapci0: child nvidia0 requested pci_enable_io
nvidia1: <GeForce GTX 780 Ti> on vgapci1
vgapci1: child nvidia1 requested pci_enable_io
vgapci1: child nvidia1 requested pci_enable_io
nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  440.100  Fri May 29 08:11:49 UTC 2020
nvidia0: <Unknown> on vgapci0
vgapci0: child nvidia0 requested pci_enable_io
vgapci0: child nvidia0 requested pci_enable_io
nvidia1: <Unknown> on vgapci1
vgapci1: child nvidia1 requested pci_enable_io
vgapci1: child nvidia1 requested pci_enable_io
```


```
# kldstat | grep nvidia
3    1 0xffffffff82486000   175238 nvidia-modeset.ko
6    2 0xffffffff826bd000  1b4b3d8 nvidia.ko
```

As a side note, the vt() screen does switch to a 1920x1080 resolution, but it looks like it's much lower.  The text is stretched and very large, and also I see "VT(vga): resolution 640x480" in the logs.  I'm not sure what's happening there.  Anyway...

With no xorg.conf(), I run `startx` and it fails.  In the log (that I linked to) you can see there is no attempt to load the NVIDIA driver that the port installed under /usr/local/lib/xorg/modules/drivers/nvidia_drv.so. In order to get X to load the correct driver I must tell it to do so manually using /usr/local/etc/X11/xorg.conf.d/driver-nvidia.conf with the following contents.:


```
Section "Device"
        Identifier "Card0"
        Driver     "nvidia"
        BusID "PCI:1:0:0"
EndSection
```

With that in place, X starts correctly.

I prefer not to mess with xorg.conf() and just let it detect the hardware.   Could it be becuase I have 2 cards? I had to put the line "BusID PCI:1:0:0" in the configuration file to  indicate which one to use.  Without that line, X fails to start in the same exact way.

In case it's relevent, this is the contents of /etc/rc.conf (minus any unrealted network config):

```
sshd_enable="YES"
powerd_enable="YES"
dumpdev="AUTO"
zfs_enable="YES"
dbus_enable="YES"
hald_enable="YES"
sddm_enable="YES"
ntpd_enable="YES"
ntpd_flags="-g"
webcamd_enable="YES"
devfs_system_ruleset="devfsrules_common"
```

Also /boot/loader.conf:


```
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gptid.enable="0"
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gptid.enable="0"
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gptid.enable="0"
opensolaris_load="YES"
zfs_load="YES"
fuse_load="YES"
tmpfs_load="YES"
aio_load="YES"
nvidia-modeset_load="YES"
libiconv_load="YES"
libmchain_load="YES"
cd9660_iconv_load="YES"
msdosfs_iconv_load="YES"
snd_driver_load="YES"
cuse4bsd_load="YES"
kern.ipc.shmseg=1024
kern.ipc.shmmni=1024
kern.maxproc=100000
```


----------

