Nvidia Optimus Driver for FreeBSD

Thanks, looks like I should include
Code:
Option "HardDPMS" "false"
in the xorg template.

  • Having Nvidia loaded prevents suspend from working (it seems to start to suspend but bounces); having nvidia not loaded prevents it from working after suspend until a dance with acpi_call and more suspend/resumes to unstick its power state.
I discovered this was my fault, caused by some leftover devd hooks running acpi_call from when I was experimenting with ondemand Nvidia power switching.


Just tested Firefox 70.0.1 real quick. No issue so far with WebGL.
The website Shadertoy.com reliably hangs Firefox tabs after a shader page reload in Firefox 70 but not in Firefox 68.
 
How can I test nvidia hybrid graphics port ?
I have a laptop with recent intel processor (i7 gen 8th) and Nvidia dicrete GPU (1060 Max Q).
I just update my laptop to 13.0-CURRENT version
Code:
#uname -a
FreeBSD msi 13.0-CURRENT FreeBSD 13.0-CURRENT #0 8d00ce82bf9-c265417(master): Mon Dec 30 21:56:43 CET 2019     hakaba@msi:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64

I presume I have to deinstall nvidia-driver in ports, update /usr/ports/, apply path in /usr/port/x11/nvidia-driver and make install.
But maybe it exists a tools to do shis step for me ?
 
The port is currently under review (see post #51 in this thread). So, it's not currently in the ports tree yet.

You should be able to test it on 12.1. The steps would be something like the following (just guessing, I haven't done this… yet)

1) Get the ports tree (for example by using portsnap), assuming that ends up in /usr/ports
2) Download the raw diff from reviews (D22521.diff)
3) apply the raw diff to your ports tree (cd /usr/ports && patch < D22521.diff)
4) assuming the patch applies cleanly: cd /usr/ports/x11/nvidia-hybrid-graphics && make

Keep in mind you are kind of "on your own" with this. But, you can probably add comments here or on the actual review.
 
I do it before test 13.0 but I did not have nvidia-hybrid-graphics port in /usr/ports/x11/ neither the nvidia-headless-utils mentionned in the diff file.
That is why I am lost.
 
I do it before test 13.0 but I did not have nvidia-hybrid-graphics port in /usr/ports/x11/ neither the nvidia-headless-utils mentionned in the diff file.
That is why I am lost.

Ah, OK. The diff creates new files (the new ports). You may need to touch those files referenced in the ports tree ahead of time and then apply the patch. You can always run patch with --dry-run to see what happens and it may give you a guide to knowing which files to touch.

Good luck!
 
I haven't been keeping up well with this, I'll check now that patches are still applicable and try to address the remaining concerns.

Firefox's problems with VirtualGL seem to have gone away, hopefully Mozilla do not reintroduce the problem but that is out of my hands.
 
Little Update for my MSI laptop :
Back in FreeBSD 12.1, I apply the patch and rebuild all from scratch.
I found a conf template in /usr/local/etc/X11/xorg.conf folder named xorg-nvidia-headless-template.conf
Without this config file, Xorg works only on the laptop screen with scfb.

With this config file, the HDMI screen receive video. The laptop screen is black with a blanc square on top left.
If I type some text in keyboard, the text appear on the laptop screen.

No error for X server, so logs do not help me.
I do not have config in /etc/X11 folder.
I change the input device config in xorg-nvidia-headless-template.conf to have a working mouse and keyboard.
 
Hi Hakaba, it sounds like your laptop is wired such that internal display uses Intel graphics, while HDMI port uses Nvidia. First be sure scfb or intel driver is working well for laptop display (your primary Xorg session should not have the nvidia driver in it). Now, if your displays are wired how I suspect, env DISPLAY=:0 xev should show a window on the laptop and env DISPLAY=:8 xev should show on the HDMI display. Is that the case?

There is not any way that I know for these two displays to share one set of input devices. A single Xorg server attached to both GPUs with PRIME would be needed for that, but PRIME is either missing or undocumented and broken on FreeBSD.
Possibly your BIOS has an option for changing the wiring of GPUs to outputs?

