diff --git a/src/gpu/i915/mod.rs b/src/gpu/i915/mod.rs index 4792585..52866e6 100644 --- a/src/gpu/i915/mod.rs +++ b/src/gpu/i915/mod.rs @@ -58,6 +58,8 @@ impl From for GemTileInfo { } /// An owned GEM handle that will be closed when dropped +/// Scoped to a file descriptor - +/// this means that it is inherited by `fork` children and can be shared with sendfd impl GemHandle<'_> { pub fn new(node: &DrmDeviceNode, size: u64) -> Option { uapi::i915::make_gem(node.fd.as_raw_fd(), size).map(|handle| GemHandle { diff --git a/src/uapi/i915/mod.rs b/src/uapi/i915/mod.rs index b6c5911..adcc3ba 100644 --- a/src/uapi/i915/mod.rs +++ b/src/uapi/i915/mod.rs @@ -284,7 +284,7 @@ pub unsafe fn gem_offset(fd: RawFd, handle: &DrmGemHandle) -> Result 0); + for node in nodes { + let gem = i915::make_gem(node.fd.as_raw_fd(), 4096).expect("Failed to make gem"); + let offset = i915::gem_offset(node.fd.as_raw_fd(), &gem); + println!("gem: {:?}, node: {:?}, offset: {:?}", gem, node, offset); + assert!(offset.unwrap() > 0); + i915::close_gem(node.fd.as_raw_fd(), gem).expect("Failed to close gem"); + } + } +} + // TODO: Fix this test // Shared mem needs to be used to communicate the gem handle between parent and child // Test both a shared fd and separate fd