Solved OpenGL renderer string: llvmpipe

So I installed FreeBSD (14.0-RELEASE-p1 FreeBSD 14.0-RELEASE-p1 #1 releng/14.0-n265385-305be1f36b3e) on a used laptop I managed to acquire recently (https://www.msi.com/Laptop/Katana-GF76-11UX/Specification);
I was surprised, actually, how smoothly everything went during the installation; The wifi adapter worked out of the box, and everything was looking good;
Eventually I compiled and installed xorg from the ports and launched cinnamon (as the DE); It worked, but I felt a laptop with a supposed RTX 3070 shouldn't lag this much (it works, but it's slow) on a small screen with a 1920x1080 resolution XD, so I checked if it detected the nvidia card as the main gpu:

$ glxinfo | grep "OpenGL renderer"
OpenGL renderer string: llvmpipe (LLVM 15.0.7, 256 bits)

$ sysctl -a | grep -E -i 'hw.machine|hw.model|hw.ncpu'
hw.machine: amd64
hw.model: 12th Gen Intel(R) Core(TM) i7-12700H
hw.ncpu: 20
hw.machine_arch: amd64

$ pciconf -lv | grep -B4 display
subclass = PCI-PCI
vgapci1@pci0:0:2:0: class=0x030000 rev=0x0c hdr=0x00 vendor=0x8086 device=0x46a6 subvendor=0x1462 subdevice=0x1334
vendor = 'Intel Corporation'
device = 'Alder Lake-P Integrated Graphics Controller'
class = display
--
class = serial bus
vgapci0@pci0:1:0:0: class=0x030000 rev=0xa1 hdr=0x00 vendor=0x10de device=0x249d subvendor=0x1462 subdevice=0x1334
vendor = 'NVIDIA Corporation'
device = 'GA104M [GeForce RTX 3070 Mobile / Max-Q]'
class = display

I checked if the necessary drivers were loaded:
$ kldstat
Id Refs Address Size Name
1 90 0xffffffff80200000 1d34598 kernel
2 1 0xffffffff81f36000 7718 cryptodev.ko
3 1 0xffffffff81f3e000 5d5770 zfs.ko
4 1 0xffffffff82514000 1c3a8 geom_eli.ko
5 1 0xffffffff835f9000 11e630 nvidia-modeset.ko
6 1 0xffffffff83800000 33a5358 nvidia.ko
7 2 0xffffffff83718000 31a10 linux.ko
8 3 0xffffffff8374a000 be70 linux_common.ko
9 1 0xffffffff83756000 3390 acpi_wmi.ko
10 1 0xffffffff8375a000 3250 ichsmb.ko
11 1 0xffffffff8375e000 2178 smbus.ko
12 1 0xffffffff83761000 93260 if_iwlwifi.ko
13 1 0xffffffff837f5000 5f00 ig4.ko
14 1 0xffffffff837fb000 4d20 ng_ubt.ko
15 3 0xffffffff86ba6000 abb8 netgraph.ko
16 2 0xffffffff86bb1000 a250 ng_hci.ko
17 2 0xffffffff86bbc000 2670 ng_bluetooth.ko
18 1 0xffffffff86bbf000 3218 iichid.ko
19 5 0xffffffff86bc3000 3380 hidbus.ko
20 1 0xffffffff86bc7000 21e8 hms.ko
21 1 0xffffffff86bca000 30a8 hidmap.ko
22 1 0xffffffff86bce000 3355 hmt.ko
23 1 0xffffffff86bd2000 22cc hconf.ko
24 1 0xffffffff86bd5000 2a68 mac_ntpd.ko
It looks like the i915kms driver is missing, so I tried:
sudo kldload i915kms

And the PC freezes! How could this be?
I was snooping around the mailing lists and I found a thread mentioning something similar (I can't find the thread anymore) and that the solution was to use this commit:
commit 68f08e26e2797707c76f8c6423baa41b25dd9df4
Author: Vladimir Kondratyev <wulf@FreeBSD.org>
Date: Sat Dec 24 12:01:20 2022 +0300

LinuxKPI: linux/seqlock.h: Fix write_seqcount_(begin|end)

in seqcount_mutex_t case with removal of extraneous mutex lock/unlock
calls and addition of missing critical section.
While here strip one inline wrap layer to reduce code size.

Fixes startup lockup of i915kms after update to drm-kmod v5.12

Reviewed by: hselasky, bz
MFC after: 1week
Differential Revision: https://reviews.freebsd.org/D37699

But it looks like this commit was already incorporated into the release 14 branch:
git branch -a --contains 68f08e26e2797707c76f8c6423baa41b25dd9df4
main
* releng/14.0
remotes/origin/HEAD -> origin/main
remotes/origin/main
remotes/origin/releng/14.0
remotes/origin/stable/14

Right, I should also probably mention what I suspect could be the problem;
If I recall correctly, the nvidia card is not directly connected to the display; I think the technique was called offload rendering, or something fancy like that;
Anyway, my suspicion is that maybe if I manage to load the i915kms driver successfully, the nvidia card will be able to be utilized / recognized as the primary gpu;

I stumbled upon this: https://forums.freebsd.org/threads/...e-intel-kmod-alderlake-the-system-halt.90792/
and I tried installing the drm-510-kmod package, it seemed to work, I rebooted, and even though I had added the i915kms module to kld_list in my /etc/rc.conf, using kldstat I could not see the module loaded; I tried loading the module manually, and this time the prompt returned and the system didn't freeze and the module appears to be loaded, unfortunately glxinfo still reports llvmpipe; Perhaps I should create a xorg.conf file with some specific settings? I remember, I had to do that when I was testing this laptop on arch linux; It was working there, but then I remembered that arch uses systemd...


Hmmm, anyway I found this: https://forums.freebsd.org/threads/prime-render-offload-on-nvidia.82561/
And:
$ __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep -i renderer
OpenGL renderer string: NVIDIA GeForce RTX 3070 Laptop GPU/PCIe/SSE2
It looks like it works, but is there a way to make everything use this, including the desktop environment (right now cinnamon is still kind of laggy)?
 
I forgot to post this! Anyway, there were a few problems, but I found a workaround XD
(1) The installer image was corrupted; (I always check this, usually, but this time I didn't)
(2) Once I recreated the installation image (this time the checksum was ok), the drivers loaded correctly, however after launching xorg I would see the cursor block in the top left corner and nothing would happen; I could still change ttys with the Alt+FX keys but no gui;
(3) I started thinking that maybe this whole 'render offload is not a bug, it's a feature' fiasco only applied to the main / default / attached by forces of nature monitor, because why would a sane person do that to the external hdmi port? And it worked! After connecting an external monitor and setting up my /usr/local/etc/X11/xorg.conf.d/20-nvidia.conf file like so:

Code:
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 525.116.04

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/sysmouse"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "keyboard"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:1:0:0"
    Option "AllowEmptyInitialConfiguration" "true"
    Option "PrimaryGPU" "true"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

the gui works!!!
 
Back
Top