aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c86
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.h9
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_fb.c3
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c10
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c2
5 files changed, 45 insertions, 65 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
index 5668ad980cb5..7f744a82892a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
@@ -32,10 +32,16 @@
32 32
33 33
34/** 34/**
35 * Validate a buffer to placement. 35 * vmw_dmabuf_to_placement - Validate a buffer to placement.
36 * 36 *
37 * May only be called by the current master as this function takes the 37 * @dev_priv: Driver private.
38 * its lock in write mode. 38 * @buf: DMA buffer to move.
39 * @pin: Pin buffer if true.
40 * @interruptible: Use interruptible wait.
41 *
42 * May only be called by the current master since it assumes that the
43 * master lock is the current master's lock.
44 * This function takes the master's lock in write mode.
39 * 45 *
40 * Returns 46 * Returns
41 * -ERESTARTSYS if interrupted by a signal. 47 * -ERESTARTSYS if interrupted by a signal.
@@ -67,10 +73,11 @@ err:
67} 73}
68 74
69/** 75/**
70 * Move a buffer to vram or gmr. 76 * vmw_dmabuf_to_vram_or_gmr - Move a buffer to vram or gmr.
71 * 77 *
72 * May only be called by the current master as this function takes the 78 * May only be called by the current master since it assumes that the
73 * its lock in write mode. 79 * master lock is the current master's lock.
80 * This function takes the master's lock in write mode.
74 * 81 *
75 * @dev_priv: Driver private. 82 * @dev_priv: Driver private.
76 * @buf: DMA buffer to move. 83 * @buf: DMA buffer to move.
@@ -134,10 +141,11 @@ err:
134} 141}
135 142
136/** 143/**
137 * Move a buffer to vram. 144 * vmw_dmabuf_to_vram - Move a buffer to vram.
138 * 145 *
139 * May only be called by the current master as this function takes the 146 * May only be called by the current master since it assumes that the
140 * its lock in write mode. 147 * master lock is the current master's lock.
148 * This function takes the master's lock in write mode.
141 * 149 *
142 * @dev_priv: Driver private. 150 * @dev_priv: Driver private.
143 * @buf: DMA buffer to move. 151 * @buf: DMA buffer to move.
@@ -164,10 +172,11 @@ int vmw_dmabuf_to_vram(struct vmw_private *dev_priv,
164} 172}
165 173
166/** 174/**
167 * Move a buffer to start of vram. 175 * vmw_dmabuf_to_start_of_vram - Move a buffer to start of vram.
168 * 176 *
169 * May only be called by the current master as this function takes the 177 * May only be called by the current master since it assumes that the
170 * its lock in write mode. 178 * master lock is the current master's lock.
179 * This function takes the master's lock in write mode.
171 * 180 *
172 * @dev_priv: Driver private. 181 * @dev_priv: Driver private.
173 * @buf: DMA buffer to move. 182 * @buf: DMA buffer to move.
@@ -219,11 +228,13 @@ err_unlock:
219 return ret; 228 return ret;
220} 229}
221 230
231
222/** 232/**
223 * Unpin the buffer given buffer, does not move the buffer. 233 * vmw_dmabuf_upin - Unpin the buffer given buffer, does not move the buffer.
224 * 234 *
225 * May only be called by the current master as this function takes the 235 * May only be called by the current master since it assumes that the
226 * its lock in write mode. 236 * master lock is the current master's lock.
237 * This function takes the master's lock in write mode.
227 * 238 *
228 * @dev_priv: Driver private. 239 * @dev_priv: Driver private.
229 * @buf: DMA buffer to unpin. 240 * @buf: DMA buffer to unpin.
@@ -246,47 +257,22 @@ int vmw_dmabuf_unpin(struct vmw_private *dev_priv,
246 interruptible); 257 interruptible);
247} 258}
248 259
260
249/** 261/**
250 * Move a buffer to system memory, does not pin the buffer. 262 * vmw_bo_get_guest_ptr - Get the guest ptr representing the current placement
251 * 263 * of a buffer.
252 * May only be called by the current master as this function takes the
253 * its lock in write mode.
254 *
255 * @dev_priv: Driver private.
256 * @buf: DMA buffer to move.
257 * @interruptible: Use interruptible wait.
258 * 264 *
259 * Returns 265 * @bo: Pointer to a struct ttm_buffer_object. Must be pinned or reserved.
260 * -ERESTARTSYS if interrupted by a signal. 266 * @ptr: SVGAGuestPtr returning the result.
261 */ 267 */
262int vmw_dmabuf_to_system(struct vmw_private *dev_priv, 268void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *bo,
263 struct vmw_dma_buffer *buf, 269 SVGAGuestPtr *ptr)
264 bool interruptible)
265{
266 return vmw_dmabuf_to_placement(dev_priv, buf,
267 &vmw_sys_placement,
268 interruptible);
269}
270
271void vmw_dmabuf_get_id_offset(struct vmw_dma_buffer *buf,
272 uint32_t *gmrId, uint32_t *offset)
273{
274 if (buf->base.mem.mem_type == TTM_PL_VRAM) {
275 *gmrId = SVGA_GMR_FRAMEBUFFER;
276 *offset = buf->base.offset;
277 } else {
278 *gmrId = buf->base.mem.start;
279 *offset = 0;
280 }
281}
282
283void vmw_dmabuf_get_guest_ptr(struct vmw_dma_buffer *buf, SVGAGuestPtr *ptr)
284{ 270{
285 if (buf->base.mem.mem_type == TTM_PL_VRAM) { 271 if (bo->mem.mem_type == TTM_PL_VRAM) {
286 ptr->gmrId = SVGA_GMR_FRAMEBUFFER; 272 ptr->gmrId = SVGA_GMR_FRAMEBUFFER;
287 ptr->offset = buf->base.offset; 273 ptr->offset = bo->offset;
288 } else { 274 } else {
289 ptr->gmrId = buf->base.mem.start; 275 ptr->gmrId = bo->mem.start;
290 ptr->offset = 0; 276 ptr->offset = 0;
291 } 277 }
292} 278}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index fc0e3bc63ec0..b22b96a491a4 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -416,13 +416,8 @@ extern int vmw_dmabuf_to_start_of_vram(struct vmw_private *vmw_priv,
416extern int vmw_dmabuf_unpin(struct vmw_private *vmw_priv, 416extern int vmw_dmabuf_unpin(struct vmw_private *vmw_priv,
417 struct vmw_dma_buffer *bo, 417 struct vmw_dma_buffer *bo,
418 bool interruptible); 418 bool interruptible);
419extern int vmw_dmabuf_to_system(struct vmw_private *vmw_priv, 419extern void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *buf,
420 struct vmw_dma_buffer *bo, 420 SVGAGuestPtr *ptr);
421 bool interruptible);
422extern void vmw_dmabuf_get_id_offset(struct vmw_dma_buffer *buf,
423 uint32_t *gmrId, uint32_t *offset);
424extern void vmw_dmabuf_get_guest_ptr(struct vmw_dma_buffer *buf,
425 SVGAGuestPtr *ptr);
426 421
427/** 422/**
428 * Misc Ioctl functionality - vmwgfx_ioctl.c 423 * Misc Ioctl functionality - vmwgfx_ioctl.c
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
index 191f1b2a2a26..070797b7b03a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
@@ -613,8 +613,7 @@ int vmw_fb_off(struct vmw_private *vmw_priv)
613 par->bo_ptr = NULL; 613 par->bo_ptr = NULL;
614 ttm_bo_kunmap(&par->map); 614 ttm_bo_kunmap(&par->map);
615 615
616 /* move this to system instead of just unpinning it */ 616 vmw_dmabuf_unpin(vmw_priv, par->vmw_bo, false);
617 vmw_dmabuf_to_system(vmw_priv, par->vmw_bo, false);
618 617
619 return 0; 618 return 0;
620} 619}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c b/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
index 29481e1cace7..14399eec9c3c 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
@@ -99,9 +99,9 @@ static int vmw_overlay_send_put(struct vmw_private *dev_priv,
99{ 99{
100 struct vmw_escape_video_flush *flush; 100 struct vmw_escape_video_flush *flush;
101 size_t fifo_size; 101 size_t fifo_size;
102 uint32_t gmrId, offset;
103 bool have_so = dev_priv->sou_priv ? true : false; 102 bool have_so = dev_priv->sou_priv ? true : false;
104 int i, num_items; 103 int i, num_items;
104 SVGAGuestPtr ptr;
105 105
106 struct { 106 struct {
107 struct vmw_escape_header escape; 107 struct vmw_escape_header escape;
@@ -141,12 +141,12 @@ static int vmw_overlay_send_put(struct vmw_private *dev_priv,
141 for (i = 0; i < num_items; i++) 141 for (i = 0; i < num_items; i++)
142 items[i].registerId = i; 142 items[i].registerId = i;
143 143
144 vmw_dmabuf_get_id_offset(buf, &gmrId, &offset); 144 vmw_bo_get_guest_ptr(&buf->base, &ptr);
145 offset += arg->offset; 145 ptr.offset += arg->offset;
146 146
147 items[SVGA_VIDEO_ENABLED].value = true; 147 items[SVGA_VIDEO_ENABLED].value = true;
148 items[SVGA_VIDEO_FLAGS].value = arg->flags; 148 items[SVGA_VIDEO_FLAGS].value = arg->flags;
149 items[SVGA_VIDEO_DATA_OFFSET].value = offset; 149 items[SVGA_VIDEO_DATA_OFFSET].value = ptr.offset;
150 items[SVGA_VIDEO_FORMAT].value = arg->format; 150 items[SVGA_VIDEO_FORMAT].value = arg->format;
151 items[SVGA_VIDEO_COLORKEY].value = arg->color_key; 151 items[SVGA_VIDEO_COLORKEY].value = arg->color_key;
152 items[SVGA_VIDEO_SIZE].value = arg->size; 152 items[SVGA_VIDEO_SIZE].value = arg->size;
@@ -164,7 +164,7 @@ static int vmw_overlay_send_put(struct vmw_private *dev_priv,
164 items[SVGA_VIDEO_PITCH_2].value = arg->pitch[1]; 164 items[SVGA_VIDEO_PITCH_2].value = arg->pitch[1];
165 items[SVGA_VIDEO_PITCH_3].value = arg->pitch[2]; 165 items[SVGA_VIDEO_PITCH_3].value = arg->pitch[2];
166 if (have_so) { 166 if (have_so) {
167 items[SVGA_VIDEO_DATA_GMRID].value = gmrId; 167 items[SVGA_VIDEO_DATA_GMRID].value = ptr.gmrId;
168 items[SVGA_VIDEO_DST_SCREEN_ID].value = SVGA_ID_INVALID; 168 items[SVGA_VIDEO_DST_SCREEN_ID].value = SVGA_ID_INVALID;
169 } 169 }
170 170
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
index e74b8e31d042..347e40699443 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
@@ -168,7 +168,7 @@ static int vmw_sou_fifo_create(struct vmw_private *dev_priv,
168 cmd->obj.root.y = y; 168 cmd->obj.root.y = y;
169 169
170 /* Ok to assume that buffer is pinned in vram */ 170 /* Ok to assume that buffer is pinned in vram */
171 vmw_dmabuf_get_guest_ptr(sou->buffer, &cmd->obj.backingStore.ptr); 171 vmw_bo_get_guest_ptr(&sou->buffer->base, &cmd->obj.backingStore.ptr);
172 cmd->obj.backingStore.pitch = mode->hdisplay * 4; 172 cmd->obj.backingStore.pitch = mode->hdisplay * 4;
173 173
174 vmw_fifo_commit(dev_priv, fifo_size); 174 vmw_fifo_commit(dev_priv, fifo_size);