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
6 changes: 4 additions & 2 deletions drivers/gpu/drm/asahi/g17/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,15 @@ impl Context {
mmu::PROT_GPU_FW_SHARED_RW
};
let exposure = Arc::new(Exposure::new(), GFP_KERNEL)?;
// The scheduler page sits in the upper half, which every execution context includes,
// and only the firmware reads and writes it: it is firmware-only.
let mut scheduler = if alloc.uat.is_m5() {
let mut object = pool.allocate(
alloc,
Family::Scheduler,
UAT_PGSZ,
0,
kernel_prot,
mmu::PROT_FW_SHARED_RW,
CpuMap::WriteCombined,
)?;
object.defer_once_exposed(&exposure);
Expand All @@ -308,7 +310,7 @@ impl Context {
SchedulerStorage::Ordinary(alloc.kernel(
UAT_PGSZ,
UAT_PGSZ as u64,
mmu::PROT_GPU_FW_SHARED_RW,
mmu::PROT_FW_SHARED_RW,
CpuMap::WriteCombined,
)?)
};
Expand Down
6 changes: 4 additions & 2 deletions drivers/gpu/drm/asahi/g17/initdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ impl ComputeShared {
}

/// A device-global scheduler, retained independently of whichever physical queue first
/// needed it. Its generation reservation precedes later graph allocation failures.
/// needed it. Its generation reservation precedes later graph allocation failures. Only the
/// firmware reads and writes it, and it sits in the upper half every execution context
/// includes, so it is firmware-only.
pub(super) struct ComputeScheduler {
object: KernelObject,
}
Expand All @@ -123,7 +125,7 @@ impl ComputeScheduler {
let mut object = alloc.kernel(
mmu::UAT_PGSZ,
mmu::UAT_PGSZ as u64,
mmu::PROT_GPU_FW_SHARED_RW,
mmu::PROT_FW_SHARED_RW,
CpuMap::WriteCombined,
)?;
object.initialize::<super::fw::context::Scheduler>(0, |state| {
Expand Down
11 changes: 3 additions & 8 deletions drivers/gpu/drm/asahi/g17/kick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,18 +690,13 @@ impl Queue {
}
}
let (vm, status) = (client.id(), client.status().cloned());
// The firmware's mapping sits in the upper half, which every execution context includes.
// On M5 it is firmware-only, as a compute ring's is; the GPU reads the ring at its lower
// The firmware's mapping sits in the upper half, which every execution context includes,
// so it is firmware-only, as a compute ring's is: the GPU reads the ring at its lower
// address.
let firmware_prot = if alloc.uat.is_m5() {
mmu::PROT_FW_SHARED_RW
} else {
mmu::PROT_GPU_FW_SHARED_RW
};
let high = alloc.kernel(
KICK_RING_SIZE,
mmu::UAT_PGSZ as u64,
firmware_prot,
mmu::PROT_FW_SHARED_RW,
CpuMap::WriteCombined,
)?;
let mut range = alloc.uat.kernel_lower_dynamic_range();
Expand Down
22 changes: 14 additions & 8 deletions drivers/gpu/drm/asahi/g17/queue/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ impl DescriptorRing {
/// does render descriptors: the host rewrites a slot only after the kick
/// that last used it retired (at most `DESCRIPTORS` kicks are in flight),
/// by when that kick's accounting store is in memory. The hardware reads
/// the same pages through an uncached canonical low alias; on M5 the
/// kernel mapping, in the upper half every execution context includes, is
/// the same pages through an uncached canonical low alias; the kernel
/// mapping, in the upper half every execution context includes, is
/// firmware-only.
pub(crate) fn new(alloc: &Allocator<'_>, objects: &Arc<Pool>) -> Result<Self> {
let size = DESCRIPTORS * COMPUTE_DESCRIPTOR_SIZE;
Expand All @@ -124,7 +124,7 @@ impl DescriptorRing {
Family::Descriptor,
size,
if alloc.uat.is_m5() { 0 } else { size },
if alloc.uat.is_m5() { mmu::PROT_FW_SHARED_RW } else { mmu::PROT_GPU_FW_SHARED_RW },
mmu::PROT_FW_SHARED_RW,
CpuMap::WriteCombined,
)?;
let low = object.alias_in(
Expand Down Expand Up @@ -181,14 +181,19 @@ impl Graph {
mcache: bool,
) -> Result<Self> {
let page = mmu::UAT_PGSZ as u64;
let prot = mmu::PROT_GPU_FW_SHARED_RW;
// The kernel's mappings of the queue's records sit in the upper half, which every
// execution context includes: only the firmware reaches them there. The GPU reaches the
// preemption buffer and usage page through the aliases a binding maps into its VM.
let prot = mmu::PROT_FW_SHARED_RW;
// The kernel lower VM is context 0's alone.
let lower = mmu::PROT_GPU_FW_SHARED_RW;
let cpu = CpuMap::WriteCombined;
let ring = DescriptorRing::new(alloc, objects)?;
let preempt = alloc.kernel(0x4000, page, prot, cpu)?;
let usage = alloc.kernel(mmu::UAT_PGSZ, page, prot, cpu)?;
let operand = alloc.lower(operand_state.size, page, prot, cpu)?;
let operand = alloc.lower(operand_state.size, page, lower, cpu)?;
// The M5 support page is firmware-only; the GPU has no access to it.
let support_prot = if m5 { mmu::PROT_FW_SHARED_RW } else { prot };
let support_prot = if m5 { mmu::PROT_FW_SHARED_RW } else { mmu::PROT_GPU_FW_SHARED_RW };
let mut support = alloc.kernel(if m5 { mmu::UAT_PGSZ } else { 0xc000 }, page, support_prot, cpu)?;
if !m5 {
let support_va = support.gpu_va();
Expand Down Expand Up @@ -231,12 +236,13 @@ impl Graph {
graph.write(0, QueueRecord::new(&record))?;
}
let (context_low, context_high) = if m5 { (None, None) } else {
(Some(alloc.lower(CONTEXT_SIZE, page, prot, cpu)?),
(Some(alloc.lower(CONTEXT_SIZE, page, lower, cpu)?),
Some(alloc.kernel(CONTEXT_SIZE, page, prot, cpu)?))
};
let records = alloc.kernel(RECORD_SLOTS * RECORD_STRIDE, page, prot, cpu)?;
let m5_timestamps = if m5 {
Some(Arc::new(alloc.kernel(RECORD_SLOTS * 16, page, prot, cpu)?, GFP_KERNEL)?)
Some(Arc::new(alloc.kernel(RECORD_SLOTS * 16, page, mmu::PROT_GPU_FW_SHARED_RW, cpu)?,
GFP_KERNEL)?)
} else { None };
let cached_records = objects.allocate(
alloc,
Expand Down
9 changes: 5 additions & 4 deletions drivers/gpu/drm/asahi/g17/queue/render/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,22 @@ impl Graph {
qids: [u8; 2],
pointers: fw::variant::PointerLayout,
) -> Result<Self> {
let prot = mmu::PROT_GPU_FW_SHARED_RW;
// The kernel's mappings of a pair's command storage and queue records sit in the upper
// half, which every execution context includes: only the firmware reaches them there.
// The GPU reads command storage only through the read-only aliases below.
let prot = mmu::PROT_FW_SHARED_RW;
let m5 = alloc.uat.is_m5();
// M5 selects cached firmware attributes at initial mapping creation;
// write-combined CPU stores also support the uncached capacity fallback.
let cpu = if m5 { CpuMap::WriteCombined } else { CpuMap::WriteBack };
let bytes = if m5 { RECORDS * fw::m5::render_assembly::COMMAND_STORAGE_BYTES }
else { TA_BYTES + FRAGMENT_BYTES };
// The GPU reads command storage only through the read-only aliases below. On M5 the
// kernel mapping, in the upper half every execution context includes, is firmware-only.
let descriptors = pool.allocate(
alloc,
Family::Descriptor,
bytes,
bytes,
if m5 { mmu::PROT_FW_SHARED_RW } else { prot },
prot,
cpu,
)?;
let ta = Aliases::new(&descriptors, alloc, context.vm(),
Expand Down
Loading