drm/msm: Add per-context perfcntr state

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>
This commit is contained in:
Rob Clark 2026-05-26 07:50:43 -07:00
parent 90f2b0461b
commit 8766dbc37d
3 changed files with 27 additions and 0 deletions

View 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);

View 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;

View 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);
}