I have a Lenovo Legion Slim 7 laptop (15ACH6) running Manjaro 21.2.3 on kernel 5.17.

The problem I am facing is that on a clean boot, I cannot change the system brightness (using Fn keys or changing the actual value of `brightness` in `/sys/class/backlight`). However, after putting the system to sleep and then resuming, the brightness controls work just fine -- although the brightness level is not preserved.

Contents of `/sys/class/backlight`:

```
amdgpu_bl1 -> ../../devices/pci0000:00/0000:00:08.1/0000:05:00.0/backlight/amdgpu_bl1/
nvidia_0 -> ../../devices/pci0000:00/0000:00:01.1/0000:01:00.0/backlight/nvidia_0/
nvidia_wmi_ec_backlight -> ../../devices/pci0000:00/PNP0C14:00/wmi_bus/wmi_bus-PNP0C14:00/603E9613-EF25-4338-A3D0-C46177516DB7/backlight/nvidia_wmi_ec_backlight/

```

The **actual** brightness value is written to the `nvidia_wmi_ec_backlight/brightness` file, the other 2 stay the same.

Loaded nVidia kernel modules:

```
nvidia_uvm           2650112  0
nvidia_drm             73728  2
nvidia_modeset       1163264  3 nvidia_drm
nvidia_wmi_ec_backlight    16384  0
nvidia              39133184  99 nvidia_uvm,nvidia_modeset
wmi                    40960  3 nvidia_wmi_ec_backlight,wmi_bmof,ideapad_laptop

```

On kernels < 5.16, the `nvidia_wmi_ec_backlight` module is not present, and I cannot change the brightness whatsoever. I am wondering what causes this module to behave correctly **only after resuming from sleep**.

I am suspecting some kind of **race condition** or **improper initialization**. What kind of investigation should I do in order to understand this behaviour?

---

The source code for the kernel module is here: [`nvidia-wmi-ec-backlight.c`](https://elixir.bootlin.com/linux/v5.17-rc3/source/drivers/platform/x86/nvidia-wmi-ec-backlight.c).

---

Output of `inxi -Fz`:

```
System:
  Kernel: 5.17.0-1-MANJARO x86_64 bits: 64 Desktop: GNOME 41.3
    Distro: Manjaro Linux
Machine:
  Type: Laptop System: LENOVO product: 82K8 v: Legion S7 15ACH6
    serial: <superuser required>
  Mobo: LENOVO model: LNVNB161216 v: NO DPK serial: <superuser required>
    UEFI: LENOVO v: HACN27WW date: 08/02/2021
Battery:
  ID-1: BAT0 charge: 64.3 Wh (90.6%) condition: 71.0/71.0 Wh (100.0%)
CPU:
  Info: 8-core model: AMD Ryzen 9 5900HX with Radeon Graphics bits: 64
    type: MT MCP cache: L2: 4 MiB
  Speed (MHz): avg: 1526 min/max: 400/4680 cores: 1: 1397 2: 1397 3: 1397
    4: 1395 5: 1396 6: 1395 7: 1397 8: 1397 9: 1397 10: 3482 11: 1395 12: 1396
    13: 1396 14: 1395 15: 1397 16: 1397
Graphics:
  Device-1: NVIDIA GA106M [GeForce RTX 3060 Mobile / Max-Q] driver: nvidia
    v: 510.47.03
  Device-2: AMD Cezanne driver: amdgpu v: kernel
  Device-3: Syntek Integrated Camera type: USB driver: uvcvideo
  Display: x11 server: X.org 1.21.1.3 driver: loaded: amdgpu,ati,nvidia
    unloaded: modesetting,nouveau,radeon resolution: <missing: xdpyinfo>
  OpenGL: renderer: AMD RENOIR (DRM 3.44.0 5.17.0-1-MANJARO LLVM 13.0.0)
    v: 4.6 Mesa 21.3.5
Audio:
  Device-1: NVIDIA driver: snd_hda_intel
  Device-2: AMD Raven/Raven2/FireFlight/Renoir Audio Processor driver: N/A
  Device-3: AMD Family 17h HD Audio driver: snd_hda_intel
  Sound Server-1: ALSA v: k5.17.0-1-MANJARO running: yes
  Sound Server-2: PulseAudio v: 15.0 running: yes
Network:
  Device-1: Intel Wi-Fi 6 AX200 driver: iwlwifi
  IF: wlp2s0 state: up mac: <filter>
Bluetooth:
  Device-1: Intel AX200 Bluetooth type: USB driver: btusb
  Report: rfkill ID: hci0 rfk-id: 4 state: down bt-service: enabled,running
    rfk-block: hardware: no software: yes address: see --recommends
Drives:
  Local Storage: total: 953.87 GiB used: 169.04 GiB (17.7%)
  ID-1: /dev/nvme0n1 vendor: SK Hynix model: HFS001TDE9X084N
    size: 953.87 GiB
Partition:
  ID-1: / size: 905.83 GiB used: 169.04 GiB (18.7%) fs: ext4
    dev: /dev/nvme0n1p3
  ID-2: /boot/efi size: 511 MiB used: 288 KiB (0.1%) fs: vfat
    dev: /dev/nvme0n1p1
Swap:
  ID-1: swap-1 type: partition size: 32 GiB used: 0 KiB (0.0%)
    dev: /dev/nvme0n1p2
Sensors:
  System Temperatures: cpu: N/A mobo: N/A
  Fan Speeds (RPM): N/A
Info:
  Processes: 452 Uptime: 8m Memory: 30.79 GiB used: 3.68 GiB (12.0%)
  Shell: Zsh inxi: 3.3.12

```

---

**Update:** It appears that on a clean boot I can control the brightness using the `amdgpu_bl1` controller:

```
echo 50 | sudo tee /sys/class/backlight/amdgpu_bl1/brightness

```

After resuming from sleep, `nvidia_wmi_ec_backlight` becomes responsible.