aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2013-10-10 12:52:52 -0400
committerThomas Hellstrom <thellstrom@vmware.com>2014-01-17 01:52:37 -0500
commit4b9e45e68ff9ccd241fa61f9eff1cbddabc05ea1 (patch)
tree28edfe64662fc3d37cabdea12248da31d9ee122f
parent173fb7d4e26705a9e8b8e9d197a18ff39bfdad0a (diff)
drm/vmwgfx: Ditch the vmw_dummy_query_bo_prepare function
Combine it with vmw_dummy_query_bo_create, and also make sure we use tryreserve when reserving the bo to avoid any lockdep warnings We are sure the tryreserve will always succeed since we are the only users at that point. In addition, allow the vmw_bo_pin function to pin/unpin system memory. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c8
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c78
2 files changed, 37 insertions, 49 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
index e90a78d54f98..a75840211b3c 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
@@ -290,8 +290,7 @@ void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *bo,
290/** 290/**
291 * vmw_bo_pin - Pin or unpin a buffer object without moving it. 291 * vmw_bo_pin - Pin or unpin a buffer object without moving it.
292 * 292 *
293 * @bo: The buffer object. Must be reserved, and present either in VRAM 293 * @bo: The buffer object. Must be reserved.
294 * or GMR memory.
295 * @pin: Whether to pin or unpin. 294 * @pin: Whether to pin or unpin.
296 * 295 *
297 */ 296 */
@@ -303,12 +302,9 @@ void vmw_bo_pin(struct ttm_buffer_object *bo, bool pin)
303 int ret; 302 int ret;
304 303
305 lockdep_assert_held(&bo->resv->lock.base); 304 lockdep_assert_held(&bo->resv->lock.base);
306 BUG_ON(old_mem_type != TTM_PL_VRAM &&
307 old_mem_type != VMW_PL_GMR &&
308 old_mem_type != VMW_PL_MOB);
309 305
310 pl_flags = TTM_PL_FLAG_VRAM | VMW_PL_FLAG_GMR | VMW_PL_FLAG_MOB 306 pl_flags = TTM_PL_FLAG_VRAM | VMW_PL_FLAG_GMR | VMW_PL_FLAG_MOB
311 | TTM_PL_FLAG_CACHED; 307 | TTM_PL_FLAG_SYSTEM | TTM_PL_FLAG_CACHED;
312 if (pin) 308 if (pin)
313 pl_flags |= TTM_PL_FLAG_NO_EVICT; 309 pl_flags |= TTM_PL_FLAG_NO_EVICT;
314 310
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 9008a56e2a97..078b9b0d2dfe 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -281,36 +281,44 @@ static void vmw_print_capabilities(uint32_t capabilities)
281 DRM_INFO(" Guest Backed Resources.\n"); 281 DRM_INFO(" Guest Backed Resources.\n");
282} 282}
283 283
284
285/** 284/**
286 * vmw_execbuf_prepare_dummy_query - Initialize a query result structure at 285 * vmw_dummy_query_bo_create - create a bo to hold a dummy query result
287 * the start of a buffer object.
288 * 286 *
289 * @dev_priv: The device private structure. 287 * @dev_priv: A device private structure.
290 * 288 *
291 * This function will idle the buffer using an uninterruptible wait, then 289 * This function creates a small buffer object that holds the query
292 * map the first page and initialize a pending occlusion query result structure, 290 * result for dummy queries emitted as query barriers.
293 * Finally it will unmap the buffer. 291 * The function will then map the first page and initialize a pending
292 * occlusion query result structure, Finally it will unmap the buffer.
293 * No interruptible waits are done within this function.
294 * 294 *
295 * TODO: Since we're only mapping a single page, we should optimize the map 295 * Returns an error if bo creation or initialization fails.
296 * to use kmap_atomic / iomap_atomic.
297 */ 296 */
298static void vmw_dummy_query_bo_prepare(struct vmw_private *dev_priv) 297static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)
299{ 298{
299 int ret;
300 struct ttm_buffer_object *bo;
300 struct ttm_bo_kmap_obj map; 301 struct ttm_bo_kmap_obj map;
301 volatile SVGA3dQueryResult *result; 302 volatile SVGA3dQueryResult *result;
302 bool dummy; 303 bool dummy;
303 int ret;
304 struct ttm_bo_device *bdev = &dev_priv->bdev;
305 struct ttm_buffer_object *bo = dev_priv->dummy_query_bo;
306 304
307 ttm_bo_reserve(bo, false, false, false, 0); 305 /*
308 spin_lock(&bdev->fence_lock); 306 * Create the bo as pinned, so that a tryreserve will
309 ret = ttm_bo_wait(bo, false, false, false); 307 * immediately succeed. This is because we're the only
310 spin_unlock(&bdev->fence_lock); 308 * user of the bo currently.
309 */
310 ret = ttm_bo_create(&dev_priv->bdev,
311 PAGE_SIZE,
312 ttm_bo_type_device,
313 &vmw_sys_ne_placement,
314 0, false, NULL,
315 &bo);
316
311 if (unlikely(ret != 0)) 317 if (unlikely(ret != 0))
312 (void) vmw_fallback_wait(dev_priv, false, true, 0, false, 318 return ret;
313 10*HZ); 319
320 ret = ttm_bo_reserve(bo, false, true, false, 0);
321 BUG_ON(ret != 0);
314 322
315 ret = ttm_bo_kmap(bo, 0, 1, &map); 323 ret = ttm_bo_kmap(bo, 0, 1, &map);
316 if (likely(ret == 0)) { 324 if (likely(ret == 0)) {
@@ -319,34 +327,19 @@ static void vmw_dummy_query_bo_prepare(struct vmw_private *dev_priv)
319 result->state = SVGA3D_QUERYSTATE_PENDING; 327 result->state = SVGA3D_QUERYSTATE_PENDING;
320 result->result32 = 0xff; 328 result->result32 = 0xff;
321 ttm_bo_kunmap(&map); 329 ttm_bo_kunmap(&map);
322 } else 330 }
323 DRM_ERROR("Dummy query buffer map failed.\n"); 331 vmw_bo_pin(bo, false);
324 ttm_bo_unreserve(bo); 332 ttm_bo_unreserve(bo);
325}
326 333
334 if (unlikely(ret != 0)) {
335 DRM_ERROR("Dummy query buffer map failed.\n");
336 ttm_bo_unref(&bo);
337 } else
338 dev_priv->dummy_query_bo = bo;
327 339
328/** 340 return ret;
329 * vmw_dummy_query_bo_create - create a bo to hold a dummy query result
330 *
331 * @dev_priv: A device private structure.
332 *
333 * This function creates a small buffer object that holds the query
334 * result for dummy queries emitted as query barriers.
335 * No interruptible waits are done within this function.
336 *
337 * Returns an error if bo creation fails.
338 */
339static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)
340{
341 return ttm_bo_create(&dev_priv->bdev,
342 PAGE_SIZE,
343 ttm_bo_type_device,
344 &vmw_vram_sys_placement,
345 0, false, NULL,
346 &dev_priv->dummy_query_bo);
347} 341}
348 342
349
350static int vmw_request_device(struct vmw_private *dev_priv) 343static int vmw_request_device(struct vmw_private *dev_priv)
351{ 344{
352 int ret; 345 int ret;
@@ -368,7 +361,6 @@ static int vmw_request_device(struct vmw_private *dev_priv)
368 ret = vmw_dummy_query_bo_create(dev_priv); 361 ret = vmw_dummy_query_bo_create(dev_priv);
369 if (unlikely(ret != 0)) 362 if (unlikely(ret != 0))
370 goto out_no_query_bo; 363 goto out_no_query_bo;
371 vmw_dummy_query_bo_prepare(dev_priv);
372 364
373 return 0; 365 return 0;
374 366