Skip to main content

commit_with_out_fence

Function commit_with_out_fence 

Source
pub fn commit_with_out_fence<F, K>(
    device: &Device,
    flags: AtomicCommitFlags,
    build: F,
) -> Result<Option<OwnedFd>>
where F: FnOnce(&mut AtomicRequest, u64) -> Result<K>,
Expand description

Commit build’s request and collect the CRTC’s out-fence.

OUT_FENCE_PTR is unlike every other atomic property: its value is not data, it is the address of a signed 32-bit slot the kernel writes into. Getting a fence back therefore means handing the kernel a pointer that has to stay put from the moment the property is added until the ioctl returns.

The closure is why this is a function rather than a property write the caller makes itself. The slot lives on this frame’s stack for exactly the commit, build receives only the value to write, and the fence is taken afterwards — so there is no arrangement of the safe API that lets the pointer outlive what it points at, or that lets a caller commit a request carrying a stale one.

Whatever build returns is held until the commit has been issued, and dropped only then. That is where property blobs the request names belong – FB_DAMAGE_CLIPS above all: the request carries only their ids, so a blob that dropped inside the closure would be destroyed before the ioctl, and the kernel refuses a commit naming a blob it no longer has.

Returns None when the commit succeeded but the kernel left the slot alone: a TEST_ONLY never produces a fence, and neither does a driver without OUT_FENCE_PTR.

§Errors

As AtomicRequest::commit, plus whatever build returns.