Commit 95095032 authored by Ben Skeggs's avatar Ben Skeggs

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: default avatarBen Skeggs <bskeggs@redhat.com>
parent c294a052
...@@ -7,6 +7,7 @@ struct nvkm_instmem { ...@@ -7,6 +7,7 @@ struct nvkm_instmem {
const struct nvkm_instmem_func *func; const struct nvkm_instmem_func *func;
struct nvkm_subdev subdev; struct nvkm_subdev subdev;
spinlock_t lock;
struct list_head list; struct list_head list;
u32 reserved; u32 reserved;
......
...@@ -97,7 +97,9 @@ static void * ...@@ -97,7 +97,9 @@ static void *
nvkm_instobj_dtor(struct nvkm_memory *memory) nvkm_instobj_dtor(struct nvkm_memory *memory)
{ {
struct nvkm_instobj *iobj = nvkm_instobj(memory); struct nvkm_instobj *iobj = nvkm_instobj(memory);
spin_lock(&iobj->imem->lock);
list_del(&iobj->head); list_del(&iobj->head);
spin_unlock(&iobj->imem->lock);
nvkm_memory_del(&iobj->parent); nvkm_memory_del(&iobj->parent);
return iobj; return iobj;
} }
...@@ -190,7 +192,9 @@ nvkm_instobj_new(struct nvkm_instmem *imem, u32 size, u32 align, bool zero, ...@@ -190,7 +192,9 @@ nvkm_instobj_new(struct nvkm_instmem *imem, u32 size, u32 align, bool zero,
nvkm_memory_ctor(&nvkm_instobj_func_slow, &iobj->memory); nvkm_memory_ctor(&nvkm_instobj_func_slow, &iobj->memory);
iobj->parent = memory; iobj->parent = memory;
iobj->imem = imem; iobj->imem = imem;
spin_lock(&iobj->imem->lock);
list_add_tail(&iobj->head, &imem->list); list_add_tail(&iobj->head, &imem->list);
spin_unlock(&iobj->imem->lock);
memory = &iobj->memory; memory = &iobj->memory;
} }
...@@ -309,5 +313,6 @@ nvkm_instmem_ctor(const struct nvkm_instmem_func *func, ...@@ -309,5 +313,6 @@ nvkm_instmem_ctor(const struct nvkm_instmem_func *func,
{ {
nvkm_subdev_ctor(&nvkm_instmem, device, index, 0, &imem->subdev); nvkm_subdev_ctor(&nvkm_instmem, device, index, 0, &imem->subdev);
imem->func = func; imem->func = func;
spin_lock_init(&imem->lock);
INIT_LIST_HEAD(&imem->list); INIT_LIST_HEAD(&imem->list);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment