]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.54/drm-etnaviv-lock-mmu-while-dumping-core.patch
Linux 4.19.54
[thirdparty/kernel/stable-queue.git] / releases / 4.19.54 / drm-etnaviv-lock-mmu-while-dumping-core.patch
CommitLineData
a15a8890
SL
1From d57d05abde0ff390edde2585727f5b8b8c93e412 Mon Sep 17 00:00:00 2001
2From: Lucas Stach <l.stach@pengutronix.de>
3Date: Tue, 21 May 2019 14:53:40 +0200
4Subject: drm/etnaviv: lock MMU while dumping core
5
6[ Upstream commit 1396500d673bd027683a0609ff84dca7eb6ea2e7 ]
7
8The devcoredump needs to operate on a stable state of the MMU while
9it is writing the MMU state to the coredump. The missing lock
10allowed both the userspace submit, as well as the GPU job finish
11paths to mutate the MMU state while a coredump is under way.
12
13Fixes: a8c21a5451d8 (drm/etnaviv: add initial etnaviv DRM driver)
14Reported-by: David Jander <david@protonic.nl>
15Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
16Tested-by: David Jander <david@protonic.nl>
17Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
18Signed-off-by: Sasha Levin <sashal@kernel.org>
19---
20 drivers/gpu/drm/etnaviv/etnaviv_dump.c | 5 +++++
21 1 file changed, 5 insertions(+)
22
23diff --git a/drivers/gpu/drm/etnaviv/etnaviv_dump.c b/drivers/gpu/drm/etnaviv/etnaviv_dump.c
24index 9146e30e24a6..468dff2f7904 100644
25--- a/drivers/gpu/drm/etnaviv/etnaviv_dump.c
26+++ b/drivers/gpu/drm/etnaviv/etnaviv_dump.c
27@@ -124,6 +124,8 @@ void etnaviv_core_dump(struct etnaviv_gpu *gpu)
28 return;
29 etnaviv_dump_core = false;
30
31+ mutex_lock(&gpu->mmu->lock);
32+
33 mmu_size = etnaviv_iommu_dump_size(gpu->mmu);
34
35 /* We always dump registers, mmu, ring and end marker */
36@@ -166,6 +168,7 @@ void etnaviv_core_dump(struct etnaviv_gpu *gpu)
37 iter.start = __vmalloc(file_size, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY,
38 PAGE_KERNEL);
39 if (!iter.start) {
40+ mutex_unlock(&gpu->mmu->lock);
41 dev_warn(gpu->dev, "failed to allocate devcoredump file\n");
42 return;
43 }
44@@ -233,6 +236,8 @@ void etnaviv_core_dump(struct etnaviv_gpu *gpu)
45 obj->base.size);
46 }
47
48+ mutex_unlock(&gpu->mmu->lock);
49+
50 etnaviv_core_dump_header(&iter, ETDUMP_BUF_END, iter.data);
51
52 dev_coredumpv(gpu->dev, iter.start, iter.data - iter.start, GFP_KERNEL);
53--
542.20.1
55