On Sun, Jul 05, 2026 at 12:12:46AM +0200, Nazarenko Mykyta wrote:
> Hi, bugs@!
> 
> I’ve been dealing with a problem for a while now.
> 
> My Ninkear A15 Pro laptop freezes when I try to put it into deep sleep
> mode or when I close the lid. It was really strange. The screen would
> just go dark for no reason, the laptop would stop responding to
> keystrokes, and the funny thing is that there was no kernel panic, the
> backlight stayed at maximum brightness, and I wasn’t switched to TTY.
> 
> I tried to identify the source of this problem, and I tried adding
> locks inside the dc_dmub_srv_fb_cmd_list_queue_execute() function
> to prevent race conditions ( which apparently do occur internally ).
> 
> I don't know if my decision was the right one, but it fixed the
> problem. After applying the patch I attached to the email, my laptop
> started waking up and going to sleep normally.
> 
> Diff attached.
> 
> What do you think about that?

The placement of locks in drm follows that of Linux.

The spin_lock types are handled as mtx.  The mutex types (which sleep)
are handled as rwlock.

There are no other spin_locks or mutexes in amd/display/dc/
they are in the interfaces to the dc code in amd/display/amdgpu_dm/

Blocking interrupts when Linux doesn't suggests the problem is elsewhere.

