From: Brian Yip Subject: [PATCH v2 2/2] drm/ttm: Reset ttm_bo_glob when initialized Date: Tue, 16 Apr 2019 01:50:35 +0000 Message-ID: <20190416015035.1435-3-itsbriany@gmail.com> References: <20190416015035.1435-1-itsbriany@gmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20190416015035.1435-1-itsbriany@gmail.com> Sender: linux-kernel-owner@vger.kernel.org To: christian.koenig@amd.com Cc: ray.huang@amd.com, Jerry.Zhang@amd.com, airlied@linux.ie, daniel@ffwll.ch, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Brian Yip List-Id: dri-devel@lists.freedesktop.org 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 --- 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