Screen tearing on optimus laptop with all ubuntu 20.04 flavors (nvidia driver 390.132)

sudo dkms remove nvidia/390.132
after remove kernel modules, install doesn’t work:

but works this:

dkms install nvidia/390.132 -k 5.4.0-29-generic

but tearing issue still here…

@generix any ideas?

I’ll have to test the patch myself. Takes some time to revert to 390, though.

@generix Figured I’d note about the patch you linked, I remember that while several said it worked (on 440, at least), there were the odd one said it didn’t, and on >= 5.5 it stopped working completely. For 5.5 and up, I took the changes from 440.44->440.59 and rebased it onto 390.132. The changes in there and more numerus, but includes the relevant reservation_object_*/PRIME code, and should be fine on 5.4 as well.

So, in case it doesn’t work with that patch, you might want to try that one instead. I could’ve tried myself if I had a compatible system, but alas.

Note: I’m not too familiar Ubuntu’s packages, but the .manifest diff probably need to go. I’m also not sure if it’d crash with the various other Ubuntu flavoured patches. Still, there it is.

Thanks, @Isaak.Aleksandrov.
I now tested the patches to no avail
driver 390.132+ your kernel 5.5 sync patch + Arch 390 kernel 5.6 patch
kernel 5.4: no prime sync
kernel 5.6: no prime sync + kernel oopses
Obviously not that straight forward, needs more investigation.

@generix That’s odd, for Ubuntu I could’ve understood if there’s some distribution specific thing present in the driver, but not on Arch. I did get response from multiple people that PRIME were apparently functional after applying that one. Oh well, sorry for not being of much help in helping debugging this.

Just curious, what were the kernel oops you encountered? Was it the use-after-free message that some were reporting a while back?

I’m on Gentoo, so I have full control which patches get used. I’ve just taken the Arch patch to get it compiled for 5.6.

Oops on 5.6:

