aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2012-11-21 05:26:55 -0500
committerThomas Hellstrom <thellstrom@vmware.com>2014-01-17 01:52:23 -0500
commitddcda24e3bec1d4c8bcc37e85d1b1b37bf0fecac (patch)
tree73fe64722ed25d0b13b4bb5108299828bf7e1134 /drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
parent96c5f0df22aaf1f20075bc6ad3bdd7656e49cf4d (diff)
drm/vmwgfx: Hook up guest-backed queries
Perform a translation of legacy query commands should they occur in the command stream. 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_fifo.c')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c90
1 files changed, 77 insertions, 13 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
index 3eb148667d63..01baffd90549 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
@@ -511,24 +511,16 @@ out_err:
511} 511}
512 512
513/** 513/**
514 * vmw_fifo_emit_dummy_query - emits a dummy query to the fifo. 514 * vmw_fifo_emit_dummy_legacy_query - emits a dummy query to the fifo using
515 * legacy query commands.
515 * 516 *
516 * @dev_priv: The device private structure. 517 * @dev_priv: The device private structure.
517 * @cid: The hardware context id used for the query. 518 * @cid: The hardware context id used for the query.
518 * 519 *
519 * This function is used to emit a dummy occlusion query with 520 * See the vmw_fifo_emit_dummy_query documentation.
520 * no primitives rendered between query begin and query end.
521 * It's used to provide a query barrier, in order to know that when
522 * this query is finished, all preceding queries are also finished.
523 *
524 * A Query results structure should have been initialized at the start
525 * of the dev_priv->dummy_query_bo buffer object. And that buffer object
526 * must also be either reserved or pinned when this function is called.
527 *
528 * Returns -ENOMEM on failure to reserve fifo space.
529 */ 521 */
530int vmw_fifo_emit_dummy_query(struct vmw_private *dev_priv, 522static int vmw_fifo_emit_dummy_legacy_query(struct vmw_private *dev_priv,
531 uint32_t cid) 523 uint32_t cid)
532{ 524{
533 /* 525 /*
534 * A query wait without a preceding query end will 526 * A query wait without a preceding query end will
@@ -566,3 +558,75 @@ int vmw_fifo_emit_dummy_query(struct vmw_private *dev_priv,
566 558
567 return 0; 559 return 0;
568} 560}
561
562/**
563 * vmw_fifo_emit_dummy_gb_query - emits a dummy query to the fifo using
564 * guest-backed resource query commands.
565 *
566 * @dev_priv: The device private structure.
567 * @cid: The hardware context id used for the query.
568 *
569 * See the vmw_fifo_emit_dummy_query documentation.
570 */
571static int vmw_fifo_emit_dummy_gb_query(struct vmw_private *dev_priv,
572 uint32_t cid)
573{
574 /*
575 * A query wait without a preceding query end will
576 * actually finish all queries for this cid
577 * without writing to the query result structure.
578 */
579
580 struct ttm_buffer_object *bo = dev_priv->dummy_query_bo;
581 struct {
582 SVGA3dCmdHeader header;
583 SVGA3dCmdWaitForGBQuery body;
584 } *cmd;
585
586 cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd));
587
588 if (unlikely(cmd == NULL)) {
589 DRM_ERROR("Out of fifo space for dummy query.\n");
590 return -ENOMEM;
591 }
592
593 cmd->header.id = SVGA_3D_CMD_WAIT_FOR_GB_QUERY;
594 cmd->header.size = sizeof(cmd->body);
595 cmd->body.cid = cid;
596 cmd->body.type = SVGA3D_QUERYTYPE_OCCLUSION;
597 BUG_ON(bo->mem.mem_type != VMW_PL_MOB);
598 cmd->body.mobid = bo->mem.start;
599 cmd->body.offset = 0;
600
601 vmw_fifo_commit(dev_priv, sizeof(*cmd));
602
603 return 0;
604}
605
606
607/**
608 * vmw_fifo_emit_dummy_gb_query - emits a dummy query to the fifo using
609 * appropriate resource query commands.
610 *
611 * @dev_priv: The device private structure.
612 * @cid: The hardware context id used for the query.
613 *
614 * This function is used to emit a dummy occlusion query with
615 * no primitives rendered between query begin and query end.
616 * It's used to provide a query barrier, in order to know that when
617 * this query is finished, all preceding queries are also finished.
618 *
619 * A Query results structure should have been initialized at the start
620 * of the dev_priv->dummy_query_bo buffer object. And that buffer object
621 * must also be either reserved or pinned when this function is called.
622 *
623 * Returns -ENOMEM on failure to reserve fifo space.
624 */
625int vmw_fifo_emit_dummy_query(struct vmw_private *dev_priv,
626 uint32_t cid)
627{
628 if (dev_priv->has_mob)
629 return vmw_fifo_emit_dummy_gb_query(dev_priv, cid);
630
631 return vmw_fifo_emit_dummy_legacy_query(dev_priv, cid);
632}