Commit 0e65ec75 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/fb: protect vram mm with private mutex

nvkm_subdev.mutex is going away.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
parent f5cfbd99
...@@ -132,6 +132,7 @@ struct nvkm_ram { ...@@ -132,6 +132,7 @@ struct nvkm_ram {
#define NVKM_RAM_MM_MIXED (NVKM_MM_HEAP_ANY + 3) #define NVKM_RAM_MM_MIXED (NVKM_MM_HEAP_ANY + 3)
struct nvkm_mm vram; struct nvkm_mm vram;
u64 stolen; u64 stolen;
struct mutex mutex;
int ranks; int ranks;
int parts; int parts;
......
...@@ -81,12 +81,12 @@ nvkm_vram_dtor(struct nvkm_memory *memory) ...@@ -81,12 +81,12 @@ nvkm_vram_dtor(struct nvkm_memory *memory)
struct nvkm_vram *vram = nvkm_vram(memory); struct nvkm_vram *vram = nvkm_vram(memory);
struct nvkm_mm_node *next = vram->mn; struct nvkm_mm_node *next = vram->mn;
struct nvkm_mm_node *node; struct nvkm_mm_node *node;
mutex_lock(&vram->ram->fb->subdev.mutex); mutex_lock(&vram->ram->mutex);
while ((node = next)) { while ((node = next)) {
next = node->next; next = node->next;
nvkm_mm_free(&vram->ram->vram, &node); nvkm_mm_free(&vram->ram->vram, &node);
} }
mutex_unlock(&vram->ram->fb->subdev.mutex); mutex_unlock(&vram->ram->mutex);
return vram; return vram;
} }
...@@ -126,7 +126,7 @@ nvkm_ram_get(struct nvkm_device *device, u8 heap, u8 type, u8 rpage, u64 size, ...@@ -126,7 +126,7 @@ nvkm_ram_get(struct nvkm_device *device, u8 heap, u8 type, u8 rpage, u64 size,
vram->page = page; vram->page = page;
*pmemory = &vram->memory; *pmemory = &vram->memory;
mutex_lock(&ram->fb->subdev.mutex); mutex_lock(&ram->mutex);
node = &vram->mn; node = &vram->mn;
do { do {
if (back) if (back)
...@@ -134,7 +134,7 @@ nvkm_ram_get(struct nvkm_device *device, u8 heap, u8 type, u8 rpage, u64 size, ...@@ -134,7 +134,7 @@ nvkm_ram_get(struct nvkm_device *device, u8 heap, u8 type, u8 rpage, u64 size,
else else
ret = nvkm_mm_head(mm, heap, type, max, min, align, &r); ret = nvkm_mm_head(mm, heap, type, max, min, align, &r);
if (ret) { if (ret) {
mutex_unlock(&ram->fb->subdev.mutex); mutex_unlock(&ram->mutex);
nvkm_memory_unref(pmemory); nvkm_memory_unref(pmemory);
return ret; return ret;
} }
...@@ -143,7 +143,7 @@ nvkm_ram_get(struct nvkm_device *device, u8 heap, u8 type, u8 rpage, u64 size, ...@@ -143,7 +143,7 @@ nvkm_ram_get(struct nvkm_device *device, u8 heap, u8 type, u8 rpage, u64 size,
node = &r->next; node = &r->next;
max -= r->length; max -= r->length;
} while (max); } while (max);
mutex_unlock(&ram->fb->subdev.mutex); mutex_unlock(&ram->mutex);
return 0; return 0;
} }
...@@ -163,6 +163,7 @@ nvkm_ram_del(struct nvkm_ram **pram) ...@@ -163,6 +163,7 @@ nvkm_ram_del(struct nvkm_ram **pram)
if (ram->func->dtor) if (ram->func->dtor)
*pram = ram->func->dtor(ram); *pram = ram->func->dtor(ram);
nvkm_mm_fini(&ram->vram); nvkm_mm_fini(&ram->vram);
mutex_destroy(&ram->mutex);
kfree(*pram); kfree(*pram);
*pram = NULL; *pram = NULL;
} }
...@@ -196,6 +197,7 @@ nvkm_ram_ctor(const struct nvkm_ram_func *func, struct nvkm_fb *fb, ...@@ -196,6 +197,7 @@ nvkm_ram_ctor(const struct nvkm_ram_func *func, struct nvkm_fb *fb,
ram->fb = fb; ram->fb = fb;
ram->type = type; ram->type = type;
ram->size = size; ram->size = size;
mutex_init(&ram->mutex);
if (!nvkm_mm_initialised(&ram->vram)) { if (!nvkm_mm_initialised(&ram->vram)) {
ret = nvkm_mm_init(&ram->vram, NVKM_RAM_MM_NORMAL, 0, ret = nvkm_mm_init(&ram->vram, NVKM_RAM_MM_NORMAL, 0,
......
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