hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
....@@ -28,7 +28,8 @@
2828 * Christian König <deathsimple@vodafone.de>
2929 */
3030
31
-#include <drm/drmP.h>
31
+#include <linux/uaccess.h>
32
+
3233 #include "amdgpu.h"
3334 #include "amdgpu_trace.h"
3435
....@@ -49,8 +50,11 @@
4950 refcount);
5051 struct amdgpu_bo_list_entry *e;
5152
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
+ }
5458
5559 call_rcu(&list->rhead, amdgpu_bo_list_free_rcu);
5660 }
....@@ -78,9 +82,9 @@
7882 return -ENOMEM;
7983
8084 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;
8488
8589 array = amdgpu_bo_list_array_entry(list, 0);
8690 memset(array, 0, num_entries * sizeof(struct amdgpu_bo_list_entry));
....@@ -98,7 +102,7 @@
98102 }
99103
100104 bo = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj));
101
- drm_gem_object_put_unlocked(gobj);
105
+ drm_gem_object_put(gobj);
102106
103107 usermm = amdgpu_ttm_tt_get_usermm(bo->tbo.ttm);
104108 if (usermm) {
....@@ -112,21 +116,19 @@
112116 entry = &array[last_entry++];
113117 }
114118
115
- entry->robj = bo;
116119 entry->priority = min(info[i].bo_priority,
117120 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;
120122
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;
127129
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);
130132 }
131133
132134 list->first_userptr = first_userptr;
....@@ -138,8 +140,16 @@
138140 return 0;
139141
140142 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
+ }
143153 kvfree(list);
144154 return r;
145155
....@@ -191,9 +201,10 @@
191201 * with the same priority, i.e. it must be stable.
192202 */
193203 amdgpu_bo_list_for_each_entry(e, list) {
204
+ struct amdgpu_bo *bo = ttm_to_amdgpu_bo(e->tv.bo);
194205 unsigned priority = e->priority;
195206
196
- if (!e->robj->parent)
207
+ if (!bo->parent)
197208 list_add_tail(&e->tv.head, &bucket[priority]);
198209
199210 e->user_pages = NULL;
....@@ -254,7 +265,7 @@
254265 int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
255266 struct drm_file *filp)
256267 {
257
- struct amdgpu_device *adev = dev->dev_private;
268
+ struct amdgpu_device *adev = drm_to_adev(dev);
258269 struct amdgpu_fpriv *fpriv = filp->driver_priv;
259270 union drm_amdgpu_bo_list *args = data;
260271 uint32_t handle = args->in.list_handle;