# X doesn't start: Nvidia 940GX



## Chuck Musser (Dec 27, 2017)

I'm trying to get X configured on a Thinkpad 25. This laptop has a GeForce 940GX graphics device and I'm running 12.0--CURRENT r3270038.

I tried the guide here, but the install of x11/nvidia-driver package failed due to "no linux compatibility in kernel". Next I referred to this page in the handbook, which led me to install the nvidia driver from the ports collection. That succeeded, but I'm still not sure if there the required Linux support is in place.

Next, I created /usr/local/etc/X11/xorg.conf.d/driver-nvidia.conf with:


```
Section "Device"
   Identifier "NVIDIA Card"
   VendorName "NVIDIA Corporation"
   Driver "nvidia"
EndSection
```

Trying to start X with `startx` resulted in the following X.org log:


```
[    25.827]
X.Org X Server 1.18.4
Release Date: 2016-07-19
[    25.827] X Protocol Version 11, Revision 0
[    25.827] Build Operating System: FreeBSD 12.0-CURRENT amd64
[    25.827] Current Operating System: FreeBSD wraith 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r327038: Wed Dec 20 21:00:23 UTC 2017     root@releng3.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
[    25.828] Build Date: 21 December 2017  04:02:09AM
[    25.828] 
[    25.828] Current version of pixman: 0.34.0
[    25.828]    Before reporting problems, check http://wiki.x.org
   to make sure that you have the latest version.
[    25.828] Markers: (--) probed, (**) from config file, (==) default setting,
   (++) from command line, (!!) notice, (II) informational,
   (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[    25.828] (==) Log file: "/var/log/Xorg.0.log", Time: Tue Dec 26 10:24:05 2017
[    25.830] (==) Using config directory: "/usr/local/etc/X11/xorg.conf.d"
[    25.830] (==) No Layout section.  Using the first Screen section.
[    25.830] (==) No screen section available. Using defaults.
[    25.831] (**) |-->Screen "Default Screen Section" (0)
[    25.831] (**) |   |-->Monitor "<default monitor>"
[    25.831] (==) No device specified for screen "Default Screen Section".
   Using the first device section listed.
[    25.831] (**) |   |-->Device "NVIDIA Card"
[    25.831] (==) No monitor specified for screen "Default Screen Section".
   Using a default monitor configuration.
[    25.831] (==) Automatically adding devices
[    25.831] (==) Automatically enabling devices
[    25.831] (==) Not automatically adding GPU devices
[    25.832] (==) Max clients allowed: 256, resource mask: 0x1fffff
[    25.838] (==) FontPath set to:
   /usr/local/share/fonts/misc/,
   /usr/local/share/fonts/TTF/,
   /usr/local/share/fonts/OTF/,
   /usr/local/share/fonts/Type1/,
   /usr/local/share/fonts/100dpi/,
   /usr/local/share/fonts/75dpi/
[    25.838] (==) ModulePath set to "/usr/local/lib/xorg/modules"
[    25.838] (II) The server relies on devd to provide the list of input devices.
   If no devices become available, reconfigure devd or disable AutoAddDevices.
[    25.838] (II) Loader magic: 0x811d40
[    25.838] (II) Module ABI versions:
[    25.838]    X.Org ANSI C Emulation: 0.4
[    25.838]    X.Org Video Driver: 20.0
[    25.838]    X.Org XInput driver : 22.1
[    25.838]    X.Org Server Extension : 9.0
[    25.838] (--) PCI:*(0:0:2:0) 8086:5916:17aa:2246 rev 2, Mem @ 0xeb000000/16777216, 0x80000000/268435456, I/O @ 0x0000e000/64, BIOS @ 0x????????/65536
[    25.838] (--) PCI: (0:2:0:0) 10de:134d:17aa:2246 rev 162, Mem @ 0xec000000/16777216, 0x90000000/268435456, 0xa0000000/33554432, I/O @ 0x0000d000/128
[    25.838] (II) LoadModule: "glx"
[    25.840] (II) Loading /usr/local/lib/xorg/modules/extensions/libglx.so
[    25.923] (II) Module glx: vendor="NVIDIA Corporation"
[    25.923]    compiled for 4.0.2, module version = 1.0.0
[    25.923]    Module class: X.Org Server Extension
[    25.923] (II) NVIDIA GLX Module  384.90  Tue Sep 19 17:25:09 PDT 2017
[    25.924] (II) LoadModule: "nvidia"
[    25.925] (II) Loading /usr/local/lib/xorg/modules/drivers/nvidia_drv.so
[    25.931] (II) Module nvidia: vendor="NVIDIA Corporation"
[    25.931]    compiled for 4.0.2, module version = 1.0.0
[    25.931]    Module class: X.Org Video Driver
[    25.932] (II) NVIDIA dlloader X Driver  384.90  Tue Sep 19 17:02:53 PDT 2017
[    25.933] (II) NVIDIA Unified Driver for all Supported NVIDIA GPUs
[    25.933] (--) Using syscons driver with X support (version 2.0)
[    25.933] (--) using VT number 9

[    25.933] (EE) No devices detected.
[    25.934] (EE)
Fatal server error:
[    25.934] (EE) no screens found(EE)
[    25.934] (EE)
Please consult the The X.Org Foundation support
    at http://wiki.x.org
 for help.
[    25.934] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
[    25.934] (EE)
[    25.935] (EE) Server terminated with error (1). Closing log file.
```

