Rev 4080 | Rev 4570 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4080 | Rev 4569 | ||
---|---|---|---|
Line 39... | Line 39... | ||
39 | { |
39 | { |
40 | __le32 __iomem *fifo_mem = dev_priv->mmio_virt; |
40 | __le32 __iomem *fifo_mem = dev_priv->mmio_virt; |
41 | uint32_t fifo_min, hwversion; |
41 | uint32_t fifo_min, hwversion; |
42 | const struct vmw_fifo_state *fifo = &dev_priv->fifo; |
42 | const struct vmw_fifo_state *fifo = &dev_priv->fifo; |
Line -... | Line 43... | ||
- | 43 | ||
- | 44 | if (!(dev_priv->capabilities & SVGA_CAP_3D)) |
|
- | 45 | return false; |
|
- | 46 | ||
- | 47 | if (dev_priv->capabilities & SVGA_CAP_GBOBJECTS) { |
|
- | 48 | uint32_t result; |
|
- | 49 | ||
- | 50 | if (!dev_priv->has_mob) |
|
- | 51 | return false; |
|
- | 52 | ||
- | 53 | mutex_lock(&dev_priv->hw_mutex); |
|
- | 54 | vmw_write(dev_priv, SVGA_REG_DEV_CAP, SVGA3D_DEVCAP_3D); |
|
- | 55 | result = vmw_read(dev_priv, SVGA_REG_DEV_CAP); |
|
- | 56 | mutex_unlock(&dev_priv->hw_mutex); |
|
- | 57 | ||
- | 58 | return (result != 0); |
|
- | 59 | } |
|
43 | 60 | ||
44 | if (!(dev_priv->capabilities & SVGA_CAP_EXTENDED_FIFO)) |
61 | if (!(dev_priv->capabilities & SVGA_CAP_EXTENDED_FIFO)) |
Line 45... | Line 62... | ||
45 | return false; |
62 | return false; |
46 | 63 | ||
Line 516... | Line 533... | ||
516 | out_err: |
533 | out_err: |
517 | return ret; |
534 | return ret; |
518 | } |
535 | } |
Line 519... | Line 536... | ||
519 | 536 | ||
520 | /** |
537 | /** |
- | 538 | * vmw_fifo_emit_dummy_legacy_query - emits a dummy query to the fifo using |
|
521 | * vmw_fifo_emit_dummy_query - emits a dummy query to the fifo. |
539 | * legacy query commands. |
522 | * |
540 | * |
523 | * @dev_priv: The device private structure. |
541 | * @dev_priv: The device private structure. |
524 | * @cid: The hardware context id used for the query. |
542 | * @cid: The hardware context id used for the query. |
525 | * |
543 | * |
526 | * This function is used to emit a dummy occlusion query with |
- | |
527 | * no primitives rendered between query begin and query end. |
- | |
528 | * It's used to provide a query barrier, in order to know that when |
- | |
529 | * this query is finished, all preceding queries are also finished. |
- | |
530 | * |
- | |
531 | * A Query results structure should have been initialized at the start |
- | |
532 | * of the dev_priv->dummy_query_bo buffer object. And that buffer object |
- | |
533 | * must also be either reserved or pinned when this function is called. |
- | |
534 | * |
- | |
535 | * Returns -ENOMEM on failure to reserve fifo space. |
544 | * See the vmw_fifo_emit_dummy_query documentation. |
536 | */ |
545 | */ |
537 | int vmw_fifo_emit_dummy_query(struct vmw_private *dev_priv, |
546 | static int vmw_fifo_emit_dummy_legacy_query(struct vmw_private *dev_priv, |
538 | uint32_t cid) |
547 | uint32_t cid) |
539 | { |
548 | { |
540 | /* |
549 | /* |
541 | * A query wait without a preceding query end will |
550 | * A query wait without a preceding query end will |
Line 571... | Line 580... | ||
571 | 580 | ||
Line 572... | Line 581... | ||
572 | vmw_fifo_commit(dev_priv, sizeof(*cmd)); |
581 | vmw_fifo_commit(dev_priv, sizeof(*cmd)); |
573 | 582 | ||
- | 583 | return 0; |
|
- | 584 | } |
|
- | 585 | ||
- | 586 | /** |
|
- | 587 | * vmw_fifo_emit_dummy_gb_query - emits a dummy query to the fifo using |
|
- | 588 | * guest-backed resource query commands. |
|
- | 589 | * |
|
- | 590 | * @dev_priv: The device private structure. |
|
- | 591 | * @cid: The hardware context id used for the query. |
|
- | 592 | * |
|
- | 593 | * See the vmw_fifo_emit_dummy_query documentation. |
|
- | 594 | */ |
|
- | 595 | static int vmw_fifo_emit_dummy_gb_query(struct vmw_private *dev_priv, |
|
- | 596 | uint32_t cid) |
|
- | 597 | { |
|
- | 598 | /* |
|
- | 599 | * A query wait without a preceding query end will |
|
- | 600 | * actually finish all queries for this cid |
|
- | 601 | * without writing to the query result structure. |
|
- | 602 | */ |
|
- | 603 | ||
- | 604 | struct ttm_buffer_object *bo = dev_priv->dummy_query_bo; |
|
- | 605 | struct { |
|
- | 606 | SVGA3dCmdHeader header; |
|
- | 607 | SVGA3dCmdWaitForGBQuery body; |
|
- | 608 | } *cmd; |
|
- | 609 | ||
- | 610 | cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd)); |
|
- | 611 | ||
- | 612 | if (unlikely(cmd == NULL)) { |
|
- | 613 | DRM_ERROR("Out of fifo space for dummy query.\n"); |
|
- | 614 | return -ENOMEM; |
|
- | 615 | } |
|
- | 616 | ||
- | 617 | cmd->header.id = SVGA_3D_CMD_WAIT_FOR_GB_QUERY; |
|
- | 618 | cmd->header.size = sizeof(cmd->body); |
|
- | 619 | cmd->body.cid = cid; |
|
- | 620 | cmd->body.type = SVGA3D_QUERYTYPE_OCCLUSION; |
|
- | 621 | BUG_ON(bo->mem.mem_type != VMW_PL_MOB); |
|
- | 622 | cmd->body.mobid = bo->mem.start; |
|
- | 623 | cmd->body.offset = 0; |
|
- | 624 | ||
- | 625 | vmw_fifo_commit(dev_priv, sizeof(*cmd)); |
|
- | 626 | ||
- | 627 | return 0; |
|
- | 628 | } |
|
- | 629 | ||
- | 630 | ||
- | 631 | /** |
|
- | 632 | * vmw_fifo_emit_dummy_gb_query - emits a dummy query to the fifo using |
|
- | 633 | * appropriate resource query commands. |
|
- | 634 | * |
|
- | 635 | * @dev_priv: The device private structure. |
|
- | 636 | * @cid: The hardware context id used for the query. |
|
- | 637 | * |
|
- | 638 | * This function is used to emit a dummy occlusion query with |
|
- | 639 | * no primitives rendered between query begin and query end. |
|
- | 640 | * It's used to provide a query barrier, in order to know that when |
|
- | 641 | * this query is finished, all preceding queries are also finished. |
|
- | 642 | * |
|
- | 643 | * A Query results structure should have been initialized at the start |
|
- | 644 | * of the dev_priv->dummy_query_bo buffer object. And that buffer object |
|
- | 645 | * must also be either reserved or pinned when this function is called. |
|
- | 646 | * |
|
- | 647 | * Returns -ENOMEM on failure to reserve fifo space. |
|
- | 648 | */ |
|
- | 649 | int vmw_fifo_emit_dummy_query(struct vmw_private *dev_priv, |
|
- | 650 | uint32_t cid) |
|
- | 651 | { |
|
- | 652 | if (dev_priv->has_mob) |
|
- | 653 | return vmw_fifo_emit_dummy_gb_query(dev_priv, cid); |
|
- | 654 |