]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.14/drm-vmwgfx-don-t-cache-framebuffer-maps.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.14 / drm-vmwgfx-don-t-cache-framebuffer-maps.patch
CommitLineData
2ca3111c
GKH
1From 98648ae6ef6bdcdcb88c46cad963906ab452e96d Mon Sep 17 00:00:00 2001
2From: Thomas Hellstrom <thellstrom@vmware.com>
3Date: Tue, 9 Jan 2018 15:33:42 +0100
4Subject: drm/vmwgfx: Don't cache framebuffer maps
5
6From: Thomas Hellstrom <thellstrom@vmware.com>
7
8commit 98648ae6ef6bdcdcb88c46cad963906ab452e96d upstream.
9
10Buffer objects need to be either pinned or reserved while a map is active,
11that's not the case here, so avoid caching the framebuffer map.
12This will cause increasing mapping activity mainly when we don't do
13page flipping.
14
15This fixes occasional garbage filled screens when the framebuffer has been
16evicted after the map.
17
18Since in-kernel mapping of whole buffer objects is error-prone on 32-bit
19architectures and also quite inefficient, we will revisit this later.
20
21Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
22Reviewed-by: Sinclair Yeh <syeh@vmware.com>
23Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24
25---
26 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 6 -----
27 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 2 -
28 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 41 ++++++++++-------------------------
29 3 files changed, 13 insertions(+), 36 deletions(-)
30
31--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
32+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
33@@ -697,7 +697,6 @@ vmw_du_plane_duplicate_state(struct drm_
34 vps->pinned = 0;
35
36 /* Mapping is managed by prepare_fb/cleanup_fb */
37- memset(&vps->guest_map, 0, sizeof(vps->guest_map));
38 memset(&vps->host_map, 0, sizeof(vps->host_map));
39 vps->cpp = 0;
40
41@@ -760,11 +759,6 @@ vmw_du_plane_destroy_state(struct drm_pl
42
43
44 /* Should have been freed by cleanup_fb */
45- if (vps->guest_map.virtual) {
46- DRM_ERROR("Guest mapping not freed\n");
47- ttm_bo_kunmap(&vps->guest_map);
48- }
49-
50 if (vps->host_map.virtual) {
51 DRM_ERROR("Host mapping not freed\n");
52 ttm_bo_kunmap(&vps->host_map);
53--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
54+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
55@@ -175,7 +175,7 @@ struct vmw_plane_state {
56 int pinned;
57
58 /* For CPU Blit */
59- struct ttm_bo_kmap_obj host_map, guest_map;
60+ struct ttm_bo_kmap_obj host_map;
61 unsigned int cpp;
62 };
63
64--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
65+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
66@@ -114,7 +114,7 @@ struct vmw_screen_target_display_unit {
67 bool defined;
68
69 /* For CPU Blit */
70- struct ttm_bo_kmap_obj host_map, guest_map;
71+ struct ttm_bo_kmap_obj host_map;
72 unsigned int cpp;
73 };
74
75@@ -695,7 +695,8 @@ static void vmw_stdu_dmabuf_cpu_commit(s
76 s32 src_pitch, dst_pitch;
77 u8 *src, *dst;
78 bool not_used;
79-
80+ struct ttm_bo_kmap_obj guest_map;
81+ int ret;
82
83 if (!dirty->num_hits)
84 return;
85@@ -706,6 +707,13 @@ static void vmw_stdu_dmabuf_cpu_commit(s
86 if (width == 0 || height == 0)
87 return;
88
89+ ret = ttm_bo_kmap(&ddirty->buf->base, 0, ddirty->buf->base.num_pages,
90+ &guest_map);
91+ if (ret) {
92+ DRM_ERROR("Failed mapping framebuffer for blit: %d\n",
93+ ret);
94+ goto out_cleanup;
95+ }
96
97 /* Assume we are blitting from Host (display_srf) to Guest (dmabuf) */
98 src_pitch = stdu->display_srf->base_size.width * stdu->cpp;
99@@ -713,7 +721,7 @@ static void vmw_stdu_dmabuf_cpu_commit(s
100 src += ddirty->top * src_pitch + ddirty->left * stdu->cpp;
101
102 dst_pitch = ddirty->pitch;
103- dst = ttm_kmap_obj_virtual(&stdu->guest_map, &not_used);
104+ dst = ttm_kmap_obj_virtual(&guest_map, &not_used);
105 dst += ddirty->fb_top * dst_pitch + ddirty->fb_left * stdu->cpp;
106
107
108@@ -772,6 +780,7 @@ static void vmw_stdu_dmabuf_cpu_commit(s
109 vmw_fifo_commit(dev_priv, sizeof(*cmd));
110 }
111
112+ ttm_bo_kunmap(&guest_map);
113 out_cleanup:
114 ddirty->left = ddirty->top = ddirty->fb_left = ddirty->fb_top = S32_MAX;
115 ddirty->right = ddirty->bottom = S32_MIN;
116@@ -1109,9 +1118,6 @@ vmw_stdu_primary_plane_cleanup_fb(struct
117 {
118 struct vmw_plane_state *vps = vmw_plane_state_to_vps(old_state);
119
120- if (vps->guest_map.virtual)
121- ttm_bo_kunmap(&vps->guest_map);
122-
123 if (vps->host_map.virtual)
124 ttm_bo_kunmap(&vps->host_map);
125
126@@ -1277,33 +1283,11 @@ vmw_stdu_primary_plane_prepare_fb(struct
127 */
128 if (vps->content_fb_type == SEPARATE_DMA &&
129 !(dev_priv->capabilities & SVGA_CAP_3D)) {
130-
131- struct vmw_framebuffer_dmabuf *new_vfbd;
132-
133- new_vfbd = vmw_framebuffer_to_vfbd(new_fb);
134-
135- ret = ttm_bo_reserve(&new_vfbd->buffer->base, false, false,
136- NULL);
137- if (ret)
138- goto out_srf_unpin;
139-
140- ret = ttm_bo_kmap(&new_vfbd->buffer->base, 0,
141- new_vfbd->buffer->base.num_pages,
142- &vps->guest_map);
143-
144- ttm_bo_unreserve(&new_vfbd->buffer->base);
145-
146- if (ret) {
147- DRM_ERROR("Failed to map content buffer to CPU\n");
148- goto out_srf_unpin;
149- }
150-
151 ret = ttm_bo_kmap(&vps->surf->res.backup->base, 0,
152 vps->surf->res.backup->base.num_pages,
153 &vps->host_map);
154 if (ret) {
155 DRM_ERROR("Failed to map display buffer to CPU\n");
156- ttm_bo_kunmap(&vps->guest_map);
157 goto out_srf_unpin;
158 }
159
160@@ -1350,7 +1334,6 @@ vmw_stdu_primary_plane_atomic_update(str
161 stdu->display_srf = vps->surf;
162 stdu->content_fb_type = vps->content_fb_type;
163 stdu->cpp = vps->cpp;
164- memcpy(&stdu->guest_map, &vps->guest_map, sizeof(vps->guest_map));
165 memcpy(&stdu->host_map, &vps->host_map, sizeof(vps->host_map));
166
167 if (!stdu->defined)