NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/58994: System panic with amdgpu and startx



The following reply was made to PR kern/58994; it has been noted by GNATS.

From: Robert Bagdan <kikadf.01%gmail.com@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/58994: System panic with amdgpu and startx
Date: Thu, 3 Dec 2026 13:49:36 +0100

 I tried again with my RX550 vga on NetBSD-11 branch. The crash has
 come again, but now the crash dump works.
 
 dmesg:
 [   315,841454] panic: unlocking unlocked wait/wound mutex: 0xffff81bcb68c7520
 [   315,841454] cpu0: Begin traceback...
 [   315,841454] vpanic() at netbsd:vpanic+0x171
 [   315,841454] panic() at netbsd:panic+0x3c
 [   315,841454] linux_ww_mutex_unlock() at netbsd:linux_ww_mutex_unlock+0x8d
 [   315,841454] ttm_bo_release() at netbsd:ttm_bo_release+0xf8
 [   315,841454] amdgpu_bo_unref() at amdgpu:amdgpu_bo_unref+0x1d
 [   315,841454] amdgpu_vm_free_table() at amdgpu:amdgpu_vm_free_table+0x53
 [   315,841454] amdgpu_vm_free_pts() at amdgpu:amdgpu_vm_free_pts+0xf4
 [   315,841454] amdgpu_vm_fini() at amdgpu:amdgpu_vm_fini+0x219
 [   315,841454] amdgpu_driver_postclose_kms() at
 amdgpu:amdgpu_driver_postclose_kms+0x133
 [   315,841454] drm_file_free() at netbsd:drm_file_free+0x1f6
 [   315,841454] drm_close() at netbsd:drm_close+0x5a
 [   315,841454] closef() at netbsd:closef+0x8a
 [   315,841454] fd_close() at netbsd:fd_close+0x134
 [   315,841454] sys_close() at netbsd:sys_close+0x1e
 [   315,841454] syscall() at netbsd:syscall+0x9a
 [   315,841454] --- syscall (number 6) ---
 [   315,841454] netbsd:syscall+0x9a:
 [   315,841454] cpu0: End traceback...
 
 [   315,841454] dumping to dev 168,2 (offset=8, size=16668651):
 [   315,841454] dump WARNING: lwp 349 (system ioflush) flags
 0x20020020: timecounter went backwards from (316 +
 0xbbab369057ec1eda/2^64) sec to (315 + 0xe05d0a7265cf1424/2^64) sec in
 netbsd:mi_switch+0x64
 [   315,841454] WARNING: lwp 349 (system ioflush): negative runtime:
 (-1 + 0x9b5b3ca6530e2f52/2^64) sec
 WARNING: pid 17688 (xinit): negative runtime; monotonic clock has gone backwards
 
 bt:
 Crash version 11.0_STABLE, image version 11.0_STABLE.
 Kernel compiled without options LOCKDEBUG.
 System panicked: unlocking unlocked wait/wound mutex: 0xffff81bcb68c7520
 Backtrace from time of crash is available.
 vmx_insn_failinvalid() at 0
 kern_reboot() at kern_reboot+0x93
 vpanic() at vpanic+0x17b
 panic() at vprintf
 linux_ww_mutex_unlock() at linux_ww_mutex_locking_ctx
 ttm_bo_release() at ttm_bo_release+0xf8
 amdgpu_bo_unref() at amdgpu_bo_unref+0x1d
 amdgpu_vm_free_table() at amdgpu_vm_free_table+0x53
 amdgpu_vm_free_pts() at amdgpu_vm_free_pts+0xf4
 amdgpu_vm_fini() at amdgpu_vm_fini+0x219
 amdgpu_driver_postclose_kms() at amdgpu_driver_postclose_kms+0x133
 drm_file_free() at drm_file_free+0x1f6
 drm_close() at drm_close+0x5a
 closef() at closef+0x8a
 fd_close() at fd_close+0x134
 sys_close() at sys_close+0x1e
 syscall() at syscall+0x9a
 
 
 The static ttm_bo_individualize_resv() inlined over the static
 ttm_bo_cleanup_refs_or_queue() into ttm_bo_release().
 
 The BUG_ON is defined in sys/external/bsd/common/include/asm/bug.h:
 #define BUG() panic("%s:%d: BUG!", __FILE__, __LINE__)
 #define BUG_ON(CONDITION) KASSERT(!(CONDITION))
 
 and KASSERT is defined in sys/lib/libkern/libkern.h:
 #ifndef DIAGNOSTIC
 #define _DIAGASSERT(a) (void)0
 #ifdef lint
 #define KASSERTMSG(e, msg, ...) /* NOTHING */
 #define KASSERT(e) /* NOTHING */
 #else /* !lint */
 /*
  * Make sure the expression compiles, but don't evaluate any of it.  We
  * use sizeof to inhibit evaluation, and cast to long so the expression
  * can be integer- or pointer-valued without bringing in other header
  * files.
  */
 #define KASSERTMSG(e, msg, ...) ((void)sizeof((long)(e)))
 #define KASSERT(e) ((void)sizeof((long)(e)))
 #endif /* !lint */
 #else /* DIAGNOSTIC */
 #define _DIAGASSERT(a) assert(a)
 #define KASSERTMSG(e, msg, ...) \
 (__predict_true((e)) ? (void)0 :    \
    kern_assert(__KASSERTSTR msg, "diagnostic ", #e,    \
 __FILE__, __LINE__, ## __VA_ARGS__))
 
 #define KASSERT(e) (__predict_true((e)) ? (void)0 :    \
    kern_assert(__KASSERTSTR, "diagnostic ", #e,    \
 __FILE__, __LINE__))
 #endif
 
 
 So, without DIAGNOSTIC it seems that in ttm_bo_individualize_resv():
 BUG_ON(!dma_resv_trylock(&bo->base._resv));
 the dma_resv_trylock doesn't executed.
 
 After in ttm_bo_cleanup_refs_or_queue():
 ret = dma_resv_trylock(bo->base.resv) ? 0 : -EBUSY;
 return with -EBUSY and finally dma_resv_unlock(&bo->base._resv)
 unlocks a ww_mutex that was never taken:
 System panicked: unlocking unlocked wait/wound mutex: 0xffff81bcb68c7520
 
 
 Linux's BUG_ON in include/asm-generic/bug.h
 #ifndef HAVE_ARCH_BUG
 #define BUG() do { \
 printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
 barrier_before_unreachable(); \
 panic("BUG!"); \
 } while (0)
 #endif
 #ifndef HAVE_ARCH_BUG_ON
 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
 #endif
 
 Based on linux I changed NetBSD's BUG_ON:
 diff --git a/sys/external/bsd/common/include/asm/bug.h
 b/sys/external/bsd/common/include/asm/bug.h
 index 5bc4137ab7a0..c86f704c6233 100644
 --- a/sys/external/bsd/common/include/asm/bug.h
 +++ b/sys/external/bsd/common/include/asm/bug.h
 @@ -38,7 +38,7 @@
  #include <linux/build_bug.h>   /* XXX */
 
  #define        BUG()                   panic("%s:%d: BUG!", __FILE__, __LINE__)
 -#define        BUG_ON(CONDITION)       KASSERT(!(CONDITION))
 +#define        BUG_ON(CONDITION)       do { if
 (__predict_false(CONDITION)) BUG(); } while (0)
 
  /* XXX Rate limit?  */
  #define WARN(CONDITION, FMT, ...)                                      \
 
 
 and this crash is gone for me.
 Maybe this is relevant for kern/58032 and kern/59275.
 



Home | Main Index | Thread Index | Old Index