Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit bc609f4

Browse files
committed
Merge tag 'drm-misc-next-fixes-2023-08-24' of git://anongit.freedesktop.org/drm/drm-misc into drm-next
Short summary of fixes pull: * gpuva: Cleanups * kunit: Documentation fixes * nouveau: * UAPI: Avoid implicit NO_PREFETCH flag * Scheduler fixes * Fix remap * ttm: Fix type conversion in tests Signed-off-by: Dave Airlie <[email protected]> From: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 38f8873 + cdf4100 commit bc609f4

File tree

10 files changed

+68
-19
lines changed

10 files changed

+68
-19
lines changed

drivers/gpu/drm/drm_gpuva_mgr.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ __drm_gpuva_sm_map(struct drm_gpuva_manager *mgr,
10761076
u64 req_addr, u64 req_range,
10771077
struct drm_gem_object *req_obj, u64 req_offset)
10781078
{
1079-
struct drm_gpuva *va, *next, *prev = NULL;
1079+
struct drm_gpuva *va, *next;
10801080
u64 req_end = req_addr + req_range;
10811081
int ret;
10821082

@@ -1106,7 +1106,7 @@ __drm_gpuva_sm_map(struct drm_gpuva_manager *mgr,
11061106
ret = op_unmap_cb(ops, priv, va, merge);
11071107
if (ret)
11081108
return ret;
1109-
goto next;
1109+
continue;
11101110
}
11111111

11121112
if (end > req_end) {
@@ -1151,7 +1151,7 @@ __drm_gpuva_sm_map(struct drm_gpuva_manager *mgr,
11511151
ret = op_remap_cb(ops, priv, &p, NULL, &u);
11521152
if (ret)
11531153
return ret;
1154-
goto next;
1154+
continue;
11551155
}
11561156

11571157
if (end > req_end) {
@@ -1184,7 +1184,7 @@ __drm_gpuva_sm_map(struct drm_gpuva_manager *mgr,
11841184
ret = op_unmap_cb(ops, priv, va, merge);
11851185
if (ret)
11861186
return ret;
1187-
goto next;
1187+
continue;
11881188
}
11891189

11901190
if (end > req_end) {
@@ -1205,8 +1205,6 @@ __drm_gpuva_sm_map(struct drm_gpuva_manager *mgr,
12051205
break;
12061206
}
12071207
}
1208-
next:
1209-
prev = va;
12101208
}
12111209

12121210
return op_map_cb(ops, priv,

drivers/gpu/drm/nouveau/nouveau_dma.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,19 @@ READ_GET(struct nouveau_channel *chan, uint64_t *prev_get, int *timeout)
6969
}
7070

7171
void
72-
nv50_dma_push(struct nouveau_channel *chan, u64 offset, int length)
72+
nv50_dma_push(struct nouveau_channel *chan, u64 offset, u32 length,
73+
bool no_prefetch)
7374
{
7475
struct nvif_user *user = &chan->drm->client.device.user;
7576
struct nouveau_bo *pb = chan->push.buffer;
7677
int ip = (chan->dma.ib_put * 2) + chan->dma.ib_base;
7778

7879
BUG_ON(chan->dma.ib_free < 1);
80+
WARN_ON(length > NV50_DMA_PUSH_MAX_LENGTH);
7981

8082
nouveau_bo_wr32(pb, ip++, lower_32_bits(offset));
81-
nouveau_bo_wr32(pb, ip++, upper_32_bits(offset) | length << 8);
83+
nouveau_bo_wr32(pb, ip++, upper_32_bits(offset) | length << 8 |
84+
(no_prefetch ? (1 << 31) : 0));
8285

8386
chan->dma.ib_put = (chan->dma.ib_put + 1) & chan->dma.ib_max;
8487

drivers/gpu/drm/nouveau/nouveau_dma.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
#include "nouveau_chan.h"
3232

3333
int nouveau_dma_wait(struct nouveau_channel *, int slots, int size);
34-
void nv50_dma_push(struct nouveau_channel *, u64 addr, int length);
34+
void nv50_dma_push(struct nouveau_channel *, u64 addr, u32 length,
35+
bool no_prefetch);
3536

3637
/*
3738
* There's a hw race condition where you can't jump to your PUT offset,
@@ -45,6 +46,9 @@ void nv50_dma_push(struct nouveau_channel *, u64 addr, int length);
4546
*/
4647
#define NOUVEAU_DMA_SKIPS (128 / 4)
4748

49+
/* Maximum push buffer size. */
50+
#define NV50_DMA_PUSH_MAX_LENGTH 0x7fffff
51+
4852
/* Object handles - for stuff that's doesn't use handle == oclass. */
4953
enum {
5054
NvDmaFB = 0x80000002,
@@ -89,7 +93,7 @@ FIRE_RING(struct nouveau_channel *chan)
8993

9094
if (chan->dma.ib_max) {
9195
nv50_dma_push(chan, chan->push.addr + (chan->dma.put << 2),
92-
(chan->dma.cur - chan->dma.put) << 2);
96+
(chan->dma.cur - chan->dma.put) << 2, false);
9397
} else {
9498
WRITE_PUT(chan->dma.cur);
9599
}

drivers/gpu/drm/nouveau/nouveau_exec.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,10 @@ nouveau_exec_job_run(struct nouveau_job *job)
164164
}
165165

166166
for (i = 0; i < exec_job->push.count; i++) {
167-
nv50_dma_push(chan, exec_job->push.s[i].va,
168-
exec_job->push.s[i].va_len);
167+
struct drm_nouveau_exec_push *p = &exec_job->push.s[i];
168+
bool no_prefetch = p->flags & DRM_NOUVEAU_EXEC_PUSH_NO_PREFETCH;
169+
170+
nv50_dma_push(chan, p->va, p->va_len, no_prefetch);
169171
}
170172

171173
ret = nouveau_fence_emit(fence, chan);
@@ -223,7 +225,18 @@ nouveau_exec_job_init(struct nouveau_exec_job **pjob,
223225
{
224226
struct nouveau_exec_job *job;
225227
struct nouveau_job_args args = {};
226-
int ret;
228+
int i, ret;
229+
230+
for (i = 0; i < __args->push.count; i++) {
231+
struct drm_nouveau_exec_push *p = &__args->push.s[i];
232+
233+
if (unlikely(p->va_len > NV50_DMA_PUSH_MAX_LENGTH)) {
234+
NV_PRINTK(err, nouveau_cli(__args->file_priv),
235+
"pushbuf size exceeds limit: 0x%x max 0x%x\n",
236+
p->va_len, NV50_DMA_PUSH_MAX_LENGTH);
237+
return -EINVAL;
238+
}
239+
}
227240

228241
job = *pjob = kzalloc(sizeof(*job), GFP_KERNEL);
229242
if (!job)

drivers/gpu/drm/nouveau/nouveau_gem.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,9 +856,11 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
856856
for (i = 0; i < req->nr_push; i++) {
857857
struct nouveau_vma *vma = (void *)(unsigned long)
858858
bo[push[i].bo_index].user_priv;
859+
u64 addr = vma->addr + push[i].offset;
860+
u32 length = push[i].length & ~NOUVEAU_GEM_PUSHBUF_NO_PREFETCH;
861+
bool no_prefetch = push[i].length & NOUVEAU_GEM_PUSHBUF_NO_PREFETCH;
859862

860-
nv50_dma_push(chan, vma->addr + push[i].offset,
861-
push[i].length);
863+
nv50_dma_push(chan, addr, length, no_prefetch);
862864
}
863865
} else
864866
if (drm->client.device.info.chipset >= 0x25) {

drivers/gpu/drm/nouveau/nouveau_sched.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,28 @@ nouveau_job_submit(struct nouveau_job *job)
292292
if (job->sync)
293293
done_fence = dma_fence_get(job->done_fence);
294294

295+
/* If a sched job depends on a dma-fence from a job from the same GPU
296+
* scheduler instance, but a different scheduler entity, the GPU
297+
* scheduler does only wait for the particular job to be scheduled,
298+
* rather than for the job to fully complete. This is due to the GPU
299+
* scheduler assuming that there is a scheduler instance per ring.
300+
* However, the current implementation, in order to avoid arbitrary
301+
* amounts of kthreads, has a single scheduler instance while scheduler
302+
* entities represent rings.
303+
*
304+
* As a workaround, set the DRM_SCHED_FENCE_DONT_PIPELINE for all
305+
* out-fences in order to force the scheduler to wait for full job
306+
* completion for dependent jobs from different entities and same
307+
* scheduler instance.
308+
*
309+
* There is some work in progress [1] to address the issues of firmware
310+
* schedulers; once it is in-tree the scheduler topology in Nouveau
311+
* should be re-worked accordingly.
312+
*
313+
* [1] https://lore.kernel.org/dri-devel/[email protected]/
314+
*/
315+
set_bit(DRM_SCHED_FENCE_DONT_PIPELINE, &job->done_fence->flags);
316+
295317
if (job->ops->armed_submit)
296318
job->ops->armed_submit(job);
297319

drivers/gpu/drm/nouveau/nouveau_uvmm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ nouveau_uvmm_sm_prepare(struct nouveau_uvmm *uvmm,
639639
struct drm_gpuva *va = r->unmap->va;
640640
struct uvmm_map_args remap_args = {
641641
.kind = uvma_from_va(va)->kind,
642+
.region = uvma_from_va(va)->region,
642643
};
643644
u64 ustart = va->va.addr;
644645
u64 urange = va->va.range;

drivers/gpu/drm/tests/drm_kunit_helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static void action_drm_release_context(void *ptr)
156156
}
157157

158158
/**
159-
* drm_kunit_helper_context_alloc - Allocates an acquire context
159+
* drm_kunit_helper_acquire_ctx_alloc - Allocates an acquire context
160160
* @test: The test context object
161161
*
162162
* Allocates and initializes a modeset acquire context.

drivers/gpu/drm/ttm/tests/ttm_pool_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ static void ttm_pool_alloc_basic_dma_addr(struct kunit *test)
228228
dma1 = tt->dma_address[0];
229229
dma2 = tt->dma_address[tt->num_pages - 1];
230230

231-
KUNIT_ASSERT_NOT_NULL(test, (void *)dma1);
232-
KUNIT_ASSERT_NOT_NULL(test, (void *)dma2);
231+
KUNIT_ASSERT_NOT_NULL(test, (void *)(uintptr_t)dma1);
232+
KUNIT_ASSERT_NOT_NULL(test, (void *)(uintptr_t)dma2);
233233

234234
ttm_pool_free(pool, tt);
235235
ttm_tt_fini(tt);

include/uapi/drm/nouveau_drm.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ struct drm_nouveau_gem_pushbuf_push {
138138
__u32 pad;
139139
__u64 offset;
140140
__u64 length;
141+
#define NOUVEAU_GEM_PUSHBUF_NO_PREFETCH (1 << 23)
141142
};
142143

143144
struct drm_nouveau_gem_pushbuf {
@@ -338,7 +339,12 @@ struct drm_nouveau_exec_push {
338339
/**
339340
* @va_len: the length of the push buffer mapping
340341
*/
341-
__u64 va_len;
342+
__u32 va_len;
343+
/**
344+
* @flags: the flags for this push buffer mapping
345+
*/
346+
__u32 flags;
347+
#define DRM_NOUVEAU_EXEC_PUSH_NO_PREFETCH 0x1
342348
};
343349

344350
/**

0 commit comments

Comments
 (0)