]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe: Use drmm_mutex_init for VRAM manager lock
authorTejas Upadhyay <tejas.upadhyay@intel.com>
Wed, 29 Apr 2026 09:31:39 +0000 (15:01 +0530)
committerTejas Upadhyay <tejas.upadhyay@intel.com>
Thu, 30 Apr 2026 10:12:21 +0000 (15:42 +0530)
Replace mutex_init()/mutex_destroy() with drmm_mutex_init() for the
VRAM manager lock. This leverages DRM managed infrastructure to
automatically destroy the mutex during device teardown, eliminating
manual mutex_destroy() calls in both the normal fini path and the
gpu_buddy_init() error path.

Assisted-by: Claude:claude-opus-4.6
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20260429093138.3899280-2-tejas.upadhyay@intel.com
Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
drivers/gpu/drm/xe/xe_ttm_vram_mgr.c

index 5fd0d5506a7ea067fdb3c581ce29dfb7145260d0..6ba47996bc7c106b88a31665b9218d23053189d8 100644 (file)
@@ -292,8 +292,6 @@ static void xe_ttm_vram_mgr_fini(struct drm_device *dev, void *arg)
        ttm_resource_manager_cleanup(&mgr->manager);
 
        ttm_set_driver_manager(&xe->ttm, mgr->mem_type, NULL);
-
-       mutex_destroy(&mgr->lock);
 }
 
 int __xe_ttm_vram_mgr_init(struct xe_device *xe, struct xe_ttm_vram_mgr *mgr,
@@ -312,7 +310,9 @@ int __xe_ttm_vram_mgr_init(struct xe_device *xe, struct xe_ttm_vram_mgr *mgr,
 
        man->func = &xe_ttm_vram_mgr_func;
        mgr->mem_type = mem_type;
-       mutex_init(&mgr->lock);
+       err = drmm_mutex_init(&xe->drm, &mgr->lock);
+       if (err)
+               return err;
        mgr->default_page_size = default_page_size;
        mgr->visible_size = io_size;
        mgr->visible_avail = io_size;