4
0
mirror of https://github.com/revyos-package/mesa.git synced 2026-04-28 09:13:36 +00:00

rusticl/event: fix deadlock when calling clGetEventProfilingInfo inside callbacks

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11243
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29483>
(cherry picked from commit 6f713a764fb412567caaabd9ae574822e79da383)
This commit is contained in:
Karol Herbst
2024-05-30 14:16:23 +02:00
committed by Eric Engestrom
parent 9b6e18a19d
commit 79c30d20f7
2 changed files with 11 additions and 10 deletions

View File

@@ -4,7 +4,7 @@
"description": "rusticl/event: fix deadlock when calling clGetEventProfilingInfo inside callbacks",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View File

@@ -110,7 +110,7 @@ impl Event {
self.state().status
}
fn set_status(&self, lock: &mut MutexGuard<EventMutState>, new: cl_int) {
fn set_status(&self, mut lock: MutexGuard<EventMutState>, new: cl_int) {
lock.status = new;
// signal on completion or an error
@@ -123,14 +123,17 @@ impl Event {
if [CL_COMPLETE, CL_RUNNING, CL_SUBMITTED].contains(&cb_idx) {
if let Some(cbs) = lock.cbs.get_mut(cb_idx as usize) {
cbs.drain(..).for_each(|cb| cb.call(self, new));
let cbs = mem::take(cbs);
// applications might want to access the event in the callback, so drop the lock
// before calling into the callbacks.
drop(lock);
cbs.into_iter().for_each(|cb| cb.call(self, new));
}
}
}
pub fn set_user_status(&self, status: cl_int) {
let mut lock = self.state();
self.set_status(&mut lock, status);
self.set_status(self.state(), status);
}
pub fn is_error(&self) -> bool {
@@ -176,10 +179,8 @@ impl Event {
}
pub(super) fn signal(&self) {
let mut lock = self.state();
self.set_status(&mut lock, CL_RUNNING as cl_int);
self.set_status(&mut lock, CL_COMPLETE as cl_int);
self.set_status(self.state(), CL_RUNNING as cl_int);
self.set_status(self.state(), CL_COMPLETE as cl_int);
}
pub fn wait(&self) -> cl_int {
@@ -235,7 +236,7 @@ impl Event {
lock.time_start = query_start.unwrap().read_blocked();
lock.time_end = query_end.unwrap().read_blocked();
}
self.set_status(&mut lock, new);
self.set_status(lock, new);
}
}