Not sure what the no devices and screens errors mean. I tried a couple of other things that I ran across, but they did not help:

1.) Adding linux_load="YES" to /boot/loader.conf
2.) Adding kern.vty=vt, also to /boot/loader.conf

The first one seemed to make sense in the context of needing Linux compatibility. The second one is voodoo I do not understand (but it was mentioned in one of the Handbook pages). According to NVidia's website, this graphics device is supported. What else can I try to make it work?

Thanks,
Chuck


----------



## SirDice (Dec 27, 2017)

Chuck Musser said:


> I'm running 12.0-CURRENT


Topics about unsupported FreeBSD versions


----------



## scottro (Dec 27, 2017)

Unless you need CURRENT for other hardware, it might be worth trying with 11.1   I don't think (but am not sure) that you would need the kern.vty=vt in this case.   (I don't want to give bogus advice, and am too tired to check it right now, but it seems to me I've only ever needed to add that with Intel cards). 

CURRENT is more useful when you have an Intel or AMD card, as many that are newer than 3 years old or so are not supported in RELEASE.  As you you have an NVidia card, you will almost certainly have better luck sticking with RELEASE 

In my experience, the guide you linked to usually works (for RELEASE).


----------



## SirDice (Dec 27, 2017)

scottro said:


> I don't think (but am not sure) that you would need the kern.vty=vt in this case.


It's been the default for a while now, there's no need to set it explicitly. But it doesn't hurt if you set it.


----------



## Chuck Musser (Dec 27, 2017)

I was using CURRENT because this machine has an Intel 8275 wireless chip and support for that was added only recently. I could try RELEASE. The machine has an Ethernet interface (supported by the em driver). Less convenient, long term, but workable for a test. 

With, CURRENT, I got a little farther by specifying a BusId.

I used this info from pciconf:


```
vgapci1@pci0:2:0:0:     class=0x030200 card=0x224617aa chip=0x134d10de rev=0xa2 hdr=0x00
    vendor     = 'NVIDIA Corporation'
    device     = 'GM108M [GeForce 940MX]'
    class      = display
    subclass   = 3D
```

to add this to the Device section:


```
BusId "PCI:2:0:0"
```

This is the Xorg.log contents:


