mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-05 08:20:26 +01:00
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> (cherry picked from commit3fa6b8d041)
This commit is contained in:
parent
9af1aa306f
commit
5be2d785ae
2 changed files with 8 additions and 31 deletions
|
|
@ -157,7 +157,7 @@
|
|||
"description": "iris: Use intel_i915_query for meminfo",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "e60114b2ae117b0f9cc55de57ab397804c8d6bf8"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue