Ubuntu don't see second display and randomly logs out

I’m very new to this forum so I apologise if I am doing something wrong!

I’m using a Lenovo P50 notebook with Ubuntu 22.04.1 LTS and I have a few problems with it.

Since the last update(which included a kernel update I think) my OS randomly logs out while I’m using it. I have encountered this problem in the summer and I tried to solve it. Somehow it worked, because it didn’t show up for 1-2 months. I don’t remember exactly what I solved it with at the time. Now I just tried to boot an earlier kernel(5.15), but the problem I have with this is that my second monitor is not detected.

I’m almost certain that a GPU driver error is behind both things. But i don’t know what to do. At the moment I’m using NVIDIA Driver 525(proprietary, tested). In the summer when I had this problem I tried to use nouveau open source but it didn’t worked. I remember that in the 1-2 months when there were no problems, I used the 525 driver.

I’ve run the journalctl -b command after the last logout and here is some of the results:

jan 24 00:37:10 zsolti-ThinkPad-P50 opera.desktop[28500]: [28500:28500:0124/003710.141014:ERROR:shared_image_factory.cc(575)] Could not find SharedImageBackingFactory with params: usage: Gles2|Raster|Di>
jan 24 00:37:18 zsolti-ThinkPad-P50 kernel: i915 0000:00:02.0: [drm] Resetting rcs0 for preemption time out
jan 24 00:37:18 zsolti-ThinkPad-P50 kernel: i915 0000:00:02.0: [drm] Xorg[26405] context reset due to GPU hang
jan 24 00:37:18 zsolti-ThinkPad-P50 kernel: i915 0000:00:02.0: [drm] GPU HANG: ecode 9:1:85dffffb, in Xorg [26405]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE)
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) Backtrace:
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 0: /usr/lib/xorg/Xorg (OsLookupColor+0x139) [0x55ff17ab0719]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 1: /lib/x86_64-linux-gnu/libc.so.6 (__sigaction+0x50) [0x7fb4fe042520]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 2: /lib/x86_64-linux-gnu/libc.so.6 (pthread_kill+0x12c) [0x7fb4fe096a7c]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 3: /lib/x86_64-linux-gnu/libc.so.6 (raise+0x16) [0x7fb4fe042476]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 4: /lib/x86_64-linux-gnu/libc.so.6 (abort+0xd3) [0x7fb4fe0287f3]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) unw_get_proc_name failed: no unwind info found [-10]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 5: /usr/lib/x86_64-linux-gnu/dri/iris_dri.so (?+0x0) [0x7fb4fb0a3144]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 6: /usr/lib/x86_64-linux-gnu/dri/iris_dri.so (nouveau_drm_screen_create+0x3f4edf) [0x7fb4fbd0daaf]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 7: /usr/lib/x86_64-linux-gnu/dri/iris_dri.so (__driDriverGetExtensions_d3d12+0xc4197) [0x7fb4fb172bb7]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 8: /usr/lib/xorg/Xorg (present_event_notify+0x67a) [0x55ff17a1b2aa]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 9: /usr/lib/xorg/Xorg (present_register_complete_notify+0x1e66) [0x55ff17a1a0e6]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) unw_get_proc_name failed: no unwind info found [-10]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 10: /usr/lib/xorg/modules/drivers/modesetting_drv.so (?+0x0) [0x7fb4fd8963c4]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) unw_get_proc_name failed: no unwind info found [-10]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 11: /usr/lib/xorg/modules/drivers/modesetting_drv.so (?+0x0) [0x7fb4fd89705c]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 12: /lib/x86_64-linux-gnu/libdrm.so.2 (drmHandleEvent+0x9d) [0x7fb4fe53936d]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 13: /usr/lib/xorg/Xorg (OsCleanup+0x571) [0x55ff17ab1101]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 14: /usr/lib/xorg/Xorg (WaitForSomething+0x193) [0x55ff17aa9e53]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 15: /usr/lib/xorg/Xorg (SendErrorToClient+0x117) [0x55ff1793a267]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 16: /usr/lib/xorg/Xorg (InitFonts+0x3c4) [0x55ff1793e534]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 17: /lib/x86_64-linux-gnu/libc.so.6 (__libc_init_first+0x90) [0x7fb4fe029d90]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 18: /lib/x86_64-linux-gnu/libc.so.6 (__libc_start_main+0x80) [0x7fb4fe029e40]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) 19: /usr/lib/xorg/Xorg (_start+0x25) [0x55ff17927605]
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE)
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE)
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: Fatal server error:
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) Caught signal 6 (Aborted). Server aborting
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE)
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE)
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: Please consult the The X.Org Foundation support
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]:          at http://wiki.x.org
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]:  for help.
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) Please also check the log file at "/home/zsolti/.local/share/xorg/Xorg.1.log" for additional information.
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE)
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (II) AIGLX: Suspending AIGLX clients for VT switch
jan 24 00:37:18 zsolti-ThinkPad-P50 /usr/libexec/gdm-x-session[26405]: (EE) Server terminated with error (1). Closing log file.



jan 24 00:37:44 zsolti-ThinkPad-P50 kernel: [drm:nv_drm_master_set [nvidia_drm]] *ERROR* [nvidia-drm] [GPU ID 0x00000100] Failed to grab modeset ownership

Do you have any ideas? Thanks!