aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c66
1 files changed, 20 insertions, 46 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c b/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
index 07ce02da78a4..7a7abcdf1020 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
@@ -87,48 +87,6 @@ static inline void fill_flush(struct vmw_escape_video_flush *cmd,
87} 87}
88 88
89/** 89/**
90 * Pin or unpin a buffer in vram.
91 *
92 * @dev_priv: Driver private.
93 * @buf: DMA buffer to pin or unpin.
94 * @pin: Pin buffer in vram if true.
95 * @interruptible: Use interruptible wait.
96 *
97 * Takes the current masters ttm lock in read.
98 *
99 * Returns
100 * -ERESTARTSYS if interrupted by a signal.
101 */
102static int vmw_dmabuf_pin_in_vram(struct vmw_private *dev_priv,
103 struct vmw_dma_buffer *buf,
104 bool pin, bool interruptible)
105{
106 struct ttm_buffer_object *bo = &buf->base;
107 struct ttm_placement *overlay_placement = &vmw_vram_placement;
108 int ret;
109
110 ret = ttm_read_lock(&dev_priv->active_master->lock, interruptible);
111 if (unlikely(ret != 0))
112 return ret;
113
114 ret = ttm_bo_reserve(bo, interruptible, false, false, 0);
115 if (unlikely(ret != 0))
116 goto err;
117
118 if (pin)
119 overlay_placement = &vmw_vram_ne_placement;
120
121 ret = ttm_bo_validate(bo, overlay_placement, interruptible, false, false);
122
123 ttm_bo_unreserve(bo);
124
125err:
126 ttm_read_unlock(&dev_priv->active_master->lock);
127
128 return ret;
129}
130
131/**
132 * Send put command to hw. 90 * Send put command to hw.
133 * 91 *
134 * Returns 92 * Returns
@@ -248,6 +206,21 @@ static int vmw_overlay_send_stop(struct vmw_private *dev_priv,
248} 206}
249 207
250/** 208/**
209 * Move a buffer to vram, and pin it if @pin.
210 *
211 * XXX: This function is here to be changed at a later date.
212 */
213static int vmw_overlay_move_buffer(struct vmw_private *dev_priv,
214 struct vmw_dma_buffer *buf,
215 bool pin, bool inter)
216{
217 if (pin)
218 return vmw_dmabuf_to_vram(dev_priv, buf, true, inter);
219 else
220 return vmw_dmabuf_unpin(dev_priv, buf, inter);
221}
222
223/**
251 * Stop or pause a stream. 224 * Stop or pause a stream.
252 * 225 *
253 * If the stream is paused the no evict flag is removed from the buffer 226 * If the stream is paused the no evict flag is removed from the buffer
@@ -279,8 +252,8 @@ static int vmw_overlay_stop(struct vmw_private *dev_priv,
279 return ret; 252 return ret;
280 253
281 /* We just remove the NO_EVICT flag so no -ENOMEM */ 254 /* We just remove the NO_EVICT flag so no -ENOMEM */
282 ret = vmw_dmabuf_pin_in_vram(dev_priv, stream->buf, false, 255 ret = vmw_overlay_move_buffer(dev_priv, stream->buf, false,
283 interruptible); 256 interruptible);
284 if (interruptible && ret == -ERESTARTSYS) 257 if (interruptible && ret == -ERESTARTSYS)
285 return ret; 258 return ret;
286 else 259 else
@@ -342,7 +315,7 @@ static int vmw_overlay_update_stream(struct vmw_private *dev_priv,
342 /* We don't start the old stream if we are interrupted. 315 /* We don't start the old stream if we are interrupted.
343 * Might return -ENOMEM if it can't fit the buffer in vram. 316 * Might return -ENOMEM if it can't fit the buffer in vram.
344 */ 317 */
345 ret = vmw_dmabuf_pin_in_vram(dev_priv, buf, true, interruptible); 318 ret = vmw_overlay_move_buffer(dev_priv, buf, true, interruptible);
346 if (ret) 319 if (ret)
347 return ret; 320 return ret;
348 321
@@ -351,7 +324,8 @@ static int vmw_overlay_update_stream(struct vmw_private *dev_priv,
351 /* This one needs to happen no matter what. We only remove 324 /* This one needs to happen no matter what. We only remove
352 * the NO_EVICT flag so this is safe from -ENOMEM. 325 * the NO_EVICT flag so this is safe from -ENOMEM.
353 */ 326 */
354 BUG_ON(vmw_dmabuf_pin_in_vram(dev_priv, buf, false, false) != 0); 327 BUG_ON(vmw_overlay_move_buffer(dev_priv, buf, false, false)
328 != 0);
355 return ret; 329 return ret;
356 } 330 }
357 331