> 
> OpenBSD 7.9-current (amdgpu_test_dc_quick) #1: Wed Jul  1 13:19:31 CEST
> 2026
> [email protected]:/home/mykyta/Dev/kernel/src/sys/arch/amd64/compile/amdgpu_test_dc_quick
> real mem = 20777701376 (19815MB) avail mem = 20120072192 (19187MB)
> random: good seed from bootblocks
> mpath0 at root
> scsibus0 at mpath0: 256 targets
> mainbus0 at root
> bios0 at mainbus0: SMBIOS rev. 3.3 @ 0xed01f000 (45 entries)
> bios0: vendor American Megatrends International, LLC. version
> "AB8139_S_2C_V00.01_002" date 04/09/2025 bios0: AB8139 AB8139
> efi0 at bios0: UEFI 2.7
> efi0: American Megatrends rev 0x50013
> acpi0 at bios0: ACPI 6.2
> acpi0: sleep states S0 S3 S4 S5
> acpi0: tables DSDT FACP MSDM SSDT SSDT FIDT MCFG HPET FPDT VFCT BGRT
> TPM2 SSDT CRAT CDIT SSDT SSDT SSDT SSDT WSMT APIC IVRS SSDT SSDT acpi0:
> wakeup devices GPP0(S4) GPP2(S4) GPP4(S4) GPP5(S4) GP17(S4) XHC0(S3)
> XHC1(S3) GP18(S4) GP19(S4) LID0(S4) acpitimer0 at acpi0: 3579545 Hz, 32
> bits acpimcfg0 at acpi0 acpimcfg0: addr 0xf0000000, bus 0-127
> acpihpet0 at acpi0: 14318180 Hz
> acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
> cpu0 at mainbus0: apid 0 (boot processor)
> cpu0: AMD Ryzen 5 5500U with Radeon Graphics, 2100.01 MHz, 17-68-01,
> patch 08608108 cpu0: cpuid 1
> edx=178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT>
> ecx=76d8320b<SSE3,PCLMUL,MWAIT,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,RDRAND>
> cpu0: cpuid 6 eax=4<ARAT> ecx=1<EFFFREQ> cpu0: cpuid 7.0
> ebx=219c91a9<FSGSBASE,BMI1,AVX2,SMEP,BMI2,PQM,RDSEED,ADX,SMAP,CLFLUSHOPT,CLWB,SHA>
> ecx=400004<UMIP> cpu0: cpuid d.1 eax=f<XSAVEOPT,XSAVEC,XGETBV1,XSAVES>
> cpu0: cpuid 80000001 edx=2fd3fbff<NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG>
> ecx=75c237ff<LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,TCE,TOPEXT,CPCTR,DBKP,PCTRL3,MWAITX>
> cpu0: cpuid 80000007 edx=6799<HWPSTATE,ITSC> cpu0: cpuid 80000008
> ebx=90cf757<IBPB,IBRS,STIBP,IBRS_PREF,IBRS_SM,SSBD> cpu0: cpuid
> 8000001F eax=1000f<SME,SEV,PFLUSH_MSR,SEVES,VTE> ecx=e edx=1 cpu0: 32KB
> 64b/line 8-way D-cache, 32KB 64b/line 8-way I-cache, 512KB 64b/line
> 8-way L2 cache, 4MB 64b/line 16-way L3 cache cpu0: smt 0, core 0,
> package 0, type P mtrr: Pentium Pro MTRR support, 8 var ranges, 88
> fixed ranges cpu0: apic clock running at 100MHz cpu0: mwait min=64,
> max=64, C-substates=1.1, IBE cpu at mainbus0: not configured cpu at
> mainbus0: not configured cpu at mainbus0: not configured cpu at
> mainbus0: not configured cpu at mainbus0: not configured
> cpu at mainbus0: not configured
> cpu at mainbus0: not configured
> cpu at mainbus0: not configured
> cpu at mainbus0: not configured
> cpu at mainbus0: not configured
> cpu at mainbus0: not configured
> ioapic0 at mainbus0: apid 33 pa 0xfec00000, version 21, 24 pins, can't
> remap ioapic1 at mainbus0: apid 34 pa 0xfec01000, version 21, 32 pins,
> can't remap acpiprt0 at acpi0: bus 0 (PCI0)
> acpiprt1 at acpi0: bus -1 (GPP0)
> acpiprt2 at acpi0: bus -1 (GPP1)
> acpiprt3 at acpi0: bus 1 (GPP2)
> acpiprt4 at acpi0: bus -1 (GPP3)
> acpiprt5 at acpi0: bus -1 (GPP4)
> acpiprt6 at acpi0: bus 2 (GPP5)
> acpiprt7 at acpi0: bus -1 (GPP6)
> acpiprt8 at acpi0: bus 3 (GP17)
> acpiprt9 at acpi0: bus -1 (GP18)
> acpiprt10 at acpi0: bus -1 (GP19)
> acpiec0 at acpi0
> acpipci0 at acpi0 PCI0: 0x00000010 0x00000011 0x00000000
> acpicmos0 at acpi0
> acpiac0 at acpi0: AC unit online
> acpibat0 at acpi0: BAT0 model "Li-ion Real Battery" serial 123456789
> type Lion oem "AMD Battery" acpibtn0 at acpi0: LID0(wakeup)
> "INT33D3" at acpi0 not configured
> acpibtn1 at acpi0: SLPB
> "MSFT0001" at acpi0 not configured
> acpibtn2 at acpi0: PWRB
> "ACPI0010" at acpi0 not configured
> acpicpu0 at acpi0: C3(0@350 io@0x415), C2(0@18 io@0x414), C1(0@1
> mwait), PSS amdgpio0 at acpi0 GPIO uid 0 addr 0xfed81500/0x400 irq 7,
> 184 pins dwiic0 at acpi0 I2CA addr 0xfedc2000/0x1000 irq 10
> iic0 at dwiic0
> dwiic1 at acpi0 I2CB addr 0xfedc3000/0x1000 irq 11
> iic1 at dwiic1
> dwiic2 at acpi0 I2CD addr 0xfedc5000/0x1000 irq 6
> iic2 at dwiic2
> ihidev0 at iic2 addr 0x2c gpio 9, vendor 0x911 product 0x5288, PNP0C50
> ihidev0: 13 report ids
> imt0 at ihidev0: clickpad, 5 contacts
> wsmouse0 at imt0 mux 0
> ims0 at ihidev0 reportid 2: 2 buttons, Z and W dir
> wsmouse1 at ims0 mux 0
> hid at ihidev0 reportid 4 not configured
> hid at ihidev0 reportid 6 not configured
> hid at ihidev0 reportid 7 not configured
> hid at ihidev0 reportid 9 not configured
> hid at ihidev0 reportid 10 not configured
> hid at ihidev0 reportid 11 not configured
> hid at ihidev0 reportid 12 not configured
> hid at ihidev0 reportid 13 not configured
> tpm0 at acpi0 TPM_: unsupported TPM2 start method 2
> "PNP0C14" at acpi0 not configured
> acpipwrres0 at acpi0: P0SA, resource for SATA
> acpipwrres1 at acpi0: P0SA, resource for SAT1
> acpivideo0 at acpi0: VGA_
> acpivout0 at acpivideo0: LCD_
> cpu0: 2100 MHz: speeds: 2100 1700 1400 MHz
> pci0 at mainbus0 bus 0
> ksmn0 at pci0 dev 0 function 0 "AMD 17h/6xh Root Complex" rev 0x00
> "AMD 17h/6xh IOMMU" rev 0x00 at pci0 dev 0 function 2 not configured
> pchb0 at pci0 dev 1 function 0 "AMD 17h/6xh Host" rev 0x00
> ppb0 at pci0 dev 1 function 3 "AMD 17h/6xh PCIE" rev 0x00: msi
> pci1 at ppb0 bus 1
> iwm0 at pci1 dev 0 function 0 "Intel AC 8260" rev 0x3a, msi
> pchb1 at pci0 dev 2 function 0 "AMD 17h/6xh Host" rev 0x00
> ppb1 at pci0 dev 2 function 3 "AMD 17h/6xh PCIE" rev 0x00: msi
> pci2 at ppb1 bus 2
> nvme0 at pci2 dev 0 function 0 unknown vendor 0x1e4b product 0x1202 rev
> 0x01: msix, NVMe 1.4 nvme0: faspeed P8-512G-SE, firmware SN22613,
> serial SCRW25081205P0637 scsibus1 at nvme0: 2 targets, initiator 0
> sd0 at scsibus1 targ 1 lun 0: <NVMe, faspeed P8-512G-, SN22>
> sd0: 488386MB, 512 bytes/sector, 1000215216 sectors
> pchb2 at pci0 dev 8 function 0 "AMD 17h/6xh Host" rev 0x00
> ppb2 at pci0 dev 8 function 1 "AMD 17h/6xh PCIE" rev 0x00
> pci3 at ppb2 bus 3
> amdgpu0 at pci3 dev 0 function 0 "ATI Lucienne" rev 0xc2
> drm0 at amdgpu0
> amdgpu0: msi
> azalia0 at pci3 dev 0 function 1 "ATI Renoir HD Audio" rev 0x00: msi
> azalia0: no supported codecs
> ccp0 at pci3 dev 0 function 2 "AMD 17h/1xh Crypto" rev 0x00
> xhci0 at pci3 dev 0 function 3 "AMD 17h/6xh xHCI" rev 0x00: msix, xHCI
> 1.10 usb0 at xhci0: USB revision 3.0
> uhub0 at usb0 configuration 1 interface 0 "AMD xHCI root hub" rev
> 3.00/1.00 addr 1 xhci1 at pci3 dev 0 function 4 "AMD 17h/6xh xHCI" rev
> 0x00: msix, xHCI 1.10 usb1 at xhci1: USB revision 3.0
> uhub1 at usb1 configuration 1 interface 0 "AMD xHCI root hub" rev
> 3.00/1.00 addr 1 "AMD 17h/1xh I2S Audio" rev 0x01 at pci3 dev 0
> function 5 not configured azalia1 at pci3 dev 0 function 6 "AMD 17h/1xh
> HD Audio" rev 0x00: msi azalia1: codecs: Realtek ALC269
> audio0 at azalia1
> vendor "AMD", unknown product 0x15e4 (class DASP subclass
> miscellaneous, rev 0x00) at pci3 dev 0 function 7 not configured
> piixpm0 at pci0 dev 20 function 0 "AMD FCH SMBus" rev 0x51: SMI
> iic3 at piixpm0
> spdmem0 at iic3 addr 0x50: 4GB DDR4 SDRAM PC4-25600 SO-DIMM
> spdmem1 at iic3 addr 0x51: 16GB DDR4 SDRAM PC4-21300 SO-DIMM
> iic4 at piixpm0
> pcib0 at pci0 dev 20 function 3 "AMD FCH LPC" rev 0x51
> pchb3 at pci0 dev 24 function 0 "AMD 17h/6xh Data Fabric" rev 0x00
> pchb4 at pci0 dev 24 function 1 "AMD 17h/6xh Data Fabric" rev 0x00
> pchb5 at pci0 dev 24 function 2 "AMD 17h/6xh Data Fabric" rev 0x00
> pchb6 at pci0 dev 24 function 3 "AMD 17h/6xh Data Fabric" rev 0x00
> pchb7 at pci0 dev 24 function 4 "AMD 17h/6xh Data Fabric" rev 0x00
> pchb8 at pci0 dev 24 function 5 "AMD 17h/6xh Data Fabric" rev 0x00
> pchb9 at pci0 dev 24 function 6 "AMD 17h/6xh Data Fabric" rev 0x00
> pchb10 at pci0 dev 24 function 7 "AMD 17h/6xh Data Fabric" rev 0x00
> isa0 at pcib0
> isadma0 at isa0
> pckbc0 at isa0 port 0x60/5 irq 1 irq 12
> pckbd0 at pckbc0 (kbd slot)
> wskbd0 at pckbd0: console keyboard
> pcppi0 at isa0 port 0x61
> spkr0 at pcppi0
> vmm0 at mainbus0: SVM/RVI
> efifb at mainbus0 not configured
> uvideo0 at uhub0 port 3 configuration 1 interface 0 "XXS-250805-J RGB
> Camera" rev 2.00/8.05 addr 2 video0 at uvideo0
> uhidev0 at uhub1 port 2 configuration 1 interface 0 "Compx 2.4G
> Receiver" rev 1.10/2.41 addr 2 uhidev0: iclass 3/1
> ukbd0 at uhidev0: 8 variable keys, 6 key codes
> wskbd1 at ukbd0 mux 1
> uhidev1 at uhub1 port 2 configuration 1 interface 1 "Compx 2.4G
> Receiver" rev 1.10/2.41 addr 2 uhidev1: iclass 3/1, 6 report ids
> ums0 at uhidev1 reportid 1: 5 buttons, Z and W dir
> wsmouse2 at ums0 mux 0
> uhid0 at uhidev1 reportid 2: input=7, output=0, feature=0
> uhid1 at uhidev1 reportid 3: input=1, output=0, feature=0
> uhid2 at uhidev1 reportid 4: input=1, output=0, feature=0
> ucc0 at uhidev1 reportid 5: 573 usages, 20 keys, array
> wskbd2 at ucc0 mux 1
> uhid3 at uhidev1 reportid 6: input=0, output=0, feature=7
> ugen0 at uhub1 port 3 "Intel Bluetooth" rev 2.00/0.01 addr 3
> uhub2 at uhub1 port 4 configuration 1 interface 0 "Genesys Logic USB2.0
> Hub" rev 2.00/88.11 addr 4 ugen1 at uhub2 port 2 "Blestech Betterlife
> Fingerprint" rev 2.00/2.00 addr 5 vscsi0 at root
> scsibus2 at vscsi0: 256 targets
> softraid0 at root
> scsibus3 at softraid0: 256 targets
> root on sd0a (ab2f272cb5524e1c.a) swap on sd0b dump on sd0b
> iwm0: hw rev 0x200, fw ver 36.ca7b901d.0, address 04:d3:b0:d3:51:80
> amdgpu0: RENOIR GC 9.3.0 7 CU rev 0x00

