Help with NVIDIA drm set up

Greetings,

Hope you are all doing well, I am trying out FreeBSD for the first time and really liking it so far.
I wanted to install my laptop graphics driver, I have a laptop with an NVIDIA (1650) card an integrated Intel card.
So far I had no luck to get my system working with graphic cards enabled, here is what I did:

I installed the graphics/nvidia-drm-kmod and added the following to my /boot/loader.conf :
Code:
hw.nvidiadrm.modeset=1

I also added this to my /etc/rc.conf :
Code:
kld_list="i915kms"
Code:
kld_list="nvidia-drm"

As far as I understood, I don't need to have anything in my /etc/X11/ or /usr/local/etc/X11/xorg.conf.d/ because it should be detected automatically with nvidia-drm. Sadly with all of this my system doesn't boot, I tried to boot it with startx but whenever I do that it just launch a black screen, I only have this in my .xinitrc
Code:
exec awesome
.
looking at my /var/log/Xorg.0.log This is my output : https://pastebin.com/FuWxkbqZ
I would appreciate any help, what am I doing wrong?
 
I also added this to my /etc/rc.conf :
Things in rc.conf are variable assignments. The second kld_list overrules whatever was set on the first. If you want to load both modules it should be used like this: kld_list="i915kms nvidia-drm".

A easy way to set variables in rc.conf is by using sysrc(8): sysrc kld_list+="i915kms" and sysrc kld_list+="nvidia-drm"
 
i have always set nvidia-modeset in my rc.conf

Code:
/etc/rc.conf

Code:
kld_list="nvidia-modeset nvidia-drm linux linux64 i915kms"

and not in /boot/loader.conf
 
This part of your log
Code:
[    36.918] (--) NVIDIA(0): Valid display device(s) on GPU-0 at PCI:1:0:0
[    36.918] (--) NVIDIA(0):     DFP-0
[    36.921] (II) NVIDIA(0): NVIDIA GPU NVIDIA GeForce GTX 1650 (TU117-A) at PCI:1:0:0
[    36.921] (II) NVIDIA(0):     (GPU-0)
[    36.921] (--) NVIDIA(0): Memory: 4194304 kBytes
[    36.921] (--) NVIDIA(0): VideoBIOS: 90.17.4c.00.1c
[    36.921] (II) NVIDIA(0): Detected PCI Express Link width: 16X
[    36.922] (--) NVIDIA(GPU-0): DFP-0: disconnected
[    36.922] (--) NVIDIA(GPU-0): DFP-0: Internal TMDS
[    36.922] (--) NVIDIA(GPU-0): DFP-0: 165.0 MHz maximum pixel clock
[    36.922] (--) NVIDIA(GPU-0):
[    36.922] (==) NVIDIA(0):
[    36.922] (==) NVIDIA(0): No modes were requested; the default mode "nvidia-auto-select"
[    36.922] (==) NVIDIA(0):     will be used as the requested mode.
[    36.922] (==) NVIDIA(0):
[    36.922] (--) NVIDIA(0): No enabled display devices found; starting anyway because
[    36.922] (--) NVIDIA(0):     AllowEmptyInitialConfiguration is enabled
would indicate that your nvidia dGPU is detected, initialized sanely but somehow not enabled, and display panel is disconnected (taken over by iGPU?).
If your computer allows disabling iGPU via firmware(BIOS) coniguration, it could help.
 
You cannot load two drm modules in the same time so don't load i915kms for now since you want to test nvidia one.
Remove modules from /boot/loader.conf and/or /etc/rc.conf. You should first load them manually to test if it works.
After reboot load linux64 and nvidia or nvidia-modeset (try them both, see which one works):
Code:
kldload linux64
kldload nvidia-modeset
Your should see a kernel message that the gpu was initialized after which you can run startx. There is no need to configure anything in /etc/X11/xorg.conf.
Adjust your resolution and dpi with xrandr if needed.

If your module works, only then you can add it in /boot/loader.conf if you want to set the resolution at boot time or in /etc/rc.conf

edit: I just noticed your xorg logs. (WW) VGA arbiter: cannot open kernel arbiter, no multi-card support - might be because you loaded both modules for intel and for nvidia.
 
Hello,

Thank you all for your help so far.
Things in rc.conf are variable assignments. The second kld_list overrules whatever was set on the first. If you want to load both modules it should be used like this: kld_list="i915kms nvidia-drm".

