drm/ttm/vmwgfx: Have TTM manage the validation sequence.
authorThomas Hellstrom <thellstrom@vmware.com>
Wed, 17 Nov 2010 12:28:31 +0000 (12:28 +0000)
committerDave Airlie <airlied@redhat.com>
Mon, 22 Nov 2010 03:25:21 +0000 (13:25 +1000)
Rather than having the driver supply the validation sequence, leave that
responsibility to TTM. This saves some confusion and a function argument.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/ttm/ttm_bo.c
drivers/gpu/drm/ttm/ttm_execbuf_util.c
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
include/drm/ttm/ttm_bo_driver.h
include/drm/ttm/ttm_execbuf_util.h

index 551a5d31cadf616c537562e2349e897801cd14ec..25e4c2a1d1d8c8ba9be32edab75c12ea7c61e7d3 100644 (file)
@@ -1539,6 +1539,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
        bdev->dev_mapping = NULL;
        bdev->glob = glob;
        bdev->need_dma32 = need_dma32;
+       bdev->val_seq = 0;
        spin_lock_init(&bdev->fence_lock);
        mutex_lock(&glob->device_list_mutex);
        list_add_tail(&bdev->device_list, &glob->device_list);
index b6da65cc502a56cf6b645006f42413b523ae75b3..3832fe10b4dffe100ac44c05397819e140822356 100644 (file)
@@ -126,11 +126,12 @@ EXPORT_SYMBOL(ttm_eu_backoff_reservation);
  * buffers in different orders.
  */
 
-int ttm_eu_reserve_buffers(struct list_head *list, uint32_t val_seq)
+int ttm_eu_reserve_buffers(struct list_head *list)
 {
        struct ttm_bo_global *glob;
        struct ttm_validate_buffer *entry;
        int ret;
+       uint32_t val_seq;
 
        if (list_empty(list))
                return 0;
@@ -146,6 +147,8 @@ int ttm_eu_reserve_buffers(struct list_head *list, uint32_t val_seq)
 
 retry:
        spin_lock(&glob->lru_lock);
+       val_seq = entry->bo->bdev->val_seq++;
+
        list_for_each_entry(entry, list, head) {
                struct ttm_buffer_object *bo = entry->bo;
 
index e7a58d055041bfacd5e4af4b5f6f055dd6214a5b..10fc01f69c4041ba3818e52573bb864ffb694832 100644 (file)
@@ -264,7 +264,6 @@ struct vmw_private {
         */
 
        struct vmw_sw_context ctx;
-       uint32_t val_seq;
        struct mutex cmdbuf_mutex;
 
        /**
index 76954e3528c1d6ccb763973c22b7f7979ad4f1b4..41b95ed6dbcddf67ef7f746c5393c58312c9409f 100644 (file)
@@ -653,8 +653,7 @@ int vmw_execbuf_ioctl(struct drm_device *dev, void *data,
        ret = vmw_cmd_check_all(dev_priv, sw_context, cmd, arg->command_size);
        if (unlikely(ret != 0))
                goto out_err;
-       ret = ttm_eu_reserve_buffers(&sw_context->validate_nodes,
-                                    dev_priv->val_seq++);
+       ret = ttm_eu_reserve_buffers(&sw_context->validate_nodes);
        if (unlikely(ret != 0))
                goto out_err;
 
index cfb9ca4ec1c43ea71411475563ca27a5abd444b3..e3b2e245db1bb9bdaf8a65adaba210eb59e54569 100644 (file)
@@ -515,6 +515,7 @@ struct ttm_bo_global {
  * @addr_space_mm: Range manager for the device address space.
  * lru_lock: Spinlock that protects the buffer+device lru lists and
  * ddestroy lists.
+ * @val_seq: Current validation sequence.
  * @nice_mode: Try nicely to wait for buffer idle when cleaning a manager.
  * If a GPU lockup has been detected, this is forced to 0.
  * @dev_mapping: A pointer to the struct address_space representing the
@@ -544,6 +545,7 @@ struct ttm_bo_device {
         * Protected by the global:lru lock.
         */
        struct list_head ddestroy;
+       uint32_t val_seq;
 
        /*
         * Protected by load / firstopen / lastclose /unload sync.
index 535ab00407e0dd857d8537a83602970d1d2bc9ed..26cc7f9ffa411ab7257f87545cd766be8c5b182a 100644 (file)
@@ -72,7 +72,6 @@ extern void ttm_eu_backoff_reservation(struct list_head *list);
  * function ttm_eu_reserve_buffers
  *
  * @list:    thread private list of ttm_validate_buffer structs.
- * @val_seq: A unique sequence number.
  *
  * Tries to reserve bos pointed to by the list entries for validation.
  * If the function returns 0, all buffers are marked as "unfenced",
@@ -94,7 +93,7 @@ extern void ttm_eu_backoff_reservation(struct list_head *list);
  * has failed.
  */
 
-extern int ttm_eu_reserve_buffers(struct list_head *list, uint32_t val_seq);
+extern int ttm_eu_reserve_buffers(struct list_head *list);
 
 /**
  * function ttm_eu_fence_buffer_objects.