Hybrid Graphics: iGPU+dGPU on laptop - configuring drivers for smooth display

Hi,

I have an old laptop, where I have installed FreeBSD 14.3 with xfce4:

Lenovo Ideapad 305-15IBD 80NJ
Intel i5-5200U (4) @ 2.195GHz
GPU: INTEL HD Graphics 5500
Memory: 6 GB

Code:
vgapci0@pci0:0:2:0:    class=0x030000 rev=0x09 hdr=0x00 vendor=0x8086 device=0x1616 subvendor=0x17aa subdevice=0x3902
    vendor     = 'Intel Corporation'
    device     = 'HD Graphics 5500'
    class      = display
    subclass   = VGA


It also has a dedicated GPU:
Code:
vgapci1@pci0:10:0:0:    class=0x038000 rev=0x83 hdr=0x00 vendor=0x1002 device=0x6660 subvendor=0x17aa subdevice=0x381b
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    device     = 'Sun XT [Radeon HD 8670A/8670M/8690M / R5 M330 / M430 / Radeon 520 Mobile]'
    class      = display


When I try to watch videos, I realized that the CPU is running at 100% and in general it is very laggy when I try to resize windows etc. For example when I go from split screen to maximize screen, the window maximizes but the content takes 2-3 seconds to fit the new size!


I tried to load radeonkms or amdgpu on system startup, but apparently it won't even enter to the graphical space.


Any idea what should I check next? I tried to follow prime configuration article, without any success.

Thank you very much for any help
 
I tried to load radeonkms or amdgpu on system startup, but apparently it won't even enter to the graphical space.
You must install the firmware first.

Try and install pkg install gpu-firmware-kmod.
That will install all gpu firmware. Then try running kldload for amd graphics and or radeon.

There is also a BIOS component on some laptops to tell it what graphics card to use.

There may also be a need to use a config file as per the handbook. 20-video.conf or similar.
Sometimes video is picked up and sometimes you get "No Screens Found". That means you need a config file..
 
I hate the whole kitchen sink approach and might even delete the gpu firmware meta-package and install only needed flavor once I determine what it needs.
There is no wrong way.
 
I hate the whole kitchen sink approach and might even delete the gpu firmware meta-package and install only needed flavor once I determine what it needs.
There is no wrong way.
I do the same too, don't like having unneeded things installed. But if in case the OP didn't install the graphics/drm-kmod yet, this is the way imo. Also be sure you have the one that is for your kernel version, 14.3-R has kmods repository installed.

Rich (BB code):
% pkg info -x gpu
gpu-firmware-amd-kmod-renoir-20230625.1403000_2
xf86-video-amdgpu-22.0.0_2
 
Are you sure you need that? That is not the correct driver for modern video. That is UMS not KMS driver. It can actually interfere with the KMS driver on Intel.
I dunno about AMD GPU.
I don't wanna go off-topic here but I think I saw some improments on Xorg usage after installing that port.

 
Why not just install graphics/drm-kmod? It would install all the gpu firmwares too. That gpu firmware port doesn't seem to depend on metaport drm-kmod.
I have done that. Tried also what Phishfry said, and I get

Code:
pkg install gpu-firmware-kmod
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating FreeBSD-kmods repository catalogue...
FreeBSD-kmods repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The most recent versions of packages are already installed
 
I have an old laptop, where I have installed FreeBSD 14.3 with xfce4:

Lenovo Ideapad 305-15IBD 80NJ
Intel i5-5200U (4) @ 2.195GHz
GPU: INTEL HD Graphics 5500
Memory: 6 GB

When I try to watch videos, I realized that the CPU is running at 100% and in general it is very laggy when I try to resize windows etc. For example when I go from split screen to maximize screen, the window maximizes but the content takes 2-3 seconds to fit the new size!


I tried to load radeonkms or amdgpu on system startup, but apparently it won't even enter to the graphical space.


