# nvidia module loads, xorg still won't work [SOLVED]

## audiodef

Trying to get my Optimus Nvidia card working. Made progress when I disabled in-kernel module signature verification (maybe I should use --no-strip with genkernel instead). So dmesg | grep nvidia gives:

```

[    9.412414] nvidia: loading out-of-tree module taints kernel.

[    9.412421] nvidia: module license 'NVIDIA' taints kernel.

[    9.466525] nvidia-nvlink: Nvlink Core is being initialized, major device number 239

[    9.467285] nvidia 0000:01:00.0: enabling device (0106 -> 0107)

[    9.489285] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  390.42  Sat Mar  3 03:30:48 PST 2018

[    9.502302] [drm] [nvidia-drm] [GPU ID 0x00000100] Loading driver

[    9.502304] [drm] Initialized nvidia-drm 0.0.0 20160202 for 0000:01:00.0 on minor 1

```

And yet, Xorg.0.log says:

```

[  1635.573] (EE) NVIDIA(GPU-0): Failed to initialize the NVIDIA GPU at PCI:1:0:0.  Please

[  1635.573] (EE) NVIDIA(GPU-0):     check your system's kernel log for additional error

[  1635.573] (EE) NVIDIA(GPU-0):     messages and refer to Chapter 8: Common Problems in the

[  1635.573] (EE) NVIDIA(GPU-0):     README for additional information.

[  1635.573] (EE) NVIDIA(GPU-0): Failed to initialize the NVIDIA graphics device!

[  1635.573] (EE) NVIDIA(0): Failing initialization of X screen 0

[  1635.573] (II) UnloadModule: "nvidia"

```

lspci:

```

00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers (rev 05)

00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16) (rev 05)

00:02.0 VGA compatible controller: Intel Corporation Device 591b (rev 04)

00:14.0 USB controller: Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller (rev 31)

00:14.2 Signal processing controller: Intel Corporation Sunrise Point-H Thermal subsystem (rev 31)

00:16.0 Communication controller: Intel Corporation Sunrise Point-H CSME HECI #1 (rev 31)

00:17.0 SATA controller: Intel Corporation Sunrise Point-H SATA Controller [AHCI mode] (rev 31)

00:1c.0 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #2 (rev f1)

00:1c.2 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #3 (rev f1)

00:1c.3 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #4 (rev f1)

00:1d.0 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #9 (rev f1)

00:1f.0 ISA bridge: Intel Corporation Sunrise Point-H LPC Controller (rev 31)

00:1f.2 Memory controller: Intel Corporation Sunrise Point-H PMC (rev 31)

00:1f.3 Audio device: Intel Corporation CM238 HD Audio Controller (rev 31)

00:1f.4 SMBus: Intel Corporation Sunrise Point-H SMBus (rev 31)

01:00.0 3D controller: NVIDIA Corporation GP107M [GeForce GTX 1050 Ti Mobile] (rev a1)

02:00.0 SD Host controller: O2 Micro, Inc. SD/MMC Card Reader Controller (rev 01)

03:00.0 Network controller: Intel Corporation Wireless 8265 / 8275 (rev 78)

04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 10)

05:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd NVMe SSD Controller SM961/PM961

```

xorg.conf:

```

Section "ServerLayout"

    Identifier     "Layout0"

    Screen      1  "nvidia" 0 0

    Inactive       "intel"

EndSection

#Section "Files"

#EndSection

Section "Monitor"

    Identifier     "Monitor0"

    Option         "DPMS"

    Option         "DPI" "96 x 96"

EndSection

Section "Device"

    Identifier     "nvidia"

    Driver         "nvidia"

    BusID          "PCI:1:0:0"

EndSection

Section "Device"

    Identifier     "intel"

    Driver         "modesetting"

    BusID          "PCI:0:2:0"

EndSection

Section "Screen"

    Identifier     "nvidia"

    Device         "nvidia"

    Monitor        "Monitor0"

    DefaultDepth    24

    Option         "UseDisplayDevice" "none"

    SubSection     "Display"

        Depth       24

#        Modes      "nvidia-auto-select"

        Virtual     1920 1080

    EndSubSection

EndSection

Section "Screen"

    Identifier     "intel"

    Device         "intel"

    Monitor        "Monitor0"

EndSection

```

----------

## krinn

anything useful in /proc/driver/nvidia/warnings  or dmesg?

----------

## audiodef

Edited post, forgot to include xorg.conf.

The first code block is dmesg | grep nvidia, edited OP to clarify.

There's a README in /proc/driver/nvidia/warnings, but it's just a description of what goes in that dir. There's nothing else there.

Autoconfigured xorg loads the nvidia driver and sets the Intel card as the default device, but there's no 3D accel and glxgears won't run. 

So I think I'm close and I'm just missing one last thing. Just don't know what...

----------

## krinn

something like eselect opengl set nvidia ?  :Smile: 

----------

## audiodef

Yep, that's been done. 

Also:

/etc/default/grub:

```

GRUB_CMDLINE_LINUX_DEFAULT="drm_kms_helper.edid_firmware=edid/g1310max.bin i915.modeset=1 rcutree.rcu_idle_gp_delay=1"

```

Both .xinitrc and /etc/lightdm/lightdm.conf are configured to use:

```

xrandr --setprovideroutputsource modesetting NVIDIA-0

xrandr --auto

```

EDIT: Commented out GRUB_CMDLINE_LINUX_DEFAULT, as it was stuff added from earlier attempts, but this made no difference.

----------

## krinn

well, the driver report an error, so we should have the error details report in dmesg, are you sure you didn't filter it out bad, NVRM error will be report as NVRM not nvidia).

----------

## audiodef

Aha...

dmesg | grep NVRM:

