]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drm/nouveau/imem/nv50: split object map out from api functions
authorBen Skeggs <bskeggs@redhat.com>
Tue, 31 Oct 2017 17:56:19 +0000 (03:56 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 2 Nov 2017 03:32:19 +0000 (13:32 +1000)
acquire()/boot() will need different logic in addition to performing
the actual mapping.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c

index e3273aed3381d38e64bf5c5944bce8428637ef39..95b2c560fe4b13a5bb969c872e562abc1911e6eb 100644 (file)
@@ -89,6 +89,34 @@ nv50_instobj_slow = {
        .wr32 = nv50_instobj_wr32_slow,
 };
 
+static void
+nv50_instobj_kmap(struct nv50_instobj *iobj, struct nvkm_vmm *vmm)
+{
+       struct nvkm_memory *memory = &iobj->memory;
+       struct nvkm_subdev *subdev = &iobj->imem->base.subdev;
+       struct nvkm_device *device = subdev->device;
+       u64 size = nvkm_memory_size(memory);
+       void __iomem *map;
+       int ret;
+
+       iobj->map = ERR_PTR(-ENOMEM);
+
+       ret = nvkm_vm_get(vmm, size, 12, NV_MEM_ACCESS_RW, &iobj->bar);
+       if (ret == 0) {
+               map = ioremap(device->func->resource_addr(device, 3) +
+                             (u32)iobj->bar.offset, size);
+               if (map) {
+                       nvkm_memory_map(memory, &iobj->bar, 0);
+                       iobj->map = map;
+               } else {
+                       nvkm_warn(subdev, "PRAMIN ioremap failed\n");
+                       nvkm_vm_put(&iobj->bar);
+               }
+       } else {
+               nvkm_warn(subdev, "PRAMIN exhausted\n");
+       }
+}
+
 static void
 nv50_instobj_map(struct nvkm_memory *memory, struct nvkm_vma *vma, u64 offset)
 {
@@ -112,7 +140,7 @@ nv50_instobj_acquire(struct nvkm_memory *memory)
        unsigned long flags;
 
        if (!iobj->map && (vm = nvkm_bar_bar2_vmm(imem->base.subdev.device)))
-               nvkm_memory_boot(memory, vm);
+               nv50_instobj_kmap(iobj, vm);
        if (!IS_ERR_OR_NULL(iobj->map))
                return iobj->map;
 
@@ -122,31 +150,10 @@ nv50_instobj_acquire(struct nvkm_memory *memory)
 }
 
 static void
-nv50_instobj_boot(struct nvkm_memory *memory, struct nvkm_vm *vm)
+nv50_instobj_boot(struct nvkm_memory *memory, struct nvkm_vmm *vmm)
 {
        struct nv50_instobj *iobj = nv50_instobj(memory);
-       struct nvkm_subdev *subdev = &iobj->imem->base.subdev;
-       struct nvkm_device *device = subdev->device;
-       u64 size = nvkm_memory_size(memory);
-       void __iomem *map;
-       int ret;
-
-       iobj->map = ERR_PTR(-ENOMEM);
-
-       ret = nvkm_vm_get(vm, size, 12, NV_MEM_ACCESS_RW, &iobj->bar);
-       if (ret == 0) {
-               map = ioremap(device->func->resource_addr(device, 3) +
-                             (u32)iobj->bar.offset, size);
-               if (map) {
-                       nvkm_memory_map(memory, &iobj->bar, 0);
-                       iobj->map = map;
-               } else {
-                       nvkm_warn(subdev, "PRAMIN ioremap failed\n");
-                       nvkm_vm_put(&iobj->bar);
-               }
-       } else {
-               nvkm_warn(subdev, "PRAMIN exhausted\n");
-       }
+       nv50_instobj_kmap(iobj, vmm);
 }
 
 static u64
@@ -173,8 +180,8 @@ nv50_instobj_dtor(struct nvkm_memory *memory)
        struct nv50_instobj *iobj = nv50_instobj(memory);
        struct nvkm_ram *ram = iobj->imem->base.subdev.device->fb->ram;
        if (!IS_ERR_OR_NULL(iobj->map)) {
-               nvkm_vm_put(&iobj->bar);
                iounmap(iobj->map);
+               nvkm_vm_put(&iobj->bar);
        }
        ram->func->put(ram, &iobj->mem);
        return iobj;