# Nvidia KMS / tty flicker

## augustin

I just installed nvidia-drivers and rebooted.

At long last, I am starting to have a stable gentoo system, although I still have many things left to configure.

I have a small problem with nvidia and KMS.

When I switch tty (F1, F7, F8...), there is a flicker/pause before the switch completes. From what I understand, it is a problem with KMS.

The nouveau driver was very unstable, to the point that I had to give up (https://forums.gentoo.org/viewtopic-t-1057046-highlight-.html ), but at least, switching tty was very smooth.

Is this supposed to work, or is that a known limitation of the nvidia binary drivers with no workaround?

I followed 

https://wiki.gentoo.org/wiki/NVidia/nvidia-drivers

and disabled all fb and drm kernel modules mentioned there.

I have:

```

# lsmod | grep nvidia

nvidia_modeset        774144  11

nvidia              11919360  290 nvidia_modeset

nvidia_drm             16384  0

i2c_core               61440  3 igb,i2c_algo_bit,nvidia
```

and:

```

$ glxinfo | grep direct

direct rendering: Yes

```

modprobe -a  nvidia_drm

does nothing.

Is nvidia_drm the kernel module that would solve the above problem?

Can it be enabled at run time?

Do I need to add it to some configuration file, or as a boot option in grub?

```

# eix nvidia-drivers

[I] x11-drivers/nvidia-drivers

     Installed versions:  375.26^md(12:35:20 04/01/17)(X acpi driver kms multilib static-libs tools -compat -gtk3 -pax_kernel -uvm -wayland KERNEL="linux -FreeBSD")

```

----------

## DawgG

 *Quote:*   

> is that a known limitation of the nvidia binary drivers with no workaround? 

 

i think it is just that.

to make it short: the nvidia-binary drivers suck except for gaming and nvenc.

i run a gf750ti (one system, two different kernels) and it shows the behaviour that you describe, except that the nouveau-driver is very usable (sometimes unstable (small graphic glitches), but never crashes or hangs the whole system - but i run ~amd64, so that is to be expected).

when working on the console or just in "2d," i think the nouveau-driver work., looks and feels much better than the binary driver. i set up a couple of system  to use both drivers (like this https://wiki.gentoo.org/wiki/Nouveau_%26_nvidia-drivers_switching) and i think it works very well (even an old thinkpad with an ancient quadro).

GOOD LUCK!

----------

## augustin

 *DawgG wrote:*   

>  *Quote:*   is that a known limitation of the nvidia binary drivers with no workaround?  
> 
> i think it is just that.
> 
> to make it short: the nvidia-binary drivers suck except for gaming and nvenc.
> ...

 

Thanks. We use the same card. 

There is a thread dedicated to the nouveau driver for this specific card.

Can you check the following and answer my question there?

https://forums.gentoo.org/viewtopic-p-8013492.html#8013492

Thanks.

Keeping this thread specific to the nvidia binary drivers, what is the output of the following when you run nvidia:

```

   # lsmod | grep nvidia 
```

Specifically, I am trying to understand what the driver nvidia_drm  is for.

I didn't know what nvenc was:

https://en.wikipedia.org/wiki/Nvidia_NVENC

Specifically, when do you use it and with which application?

----------

## DawgG

/usr/share/doc/nvidia-drivers-375.26/html/kms.html states:

 *Quote:*   

> The NVIDIA GPU driver package provides a kernel module, nvidia-drm.ko, which registers a DRM driver with the DRM subsystem of the Linux kernel. (...)

 

i reconfigured my system (activated config_drm for the nvidia-binary-kernel, nvidia-drm.modeset=1 for grub) and use it now:

```
x2 ~ # lsmod

Module                  Size  Used by

nvidia_drm             34944  1

nvidia_modeset        756391  4 nvidia_drm
```

and it does something, but not at all like nouveau's KMS. not bad, but not great either.

i use nvenc for transcoding MPEG2 to X264 with ffmpeg which is unbelievably fast as compared to cpu-based encoding (MOVIE-raw.mkv is an mkv-file with MPEG2-video and ac3-sound; the sound is just copied):

```
ffmpeg -i MOVIE-raw.mkv -vf "crop=720:416:0:80" -map 0:0 -map 0:1 -map 0:2 -map 0:3 -map 0:4 -map 0:5 -c:v libx264 -crf 18 -preset veryslow -tune film -c:s copy -c:a:0 copy -c:a:1 copy enc-MOVIE-raw.mkv
```

yields: frame= 1626 fps= 48 q=-1.0 Lsize=   12518kB time=00:01:05.05 bitrate=1576.3kbits/s speed=1.93x

```
ffmpeg -i MOVIE-raw.mkv -vf "crop=720:416:0:80" -map 0:0 -map 0:1 -map 0:2 -map 0:3 -map 0:4 -map 0:5 -c:v h264_nvenc -pixel_format yuv444p -crf 18 -preset slow -tune film -c:s copy -c:a:0 copy -c:a:1 copy enc-MOVIE-raw-nvenc.mkv
```

yields: fps=843 q=24.0 Lsize=  130448kB time=00:06:23.20 bitrate=2788.7kbits/s speed=33.7x

i haven't done extensive testing but with similar filesize and quality ffmpeg with h264_nvenc encodes at about 750-950 fps whereas ffmpeg with libx264 encodes at about 20-50 fps.

you can find more about it here: https://trac.ffmpeg.org/wiki/HWAccelIntro#NVENC

nvenc is a useflag for ffmpeg and you need the uvm-module (useflag uvm) for the nvidia-drivers.

GOOD LUCK!

----------

## augustin

 *DawgG wrote:*   

> /usr/share/doc/nvidia-drivers-375.26/html/kms.html states:
> 
>  *Quote:*   The NVIDIA GPU driver package provides a kernel module, nvidia-drm.ko, which registers a DRM driver with the DRM subsystem of the Linux kernel. (...) 
> 
> i reconfigured my system (activated config_drm for the nvidia-binary-kernel, nvidia-drm.modeset=1 for grub) and use it now:
> ...

 

Thanks DawgG for your extensive notes on nvenc. I have noted them so that I remember to use this method when I need to.

Regarding nvidia_drm, I have just tested. The only change I made was enabling  CONFIG_DRM in the kernel. I didn't add anything to the grub menu but I get like you:

```

# lsmod | grep nvidia 

nvidia_drm             49152  1

nvidia_modeset        774144  6 nvidia_drm

nvidia              11919360  104 nvidia_modeset

```

It doesn't appear to make much difference:

- switching back and forth between tty7 and tty8 is still slow, but less ugly (with less artefacts during the switch).

- same when switching from tty7 to tty1 (slow but clean).

- but switching back from tty1 to tty7 is both slow and ugly.

Now, regarding CONFIG_DRM, I had previously disabled it because of what the wiki says:

 *Quote:*   

> 
> 
> https://wiki.gentoo.org/wiki/NVidia/nvidia-drivers#Direct_rendering_is_not_enabled
> 
> If direct rendering does not work, it may be because the kernel has Direct Rendering Manager enabled, which conflicts with the driver. See the direct rendering status by following instructions in the section Testing the card. 
> ...

 

Is the wiki wrong? What is it referring to?

I am still unsure what DRM and DRI are for, and how related they are to the tty switch we're discussing.

I'll leave it at that for the time being, as I have more important things to do, but we welcome anybody to shed more light on the topic.  :Smile: 

----------

## augustin

 *augustin wrote:*   

> 
> 
> Regarding nvidia_drm, I have just tested. The only change I made was enabling  CONFIG_DRM in the kernel. I didn't add anything to the grub menu 
> 
> It doesn't appear to make much difference:
> ...

 

This time I did add modeset to the boot parameters:

```

 # cat /proc/cmdline

BOOT_IMAGE=/vmlinuz-4.4.26-gentoo-2017-jan-10-with-drm-nvidia root=UUID=999d57-etc  ro nvidia-drm.modeset=1

```

nvidia_drm  is loaded:

```

# lsmod | grep nvidia

nvidia_drm             49152  2

nvidia_modeset        774144  12 nvidia_drm

nvidia              11919360  236 nvidia_modeset

```

modeset is enabled:

```

# cat /sys/module/nvidia_drm/parameters/modeset

Y
```

But frankly, it does not seem to make much difference from what I was describing above :-/

----------

