# Nvidia Driver; startx rebooting system?



## TheOriginal_MrMacintosh (Nov 3, 2020)

Good evening everyone.
This problem is my first post here as I favor pouring thru the handbook and researching my own problems, but I just can't beat this one.

I have two hard drives in a 2011 Macbook Pro, and I'm dual booting with FreeBSD12.2-RELEASE.

I have installed the correct driver for my display, which is the Nvidia-340 driver specifically. I have tried installing from both ports and packages. The problem I'm facing is this:
if I add 
	
	



```
nvidia_load="YES"
```
 to my /boot/loader.conf, then after booting and logging in I run `kldstat` and verify it is loaded. At this point all looks normal. Once I run `startx` my system crashes and almost immediately reboots. I have rewritten my configs many times from precisely following the handbook's suggestions to other ideas I've come across doing web searches.

But wait, here's the real kicker. If I do not use that line in /boot/loader.conf whatsoever, and instead bootup, log in, and manually load the Nvidia module with `kldload nvidia` , then it works perfectly. Upon `startx` I am greeted with an Nvidia splash screen and my WM loads just fine.

Any thoughts?


----------



## xtouqh (Nov 3, 2020)

That's exactly why loading DRM modules and nvidia driver should be done using `kld_list` variable in /etc/rc.conf and not from /boot/loader.conf.


----------



## TheOriginal_MrMacintosh (Nov 3, 2020)

xtouqh said:


> That's exactly why loading DRM modules and nvidia driver should be done using `kld_list` variable in /etc/rc.conf and not from /boot/loader.conf.


I've never loaded my video modules that way in the past, but this is technically my first go with Nvidia if that matters.

Regardless, the result is the same I'm afraid. Upon `startx` is instant crash and system reboot. I can live with manually loading the module everytime I log in if need be, but that seems unnecessary if not out of line. Any other suggestions? I can only post here via my smartphone, so other than photos I don't have a particularly efficient way to post configs and so on.


----------



## SirDice (Nov 3, 2020)

TheOriginal_MrMacintosh said:


> I've never loaded my video modules that way in the past,


The `kld_list` option is relatively new. 

The idea here is to use loader.conf to only load modules that are crucial for the boot process and `kld_list` for everything else.


----------



## shkhln (Nov 3, 2020)

xtouqh said:


> That's exactly why loading DRM modules and nvidia driver should be done using `kld_list` variable in /etc/rc.conf and not from /boot/loader.conf.


I'm pretty sure this is strictly due to the necessity of specifying absolute paths to the drm-kmod kernel modules installed from ports. Every other explanation is fishy at best. (Well, this also avoids triggering a couple of bugs, but this is mostly incidental.)


----------



## TheOriginal_MrMacintosh (Nov 3, 2020)

SirDice said:


> The `kld_list` option is relatively new.
> 
> The idea here is to use loader.conf to only load modules that are crucial for the boot process and `kld_list` for everything else.


This is good information, i'll further research the what's and why's behind this, but since my result is the same, I can only assume it's a sort of bug with either the Nvidia module itself or X. I could perhaps create a login script to run `kldload` at login to circumvent this issue. Seems sloppy but if it works...


----------



## TheOriginal_MrMacintosh (Nov 3, 2020)

Interesting and unfortunate development; so far in this journey the only way to load X has been manually loading the Nvidia module right? I have only loaded up an xterm while in X. I tried opening Firefox and bam, immediate crash and reboot.

I'm not particularly adept on parsing the crash log but if I'm reading this correctly, something is causing my kernel to panic, assuming if this is even relevant or related, I just don't know.


```
panic: vm_radix_insert: key 1ec00 is already present
```

At the moment, I've completely removed the Nvidia module, and am using the default video settings it detects, generic at an awful looking 1024x768. At this point, at least X and any applications including my browser doesn't kill my system. Xrandr reports that resolution is the maximum so to get a proper display I am stuck with getting that nasty little Nvidia module to work.


----------



## SirDice (Nov 3, 2020)

As far as I know the 304 version is actually broken (doesn't like the recent Xorg changes) and will probably never be fixed. But the 340 driver should still work. Have you tried building x11/nvidia-driver-340 from ports? The packages are still being built for 12.1 and this may cause problems with certain kernel modules.


----------



## TheOriginal_MrMacintosh (Nov 3, 2020)

SirDice said:


> As far as I know the 304 version is actually broken (doesn't like the recent Xorg changes) and will probably never be fixed. But the 340 driver should still work. Have you tried building x11/nvidia-driver-340 from ports? The packages are still being built for 12.1 and this may cause problems with certain kernel modules.


Aye sir. In the course of my research I've found that very information and built my driver from ports. In experimenting I tried the package version as well to no avail, and I chose the 340 driver based on Nvidia's own website. As another experiment, I tried to compile the driver directly from their website but I then get a message that is not compatible due to something that is deprecated.


----------



## SirDice (Nov 3, 2020)

What type/model of the NVidia card does your MacBook have?

I have a Zotac box (GT 520M) running 12.2-STABLE and using the x11/nvidia-driver-390, I know that one definitely works.


----------



## TheOriginal_MrMacintosh (Nov 3, 2020)

SirDice said:


> What type/model of the NVidia card does your MacBook have?
> 
> I have a Zotac box (GT 520M) running 12.2-STABLE and using the x11/nvidia-driver-390, I know that one definitely works.


It would be a Geforce 320M. Not especially high-end I know.


----------

