Resume issue after suspend Ubuntu 20.04

Ubuntu 20.04
GeForce GT 740M
Asus K56CB
I’ve tried 418-server, 390, 340,460, 470.57.02, 470.42.01
Suspend only works when I’ve changed prime-select to intel and with nouveau.

Tried everything: acpi_osi, various kernel settings like:
nvidia-drm.modeset=1 vga=0 rdblacklist=nouveau nouveau.modeset=0 mem_sleep_default=deep snd_hda_intel.dmic_detect=0
also tried with nvida-sleep.sh
etc.

System freezes with this code:

Oct 27 20:09:24 JPC kernel: [   57.393600] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Oct 27 20:09:24 JPC kernel: [   57.394806] CR2: 00007f793018d114 CR3: 000000010dc06005 CR4: 00000000001706e0
Oct 27 20:09:24 JPC kernel: [   57.396000] Call Trace:
Oct 27 20:09:24 JPC kernel: [   57.397183]  ? _nv022199rm+0xee/0x1a0 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.398902]  ? _nv009235rm+0x12e/0x230 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.400579]  ? _nv036126rm+0x62/0x70 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.402240]  ? _nv040258rm+0x190/0x190 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.403845]  ? _nv040263rm+0x77/0x130 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.405428]  ? _nv040236rm+0x1a9/0x280 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.407043]  ? _nv007498rm+0x2c0b/0x2fc0 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.408607]  ? _nv000237rm+0x711/0xc80 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.410185]  ? _nv022095rm+0x6a3/0x7a0 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.411852]  ? _nv022193rm+0x4b/0xd0 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.413491]  ? _nv000724rm+0x284/0x2c0 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.415018]  ? _nv000723rm+0x10/0x40 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.416521]  ? rm_power_management+0xed/0x220 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.418019]  ? nv_power_management+0xf1/0x130 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.419414]  ? nvidia_resume+0x61/0x80 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.420783]  ? nv_set_system_power_state+0x2b9/0x3c0 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.422162]  ? nv_procfs_write_suspend+0xe7/0x140 [nvidia]
Oct 27 20:09:24 JPC kernel: [   57.423570]  ? proc_reg_write+0x66/0x90
Oct 27 20:09:24 JPC kernel: [   57.424709]  ? vfs_write+0xca/0x280
Oct 27 20:09:24 JPC kernel: [   57.425842]  ? ksys_write+0x67/0xe0
Oct 27 20:09:24 JPC kernel: [   57.426988]  ? __x64_sys_write+0x1a/0x20
Oct 27 20:09:24 JPC kernel: [   57.428094]  ? do_syscall_64+0x38/0x90
Oct 27 20:09:24 JPC kernel: [   57.429199]  ? entry_SYSCALL_64_after_hwframe+0x44/0xa9
Oct 27 20:09:26 JPC systemd[1]: systemd-fsckd.service: Succeeded.
Oct 27 20:09:52 JPC kernel: [   85.370814] watchdog: BUG: soft lockup - CPU#2 stuck for 22s! [nvidia-sleep.sh:2267]
Oct 27 20:09:52 JPC kernel: [   85.371911] Modules linked in: ccm rfcomm cmac algif_hash algif_skcipher af_alg bnep nls_iso8859_1 btusb btrtl btbcm btintel bluetooth ecdh_generic ecc snd
_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic ledtrig_audio intel_rapl_msr mei_hdcp snd_hda_intel intel_rapl_common snd_intel_dspcfg soundwire_intel soundwire_generic_alloc
ation soundwire_cadence snd_hda_codec x86_pkg_temp_thermal intel_powerclamp snd_hda_core coretemp snd_hwdep soundwire_bus snd_soc_core snd_compress kvm_intel ac97_bus snd_pcm_dmaengine k
vm crct10dif_pclmul snd_pcm ghash_clmulni_intel aesni_intel crypto_simd snd_seq_midi snd_seq_midi_event cryptd glue_helper rapl snd_rawmidi intel_cstate joydev input_leds mxm_wmi wmi_bmo
f efi_pstore at24 serio_raw asus_nb_wmi snd_seq iwlmvm mac80211 libarc4 snd_seq_device snd_timer iwlwifi cfg80211 snd mei_me mei i915 int3403_thermal soundcore int3402_thermal int3400_th
ermal int340x_thermal_zone asus_wireless acpi_thermal_rel i2c_algo_bit mac_hid sch_fq_codel msr
Oct 27 20:09:52 JPC kernel: [   85.371970]  parport_pc ppdev lp parport ip_tables x_tables autofs4 nvidia_uvm(POE) mmc_block hid_generic usbhid hid nvidia_drm(POE) nvidia_modeset(POE) nv
idia(POE) drm_kms_helper syscopyarea sysfillrect sysimgblt mfd_aaeon fb_sys_fops asus_wmi rtsx_pci_sdmmc cec sparse_keymap r8169 rc_core i2c_i801 psmouse ahci crc32_pclmul rtsx_pci lpc_i
ch i2c_smbus drm realtek libahci xhci_pci xhci_pci_renesas video wmi
Oct 27 20:09:52 JPC kernel: [   85.381978] CPU: 2 PID: 2267 Comm: nvidia-sleep.sh Tainted: P           OEL    5.11.0-38-generic #42~20.04.1-Ubuntu
Oct 27 20:09:52 JPC kernel: [   85.383110] Hardware name: ASUSTeK COMPUTER INC. K56CB/K56CB, BIOS K56CB.205 03/13/2013
Oct 27 20:09:52 JPC kernel: [   85.384215] RIP: 0010:_nv032887rm+0x12/0x40 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.385687] Code: d2 0e 31 c0 e8 af 7d 78 ff e8 ca 3c eb ff 31 c0 48 83 c4 08 c3 0f 1f 00 48 83 ec 08 39 4a 10 76 17 48 8b 02 c1 e9 02 8b 04 88 <48> 83 c4 
08 c3 66 0f 1f 84 00 00 00 00 00 be 00 00 d5 09 bf 0a ad
Oct 27 20:09:52 JPC kernel: [   85.387902] RSP: 0018:ffffb844027b3b30 EFLAGS: 00000206
Oct 27 20:09:52 JPC kernel: [   85.389003] RAX: 00000000bad0da1f RBX: 0000000000000020 RCX: 0000000000002500
Oct 27 20:09:52 JPC kernel: [   85.390113] RDX: ffff9e0d526a50a0 RSI: ffff9e0d526a4008 RDI: ffff9e0d42da0008
Oct 27 20:09:52 JPC kernel: [   85.391250] RBP: ffff9e0d4ad6ad50 R08: 0000000000000020 R09: ffff9e0d4ad6ad68
Oct 27 20:09:52 JPC kernel: [   85.392368] R10: ffff9e0d526a4008 R11: ffff9e0d526a50a0 R12: 0000000000009400
Oct 27 20:09:52 JPC kernel: [   85.393480] R13: 0000000000000000 R14: 0000000000000000 R15: ffff9e0d526a4008
Oct 27 20:09:52 JPC kernel: [   85.394616] FS:  00007f7985c52740(0000) GS:ffff9e105f700000(0000) knlGS:0000000000000000
Oct 27 20:09:52 JPC kernel: [   85.395730] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Oct 27 20:09:52 JPC kernel: [   85.396835] CR2: 00007f793018d114 CR3: 000000010dc06005 CR4: 00000000001706e0
Oct 27 20:09:52 JPC kernel: [   85.397944] Call Trace:
Oct 27 20:09:52 JPC kernel: [   85.399084]  ? _nv032886rm+0x40/0x40 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.400553]  ? _nv009235rm+0x1f1/0x230 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.402154]  ? _nv036126rm+0x62/0x70 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.403785]  ? _nv040258rm+0x190/0x190 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.405309]  ? _nv040263rm+0x77/0x130 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.406863]  ? _nv040236rm+0x1a9/0x280 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.408387]  ? _nv007498rm+0x2c0b/0x2fc0 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.409911]  ? _nv000237rm+0x711/0xc80 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.411445]  ? _nv022095rm+0x6a3/0x7a0 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.413045]  ? _nv022193rm+0x4b/0xd0 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.414673]  ? _nv000724rm+0x284/0x2c0 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.416132]  ? _nv000723rm+0x10/0x40 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.417604]  ? rm_power_management+0xed/0x220 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.419095]  ? nv_power_management+0xf1/0x130 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.420437]  ? nvidia_resume+0x61/0x80 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.421772]  ? nv_set_system_power_state+0x2b9/0x3c0 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.423167]  ? nv_procfs_write_suspend+0xe7/0x140 [nvidia]
Oct 27 20:09:52 JPC kernel: [   85.424511]  ? proc_reg_write+0x66/0x90
Oct 27 20:09:52 JPC kernel: [   85.425625]  ? vfs_write+0xca/0x280
Oct 27 20:09:52 JPC kernel: [   85.426763]  ? ksys_write+0x67/0xe0
Oct 27 20:09:52 JPC kernel: [   85.427874]  ? __x64_sys_write+0x1a/0x20
Oct 27 20:09:52 JPC kernel: [   85.428986]  ? do_syscall_64+0x38/0x90
Oct 27 20:09:52 JPC kernel: [   85.430093]  ? entry_SYSCALL_64_after_hwframe+0x44/0xa9
Oct 27 20:09:56 JPC kernel: [   90.066322] rcu: INFO: rcu_sched self-detected stall on CPU
Oct 27 20:09:56 JPC kernel: [   90.067547] rcu: 	2-....: (14973 ticks this GP) idle=196/1/0x4000000000000000 softirq=9490/9490 fqs=7487 
Oct 27 20:09:56 JPC kernel: [   90.068616] 	(t=15001 jiffies g=4217 q=7566)
Oct 27 20:09:56 JPC kernel: [   90.069651] NMI backtrace for cpu 2
Oct 27 20:09:56 JPC kernel: [   90.070692] CPU: 2 PID: 2267 Comm: nvidia-sleep.sh Tainted: P           OEL    5.11.0-38-generic #42~20.04.1-Ubuntu
Oct 27 20:09:56 JPC kernel: [   90.071770] Hardware name: ASUSTeK COMPUTER INC. K56CB/K56CB, BIOS K56CB.205 03/13/2013
Oct 27 20:09:56 JPC kernel: [   90.073838]  <IRQ>
Oct 27 20:09:56 JPC kernel: [   90.074820]  dump_stack+0x74/0x92
Oct 27 20:09:56 JPC kernel: [   90.075768]  ? lapic_can_unplug_cpu+0x80/0x80
Oct 27 20:09:56 JPC kernel: [   90.076695]  nmi_cpu_backtrace.cold+0x32/0x69
Oct 27 20:09:56 JPC kernel: [   90.077599]  nmi_trigger_cpumask_backtrace+0xe8/0xf0
Oct 27 20:09:56 JPC kernel: [   90.078498]  arch_trigger_cpumask_backtrace+0x19/0x20
Oct 27 20:09:56 JPC kernel: [   90.079341]  rcu_dump_cpu_stacks+0xae/0xe0
Oct 27 20:09:56 JPC kernel: [   90.080126]  rcu_sched_clock_irq.cold+0x23d/0x42a
Oct 27 20:09:56 JPC kernel: [   90.080905]  ? account_system_index_time+0x96/0xa0
Oct 27 20:09:56 JPC kernel: [   90.081675]  update_process_times+0x94/0xd0
Oct 27 20:09:56 JPC kernel: [   90.082440]  tick_sched_handle.isra.0+0x25/0x60
Oct 27 20:09:56 JPC kernel: [   90.083202]  tick_sched_timer+0x6d/0x80
Oct 27 20:09:56 JPC kernel: [   90.083951]  ? tick_sched_do_timer+0x50/0x50
Oct 27 20:09:56 JPC kernel: [   90.084690]  __hrtimer_run_queues+0xfb/0x230
Oct 27 20:09:56 JPC kernel: [   90.085417]  hrtimer_interrupt+0x109/0x220
Oct 27 20:09:56 JPC kernel: [   90.086134]  __sysvec_apic_timer_interrupt+0x64/0xe0
Oct 27 20:09:56 JPC kernel: [   90.086851]  asm_call_irq_on_stack+0x12/0x20
Oct 27 20:09:56 JPC kernel: [   90.087549]  </IRQ>
Oct 27 20:09:56 JPC kernel: [   90.088238]  sysvec_apic_timer_interrupt+0x81/0x90
Oct 27 20:09:56 JPC kernel: [   90.088944]  asm_sysvec_apic_timer_interrupt+0x12/0x20
Oct 27 20:09:56 JPC kernel: [   90.089651] RIP: 0010:_nv031760rm+0x200/0x440 [nvidia]
Oct 27 20:09:56 JPC kernel: [   90.090783] Code: a0 44 89 f8 45 09 e6 09 cb 45 31 e4 89 5c 85 40 44 89 74 95 40 31 db 46 8d 34 bd 08 00 00 00 eb 13 66 0f 1f 84 00 00 00 00 00 <48> 83 c3 
01 48 83 fb 08 74 29 41 0f a3 dd 73 f0 8b 3c 9d 1c 32 2c
Oct 27 20:09:56 JPC kernel: [   90.092392] RSP: 0018:ffffb844027b3ad0 EFLAGS: 00000296
Oct 27 20:09:56 JPC kernel: [   90.093221] RAX: 0000000000000000 RBX: 0000000000000007 RCX: 0000000000000000
Oct 27 20:09:56 JPC kernel: [   90.094067] RDX: ffffffffc22c32e0 RSI: ffff9e0d4ad6a900 RDI: ffffffffc22c32e0
Oct 27 20:09:56 JPC kernel: [   90.094929] RBP: ffff9e0d4ad6a8c0 R08: 0000000000000000 R09: ffff9e0d4ad6a914
Oct 27 20:09:56 JPC kernel: [   90.095793] R10: 00000000000008db R11: ffff9e0d526a50a0 R12: 0000000000000002
Oct 27 20:09:56 JPC kernel: [   90.096669] R13: 000000000000000e R14: 0000000000000014 R15: 0000000000000003
Oct 27 20:09:56 JPC kernel: [   90.097550] WARNING: kernel stack regs at 0000000006d5e9d3 in nvidia-sleep.sh:2267 has bad 'bp' value 00000000742a8a5c
Oct 27 20:09:56 JPC kernel: [   90.097553] unwind stack type:0 next_sp:0000000000000000 mask:0x6 graph_idx:0
Oct 27 20:09:56 JPC kernel: [   90.097555] 00000000164287d0: ffffb84400138d80 (0xffffb84400138d80)
Oct 27 20:09:56 JPC kernel: [   90.097558] 000000003cec40b4: ffffffff8d18dd92 (show_trace_log_lvl+0x20d/0x2f4)
Oct 27 20:09:56 JPC kernel: [   90.097562] 00000000822a1003: ffffffff8d200d42 (asm_sysvec_apic_timer_interrupt+0x12/0x20)
Oct 27 20:09:56 JPC kernel: [   90.097565] 00000000b7045e22: ffffb844027b3aa8 (0xffffb844027b3aa8)
Oct 27 20:09:56 JPC kernel: [   90.097567] 00000000e641d4aa: 0000000000000000 ...
Oct 27 20:09:56 JPC kernel: [   90.097568] 000000007e87e871: 0000000000138d18 (0x138d18)
Oct 27 20:09:56 JPC kernel: [   90.097569] 00000000f522585f: 0000000000000006 (0x6)
...

