Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions drivers/gpu/drm/asahi/g17/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,12 @@ impl Packet {
!self.inputs.is_empty() || self.producers.is_some()
}

/// Host-waited inputs keep a packet on the scheduler publication path;
/// already-published cross-engine firmware producers do not.
pub(crate) fn has_host_dependencies(&self) -> bool {
!self.inputs.is_empty()
}

pub(crate) fn begin_publication(&self) -> bool {
self.publication
.compare_exchange(0, 1, Ordering::AcqRel, Ordering::Acquire)
Expand Down Expand Up @@ -645,6 +651,10 @@ pub(crate) struct Fences {
/// producers in firmware: what that engine's failure log must keep for it.
pub(crate) producers: Option<(u64, Option<u64>)>,
pub(crate) owner: Arc<Completion>,
/// True when `Scheduler::enqueue()` already published this command inline
/// before returning, so later cross-engine consumers can publish inline too
/// without waiting for `scheduled` to signal through `drm_sched`.
pub(crate) inline_published: bool,
}

impl super::dependency::Retention for Fences {
Expand Down Expand Up @@ -783,6 +793,7 @@ impl<B: Backend> Scheduler<B> {
timestamp_waits: None,
producers: None,
owner: packet.completion.clone(),
inline_published: inline && packet.is_published(),
})
}
}
Expand Down
29 changes: 24 additions & 5 deletions drivers/gpu/drm/asahi/g17/queue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ impl<B: Backend> Queue<B> {
publication,
ordering_host_waits,
ordering_firmware_waits,
ordering_firmware_published,
inherited_timestamp_waits,
) = {
let ordering = EnqueueOrdering::build(
Expand Down Expand Up @@ -380,6 +381,7 @@ impl<B: Backend> Queue<B> {
publication,
ordering.host_waits,
ordering.firmware_waits,
ordering.firmware_published,
inherited_timestamp_waits,
)
};
Expand Down Expand Up @@ -412,12 +414,17 @@ impl<B: Backend> Queue<B> {
checked_inputs.push(fence, GFP_KERNEL)?;
}
// Firmware orders execution after each producer; the scheduler needs only the latest
// scheduled fence of them (dependency::ProducerWaits).
// scheduled fence of producers that have not already been published into firmware.
let mut producer_waits = super::dependency::ProducerWaits::new();
for (scheduled, _) in &ordering_firmware_waits {
producer_waits.producer(scheduled, |fence| {
Ok(dependencies.push(fence.clone(), GFP_KERNEL)?)
})?;
for ((scheduled, _), published) in ordering_firmware_waits
.iter()
.zip(ordering_firmware_published.iter())
{
if !*published && job::fence_status(scheduled) <= 0 {
producer_waits.producer(scheduled, |fence| {
Ok(dependencies.push(fence.clone(), GFP_KERNEL)?)
})?;
}
}
// Their failures are checked through the other engine's failure log: one reference
// instead of a completed fence per producer.
Expand Down Expand Up @@ -838,6 +845,9 @@ trait FrontierEntry: outstanding::Status {
}
fn completed(&self) -> &Fence;
fn scheduled(&self) -> &Fence;
fn inline_published(&self) -> bool {
false
}
}

impl FrontierEntry for Fences {
Expand All @@ -860,6 +870,10 @@ impl FrontierEntry for Fences {
fn scheduled(&self) -> &Fence {
&self.scheduled
}

fn inline_published(&self) -> bool {
self.inline_published
}
}

fn push_unique_fence(out: &mut KVec<Fence>, fence: &Fence) -> Result {
Expand Down Expand Up @@ -895,6 +909,7 @@ struct EnqueueOrdering<'a> {
reach: [u64; 2],
host_waits: KVec<Fence>,
firmware_waits: KVec<(Fence, Fence)>,
firmware_published: KVec<bool>,
inherited_timestamp_waits: KVec<Fence>,
}

Expand Down Expand Up @@ -926,6 +941,7 @@ impl<'a> EnqueueOrdering<'a> {
let mut predecessors = KVec::new();
let mut host = KVec::new();
let mut firmware = KVec::new();
let mut firmware_published = KVec::new();
let mut inherited_timestamp_waits = KVec::new();
// A covered publication some kept predecessor already has as an ancestor needs no link of
// its own: it fires before that predecessor, which fires before this command, and its
Expand Down Expand Up @@ -1024,12 +1040,14 @@ impl<'a> EnqueueOrdering<'a> {
(entry.scheduled().clone(), entry.completed().clone()),
GFP_KERNEL,
)?;
firmware_published.push(entry.inline_published(), GFP_KERNEL)?;
}
} else {
firmware.push(
(entry.scheduled().clone(), entry.completed().clone()),
GFP_KERNEL,
)?;
firmware_published.push(entry.inline_published(), GFP_KERNEL)?;
}
}

Expand All @@ -1038,6 +1056,7 @@ impl<'a> EnqueueOrdering<'a> {
reach,
host_waits: host,
firmware_waits: firmware,
firmware_published,
inherited_timestamp_waits,
})
}
Expand Down
12 changes: 11 additions & 1 deletion drivers/gpu/drm/asahi/g17/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3806,13 +3806,23 @@ impl Backend {
/// its queue is already bound and nothing has to wait, as renders do. Any
/// wait leaves the command, unpublished, to its scheduler.
pub(super) fn try_compute_early(&self, packet: &Arc<super::job::Packet>) -> bool {
if self.compute_backlog.load(Ordering::Acquire) != 0 || packet.has_dependencies() {
if self.compute_backlog.load(Ordering::Acquire) != 0 || packet.has_host_dependencies() {
return false;
}
// A command the ray-traversal rule could hold now is left to its scheduler.
if !self.traversal_inline(packet) {
return false;
}
if let Err(error) = packet.check_firmware_producers() {
if !packet.begin_publication() {
packet.completion.fail_unpublished(ECANCELED);
packet.set_early_result(Err(ECANCELED));
return true;
}
packet.completion.fail_unpublished(error);
packet.set_early_result(Err(error));
return true;
}
if !packet.begin_publication() {
packet.completion.fail_unpublished(ECANCELED);
packet.set_early_result(Err(ECANCELED));
Expand Down
12 changes: 11 additions & 1 deletion drivers/gpu/drm/asahi/g17/runtime/render/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,13 +578,23 @@ impl Backend {
}

pub(in crate::g17) fn try_render_early(&self, packet: &Arc<Packet>) -> bool {
if self.backlog.load(Ordering::Acquire) != 0 || packet.has_dependencies() {
if self.backlog.load(Ordering::Acquire) != 0 || packet.has_host_dependencies() {
return false;
}
// As for compute: a render that traces rays is admitted by its scheduler.
if !self.traversal_inline(packet) {
return false;
}
if let Err(error) = packet.check_firmware_producers() {
if !packet.begin_publication() {
packet.completion.fail_unpublished(ECANCELED);
packet.set_early_result(Err(ECANCELED));
return true;
}
packet.completion.fail_unpublished(error);
packet.set_early_result(Err(error));
return true;
}
let admission = match self.admission.try_acquire_render(self.owner, self.render_pairs(packet).into(), Request::of(packet)) {
Ok(Some(lease)) => lease,
_ => return false,
Expand Down
Loading
Loading