Suspending to ram disables sysfs backlight

So I have another “fun” problem with my razer laptop: when the system wakes from suspend to ram (mem_sleep=[deep]) the backlight can no longer be changed.

I mean that neither, brightnessctl (which I usually use), xbacklight nor writing directly to /sys/class/backlight/nvidia_wmi_ec_backlight/brightness have any effect on the actual brightness of the screen. They do however all appear to work, ie the value in /sys/.../brightness does actually change and the utilities report successful execution.

To my (admittedly newby) eyes there was nothing in the journalctl output that indicates a problem when waking from sleep.

Here is what I have tried so far:

  • Set the acpi_backlight parameter to vendor, native, video and nvidia_wmi_ec. The parameter was not set before and neither of these settings helped. (With some it was actually impossible to change the backlight even after booting).

  • Change the nvidia-drm.modeset to 0 (was 1).

  • Restarting the systemd-backlight@backlight:nvidia_wmi_ec_backlight.service (it wasn’t reporting any errors).

  • Changing mem_sleep back to s2idle, this “works” but is a last resort as this laptops battery drains quite fast in this suspend state.

I will add that it is possible to change the brightness using xrandr, so this I’m mostly asking out of curiosity. (And because I’m not keen on writing a script parsing the xrandr --verbose output to incrementally adjust the brightness.)
If anyone has any more ideas I could try or places I could look for errors please let me know.

xrandr works by changing the gamma values, not the actual backlight, so this is mainly useful for relatively bright environments (since the actual backlight is at full brightness).
An advantage of using this is that it lets me change the brightness of an external display.