--- a/sys/dev/drm/amd/amdgpu/amdgpu_mn.c +++ b/sys/dev/drm/amd/amdgpu/amdgpu_mn.c @@ -83,6 +83,7 @@ /* objects protected by lock */ struct rw_semaphore lock; struct rb_root_cached objects; struct lock read_lock; atomic_t recursion; + struct kref kref; }; @@ -394,8 +395,10 @@ hash_for_each_possible(adev->mn_hash, amn, node, key) if (AMDGPU_MN_KEY(amn->mm, amn->type) == key) + kref_get(&amn->kref); goto release_locks; amn = kzalloc(sizeof(*amn), GFP_KERNEL); @@ -410,6 +413,7 @@ amn->mn.ops = &amdgpu_mn_ops[type]; amn->objects = RB_ROOT_CACHED; mutex_init(&amn->read_lock); atomic_set(&amn->recursion, 0); + kref_init(&amn->kref); r = __mmu_notifier_register(&amn->mn, mm); --- a/sys/dev/drm/amd/amdgpu/amdgpu_mn.h +++ b/sys/dev/drm/amd/amdgpu/amdgpu_mn.h @@ -44,6 +44,12 @@ #else +/* + * WARNING: DragonFly has no MMU-notifier implementation behind + * ; amdgpu_mn.c is deliberately NOT in the module + * build. These stubs keep userptr BOs uncreatable (-ENODEV) and the CS + * path lock-free on a NULL mn. Do not define CONFIG_MMU_NOTIFIER until + * sys/vm grows real invalidate_range_start/end + release hooks that the + * shim's registration API actually wires into. + */ static inline void amdgpu_mn_lock(struct amdgpu_mn *mn) {} static inline void amdgpu_mn_unlock(struct amdgpu_mn *mn) {}