Skip to content

Commit bd0b8e9

Browse files
committed
drm/msm: Drop submit bo_list
This was only used to detect userspace including the same bo multiple times in a submit. But ww_mutex can already tell us this. When we drop struct_mutex around the submit ioctl, we'd otherwise need to lock the bo before adding it to the bo_list. But since ww_mutex can already tell us this, it is simpler just to remove the bo_list. Signed-off-by: Rob Clark <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Clark <[email protected]>
1 parent 1d8a5ca commit bd0b8e9

File tree

3 files changed

+13
-24
lines changed

3 files changed

+13
-24
lines changed

drivers/gpu/drm/msm/msm_gem.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,6 @@ static int msm_gem_new_impl(struct drm_device *dev,
11481148
msm_obj->flags = flags;
11491149
msm_obj->madv = MSM_MADV_WILLNEED;
11501150

1151-
INIT_LIST_HEAD(&msm_obj->submit_entry);
11521151
INIT_LIST_HEAD(&msm_obj->vmas);
11531152

11541153
*obj = &msm_obj->base;

drivers/gpu/drm/msm/msm_gem.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,6 @@ struct msm_gem_object {
8888
*/
8989
struct list_head mm_list;
9090

91-
/* Transiently in the process of submit ioctl, objects associated
92-
* with the submit are on submit->bo_list.. this only lasts for
93-
* the duration of the ioctl, so one bo can never be on multiple
94-
* submit lists.
95-
*/
96-
struct list_head submit_entry;
97-
9891
struct page **pages;
9992
struct sg_table *sgt;
10093
void *vaddr;
@@ -316,7 +309,6 @@ struct msm_gem_submit {
316309
struct msm_gpu *gpu;
317310
struct msm_gem_address_space *aspace;
318311
struct list_head node; /* node in ring submit list */
319-
struct list_head bo_list;
320312
struct ww_acquire_ctx ticket;
321313
uint32_t seqno; /* Sequence number of the submit on the ring */
322314

drivers/gpu/drm/msm/msm_gem_submit.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ static struct msm_gem_submit *submit_create(struct drm_device *dev,
6363
submit->fault_dumped = false;
6464

6565
INIT_LIST_HEAD(&submit->node);
66-
INIT_LIST_HEAD(&submit->bo_list);
6766

6867
return submit;
6968
}
@@ -143,7 +142,6 @@ static int submit_lookup_objects(struct msm_gem_submit *submit,
143142

144143
for (i = 0; i < args->nr_bos; i++) {
145144
struct drm_gem_object *obj;
146-
struct msm_gem_object *msm_obj;
147145

148146
/* normally use drm_gem_object_lookup(), but for bulk lookup
149147
* all under single table_lock just hit object_idr directly:
@@ -155,20 +153,9 @@ static int submit_lookup_objects(struct msm_gem_submit *submit,
155153
goto out_unlock;
156154
}
157155

158-
msm_obj = to_msm_bo(obj);
159-
160-
if (!list_empty(&msm_obj->submit_entry)) {
161-
DRM_ERROR("handle %u at index %u already on submit list\n",
162-
submit->bos[i].handle, i);
163-
ret = -EINVAL;
164-
goto out_unlock;
165-
}
166-
167156
drm_gem_object_get(obj);
168157

169-
submit->bos[i].obj = msm_obj;
170-
171-
list_add_tail(&msm_obj->submit_entry, &submit->bo_list);
158+
submit->bos[i].obj = to_msm_bo(obj);
172159
}
173160

174161
out_unlock:
@@ -299,6 +286,12 @@ static int submit_lock_objects(struct msm_gem_submit *submit)
299286
return 0;
300287

301288
fail:
289+
if (ret == -EALREADY) {
290+
DRM_ERROR("handle %u at index %u already on submit list\n",
291+
submit->bos[i].handle, i);
292+
ret = -EINVAL;
293+
}
294+
302295
for (; i >= 0; i--)
303296
submit_unlock_unpin_bo(submit, i);
304297

@@ -315,6 +308,12 @@ static int submit_lock_objects(struct msm_gem_submit *submit)
315308
slow_locked = contended;
316309
goto retry;
317310
}
311+
312+
/* Not expecting -EALREADY here, if the bo was already
313+
* locked, we should have gotten -EALREADY already from
314+
* the dma_resv_lock_interruptable() call.
315+
*/
316+
WARN_ON_ONCE(ret == -EALREADY);
318317
}
319318

320319
return ret;
@@ -508,7 +507,6 @@ static void submit_cleanup(struct msm_gem_submit *submit, bool error)
508507
for (i = 0; i < submit->nr_bos; i++) {
509508
struct msm_gem_object *msm_obj = submit->bos[i].obj;
510509
submit_cleanup_bo(submit, i, cleanup_flags);
511-
list_del_init(&msm_obj->submit_entry);
512510
if (error)
513511
drm_gem_object_put(&msm_obj->base);
514512
}

0 commit comments

Comments
 (0)