# Starting GDM on NVIDIA results in black screen



## volatilevoid (Oct 4, 2018)

Hi,

I have a Lenovo ThinkPad P71 with an Intel HD Graphics P630 and an NVIDIA Quadro P5000 graphics adapter.

When I have _Hybrid Graphics_ enabled in the BIOS, GDM starts without problems with the graphics/drm-next-kmod Intel driver (well, it complains about GLX but that is most probably because X is trying to use the NVIDIA GLX library) and I see something on the screen. Starting GDM with the NVIDIA driver (latest version 390.87) does not work of course as the Intel GPU is controlling the display and the NVIDIA driver is complaining about not being able to connect to any display. So far so good.

When I switch to _Discrete Graphics_ in the BIOS (switching off the Intel graphics adapter), GDM seems to start on the Quadro but I get a black screen. If I wait 10 minutes until the screen shuts off and I switch it on again by pressing a key or touching the touchpad, I see the X mouse cursor and can also move it but the rest of the screen is still black.

/var/log/Xorg.0.log is not looking too bad; I see some suspicious error messages about Clutter in /var/log/gdm/:0.log though (see attached files). I also attached my /boot/loader.conf and /etc/rc.conf and the dmesg output. Everything was compiled from ports and I enabled Wayland if there was the option.

I am running FreeBSD 11.2-RELEASE.

Any help would be greatly appreciated. BTW, if I get the NVIDIA driver to work I am considering using VirtualGL as described here.

Regards
Thomas


----------



## shkhln (Oct 4, 2018)

https://devtalk.nvidia.com/default/...ogin-gtx-750-ti-390-25-/post/5247043/#5247043 ?


----------



## volatilevoid (Oct 4, 2018)

Thanks for the reply, I do not have a secondary monitor configured so the _position_ part does not apply. I have disabled the _Composite_ extension but that did not change anything (except that I see in Xorg.0.log that the extension has been disabled). Still getting a black screen.

Thomas

*Edit:* Starting a plain X session with `startx` actually does work. So the problem seems to be related to Clutter and Wayland(?).


----------



## shkhln (Oct 6, 2018)

You might want to check https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=226403.


----------



## volatilevoid (Oct 6, 2018)

Well, if you see this error message

```
libGL error: No matching fbConfigs or visuals found
```
in /var/log/gdm/:0-greeter.log then you are using the libGL library from Mesa instead from the NVIDIA driver. That is what I found out after some googling.  By the way, I attached the wrong file, I did not mean to attach /var/log/gdm/:0.log.

For testing purposes I backed up the original library and replaced it with the NVIDIA one and — lo and behold — GDM starts up. 

Just a few open issues now.

If I log out, I get a black screen again. Maybe the NVIDIA driver does not like vt(4) with _efifb_? *Edit:* SirDice seems to agree.
The GNOME Tracker crashes with a core dump (I see a tracker-miner-fs.core file in my home directory). I already tried to investigate this issue but did not get very far. It was also coredumping when I tried out GNOME 3.28 from the GNOME development ports tree.
When I change the language in GNOME, nothing happens except that restarting GNOME takes a very long time (probably forgot to configure something).
The mouse pointer changes its size depending on its position which is odd.
Maybe I can get around the first issue when I switch to VirtualGL.



shkhln said:


> You might want to check https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=226403.


Thanks! We were writing our replies at almost the exact same time. 

Thomas


----------



## shkhln (Oct 6, 2018)

volatilevoid said:


> If I log out, I get a black screen again.



Note that black is the default Xorg background color, it might be just that.



volatilevoid said:


> Maybe the NVIDIA driver does not like vt(4) with _efifb_? *Edit:* SirDice seems to agree.



Yeah, pretty obnoxious bug. There are quite a few complaints on the FreeBSD bugtracker:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=213912
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224069
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=201461


----------



## volatilevoid (Oct 6, 2018)

shkhln said:


> Note that black is the default Xorg background color, it might be just that.


No, the screen is black like in _Ctrl+Alt+Fn does not do anything, but the machine is still fully functional_. Is not GDM restarted after a logout? This would more or less be the same like switching to the console from X which also results in a black screen.

I think I will either try

```
hw.vga.textmode=1
```
or see if I can get around this by switching to Intel + NVIDIA over VirtualGL as _fb_ from graphics/drm-next-kmod works without problems.

Thomas


----------



## calindan2013 (Oct 6, 2018)

volatilevoid said:


> Well, if you see this error message
> 
> ```
> libGL error: No matching fbConfigs or visuals found
> ...



Hey, I have the same issue with the same errrors in gdm log, how do I apply your fix and replace the libGL with nvidia one?


----------



## volatilevoid (Oct 6, 2018)

calindan2013 said:


> Hey, I have the same issue with the same errrors in gdm log, how do I apply your fix and replace the libGL with nvidia one?


I strongly recommend that you do not do it like I did (because that was a quick & dirty hack) but check out PR 226403. You need to patch the Makefile of x11/nvidia-driver and rebuild the port, then it should work. I just replaced libGL.so.1.2.0 which is not how you should do it.


----------



## calindan2013 (Oct 6, 2018)

volatilevoid said:


> I strongly recommend that you do not do it like I did (because that was a quick & dirty hack) but check out PR 226403. You need to patch the Makefile of x11/nvidia-driver and rebuild the port, then it should work. I just replaced libGL.so.1.2.0 which is not how you should do it.



it's weird because xfce works but gnome/gdm doesnt using the current libGL. Do you think i need to compile nvidia driver from ports with that patch to get gnome going in this case?


----------



## calindan2013 (Oct 6, 2018)

anyway, what is the command to apply that patch ?


----------



## volatilevoid (Oct 7, 2018)

calindan2013 said:


> it's weird because xfce works but gnome/gdm doesnt using the current libGL.


GNOME definitely needs OpenGL to work while I am pretty sure that Xfce does not. That is why Xfce starts even with the "incorrect" libGL.



calindan2013 said:


> anyway, what is the command to apply that patch ?



You need to download attachment 191260 from the first message of PR 226403.
Copy x11_nvidia-driver_Makefile.diff to /usr/ports/x11/nvidia-driver.
Go to /usr/ports/x11/nvidia-driver.
Execute `patch Makefile < x11_nvidia-driver_Makefile.diff` and then `make install clean` (or use portmaster(8) for example). If you have already installed the driver before and you are installing it manually, run `make deinstall` first.
Thomas


----------



## calindan2013 (Oct 7, 2018)

so i only need to compile nvidia driver , gnome can be used from packages right?


----------



## volatilevoid (Oct 7, 2018)

calindan2013 said:


> so i only need to compile nvidia driver , gnome can be used from packages right?


That should work, yes.


----------



## Minbari (Oct 7, 2018)

calindan2013 said:


> so i only need to compile nvidia driver , gnome can be used from packages right?


Don't mix ports with packages you will break your system, instead make a package from that port (inside the port run `make package` to create a binary package which is not automatically installed on your machine, you have to use`pkg install` to install it) or you could use ports-mgmt/poudriere to build custom packages.


----------



## calindan2013 (Oct 7, 2018)

any idea how to fix my mouse? doesnt work in either X or text mode.


----------



## volatilevoid (Oct 7, 2018)

calindan2013 said:


> any idea how to fix my mouse? doesnt work in either X or text mode.


Cannot really help you with your mouse issue but there are already several threads about mice not working, e.g.

Thread 47318
Thread 54244
Thread 64262
You might want to check them out.

Meanwhile I was able to (temporarily) fix the segfault in tracker-miner-fs (not exactly X.Org-related but oh well). The issue has been reported already 2 months back. For now the solution is to compile sysutils/tracker-miners with `-O0`. It is sufficient to add `CFLAGS+=-O0` in the port Makefile.

Thomas


----------



## SirDice (Oct 8, 2018)

```
(==) Using config file: "/etc/X11/xorg.conf"
```

`rm /etc/X11/xorg.conf`

Handbook: 5.4. Xorg Configuration


----------



## volatilevoid (Oct 8, 2018)

SirDice said:


> `rm /etc/X11/xorg.conf`
> 
> Handbook: 5.4. Xorg Configuration


Thanks, I know that using xorg.conf is not how to do it.  I just quickly hacked the config file together for a first test. Still have not decided if I will use VirtualGL or just the NVIDIA card. If I use VirtualGL then I need another setup anyway to be able to start both X servers.


----------



## calindan2013 (Oct 8, 2018)

volatilevoid said:


> No, the screen is black like in _Ctrl+Alt+Fn does not do anything, but the machine is still fully functional_. Is not GDM restarted after a logout? This would more or less be the same like switching to the console from X which also results in a black screen.
> 
> I think I will either try
> 
> ...



Please show me the exact command you used to link the libGL that made it work.


----------



## volatilevoid (Oct 9, 2018)

calindan2013 said:


> Please show me the exact command you used to link the libGL that made it work.


*Disclaimer: Do not do it like this!* Patch the Makefile of x11/nvidia-driver!
You asked for it...

`# mv /usr/local/lib/libGL.so.1.2.0 /usr/local/lib/libGL.so.1.2.0.orig
# cp /usr/local/lib/libGL-NVIDIA.so.1 /usr/local/lib/libGL.so.1.2.0`

Again, it is extremely bad to do it like this.

Thomas


----------

