Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How does Optimus really work?
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
Helena
Veteran
Veteran


Joined: 02 Apr 2003
Posts: 1114
Location: Den Dolder, The Netherlands

PostPosted: Thu Jan 12, 2023 11:12 am    Post subject: How does Optimus really work? Reply with quote

After a lot of experimentation and with a little help from my friends I finally managed to get X working on my Optimus-enabled laptop. The final step I needed was https://wiki.gentoo.org/wiki/NVIDIA/Optimus.

However, Gentoo is about understanding a lot of what's going on, and in this case I seem to be missing something with respect to what and how the screen is drawn. I'll explain.

When booting, the screen is driven by the BIOS. I use Grub to boot and only when the kernel is loaded into memory the next phase starts; the EFI frame buffer is now in control. I boot to a command prompt, so after logging in this goes on until I fire up X. Correct so far?

X reads the configuration file that I generated using
Code:
nvidia-xconfig --prime
and now the nvidia divers are responsible for painting the screen. However, as has been pointed out in various places, it must use the built-in Intel graphics card to be able to do that. And that's where I get lost.

My make.conf contains:
Code:
VIDEO_CARDS="intel nvidia"
and my kernel configuration has
Code:
# CONFIG_DRM_RADEON is not set
# CONFIG_DRM_AMDGPU is not set
# CONFIG_DRM_NOUVEAU is not set
CONFIG_DRM_I915=m
CONFIG_DRM_I915_FORCE_PROBE="4621"
CONFIG_DRM_I915_CAPTURE_ERROR=y
CONFIG_DRM_I915_COMPRESS_ERROR=y
CONFIG_DRM_I915_USERPTR=y
CONFIG_DRM_I915_REQUEST_TIMEOUT=20000
CONFIG_DRM_I915_FENCE_TIMEOUT=10000
CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND=250
CONFIG_DRM_I915_HEARTBEAT_INTERVAL=2500
CONFIG_DRM_I915_PREEMPT_TIMEOUT=640
CONFIG_DRM_I915_MAX_REQUEST_BUSYWAIT=8000
CONFIG_DRM_I915_STOP_TIMEOUT=100
CONFIG_DRM_I915_TIMESLICE_DURATION=1
# CONFIG_DRM_VGEM is not set
# CONFIG_DRM_VKMS is not set
# CONFIG_DRM_VMWGFX is not set
# CONFIG_DRM_GMA500 is not set
# CONFIG_DRM_UDL is not set
# CONFIG_DRM_AST is not set
# CONFIG_DRM_MGAG200 is not set
# CONFIG_DRM_QXL is not set
CONFIG_DRM_PANEL=y

In spite of what I would expect, xorg-drivers does not load an intel driver:
Code:
NitroGentoo ~ # emerge -av xorg-drivers
setlocale: unsupported locale setting
setlocale: unsupported locale setting

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] x11-base/xorg-drivers-21.1-r2::gentoo  INPUT_DEVICES="elographics libinput synaptics -evdev -joystick -vmmouse -void -wacom" VIDEO_CARDS="intel nvidia -amdgpu -ast -dummy -fbdev (-freedreno) (-geode) -i915 -mga -nouveau (-omap) -qxl -r128 -radeon -radeonsi -siliconmotion (-tegra) (-vc4) -vesa -via -virtualbox -vmware" 0 KiB

Total: 1 package (1 reinstall), Size of downloads: 0 KiB
and the i915 driver of course was already loaded as a kernel module. And it's required too, I believe. So the confusing point to me is that all documentation suggests I should use an intel driver but in fact I need an i915 driver. Hopefully somebody can explain this. PS I will be happy to share any further information required.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Thu Jan 12, 2023 7:28 pm    Post subject: Reply with quote

Helena,

Optimus can be though of as one and a half graphics systems.
The Intel part is complete. It can work alone.
The nVidia part has no connections to the display surface, so it can draw images but not move the images to the display. Attempting to use the nVidia GPU alone results in a blank screen.
That's a design feature, not a bug.

The images in the pixel buffer can be drawn by either GPU but you need to use Intel alone or both GPUs together to get an image.

When the nVidia GPU is doing the rendering, the Intel GPU must be controlled by the modesetting driver. Its only role is to read the images in the pixel buffer to the display surface.
x11-drivers/xf86-video-intel is not used.

This saves an expensive power hungry video multiplexer chip in your laptop. That's good for for space, battery life, thermal performance and your pocket but it does add some complexity.

