| .. | .. |
|---|
| 28 | 28 | * Christian König <deathsimple@vodafone.de> |
|---|
| 29 | 29 | */ |
|---|
| 30 | 30 | |
|---|
| 31 | | -#include <drm/drmP.h> |
|---|
| 31 | +#include <linux/uaccess.h> |
|---|
| 32 | + |
|---|
| 32 | 33 | #include "amdgpu.h" |
|---|
| 33 | 34 | #include "amdgpu_trace.h" |
|---|
| 34 | 35 | |
|---|
| .. | .. |
|---|
| 49 | 50 | refcount); |
|---|
| 50 | 51 | struct amdgpu_bo_list_entry *e; |
|---|
| 51 | 52 | |
|---|
| 52 | | - amdgpu_bo_list_for_each_entry(e, list) |
|---|
| 53 | | - amdgpu_bo_unref(&e->robj); |
|---|
| 53 | + amdgpu_bo_list_for_each_entry(e, list) { |
|---|
| 54 | + struct amdgpu_bo *bo = ttm_to_amdgpu_bo(e->tv.bo); |
|---|
| 55 | + |
|---|
| 56 | + amdgpu_bo_unref(&bo); |
|---|
| 57 | + } |
|---|
| 54 | 58 | |
|---|
| 55 | 59 | call_rcu(&list->rhead, amdgpu_bo_list_free_rcu); |
|---|
| 56 | 60 | } |
|---|
| .. | .. |
|---|
| 78 | 82 | return -ENOMEM; |
|---|
| 79 | 83 | |
|---|
| 80 | 84 | kref_init(&list->refcount); |
|---|
| 81 | | - list->gds_obj = adev->gds.gds_gfx_bo; |
|---|
| 82 | | - list->gws_obj = adev->gds.gws_gfx_bo; |
|---|
| 83 | | - list->oa_obj = adev->gds.oa_gfx_bo; |
|---|
| 85 | + list->gds_obj = NULL; |
|---|
| 86 | + list->gws_obj = NULL; |
|---|
| 87 | + list->oa_obj = NULL; |
|---|
| 84 | 88 | |
|---|
| 85 | 89 | array = amdgpu_bo_list_array_entry(list, 0); |
|---|
| 86 | 90 | memset(array, 0, num_entries * sizeof(struct amdgpu_bo_list_entry)); |
|---|
| .. | .. |
|---|
| 98 | 102 | } |
|---|
| 99 | 103 | |
|---|
| 100 | 104 | bo = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj)); |
|---|
| 101 | | - drm_gem_object_put_unlocked(gobj); |
|---|
| 105 | + drm_gem_object_put(gobj); |
|---|
| 102 | 106 | |
|---|
| 103 | 107 | usermm = amdgpu_ttm_tt_get_usermm(bo->tbo.ttm); |
|---|
| 104 | 108 | if (usermm) { |
|---|
| .. | .. |
|---|
| 112 | 116 | entry = &array[last_entry++]; |
|---|
| 113 | 117 | } |
|---|
| 114 | 118 | |
|---|
| 115 | | - entry->robj = bo; |
|---|
| 116 | 119 | entry->priority = min(info[i].bo_priority, |
|---|
| 117 | 120 | AMDGPU_BO_LIST_MAX_PRIORITY); |
|---|
| 118 | | - entry->tv.bo = &entry->robj->tbo; |
|---|
| 119 | | - entry->tv.shared = !entry->robj->prime_shared_count; |
|---|
| 121 | + entry->tv.bo = &bo->tbo; |
|---|
| 120 | 122 | |
|---|
| 121 | | - if (entry->robj->preferred_domains == AMDGPU_GEM_DOMAIN_GDS) |
|---|
| 122 | | - list->gds_obj = entry->robj; |
|---|
| 123 | | - if (entry->robj->preferred_domains == AMDGPU_GEM_DOMAIN_GWS) |
|---|
| 124 | | - list->gws_obj = entry->robj; |
|---|
| 125 | | - if (entry->robj->preferred_domains == AMDGPU_GEM_DOMAIN_OA) |
|---|
| 126 | | - list->oa_obj = entry->robj; |
|---|
| 123 | + if (bo->preferred_domains == AMDGPU_GEM_DOMAIN_GDS) |
|---|
| 124 | + list->gds_obj = bo; |
|---|
| 125 | + if (bo->preferred_domains == AMDGPU_GEM_DOMAIN_GWS) |
|---|
| 126 | + list->gws_obj = bo; |
|---|
| 127 | + if (bo->preferred_domains == AMDGPU_GEM_DOMAIN_OA) |
|---|
| 128 | + list->oa_obj = bo; |
|---|
| 127 | 129 | |
|---|
| 128 | | - total_size += amdgpu_bo_size(entry->robj); |
|---|
| 129 | | - trace_amdgpu_bo_list_set(list, entry->robj); |
|---|
| 130 | + total_size += amdgpu_bo_size(bo); |
|---|
| 131 | + trace_amdgpu_bo_list_set(list, bo); |
|---|
| 130 | 132 | } |
|---|
| 131 | 133 | |
|---|
| 132 | 134 | list->first_userptr = first_userptr; |
|---|
| .. | .. |
|---|
| 138 | 140 | return 0; |
|---|
| 139 | 141 | |
|---|
| 140 | 142 | error_free: |
|---|
| 141 | | - while (i--) |
|---|
| 142 | | - amdgpu_bo_unref(&array[i].robj); |
|---|
| 143 | + for (i = 0; i < last_entry; ++i) { |
|---|
| 144 | + struct amdgpu_bo *bo = ttm_to_amdgpu_bo(array[i].tv.bo); |
|---|
| 145 | + |
|---|
| 146 | + amdgpu_bo_unref(&bo); |
|---|
| 147 | + } |
|---|
| 148 | + for (i = first_userptr; i < num_entries; ++i) { |
|---|
| 149 | + struct amdgpu_bo *bo = ttm_to_amdgpu_bo(array[i].tv.bo); |
|---|
| 150 | + |
|---|
| 151 | + amdgpu_bo_unref(&bo); |
|---|
| 152 | + } |
|---|
| 143 | 153 | kvfree(list); |
|---|
| 144 | 154 | return r; |
|---|
| 145 | 155 | |
|---|
| .. | .. |
|---|
| 191 | 201 | * with the same priority, i.e. it must be stable. |
|---|
| 192 | 202 | */ |
|---|
| 193 | 203 | amdgpu_bo_list_for_each_entry(e, list) { |
|---|
| 204 | + struct amdgpu_bo *bo = ttm_to_amdgpu_bo(e->tv.bo); |
|---|
| 194 | 205 | unsigned priority = e->priority; |
|---|
| 195 | 206 | |
|---|
| 196 | | - if (!e->robj->parent) |
|---|
| 207 | + if (!bo->parent) |
|---|
| 197 | 208 | list_add_tail(&e->tv.head, &bucket[priority]); |
|---|
| 198 | 209 | |
|---|
| 199 | 210 | e->user_pages = NULL; |
|---|
| .. | .. |
|---|
| 254 | 265 | int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, |
|---|
| 255 | 266 | struct drm_file *filp) |
|---|
| 256 | 267 | { |
|---|
| 257 | | - struct amdgpu_device *adev = dev->dev_private; |
|---|
| 268 | + struct amdgpu_device *adev = drm_to_adev(dev); |
|---|
| 258 | 269 | struct amdgpu_fpriv *fpriv = filp->driver_priv; |
|---|
| 259 | 270 | union drm_amdgpu_bo_list *args = data; |
|---|
| 260 | 271 | uint32_t handle = args->in.list_handle; |
|---|