No vsync on linux

Hello, Nvidia!
Support chat is turned off, and there is no way to contact Nvidia support, so I decided to write here.
Problem: no vsync on Linux. Glgears renders up to 13000 fps on propietary NVidia drivers. Also, I can see tearing in prowsers/desktop animations, etc.
My system: Dell XPS 15 9550 with NVidia GTX 960M. The same problem on Kubuntu and Mint KDE.
Vsync works with Nouveau driver, it also works with integrated Intel GPU.
Waiting for your response.

https://www.dropbox.com/s/ylfvkseuvo6adgl/nvidia-bug-report.log.gz?dl=0

Driver versions 384 and 390 - the same problem.
Manually creating xorg.conf makes my screen black.

Did you try 396.x ?
https://devtalk.nvidia.com/default/topic/533434/linux/current-graphics-driver-releases/post/5255728/#5255728

no, is there a bugfix?

It’s probably an Optimus laptop, so you’ll have to turn on prime sync:
To get rid of tearing, use kernel parameter

nvidia-drm.modeset=1

In case of Ubuntu, you might have to add a file in /etc/modprobe.d/ containing

options nvidia_XXX_drm modeset=1

with XXX being the major version of the installed nvidia driver.
After that, run

sudo update-initramfs -u

and reboot.

sudo cat /sys/module/nvidia_drm/parameters/modeset

should return ‘Y’ if done right.

Thank you. That`s my console output after reboot:

staseg@staseg-XPS-15 ~ sudo cat /sys/module/nvidia_drm/parameters/modeset [sudo] password for staseg: Y staseg@staseg-XPS-15 ~ glxgears
Running synchronized to the vertical refresh. The framerate should be
approximately the same as the monitor refresh rate.
65946 frames in 5.0 seconds = 13189.188 FPS
staseg@staseg-XPS-15 ~ $

I did, what you have told.
Modeset is on now.
Then I tested glxgears to view FPS. 13 thousands. It seems, VSync is off.
And I see tearing.

I used 384, 390, 396 drivers. The same problem.

It seems, this is a bug.

I also pasted
Option “metamodes” “nvidia-auto-select +0+0 {ForceCompositionPipeline=On, ForceFullCompositionPipeline=On}”
to xorg.conf
Nothing changed

An only way to switch on VSync is to switch to Intel Graphics

The prerequisite for prime sync to work apart from setting the modeset option is having an xserver>=1.19.
What kind of distro are you running? Please run nvidia-bug-report.sh as root and attach the resulting .gz file to your post. Hovering the mouse over an existing post will reveal a paperclip icon.
Edit: you also need a kernel >=4.5

Thank you, added bug report
https://www.dropbox.com/s/ylfvkseuvo6adgl/nvidia-bug-report.log.gz?dl=0
Linux Mint 18.3
Kernel 4.13

You’re running xserver 1.18.4, so you’ll need to upgrade:
run

sudo apt-get install --install-recommends linux-generic-hwe-16.04 xserver-xorg-hwe-16.04

see:
https://wiki.ubuntu.com/Kernel/LTSEnablementStack

It works! Thank you so much!
I was tortured my laptop for almost two weeks to turn vsync on :)