]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/msm: Add per-context perfcntr state
authorRob Clark <robin.clark@oss.qualcomm.com>
Tue, 26 May 2026 14:50:43 +0000 (07:50 -0700)
committerRob Clark <robin.clark@oss.qualcomm.com>
Fri, 29 May 2026 14:07:28 +0000 (07:07 -0700)
The upcoming PERFCNTR_CONFIG ioctl will allow for both global counter
collection, and per-context counter reservation for local (ie. within
a single GEM_SUBMIT ioctl) counter collection.

Any number of contexts can reserve the same counters, but we will need
to ensure that counters reserved for local counter collection do not
conflict with counters used for global counter collection.

So add tracking for per-context local counter reservations.

Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Anna Maniscalco <anna.maniscalco2000@gmail.com>
Reviewed-by: Akhil P Oommen <akhilpo@oss.qualcomm.com>
Patchwork: https://patchwork.freedesktop.org/patch/728211/
Message-ID: <20260526145137.160554-10-robin.clark@oss.qualcomm.com>

drivers/gpu/drm/msm/msm_gpu.h
drivers/gpu/drm/msm/msm_perfcntr.h
drivers/gpu/drm/msm/msm_submitqueue.c

index bdafdf20f3f761841bb9a475d1fcd842f365566b..677cd7d509d7279b255fc6cd767014b18b6ac527 100644 (file)
@@ -434,6 +434,11 @@ struct msm_context {
         * this context.
         */
        atomic64_t ctx_mem;
+
+       /**
+        * @perfcntrs: Per-context reserved perfcntrs state
+        */
+       struct msm_perfcntr_context_state *perfctx;
 };
 
 struct drm_gpuvm *msm_context_vm(struct drm_device *dev, struct msm_context *ctx);
index 8b0d627b2779c467cada33c0d5b3fd3b2dce5086..d73f1ad9039d8aad8992525b5932a0993443b047 100644 (file)
@@ -35,6 +35,27 @@ struct msm_perfcntr_group {
        const struct msm_perfcntr_counter *counters;
 };
 
+/**
+ * struct msm_perfcntr_context_state - per-msm_context counter state
+ *
+ * A given counter can either be unused, reserved for global counter
+ * collection exclusively, or reserved for local per-context counter
+ * collection inclusively.  Multiple contexts can reserve the same
+ * counter, since SEL reg programming and counter begin/end sampling
+ * happen locally (within a single GEM_SUBMIT ioctl).
+ */
+struct msm_perfcntr_context_state {
+       /** @dummy: Some compilers dislike structs with only a flex array */
+       unsigned dummy;
+
+       /**
+        * @reserved_counters:
+        *
+        * The number of reserved counters indexed by perfcntr group.
+        */
+       unsigned reserved_counters[];
+};
+
 extern const struct msm_perfcntr_group a6xx_perfcntr_groups[];
 extern const unsigned a6xx_num_perfcntr_groups;
 
index 2598d674a99da885c7850334d0f6e4f9dd6cf8a4..a58fe41602c6ae838427369722278fbbd7230fc5 100644 (file)
@@ -66,6 +66,7 @@ void __msm_context_destroy(struct kref *kref)
        drm_gpuvm_put(ctx->vm);
        kfree(ctx->comm);
        kfree(ctx->cmdline);
+       kfree(ctx->perfctx);
        kfree(ctx);
 }