# Update problem with nvidia-driver-340-340.107_4



## Crotalus (Jul 11, 2019)

After updating the driver the result is that it does not work.
First my environment;

```
Copyright (c) 1992-2018 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 11.2-RELEASE-p11 #0: Tue Jul  2 21:24:25 UTC 2019
    root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64
FreeBSD clang version 6.0.0 (tags/RELEASE_600/final 326565) (based on LLVM 6.0.0)
VT(vga): resolution 640x480
CPU: AMD FX(tm)-6300 Six-Core Processor              (3492.51-MHz K8-class CPU)
  Origin="AuthenticAMD"  Id=0x600f20  Family=0x15  Model=0x2  Stepping=0
  Features=0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
  Features2=0x3e98320b<SSE3,PCLMULQDQ,MON,SSSE3,FMA,CX16,SSE4.1,SSE4.2,POPCNT,AESNI,XSAVE,OSXSAVE,AVX,F16C>
  AMD Features=0x2e500800<SYSCALL,NX,MMX+,FFXSR,Page1GB,RDTSCP,LM>
  AMD Features2=0x1ebbfff<LAHF,CMP,SVM,ExtAPIC,CR8,ABM,SSE4A,MAS,Prefetch,OSVW,IBS,XOP,SKINIT,WDT,LWP,FMA4,TCE,NodeId,TBM,Topology,PCXC,PNXC>
  Structured Extended Features=0x8<BMI1>
  SVM: NP,NRIP,VClean,AFlush,DAssist,NAsids=65536
  TSC: P-state invariant, performance statistics
real memory  = 17179869184 (16384 MB)
avail memory = 16525598720 (15760 MB)
Event timer "LAPIC" quality 600
ACPI APIC Table: <ALASKA A M I>
FreeBSD/SMP: Multiprocessor System Detected: 6 CPUs
```
The package

```
root@Prometheus:/ # pkg info "nvidia*"
nvidia-driver-340-340.107_4
root@Prometheus:/ #
```
The driver;

```
root@Prometheus:/ # kldstat
Id Refs Address            Size     Name
 1   39 0xffffffff80200000 20a5c10  kernel
 2    1 0xffffffff822a7000 e148b8   nvidia.ko
 3    5 0xffffffff830bc000 92c0     linux_common.ko
 4    2 0xffffffff830c6000 a4af0    linux.ko
 5    1 0xffffffff83221000 1820     fdescfs.ko
 6    1 0xffffffff83223000 6fc4     tmpfs.ko
 7    1 0xffffffff8322a000 41f0     linprocfs.ko
 8    1 0xffffffff8322f000 1780     uhid.ko
 9    1 0xffffffff83231000 31e70    linux64.ko
10    1 0xffffffff83263000 16684    smbfs.ko
11    2 0xffffffff8327a000 2ee8     libiconv.ko
12    2 0xffffffff8327d000 1ddc     libmchain.ko
root@Prometheus:/ #
```

The error;

```
[    86.416] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
[    86.416] (II) scfb: driver for wsdisplay framebuffer: scfb
[    86.416] (II) VESA: driver for VESA chipsets: vesa
[    86.416] (--) Using syscons driver with X support (version 2.0)
[    86.416] (--) using VT number 9

[    86.445] (EE) NV: The PCI device 0x10de10c3 ((null)) at 01@00:00:0 has a kernel module claiming it.
[    86.445] (EE) NV: This driver cannot operate until it has been unloaded.
[    86.445] (EE) open /dev/dri/card0: No such file or directory
[    86.445] (WW) Falling back to old probe method for modesetting
[    86.445] (EE) open /dev/dri/card0: No such file or directory
[    86.445] (WW) Falling back to old probe method for scfb
[    86.445] scfb trace: probe start
[    86.445] scfb trace: probe done
[    86.445] vesa: Ignoring device with a bound kernel driver
[    86.446] (WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
[    86.446] (EE) Screen 0 deleted because of no matching config section.
[    86.446] (II) UnloadModule: "modesetting"
[    86.446] (EE) Screen 0 deleted because of no matching config section.
[    86.446] (II) UnloadModule: "vesa"
[    86.446] (EE) Device(s) detected, but none match those in the config file.
[    86.446] (EE)
Fatal server error:
[    86.446] (EE) no screens found(EE)
[    86.446] (EE)
Please consult the The X.Org Foundation support
         at http://wiki.x.org
 for help.
[    86.446] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
[    86.446] (EE)
[    86.463] (EE) Server terminated with error (1). Closing log file.
```
When I do the following you can see the the size has changed;
I have no idea why.

