Skip to content

Commit 9509503

Browse files
author
Ben Skeggs
committed
drm/nouveau/instmem: protect instobj list with a spinlock
No locking is required for the traversal of this list, as it only happens during suspend/resume where nothing else can be executing. Fixes some of the issues noticed during parallel piglit runs. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
1 parent c294a05 commit 9509503

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

  • drivers/gpu/drm/nouveau

drivers/gpu/drm/nouveau/include/nvkm/subdev/instmem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ struct nvkm_instmem {
77
const struct nvkm_instmem_func *func;
88
struct nvkm_subdev subdev;
99

10+
spinlock_t lock;
1011
struct list_head list;
1112
u32 reserved;
1213

drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ static void *
9797
nvkm_instobj_dtor(struct nvkm_memory *memory)
9898
{
9999
struct nvkm_instobj *iobj = nvkm_instobj(memory);
100+
spin_lock(&iobj->imem->lock);
100101
list_del(&iobj->head);
102+
spin_unlock(&iobj->imem->lock);
101103
nvkm_memory_del(&iobj->parent);
102104
return iobj;
103105
}
@@ -190,7 +192,9 @@ nvkm_instobj_new(struct nvkm_instmem *imem, u32 size, u32 align, bool zero,
190192
nvkm_memory_ctor(&nvkm_instobj_func_slow, &iobj->memory);
191193
iobj->parent = memory;
192194
iobj->imem = imem;
195+
spin_lock(&iobj->imem->lock);
193196
list_add_tail(&iobj->head, &imem->list);
197+
spin_unlock(&iobj->imem->lock);
194198
memory = &iobj->memory;
195199
}
196200

@@ -309,5 +313,6 @@ nvkm_instmem_ctor(const struct nvkm_instmem_func *func,
309313
{
310314
nvkm_subdev_ctor(&nvkm_instmem, device, index, 0, &imem->subdev);
311315
imem->func = func;
316+
spin_lock_init(&imem->lock);
312317
INIT_LIST_HEAD(&imem->list);
313318
}

0 commit comments

Comments
 (0)