Skip to content

Commit 81c6dab

Browse files
ChristianKoenigAMDalexdeucher
authored andcommitted
drm/amdgpu: always recreate bo_list
The bo_list handle is allocated by OP_CREATE, so in OP_UPDATE here we just re-create the bo_list object and replace the handle. This way we don't need locking to protect the bo_list because it's always re-created when changed. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Chunming Zhou <david1.zhou@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 4a8c21a commit 81c6dab

3 files changed

Lines changed: 12 additions & 15 deletions

File tree

‎drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ static void amdgpu_bo_list_release_rcu(struct kref *ref)
5050
for (i = 0; i < list->num_entries; ++i)
5151
amdgpu_bo_unref(&list->array[i].robj);
5252

53-
mutex_destroy(&list->lock);
5453
kvfree(list->array);
5554
kfree_rcu(list, rhead);
5655
}
@@ -70,7 +69,6 @@ int amdgpu_bo_list_create(struct amdgpu_device *adev,
7069
return -ENOMEM;
7170

7271
/* initialize bo list*/
73-
mutex_init(&list->lock);
7472
kref_init(&list->refcount);
7573
r = amdgpu_bo_list_set(adev, filp, list, info, num_entries);
7674
if (r) {
@@ -188,7 +186,6 @@ int amdgpu_bo_list_get(struct amdgpu_fpriv *fpriv, int id,
188186

189187
if (*result && kref_get_unless_zero(&(*result)->refcount)) {
190188
rcu_read_unlock();
191-
mutex_lock(&(*result)->lock);
192189
return 0;
193190
}
194191

@@ -231,7 +228,6 @@ void amdgpu_bo_list_get_list(struct amdgpu_bo_list *list,
231228

232229
void amdgpu_bo_list_put(struct amdgpu_bo_list *list)
233230
{
234-
mutex_unlock(&list->lock);
235231
kref_put(&list->refcount, amdgpu_bo_list_release_rcu);
236232
}
237233

@@ -242,7 +238,6 @@ void amdgpu_bo_list_free(struct amdgpu_bo_list *list)
242238
for (i = 0; i < list->num_entries; ++i)
243239
amdgpu_bo_unref(&list->array[i].robj);
244240

245-
mutex_destroy(&list->lock);
246241
kvfree(list->array);
247242
kfree(list);
248243
}
@@ -297,7 +292,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
297292
union drm_amdgpu_bo_list *args = data;
298293
uint32_t handle = args->in.list_handle;
299294
struct drm_amdgpu_bo_list_entry *info = NULL;
300-
struct amdgpu_bo_list *list;
295+
struct amdgpu_bo_list *list, *old;
301296
int r;
302297

303298
r = amdgpu_bo_create_list_entry_array(&args->in, &info);
@@ -328,16 +323,22 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
328323
break;
329324

330325
case AMDGPU_BO_LIST_OP_UPDATE:
331-
r = amdgpu_bo_list_get(fpriv, handle, &list);
326+
r = amdgpu_bo_list_create(adev, filp, info, args->in.bo_number,
327+
&list);
332328
if (r)
333329
goto error_free;
334330

335-
r = amdgpu_bo_list_set(adev, filp, list, info,
336-
args->in.bo_number);
337-
amdgpu_bo_list_put(list);
338-
if (r)
331+
mutex_lock(&fpriv->bo_list_lock);
332+
old = idr_replace(&fpriv->bo_list_handles, list, handle);
333+
mutex_unlock(&fpriv->bo_list_lock);
334+
335+
if (IS_ERR(old)) {
336+
amdgpu_bo_list_put(list);
337+
r = PTR_ERR(old);
339338
goto error_free;
339+
}
340340

341+
amdgpu_bo_list_put(old);
341342
break;
342343

343344
default:

‎drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ struct amdgpu_bo_list_entry {
4141
};
4242

4343
struct amdgpu_bo_list {
44-
struct mutex lock;
4544
struct rcu_head rhead;
4645
struct kref refcount;
4746
struct amdgpu_bo *gds_obj;

‎drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,6 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
580580
&p->bo_list);
581581
if (r)
582582
return r;
583-
584-
} else if (p->bo_list) {
585-
mutex_lock(&p->bo_list->lock);
586583
}
587584

588585
if (p->bo_list) {

0 commit comments

Comments
 (0)