Skip to content

Commit d273872

Browse files
committed
Merge tag 'drm-misc-fixes-2025-03-20' of ssh://gitlab.freedesktop.org/drm/misc/kernel into drm-fixes
A sched fence reference leak fix, two fence fixes for v3d, two overflow fixes for quaic, and a iommu handling fix for host1x. Signed-off-by: Dave Airlie <airlied@redhat.com> From: Maxime Ripard <mripard@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250320-valiant-outstanding-nightingale-e9acae@houat
2 parents 4701f33 + cb83f4b commit d273872

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

drivers/accel/qaic/qaic_data.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,19 @@ static void free_slice(struct kref *kref)
172172
static int clone_range_of_sgt_for_slice(struct qaic_device *qdev, struct sg_table **sgt_out,
173173
struct sg_table *sgt_in, u64 size, u64 offset)
174174
{
175-
int total_len, len, nents, offf = 0, offl = 0;
176175
struct scatterlist *sg, *sgn, *sgf, *sgl;
176+
unsigned int len, nents, offf, offl;
177177
struct sg_table *sgt;
178+
size_t total_len;
178179
int ret, j;
179180

180181
/* find out number of relevant nents needed for this mem */
181182
total_len = 0;
182183
sgf = NULL;
183184
sgl = NULL;
184185
nents = 0;
186+
offf = 0;
187+
offl = 0;
185188

186189
size = size ? size : PAGE_SIZE;
187190
for_each_sgtable_dma_sg(sgt_in, sg, j) {
@@ -554,6 +557,7 @@ static bool invalid_sem(struct qaic_sem *sem)
554557
static int qaic_validate_req(struct qaic_device *qdev, struct qaic_attach_slice_entry *slice_ent,
555558
u32 count, u64 total_size)
556559
{
560+
u64 total;
557561
int i;
558562

559563
for (i = 0; i < count; i++) {
@@ -563,7 +567,8 @@ static int qaic_validate_req(struct qaic_device *qdev, struct qaic_attach_slice_
563567
invalid_sem(&slice_ent[i].sem2) || invalid_sem(&slice_ent[i].sem3))
564568
return -EINVAL;
565569

566-
if (slice_ent[i].offset + slice_ent[i].size > total_size)
570+
if (check_add_overflow(slice_ent[i].offset, slice_ent[i].size, &total) ||
571+
total > total_size)
567572
return -EINVAL;
568573
}
569574

drivers/gpu/drm/scheduler/sched_entity.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,16 @@ static void drm_sched_entity_kill(struct drm_sched_entity *entity)
259259
struct drm_sched_fence *s_fence = job->s_fence;
260260

261261
dma_fence_get(&s_fence->finished);
262-
if (!prev || dma_fence_add_callback(prev, &job->finish_cb,
263-
drm_sched_entity_kill_jobs_cb))
262+
if (!prev ||
263+
dma_fence_add_callback(prev, &job->finish_cb,
264+
drm_sched_entity_kill_jobs_cb)) {
265+
/*
266+
* Adding callback above failed.
267+
* dma_fence_put() checks for NULL.
268+
*/
269+
dma_fence_put(prev);
264270
drm_sched_entity_kill_jobs_cb(NULL, &job->finish_cb);
271+
}
265272

266273
prev = &s_fence->finished;
267274
}

drivers/gpu/drm/v3d/v3d_sched.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,12 @@ static struct dma_fence *v3d_bin_job_run(struct drm_sched_job *sched_job)
226226
struct dma_fence *fence;
227227
unsigned long irqflags;
228228

229-
if (unlikely(job->base.base.s_fence->finished.error))
229+
if (unlikely(job->base.base.s_fence->finished.error)) {
230+
spin_lock_irqsave(&v3d->job_lock, irqflags);
231+
v3d->bin_job = NULL;
232+
spin_unlock_irqrestore(&v3d->job_lock, irqflags);
230233
return NULL;
234+
}
231235

232236
/* Lock required around bin_job update vs
233237
* v3d_overflow_mem_work().
@@ -281,8 +285,10 @@ static struct dma_fence *v3d_render_job_run(struct drm_sched_job *sched_job)
281285
struct drm_device *dev = &v3d->drm;
282286
struct dma_fence *fence;
283287

284-
if (unlikely(job->base.base.s_fence->finished.error))
288+
if (unlikely(job->base.base.s_fence->finished.error)) {
289+
v3d->render_job = NULL;
285290
return NULL;
291+
}
286292

287293
v3d->render_job = job;
288294

@@ -327,11 +333,17 @@ v3d_tfu_job_run(struct drm_sched_job *sched_job)
327333
struct drm_device *dev = &v3d->drm;
328334
struct dma_fence *fence;
329335

336+
if (unlikely(job->base.base.s_fence->finished.error)) {
337+
v3d->tfu_job = NULL;
338+
return NULL;
339+
}
340+
341+
v3d->tfu_job = job;
342+
330343
fence = v3d_fence_create(v3d, V3D_TFU);
331344
if (IS_ERR(fence))
332345
return NULL;
333346

334-
v3d->tfu_job = job;
335347
if (job->base.irq_fence)
336348
dma_fence_put(job->base.irq_fence);
337349
job->base.irq_fence = dma_fence_get(fence);
@@ -369,6 +381,11 @@ v3d_csd_job_run(struct drm_sched_job *sched_job)
369381
struct dma_fence *fence;
370382
int i, csd_cfg0_reg;
371383

384+
if (unlikely(job->base.base.s_fence->finished.error)) {
385+
v3d->csd_job = NULL;
386+
return NULL;
387+
}
388+
372389
v3d->csd_job = job;
373390

374391
v3d_invalidate_caches(v3d);

drivers/gpu/host1x/dev.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ static bool host1x_wants_iommu(struct host1x *host1x)
361361
return true;
362362
}
363363

364+
/*
365+
* Returns ERR_PTR on failure, NULL if the translation is IDENTITY, otherwise a
366+
* valid paging domain.
367+
*/
364368
static struct iommu_domain *host1x_iommu_attach(struct host1x *host)
365369
{
366370
struct iommu_domain *domain = iommu_get_domain_for_dev(host->dev);
@@ -385,6 +389,8 @@ static struct iommu_domain *host1x_iommu_attach(struct host1x *host)
385389
* Similarly, if host1x is already attached to an IOMMU (via the DMA
386390
* API), don't try to attach again.
387391
*/
392+
if (domain && domain->type == IOMMU_DOMAIN_IDENTITY)
393+
domain = NULL;
388394
if (!host1x_wants_iommu(host) || domain)
389395
return domain;
390396

0 commit comments

Comments
 (0)