Any idea what should I check next? I tried to follow prime configuration article, without any success.

Thank you very much for any help

I wished the Handbook had better guidance on configuring/troubleshooting iGPU+dGPU systems, because many high-end laptops have a combo like this (usually Intel i915 + NVidia or Intel i915 + AMD).

I recently installed 14.3-RELEASE on such a laptop (Dell Inspiron 7706 2n1, circa 2020), and to my surprise, it "mostly" just worked after I installed graphics/drm-kmod and x11/nvidia-driver from ports (to make certain of a match between the kernel version and the built-modules).

I initially thought acceleration wasn't working, because I didn't understand exactly what to expect, so I assumed I had to hardwire the xorg.conf for Driver "nvidia", but with Optimus Prime laptops like mine, it appears to use the integrated graphics as "primary", and does acceleration on the backend transparently. I didn't find any documentation about how to configure or verify that iGPU+dGPU was working the way the FreeBSD team intended, and trying to hard-configure Driver "nvidia" resulted in a black screen.

But after getting drm-kmod installed, I just let X start normally, and found OpenGL-accelerated apps were actually getting accelerated without having to configure xorg.conf specifically for NVidia.

I know iGPU+dGPU adds "complication", because different makes/models multiplex the display in different ways between the iGPU and the dGPU.

If you're not sure which kernel modules actually got loaded that support your GPU(s), you can run:

kldstat

then look for amdgpu, radeon, i915kms, and/or nvidia in the list. I don't have any systems with AMD, so I can't tell you exactly which modules will be loaded for AMD, but on my Intel+NVidia laptop, the relevant modules I see loaded include: i915kms, drm, nvidia-modeset, and nvidia.

If you're not certain if acceleration is available, you can run:

glxinfo

