libdrm/lima: check buffer id in WAIT

Issue #4760.
This commit is contained in:
Josef Söntgen 2022-12-20 17:34:01 +00:00 committed by Christian Helmuth
parent 66fedecf34
commit 89f99df44d

View File

@ -396,6 +396,22 @@ class Lima::Call
Gpu::Vram_id_space _buffer_space { }; Gpu::Vram_id_space _buffer_space { };
template <typename FN>
bool _apply_handle(uint32_t handle, FN const &fn)
{
Buffer_id const id { .value = handle };
bool found = false;
try {
_buffer_space.apply<Buffer>(id, [&] (Buffer &b) {
fn(b);
found = true;
});
} catch (Genode::Id_space<Buffer>::Unknown_id) { }
return found;
}
/* /*
* Play it safe, glmark2 apparently submits araound 110 KiB at * Play it safe, glmark2 apparently submits araound 110 KiB at
* some point. * some point.
@ -405,14 +421,15 @@ class Lima::Call
void _wait_for_mapping(uint32_t handle, unsigned op) void _wait_for_mapping(uint32_t handle, unsigned op)
{ {
Buffer_id const id { .value = handle }; (void)_apply_handle(handle, [&] (Buffer &b) {
do { do {
if (_main_ctx.gpu().set_tiling(id, 0, op)) if (_main_ctx.gpu().set_tiling(b.id(), 0, op))
break; break;
char buf; char buf;
(void)::read(_main_ctx.fd(), &buf, sizeof(buf)); (void)::read(_main_ctx.fd(), &buf, sizeof(buf));
} while (true); } while (true);
});
} }
int _wait_for_syncobj(int fd) int _wait_for_syncobj(int fd)
@ -446,22 +463,6 @@ class Lima::Call
return 0; return 0;
} }
template <typename FN>
bool _apply_handle(uint32_t handle, FN const &fn)
{
Buffer_id const id { .value = handle };
bool found = false;
try {
_buffer_space.apply<Buffer>(id, [&] (Buffer &b) {
fn(b);
found = true;
});
} catch (Genode::Id_space<Buffer>::Unknown_id) { }
return found;
}
Dataspace_capability _lookup_cap_from_handle(uint32_t handle) Dataspace_capability _lookup_cap_from_handle(uint32_t handle)
{ {
Dataspace_capability cap { }; Dataspace_capability cap { };