@@ -9,6 +9,7 @@ panthor-y := \
panthor_gpu.o \
panthor_heap.o \
panthor_mmu.o \
+ panthor_perf.o \
panthor_sched.o
obj-$(CONFIG_DRM_PANTHOR) += panthor.o
@@ -119,6 +119,9 @@ struct panthor_device {
/** @csif_info: Command stream interface information. */
struct drm_panthor_csif_info csif_info;
+ /** @perf_info: Performance counter interface information. */
+ struct drm_panthor_perf_info perf_info;
+
/** @gpu: GPU management data. */
struct panthor_gpu *gpu;
@@ -175,7 +175,9 @@ panthor_get_uobj_array(const struct drm_panthor_obj_array *in, u32 min_stride,
PANTHOR_UOBJ_DECL(struct drm_panthor_sync_op, timeline_value), \
PANTHOR_UOBJ_DECL(struct drm_panthor_queue_submit, syncs), \
PANTHOR_UOBJ_DECL(struct drm_panthor_queue_create, ringbuf_size), \
- PANTHOR_UOBJ_DECL(struct drm_panthor_vm_bind_op, syncs))
+ PANTHOR_UOBJ_DECL(struct drm_panthor_vm_bind_op, syncs), \
+ PANTHOR_UOBJ_DECL(struct drm_panthor_perf_info, shader_blocks))
+
/**
* PANTHOR_UOBJ_SET() - Copy a kernel object to a user object.
@@ -834,6 +836,10 @@ static int panthor_ioctl_dev_query(struct drm_device *ddev, void *data, struct d
args->size = sizeof(priorities_info);
return 0;
+ case DRM_PANTHOR_DEV_QUERY_PERF_INFO:
+ args->size = sizeof(ptdev->perf_info);
+ return 0;
+
default:
return -EINVAL;
}
@@ -858,6 +864,9 @@ static int panthor_ioctl_dev_query(struct drm_device *ddev, void *data, struct d
panthor_query_group_priorities_info(file, &priorities_info);
return PANTHOR_UOBJ_SET(args->pointer, args->size, priorities_info);
+ case DRM_PANTHOR_DEV_QUERY_PERF_INFO:
+ return PANTHOR_UOBJ_SET(args->pointer, args->size, ptdev->perf_info);
+
default:
return -EINVAL;
}
@@ -21,6 +21,7 @@
#include "panthor_gem.h"
#include "panthor_gpu.h"
#include "panthor_mmu.h"
+#include "panthor_perf.h"
#include "panthor_regs.h"
#include "panthor_sched.h"
@@ -1417,6 +1418,9 @@ int panthor_fw_init(struct panthor_device *ptdev)
goto err_unplug_fw;
panthor_fw_init_global_iface(ptdev);
+
+ panthor_perf_info_init(ptdev);
+
return 0;
err_unplug_fw:
@@ -5,6 +5,7 @@
#define __PANTHOR_MCU_H__
#include <linux/types.h>
+#include <linux/spinlock.h>
struct panthor_device;
struct panthor_kernel_bo;
@@ -197,8 +198,11 @@ struct panthor_fw_global_control_iface {
u32 output_va;
u32 group_num;
u32 group_stride;
+#define GLB_PERFCNT_FW_SIZE(x) ((((x) >> 16) << 8))
u32 perfcnt_size;
u32 instr_features;
+#define PERFCNT_FEATURES_MD_SIZE(x) ((x) & GENMASK(3, 0))
+ u32 perfcnt_features;
};
struct panthor_fw_global_input_iface {
new file mode 100644
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0 or MIT
+/* Copyright 2023 Collabora Ltd */
+/* Copyright 2024 Arm ltd. */
+
+#include <drm/drm_file.h>
+#include <drm/drm_gem_shmem_helper.h>
+#include <drm/drm_managed.h>
+#include <drm/panthor_drm.h>
+
+#include "panthor_device.h"
+#include "panthor_fw.h"
+#include "panthor_gpu.h"
+#include "panthor_perf.h"
+#include "panthor_regs.h"
+
+/**
+ * PANTHOR_PERF_COUNTERS_PER_BLOCK - On CSF architectures pre-11.x, the number of counters
+ * per block was hardcoded to be 64. Arch 11.0 onwards supports the PRFCNT_FEATURES GPU register,
+ * which indicates the same information.
+ */
+#define PANTHOR_PERF_COUNTERS_PER_BLOCK (64)
+
+void panthor_perf_info_init(struct panthor_device *ptdev)
+{
+ struct panthor_fw_global_iface *glb_iface = panthor_fw_get_glb_iface(ptdev);
+ struct drm_panthor_perf_info *const perf_info = &ptdev->perf_info;
+
+ if (PERFCNT_FEATURES_MD_SIZE(glb_iface->control->perfcnt_features))
+ perf_info->flags |= DRM_PANTHOR_PERF_BLOCK_STATES_SUPPORT;
+
+ if (GPU_ARCH_MAJOR(ptdev->gpu_info.gpu_id) < 11)
+ perf_info->counters_per_block = PANTHOR_PERF_COUNTERS_PER_BLOCK;
+
+ perf_info->sample_header_size = sizeof(struct drm_panthor_perf_sample_header);
+ perf_info->block_header_size = sizeof(struct drm_panthor_perf_block_header);
+
+ if (GLB_PERFCNT_FW_SIZE(glb_iface->control->perfcnt_size)) {
+ perf_info->fw_blocks = 1;
+ perf_info->csg_blocks = glb_iface->control->group_num;
+ }
+
+ perf_info->cshw_blocks = 1;
+ perf_info->tiler_blocks = 1;
+ perf_info->memsys_blocks = hweight64(ptdev->gpu_info.l2_present);
+ perf_info->shader_blocks = hweight64(ptdev->gpu_info.shader_present);
+}
+
new file mode 100644
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 or MIT */
+/* Copyright 2024 Collabora Ltd */
+/* Copyright 2024 Arm ltd. */
+
+#ifndef __PANTHOR_PERF_H__
+#define __PANTHOR_PERF_H__
+
+struct panthor_device;
+
+void panthor_perf_info_init(struct panthor_device *ptdev);
+
+#endif /* __PANTHOR_PERF_H__ */
This change adds the IOCTL to query data about the performance counter setup. Some of this data was available via previous DEV_QUERY calls, for instance for GPU info, but exposing it via PERF_INFO minimizes the overhead of creating a single session to just the one aggregate IOCTL. To better align the FW interfaces with the arch spec, the patch also renames perfcnt to prfcnt. Signed-off-by: Lukas Zapolskas <lukas.zapolskas@arm.com> --- drivers/gpu/drm/panthor/Makefile | 1 + drivers/gpu/drm/panthor/panthor_device.h | 3 ++ drivers/gpu/drm/panthor/panthor_drv.c | 11 +++++- drivers/gpu/drm/panthor/panthor_fw.c | 4 ++ drivers/gpu/drm/panthor/panthor_fw.h | 4 ++ drivers/gpu/drm/panthor/panthor_perf.c | 47 ++++++++++++++++++++++++ drivers/gpu/drm/panthor/panthor_perf.h | 12 ++++++ 7 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/panthor/panthor_perf.c create mode 100644 drivers/gpu/drm/panthor/panthor_perf.h