A easy way to set variables in rc.conf is by using sysrc(8): sysrc kld_list+="i915kms" and sysrc kld_list+="nvidia-drm"
I did't know that thanks for letting me know, I changed my /etc/rc.conf to look like this kld_list="nvidia-modeset nvidia-drm i915kms"
I also added nvidia-modeset like NapoleonWils0n suggested.

This part of your log
Code:
[    36.918] (--) NVIDIA(0): Valid display device(s) on GPU-0 at PCI:1:0:0
[    36.918] (--) NVIDIA(0):     DFP-0
[    36.921] (II) NVIDIA(0): NVIDIA GPU NVIDIA GeForce GTX 1650 (TU117-A) at PCI:1:0:0
[    36.921] (II) NVIDIA(0):     (GPU-0)
[    36.921] (--) NVIDIA(0): Memory: 4194304 kBytes
[    36.921] (--) NVIDIA(0): VideoBIOS: 90.17.4c.00.1c
[    36.921] (II) NVIDIA(0): Detected PCI Express Link width: 16X
[    36.922] (--) NVIDIA(GPU-0): DFP-0: disconnected
[    36.922] (--) NVIDIA(GPU-0): DFP-0: Internal TMDS
[    36.922] (--) NVIDIA(GPU-0): DFP-0: 165.0 MHz maximum pixel clock
[    36.922] (--) NVIDIA(GPU-0):
[    36.922] (==) NVIDIA(0):
[    36.922] (==) NVIDIA(0): No modes were requested; the default mode "nvidia-auto-select"
[    36.922] (==) NVIDIA(0):     will be used as the requested mode.
[    36.922] (==) NVIDIA(0):
[    36.922] (--) NVIDIA(0): No enabled display devices found; starting anyway because
[    36.922] (--) NVIDIA(0):     AllowEmptyInitialConfiguration is enabled
would indicate that your nvidia dGPU is detected, initialized sanely but somehow not enabled, and display panel is disconnected (taken over by iGPU?).
If your computer allows disabling iGPU via firmware(BIOS) coniguration, it could help.

Thanks your for your input T-Aoki! however my bios sadly doesn't have that option, I also would like if it is possible to use the two GPU's so I could use the nvidia one for heavy stuff and the intel one for everything else, that way I could save on battery.

After doing the changes above I my system doesn't get stuck at a black screenn, insted whenever I enter startx it tries to launch and goes back to tty after it fails. Here is the output of my /var/log/Xorg.0.log : https://pastebin.com/zye6XrLJ

I hope someone might now if I am still doing something wrong.
 
The error part of the log is now
Code:
[    89.943] (EE) intel(G0): intel_uxa_set_pixmap_bo: size of buffer object does not match constraints: size=3145728, must be greater than 3145728, but less than 0
[    89.943] (EE)
Fatal server error:
[    89.943] (EE) failed to create screen resources(EE)

So, a question.
Have you installed x11-drivers/xf86-video-intel?
If so, try deinstalling it. The driver should be non-DRM one and would block i915kms to work (as prioritized by X) if both are activated by X window.
 
Indeed, I have that package installed, I removed it like you advised, now whenever I try to boot with startx I go to a completely black screen and doesn't fail and bring me back to the tty. So far this is the closest I got to getting into the system with the graphics driver haha. my /etc/rc.conf is still the same. this is now the output of my /var/log/Xorg.0.log : https://pastebin.com/wqCcPjyC

Looking at it it seems that the intel module is not being found anymore after deleting the x11-drivers/xf86-video-intel. That being said it seems like more stuff are happening now, as far as I can understand it seems that more stuff are being initiated in the system now, like I said this is definitely the closest I got thus far.
Can anyone provide advice of what to do next?
 
Could you post some info about your system; what is the output of the following commands?
freebsd-version -kru
pciconf -lv | grep -B4 -A1 display
sysctl hw.model hw.machine hw.ncpu
pkg info -g 'drm-*-kmod'
pkg info | grep nvidia
 
Hey Erichans, ofcourse. Here you go :

freebsd-version -kru :
Code:
14.1-RELEASE
14.1-RELEASE
14.1-RELEASE

pciconf -lv | grep -B4 -A1 display :
Code:
    subclass   = PCI-PCI
vgapci1@pci0:0:2:0:    class=0x030000 rev=0x05 hdr=0x00 vendor=0x8086 device=0x9bc4 subvendor=0x1025 subdevice=0x143d
    vendor     = 'Intel Corporation'
    device     = 'CometLake-H GT2 [UHD Graphics]'
    class      = display
    subclass   = VGA
--
    class      = serial bus
vgapci0@pci0:1:0:0:    class=0x030000 rev=0xa1 hdr=0x00 vendor=0x10de device=0x1f99 subvendor=0x1025 subdevice=0x143e
    vendor     = 'NVIDIA Corporation'
    device     = 'TU117M [GeForce GTX 1650 Mobile / Max-Q]'
    class      = display
    subclass   = VGA


sysctl hw.model hw.machine hw.ncpu
Code:
hw.model: Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
hw.machine: amd64
hw.ncpu: 12


pkg info -g 'drm-*-kmod'
Code:
drm-61-kmod-6.1.92

Hope this is good! if you need more info please let me know.
 
/etc/rc.conf
Code:
kld_list="nvidia-drm ..............."

/boot/loader.conf
Code:
hw.nvidiadrm.modeset=1

is all you need for NVIDIA only.
 
Depending on the laptop model it may also possible that only the iGPU works on FreeBSD…
So another try would be only with the Intel drm driver…
 
You cannot load two drm modules in the same time so don't load i915kms for now since you want to test nvidia one.
Remove modules from /boot/loader.conf and/or /etc/rc.conf. You should first load them manually to test if it works.
After reboot load linux64 and nvidia or nvidia-modeset (try them both, see which one works):
Code:
kldload linux64
kldload nvidia-modeset
Your should see a kernel message that the gpu was initialized after which you can run startx. There is no need to configure anything in /etc/X11/xorg.conf.
Adjust your resolution and dpi with xrandr if needed.

If your module works, only then you can add it in /boot/loader.conf if you want to set the resolution at boot time or in /etc/rc.conf

edit: I just noticed your xorg logs. (WW) VGA arbiter: cannot open kernel arbiter, no multi-card support - might be because you loaded both modules for intel and for nvidia.

Hey dann, My bad I just noticed your comment. I did the same as you suggested and I managed to boot into the system! I added it back to my /etc/rc.conf like this :
kld_list="nvidia-modeset"
And add this back to my /boot/loader.conf :
hw.nvidiadrm.modeset=1

And now I can normally boot into the system.
I tried to do the same with nvidia-drm like jb82 suggested

/etc/rc.conf
Code:
kld_list="nvidia-drm ..............."

/boot/loader.conf
Code:
hw.nvidiadrm.modeset=1

is all you need.

But that didn't seem to work, I am honestly not sure what is the difference between the two packages. Is nvidia-modeset the free package and nvidia-drm the proprietary one? like nouveau on Linux? if so then does that mean I wouldn't get good performance on nvidia-modeset in comparison with nvidia-drm?
I would really appereciate it if someone could explain it to me. Thanks for everyone help so far! and I apologize to the moderators if I am posting to many messages in a short time since they have to approve each one.
 
Hey dann, My bad I just noticed your comment. I did the same as you suggested and I managed to boot into the system! I added it back to my /etc/rc.conf like this :
kld_list="nvidia-modeset"
And add this back to my /boot/loader.conf :
hw.nvidiadrm.modeset=1

And now I can normally boot into the system.
I tried to do the same with nvidia-drm like jb82 suggested



But that didn't seem to work, I am honestly not sure what is the difference between the two packages. Is nvidia-modeset the free package and nvidia-drm the proprietary one? like nouveau on Linux? if so then does that mean I wouldn't get good performance on nvidia-modeset in comparison with nvidia-drm?
I would really appereciate it if someone could explain it to me. Thanks for everyone help so far! and I apologize to the moderators if I am posting to many messages in a short time since they have to approve each one.

The nvidia-modeset module provides foundational display management capabilities for the NVIDIA driver while the nvidia-drm module extends this by integrating with the Linux DRM subsystem, enabling modern graphical features and environments - if you use wayland or graphical KMS features and, if I'm not mistaken, it's loaded automatically if supported.

