public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Yip <itsbriany@gmail.com>
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 <itsbriany@gmail.com>
Subject: [PATCH v2 2/2] drm/ttm: Reset ttm_bo_glob when initialized
Date: Tue, 16 Apr 2019 01:50:35 +0000	[thread overview]
Message-ID: <20190416015035.1435-3-itsbriany@gmail.com> (raw)
In-Reply-To: <20190416015035.1435-1-itsbriany@gmail.com>

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@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


      parent reply	other threads:[~2019-04-16  1:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-16  1:50 [PATCH v2 0/2] drm/ttm: Cleanup state in global ttm structures Brian Yip
2019-04-16  1:50 ` [PATCH v2 1/2] drm/ttm: Reset ttm_mem_global when initialized Brian Yip
2019-04-16  1:50 ` Brian Yip [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190416015035.1435-3-itsbriany@gmail.com \
    --to=itsbriany@gmail.com \
    --cc=Jerry.Zhang@amd.com \
    --cc=airlied@linux.ie \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ray.huang@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox