Fixing Nvidia Lock Screen/Resume from Sleep Freezing and Artifacting Issues

Hey guys I installed some updates yesterday through the default updater and then after a reboot I noticed my lock screen would shuffle the layout between my 4 monitors and also freeze. I would then have to Ctrl + Alt + F3 to enter TTY and type:

sudo systemctl restart gdm3
#this will force close all open apps

to fix it then finally login but then the layout would still be corrupted.

After spending a few hours back and forth with Gemini these steps finally fixed the lock screen freezing up issue. Hope that it helps other users with an Nvidia GPU. For context I'm not using the Intel iGPU rather the Quadro P620 on Nvidia 580 proprietary drivers running X11 display server and elected to enable Nvidia's "Force Composition Pipeline" to prevent screen tearing. Keep in mind these steps will lock in your screen layout and relative positions. On step 8 we will even dictate which monitor belongs to which port on your GPU by copying the monitor EDID info. This is a very rigid setup but should fix all screen shuffling/freezing issues for NVIDIA GPUs. Below are the steps I had to take to fully fix the issue:

1. Clear any bad settings
In terminal:

sudo rm -f /etc/X11/xorg.conf

2. Grab Your Exact Layout via CLI
Go to your "NVIDIA X Server Settings" app > X Server Display Configuration and setup the exact layout you want for your monitors make sure to set the primary monitor. Also click on "Advanced" button and enable "Force Composition Pipeline". Press apply, but do not click Save to X Configuration File.
In terminal:

nvidia-settings -q CurrentMetaMode -t

this will print your display layout + exact positioning and also save the "Force Composition Pipeline" (prevents screen tearing) setting after a reboot.

It will look similar to middle section below:

sudo bash -c "cat > /etc/X11/xorg.conf.d/10-nvidia-layout.conf" << 'EOF'
Section "Device"
    Identifier "Device0"
    Driver "nvidia"
    VendorName "NVIDIA Corporation"
    Option "UseHotplugEvents" "false"
EndSection

Section "Screen"
    Identifier "Screen0"
    Device "Device0"
    Option "metamodes" "DPY-2: nvidia-auto-select @2560x1440 +1920+1080 {ViewPortIn=2560x1440, ViewPortOut=2560x1440+0+0, ForceCompositionPipeline=On, ForceFullCompositionPipeline=On}, DPY-0: nvidia-auto-select @3840x2160 +4480+638 {ViewPortIn=3840x2160, ViewPortOut=3840x2160+0+0, ForceCompositionPipeline=On, ForceFullCompositionPipeline=On}, DPY-4: nvidia-auto-select @1920x1080 +0+1440 {ViewPortIn=1920x1080, ViewPortOut=1920x1080+0+0, ForceCompositionPipeline=On, ForceFullCompositionPipeline=On}, DPY-7: 1920x1080_60_0 @1920x1080 +2240+0 {ViewPortIn=1920x1080, ViewPortOut=1920x1080+0+0, ForceCompositionPipeline=On, ForceFullCompositionPipeline=On}"
EndSection
EOF

Replace the middle section (long text after: Option "metamodes") with your exact layout using the command shown earlier. Assuming you copy and pasted above and replaced with your layout, after you hit enter it will automatically make the configuration file in the correct directory. Also note that I had to eventually turn "ForceFullCompositionPipeline=On" to "Off". I believe this is a low VRAM restriction (my card only has 2GB if you have more perhaps you can keep it on).

3. Enable NVIDIA Preserve VRAM
This step will create a configuration to dump your VRAM onto your storage drive before it enters a low power state that lock screen/sleep will trigger. This prevents any artifact rendering issues when resuming from a low power state.

echo "options nvidia NVreg_PreserveVideoMemoryAllocations=1 NVreg_TemporaryFilePath=/var/tmp" | sudo tee /etc/modprobe.d/nvidia-power-management.conf

and enable the NVIDIA background sleep services:

sudo systemctl enable nvidia-suspend.service nvidia-hibernate.service nvidia-resume.service

4. Bake the VRAM fix into the boot image

sudo update-initramfs -u

5. Force the Lock Screen to X11

