Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/panthor: Add gpu_job_irq tracepoint

Mali's CSF firmware triggers the job IRQ whenever there's new firmware
events for processing. While this can be a global event (BIT(31) of the
status register), it's usually an event relating to a command stream
group (the other bit indices).

Panthor throws these events onto a workqueue for processing outside the
IRQ handler. It's therefore useful to have an instrumented tracepoint
that goes beyond the generic IRQ tracepoint for this specific case, as
it can be augmented with additional data, namely the events bit mask.

This can then be used to debug problems relating to GPU jobs events not
being processed quickly enough. The duration_ns field can be used to
work backwards from when the tracepoint fires (at the end of the IRQ
handler) to figure out when the interrupt itself landed, providing not
just information on how long the work queueing took, but also when the
actual interrupt itself arrived.

With this information in hand, the IRQ handler itself being slow can be
excluded as a possible source of problems, and attention can be directed
to the workqueue processing instead.

Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://patch.msgid.link/20260116-panthor-tracepoints-v10-4-d925986e3d1b@collabora.com
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>

authored by

Nicolas Frattaroli and committed by
Boris Brezillon
15bd2f5d 52ebfd8d

+41
+13
drivers/gpu/drm/panthor/panthor_fw.c
··· 26 26 #include "panthor_mmu.h" 27 27 #include "panthor_regs.h" 28 28 #include "panthor_sched.h" 29 + #include "panthor_trace.h" 29 30 30 31 #define CSF_FW_NAME "mali_csffw.bin" 31 32 ··· 1061 1060 1062 1061 static void panthor_job_irq_handler(struct panthor_device *ptdev, u32 status) 1063 1062 { 1063 + u32 duration; 1064 + u64 start = 0; 1065 + 1066 + if (tracepoint_enabled(gpu_job_irq)) 1067 + start = ktime_get_ns(); 1068 + 1064 1069 gpu_write(ptdev, JOB_INT_CLEAR, status); 1065 1070 1066 1071 if (!ptdev->fw->booted && (status & JOB_INT_GLOBAL_IF)) ··· 1079 1072 return; 1080 1073 1081 1074 panthor_sched_report_fw_events(ptdev, status); 1075 + 1076 + if (tracepoint_enabled(gpu_job_irq) && start) { 1077 + if (check_sub_overflow(ktime_get_ns(), start, &duration)) 1078 + duration = U32_MAX; 1079 + trace_gpu_job_irq(ptdev->base.dev, status, duration); 1080 + } 1082 1081 } 1083 1082 PANTHOR_IRQ_HANDLER(job, JOB, panthor_job_irq_handler); 1084 1083
+28
drivers/gpu/drm/panthor/panthor_trace.h
··· 48 48 panthor_hw_power_status_register, panthor_hw_power_status_unregister 49 49 ); 50 50 51 + /** 52 + * gpu_job_irq - called after a job interrupt from firmware completes 53 + * @dev: pointer to the &struct device, for printing the device name 54 + * @events: bitmask of BIT(CSG id) | BIT(31) for a global event 55 + * @duration_ns: Nanoseconds between job IRQ handler entry and exit 56 + * 57 + * The panthor_job_irq_handler() function instrumented by this tracepoint exits 58 + * once it has queued the firmware interrupts for processing, not when the 59 + * firmware interrupts are fully processed. This tracepoint allows for debugging 60 + * issues with delays in the workqueue's processing of events. 61 + */ 62 + TRACE_EVENT(gpu_job_irq, 63 + TP_PROTO(const struct device *dev, u32 events, u32 duration_ns), 64 + TP_ARGS(dev, events, duration_ns), 65 + TP_STRUCT__entry( 66 + __string(dev_name, dev_name(dev)) 67 + __field(u32, events) 68 + __field(u32, duration_ns) 69 + ), 70 + TP_fast_assign( 71 + __assign_str(dev_name); 72 + __entry->events = events; 73 + __entry->duration_ns = duration_ns; 74 + ), 75 + TP_printk("%s: events=0x%x duration_ns=%d", __get_str(dev_name), 76 + __entry->events, __entry->duration_ns) 77 + ); 78 + 51 79 #endif /* __PANTHOR_TRACE_H__ */ 52 80 53 81 #undef TRACE_INCLUDE_PATH