Skip to content

Commit 989c5b9

Browse files
committed
Merge tag 'drm-misc-fixes-2024-10-31' of https://gitlab.freedesktop.org/drm/misc/kernel into drm-fixes
Short summary of fixes pull: ivpu: - Fix firewall IRQ handling panthor: - Fix firmware initialization wrt page sizes - Fix handling and reporting of dead job groups sched: - Guarantee forward progress via WC_MEM_RECLAIM tests: - Fix memory leak in drm_display_mode_from_cea_vic() Signed-off-by: Dave Airlie <[email protected]> From: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 8198375 + add4163 commit 989c5b9

File tree

15 files changed

+122
-33
lines changed

15 files changed

+122
-33
lines changed

drivers/accel/ivpu/ivpu_debugfs.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ static int reset_pending_show(struct seq_file *s, void *v)
108108
return 0;
109109
}
110110

111+
static int firewall_irq_counter_show(struct seq_file *s, void *v)
112+
{
113+
struct ivpu_device *vdev = seq_to_ivpu(s);
114+
115+
seq_printf(s, "%d\n", atomic_read(&vdev->hw->firewall_irq_counter));
116+
return 0;
117+
}
118+
111119
static const struct drm_debugfs_info vdev_debugfs_list[] = {
112120
{"bo_list", bo_list_show, 0},
113121
{"fw_name", fw_name_show, 0},
@@ -116,6 +124,7 @@ static const struct drm_debugfs_info vdev_debugfs_list[] = {
116124
{"last_bootmode", last_bootmode_show, 0},
117125
{"reset_counter", reset_counter_show, 0},
118126
{"reset_pending", reset_pending_show, 0},
127+
{"firewall_irq_counter", firewall_irq_counter_show, 0},
119128
};
120129

121130
static ssize_t

drivers/accel/ivpu/ivpu_hw.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ int ivpu_hw_init(struct ivpu_device *vdev)
249249
platform_init(vdev);
250250
wa_init(vdev);
251251
timeouts_init(vdev);
252+
atomic_set(&vdev->hw->firewall_irq_counter, 0);
252253

253254
return 0;
254255
}

drivers/accel/ivpu/ivpu_hw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct ivpu_hw_info {
5252
int dma_bits;
5353
ktime_t d0i3_entry_host_ts;
5454
u64 d0i3_entry_vpu_ts;
55+
atomic_t firewall_irq_counter;
5556
};
5657

5758
int ivpu_hw_init(struct ivpu_device *vdev);

drivers/accel/ivpu/ivpu_hw_ip.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,10 @@ static void irq_wdt_mss_handler(struct ivpu_device *vdev)
10621062

10631063
static void irq_noc_firewall_handler(struct ivpu_device *vdev)
10641064
{
1065-
ivpu_pm_trigger_recovery(vdev, "NOC Firewall IRQ");
1065+
atomic_inc(&vdev->hw->firewall_irq_counter);
1066+
1067+
ivpu_dbg(vdev, IRQ, "NOC Firewall interrupt detected, counter %d\n",
1068+
atomic_read(&vdev->hw->firewall_irq_counter));
10661069
}
10671070

10681071
/* Handler for IRQs from NPU core */

drivers/gpu/drm/panthor/panthor_fw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ static int panthor_fw_load_section_entry(struct panthor_device *ptdev,
487487
struct panthor_fw_binary_iter *iter,
488488
u32 ehdr)
489489
{
490+
ssize_t vm_pgsz = panthor_vm_page_size(ptdev->fw->vm);
490491
struct panthor_fw_binary_section_entry_hdr hdr;
491492
struct panthor_fw_section *section;
492493
u32 section_size;
@@ -515,8 +516,7 @@ static int panthor_fw_load_section_entry(struct panthor_device *ptdev,
515516
return -EINVAL;
516517
}
517518

518-
if ((hdr.va.start & ~PAGE_MASK) != 0 ||
519-
(hdr.va.end & ~PAGE_MASK) != 0) {
519+
if (!IS_ALIGNED(hdr.va.start, vm_pgsz) || !IS_ALIGNED(hdr.va.end, vm_pgsz)) {
520520
drm_err(&ptdev->base, "Firmware corrupted, virtual addresses not page aligned: 0x%x-0x%x\n",
521521
hdr.va.start, hdr.va.end);
522522
return -EINVAL;

drivers/gpu/drm/panthor/panthor_gem.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ void panthor_kernel_bo_destroy(struct panthor_kernel_bo *bo)
4444
to_panthor_bo(bo->obj)->exclusive_vm_root_gem != panthor_vm_root_gem(vm)))
4545
goto out_free_bo;
4646

47-
ret = panthor_vm_unmap_range(vm, bo->va_node.start,
48-
panthor_kernel_bo_size(bo));
47+
ret = panthor_vm_unmap_range(vm, bo->va_node.start, bo->va_node.size);
4948
if (ret)
5049
goto out_free_bo;
5150

@@ -95,10 +94,16 @@ panthor_kernel_bo_create(struct panthor_device *ptdev, struct panthor_vm *vm,
9594
}
9695

9796
bo = to_panthor_bo(&obj->base);
98-
size = obj->base.size;
9997
kbo->obj = &obj->base;
10098
bo->flags = bo_flags;
10199

100+
/* The system and GPU MMU page size might differ, which becomes a
101+
* problem for FW sections that need to be mapped at explicit address
102+
* since our PAGE_SIZE alignment might cover a VA range that's
103+
* expected to be used for another section.
104+
* Make sure we never map more than we need.
105+
*/
106+
size = ALIGN(size, panthor_vm_page_size(vm));
102107
ret = panthor_vm_alloc_va(vm, gpu_va, size, &kbo->va_node);
103108
if (ret)
104109
goto err_put_obj;

drivers/gpu/drm/panthor/panthor_mmu.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,14 @@ void panthor_vm_idle(struct panthor_vm *vm)
826826
mutex_unlock(&ptdev->mmu->as.slots_lock);
827827
}
828828