Mai 09 15:19:41 homer kernel: ------------[ cut here ]------------
Mai 09 15:19:41 homer kernel: refcount_t: underflow; use-after-free.
Mai 09 15:19:41 homer kernel: WARNING: CPU: 3 PID: 936 at lib/refcount.c:28 refcount_warn_saturate+0xa6/0xf0
Mai 09 15:19:41 homer kernel: Modules linked in: bnep btusb uvcvideo btrtl btbcm btintel videobuf2_vmalloc videobuf2_memops bluetooth videobuf2_v4l2 videobuf2_common ecdh_generic ecc nvidia_drm(PO) nvidia_modeset(PO) iwlmvm x86_pkg_temp_thermal r8169 nvidia(PO) iwlwifi realtek libphy ideapad_laptop wmi efivarfs
Mai 09 15:19:41 homer kernel: CPU: 3 PID: 936 Comm: Xorg.wrap Tainted: P     U     O      5.6.10-gentoo #1
Mai 09 15:19:41 homer kernel: Hardware name: LENOVO 20287/VIUU4, BIOS 8DCN40WW 10/24/2014
Mai 09 15:19:41 homer kernel: RIP: 0010:refcount_warn_saturate+0xa6/0xf0
Mai 09 15:19:41 homer kernel: Code: 05 a1 1a 55 01 01 e8 d6 58 9f ff 0f 0b c3 80 3d 8f 1a 55 01 00 75 95 48 c7 c7 c0 6b 6f 82 c6 05 7f 1a 55 01 01 e8 b7 58 9f ff <0f> 0b c3 80 3d 6e 1a 55 01 00 0f 85 72 ff ff ff 48 c7 c7 18 6c 6f
Mai 09 15:19:41 homer kernel: RSP: 0018:ffffc9000162fd98 EFLAGS: 00010282
Mai 09 15:19:41 homer kernel: RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000007
Mai 09 15:19:41 homer kernel: RDX: 0000000000000007 RSI: 0000000000000096 RDI: ffff8882572d8790
Mai 09 15:19:41 homer kernel: RBP: ffff8882258a9428 R08: 0000000000000001 R09: 0000000000000406
Mai 09 15:19:41 homer kernel: R10: 0000000000015c9c R11: 0000000000000003 R12: ffff8882456982e8
Mai 09 15:19:41 homer kernel: R13: ffff888245698000 R14: 0000000000000000 R15: ffff88823c65bcc8
Mai 09 15:19:41 homer kernel: FS:  00007f3c9fd4e740(0000) GS:ffff8882572c0000(0000) knlGS:0000000000000000
Mai 09 15:19:41 homer kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Mai 09 15:19:41 homer kernel: CR2: 00007f68ac000010 CR3: 0000000217e58002 CR4: 00000000001606e0
Mai 09 15:19:41 homer kernel: Call Trace:
Mai 09 15:19:41 homer kernel:  nv_drm_atomic_helper_disable_all+0xe7/0x340 [nvidia_drm]
Mai 09 15:19:41 homer kernel:  nv_drm_exit+0xcd/0x300 [nvidia_drm]
Mai 09 15:19:41 homer kernel:  drm_drop_master+0x19/0x30
Mai 09 15:19:41 homer kernel:  drm_master_release+0x9a/0xa0
Mai 09 15:19:41 homer kernel:  drm_file_free.part.0+0x1f9/0x260
Mai 09 15:19:41 homer kernel:  drm_release+0x95/0xd0
Mai 09 15:19:41 homer kernel:  __fput+0xb4/0x240
Mai 09 15:19:41 homer kernel:  task_work_run+0x84/0xa0
Mai 09 15:19:41 homer kernel:  exit_to_usermode_loop+0x98/0xa0
Mai 09 15:19:41 homer kernel:  do_syscall_64+0x159/0x190
Mai 09 15:19:41 homer kernel:  entry_SYSCALL_64_after_hwframe+0x44/0xa9
Mai 09 15:19:41 homer kernel: RIP: 0033:0x7f3c9ff1be23
Mai 09 15:19:41 homer kernel: Code: 00 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb bb 0f 1f 80 00 00 00 00 64 8b 04 25 18 00 00 00 85 c0 75 14 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 83 ec 18 89 7c 24 0c e8
Mai 09 15:19:41 homer kernel: RSP: 002b:00007ffc973075c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
Mai 09 15:19:41 homer kernel: RAX: 0000000000000000 RBX: 0000000000000001 RCX: 00007f3c9ff1be23
Mai 09 15:19:41 homer kernel: RDX: 00007ffc973075e0 RSI: 00000000c04064a0 RDI: 0000000000000004
Mai 09 15:19:41 homer kernel: RBP: 00007ffc973076c0 R08: 0000000000000000 R09: 000000000000000e
Mai 09 15:19:41 homer kernel: R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffc973075e0
Mai 09 15:19:41 homer kernel: R13: 0000000000000002 R14: 0000000000000002 R15: 0000000000000004
Mai 09 15:19:41 homer kernel: ---[ end trace e428bf47ce73e3b1 ]---

NB: the oops is unrelated to your patch, it also happens when just using the full Arch patchset for 390.

@generix Yeah, I figured it’d be that. While I’m not sure if this is what actually fixed it – as I couldn’t replicate the issue myself – when the new release of the 440 driver came, and others said it was fixed, they had the following change that might’ve been relevant to that refcount issue:

diff --git a/kernel/nvidia-drm/nvidia-drm-modeset.c b/kernel/nvidia-drm/nvidia-drm-modeset.c
index 035c0d9..3a57e8e 100644
--- a/kernel/nvidia-drm/nvidia-drm-modeset.c
+++ b/kernel/nvidia-drm/nvidia-drm-modeset.c
@@ -342,7 +342,10 @@ int nv_drm_atomic_commit(struct drm_device *dev,
     }
 
 #if defined(NV_DRM_ATOMIC_STATE_REF_COUNTING_PRESENT)
-    drm_atomic_state_put(state);
+    /*
+     * If ref counting is present, state will be freed when the caller
+     * drops its reference after we return.
+     */
 #else
     drm_atomic_state_free(state);
 #endif

If you’re going to test any further on that kernel, then it might be worth giving that a try as well. Not so much for the PRIME stuff, but for that oops.

@Isaak.Aleksandrov @generix well guys for now no fix for screen tearing with nvidia-390?

At least not that soon, takes time.

Hi all. Is still no solution? I am having similar issues with 390.132 driver on kubuntu 20.04 and GeForce 630M.

For now nope.
@generix @Isaak.Aleksandrov right guys?

1 Like

Issue is fixed after update drivers to version 390.138

1 Like