sudo nano /etc/gdm3/custom.conf

Look for: #WaylandEnable=false
Delete the "#" so it looks like:

WaylandEnable=false

Save (Ctrl + O), then hit Enter, and exit (Ctrl + X).

6. Enable NVIDIA DRM Modesetting
To make sure the X11 lock screen can talk to your Quadro P620 smoothly during the wake-up cycle, we need to ensure "Direct Rendering Manager" (DRM) is turned on in the kernel. Open your bootloader configuration:

sudo nano /etc/default/grub

Edit GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
so it looks like:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nvidia-drm.modeset=1"

Save (Ctrl + O), then hit Enter, and exit (Ctrl + X).

Update your bootloader to apply the change:

sudo update-grub

7. Fix lock screen layout:
This is 3 commands in one:

sudo mkdir -p /var/lib/gdm3/.config && sudo cp ~/.config/monitors.xml /var/lib/gdm3/.config/ && sudo chown -R gdm:gdm /var/lib/gdm3/.config

8. Add Custom EDIDs, for full lock down
Warning what you are about to do is very rigid, you are dictating which monitor plugs into which exact port on your GPU.
Go to NVIDIA X Server app, grab and save EDID from each monitor to folder of choice. Name each EDID with the NVIDIA assigned port names + monitor name of choice ie, DP-2_ASUS.bin, DP-0_LG.bin etc.

Edit this block of text (adjust EDID path and file names as applicable):

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    Option         "UseHotplugEvents" "false"
    Option         "ConnectedMonitor" "DP-2, DP-0, DP-4, DP-7"
    Option         "CustomEDID" "DP-2:/home/yourusernamehere/Documents/Quadro_4_Monitor_Lock_Screen_Freezing_Fix/DP-2-edid.bin; DP-0:/home/yourusernamehere/Documents/Quadro_4_Monitor_Lock_Screen_Freezing_Fix/DP-0_edid.bin; DP-4:/home/yourusernamehere/Documents/Quadro_4_Monitor_Lock_Screen_Freezing_Fix/DP-4_edid.bin; DP-7:/home/yourusernamehere/Documents/Quadro_4_Monitor_Lock_Screen_Freezing_Fix/DP-7_edid.bin"
EndSection

into "sudo nano /etc/X11/xorg.conf.d/10-nvidia-layout.conf", replacing the existing block of text:

Section "Device"
    Identifier "Device0"
    Driver "nvidia"
    VendorName "NVIDIA Corporation"
    Option "UseHotplugEvents" "false"
EndSection

9. Turn off s2idle (modern standby) opting for S3 sleep.
Some hardware does not interact with s2idle well and prefer S3 sleep such as my NVIDIA Quadro card. This step combined with the previous steps completely fixed resume from sleep for my system. No more artifacting.

sudo nano /etc/default/grub

look for:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nvidia-drm.modeset=1"

and add "mem_sleep_default=deep" to the end so it looks like:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nvidia-drm.modeset=1 mem_sleep_default=deep"

Save (Ctrl + O), then hit Enter, and exit (Ctrl + X).

Bake into bootloader by running:

sudo update-grub

10. Force the NVMe to Stay Awake
This step is hardware specific it may not apply to you. Some NVMe drives wake up too slowly or bug out and not wake up from a low power state. What this step does is it prevents the NVMe from entering a low power state. This will drain your laptop battery faster on standby.

sudo nano /etc/default/grub

look for this line from step 6 and 9:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nvidia-drm.modeset=1 mem_sleep_default=deep"

add "nvme_core.default_ps_max_latency_us=0" to the very end of the line so it looks like this:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nvidia-drm.modeset=1 mem_sleep_default=deep nvme_core.default_ps_max_latency_us=0"

Save (Ctrl + O), then hit Enter, and exit (Ctrl + X).

Bake into bootloader by running:

sudo update-grub

Congratulations for reaching the end of NVIDIA driver issues hell! Just reboot and enjoy your screens not randomly shuffling around and crashing from sleep/lock screen. I am not an expert, this is my first guide, feedback is welcome!

1 Like

Thank you I'm sure it would help some users...

1 Like