I would suggest to pay attention to what modules you have loaded with kldstat.
With ONLY linux64 and nvidia OR nvidia-modeset you should have a working X11 session and these modules you can test them with kldload linux64 and kldload nvidia-modeset.

You don't need to set anything in /boot/loader.conf!

Please forgive me for repeating myself.
 
Thanks for your reply.

[...] I managed to boot into the system! I added it back to my /etc/rc.conf like this :
kld_list="nvidia-modeset"
And add this back to my /boot/loader.conf :
hw.nvidiadrm.modeset=1

And now I can normally boot into the system.
Based on these settings can you post the output of:
sysctl hw.nvidiadrm.modeset
sysrc kld_list
kldstat | grep -E 'nvidia|drm'

After that, start X and post the link of Xorg.0.log as you did before.
 
Hey Erichans,

Ofcourse, here you go :

This command was not found and returned the following :

sysctl hw.nvidiadrm.modeset
Code:
sysctl: unknown oid 'hw.nvidiadrm.modeset'

sysrc kld_list
Code:
kld_list: nvidia-modeset nullfs

kldstat | grep -E 'nvidia|drm'
Code:
 2    1 0xffffffff82ff9000   126678 nvidia-modeset.ko
 3    1 0xffffffff83200000  3148420 nvidia.ko

Here is the output of Xorg.0.log : https://pastebin.com/s6x8Bx3m

Hope this helps!
 
nvidia-modeset autoloads nviidia.ko, but not nvidia-drm.ko.

nvidia-drm.ko autoloads nvidia-modeset.ko, then, nvidia-modeset autoloads nvidia.ko. nvidia-drm also autoloads some of modules installed by corresponding graphics/drm-[510|515|61]-kmod.

So loading nvidia-modeset alone causes legacy (non-DRM) nvidia proprietary driver, thus requires legacy configurations. xorg does NOT know of nvidia proprietary driver by default and attempt to load open source nv driver which FreeBSD does not have ported.

If your notebook has hardware multiplexer which handles both iGPU and nvidia dGPU, properly configuring for nvidia proprietary driver (x11/nvidia-driver) should work.
But unfortunately, most of recent notebooks does NOT have it and internal display panel is physically connected to iGPU only and proper configuration for Optimus (some doesn't work sanely, unfortunately, though) would be needed.
 
yes the nvidia-driver-550 does work with Freebsd 14.2

Code:
Yes Master ? freebsd-version -kru
14.2-RELEASE-p1
14.2-RELEASE-p1
14.2-RELEASE-p1

Code:
Yes Master ? nv-sglrun nvidia-smi
shim init
Fri Feb 14 15:26:31 2025
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.127.05             Driver Version: 550.127.05     CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce GTX 1650        Off |   00000000:01:00.0 Off |                  N/A |
| N/A   49C    P8              2W /   50W |    3640MiB /   4096MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
+-----------------------------------------------------------------------------------------+
 
Does this package is supported for 14.2-STABLE ?
It should be supported.


The version shows as nvidia-driver-550.127.05.1401000 from freshport.
Packages are still being built for 14.1, so that's expected. You can build the port yourself and then you will have the package with right OSVERSION matching with your system. It's likely that you would have issues with kernel module that's build for another version (in case you install nvidia-driver-550.127.05.[B]1401000)[/B])
 
Does this package is supported for 14.2-STABLE ? The version shows as
Code:
nvidia-driver-550.127.05.1401000
from freshport. I have already purchased the GPU and have plan to use that for my desktop.
Basically, all kmod ports is needed to be rebuilt with the kernel sources exactly matches the running (or to-be-updated) kernel.
So if you have /usr/src/sys exactly from which the kernel is built from and build x11/nvidia-driver yourself, it is OK. This applies especially with drm drivers like graphics/drm-61-kmod, nvidia-drm-61-kmod and others related.

Unfortunately, current official pkg repo is built using "oldest supported release of the branch". For 14.*, currently 14.1. This is what you are seeing currently. But fortunately, x11/nvidia-driver is relatively robust with kernel source changes. So if you're lucky enough, pkg built for 14.1 could work.

Currently, kmod repo for 14.2 is on test (not yet announced as official, but CFT is propagated). Comment #30 of thread "Possible solution to the drm-kmod kernel mismatch after upgrade from Bapt" would help with it. But x11/nvidia-driver has some difficulties.
 
Back
Top