From: Lucas De Marchi Date: Sat, 25 Feb 2023 00:21:37 +0000 (-0800) Subject: drm/xe/device: Prefer the drm-managed mutex_init X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=3ea9f1f1f699c44b3064006b51566ed6accc6a53;p=linux.git drm/xe/device: Prefer the drm-managed mutex_init There's inconsistent use of mutex_init(), in xe_device_create(), with several of them never calling mutex_destroy() in xe_device_destroy(). Migrate all of them to drmm_mutex_init(), so the destroy part is automatically called. Signed-off-by: Lucas De Marchi Reviewed-by: Matt Roper Link: https://lore.kernel.org/r/20230225002138.1759016-2-lucas.demarchi@intel.com Signed-off-by: Rodrigo Vivi --- diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c index 00e8ed2353534..8a9f1e5ce34d8 100644 --- a/drivers/gpu/drm/xe/xe_device.c +++ b/drivers/gpu/drm/xe/xe_device.c @@ -155,7 +155,6 @@ static void xe_device_destroy(struct drm_device *dev, void *dummy) struct xe_device *xe = to_xe_device(dev); destroy_workqueue(xe->ordered_wq); - mutex_destroy(&xe->persitent_engines.lock); ttm_device_fini(&xe->ttm); } @@ -187,10 +186,10 @@ struct xe_device *xe_device_create(struct pci_dev *pdev, init_waitqueue_head(&xe->ufence_wq); - mutex_init(&xe->usm.lock); + drmm_mutex_init(&xe->drm, &xe->usm.lock); xa_init_flags(&xe->usm.asid_to_vm, XA_FLAGS_ALLOC1); - mutex_init(&xe->persitent_engines.lock); + drmm_mutex_init(&xe->drm, &xe->persitent_engines.lock); INIT_LIST_HEAD(&xe->persitent_engines.list); spin_lock_init(&xe->pinned.lock); @@ -200,14 +199,15 @@ struct xe_device *xe_device_create(struct pci_dev *pdev, xe->ordered_wq = alloc_ordered_workqueue("xe-ordered-wq", 0); - mutex_init(&xe->sb_lock); + drmm_mutex_init(&xe->drm, &xe->sb_lock); xe->enabled_irq_mask = ~0; err = drmm_add_action_or_reset(&xe->drm, xe_device_destroy, NULL); if (err) goto err_put; - mutex_init(&xe->mem_access.lock); + drmm_mutex_init(&xe->drm, &xe->mem_access.lock); + return xe; err_put: