anv: Handle errors properly in anv_i915_query
DRM_IOCTL_I915_QUERY is a multi-query. The most egregious errors are
returned via the usual ioctl error mechanism but there are also
per-query errors that are indicated by item.length < 0. We need to
handle those as well. While we're at it, scrape errno so we can return
a proper integer error.
Fixes: c0d07c838a "anv: Support i915 query (DRM_IOCTL_I915_QUERY)..."
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
d07e5bde75
commit
b664481ba9
@@ -787,8 +787,13 @@ anv_i915_query(int fd, uint64_t query_id, void *buffer,
|
||||
};
|
||||
|
||||
int ret = intel_ioctl(fd, DRM_IOCTL_I915_QUERY, &args);
|
||||
if (ret != 0)
|
||||
return -errno;
|
||||
else if (item.length < 0)
|
||||
return item.length;
|
||||
|
||||
*buffer_len = item.length;
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct drm_i915_query_engine_info *
|
||||
@@ -796,14 +801,14 @@ anv_gem_get_engine_info(int fd)
|
||||
{
|
||||
int32_t length = 0;
|
||||
int ret = anv_i915_query(fd, DRM_I915_QUERY_ENGINE_INFO, NULL, &length);
|
||||
if (ret == -1)
|
||||
if (ret < 0)
|
||||
return NULL;
|
||||
|
||||
struct drm_i915_query_engine_info *info = calloc(1, length);
|
||||
ret = anv_i915_query(fd, DRM_I915_QUERY_ENGINE_INFO, info, &length);
|
||||
assert(ret == 0);
|
||||
|
||||
if (ret != 0) {
|
||||
if (ret < 0) {
|
||||
free(info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user