```
root@Prometheus:/ # kldstat
Id Refs Address            Size     Name
 1   39 0xffffffff80200000 20a5c10  kernel
 2    1 0xffffffff822a7000 e148b8   nvidia.ko
 3    5 0xffffffff830bc000 92c0     linux_common.ko
 4    2 0xffffffff830c6000 a4af0    linux.ko
 5    1 0xffffffff83221000 1820     fdescfs.ko
 6    1 0xffffffff83223000 6fc4     tmpfs.ko
 7    1 0xffffffff8322a000 41f0     linprocfs.ko
 8    1 0xffffffff8322f000 1780     uhid.ko
 9    1 0xffffffff83231000 31e70    linux64.ko
10    1 0xffffffff83263000 16684    smbfs.ko
11    2 0xffffffff8327a000 2ee8     libiconv.ko
12    2 0xffffffff8327d000 1ddc     libmchain.ko
root@Prometheus:/ #
root@Prometheus:/ # kldunload nvidia
root@Prometheus:/ #
root@Prometheus:/ # kldstat
Id Refs Address            Size     Name
 1   35 0xffffffff80200000 20a5c10  kernel
 3    4 0xffffffff830bc000 92c0     linux_common.ko
 4    1 0xffffffff830c6000 a4af0    linux.ko
 5    1 0xffffffff83221000 1820     fdescfs.ko
 6    1 0xffffffff83223000 6fc4     tmpfs.ko
 7    1 0xffffffff8322a000 41f0     linprocfs.ko
 8    1 0xffffffff8322f000 1780     uhid.ko
 9    1 0xffffffff83231000 31e70    linux64.ko
10    1 0xffffffff83263000 16684    smbfs.ko
11    2 0xffffffff8327a000 2ee8     libiconv.ko
12    2 0xffffffff8327d000 1ddc     libmchain.ko
root@Prometheus:/ #
root@Prometheus:/ # kldload nvidia
root@Prometheus:/ #
root@Prometheus:/ # kldstat
Id Refs Address            Size     Name
 1   39 0xffffffff80200000 20a5c10  kernel
 3    5 0xffffffff830bc000 92c0     linux_common.ko
 4    2 0xffffffff830c6000 a4af0    linux.ko
 5    1 0xffffffff83221000 1820     fdescfs.ko
 6    1 0xffffffff83223000 6fc4     tmpfs.ko
 7    1 0xffffffff8322a000 41f0     linprocfs.ko
 8    1 0xffffffff8322f000 1780     uhid.ko
 9    1 0xffffffff83231000 31e70    linux64.ko
10    1 0xffffffff83263000 16684    smbfs.ko
11    2 0xffffffff8327a000 2ee8     libiconv.ko
12    2 0xffffffff8327d000 1ddc     libmchain.ko
13    1 0xffffffff8327f000 965468   nvidia.ko
root@Prometheus:/ #
```
From the message file;

```
Jul 11 15:03:40 Prometheus kernel: nvidia0: detached
Jul 11 15:04:07 Prometheus kernel: nvidia0: <GeForce 8400GS> on vgapci0
Jul 11 15:04:07 Prometheus kernel: vgapci0: child nvidia0 requested pci_enable_io
Jul 11 15:04:07 Prometheus kernel: vgapci0: child nvidia0 requested pci_enable_io
```
After a reboot;
You will see that size is back to where it was prior to the unload/load.

```
$ kldstat
Id Refs Address            Size     Name
 1   30 0xffffffff80200000 20a5c10  kernel
 2    1 0xffffffff822a7000 e148b8   nvidia.ko
 3    5 0xffffffff830bc000 92c0     linux_common.ko
 4    2 0xffffffff830c6000 a4af0    linux.ko
 5    1 0xffffffff83221000 1820     fdescfs.ko
 6    1 0xffffffff83223000 6fc4     tmpfs.ko
 7    1 0xffffffff8322a000 41f0     linprocfs.ko
 8    1 0xffffffff8322f000 1780     uhid.ko
 9    1 0xffffffff83231000 31e70    linux64.ko
$
```

I don't know what version I had of the driver prior to the attempted upgrade. 
I have no idea what is going on or how to fix it.
Is there anybody out there that can help? Maybe point me to the area I need to look.


----------



## trev (Jul 11, 2019)

FreeBSD 11.2-STABLE FreeBSD 11.2-STABLE #6 r343871: Fri Feb  8 19:15:04 AEDT 2019
trev@shadow:/usr/obj/usr/src/sys/MACMINI  amd64
Hardware: Late 2009 Mac mini


```
trev@shadow [/tmp] $ pkg info | grep -i nvidia
nvidia-driver-340-340.107_4    NVidia graphics card binary drivers for hardware OpenGL rendering
```


