intel/perf: restructure i915 perf version checks
Trying to make things more readable. Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Marcin Ślusarz <marcin.slusarz@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8525>
This commit is contained in:
@@ -389,6 +389,26 @@ gen_perf_new(void *ctx)
|
|||||||
return perf;
|
return perf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Whether we have the ability to hold off preemption on a batch so we don't
|
||||||
|
* have to look at the OA buffer to subtract unrelated workloads off the
|
||||||
|
* values captured through MI_* commands.
|
||||||
|
*/
|
||||||
|
static inline bool
|
||||||
|
gen_perf_has_hold_preemption(const struct gen_perf_config *perf)
|
||||||
|
{
|
||||||
|
return perf->i915_perf_version >= 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether we have the ability to lock EU array power configuration for the
|
||||||
|
* duration of the performance recording. This is useful on Gen11 where the HW
|
||||||
|
* architecture requires half the EU for particular workloads.
|
||||||
|
*/
|
||||||
|
static inline bool
|
||||||
|
gen_perf_has_global_sseu(const struct gen_perf_config *perf)
|
||||||
|
{
|
||||||
|
return perf->i915_perf_version >= 4;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t gen_perf_get_n_passes(struct gen_perf_config *perf,
|
uint32_t gen_perf_get_n_passes(struct gen_perf_config *perf,
|
||||||
const uint32_t *counter_indices,
|
const uint32_t *counter_indices,
|
||||||
uint32_t counter_indices_count,
|
uint32_t counter_indices_count,
|
||||||
|
@@ -348,8 +348,6 @@ gen_perf_close(struct gen_perf_context *perfquery,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NUM_PERF_PROPERTIES(array) (ARRAY_SIZE(array) / 2)
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
gen_perf_open(struct gen_perf_context *perf_ctx,
|
gen_perf_open(struct gen_perf_context *perf_ctx,
|
||||||
int metrics_set_id,
|
int metrics_set_id,
|
||||||
@@ -358,28 +356,40 @@ gen_perf_open(struct gen_perf_context *perf_ctx,
|
|||||||
int drm_fd,
|
int drm_fd,
|
||||||
uint32_t ctx_id)
|
uint32_t ctx_id)
|
||||||
{
|
{
|
||||||
uint64_t properties[] = {
|
uint64_t properties[DRM_I915_PERF_PROP_MAX * 2];
|
||||||
/* Single context sampling */
|
uint32_t p = 0;
|
||||||
DRM_I915_PERF_PROP_CTX_HANDLE, ctx_id,
|
|
||||||
|
|
||||||
/* Include OA reports in samples */
|
/* Single context sampling */
|
||||||
DRM_I915_PERF_PROP_SAMPLE_OA, true,
|
properties[p++] = DRM_I915_PERF_PROP_CTX_HANDLE;
|
||||||
|
properties[p++] = ctx_id;
|
||||||
|
|
||||||
/* OA unit configuration */
|
/* Include OA reports in samples */
|
||||||
DRM_I915_PERF_PROP_OA_METRICS_SET, metrics_set_id,
|
properties[p++] = DRM_I915_PERF_PROP_SAMPLE_OA;
|
||||||
DRM_I915_PERF_PROP_OA_FORMAT, report_format,
|
properties[p++] = true;
|
||||||
DRM_I915_PERF_PROP_OA_EXPONENT, period_exponent,
|
|
||||||
|
/* OA unit configuration */
|
||||||
|
properties[p++] = DRM_I915_PERF_PROP_OA_METRICS_SET;
|
||||||
|
properties[p++] = metrics_set_id;
|
||||||
|
|
||||||
|
properties[p++] = DRM_I915_PERF_PROP_OA_FORMAT;
|
||||||
|
properties[p++] = report_format;
|
||||||
|
|
||||||
|
properties[p++] = DRM_I915_PERF_PROP_OA_EXPONENT;
|
||||||
|
properties[p++] = period_exponent;
|
||||||
|
|
||||||
|
/* SSEU configuration */
|
||||||
|
if (gen_perf_has_global_sseu(perf_ctx->perf)) {
|
||||||
|
properties[p++] = DRM_I915_PERF_PROP_GLOBAL_SSEU;
|
||||||
|
properties[p++] = to_user_pointer(&perf_ctx->perf->sseu);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(p <= ARRAY_SIZE(properties));
|
||||||
|
|
||||||
/* SSEU configuration */
|
|
||||||
DRM_I915_PERF_PROP_GLOBAL_SSEU, to_user_pointer(&perf_ctx->perf->sseu),
|
|
||||||
};
|
|
||||||
struct drm_i915_perf_open_param param = {
|
struct drm_i915_perf_open_param param = {
|
||||||
.flags = I915_PERF_FLAG_FD_CLOEXEC |
|
.flags = I915_PERF_FLAG_FD_CLOEXEC |
|
||||||
I915_PERF_FLAG_FD_NONBLOCK |
|
I915_PERF_FLAG_FD_NONBLOCK |
|
||||||
I915_PERF_FLAG_DISABLED,
|
I915_PERF_FLAG_DISABLED,
|
||||||
.num_properties = perf_ctx->perf->i915_perf_version >= 4 ?
|
.num_properties = p / 2,
|
||||||
NUM_PERF_PROPERTIES(properties) :
|
|
||||||
NUM_PERF_PROPERTIES(properties) - 1,
|
|
||||||
.properties_ptr = (uintptr_t) properties,
|
.properties_ptr = (uintptr_t) properties,
|
||||||
};
|
};
|
||||||
int fd = gen_ioctl(drm_fd, DRM_IOCTL_I915_PERF_OPEN, ¶m);
|
int fd = gen_ioctl(drm_fd, DRM_IOCTL_I915_PERF_OPEN, ¶m);
|
||||||
|
@@ -57,7 +57,7 @@ anv_get_perf(const struct gen_device_info *devinfo, int fd)
|
|||||||
* perf revision 2.
|
* perf revision 2.
|
||||||
*/
|
*/
|
||||||
if (!(INTEL_DEBUG & DEBUG_NO_OACONFIG)) {
|
if (!(INTEL_DEBUG & DEBUG_NO_OACONFIG)) {
|
||||||
if (perf->i915_perf_version < 3)
|
if (!gen_perf_has_hold_preemption(perf))
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ anv_device_perf_open(struct anv_device *device, uint64_t metric_id)
|
|||||||
* enabled we would use only half on Gen11 because of functional
|
* enabled we would use only half on Gen11 because of functional
|
||||||
* requirements.
|
* requirements.
|
||||||
*/
|
*/
|
||||||
if (device->physical->perf->i915_perf_version >= 4) {
|
if (gen_perf_has_global_sseu(device->physical->perf)) {
|
||||||
properties[p++] = DRM_I915_PERF_PROP_GLOBAL_SSEU;
|
properties[p++] = DRM_I915_PERF_PROP_GLOBAL_SSEU;
|
||||||
properties[p++] = (uintptr_t) &device->physical->perf->sseu;
|
properties[p++] = (uintptr_t) &device->physical->perf->sseu;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user