Skip to content

Commit 0240fa1

Browse files
kwachowsjlawryno
authored andcommitted
accel/ivpu: Dump only first MMU fault from single context
Stop dumping consecutive faults from an already faulty context immediately, instead of waiting for the context abort thread handler (IRQ handler bottom half) to abort currently executing jobs. Remove 'R' (record events) bit from context descriptor of a faulty context to prevent future faults generation. This change speeds up the IRQ handler by eliminating the need to print the fault content repeatedly. Additionally, it prevents flooding dmesg with errors, which was occurring due to the delay in the bottom half of the handler stopping fault-generating jobs. Signed-off-by: Karol Wachowski <karol.wachowski@intel.com> Signed-off-by: Maciej Falkowski <maciej.falkowski@linux.intel.com> Reviewed-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com> Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250107173238.381120-7-maciej.falkowski@linux.intel.com
1 parent bc3e5f4 commit 0240fa1

File tree

3 files changed

+46
-20
lines changed

3 files changed

+46
-20
lines changed

drivers/accel/ivpu/ivpu_mmu.c

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -870,23 +870,64 @@ static u32 *ivpu_mmu_get_event(struct ivpu_device *vdev)
870870
return evt;
871871
}
872872

873+
static int ivpu_mmu_disable_events(struct ivpu_device *vdev, u32 ssid)
874+
{
875+
struct ivpu_mmu_info *mmu = vdev->mmu;
876+
struct ivpu_mmu_cdtab *cdtab = &mmu->cdtab;
877+
u64 *entry;
878+
u64 val;
879+
880+
if (ssid > IVPU_MMU_CDTAB_ENT_COUNT)
881+
return -EINVAL;
882+
883+
entry = cdtab->base + (ssid * IVPU_MMU_CDTAB_ENT_SIZE);
884+
885+
val = READ_ONCE(entry[0]);
886+
val &= ~IVPU_MMU_CD_0_R;
887+
WRITE_ONCE(entry[0], val);
888+
889+
if (!ivpu_is_force_snoop_enabled(vdev))
890+
clflush_cache_range(entry, IVPU_MMU_CDTAB_ENT_SIZE);
891+
892+
ivpu_mmu_cmdq_write_cfgi_all(vdev);
893+
894+
return 0;
895+
}
896+
873897
void ivpu_mmu_irq_evtq_handler(struct ivpu_device *vdev)
874898
{
899+
struct ivpu_file_priv *file_priv;
900+
u32 last_ssid = -1;
875901
u32 *event;
876902
u32 ssid;
877903

878904
ivpu_dbg(vdev, IRQ, "MMU event queue\n");
879905

880-
while ((event = ivpu_mmu_get_event(vdev)) != NULL) {
881-
ivpu_mmu_dump_event(vdev, event);
882-
906+
while ((event = ivpu_mmu_get_event(vdev))) {
883907
ssid = FIELD_GET(IVPU_MMU_EVT_SSID_MASK, event[0]);
908+
909+
if (ssid == last_ssid)
910+
continue;
911+
912+
xa_lock(&vdev->context_xa);
913+
file_priv = xa_load(&vdev->context_xa, ssid);
914+
if (file_priv) {
915+
if (file_priv->has_mmu_faults) {
916+
event = NULL;
917+
} else {
918+
ivpu_mmu_disable_events(vdev, ssid);
919+
file_priv->has_mmu_faults = true;
920+
}
921+
}
922+
xa_unlock(&vdev->context_xa);
923+
924+
if (event)
925+
ivpu_mmu_dump_event(vdev, event);
926+
884927
if (ssid == IVPU_GLOBAL_CONTEXT_MMU_SSID) {
885928
ivpu_pm_trigger_recovery(vdev, "MMU event");
886929
return;
887930
}
888-
889-
ivpu_mmu_user_context_mark_invalid(vdev, ssid);
890931
REGV_WR32(IVPU_MMU_REG_EVTQ_CONS_SEC, vdev->mmu->evtq.cons);
891932
}
892933

drivers/accel/ivpu/ivpu_mmu_context.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -631,16 +631,3 @@ void ivpu_mmu_reserved_context_fini(struct ivpu_device *vdev)
631631
ivpu_mmu_cd_clear(vdev, vdev->rctx.id);
632632
ivpu_mmu_context_fini(vdev, &vdev->rctx);
633633
}
634-
635-
void ivpu_mmu_user_context_mark_invalid(struct ivpu_device *vdev, u32 ssid)
636-
{
637-
struct ivpu_file_priv *file_priv;
638-
639-
xa_lock(&vdev->context_xa);
640-
641-
file_priv = xa_load(&vdev->context_xa, ssid);
642-
if (file_priv)
643-
file_priv->has_mmu_faults = true;
644-
645-
xa_unlock(&vdev->context_xa);
646-
}

drivers/accel/ivpu/ivpu_mmu_context.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ void ivpu_mmu_global_context_fini(struct ivpu_device *vdev);
3737
int ivpu_mmu_reserved_context_init(struct ivpu_device *vdev);
3838
void ivpu_mmu_reserved_context_fini(struct ivpu_device *vdev);
3939

40-
void ivpu_mmu_user_context_mark_invalid(struct ivpu_device *vdev, u32 ssid);
41-
4240
int ivpu_mmu_context_insert_node(struct ivpu_mmu_context *ctx, const struct ivpu_addr_range *range,
4341
u64 size, struct drm_mm_node *node);
4442
void ivpu_mmu_context_remove_node(struct ivpu_mmu_context *ctx, struct drm_mm_node *node);

0 commit comments

Comments
 (0)