@@ -1072,6 +1072,65 @@ i915_emit_box(struct intel_engine_cs *ring,
1072
1072
return 0 ;
1073
1073
}
1074
1074
1075
+ static struct drm_i915_gem_object *
1076
+ i915_gem_execbuffer_parse (struct intel_engine_cs * ring ,
1077
+ struct drm_i915_gem_exec_object2 * shadow_exec_entry ,
1078
+ struct eb_vmas * eb ,
1079
+ struct drm_i915_gem_object * batch_obj ,
1080
+ u32 batch_start_offset ,
1081
+ u32 batch_len ,
1082
+ bool is_master ,
1083
+ u32 * flags )
1084
+ {
1085
+ struct drm_i915_private * dev_priv = to_i915 (batch_obj -> base .dev );
1086
+ struct drm_i915_gem_object * shadow_batch_obj ;
1087
+ int ret ;
1088
+
1089
+ shadow_batch_obj = i915_gem_batch_pool_get (& dev_priv -> mm .batch_pool ,
1090
+ batch_obj -> base .size );
1091
+ if (IS_ERR (shadow_batch_obj ))
1092
+ return shadow_batch_obj ;
1093
+
1094
+ ret = i915_parse_cmds (ring ,
1095
+ batch_obj ,
1096
+ shadow_batch_obj ,
1097
+ batch_start_offset ,
1098
+ batch_len ,
1099
+ is_master );
1100
+ if (ret ) {
1101
+ if (ret == - EACCES )
1102
+ return batch_obj ;
1103
+ } else {
1104
+ struct i915_vma * vma ;
1105
+
1106
+ memset (shadow_exec_entry , 0 , sizeof (* shadow_exec_entry ));
1107
+
1108
+ vma = i915_gem_obj_to_ggtt (shadow_batch_obj );
1109
+ vma -> exec_entry = shadow_exec_entry ;
1110
+ vma -> exec_entry -> flags = __EXEC_OBJECT_PURGEABLE ;
1111
+ drm_gem_object_reference (& shadow_batch_obj -> base );
1112
+ list_add_tail (& vma -> exec_list , & eb -> vmas );
1113
+
1114
+ shadow_batch_obj -> base .pending_read_domains =
1115
+ batch_obj -> base .pending_read_domains ;
1116
+
1117
+ /*
1118
+ * Set the DISPATCH_SECURE bit to remove the NON_SECURE
1119
+ * bit from MI_BATCH_BUFFER_START commands issued in the
1120
+ * dispatch_execbuffer implementations. We specifically
1121
+ * don't want that set when the command parser is
1122
+ * enabled.
1123
+ *
1124
+ * FIXME: with aliasing ppgtt, buffers that should only
1125
+ * be in ggtt still end up in the aliasing ppgtt. remove
1126
+ * this check when that is fixed.
1127
+ */
1128
+ if (USES_FULL_PPGTT (dev ))
1129
+ * flags |= I915_DISPATCH_SECURE ;
1130
+ }
1131
+
1132
+ return ret ? ERR_PTR (ret ) : shadow_batch_obj ;
1133
+ }
1075
1134
1076
1135
int
1077
1136
i915_gem_ringbuffer_submission (struct drm_device * dev , struct drm_file * file ,
@@ -1289,7 +1348,6 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
1289
1348
struct drm_i915_private * dev_priv = dev -> dev_private ;
1290
1349
struct eb_vmas * eb ;
1291
1350
struct drm_i915_gem_object * batch_obj ;
1292
- struct drm_i915_gem_object * shadow_batch_obj = NULL ;
1293
1351
struct drm_i915_gem_exec_object2 shadow_exec_entry ;
1294
1352
struct intel_engine_cs * ring ;
1295
1353
struct intel_context * ctx ;
@@ -1409,62 +1467,18 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
1409
1467
}
1410
1468
1411
1469
if (i915_needs_cmd_parser (ring )) {
1412
- shadow_batch_obj =
1413
- i915_gem_batch_pool_get (& dev_priv -> mm .batch_pool ,
1414
- batch_obj -> base .size );
1415
- if (IS_ERR (shadow_batch_obj )) {
1416
- ret = PTR_ERR (shadow_batch_obj );
1417
- /* Don't try to clean up the obj in the error path */
1418
- shadow_batch_obj = NULL ;
1470
+ batch_obj = i915_gem_execbuffer_parse (ring ,
1471
+ & shadow_exec_entry ,
1472
+ eb ,
1473
+ batch_obj ,
1474
+ args -> batch_start_offset ,
1475
+ args -> batch_len ,
1476
+ file -> is_master ,
1477
+ & flags );
1478
+ if (IS_ERR (batch_obj )) {
1479
+ ret = PTR_ERR (batch_obj );
1419
1480
goto err ;
1420
1481
}
1421
-
1422
- ret = i915_gem_obj_ggtt_pin (shadow_batch_obj , 4096 , 0 );
1423
- if (ret )
1424
- goto err ;
1425
-
1426
- ret = i915_parse_cmds (ring ,
1427
- batch_obj ,
1428
- shadow_batch_obj ,
1429
- args -> batch_start_offset ,
1430
- args -> batch_len ,
1431
- file -> is_master );
1432
- i915_gem_object_ggtt_unpin (shadow_batch_obj );
1433
-
1434
- if (ret ) {
1435
- if (ret != - EACCES )
1436
- goto err ;
1437
- } else {
1438
- struct i915_vma * vma ;
1439
-
1440
- memset (& shadow_exec_entry , 0 ,
1441
- sizeof (shadow_exec_entry ));
1442
-
1443
- vma = i915_gem_obj_to_ggtt (shadow_batch_obj );
1444
- vma -> exec_entry = & shadow_exec_entry ;
1445
- vma -> exec_entry -> flags = __EXEC_OBJECT_PURGEABLE ;
1446
- drm_gem_object_reference (& shadow_batch_obj -> base );
1447
- list_add_tail (& vma -> exec_list , & eb -> vmas );
1448
-
1449
- shadow_batch_obj -> base .pending_read_domains =
1450
- batch_obj -> base .pending_read_domains ;
1451
-
1452
- batch_obj = shadow_batch_obj ;
1453
-
1454
- /*
1455
- * Set the DISPATCH_SECURE bit to remove the NON_SECURE
1456
- * bit from MI_BATCH_BUFFER_START commands issued in the
1457
- * dispatch_execbuffer implementations. We specifically
1458
- * don't want that set when the command parser is
1459
- * enabled.
1460
- *
1461
- * FIXME: with aliasing ppgtt, buffers that should only
1462
- * be in ggtt still end up in the aliasing ppgtt. remove
1463
- * this check when that is fixed.
1464
- */
1465
- if (USES_FULL_PPGTT (dev ))
1466
- flags |= I915_DISPATCH_SECURE ;
1467
- }
1468
1482
}
1469
1483
1470
1484
batch_obj -> base .pending_read_domains |= I915_GEM_DOMAIN_COMMAND ;
0 commit comments