intel/perf: Use intel_i915_query_flags instead of hand-rolling it
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11770>
This commit is contained in:

committed by
Marge Bot

parent
ba99d2a328
commit
f5008a48d3
@@ -83,12 +83,13 @@ intel_ioctl(int fd, unsigned long request, void *arg)
|
|||||||
* it's better to have a common helper.
|
* it's better to have a common helper.
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int
|
||||||
intel_i915_query(int fd, uint64_t query_id, void *buffer,
|
intel_i915_query_flags(int fd, uint64_t query_id, uint32_t flags,
|
||||||
int32_t *buffer_len)
|
void *buffer, int32_t *buffer_len)
|
||||||
{
|
{
|
||||||
struct drm_i915_query_item item = {
|
struct drm_i915_query_item item = {
|
||||||
.query_id = query_id,
|
.query_id = query_id,
|
||||||
.length = *buffer_len,
|
.length = *buffer_len,
|
||||||
|
.flags = flags,
|
||||||
.data_ptr = (uintptr_t)buffer,
|
.data_ptr = (uintptr_t)buffer,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -108,6 +109,13 @@ intel_i915_query(int fd, uint64_t query_id, void *buffer,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
intel_i915_query(int fd, uint64_t query_id, void *buffer,
|
||||||
|
int32_t *buffer_len)
|
||||||
|
{
|
||||||
|
return intel_i915_query_flags(fd, query_id, 0, buffer, buffer_len);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query for the given data, allocating as needed
|
* Query for the given data, allocating as needed
|
||||||
*
|
*
|
||||||
|
@@ -252,26 +252,13 @@ kernel_has_dynamic_config_support(struct intel_perf_config *perf, int fd)
|
|||||||
&invalid_config_id) < 0 && errno == ENOENT;
|
&invalid_config_id) < 0 && errno == ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
i915_query_items(struct intel_perf_config *perf, int fd,
|
|
||||||
struct drm_i915_query_item *items, uint32_t n_items)
|
|
||||||
{
|
|
||||||
struct drm_i915_query q = {
|
|
||||||
.num_items = n_items,
|
|
||||||
.items_ptr = to_user_pointer(items),
|
|
||||||
};
|
|
||||||
return intel_ioctl(fd, DRM_IOCTL_I915_QUERY, &q);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
i915_query_perf_config_supported(struct intel_perf_config *perf, int fd)
|
i915_query_perf_config_supported(struct intel_perf_config *perf, int fd)
|
||||||
{
|
{
|
||||||
struct drm_i915_query_item item = {
|
int32_t length = 0;
|
||||||
.query_id = DRM_I915_QUERY_PERF_CONFIG,
|
return !intel_i915_query_flags(fd, DRM_I915_QUERY_PERF_CONFIG,
|
||||||
.flags = DRM_I915_QUERY_PERF_CONFIG_LIST,
|
DRM_I915_QUERY_PERF_CONFIG_LIST,
|
||||||
};
|
NULL, &length);
|
||||||
|
|
||||||
return i915_query_items(perf, fd, &item, 1) == 0 && item.length > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@@ -283,18 +270,15 @@ i915_query_perf_config_data(struct intel_perf_config *perf,
|
|||||||
struct drm_i915_query_perf_config query;
|
struct drm_i915_query_perf_config query;
|
||||||
struct drm_i915_perf_oa_config config;
|
struct drm_i915_perf_oa_config config;
|
||||||
} item_data;
|
} item_data;
|
||||||
struct drm_i915_query_item item = {
|
|
||||||
.query_id = DRM_I915_QUERY_PERF_CONFIG,
|
|
||||||
.flags = DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID,
|
|
||||||
.data_ptr = to_user_pointer(&item_data),
|
|
||||||
.length = sizeof(item_data),
|
|
||||||
};
|
|
||||||
|
|
||||||
memset(&item_data, 0, sizeof(item_data));
|
memset(&item_data, 0, sizeof(item_data));
|
||||||
memcpy(item_data.query.uuid, guid, sizeof(item_data.query.uuid));
|
memcpy(item_data.query.uuid, guid, sizeof(item_data.query.uuid));
|
||||||
memcpy(&item_data.config, config, sizeof(item_data.config));
|
memcpy(&item_data.config, config, sizeof(item_data.config));
|
||||||
|
|
||||||
if (!(i915_query_items(perf, fd, &item, 1) == 0 && item.length > 0))
|
int32_t item_length = sizeof(item_data);
|
||||||
|
if (intel_i915_query_flags(fd, DRM_I915_QUERY_PERF_CONFIG,
|
||||||
|
DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID,
|
||||||
|
&item_data, &item_length))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
memcpy(config, &item_data.config, sizeof(item_data.config));
|
memcpy(config, &item_data.config, sizeof(item_data.config));
|
||||||
|
Reference in New Issue
Block a user