```
[  1020.473]
X.Org X Server 1.18.4
Release Date: 2016-07-19
[  1020.474] X Protocol Version 11, Revision 0
[  1020.474] Build Operating System: FreeBSD 12.0-CURRENT amd64
[  1020.474] Current Operating System: FreeBSD wraith 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r327038: Wed Dec 20 21:00:23 UTC 2017     root@releng3.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
[  1020.475] Build Date: 21 December 2017  04:02:09AM
[  1020.475]  
[  1020.475] Current version of pixman: 0.34.0
[  1020.475]    Before reporting problems, check http://wiki.x.org
   to make sure that you have the latest version.
[  1020.475] Markers: (--) probed, (**) from config file, (==) default setting,
   (++) from command line, (!!) notice, (II) informational,
   (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[  1020.476] (==) Log file: "/var/log/Xorg.0.log", Time: Wed Dec 27 00:52:59 2017
[  1020.477] (==) Using config directory: "/usr/local/etc/X11/xorg.conf.d"
[  1020.477] (==) No Layout section.  Using the first Screen section.
[  1020.477] (==) No screen section available. Using defaults.
[  1020.477] (**) |-->Screen "Default Screen Section" (0)
[  1020.477] (**) |   |-->Monitor "<default monitor>"
[  1020.478] (==) No device specified for screen "Default Screen Section".
   Using the first device section listed.
[  1020.478] (**) |   |-->Device "NVIDIA Card"
[  1020.478] (==) No monitor specified for screen "Default Screen Section".
   Using a default monitor configuration.
[  1020.478] (==) Automatically adding devices
[  1020.478] (==) Automatically enabling devices
[  1020.478] (==) Not automatically adding GPU devices
[  1020.479] (==) Max clients allowed: 256, resource mask: 0x1fffff
[  1020.479] (==) FontPath set to:
   /usr/local/share/fonts/misc/,
   /usr/local/share/fonts/TTF/,
   /usr/local/share/fonts/OTF/,
   /usr/local/share/fonts/Type1/,
   /usr/local/share/fonts/100dpi/,
   /usr/local/share/fonts/75dpi/
[  1020.479] (==) ModulePath set to "/usr/local/lib/xorg/modules"
[  1020.479] (II) The server relies on devd to provide the list of input devices.
   If no devices become available, reconfigure devd or disable AutoAddDevices.
[  1020.479] (II) Loader magic: 0x811d40
[  1020.479] (II) Module ABI versions:
[  1020.480]    X.Org ANSI C Emulation: 0.4
[  1020.480]    X.Org Video Driver: 20.0
[  1020.480]    X.Org XInput driver : 22.1
[  1020.480]    X.Org Server Extension : 9.0
[  1020.480] (--) PCI:*(0:0:2:0) 8086:5916:17aa:2246 rev 2, Mem @ 0xeb000000/16777216, 0x80000000/268435456, I/O @ 0x0000e000/64, BIOS @ 0x????????/65536
[  1020.481] (--) PCI: (0:2:0:0) 10de:134d:17aa:2246 rev 162, Mem @ 0xec000000/16777216, 0x90000000/268435456, 0xa0000000/33554432, I/O @ 0x0000d000/128
[  1020.481] (II) LoadModule: "glx"
[  1020.482] (II) Loading /usr/local/lib/xorg/modules/extensions/libglx.so
[  1020.500] (II) Module glx: vendor="NVIDIA Corporation"
[  1020.500]    compiled for 4.0.2, module version = 1.0.0
[  1020.501]    Module class: X.Org Server Extension
[  1020.501] (II) NVIDIA GLX Module  384.90  Tue Sep 19 17:25:09 PDT 2017
[  1020.501] (II) LoadModule: "nvidia"
[  1020.502] (II) Loading /usr/local/lib/xorg/modules/drivers/nvidia_drv.so
[  1020.503] (II) Module nvidia: vendor="NVIDIA Corporation"
[  1020.504]    compiled for 4.0.2, module version = 1.0.0
[  1020.504]    Module class: X.Org Video Driver
[  1020.504] (II) NVIDIA dlloader X Driver  384.90  Tue Sep 19 17:02:53 PDT 2017
[  1020.504] (II) NVIDIA Unified Driver for all Supported NVIDIA GPUs
[  1020.504] (--) Using syscons driver with X support (version 2.0)
[  1020.504] (--) using VT number 9

[  1020.506] (II) Loading sub module "fb"
[  1020.506] (II) LoadModule: "fb"
[  1020.507] (II) Loading /usr/local/lib/xorg/modules/libfb.so
[  1020.507] (II) Module fb: vendor="X.Org Foundation"
[  1020.507]    compiled for 1.18.4, module version = 1.0.0
[  1020.508]    ABI class: X.Org ANSI C Emulation, version 0.4
[  1020.508] (II) Loading sub module "wfb"
[  1020.508] (II) LoadModule: "wfb"
[  1020.508] (II) Loading /usr/local/lib/xorg/modules/libwfb.so
[  1020.509] (II) Module wfb: vendor="X.Org Foundation"
[  1020.509]    compiled for 1.18.4, module version = 1.0.0
[  1020.509]    ABI class: X.Org ANSI C Emulation, version 0.4
[  1020.510] (II) Loading sub module "ramdac"
[  1020.510] (II) LoadModule: "ramdac"
[  1020.510] (II) Module "ramdac" already built-in
[  1020.510] (WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
[  1020.510] (II) NVIDIA(0): Creating default Display subsection in Screen section
   "Default Screen Section" for depth/fbbpp 24/32
[  1020.511] (==) NVIDIA(0): Depth 24, (==) framebuffer bpp 32
[  1020.511] (==) NVIDIA(0): RGB weight 888
[  1020.511] (==) NVIDIA(0): Default visual is TrueColor
[  1020.511] (==) NVIDIA(0): Using gamma correction (1.0, 1.0, 1.0)
[  1020.511] (**) NVIDIA(0): Enabling 2D acceleration
[  1020.520] (EE) NVIDIA(GPU-0): Failed to initialize the NVIDIA GPU at PCI:2:0:0.  Please
[  1020.520] (EE) NVIDIA(GPU-0):     check your system's kernel log for additional error
[  1020.520] (EE) NVIDIA(GPU-0):     messages and refer to Chapter 8: Common Problems in the
[  1020.521] (EE) NVIDIA(GPU-0):     README for additional information.
[  1020.521] (EE) NVIDIA(GPU-0): Failed to initialize the NVIDIA graphics device!
[  1020.521] (EE) NVIDIA(0): Failing initialization of X screen 0
[  1020.521] (II) UnloadModule: "nvidia"
[  1020.521] (II) UnloadSubModule: "wfb"
[  1020.521] (II) UnloadSubModule: "fb"
[  1020.521] (EE) Screen(s) found, but none have a usable configuration.
[  1020.522] (EE)
Fatal server error:
[  1020.522] (EE) no screens found(EE)
[  1020.522] (EE)
Please consult the The X.Org Foundation support
    at http://wiki.x.org
 for help.
[  1020.522] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
[  1020.522] (EE)
[  1020.524] (EE) Server terminated with error (1). Closing log file.
```

