aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_gem_execbuffer.c
diff options
context:
space:
mode:
authorBrad Volkin <bradley.d.volkin@intel.com>2014-12-11 15:13:09 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-12-16 04:39:09 -0500
commit78a423772d08eb5a048765a883b5b5a308ea0d0f (patch)
treef94b1154c11e6b4d46e151402639e97480ff0729 /drivers/gpu/drm/i915/i915_gem_execbuffer.c
parent493018dcb1c7a17f2a811db41522a3a5350304fe (diff)
drm/i915: Use batch pools with the command parser
This patch sets up all of the tracking and copying necessary to use batch pools with the command parser and dispatches the copied (shadow) batch to the hardware. After this patch, the parser is in 'enabling' mode. Note that performance takes a hit from the copy in some cases and will likely need some work. At a rough pass, the memcpy appears to be the bottleneck. Without having done a deeper analysis, two ideas that come to mind are: 1) Copy sections of the batch at a time, as they are reached by parsing. Might improve cache locality. 2) Copy only up to the userspace-supplied batch length and memset the rest of the buffer. Reduces the number of reads. v2: - Remove setting the capacity of the pool - One global pool instead of per-ring pools - Replace batch_obj with shadow_batch_obj and hook into eb->vmas - Memset any space in the shadow batch beyond what gets copied - Rebased on execlist prep refactoring v3: - Rebase on chained batch handling - Squash in setting the secure dispatch flag - Add a note about the interaction w/secure dispatch pinning - Check for request->batch_obj == NULL in i915_gem_free_request v4: - Fix read domains for shadow_batch_obj - Remove the set_to_gtt_domain call from i915_parse_cmds - ggtt_pin/unpin in the parser block to simplify error handling - Check USES_FULL_PPGTT before setting DISPATCH_SECURE flag - Remove i915_gem_batch_pool_put calls v5: - Move 'pending_read_domains |= I915_GEM_DOMAIN_COMMAND' after the parser (danvet, from v4 0/7 feedback) Issue: VIZ-4719 Signed-off-by: Brad Volkin <bradley.d.volkin@intel.com> Reviewed-By: Jon Bloomfield <jon.bloomfield@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_execbuffer.c')
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c52
1 files changed, 46 insertions, 6 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 3927d931ad73..cadb04d964e0 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1283,6 +1283,8 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
1283 struct drm_i915_private *dev_priv = dev->dev_private; 1283 struct drm_i915_private *dev_priv = dev->dev_private;
1284 struct eb_vmas *eb; 1284 struct eb_vmas *eb;
1285 struct drm_i915_gem_object *batch_obj; 1285 struct drm_i915_gem_object *batch_obj;
1286 struct drm_i915_gem_object *shadow_batch_obj = NULL;
1287 struct drm_i915_gem_exec_object2 shadow_exec_entry;
1286 struct intel_engine_cs *ring; 1288 struct intel_engine_cs *ring;
1287 struct intel_context *ctx; 1289 struct intel_context *ctx;
1288 struct i915_address_space *vm; 1290 struct i915_address_space *vm;
@@ -1399,28 +1401,66 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
1399 ret = -EINVAL; 1401 ret = -EINVAL;
1400 goto err; 1402 goto err;
1401 } 1403 }
1402 batch_obj->base.pending_read_domains |= I915_GEM_DOMAIN_COMMAND;
1403 1404
1404 if (i915_needs_cmd_parser(ring)) { 1405 if (i915_needs_cmd_parser(ring)) {
1406 shadow_batch_obj =
1407 i915_gem_batch_pool_get(&dev_priv->mm.batch_pool,
1408 batch_obj->base.size);
1409 if (IS_ERR(shadow_batch_obj)) {
1410 ret = PTR_ERR(shadow_batch_obj);
1411 /* Don't try to clean up the obj in the error path */
1412 shadow_batch_obj = NULL;
1413 goto err;
1414 }
1415
1416 ret = i915_gem_obj_ggtt_pin(shadow_batch_obj, 4096, 0);
1417 if (ret)
1418 goto err;
1419
1405 ret = i915_parse_cmds(ring, 1420 ret = i915_parse_cmds(ring,
1406 batch_obj, 1421 batch_obj,
1422 shadow_batch_obj,
1407 args->batch_start_offset, 1423 args->batch_start_offset,
1408 file->is_master); 1424 file->is_master);
1425 i915_gem_object_ggtt_unpin(shadow_batch_obj);
1426
1409 if (ret) { 1427 if (ret) {
1410 if (ret != -EACCES) 1428 if (ret != -EACCES)
1411 goto err; 1429 goto err;
1412 } else { 1430 } else {
1431 struct i915_vma *vma;
1432
1433 memset(&shadow_exec_entry, 0,
1434 sizeof(shadow_exec_entry));
1435
1436 vma = i915_gem_obj_to_ggtt(shadow_batch_obj);
1437 vma->exec_entry = &shadow_exec_entry;
1438 drm_gem_object_reference(&shadow_batch_obj->base);
1439 list_add_tail(&vma->exec_list, &eb->vmas);
1440
1441 shadow_batch_obj->base.pending_read_domains =
1442 batch_obj->base.pending_read_domains;
1443
1444 batch_obj = shadow_batch_obj;
1445
1413 /* 1446 /*
1414 * XXX: Actually do this when enabling batch copy... 1447 * Set the DISPATCH_SECURE bit to remove the NON_SECURE
1448 * bit from MI_BATCH_BUFFER_START commands issued in the
1449 * dispatch_execbuffer implementations. We specifically
1450 * don't want that set when the command parser is
1451 * enabled.
1415 * 1452 *
1416 * Set the DISPATCH_SECURE bit to remove the NON_SECURE bit 1453 * FIXME: with aliasing ppgtt, buffers that should only
1417 * from MI_BATCH_BUFFER_START commands issued in the 1454 * be in ggtt still end up in the aliasing ppgtt. remove
1418 * dispatch_execbuffer implementations. We specifically don't 1455 * this check when that is fixed.
1419 * want that set when the command parser is enabled.
1420 */ 1456 */
1457 if (USES_FULL_PPGTT(dev))
1458 flags |= I915_DISPATCH_SECURE;
1421 } 1459 }
1422 } 1460 }
1423 1461
1462 batch_obj->base.pending_read_domains |= I915_GEM_DOMAIN_COMMAND;
1463
1424 /* snb/ivb/vlv conflate the "batch in ppgtt" bit with the "non-secure 1464 /* snb/ivb/vlv conflate the "batch in ppgtt" bit with the "non-secure
1425 * batch" bit. Hence we need to pin secure batches into the global gtt. 1465 * batch" bit. Hence we need to pin secure batches into the global gtt.
1426 * hsw should have this fixed, but bdw mucks it up again. */ 1466 * hsw should have this fixed, but bdw mucks it up again. */