iris: Use intel_i915_query for meminfo
Error handling with DRM_IOCTL_I915_QUERY is tricky and we got it wrong
in one of the two calls here. Use the common helper instead. This also
fixes a theoretical bug where calloc() fails. While we're here, inline
iris_bufmgr_update_meminfo because we're not really benefiting from
having it separate anymore.
Fixes: e60114b2ae "iris/bufmgr: Query memory region info."
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
35ec1d9730
commit
3fa6b8d041
@@ -1674,10 +1674,14 @@ gem_param(int fd, int name)
|
||||
return v;
|
||||
}
|
||||
|
||||
static void
|
||||
iris_bufmgr_update_meminfo(struct iris_bufmgr *bufmgr,
|
||||
const struct drm_i915_query_memory_regions *meminfo)
|
||||
static bool
|
||||
iris_bufmgr_query_meminfo(struct iris_bufmgr *bufmgr)
|
||||
{
|
||||
struct drm_i915_query_memory_regions *meminfo =
|
||||
intel_i915_query_alloc(bufmgr->fd, DRM_I915_QUERY_MEMORY_REGIONS);
|
||||
if (meminfo == NULL)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < meminfo->num_regions; i++) {
|
||||
const struct drm_i915_memory_region_info *mem = &meminfo->regions[i];
|
||||
switch (mem->region.memory_class) {
|
||||
@@ -1692,35 +1696,8 @@ iris_bufmgr_update_meminfo(struct iris_bufmgr *bufmgr,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static bool
|
||||
iris_bufmgr_query_meminfo(struct iris_bufmgr *bufmgr)
|
||||
{
|
||||
struct drm_i915_query_item item = {
|
||||
.query_id = DRM_I915_QUERY_MEMORY_REGIONS,
|
||||
};
|
||||
|
||||
struct drm_i915_query query = {
|
||||
.num_items = 1,
|
||||
.items_ptr = (uintptr_t) &item,
|
||||
};
|
||||
|
||||
if (drmIoctl(bufmgr->fd, DRM_IOCTL_I915_QUERY, &query))
|
||||
return false;
|
||||
|
||||
struct drm_i915_query_memory_regions *meminfo = calloc(1, item.length);
|
||||
item.data_ptr = (uintptr_t)meminfo;
|
||||
|
||||
if (drmIoctl(bufmgr->fd, DRM_IOCTL_I915_QUERY, &query) ||
|
||||
item.length <= 0) {
|
||||
free(meminfo);
|
||||
return false;
|
||||
}
|
||||
|
||||
iris_bufmgr_update_meminfo(bufmgr, meminfo);
|
||||
|
||||
free(meminfo);
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user