829+
u32 panthor_vm_page_size(struct panthor_vm *vm)
830+
{
831+
const struct io_pgtable *pgt = io_pgtable_ops_to_pgtable(vm->pgtbl_ops);
832+
u32 pg_shift = ffs(pgt->cfg.pgsize_bitmap) - 1;
833+
834+
return 1u << pg_shift;
835+
}
836+
829837
static void panthor_vm_stop(struct panthor_vm *vm)
830838
{
831839
drm_sched_stop(&vm->sched, NULL);
@@ -1025,12 +1033,13 @@ int
10251033
panthor_vm_alloc_va(struct panthor_vm *vm, u64 va, u64 size,
10261034
struct drm_mm_node *va_node)
10271035
{
1036+
ssize_t vm_pgsz = panthor_vm_page_size(vm);
10281037
int ret;
10291038

1030-
if (!size || (size & ~PAGE_MASK))
1039+
if (!size || !IS_ALIGNED(size, vm_pgsz))
10311040
return -EINVAL;
10321041

1033-
if (va != PANTHOR_VM_KERNEL_AUTO_VA && (va & ~PAGE_MASK))
1042+
if (va != PANTHOR_VM_KERNEL_AUTO_VA && !IS_ALIGNED(va, vm_pgsz))
10341043
return -EINVAL;
10351044

10361045
mutex_lock(&vm->mm_lock);
@@ -2366,11 +2375,12 @@ panthor_vm_bind_prepare_op_ctx(struct drm_file *file,
23662375
const struct drm_panthor_vm_bind_op *op,
23672376
struct panthor_vm_op_ctx *op_ctx)
23682377
{
2378+
ssize_t vm_pgsz = panthor_vm_page_size(vm);
23692379
struct drm_gem_object *gem;
23702380
int ret;
23712381

23722382
/* Aligned on page size. */
2373-
if ((op->va | op->size) & ~PAGE_MASK)
2383+
if (!IS_ALIGNED(op->va | op->size, vm_pgsz))
23742384
return -EINVAL;
23752385

23762386
switch (op->flags & DRM_PANTHOR_VM_BIND_OP_TYPE_MASK) {

drivers/gpu/drm/panthor/panthor_mmu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ panthor_vm_get_bo_for_va(struct panthor_vm *vm, u64 va, u64 *bo_offset);
3030

3131
int panthor_vm_active(struct panthor_vm *vm);
3232
void panthor_vm_idle(struct panthor_vm *vm);
33+
u32 panthor_vm_page_size(struct panthor_vm *vm);
3334
int panthor_vm_as(struct panthor_vm *vm);
3435
int panthor_vm_flush_all(struct panthor_vm *vm);
3536

drivers/gpu/drm/panthor/panthor_sched.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,11 @@ struct panthor_group {
589589
* @timedout: True when a timeout occurred on any of the queues owned by
590590
* this group.
591591
*
592-
* Timeouts can be reported by drm_sched or by the FW. In any case, any
593-
* timeout situation is unrecoverable, and the group becomes useless.
594-
* We simply wait for all references to be dropped so we can release the
595-
* group object.
592+
* Timeouts can be reported by drm_sched or by the FW. If a reset is required,
593+
* and the group can't be suspended, this also leads to a timeout. In any case,
594+
* any timeout situation is unrecoverable, and the group becomes useless. We
595+
* simply wait for all references to be dropped so we can release the group
596+
* object.
596597
*/
597598
bool timedout;
598599

@@ -2640,6 +2641,12 @@ void panthor_sched_suspend(struct panthor_device *ptdev)
26402641
csgs_upd_ctx_init(&upd_ctx);
26412642
while (slot_mask) {
26422643
u32 csg_id = ffs(slot_mask) - 1;
2644+
struct panthor_csg_slot *csg_slot = &sched->csg_slots[csg_id];
2645+
2646+
/* We consider group suspension failures as fatal and flag the
2647+
* group as unusable by setting timedout=true.
2648+
*/
2649+
csg_slot->group->timedout = true;
26432650

26442651
csgs_upd_ctx_queue_reqs(ptdev, &upd_ctx, csg_id,
26452652
CSG_STATE_TERMINATE,
@@ -3409,6 +3416,11 @@ panthor_job_create(struct panthor_file *pfile,
34093416
goto err_put_job;
34103417
}
34113418

3419+
if (!group_can_run(job->group)) {
3420+
ret = -EINVAL;
3421+
goto err_put_job;
3422+
}
3423+
34123424
if (job->queue_idx >= job->group->queue_count ||
34133425
!job->group->queues[job->queue_idx]) {
34143426
ret = -EINVAL;

drivers/gpu/drm/scheduler/sched_main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,10 +1276,11 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,
12761276
sched->own_submit_wq = false;
12771277
} else {
12781278
#ifdef CONFIG_LOCKDEP
1279-
sched->submit_wq = alloc_ordered_workqueue_lockdep_map(name, 0,
1279+
sched->submit_wq = alloc_ordered_workqueue_lockdep_map(name,
1280+
WQ_MEM_RECLAIM,
12801281
&drm_sched_lockdep_map);
12811282
#else
1282-
sched->submit_wq = alloc_ordered_workqueue(name, 0);
1283+
sched->submit_wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
12831284
#endif
12841285
if (!sched->submit_wq)
12851286
return -ENOMEM;

0 commit comments

Comments
 (0)