Code:
VIDEO_CARDS="intel nvidia -amdgpu -ast -dummy -fbdev (-freedreno) (-geode) -i915 -mga -nouveau (-omap) -qxl -r128 -radeon -radeonsi -siliconmotion (-tegra) (-vc4) -vesa -via -virtualbox -vmware"
lists the Xorg Video drivers. They are separate from the kernel. You have intel listed, but look in Xorg.0.log ...
The i915 there is an Xorg video driwer by the same name as the kernel driver but its not the same thing.

The kernel i915 is required. It provides the kernel Direct Render Manager (DRM) for Intel chips. The Xorg drivers, including modesetting, use the DRM interface provided by the kernel.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Ran.Rutenberg
n00b
n00b


Joined: 23 Mar 2007
Posts: 27

PostPosted: Thu Jan 12, 2023 7:37 pm    Post subject: Reply with quote

The new (modesetting) intel driver is part of the kernel. The kernel module is called i915 but x calls it intel.
The intel driver in x11-drivers/xf86-video-intel is an old driver that is not needed in newer systems.

At least in my laptop, it won't work without the intel kernel module (i915), but the nvidia modules are optional.
Back to top
View user's profile Send private message
Helena
Veteran
Veteran


Joined: 02 Apr 2003
Posts: 1114
Location: Den Dolder, The Netherlands

PostPosted: Sat Jan 14, 2023 9:41 am    Post subject: Reply with quote

Ran,

Thx for replying.

Neddy,

Your comments are useful and add to my understanding. Still, the use of i915 vs. intel is very confusing for me.

Anyway, I've got the system running on the closed-source nvidia drivers. I chose this as using nouveau is being reported as suboptimal. However, the whole idea of hybrid graphics is being able to switch between the iGPU only and the dGPU (which then also requires the iGPU). Right now I do not know how to switch back and forth between the 2. Does it require a separate xorg.conf file? The one I use now is generated by the nvidia driver, as mentioned before:
Code:
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 525.60.13

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

Section "Files"
EndSection

Section "InputDevice"
    # generated from data in "/etc/conf.d/gpm"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol"
    Option         "Device" "/dev/input/mice"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
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"
EndSection

Section "Device"
    Identifier     "InactiveDevice1"
    Driver         "modesetting"
    VendorName     "Unknown"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "AllowEmptyInitialConfiguration" "True"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Sat Jan 14, 2023 12:13 pm    Post subject: Reply with quote

Helena,

The hardware bit is easy for me, I'm a retired electronics engineer.

The software bit is a much harder. From the Optimus Wiki page, XRandR is used to choose the nVidia GPU for rendering at Xorg start time, so a restart of Xorg is required to switch GPUs

This bit of the auto generated xorg.conf always makes me smile
Code:
Section "InputDevice"
    # generated from data in "/etc/conf.d/gpm"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol"
    Option         "Device" "/dev/input/mice"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

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

The mouse and kbd drivers were removed years ago. It's harmless though. If you look in your Xorg.0.log, it will tell you that they are being ignored.

On the i915 topic.
x11-base/xorg-drivers shows
Code:
VIDEO_CARDS="amdgpu fbdev radeonsi vesa -ast -dummy -freedreno -geode -i915 -intel -mga -nouveau -nvidia -omap -qxl -r128 -radeon -siliconmotion -tegra -vc4 -via -virtualbox -vmware")
so there are two possible drivers for Intel GPUs, i915 or intel. They are both for Xorg and are selected by the VIDEO_CARDS setting.

They cannot work alone. They both require kernel support which is provided by the CONFIG_DRM_I915 kernel configuration option.
That kernel option gets you a framebuffer console and provides /dev/dri/cardX for the Intel GPU which the Xorg drivers will use.

Its really a case of the one driver being in several parts, rather than separate drivers. You need all the parts.
Its a bit unfortunate that i915 can mean two different things. Blame history.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
mrbassie
l33t
l33t


Joined: 31 May 2013
Posts: 772
Location: over here

PostPosted: Sun Jan 15, 2023 8:24 pm    Post subject: Reply with quote

Helena wrote:
Right now I do not know how to switch back and forth between the 2. Does it require a separate xorg.conf file?


No. mine is like this:

Code:
 
Section "Device"
    Identifier "intel"
    Driver "modesetting"
    Option "AccelMethod"        "glamor"
    Option "DRI"                       "3"
    Option "Composite"            "Enable"
    Option "PageFlip"               "false"
EndSection

Section "Module"
    Load "modesetting"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:01:00.0"
    Option "AllowEmptyInitialConfiguration"
EndSection


^This is for integrated intel gfx and an nvidia "3d controller", I believe optimus can also be a full gpu.


For running on nvidia look at prime-run. e.g $ prime-run glxgears.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum