Skip to content

Commit af515ec

Browse files
author
Ben Skeggs
committed
drm/nouveau/imem/nv50: move slow-path locking into rd/wr functions
This is to simplify upcoming changes. The slow-path is something that currently occurs during bootstrap of the BAR2 VMM, while backing up an object during suspend/resume, or when BAR2 address space runs out. The latter is a real problem that can happen at runtime, and occurs in Fedora 26 already (due to some change that causes a lot of channels to be created at login), so ideally we'd prefer not to make it any slower. We'd also like suspend/resume speed to not suffer. Upcoming commits will solve those problems in a better way, making the extra overhead of moving the locking here a non-issue. Signed-off-by: Ben Skeggs <[email protected]>
1 parent f584bde commit af515ec

File tree

1 file changed

+6
-8
lines changed
  • drivers/gpu/drm/nouveau/nvkm/subdev/instmem

1 file changed

+6
-8
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131

3232
struct nv50_instmem {
3333
struct nvkm_instmem base;
34-
unsigned long lock_flags;
35-
spinlock_t lock;
3634
u64 addr;
3735
};
3836

@@ -57,12 +55,15 @@ nv50_instobj_wr32_slow(struct nvkm_memory *memory, u64 offset, u32 data)
5755
struct nvkm_device *device = imem->base.subdev.device;
5856
u64 base = (iobj->mem->offset + offset) & 0xffffff00000ULL;
5957
u64 addr = (iobj->mem->offset + offset) & 0x000000fffffULL;
58+
unsigned long flags;
6059

60+
spin_lock_irqsave(&imem->base.lock, flags);
6161
if (unlikely(imem->addr != base)) {
6262
nvkm_wr32(device, 0x001700, base >> 16);
6363
imem->addr = base;
6464
}
6565
nvkm_wr32(device, 0x700000 + addr, data);
66+
spin_unlock_irqrestore(&imem->base.lock, flags);
6667
}
6768

6869
static u32
@@ -74,12 +75,15 @@ nv50_instobj_rd32_slow(struct nvkm_memory *memory, u64 offset)
7475
u64 base = (iobj->mem->offset + offset) & 0xffffff00000ULL;
7576
u64 addr = (iobj->mem->offset + offset) & 0x000000fffffULL;
7677
u32 data;
78+
unsigned long flags;
7779

80+
spin_lock_irqsave(&imem->base.lock, flags);
7881
if (unlikely(imem->addr != base)) {
7982
nvkm_wr32(device, 0x001700, base >> 16);
8083
imem->addr = base;
8184
}
8285
data = nvkm_rd32(device, 0x700000 + addr);
86+
spin_unlock_irqrestore(&imem->base.lock, flags);
8387
return data;
8488
}
8589

@@ -127,8 +131,6 @@ nv50_instobj_map(struct nvkm_memory *memory, struct nvkm_vma *vma, u64 offset)
127131
static void
128132
nv50_instobj_release(struct nvkm_memory *memory)
129133
{
130-
struct nv50_instmem *imem = nv50_instobj(memory)->imem;
131-
spin_unlock_irqrestore(&imem->lock, imem->lock_flags);
132134
}
133135

134136
static void __iomem *
@@ -137,15 +139,12 @@ nv50_instobj_acquire(struct nvkm_memory *memory)
137139
struct nv50_instobj *iobj = nv50_instobj(memory);
138140
struct nv50_instmem *imem = iobj->imem;
139141
struct nvkm_vm *vm;
140-
unsigned long flags;
141142

142143
if (!iobj->map && (vm = nvkm_bar_bar2_vmm(imem->base.subdev.device)))
143144
nv50_instobj_kmap(iobj, vm);
144145
if (!IS_ERR_OR_NULL(iobj->map))
145146
return iobj->map;
146147

147-
spin_lock_irqsave(&imem->lock, flags);
148-
imem->lock_flags = flags;
149148
return NULL;
150149
}
151150

@@ -254,7 +253,6 @@ nv50_instmem_new(struct nvkm_device *device, int index,
254253
if (!(imem = kzalloc(sizeof(*imem), GFP_KERNEL)))
255254
return -ENOMEM;
256255
nvkm_instmem_ctor(&nv50_instmem, device, index, &imem->base);
257-
spin_lock_init(&imem->lock);
258256
*pimem = &imem->base;
259257
return 0;
260258
}

0 commit comments

Comments
 (0)