(These FreeBSD Optimus support drivers are only working for laptops where Intel GPU manages all displays, but if you can select Nvidia to manage all displays, then you will only need nvidia-driver package.)
 
env DISPLAY=:0 xev should show a window on the laptop and env DISPLAY=:8 xev should show on the HDMI display. Is that the case?

DISPLAY=:0 works well.
DISPLAY=:8 xev
xev: unable to open display ':8'
(With scfb on the laptop screen or nvidia in the hdmi screen)

I probably have to install Intel driver, scfb only allow 800x600 px (xrandr).

What surprise me is : if I want to use the HDMI screen without X, it is not possible ? Why the mist screen is related with X and WM and not with the system ?

With nvidia, when my HDMI screen works :
nvidia-settings
Could not open display :8

More tests tomorow...
 
Thanks. This time I can see the window on HDMI screen.
So Xev works.

env DISPLAY=:8 optirun glxgears show the gears on my HDMI screen.
Without optirun if failed.
I search a way to change the max resolution and to be sure that NVidia graphics is used (in the laptop display, I have the same perfs with glxgears and optirun glxgears).

Thanks a lot, I will be able to test this patch.
 
to be sure that NVidia graphics is used (in the laptop display, I have the same perfs with glxgears and optirun glxgears).

glxgears is not a test of overall GPU power, the limiting factor is usually the framebuffer throughput of the method used for transporting frames to the display (naturally, direct Integrated graphics typically outperforms Nvidia->Integrated proxy). FPS for an on-screen demo at or above monitor refresh rate means nearly nothing for GPU rendering power.

You can use glxinfo -B or glxgears -info to see a summary of OpenGL support including which GPU is used in that environment.
 
I have different score with glmark2 :
glmark2 487
optirun glmark2 826
env DISPLAY=:8 optirun glmark2 798

glxinfo -B show me a strange things... «OpenGL vendor string: VMWare»
optirun glxinfo -B use NVidia
 
How to start optimus service automatically?? I do have optimus_enable="YES" in rc.conf but after reboot service is not started, I have to start it manually?

Acer Aspire 5742G GeForce 420M works/
 
How to start optimus service automatically?? I do have optimus_enable="YES" in rc.conf but after reboot service is not started, I have to start it manually?