```

[    9.218116] NVRM: loading NVIDIA UNIX x86_64 Kernel Module  390.42  Sat Mar  3 04:10:22 PST 2018 (using threaded interrupts)

[   15.309608] NVRM: failed to copy vbios to system memory.

[   15.312162] NVRM: RmInitAdapter failed! (0x30:0xffff:664)

[   15.312325] NVRM: rm_init_adapter failed for device bearing minor number 0

[   39.870771] NVRM: failed to copy vbios to system memory.

[   39.873553] NVRM: RmInitAdapter failed! (0x30:0xffff:664)

[   39.873732] NVRM: rm_init_adapter failed for device bearing minor number 0

```

Not familiar with how to address this, though.

----------

## Tyler_Durden

 *audiodef wrote:*   

> Not familiar with how to address this, though.

 

maybe to your rt kernel?

----------

## audiodef

What I have read so far suggests that this could be ACPI-related, regardless of kernel type. I just tried disabling ACPI in kernel, but that meant no EFI framebuffer and therefore no TTY1-6. I'm hoping a grub cmdline arg will help - just need to figure out what arg to use.

Most of the things I've read about making this work involve

```

xrandr --setprovideroutputsource modesetting NVIDIA-0

```

If I stop xdm or boot without xdm and run this at a root prompt, I get a Can't open display error. Not sure what that means in terms of figuring out what's not working here.

Found this page: http://us.download.nvidia.com/XFree86/Linux-x86/304.43/README/commonproblems.html

And this section:

```

    

Why does the VBIOS fail to load on my Optimus system?

   

On some notebooks with Optimus graphics, the NVIDIA driver may not be able to retrieve the Video BIOS due to interactions between the System BIOS and the Linux kernel's ACPI subsystem. On affected notebooks, applications that require the GPU will fail, and messages like the following may appear in the system log:

NVRM: failed to copy vbios to system memory.

NVRM: RmInitAdapter failed! (0x30:0xffffffff:858)

NVRM: rm_init_adapter(0) failed

Such problems are typically beyond the control of the NVIDIA driver, which relies on proper cooperation of ACPI and the System BIOS to retrieve important information about the GPU, including the Video BIOS.

```

This is unhelpful. What is the "proper cooperation of ACPI and the system BIOS to retrieve important information about the GPU?" On my BIOS, the only GPU option is whether to use on-board only or use both together.

I've started wondering if I should have installed Gentoo in legacy mode. Could EFI be getting in the way of using nvidia-drivers?

----------

## hhfeuer

This dreaded message

```
[   15.309608] NVRM: failed to copy vbios to system memory.

[   15.312162] NVRM: RmInitAdapter failed! (0x30:0xffff:664) 

```

is happening more often lately. So far, this seems to be depending on the kernel in use. What kernel are you using?

----------

## audiodef

Latest rt-sources. I'm going to emerge gentoo-sources and see whether this still happens. I kind of expect it to, but at least I can rule out the specific kernel as the culprit. If I'm wrong, maybe I can think about patching.

Also:

```

localhost /usr/src/linux # glxinfo 

name of display: :0.0

Error: couldn't find RGB GLX visual or fbconfig

```

If this matters.

----------

## audiodef

Well, shoot. 

gentoo-sources works with the setup I've prepared thus far. All I have to do is place my saved xorg.conf (from above) in /etc/X11 to test, and this time it worked. glxgears runs. 

So something in rt-sources, 4.9 or latest, is different. I'm not sure it's an Nvidia/rt-sources compat issue, because there is an nvidia-drivers/rt-sources version combo that normally works on desktops, but does not here on my Optimus laptop. So the question now is: what is it about gentoo-sources that allows this to work where rt-sources fails? What kernel config option(s) is/are relevant?

----------

## hhfeuer

This shouldn't be depending on rt-sources, other users had problems with certain distro kernels like ubuntu, centos, arch. So it's a mistery which kernel-version/options are involved.

To be sure, did you emerge nvidia-drivers for the current kernel and see in dmesg that the kernel modules get loaded? Not that you're currently running nouveau.

----------

## audiodef

I make sure to emerge nvidia-drivers whenever I compile a kernel. 

You're right, it should not depend on kernel version, but it could depend on kernel config. I'm now compiling rt-sources-4.9 with the config from gentoo-sources-4.9. If that works, then I'll have the option of picking it apart to figure out what kernel option breaks Optimus support.

EDIT: Success - I think. Booted into rt-sources. less /var/log/Xorg.0.log | grep nvidia shows the nvidia driver loaded. Looking at the log without grep, everything looks ok. Grepping the log for nouveau shows no nouveau in use even though genkernel compiled the module and the module is present. I could blacklist nouveau to test this for sure. 

So, something in the kernel config I had previously prevented Optimus from working. I just don't know what. Will try to remember to post if I figure it out.

I kind of recall glxgears not working for me when I intentionally used nouveau, so that tells me that particular driver is not in use.

----------

## hhfeuer

Great!

```
glxinfo |grep OpenGL
```

should return something Nvidia.

Running a diff on the .config files wouldn't help? Was the previos rt-kernel .config a customized and now a generic one?

----------

## audiodef

Aha. 

Since I used the working default genkernel config from gentoo-sources, I realized I did not change the rt settings. So I changed it to fully-preemptible, recompiled nvidia-drivers, reboot - and could not load vbios. 

I changed the kernel rt to the next highest setting - normal rt, recompiled nvidia-drivers, and that works.

So the fully-preemptible kernel actually does something to prevent nvidia-drivers from accessing vbios.

Going to mark this thread [SOLVED] and start a new post about this in Unsupported, as anything further is now actually about rt-sources. 

Thanks for all the replies - it's been very helpful.   :Smile: 

----------

