/* execbuffer3 idea - mmap a command buffer between userspace and kernel, ioctls are commands emitted into the buffer. stateful, we have a batch buffer we're working on. declare relocs as we go: insert a bo handle with expected offset into the buffers, buffer handles in relocs in the execbuffer bos are the offset into the ring buffer of the buffer decl. gem writes back the actual offset into the buffer decl. exec command only takes the batch buffer as argument, all other buffers have been declared previously. exec resets all buffer decls. userspace keeps its own tail pointer, parses actual buffer offsets. once a buffer is declared, we can emit relocs in the buffer, by referencing the buffer by its offset in the ring and by giving the domain. command to send drmEvent back, pwrite, pread commands, wait rendering command, madvise problem: check_aperture_space, synchronous command -> ok, all userspace gem_context: current buffers with pending domains */ /* 8/24 command split */ /* declares a buffer for use in the batch buffer, the context assigns * a running index to each declared buffer, running number is reset by * exec. userspace needs to keep track of the index on its side as it * emits declare_buffer commands. */ #define DECLARE_BUFFER 1 struct declare_buffer { u32 handle; /* handle + opcode */ u32 reserved1; /* padding */ u64 alignment; /* Required alignment in graphics aperture */ u64 offset; /* presumed offset */ }; #define RELOCATION 2 struct relocation { u32 index; /* index of declared buffer + opcode */ u32 delta; /* value to be added to the offset */ u64 offset; /* offset in the buffer */ }; /* * atomic emit: begin/commit * * we keep a running total size of all the objects declared so * far. begin remembers the userspace tail pointer and total size. * declaring buffers adds to the total. once the atomic emit is done, * we compare the new total against the aperture size. if there is * space, we're good, return 0, otherwise reset tail pointer and total * size to begin values. */