[PATCH v2 2/2] drm/ttm: Reset ttm_bo_glob when initialized

Brian Yip itsbriany at gmail.com
Tue Apr 16 01:50:35 UTC 2019


Always initialize ttm_bo_glob from a pristine state when its use_count
is 0. Persist use_count so that ttm_bo_glob can later be released.

Signed-off-by: Brian Yip <itsbriany at gmail.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 988416fb8a0b..d95762a90654 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1543,12 +1543,16 @@ static int ttm_bo_global_init(void)
 {
 	struct ttm_bo_global *glob = &ttm_bo_glob;
 	int ret = 0;
-	unsigned i;
+	unsigned i, uc;
 
 	mutex_lock(&ttm_global_mutex);
 	if (++glob->use_count > 1)
 		goto out;
 
+	uc = glob->use_count;
+	memset(glob, 0, sizeof(struct ttm_bo_global));
+	glob->use_count = uc;
+
 	ret = ttm_mem_global_init(&ttm_mem_glob);
 	if (ret)
 		goto out;
-- 
2.20.1



More information about the dri-devel mailing list