dma_buf_imports: memfd memory with no source is a copy where the device refuses its pointer
shared_memory_is_refused_without_a_working_source still expected RADV to refuse a no-copy buffer over memfd pages made with no dma-buf source. Since3f69d1af77the runtime makes that buffer over a copy of the pages (copied.rs, counted as copied_host_buffers_device_refused), as Metal makes a no-copy buffer over any page, so the test's first check failed on every RADV device (an RX 7900 XTX at0b52add1c9) before it reached the refusals it is about. The no-source case now expects the buffer on every device: on RADV a copy (HostBacking::Copied, one copied_host_buffers_device_refused), on NVIDIA and lavapipe the pointer's import (ImportedByPointer, none counted); a driver not measured has its answer printed. The rest is unchanged: a failing source keeps the device's refusal and is called once, short chunks and a chunk that is no dma-buf are misuse, and no dma-buf import is counted. Verified: to be run on the XTX and the 780M (RADV) and lavapipe; the runs go in the report. (cherry picked from commit bd6676c26bc68b87707c26f4eea15c12d87ecb60) (cherry picked from commit dadada31c211c8fccf1f909beb259937bafe3d14)
This commit is contained in:
1 parent
136c0f528d
commit
f04d9fa356
1 file changed
+29
-6
@@ -1087,11 +1087,13 @@ fn a_keep_alive_goes_after_the_imports_of_its_pages() {
|
||||
});
|
||||
}
|
||||
|
||||
/// The refusals: memfd memory with no source is refused typed where the device refuses its
|
||||
/// pointer (RADV), as before; a source that fails keeps that refusal, called once; chunks that do
|
||||
/// not cover the pages, and a chunk whose descriptor is no dma-buf (the memfd itself), are the
|
||||
/// caller's misuse (`Invalid`, `DmaBuf`), their descriptors closed. Nothing is counted for any of
|
||||
/// them. Where the device imports the pointer, each is made and no source is called.
|
||||
/// The refusals: memfd memory with no source is no refusal, made on every device: where the
|
||||
/// device refuses its pointer (RADV) a copy of its pages (`copied.rs`), counted as the device's
|
||||
/// refusal (`WorkCounts::copied_host_buffers_device_refused`), else an import of the pointer. A
|
||||
/// source that fails keeps the device's refusal, called once; chunks that do not cover the pages,
|
||||
/// and a chunk whose descriptor is no dma-buf (the memfd itself), are the caller's misuse
|
||||
/// (`Invalid`, `DmaBuf`), their descriptors closed. No dma-buf import is counted for any of them.
|
||||
/// Where the device imports the pointer, each is made and no source is called.
|
||||
#[test]
|
||||
fn shared_memory_is_refused_without_a_working_source() {
|
||||
const TEST: &str = "dma-buf refusals";
|
||||
@@ -1100,6 +1102,7 @@ fn shared_memory_is_refused_without_a_working_source() {
|
||||
let ram = Memfd::new(4 * page);
|
||||
let view = ram.view(&[(page, 2 * page)]);
|
||||
let before = dma_buf_counts(device);
|
||||
let before_copies = device.work_counts();
|
||||
let refuses = imports_dma_buf(device);
|
||||
let check =
|
||||
|what: &str, made: Result<Buffer, Error>, expected: fn(&Error) -> bool| match made {
|
||||
@@ -1118,7 +1121,27 @@ fn shared_memory_is_refused_without_a_working_source() {
|
||||
None,
|
||||
)
|
||||
};
|
||||
check("no source", plain, not_importable);
|
||||
let plain = plain.unwrap_or_else(|error| panic!("{TEST}: no source: {error:?}"));
|
||||
let copied = device.work_counts().copied_host_buffers_device_refused
|
||||
- before_copies.copied_host_buffers_device_refused;
|
||||
let backing = plain.host_backing();
|
||||
match refuses {
|
||||
Some(true) => assert_eq!(
|
||||
(backing, copied),
|
||||
(Some(HostBacking::Copied), 1),
|
||||
"{TEST}: no source: a copy, for the device's refusal"
|
||||
),
|
||||
Some(false) => assert_eq!(
|
||||
(backing, copied),
|
||||
(Some(HostBacking::ImportedByPointer), 0),
|
||||
"{TEST}: no source: the pointer's import"
|
||||
),
|
||||
None => eprintln!(
|
||||
"{TEST}: no source, on {}: {backing:?}, {copied} copied for the device's refusal",
|
||||
device.name()
|
||||
),
|
||||
}
|
||||
drop(plain);
|
||||
let calls = Arc::new(Mutex::new(0usize));
|
||||
let counted = Arc::clone(&calls);
|
||||
let failing: DmaBufSource = Arc::new(move |_| {
|
||||
|
||||
Reference in new issue
Block a user