Web lists-archives.com

[PATCH 3/3] drm/ttm: Fix ttm_bo_glob.kobj state on cleanup




Cleanup ttm_bo_glob.kobj when its reference count hits 0
so that it can be re-initialized by future ttm_bo_global_init calls
without dumping a stack trace.

Signed-off-by: Brian Yip <itsbriany@xxxxxxxxx>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 988416fb8a0b..1e1844f4a4fa 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1535,6 +1535,10 @@ static void ttm_bo_global_release(void)
 	kobject_del(&glob->kobj);
 	kobject_put(&glob->kobj);
 	ttm_mem_global_release(&ttm_mem_glob);
+
+	if (!kref_read(&glob->kobj.kref))
+		glob->kobj.state_initialized = 0;
+
 out:
 	mutex_unlock(&ttm_global_mutex);
 }
-- 
2.20.1