also didn’t work before I’ve installed nvidia-sleep.sh

should I try with other versions?

PS: as I read, I should remove these services while using 470 version driver:
sudo systemctl stop nvidia-suspend.service
sudo systemctl stop nvidia-hibernate.service
sudo systemctl stop nvidia-resume.service
sudo systemctl disable nvidia-suspend.service
sudo systemctl disable nvidia-hibernate.service
sudo systemctl disable nvidia-resume.service
sudo rm /lib/systemd/system-sleep/nvidia

so now the system stops freeze but doesn’t go to deep sleep:

Oct 28 08:43:39 JPC NetworkManager[1252]: <info>  [1635396219.8124] manager: sleep: sleep requested (sleeping: no  enabled: yes)
Oct 28 08:43:39 JPC ModemManager[1374]: <info>  [sleep-monitor] system is about to suspend
...
...
Oct 28 08:44:09 JPC systemd[1]: Reached target Sleep.
Oct 28 08:44:09 JPC systemd[1]: Starting Record successful boot for GRUB...
Oct 28 08:44:09 JPC systemd[1]: Starting Suspend...
Oct 28 08:44:09 JPC systemd[1]: grub-common.service: Succeeded.
Oct 28 08:44:09 JPC systemd[1]: Finished Record successful boot for GRUB.
Oct 28 08:44:09 JPC systemd[1]: Starting GRUB failed boot detection...
Oct 28 08:44:09 JPC systemd[1]: grub-initrd-fallback.service: Succeeded.
Oct 28 08:44:09 JPC systemd[1]: Finished GRUB failed boot detection.
Oct 28 08:44:09 JPC kernel: [  514.835874] PM: suspend entry (deep)
Oct 28 08:44:09 JPC systemd-sleep[4450]: Suspending system...
....
....
...
Oct 28 08:44:12 JPC kernel: [  517.366725] OOM killer enabled.
Oct 28 08:44:12 JPC kernel: [  517.367702] Restarting tasks ... done.
Oct 28 08:44:12 JPC kernel: [  517.496179] PM: suspend exit
Oct 28 08:44:12 JPC kernel: [  517.496248] PM: suspend entry (s2idle)
...
...
Oct 28 08:44:14 JPC kernel: [  519.545829] OOM killer enabled.
Oct 28 08:44:14 JPC kernel: [  519.546944] Restarting tasks ... done.
Oct 28 08:44:14 JPC acpid: client 1430[0:0] has disconnected
Oct 28 08:44:14 JPC acpid: client connected from 1430[0:0]
Oct 28 08:44:14 JPC acpid: 1 client rule loaded
Oct 28 08:44:14 JPC kernel: [  519.715060] mmc0: cannot verify signal voltage switch
Oct 28 08:44:15 JPC kernel: [  519.995397] PM: suspend exit
Oct 28 08:44:15 JPC systemd-sleep[4450]: Failed to suspend system. System resumed again: Input/output error
Oct 28 08:44:15 JPC systemd-sleep[4597]: /dev/sda:
Oct 28 08:44:15 JPC systemd-sleep[4597]:  setting Advanced Power Management level to 0xfe (254)
Oct 28 08:44:15 JPC systemd-sleep[4597]:  APM_level#011= 254
Oct 28 08:44:15 JPC systemd[1]: systemd-suspend.service: Main process exited, code=exited, status=1/FAILURE
Oct 28 08:44:15 JPC systemd[1]: systemd-suspend.service: Failed with result 'exit-code'.
Oct 28 08:44:15 JPC systemd[1]: Failed to start Suspend.
Oct 28 08:44:15 JPC systemd[1]: Dependency failed for Suspend.
Oct 28 08:44:15 JPC systemd[1]: suspend.target: Job suspend.target/start failed with result 'dependency'.
Oct 28 08:44:15 JPC systemd[1]: Stopped target Sleep.
Oct 28 08:44:15 JPC NetworkManager[1252]: <info>  [1635396255.7239] manager: sleep: wake requested (sleeping: yes  enabled: yes)
Oct 28 08:44:15 JPC ModemManager[1374]: <info>  [sleep-monitor] system is resuming

syslog (139.5 KB)
nvidia-bug-report.log.gz (246.4 KB)

Please see this:
https://forums.developer.nvidia.com/t/kernel-5-6-system-freeze-when-resuming-from-suspend-or-hibernate/121630/22?u=generix
Please start for testing with a 390 driver, if it works then, upgrade to 470 and use the nvidia-suspend/resume services.

I had a similiar issue withOpenSuSE Leap 15.3. (PC with two Nvidia GT 710). And disabling the nvidia suspend/resume services, i.e. going back to kernel callback, solved my problem …

I’ve tried to switch to 390 - didn’t work again, then upgraded to 470.86 -didn’t help.
Then I’ve found out about (inttf-nvidia-patcher: inttf NVIDIA 435.xx, 390.xx, 418.xx, 340.xx Patcher for Kernel 5.14/5.13/5.12 [BASH Script] – If Not True Then False - I hope this is without any viruses/trojans…). Tried it with version 418.113. And now my system and screen woke up, but when I tried to run something, the system stucks… I almost can’t do anything.
(each time I’ve tried with and without nvidia suspend services).

Do nvidia suspend services the same on every version? Shouldn’t I have reinstalled them each time?

So then maybe version matters or this patch helped… but anyway it’s not fully working,
and as I understand now again, it doesn’t matter about your hardware, and pointed errors in logs about your hardware, it really only depends on nvidia card/driver.

Now I think I will try with clean 418, then 415, and patched 390.
unfortunately, the 495 version doesn’t fit…

I’ll attach the last full log from reboot and last try. (with enabled nvidia-services almost the same errors except there is a pointer about CPU stuck to nvidia-sleep.sh like in logs above).[NV_2send|attachment].

(upload://mrl8KDxQfvrvilZ0Qm1KBZMKI1O) (654.1 KB)
send_dmesg (260.9 KB)

errors like this: watchdog: BUG: soft lockup - CPU#0 stuck for 23s! (after suspend)

ADDED:
I’ve installed Optimus & Bumblebee.
But if I try to go suspend mode with active optirun app, then the system freezes with a black screen.
But if I close this app that uses Nvidia card, then suspend goes well.
Today it’s like a nightmare, I’ve tried: {450|460|440|470}-server Nvidia driver, and also 340, 335, 390 again.
As I said the driver with patched made the system wake up but then I barely can do anything, just was able somehow to save some notes… (the same with other patched drives).

So maybe I should get used to closing those apps before suspending… because it’s better to buy a new card than spend days trying to fix it…