(if there is no OpenGL acceleration, I believe it will give a short error message, but if acceleration is available, you'll usually see hundreds of lines of OpenGL info)

I also encountered a very odd problem on my Dell Inspiron 7706 (11th gen i7-1165G7 2.8GHz 4-core w/NVidia dGPU) -- I ran mpv to view a video which appeared to work well for a while (ie seemed like good performance), but when I fullscreened -OR- when I hit "q" to exit while playing a 4K video, it went into CPU-burn mode for several seconds (top showed "uwait") for the state, and mpv's UI was "unresponsive" during that time.

This problem turned-out to be that mpv uses the OpenMP library (a multiprocessing library apparently provided with clang) where the modern-default is where one CPU can do tight-polling of threads to look for other-thread completions, and as a result, I saw almost exactly 100% cpu burn according to top (with STATE of "uwait"). It took me a lot of effort researching and experimenting to figure-out that I could just set the environment variable KMP_LIBRARY=serial before starting mpv, then the OpenMP library saw that env variable and apparently stopped spin-polling, which greatly-reduced the amount of CPU-time mpv needed for full-screening and/or when I hit "q" to exit, mpv has behaved great since I preset KMP_LIBRARY as part of starting mpv. For me, setting KMP_LIBRARY=serial did not negatively mpv's performance in any other way that I could notice.

The KMP_LIBRARY environment variable may not fix your problem, but it's easy/quick to try, so shot in the dark here..

I recommend not setting the KMP_LIBRARY environment variable to "serial" as your global-default for all programs in your home-login environment, because there may be other applications that behave unfavorably with that particular setting (apparently a bunch of packages use OpenMP).

If you are still experiencing problems after reading and/or trying the various comments in this thread, please let us know your kldstat output and which video player you are running, that additional info might help us zero-in better on your particular problem.

Hope this helps,
 
I am attaching the glxinfo and kldstat output.

Regarding the video player, I tried VLC for video samples I found online. And on Firefox and Chromium trying to watch YouTube.

My rc.conf:


❯ cat /etc/rc.conf
hostname="lenobro"
wlans_ath0="wlan0"
ifconfig_wlan0="WPA DHCP"
sshd_enable="YES"
moused_enable="YES"
ntpd_enable="YES"
powerd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
kld_list="i915kms radeonkms"
dbus_enable="YES"
lightdm_enable="YES"
ntpd_sync_on_start="YES"
ifconfig_re0="DHCP"
linux_enable="YES"


The thing is that the system is very responsive when I do other stuff. It is only lagging when videos are playing.
So I suspect that it has to be something with the GPU.
 

Attachments

I am attaching the glxinfo and kldstat output.

Regarding the video player, I tried VLC for video samples I found online. And on Firefox and Chromium trying to watch YouTube.

My rc.conf:


❯ cat /etc/rc.conf
hostname="lenobro"
wlans_ath0="wlan0"
ifconfig_wlan0="WPA DHCP"
sshd_enable="YES"
moused_enable="YES"
ntpd_enable="YES"
powerd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
kld_list="i915kms radeonkms"
dbus_enable="YES"
lightdm_enable="YES"
ntpd_sync_on_start="YES"
ifconfig_re0="DHCP"
linux_enable="YES"


The thing is that the system is very responsive when I do other stuff. It is only lagging when videos are playing.
So I suspect that it has to be something with the GPU.
I'd recommend trying amdgpu module instead of radeonkms module, this GPU may not be that old and maybe works with amdgpu properly. I still don't think that your integral GPU is not powerful enough to be able to play a video properly, it should be. Did you checked the BIOS to see if you can use only one of your GPU(s)?
 
I'd recommend trying amdgpu module instead of radeonkms module, this GPU may not be that old and maybe works with amdgpu properly. I still don't think that your integral GPU is not powerful enough to be able to play a video properly, it should be. Did you checked the BIOS to see if you can use only one of your GPU(s)?
Yes, I can use only the integrated one in BIOS.

I’ll try to see if that helps, and I agree with you that only the intel one should be fine to run tasks like this. Because on another old laptop (14 yo) that runs xubuntu, I have no problems and everything runs smoothly despite its old technology.
 
I am attaching the glxinfo and kldstat output.

Regarding the video player, I tried VLC for video samples I found online. And on Firefox and Chromium trying to watch YouTube.

The thing is that the system is very responsive when I do other stuff. It is only lagging when videos are playing.
So I suspect that it has to be something with the GPU.

OK, the "OpenGL Renderer String" in your glxinfo.txt file shows that it's using your Intel iGPU for OpenGL acceleration. FWIW, this is similar to my Intel+NVidia laptop, but I don't know if this is what it's "supposed" to be in a hybrid iGPU+dGPU system (back to my earlier comment that I wished the Handbook better-documented how to configure/test iGPU+dGPU setups). I do know that one of my systems where I have only 1 NVidia card (ie no integrated graphics), the 'OpenGL Renderer String" shows "NVidia GeForce RTX [model#]". So I infer that your xorg server is not currently configured to use your dGPU for OpenGL acceleration, but I'm not sure if that's critical here.

Based on your kldstat.txt file, it looks like radeonkms got loaded, plus several related firmware files, so I'd guess drm-kmod correctly identified your dGPU and loaded the associated firmware, I think that's a "good sign", but I'm not an AMD expert, so that's not conclusive. :)

It looks like VLC does not use the KMP_LIBRARY environment variable at all, so I do not think OpenMP spinning has anything to do with your responsiveness problem.

When I play 4K@60Hz videos on my Intel 11th gen 4-core, with acceleration, I am seeing CPU loads of 70-90%.

If you start top -s 1 in another window before running vlc, can you peek at top to let us know how much system idle CPU you have left while your video(s) are playing?

Is the responsiveness of your system OK if you play lower-res vids (e.g.: 640 or 720 x 480)??

Hmmm, have you looked closely at your /var/log/Xorg.log.0 for any clues?
 
Back
Top