Acer Aspire 5742G GeForce 420M works/
Hi, are you using https://github.com/pouya-eghbali/freebsd-nvidia-optimus (deprecated) or https://reviews.freebsd.org/D22521 ?
For the latter, which I will try to get submitted to ports tree (I've been neglecting some little remaining issues), the service name is "nvidia_xorg".

(Currently waiting on danfe@FreeBSD.org for review)
 
Last edited:
Hello, some news here...

I install the Intel graphic driver that match my CPU and use it now as default.

With glmark2, I have a very good score with Intel graphics (2350) and still 760 with the NVidia card.
That means I have an issue with the NVidia driver too (I installed the latest version for an NVidia 1060 Max-Q) ?
 
What does glmark2 measure? If it has anything to do with framerate then it won't be useful here. Rendering directly from Intel graphics should have a higher frame throughput than with nvrun-vgl/optirun since needing to transfer frames from Nvidia to Intel over the PCIe bus can become the limiting factor. However in either case it should keep up with your monitor refresh, otherwise there is a real problem.

To reiterate: Optimus GPU performance is expected to be worse than Integrated for simple workloads, but still "fast enough" for display. For complex workloads, Nvidia should outperform the Integrated.
 
Ok, I will find an another benchmark to measure Intel/Nvidia perfs not based on framerate, but on calculation.
I notice no bug with programs lauched via optimus.
 
I have tried to install the nvidia-hybrid-graphics driver, it appears to work,
I get a desktop session and I the output of nvrun glxinfo -B indicates that I can offload to the nvidia card, however I am unable to output via HDMI to an external monitor on this laptop.
Is this functionality supported by the driver?

hostb0@pci0:0:0:0: class=0x060000 rev=0x07 hdr=0x00 vendor=0x8086 device=0x1910 subvendor=0x103c subdevice=0x8257
vendor = 'Intel Corporation'
device = 'Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Host Bridge/DRAM Registers'
class = bridge
subclass = HOST-PCI
pcib1@pci0:0:1:0: class=0x060400 rev=0x07 hdr=0x01 vendor=0x8086 device=0x1901 subvendor=0x103c subdevice=0x8257
vendor = 'Intel Corporation'
device = '6th-10th Gen Core Processor PCIe Controller (x16)'
class = bridge
subclass = PCI-PCI
vgapci1@pci0:0:2:0: class=0x030000 rev=0x06 hdr=0x00 vendor=0x8086 device=0x191b subvendor=0x103c subdevice=0x8257
vendor = 'Intel Corporation'
device = 'HD Graphics 530'
class = display
subclass = VGA
none0@pci0:0:4:0: class=0x118000 rev=0x07 hdr=0x00 vendor=0x8086 device=0x1903 subvendor=0x103c subdevice=0x8257
vendor = 'Intel Corporation'
device = 'Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Thermal Subsystem'
class = dasp
xhci0@pci0:0:20:0: class=0x0c0330 rev=0x31 hdr=0x00 vendor=0x8086 device=0xa12f subvendor=0x103c subdevice=0x8257
vendor = 'Intel Corporation'
device = '100 Series/C230 Series Chipset Family USB 3.0 xHCI Controller'
class = serial bus
subclass = USB
pchtherm0@pci0:0:20:2: class=0x118000 rev=0x31 hdr=0x00 vendor=0x8086 device=0xa131 subvendor=0x103c subdevice=0x8257
vendor = 'Intel Corporation'
device = '100 Series/C230 Series Chipset Family Thermal Subsystem'
class = dasp
none1@pci0:0:22:0: class=0x078000 rev=0x31 hdr=0x00 vendor=0x8086 device=0xa13a subvendor=0x103c subdevice=0x8257
vendor = 'Intel Corporation'
device = '100 Series/C230 Series Chipset Family MEI Controller'
class = simple comms
ahci0@pci0:0:23:0: class=0x010601 rev=0x31 hdr=0x00 vendor=0x8086 device=0xa103 subvendor=0x103c subdevice=0x8257
vendor = 'Intel Corporation'
device = 'HM170/QM170 Chipset SATA Controller [AHCI Mode]'
class = mass storage
subclass = SATA
pcib2@pci0:0:28:0: class=0x060400 rev=0xf1 hdr=0x01 vendor=0x8086 device=0xa114 subvendor=0x103c subdevice=0x8257
vendor = 'Intel Corporation'
device = '100 Series/C230 Series Chipset Family PCI Express Root Port'
class = bridge
subclass = PCI-PCI
pcib3@pci0:0:28:5: class=0x060400 rev=0xf1 hdr=0x01 vendor=0x8086 device=0xa115 subvendor=0x103c subdevice=0x8257
vendor = 'Intel Corporation'
device = '100 Series/C230 Series Chipset Family PCI Express Root Port'
class = bridge
subclass = PCI-PCI
pcib4@pci0:0:28:6: class=0x060400 rev=0xf1 hdr=0x01 vendor=0x8086 device=0xa116 subvendor=0x103c subdevice=0x8257
vendor = 'Intel Corporation'
device = '100 Series/C230 Series Chipset Family PCI Express Root Port'
class = bridge
subclass = PCI-PCI
isab0@pci0:0:31:0: class=0x060100 rev=0x31 hdr=0x00 vendor=0x8086 device=0xa14e subvendor=0x103c subdevice=0x8257
vendor = 'Intel Corporation'
device = 'HM170 Chipset LPC/eSPI Controller'
class = bridge
subclass = PCI-ISA
none2@pci0:0:31:2: class=0x058000 rev=0x31 hdr=0x00 vendor=0x8086 device=0xa121 subvendor=0x103c subdevice=0x8257
vendor = 'Intel Corporation'
device = '100 Series/C230 Series Chipset Family Power Management Controller'
class = memory
hdac0@pci0:0:31:3: class=0x040300 rev=0x31 hdr=0x00 vendor=0x8086 device=0xa170 subvendor=0x103c subdevice=0x8257
vendor = 'Intel Corporation'
device = '100 Series/C230 Series Chipset Family HD Audio Controller'
class = multimedia
subclass = HDA
ichsmb0@pci0:0:31:4: class=0x0c0500 rev=0x31 hdr=0x00 vendor=0x8086 device=0xa123 subvendor=0x103c subdevice=0x8257
vendor = 'Intel Corporation'
device = '100 Series/C230 Series Chipset Family SMBus'
class = serial bus
subclass = SMBus
vgapci0@pci0:1:0:0: class=0x030200 rev=0xa1 hdr=0x00 vendor=0x10de device=0x1427 subvendor=0x103c subdevice=0x8257
vendor = 'NVIDIA Corporation'
device = 'GM206M [GeForce GTX 965M]'
class = display
subclass = 3D
rtsx0@pci0:7:0:0: class=0xff0000 rev=0x01 hdr=0x00 vendor=0x10ec device=0x522a subvendor=0x103c subdevice=0x8257
vendor = 'Realtek Semiconductor Co., Ltd.'
device = 'RTS522A PCI Express Card Reader'
iwm0@pci0:8:0:0: class=0x028000 rev=0x61 hdr=0x00 vendor=0x8086 device=0x095a subvendor=0x8086 subdevice=0x5010
vendor = 'Intel Corporation'
device = 'Wireless 7265'
class = network
re0@pci0:9:0:0: class=0x020000 rev=0x15 hdr=0x00 vendor=0x10ec device=0x8168 subvendor=0x103c subdevice=0x8257
vendor = 'Realtek Semiconductor Co., Ltd.'
device = 'RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller'
class = network
subclass = ethernet
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
eDP-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
1920x1080 60.02*+ 59.93 40.03
1680x1050 59.95 59.88
1400x1050 59.98
1600x900 59.95 59.82
1280x1024 60.02
1400x900 59.96 59.88
1280x960 60.00
1368x768 59.88 59.85
1280x800 59.97 59.81 59.91
1280x720 59.99 59.86 59.74
1024x768 60.04 60.00
960x720 60.00
928x696 60.05
896x672 60.01
1024x576 59.95 59.96 59.90 59.82
960x600 59.93 60.00
960x540 59.96 59.99 59.63 59.82
800x600 60.00 60.32 56.25
840x525 60.01 59.88
864x486 59.92 59.57
700x525 59.98
800x450 59.95 59.82
640x512 60.02
700x450 59.96 59.88
640x480 60.00 59.94
720x405 59.51 58.99
684x384 59.88 59.85
640x400 59.88 59.98
640x360 59.86 59.83 59.84 59.32
512x384 60.00
512x288 60.00 59.92
480x270 59.63 59.82
400x300 60.32 56.34
432x243 59.92 59.57
320x240 60.05
360x202 59.51 59.13
320x180 59.84 59.32
HDMI-1 disconnected (normal left inverted right x axis y axis)
kld_list="i915kms"
clear_tmp_enable="YES"
sendmail_enable="NONE"
hostname="Polaris"
keymap="uk.kbd"
wlans_iwm0="wlan0"
ifconfig_wlan0="WPA DHCP"
ifconfig_wlan0_ipv6="inet6 accept_rtadv"
create_args_wlan0="country GB"
sshd_enable="YES"
powerd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
nvidia_xorg_enable="YES"
dbus_enable="YES"
sddm_enable="YES"
 
Is this functionality supported by the driver?
Some of this is going to depend on the hardware.
Some will wire the HDMI to Optimus and some to base Intel Graphics.
Looks like your main display is eDP and HDMI1 is not connected.
If it is wired to the NVidia chip then you might be able to use the NVidia control panel.
x11/nvidia-settings
If not you might need to make a custom conf for it. Same with Intel Graphics.
 
Back
Top