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 1/2] drm/ttm: Reset ttm_mem_global when initialized
Date: Tue, 16 Apr 2019 01:50:34 +0000 [thread overview]
Message-ID: <20190416015035.1435-2-itsbriany@gmail.com> (raw)
In-Reply-To: <20190416015035.1435-1-itsbriany@gmail.com>
Certain attributes such as num_zones and kobj in the
ttm_mem_global structure were never reset after calling
ttm_mem_global_release(). Consequently, when multiple GPU drivers
are loaded, and the first one fails to load its firmware, the second
driver will attempt to load its own firmware. Initializing the
second driver invokes ttm_mem_global_init where ttm_mem_global.num_zones
is eventually incremented beyond TTM_MEM_MAX_ZONES.
ttm_mem_global.num_zones is then used to dereference a ttm_mem_zone beyond
the amount of ttm_mem_zones allocated, resulting in a crash.
Zero initialize the ttm_mem_global structure such that its state will
be pristine and thus, ready to be re-initialized.
Signed-off-by: Brian Yip <itsbriany@gmail.com>
---
drivers/gpu/drm/ttm/ttm_memory.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
index 699fed9e08ee..73b461d5a4c0 100644
--- a/drivers/gpu/drm/ttm/ttm_memory.c
+++ b/drivers/gpu/drm/ttm/ttm_memory.c
@@ -419,6 +419,8 @@ int ttm_mem_global_init(struct ttm_mem_global *glob)
int i;
struct ttm_mem_zone *zone;
+ memset(glob, 0, sizeof(struct ttm_mem_global));
+
spin_lock_init(&glob->lock);
glob->swap_queue = create_singlethread_workqueue("ttm_swap");
INIT_WORK(&glob->work, ttm_shrink_work);
--
2.20.1
next prev 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 ` Brian Yip [this message]
2019-04-16 1:50 ` [PATCH v2 2/2] drm/ttm: Reset ttm_bo_glob when initialized Brian Yip
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-2-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