gbm_bo_map fails on i915 when *map_data is not NULL before call
Submitted by M Stoeckl
Assigned to Intel 3D Bugs Mailing List
Created attachment 144477 Test case, compile with gcc -lgbm
The documentation for the function gbm_bo_map in src/gbm/main/gbm.c states that the argument void** map_data is a "Returned opaque ptr for the mapped region". Contrary to convention for a return value, if *map_data is not NULL, and the DRI i965 driver is used, then gbm_bo_map fails.
The value of *map_data is checked by intel_map_image in src/mesa/drivers/dri/i965/intel_screen.c (line 823 in today's git master).
Debugging this (see attached test program) was made slightly more complicated by the fact that errno was set to ENODEV, after the syscall DRM_IOCTL_I915_GEM_CONTEXT_CREATE failed on the first call to gbm_bo_map . Reading kernel sources implies that this probably only happens for <gen6 intel GPUs.
Attachment 144477, "Test case, compile with gcc -lgbm":