Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions drivers/gpu/drm/asahi/g17/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,9 +1053,12 @@ impl Backend {
{
let state = self.shared.state.lock();
let firmware = state.as_ref().ok_or(ENODEV)?;
if firmware.queues.compute(self.owner).is_some_and(|queue| queue.pool_fits(required)) {
return Ok(());
}
match firmware.queues.compute(self.owner) {
Some(queue) if queue.pool_fits(required) => return Ok(()),
// Shared away already: build_compute binds a channel, so allocate nothing here.
None => return Err(EAGAIN),
Some(_) => {}
};
}
let lease = self.shared.preparations.enter_until(admission)?;
let dev = self.shared.drm()?;
Expand All @@ -1066,6 +1069,11 @@ impl Backend {
let mut alias = Some(pages.as_mut().ok_or(EIO)?.map_client(self.context.vm())?);
let mut deferred = DeferredBatch::publication()?;
let mut growth = None;
// Set when the owner holds no queue any more. Until growth begins, its queue is an idle
// channel that another owner's admission may share away (`share_idle`); only
// build_compute binds a channel again, so no progress this loop waits for can end that
// wait.
let mut unbound = false;
let result = (|| loop {
// Growth waits for this queue's retirement and for firmware to consume the pool
// release; both are progress the event worker reports.
Expand All @@ -1077,7 +1085,10 @@ impl Backend {
if !lease.is_current() { return Err(EAGAIN); }
if self.shared.crashed.load(Ordering::Acquire) { return Err(EIO); }
firmware.scan_compute(None, &mut deferred)?;
let mut queue = firmware.queues.compute_mut(self.owner).ok_or(EAGAIN)?;
let Some(mut queue) = firmware.queues.compute_mut(self.owner) else {
unbound = true;
return Err(EAGAIN);
};
if queue.pool_fits(required) { return Ok(None); }
if growth.is_none() {
let notify = queue.begin_growth(&firmware.init, required)?;
Expand All @@ -1094,6 +1105,8 @@ impl Backend {
deferred.finish();
match result {
Ok(old) => { drop(old); return Ok(()); }
// ensure_compute retries EAGAIN through build_compute, which binds a channel.
Err(error) if error == EAGAIN && unbound => return Err(error),
Err(error) if error == EAGAIN && lease.is_current() => {
self.shared.queue_events();
self.wait_release(&self.shared.progress, observed, admission)?;
Expand Down
Loading