iris: Avoid recursive ctx mutex lock when re-using buffer
I found a recursive mutex lock when creating texture from glamor that ended up re-usng a bo which had aux map. The proposed patch isn't a great fix as it makes the ctx mutex recursive. A real fix will probably require restructuring a lot of code.
intel_aux_map_add_mapping locks ctx->mutex and then calls:
add_mapping ->
get_aux_entry ->
add_sub_table ->
add_buffer ->
` intel_aux_map_buffer_alloc -> iris_bo_alloc -> alloc_bo_from_cache -> intel_aux_map_unmap_range -> intel_aux_unmap_range -> pthread_lock
GDB Stack trace:
(bufmgr=bufmgr@entry=0x55fb10f6f390, bucket=bucket@entry=0x55fb10f6f638, alignment=alignment@entry=65536, memzone=memzone@entry=IRIS_MEMZONE_OTHER, mmap_mode=mmap_mode@entry=IRIS_MMAP_WB, flags=flags@entry=0, match_zone=true) at ../src/gallium/drivers/iris/iris_bufmgr.c:486
(bufmgr=bufmgr@entry=0x55fb10f6f390, name=name@entry=0x7fe05c1b6db8 "aux-map", size=size@entry=1048576, alignment=alignment@entry=65536, memzone=memzone@entry=IRIS_MEMZONE_OTHER, flags=flags@entry=0) at ../src/gallium/drivers/iris/iris_bufmgr.c:626
at ../src/intel/common/intel_aux_map.c:183
(ctx=0x55fb10f6ff70, address=18446744067199991808, l1_index_out=0x7ffcd0c1b8a4, l1_entry_addr_out=0x0, l1_entry_map_out=0x7ffcd0c1b8a8)
at ../src/intel/common/intel_aux_map.c:372
(state_changed=<synthetic pointer>, format_bits=2976879353691897856, aux_address=18446744067315955968, address=18446744067199991808, ctx=0x55fb10f6ff70)
at ../src/intel/common/intel_aux_map.c:404
(ctx=ctx@entry=0x55fb10f6ff70, address=18446744067175284736, aux_address=140723810842792, main_size_B=140723810842788, format_bits=2976879353691897856)
at ../src/intel/common/intel_aux_map.c:460
at ../src/gallium/drivers/iris/iris_resource.c:547
(pscreen=<optimized out>, templ=0x7ffcd0c1b970, modifiers=<optimized out>, modifiers_count=<optimized out>)
at ../src/gallium/drivers/iris/iris_resource.c:1098
(st=st@entry=0x55fb10fb7030, target=<optimized out>, format=format@entry=PIPE_FORMAT_B8G8R8A8_UNORM, last_level=last_level@entry=0, width0=<optimized out>, height0=<optimized out>, depth0=1, layers=1, nr_samples=0, bind=10) at ../src/mesa/state_tracker/st_texture.c:100
at ../src/mesa/state_tracker/st_cb_texture.c:987
at ../src/mesa/state_tracker/st_cb_texture.c:2267
at ../src/mesa/state_tracker/st_cb_texture.c:2254
(no_error=false, pixels=0x0, imageSize=0, type=33639, format=32993, border=0, depth=<optimized out>, height=<optimized out>, width=<optimized out>, internalFormat=6408, level=0, target=3553, texObj=0x55fb1224d360, dims=2, compressed=compressed@entry=0 '\000', ctx=0x7fe050e85010) at ../src/mesa/main/teximage.c:3154
(ctx=0x7fe050e85010, compressed=compressed@entry=0 '\000', dims=dims@entry=2, target=3553, level=0, internalFormat=<optimized out>, width=7680, height=4560, depth=1, border=<optimized out>, format=32993, type=33639, imageSize=0, pixels=0x0) at ../src/mesa/main/teximage.c:3181
(target=<optimized out>, level=<optimized out>, internalFormat=<optimized out>, width=<optimized out>, height=<optimized out>, border=<optimized out>, format=32993, type=33639, pixels=0x0) at ../src/mesa/main/teximage.c:3252
at ../glamor/glamor_fbo.c:137
(glamor_priv=glamor_priv@entry=0x55fb11005490, pixmap=pixmap@entry=0x55fb1220efc0, w=w@entry=7680, h=h@entry=4560, flag=flag@entry=0)
at ../glamor/glamor_fbo.c:160
0x55fb104229b0 <main>, argc=10, argv=0x7ffcd0c1bef8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffcd0c1bee8)
at ../csu/libc-start.c:308
Signed-off-by: Keith Packard keithp@keithp.com Fixes: #5191 (closed) (iris: recursive mutex acquire when re-using BO with aux map)