Skip to content

iris: handle another error case when querying meminfo

Paulo Zanoni requested to merge pzanoni/mesa:iris-meminfo-alloc-einval into main

The I915_QUERY ioctl may work but the specific query passed may not exist to the Kernel. According to i915.ko's i915_query_ioctl() we return -EINVAL if the query does not exist, so check for that.

Solves:

user@machine:~/git/piglit$ wm valgrind ./bin/shader_runner generated_tests/spec/amd_shader_trinary_minmax/execution/built-in-functions/tcs-mid3-int-int-int.shader_test -auto -fbo
==18830== Argument 'size' of function calloc has a fishy (possibly negative) value: -22
==18830==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==18830==    by 0x6B31202: iris_bufmgr_query_meminfo (iris_bufmgr.c:1713)
==18830==    by 0x6B313E4: iris_bufmgr_create (iris_bufmgr.c:1771)
==18830==    by 0x6B317C2: iris_bufmgr_get_for_fd (iris_bufmgr.c:1871)
==18830==    by 0x6B2C7C3: iris_screen_create (iris_screen.c:797)
==18830==    by 0x6B0307C: iris_drm_screen_create (iris_drm_winsys.c:38)
==18830==    by 0x60FC240: pipe_iris_create_screen (drm_helper.h:102)
==18830==    by 0x6AFF930: pipe_loader_drm_create_screen (pipe_loader_drm.c:269)
==18830==    by 0x6AFF5E2: pipe_loader_create_screen_vk (pipe_loader.c:159)
==18830==    by 0x6AFF601: pipe_loader_create_screen (pipe_loader.c:165)
==18830==    by 0x610189F: dri2_init_screen (dri2.c:2335)
==18830==    by 0x697671B: driCreateNewScreen2 (dri_util.c:160)

Please notice that this fixes the malloc with the -EINVAL as the size argument, but it does not fix the issue where we don't end up actually setting initial values to bufmgr->{vram,sys}.

Fixes: e60114b2 ("iris/bufmgr: Query memory region info.") Cc: @kwg Signed-off-by: Paulo Zanoni <>

Edited by Marcin Ślusarz

Merge request reports