diff --git a/drivers/gpu/drm/asahi/file.rs b/drivers/gpu/drm/asahi/file.rs index 0883715502766..dd9b502c3de86 100644 --- a/drivers/gpu/drm/asahi/file.rs +++ b/drivers/gpu/drm/asahi/file.rs @@ -290,12 +290,13 @@ impl SyncItem { in_count: u32, out_count: u32, allow_cumulative: bool, - ) -> Result> { + ) -> Result> { let count = in_count.checked_add(out_count).ok_or(EOVERFLOW)?; const STRIDE: usize = core::mem::size_of::(); 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. @@ -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 { @@ -1822,14 +1823,15 @@ impl File { data.queue_id, id ); - let mut vec = KVec::new(); - let copy_commands = |bytes: &mut KVec| { + // 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| { 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::() || gpu.tracked_submission(); // Once G17 output syncobjs are resolved, its queue must install a fence diff --git a/drivers/gpu/drm/asahi/g15/fence.rs b/drivers/gpu/drm/asahi/g15/fence.rs index bb85764228070..55a85472a794d 100644 --- a/drivers/gpu/drm/asahi/g15/fence.rs +++ b/drivers/gpu/drm/asahi/g15/fence.rs @@ -179,12 +179,12 @@ fn install(outputs: impl Iterator, 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, + syncs: KVVec, input_count: usize, } impl Syncs { - pub(crate) fn new(syncs: KVec, input_count: usize) -> Self { + pub(crate) fn new(syncs: KVVec, input_count: usize) -> Self { Self { syncs, input_count } } diff --git a/drivers/gpu/drm/asahi/g15/mod.rs b/drivers/gpu/drm/asahi/g15/mod.rs index 4cb221fb0a5df..d5cad14a50411 100644 --- a/drivers/gpu/drm/asahi/g15/mod.rs +++ b/drivers/gpu/drm/asahi/g15/mod.rs @@ -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> { None } diff --git a/drivers/gpu/drm/asahi/g15/queue.rs b/drivers/gpu/drm/asahi/g15/queue.rs index 03a8f46c8a0fc..3bdebb7995e44 100644 --- a/drivers/gpu/drm/asahi/g15/queue.rs +++ b/drivers/gpu/drm/asahi/g15/queue.rs @@ -212,7 +212,7 @@ impl crate::queue::Queue for Queue { &mut self, _reg_data: &crate::driver::AsahiRegData<'_>, id: u64, - syncs: KVec, + syncs: KVVec, in_sync_count: usize, cmdbuf_raw: &[u8], objects: Pin<&xarray::XArray>>, diff --git a/drivers/gpu/drm/asahi/g16/fence.rs b/drivers/gpu/drm/asahi/g16/fence.rs index 01ba768b313b7..6f23c870f9638 100644 --- a/drivers/gpu/drm/asahi/g16/fence.rs +++ b/drivers/gpu/drm/asahi/g16/fence.rs @@ -226,12 +226,12 @@ fn install(outputs: impl Iterator, 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, + syncs: KVVec, input_count: usize, } impl Syncs { - pub(crate) fn new(syncs: KVec, input_count: usize) -> Self { + pub(crate) fn new(syncs: KVVec, input_count: usize) -> Self { Self { syncs, input_count } } diff --git a/drivers/gpu/drm/asahi/g16/queue.rs b/drivers/gpu/drm/asahi/g16/queue.rs index 41da5b94c7c50..0d2f55dd19853 100644 --- a/drivers/gpu/drm/asahi/g16/queue.rs +++ b/drivers/gpu/drm/asahi/g16/queue.rs @@ -226,7 +226,7 @@ impl crate::queue::Queue for Queue { &mut self, _reg_data: &crate::driver::AsahiRegData<'_>, id: u64, - syncs: KVec, + syncs: KVVec, in_sync_count: usize, cmdbuf_raw: &[u8], objects: Pin<&xarray::XArray>>, diff --git a/drivers/gpu/drm/asahi/g17/fence.rs b/drivers/gpu/drm/asahi/g17/fence.rs index df98a3410a50d..29b29779c2267 100644 --- a/drivers/gpu/drm/asahi/g17/fence.rs +++ b/drivers/gpu/drm/asahi/g17/fence.rs @@ -466,7 +466,7 @@ fn install(outputs: impl Iterator, fence: &Fence) { pub(crate) struct Outputs { fallback: Option>, - syncs: KVec, + syncs: KVVec, input_count: usize, submission: Option, result: Result, @@ -475,7 +475,7 @@ pub(crate) struct Outputs { impl Outputs { pub(crate) fn new( contexts: &FenceContexts, - mut syncs: KVec, + mut syncs: KVVec, input_count: usize, allocation_failure: &Fence, ) -> Result { diff --git a/drivers/gpu/drm/asahi/g17/queue/mod.rs b/drivers/gpu/drm/asahi/g17/queue/mod.rs index d322c2710ab9e..93a39cf144dcf 100644 --- a/drivers/gpu/drm/asahi/g17/queue/mod.rs +++ b/drivers/gpu/drm/asahi/g17/queue/mod.rs @@ -547,7 +547,7 @@ impl crate::queue::Queue for Queue { &mut self, _reg_data: &crate::driver::AsahiRegData<'_>, id: u64, - syncs: KVec, + syncs: KVVec, input_count: usize, bytes: &[u8], objects: Pin<&xarray::XArray>>, diff --git a/drivers/gpu/drm/asahi/g18/drm.rs b/drivers/gpu/drm/asahi/g18/drm.rs index 14a726b24fc4c..f8c4e70574d51 100644 --- a/drivers/gpu/drm/asahi/g18/drm.rs +++ b/drivers/gpu/drm/asahi/g18/drm.rs @@ -286,7 +286,7 @@ impl FenceOps for G18SubmissionFence { /// Dropped unaccepted, it signals the fence with `result` and installs it. struct OutputPublication { fence: Option>, - syncs: KVec, + syncs: KVVec, input_count: usize, result: Result, } @@ -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, + syncs: KVVec, in_sync_count: usize, cmdbuf_raw: &[u8], objects: Pin<&xarray::XArray>>) -> Result { if in_sync_count > syncs.len() { return Err(EINVAL); } diff --git a/drivers/gpu/drm/asahi/m3/m3_submit.rs b/drivers/gpu/drm/asahi/m3/m3_submit.rs index 155bda714e9d9..8cb019e5924a4 100644 --- a/drivers/gpu/drm/asahi/m3/m3_submit.rs +++ b/drivers/gpu/drm/asahi/m3/m3_submit.rs @@ -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,in_sync_count:usize, + fn submit(&mut self,_reg_data:&crate::driver::AsahiRegData<'_>,_id:u64,mut syncs:KVVec,in_sync_count:usize, raw:&[u8],objects:Pin<&xarray::XArray>>)->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(); diff --git a/drivers/gpu/drm/asahi/m5/drm.rs b/drivers/gpu/drm/asahi/m5/drm.rs index 6ab2108d8813b..0eb1e8a8ded4b 100644 --- a/drivers/gpu/drm/asahi/m5/drm.rs +++ b/drivers/gpu/drm/asahi/m5/drm.rs @@ -196,7 +196,7 @@ impl FenceOps for M5SubmissionFence { /// allocation failure after userspace has already supplied its wait targets. struct OutputPublication { fence: UserFence, - syncs: KVec, + syncs: KVVec, input_count: usize, result: Result, } @@ -237,7 +237,7 @@ struct M5Queue { impl queue::Queue for M5Queue { fn submit(&mut self, _reg_data: &AsahiRegData<'_>, _submission_id: u64, - syncs: KVec, + syncs: KVVec, in_sync_count: usize, cmdbuf_raw: &[u8], _objects: Pin<&xarray::XArray>>) -> Result { if in_sync_count > syncs.len() { return Err(EINVAL); } diff --git a/drivers/gpu/drm/asahi/queue/mod.rs b/drivers/gpu/drm/asahi/queue/mod.rs index d80395ca3431a..81384228b37b6 100644 --- a/drivers/gpu/drm/asahi/queue/mod.rs +++ b/drivers/gpu/drm/asahi/queue/mod.rs @@ -197,7 +197,7 @@ pub(crate) trait Queue: Send + Sync { &mut self, reg_data: &AsahiRegData<'_>, id: u64, - syncs: KVec, + syncs: KVVec, in_sync_count: usize, cmdbuf_raw: &[u8], objects: Pin<&xarray::XArray>>, @@ -1008,7 +1008,7 @@ impl Queue for Queue::ver { &mut self, reg_data: &AsahiRegData<'drm>, id: u64, - mut syncs: KVec, + mut syncs: KVVec, in_sync_count: usize, cmdbuf_raw: &[u8], objects: Pin<&xarray::XArray>>, diff --git a/tools/testing/selftests/drivers/gpu/asahi-m4/test-submit-restart.py b/tools/testing/selftests/drivers/gpu/asahi-m4/test-submit-restart.py index a920eae57ee3a..72e5d9cf6f89b 100644 --- a/tools/testing/selftests/drivers/gpu/asahi-m4/test-submit-restart.py +++ b/tools/testing/selftests/drivers/gpu/asahi-m4/test-submit-restart.py @@ -11,7 +11,7 @@ #![allow(dead_code,unused_variables)] use std::pin::Pin;use std::sync::atomic::{AtomicU32,Ordering}; type Result = std::result::Result;const ERESTARTSYS:i32=512;const EBUSY:i32=16; -type KVec=Vec;type KBox=Box; +type KVec=Vec;type KVVec=Vec;type KBox=Box; mod xarray{pub struct XArray(pub T);} mod file{pub struct SyncItem;pub struct Object;} mod driver{pub struct AsahiRegData<'a>(pub &'a ());}