```
trev@shadow [/tmp] $ kldstat
Id Refs Address            Size     Name
 1   47 0xffffffff80200000 db86c0   kernel
 2    1 0xffffffff80fba000 2cc8     coretemp.ko
 4    1 0xffffffff80fdf000 10fa8    if_nfe.ko
 5    1 0xffffffff80ff0000 44a78    snd_hda.ko
 6    1 0xffffffff81035000 1678     accf_http.ko
 7    1 0xffffffff81037000 920      accf_data.ko
 8    1 0xffffffff81221000 965208   nvidia.ko
 9    1 0xffffffff81b87000 20488    ipfw.ko
10    1 0xffffffff81ba8000 6e40     uftdi.ko
11    1 0xffffffff81baf000 3c58     ucom.ko
12    1 0xffffffff81bb3000 2328     ums.ko
13    1 0xffffffff81bb6000 1a4      green_saver.ko
22    1 0xffffffff81bb7000 1d40     ng_socket.ko
23    2 0xffffffff81bb9000 9a20     netgraph.ko
26    1 0xffffffff81bd0000 95c      ng_bluetooth.ko
28    1 0xffffffff81bdd000 17408    ng_btsocket.ko
29    1 0xffffffff81bf5000 1297c    asmc.ko
```

I start the nvidia driver from rc.conf:


```
kld_list="nvidia"         # Kernel modules to load after local disks are mounted
```

dmesg on boot:


```
nvidia0: <GeForce 9400> on vgapci0
vgapci0: child nvidia0 requested pci_enable_io
vgapci0: child nvidia0 requested pci_enable_io
```

I notice your version of the driver seems to be pulling in Linux modules - my config from  /var/db/ports/x11_nvidia-driver-340/options below:


```
# This file is auto-generated by 'make config'.
# Options for nvidia-driver-340-340.76
_OPTIONS_READ=nvidia-driver-340-340.76
_FILE_COMPLETE_OPTIONS_LIST=ACPI_PM DOCS LINUX WBINVD
OPTIONS_FILE_SET+=ACPI_PM
OPTIONS_FILE_UNSET+=DOCS
OPTIONS_FILE_UNSET+=LINUX
OPTIONS_FILE_UNSET+=WBINVD
```


----------



## shkhln (Jul 12, 2019)

Crotalus said:


> ```
> [    86.445] (EE) NV: The PCI device 0x10de10c3 ((null)) at 01@00:00:0 has a kernel module claiming it.
> [    86.445] (EE) NV: This driver cannot operate until it has been unloaded.
> ```



That looks like a message from xf86-video-nv driver. Apparently you didn't configure Xorg to load _nvidia_ driver.


----------



## Crotalus (Jul 12, 2019)

I believe that the module should be loaded.

Prior to applying updates there was no problem with previous driver. The sequence of events were;

```
freebsd-update fetch 
portsnap fetch update
portmaster -L --index-only | egrep '(ew|ort) version | total install'
```
This gave me a list of ports/packages that need to be updated.  Among them was the nvidia-driver. I don't remember the number, but it was about 20. 
In my /boot/loader.conf I have the entry
	
	



```
nvidia_load="YES"
```
Here is a few interesting things;

