Skip to content
Open
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
14 changes: 8 additions & 6 deletions drivers/gpu/drm/asahi/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,13 @@ impl SyncItem {
in_count: u32,
out_count: u32,
allow_cumulative: bool,
) -> Result<KVec<SyncItem>> {
) -> Result<KVVec<SyncItem>> {
let count = in_count.checked_add(out_count).ok_or(EOVERFLOW)?;

const STRIDE: usize = core::mem::size_of::<uapi::drm_asahi_sync>();
let size = STRIDE.checked_mul(count as usize).ok_or(EOVERFLOW)?;
let mut vec = KVec::with_capacity(count as usize, GFP_KERNEL)?;
// Userspace sets the count, so the syncs need no contiguous pages and are charged to it.
let mut vec = KVVec::with_capacity(count as usize, GFP_KERNEL_ACCOUNT)?;
let mut anchor = None;

// Read each record once so validation and use see the same retained bytes.
Expand All @@ -320,7 +321,7 @@ impl SyncItem {
}
vec.push(
Self::parse_one(file, sync, i >= in_count, allow_cumulative)?,
GFP_KERNEL,
GFP_KERNEL_ACCOUNT,
)?;
}
if let Some(anchor) = anchor {
Expand Down Expand Up @@ -1822,14 +1823,15 @@ impl File {
data.queue_id,
id
);
let mut vec = KVec::new();
let copy_commands = |bytes: &mut KVec<u8>| {
// As long as userspace makes it: no contiguous pages, and charged to the caller.
let mut vec = KVVec::new();
let copy_commands = |bytes: &mut KVVec<u8>| {
UserSlice::new(
UserPtr::from_addr(data.cmdbuf as usize),
data.cmdbuf_size as usize,
)
.reader()
.read_all(bytes, GFP_KERNEL)
.read_all(bytes, GFP_KERNEL_ACCOUNT)
};
let guarded = gpu.as_any().is::<crate::g17::Gpu>() || gpu.tracked_submission();
// Once G17 output syncobjs are resolved, its queue must install a fence
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/asahi/g15/fence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ fn install(outputs: impl Iterator<Item = SyncItem>, fence: &Fence) {
/// accepted, a signalled error fence when the submission is refused (the shared `file.rs`
/// contract of `tracked_submission`).
pub(crate) struct Syncs {
syncs: KVec<SyncItem>,
syncs: KVVec<SyncItem>,
input_count: usize,
}

impl Syncs {
pub(crate) fn new(syncs: KVec<SyncItem>, input_count: usize) -> Self {
pub(crate) fn new(syncs: KVVec<SyncItem>, input_count: usize) -> Self {
Self { syncs, input_count }
}

Expand Down
4 changes: 4 additions & 0 deletions drivers/gpu/drm/asahi/g15/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,10 @@ impl Firmware {
}

impl gpu::Gpu for Gpu {
fn max_cmdbuf_size(&self) -> usize {
command::MAX_CMDBUF
}

fn stats_snapshot(&self) -> Option<Arc<crate::stats::StatsSnapshot>> {
None
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/asahi/g15/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl crate::queue::Queue for Queue {
&mut self,
_reg_data: &crate::driver::AsahiRegData<'_>,
id: u64,
syncs: KVec<file::SyncItem>,
syncs: KVVec<file::SyncItem>,
in_sync_count: usize,
cmdbuf_raw: &[u8],
objects: Pin<&xarray::XArray<KBox<file::Object>>>,
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/asahi/g16/fence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ fn install(outputs: impl Iterator<Item = SyncItem>, fence: &Fence) {
/// accepted, a signalled error fence when the submission is refused (the shared `file.rs`
/// contract of `tracked_submission`).
pub(crate) struct Syncs {
syncs: KVec<SyncItem>,
syncs: KVVec<SyncItem>,
input_count: usize,
}

impl Syncs {
pub(crate) fn new(syncs: KVec<SyncItem>, input_count: usize) -> Self {
pub(crate) fn new(syncs: KVVec<SyncItem>, input_count: usize) -> Self {
Self { syncs, input_count }
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/asahi/g16/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl crate::queue::Queue for Queue {
&mut self,
_reg_data: &crate::driver::AsahiRegData<'_>,
id: u64,
syncs: KVec<file::SyncItem>,
syncs: KVVec<file::SyncItem>,
in_sync_count: usize,
cmdbuf_raw: &[u8],
objects: Pin<&xarray::XArray<KBox<file::Object>>>,
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/asahi/g17/fence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ fn install(outputs: impl Iterator<Item = SyncItem>, fence: &Fence) {

pub(crate) struct Outputs {
fallback: Option<UniqueFence<ExportFence>>,
syncs: KVec<SyncItem>,
syncs: KVVec<SyncItem>,
input_count: usize,
submission: Option<Aggregate>,
result: Result,
Expand All @@ -475,7 +475,7 @@ pub(crate) struct Outputs {
impl Outputs {
pub(crate) fn new(
contexts: &FenceContexts,
mut syncs: KVec<SyncItem>,
mut syncs: KVVec<SyncItem>,
input_count: usize,
allocation_failure: &Fence,
) -> Result<Self> {
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/asahi/g17/queue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ impl<B: Backend> crate::queue::Queue for Queue<B> {
&mut self,
_reg_data: &crate::driver::AsahiRegData<'_>,
id: u64,
syncs: KVec<file::SyncItem>,
syncs: KVVec<file::SyncItem>,
input_count: usize,
bytes: &[u8],
objects: Pin<&xarray::XArray<KBox<file::Object>>>,
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/asahi/g18/drm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl FenceOps for G18SubmissionFence {
/// Dropped unaccepted, it signals the fence with `result` and installs it.
struct OutputPublication {
fence: Option<UserFence<G18SubmissionFence>>,
syncs: KVec<file::SyncItem>,
syncs: KVVec<file::SyncItem>,
input_count: usize,
result: Result,
}
Expand Down Expand Up @@ -707,7 +707,7 @@ impl queue::Queue for G18Queue {
/// userspace nothing to wait on (Mesa's G18G split compute prepass reads
/// GPU results after such submissions).
fn submit(&mut self, _reg_data: &AsahiRegData<'_>, submission_id: u64,
syncs: KVec<file::SyncItem>,
syncs: KVVec<file::SyncItem>,
in_sync_count: usize, cmdbuf_raw: &[u8],
objects: Pin<&xarray::XArray<KBox<file::Object>>>) -> Result {
if in_sync_count > syncs.len() { return Err(EINVAL); }
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/asahi/m3/m3_submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl Queue {
}
}
impl queue::Queue for Queue {
fn submit(&mut self,_reg_data:&crate::driver::AsahiRegData<'_>,_id:u64,mut syncs:KVec<file::SyncItem>,in_sync_count:usize,
fn submit(&mut self,_reg_data:&crate::driver::AsahiRegData<'_>,_id:u64,mut syncs:KVVec<file::SyncItem>,in_sync_count:usize,
raw:&[u8],objects:Pin<&xarray::XArray<KBox<file::Object>>>)->Result {
let vm_job=self.vm.retain_job()?;
let mut parser=agx_uapi::UapiCommandParser::new(raw);let mut commands=KVec::new();let mut timestamps=KVec::new();let mut flushes=KVec::new();let mut visibility=KVec::new();let mut render_attachments=KVec::new();
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/asahi/m5/drm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl FenceOps for M5SubmissionFence {
/// allocation failure after userspace has already supplied its wait targets.
struct OutputPublication {
fence: UserFence<M5SubmissionFence>,
syncs: KVec<file::SyncItem>,
syncs: KVVec<file::SyncItem>,
input_count: usize,
result: Result,
}
Expand Down Expand Up @@ -237,7 +237,7 @@ struct M5Queue {

impl queue::Queue for M5Queue {
fn submit(&mut self, _reg_data: &AsahiRegData<'_>, _submission_id: u64,
syncs: KVec<file::SyncItem>,
syncs: KVVec<file::SyncItem>,
in_sync_count: usize, cmdbuf_raw: &[u8],
_objects: Pin<&xarray::XArray<KBox<file::Object>>>) -> Result {
if in_sync_count > syncs.len() { return Err(EINVAL); }
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/asahi/queue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ pub(crate) trait Queue: Send + Sync {
&mut self,
reg_data: &AsahiRegData<'_>,
id: u64,
syncs: KVec<file::SyncItem>,
syncs: KVVec<file::SyncItem>,
in_sync_count: usize,
cmdbuf_raw: &[u8],
objects: Pin<&xarray::XArray<KBox<file::Object>>>,
Expand Down Expand Up @@ -1008,7 +1008,7 @@ impl Queue for Queue::ver {
&mut self,
reg_data: &AsahiRegData<'drm>,
id: u64,
mut syncs: KVec<file::SyncItem>,
mut syncs: KVVec<file::SyncItem>,
in_sync_count: usize,
cmdbuf_raw: &[u8],
objects: Pin<&xarray::XArray<KBox<file::Object>>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#![allow(dead_code,unused_variables)]
use std::pin::Pin;use std::sync::atomic::{AtomicU32,Ordering};
type Result<T=()> = std::result::Result<T,i32>;const ERESTARTSYS:i32=512;const EBUSY:i32=16;
type KVec<T>=Vec<T>;type KBox<T>=Box<T>;
type KVec<T>=Vec<T>;type KVVec<T>=Vec<T>;type KBox<T>=Box<T>;
mod xarray{pub struct XArray<T>(pub T);}
mod file{pub struct SyncItem;pub struct Object;}
mod driver{pub struct AsahiRegData<'a>(pub &'a ());}
Expand Down
Loading