This series adds two tracepoints to panthor. The first tracepoint allows for inspecting the power status of the hardware subdivisions, e.g. how many shader cores are powered on. This is done by reading three hardware registers when a certain IRQ fires.
The second tracepoint instruments panthor's job IRQ handler. This is more useful than the generic interrupt tracing functionality, as the tracepoint has the events bit mask included, which indicates which command stream group interfaces triggered the interrupt. To test the tracepoints, the following can be used: :~# echo 1 > /sys/kernel/tracing/events/panthor/gpu_power_status/enable :~# echo 1 > /sys/kernel/tracing/events/panthor/gpu_job_irq/enable :~# echo 1 > /sys/kernel/tracing/tracing_on :~# cat /sys/kernel/tracing/trace_pipe Signed-off-by: Nicolas Frattaroli <[email protected]> --- Changes in v6: - Read the mask member into a local while holding the lock in irq_threaded_handler. - Drop the lock before entering the while loop, letting the threaded handler function run without holding a spinlock - Re-acquire the spinlock at the end of irq_threaded_handler, OR'ing the mask register's contents with the mask local ANDed by the member. This avoids stomping over any other modified bits, or restoring ones that have been disabled in the meantime. - Link to v5: https://lore.kernel.org/r/[email protected] Changes in v5: - Change the panthor IRQ helpers to guard the mask member and register with a spinlock. The rationale behind using a spinlock, rather than some constellation of atomics, is that we have to guarantee mutual exclusion for state beyond just a single value, namely both the register write, and writes to/reads from the mask member, including reads-from-member-writes-to-register. Making the mask atomic does not do anything to avoid concurrency issues in such a case. - Change the IRQ mask member to not get zeroed when suspended. It's possible something outside of the IRQ helpers depends on this behaviour, but I'd argue the code should not access the mask outside of the IRQ helpers, as it'll do so with no lock taken. - Drop the mask_set function, but add mask_enable/mask_disable helpers to enable/disable individual parts of the IRQ mask. - Add a resume_restore IRQ helper that does the same thing as resume, but does not overwrite the mask member. This avoids me having to refactor whatever panthor_mmu.c is doing with that poor mask member. - Link to v4: https://lore.kernel.org/r/[email protected] Changes in v4: - Include "panthor_hw.h" in panthor_trace.h instead of duplicating the reg/unreg function prototypes. - Link to v3: https://lore.kernel.org/r/[email protected] Changes in v3: - Drop PWRFEATURES patch, as this register is no longer needed by this series. - Eliminate the rt_on field from the gpu_power_status register, as per Steven Price's feedback. - Make gpu_power_status tracepoint reg/unreg functions generic across hardware generations by wrapping a hw op in panthor_hw.c. - Reimplement the <= v13 IRQ mask modification functions as the new hw ops functions. v14 can add its own ops in due time. - Link to v2: https://lore.kernel.org/r/[email protected] Changes in v2: - Only enable the GPU_IRQ_POWER_CHANGED_* IRQ mask bits when the tracepoint is enabled. Necessitates the new irq helper patch. - Only enable the GPU_IRQ_POWER_CHANGED_* IRQ mask bits if the hardware architecture is <= v13, as v14 changes things. - Use _READY instead of _PWRACTIVE registers, and rename the tracepoint accordingly. - Also read the status of the ray tracing unit's power. This is a global flag for all shader cores, it seems. Necessitates the new register definition patch. - Move the POWER_CHANGED_* check to earlier in the interrupt handler. - Also listen to POWER_CHANGED, not just POWER_CHANGED_ALL, as this provides useful information with the _READY registers. - Print the device name in both tracepoints, to disambiguate things on systems with multiple Mali GPUs. - Document the gpu_power_status tracepoint, so the meaning of the fields is made clear. - Link to v1: https://lore.kernel.org/r/[email protected] --- Nicolas Frattaroli (3): drm/panthor: Extend IRQ helpers for mask modification/restoration drm/panthor: Add tracepoint for hardware utilisation changes drm/panthor: Add gpu_job_irq tracepoint drivers/gpu/drm/panthor/panthor_device.h | 68 +++++++++++++++++++++---- drivers/gpu/drm/panthor/panthor_fw.c | 13 +++++ drivers/gpu/drm/panthor/panthor_gpu.c | 30 ++++++++++- drivers/gpu/drm/panthor/panthor_gpu.h | 2 + drivers/gpu/drm/panthor/panthor_hw.c | 62 +++++++++++++++++++++++ drivers/gpu/drm/panthor/panthor_hw.h | 8 +++ drivers/gpu/drm/panthor/panthor_trace.h | 86 ++++++++++++++++++++++++++++++++ 7 files changed, 258 insertions(+), 11 deletions(-) --- base-commit: 98fdf8a438c3a1d9de8d5804cdcda94e097d53a0 change-id: 20251203-panthor-tracepoints-488af09d46e7 Best regards, -- Nicolas Frattaroli <[email protected]>
