aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2012-11-21 05:45:13 -0500
committerThomas Hellstrom <thellstrom@vmware.com>2014-01-17 01:52:26 -0500
commita97e21923b421993258e8487f2a5700c1ba3897f (patch)
tree7c5f9513eacf947564f46c06e1df205b2f95d151 /drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
parent58a0c5f036464bd891880b30bde196320e904b81 (diff)
drm/vmwgfx: Hook up guest-backed surfaces
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Zack Rusin <zackr@vmware.com>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c231
1 files changed, 231 insertions, 0 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index c2a6e4832e74..4d51ad0a2f51 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -1186,6 +1186,222 @@ static int vmw_cmd_check_define_gmrfb(struct vmw_private *dev_priv,
1186} 1186}
1187 1187
1188/** 1188/**
1189 * vmw_cmd_switch_backup - Utility function to handle backup buffer switching
1190 *
1191 * @dev_priv: Pointer to a device private struct.
1192 * @sw_context: The software context being used for this batch.
1193 * @res_type: The resource type.
1194 * @converter: Information about user-space binding for this resource type.
1195 * @res_id: Pointer to the user-space resource handle in the command stream.
1196 * @buf_id: Pointer to the user-space backup buffer handle in the command
1197 * stream.
1198 * @backup_offset: Offset of backup into MOB.
1199 *
1200 * This function prepares for registering a switch of backup buffers
1201 * in the resource metadata just prior to unreserving.
1202 */
1203static int vmw_cmd_switch_backup(struct vmw_private *dev_priv,
1204 struct vmw_sw_context *sw_context,
1205 enum vmw_res_type res_type,
1206 const struct vmw_user_resource_conv
1207 *converter,
1208 uint32_t *res_id,
1209 uint32_t *buf_id,
1210 unsigned long backup_offset)
1211{
1212 int ret;
1213 struct vmw_dma_buffer *dma_buf;
1214 struct vmw_resource_val_node *val_node;
1215
1216 ret = vmw_cmd_res_check(dev_priv, sw_context, res_type,
1217 converter, res_id, &val_node);
1218 if (unlikely(ret != 0))
1219 return ret;
1220
1221 ret = vmw_translate_mob_ptr(dev_priv, sw_context, buf_id, &dma_buf);
1222 if (unlikely(ret != 0))
1223 return ret;
1224
1225 if (val_node->first_usage)
1226 val_node->no_buffer_needed = true;
1227
1228 vmw_dmabuf_unreference(&val_node->new_backup);
1229 val_node->new_backup = dma_buf;
1230 val_node->new_backup_offset = backup_offset;
1231
1232 return 0;
1233}
1234
1235/**
1236 * vmw_cmd_bind_gb_surface - Validate an SVGA_3D_CMD_BIND_GB_SURFACE
1237 * command
1238 *
1239 * @dev_priv: Pointer to a device private struct.
1240 * @sw_context: The software context being used for this batch.
1241 * @header: Pointer to the command header in the command stream.
1242 */
1243static int vmw_cmd_bind_gb_surface(struct vmw_private *dev_priv,
1244 struct vmw_sw_context *sw_context,
1245 SVGA3dCmdHeader *header)
1246{
1247 struct vmw_bind_gb_surface_cmd {
1248 SVGA3dCmdHeader header;
1249 SVGA3dCmdBindGBSurface body;
1250 } *cmd;
1251
1252 cmd = container_of(header, struct vmw_bind_gb_surface_cmd, header);
1253
1254 return vmw_cmd_switch_backup(dev_priv, sw_context, vmw_res_surface,
1255 user_surface_converter,
1256 &cmd->body.sid, &cmd->body.mobid,
1257 0);
1258}
1259
1260/**
1261 * vmw_cmd_update_gb_image - Validate an SVGA_3D_CMD_UPDATE_GB_IMAGE
1262 * command
1263 *
1264 * @dev_priv: Pointer to a device private struct.
1265 * @sw_context: The software context being used for this batch.
1266 * @header: Pointer to the command header in the command stream.
1267 */
1268static int vmw_cmd_update_gb_image(struct vmw_private *dev_priv,
1269 struct vmw_sw_context *sw_context,
1270 SVGA3dCmdHeader *header)
1271{
1272 struct vmw_gb_surface_cmd {
1273 SVGA3dCmdHeader header;
1274 SVGA3dCmdUpdateGBImage body;
1275 } *cmd;
1276
1277 cmd = container_of(header, struct vmw_gb_surface_cmd, header);
1278
1279 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
1280 user_surface_converter,
1281 &cmd->body.image.sid, NULL);
1282}
1283
1284/**
1285 * vmw_cmd_update_gb_surface - Validate an SVGA_3D_CMD_UPDATE_GB_SURFACE
1286 * command
1287 *
1288 * @dev_priv: Pointer to a device private struct.
1289 * @sw_context: The software context being used for this batch.
1290 * @header: Pointer to the command header in the command stream.
1291 */
1292static int vmw_cmd_update_gb_surface(struct vmw_private *dev_priv,
1293 struct vmw_sw_context *sw_context,
1294 SVGA3dCmdHeader *header)
1295{
1296 struct vmw_gb_surface_cmd {
1297 SVGA3dCmdHeader header;
1298 SVGA3dCmdUpdateGBSurface body;
1299 } *cmd;
1300
1301 cmd = container_of(header, struct vmw_gb_surface_cmd, header);
1302
1303 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
1304 user_surface_converter,
1305 &cmd->body.sid, NULL);
1306}
1307
1308/**
1309 * vmw_cmd_readback_gb_image - Validate an SVGA_3D_CMD_READBACK_GB_IMAGE
1310 * command
1311 *
1312 * @dev_priv: Pointer to a device private struct.
1313 * @sw_context: The software context being used for this batch.
1314 * @header: Pointer to the command header in the command stream.
1315 */
1316static int vmw_cmd_readback_gb_image(struct vmw_private *dev_priv,
1317 struct vmw_sw_context *sw_context,
1318 SVGA3dCmdHeader *header)
1319{
1320 struct vmw_gb_surface_cmd {
1321 SVGA3dCmdHeader header;
1322 SVGA3dCmdReadbackGBImage body;
1323 } *cmd;
1324
1325 cmd = container_of(header, struct vmw_gb_surface_cmd, header);
1326
1327 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
1328 user_surface_converter,
1329 &cmd->body.image.sid, NULL);
1330}
1331
1332/**
1333 * vmw_cmd_readback_gb_surface - Validate an SVGA_3D_CMD_READBACK_GB_SURFACE
1334 * command
1335 *
1336 * @dev_priv: Pointer to a device private struct.
1337 * @sw_context: The software context being used for this batch.
1338 * @header: Pointer to the command header in the command stream.
1339 */
1340static int vmw_cmd_readback_gb_surface(struct vmw_private *dev_priv,
1341 struct vmw_sw_context *sw_context,
1342 SVGA3dCmdHeader *header)
1343{
1344 struct vmw_gb_surface_cmd {
1345 SVGA3dCmdHeader header;
1346 SVGA3dCmdReadbackGBSurface body;
1347 } *cmd;
1348
1349 cmd = container_of(header, struct vmw_gb_surface_cmd, header);
1350
1351 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
1352 user_surface_converter,
1353 &cmd->body.sid, NULL);
1354}
1355
1356/**
1357 * vmw_cmd_invalidate_gb_image - Validate an SVGA_3D_CMD_INVALIDATE_GB_IMAGE
1358 * command
1359 *
1360 * @dev_priv: Pointer to a device private struct.
1361 * @sw_context: The software context being used for this batch.
1362 * @header: Pointer to the command header in the command stream.
1363 */
1364static int vmw_cmd_invalidate_gb_image(struct vmw_private *dev_priv,
1365 struct vmw_sw_context *sw_context,
1366 SVGA3dCmdHeader *header)
1367{
1368 struct vmw_gb_surface_cmd {
1369 SVGA3dCmdHeader header;
1370 SVGA3dCmdInvalidateGBImage body;
1371 } *cmd;
1372
1373 cmd = container_of(header, struct vmw_gb_surface_cmd, header);
1374
1375 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
1376 user_surface_converter,
1377 &cmd->body.image.sid, NULL);
1378}
1379
1380/**
1381 * vmw_cmd_invalidate_gb_surface - Validate an
1382 * SVGA_3D_CMD_INVALIDATE_GB_SURFACE command
1383 *
1384 * @dev_priv: Pointer to a device private struct.
1385 * @sw_context: The software context being used for this batch.
1386 * @header: Pointer to the command header in the command stream.
1387 */
1388static int vmw_cmd_invalidate_gb_surface(struct vmw_private *dev_priv,
1389 struct vmw_sw_context *sw_context,
1390 SVGA3dCmdHeader *header)
1391{
1392 struct vmw_gb_surface_cmd {
1393 SVGA3dCmdHeader header;
1394 SVGA3dCmdInvalidateGBSurface body;
1395 } *cmd;
1396
1397 cmd = container_of(header, struct vmw_gb_surface_cmd, header);
1398
1399 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
1400 user_surface_converter,
1401 &cmd->body.sid, NULL);
1402}
1403
1404/**
1189 * vmw_cmd_set_shader - Validate an SVGA_3D_CMD_SET_SHADER 1405 * vmw_cmd_set_shader - Validate an SVGA_3D_CMD_SET_SHADER
1190 * command 1406 * command
1191 * 1407 *
@@ -1300,6 +1516,21 @@ static vmw_cmd_func vmw_cmd_funcs[SVGA_3D_CMD_MAX] = {
1300 VMW_CMD_DEF(SVGA_3D_CMD_GENERATE_MIPMAPS, &vmw_cmd_invalid), 1516 VMW_CMD_DEF(SVGA_3D_CMD_GENERATE_MIPMAPS, &vmw_cmd_invalid),
1301 VMW_CMD_DEF(SVGA_3D_CMD_ACTIVATE_SURFACE, &vmw_cmd_invalid), 1517 VMW_CMD_DEF(SVGA_3D_CMD_ACTIVATE_SURFACE, &vmw_cmd_invalid),
1302 VMW_CMD_DEF(SVGA_3D_CMD_DEACTIVATE_SURFACE, &vmw_cmd_invalid), 1518 VMW_CMD_DEF(SVGA_3D_CMD_DEACTIVATE_SURFACE, &vmw_cmd_invalid),
1519 VMW_CMD_DEF(SVGA_3D_CMD_DEFINE_GB_SURFACE, &vmw_cmd_invalid),
1520 VMW_CMD_DEF(SVGA_3D_CMD_DESTROY_GB_SURFACE, &vmw_cmd_invalid),
1521 VMW_CMD_DEF(SVGA_3D_CMD_BIND_GB_SURFACE, &vmw_cmd_bind_gb_surface),
1522 VMW_CMD_DEF(SVGA_3D_CMD_COND_BIND_GB_SURFACE, &vmw_cmd_invalid),
1523 VMW_CMD_DEF(SVGA_3D_CMD_UPDATE_GB_IMAGE, &vmw_cmd_update_gb_image),
1524 VMW_CMD_DEF(SVGA_3D_CMD_UPDATE_GB_SURFACE,
1525 &vmw_cmd_update_gb_surface),
1526 VMW_CMD_DEF(SVGA_3D_CMD_READBACK_GB_IMAGE,
1527 &vmw_cmd_readback_gb_image),
1528 VMW_CMD_DEF(SVGA_3D_CMD_READBACK_GB_SURFACE,
1529 &vmw_cmd_readback_gb_surface),
1530 VMW_CMD_DEF(SVGA_3D_CMD_INVALIDATE_GB_IMAGE,
1531 &vmw_cmd_invalidate_gb_image),
1532 VMW_CMD_DEF(SVGA_3D_CMD_INVALIDATE_GB_SURFACE,
1533 &vmw_cmd_invalidate_gb_surface),
1303 VMW_CMD_DEF(SVGA_3D_CMD_DEFINE_GB_CONTEXT, &vmw_cmd_invalid), 1534 VMW_CMD_DEF(SVGA_3D_CMD_DEFINE_GB_CONTEXT, &vmw_cmd_invalid),
1304 VMW_CMD_DEF(SVGA_3D_CMD_DESTROY_GB_CONTEXT, &vmw_cmd_invalid), 1535 VMW_CMD_DEF(SVGA_3D_CMD_DESTROY_GB_CONTEXT, &vmw_cmd_invalid),
1305 VMW_CMD_DEF(SVGA_3D_CMD_BIND_GB_CONTEXT, &vmw_cmd_invalid), 1536 VMW_CMD_DEF(SVGA_3D_CMD_BIND_GB_CONTEXT, &vmw_cmd_invalid),