> Index: dc_dmub_srv.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/drm/amd/display/dc/dc_dmub_srv.c,v
> diff -u -p -u -r1.10 dc_dmub_srv.c
> --- dc_dmub_srv.c     7 May 2026 06:31:44 -0000       1.10
> +++ dc_dmub_srv.c     4 Jul 2026 21:46:40 -0000
> @@ -23,6 +23,7 @@
>   *
>   */
>  
> +#include <sys/mutex.h>
>  #include "dm_services.h"
>  #include "dc.h"
>  #include "dc_dmub_srv.h"
> @@ -41,6 +42,8 @@
>  #define DC_LOGGER CTX->logger
>  #define GPINT_RETRY_NUM 20
>  
> +static mutex dmub_fb_cmd_queue_lock = MUTEX_INITIALIZER(IPL_TTY);
> +
>  static void dc_dmub_srv_construct(struct dc_dmub_srv *dc_srv, struct dc *dc,
>                                 struct dmub_srv *dmub)
>  {
> @@ -192,6 +195,8 @@ static bool dc_dmub_srv_fb_cmd_list_queu
>       dc_ctx = dc_dmub_srv->ctx;
>       dmub = dc_dmub_srv->dmub;
>  
> +     mtx_enter(&dmub_fb_cmd_queue_lock);
> +
>       for (i = 0 ; i < count; i++) {
>               // Queue command
>               if (!cmd_list[i].cmd_common.header.multi_cmd_pending ||
> @@ -204,8 +209,10 @@ static bool dc_dmub_srv_fb_cmd_list_queu
>               if (status == DMUB_STATUS_QUEUE_FULL) {
>                       /* Execute and wait for queue to become empty again. */
>                       status = dmub_srv_fb_cmd_execute(dmub);
> -                     if (status == DMUB_STATUS_POWER_STATE_D3)
> +                     if (status == DMUB_STATUS_POWER_STATE_D3) {
> +                             mtx_leave(&dmub_fb_cmd_queue_lock);
>                               return false;
> +                     }
>  
>                       do {
>                                       status = 
> dmub_srv_wait_for_inbox_free(dmub, 100000, count - i);
> @@ -220,11 +227,13 @@ static bool dc_dmub_srv_fb_cmd_list_queu
>                               DC_ERROR("Error queueing DMUB command: 
> status=%d\n", status);
>                               dc_dmub_srv_log_diagnostic_data(dc_dmub_srv);
>                       }
> +                     mtx_leave(&dmub_fb_cmd_queue_lock);
>                       return false;
>               }
>       }
>  
>       status = dmub_srv_fb_cmd_execute(dmub);
> +     mtx_leave(&dmub_fb_cmd_queue_lock);
>       if (status != DMUB_STATUS_OK) {
>               if (status != DMUB_STATUS_POWER_STATE_D3) {
>                       DC_ERROR("Error starting DMUB execution: status=%d\n", 
> status);

Reply via email to