```
root@Prometheus:/ # cd /usr/ports/x11/nvidia-driver-340/ && make install clean
===>  nvidia-driver-340-340.107_4 requires kernel source files in /usr/src.
*** Error code 1

Stop.
make: stopped in /usr/ports/x11/nvidia-driver-340
root@Prometheus:/usr/ports/x11/nvidia-driver-340

root@Prometheus:/ # pkg install nvidia-driver-340
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The most recent versions of packages are already installed
root@Prometheus:/ # 

root@Prometheus:/ # cd /usr/ports/x11/nvidia-driver-340/ && make deinstall clean
===>  Deinstalling for nvidia-driver-340
===>   Deinstalling nvidia-driver-340-340.107_4
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
        nvidia-driver-340-340.107_4

Number of packages to be removed: 1

The operation will free 400 MiB.
[1/1] Deinstalling nvidia-driver-340-340.107_4...
[1/1] Deleting files for nvidia-driver-340-340.107_4: 100%
===>  Cleaning for nvidia-driver-340-340.107_4
root@Prometheus:/usr/ports/x11/nvidia-driver-340 # 

root@Prometheus:/ # 
root@Prometheus:/usr/ports/x11/nvidia-driver-340 # cd /usr/ports/x11/nvidia-driver-340/ && make install clean
===>  nvidia-driver-340-340.107_4 requires kernel source files in /usr/src.
*** Error code 1

Stop.
make: stopped in /usr/ports/x11/nvidia-driver-340
root@Prometheus:/usr/ports/x11/nvidia-driver-340 #

root@Prometheus:/ # pkg install nvidia-driver-340
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        nvidia-driver-340: 340.107_4

Number of packages to be installed: 1

The process will require 400 MiB more space.

Proceed with this action? [y/N]: y
[1/1] Installing nvidia-driver-340-340.107_4...
[1/1] Extracting nvidia-driver-340-340.107_4: 100%
Message from nvidia-driver-340-340.107_4:

To use these drivers, make sure that you have loaded the NVidia kernel
module, by doing

        # kldload nvidia        (or nvidia-modeset, see below)

or adding

        nvidia_load="YES"       (or nvidia-modeset_load="YES", see below)

to /boot/loader.conf, or putting ``nvidia'' (or ``nvidia-modeset'', see
below again) on ``kld_list'' variable in /etc/rc.conf.

If you build this port with FreeBSD AGP GART driver, make sure you have
agp.ko kernel module installed and loaded, since nvidia.ko will depend
on it, or have your kernel compiled with "device agp".  Otherwise, the
NVidia kernel module will not load.  Also, please set correct value for
``Option "NvAGP"'' in ``Device'' section of your X11 configuration file.

When building with Linux compatibility support, make sure that linux.ko
module is available as well (or have it compiled in kernel).  It can be
loaded via /boot/loader.conf, or later in the boot process if you add

        linux_enable="YES"

to your /etc/rc.conf.

If X.org cannot start and reports

        (EE) NVIDIA(0): Failed to obtain a shared memory identifier.

in /var/log/Xorg.0.log while actually you have ``options SYSVSHM''
enabled in kernel, the sysctl ``kern.ipc.shmall'' should be increased.

Starting with version 358.09, some important functionality of the driver
has been broken out into a separate kernel module, nvidia-modeset.ko.
Users that experience hangs when starting X11 server, or observe

        (II) NVIDIA(0): Validated MetaModes:
        (II) NVIDIA(0):     "NULL"

in /var/log/Xorg.0.log should replace ``nvidia'' with ``nvidia-modeset''
in their /boot/loader.conf or /etc/rc.conf configuration files, depending
on how they prefer to load NVidia driver kernel module.

See /usr/local/share/doc/NVIDIA_GLX-1.0/README for more information.
root@Prometheus:/ # 

root@Prometheus:/ # pkg info "nvidia*"
nvidia-driver-340-340.107_4
root@Prometheus:/ #
```


----------



## shkhln (Jul 12, 2019)

Crotalus said:


> I believe that the module should be loaded.



That kernel module has a corresponding userpace Xorg driver. See step 8 from https://forums.freebsd.org/threads/howto-setup-xorg-with-nvidias-driver.52311/#post-293480.


----------



## Amzo (Jul 12, 2019)

You need:

```
nvidia-modeset_load="YES"
```
in /boot/loader.conf

Also create this file:

/usr/local/etc/X11/xorg.conf.d/nvidia.conf

And add the following:


```
Section "Device"
    Identifier     "Device0"
    Driver "nvidia"
    VendorName "NVIDIA Corporation"
    Option "MetaModes" "nvidia-auto-select +0+0 { ForceFullCompositionPipeline = On }"
EndSection
```


----------



## shkhln (Jul 12, 2019)

Amzo said:


> ```
> nvidia-modeset_load="YES"
> ```



_nvidia-modeset_ kernel module was introduced in 358.09 driver package.


----------



## Amzo (Jul 12, 2019)

shkhln said:


> _nvidia-modeset_ kernel module was introduced in 358.09 driver package.



My bad, I thought you were using 360. The other configuration should still apply though since Xorg is trying to use NV. Could uninstall xf86-video-nv package or create the configuration file.


----------



## Crotalus (Jul 12, 2019)

I got it to work. Thanks to everybody that responded as I had no idea what was going on. I used the suggestions from Amzo. Deleting `xf86-video-nv` did not work so I put it back. 
Here is what is now in my /boot/loader.conf

```
nvidia-modset_load="yes"
nvidia_load="YES"
```
I also added the file /usr/local/etc/X11/xorg.conf.d/nvidia.conf and added the Section code. This was the last piece to make it work.

Why did I not need the configuration file prior to the updates? The new driver code or xorg must have something that needs additional information?
I should have seen the message in the install, but I missed it. I think I would still searching for the  data for the file. I have no idea what the option code does.

Thanks!


----------



## Amzo (Jul 12, 2019)

At some point you must have installed xf86-video-nv during an upgrade or reinstall of Xorg which was being loaded by default, the configuration file you made forced Xorg to use the nvidia driver.


----------