As indicated in the above, /var/log/messages does contain something interesting:


```
Dec 27 00:56:05 wraith kernel: NVRM: failed to copy vbios to system memory.
Dec 27 00:56:05 wraith kernel: NVRM: RmInitAdapter failed! (0x30:0xffff:660)
Dec 27 00:56:05 wraith kernel: nvidia1: NVRM: rm_init_adapter() failed!
```

I tried a couple other values for the BusId, such as "0:2:0" (which was printed early in the Xorg.log) and one that was intended to be invalid "3:0:0", just to see what would happen. Both of those resulted in an Xorg.log similar to the original one.


----------



## SirDice (Dec 27, 2017)

Chuck Musser said:


> That succeeded, but I'm still not sure if there the required Linux support is in place.


Linux support is NOT required for the driver to work.

Remove the whole BusId from the configuration, you rarely need to set it. And it really only makes sense if you have more than one card.



Chuck Musser said:


> Next I referred to this page in the handbook


That's from 7.3-RELEASE. Seriously outdated.

Handbook: 5.4. Xorg Configuration


----------



## Chuck Musser (Dec 27, 2017)

Yeah, only one NVIDIA, so maybe BusID is irrelevant here. Linux modules seemed to be loaded even if I removed the the line from loader.conf. Not sure what's up with that.

Given all that: it turns out it has an Intel HD 620 chip as well. After these steps, X started:

- Install drm-next-kmod package
- Add kld_list="/boot/modules/i915kms.ko"
- remove all the files from /usr/local/etc/X11/xorg.conf.d (there was only the one).
- reboot

I have a feeling that the NVIDIA could be made to work, but not sure how to interpret those errors.


----------



## scottro (Dec 27, 2017)

Ah, I didn't realize it had an Intel card, or I would have aggravated SirDice and told you to use CURRENT.   I haven't had a dual video laptop so have no experience with them, but the newer (with a loose definition of new--at this point we're talking 3 years old and newer) laptops often require CURRENT to have any sort of decent performance.  I have a little page (that I don't think you need) about FreeBSD and later intel cards, http://srobb.net/freebsdintel.html but the only thing I'd mention from it is to redo your kernel to use the GENERIC-NODEBUG kernel, as the default CURRENT kernel will give reduced performance.


----------



## Chuck Musser (Dec 27, 2017)

I didn't realize it either, but pciconf -lv showed it. I think this is a Kabylake-based laptop and, according to the graphics support page, that requires CURRENT and using drm-next-kmod. Seems like it works fine, but my needs are modest here: mostly terminal and Emacs work with some web browsing.


----------



## SirDice (Dec 28, 2017)

Some laptops allow you to disable one or the other card in the BIOS. That might provide a solution. 

Mixing the Intel driver and the NVidia driver is going to be problematic in any case. The NVidia driver replaces a couple of Xorg libraries, I'm really unsure how this would interact with the Intel driver that assumes the original Xorg libraries.


----------



## akram65 (Jan 9, 2018)

Chuck Musser said:


> - Add kld_list="/boot/modules/i915kms.ko"


Where do I add this? 
I'm having the same problem and I have to use current-12 as I'm using kaby lake laptop with nvidia and xorg doesn't start despite doing all other steps. I feel like this will work.


----------



## ThothK (Oct 22, 2018)

akram65 said:


> Where do I add this?



In case anyone else needs it:
I added the line to /etc/rc.conf
`kld_list="/boot/modules/i915kms.ko"`
As a result of experimenting with an external display, I currently have:
`# Trying all three
kld_list="/boot/modules/i915kms.ko nvidia nvidia-modeset"`



=thoth=


----------

