posix: implement PRIME for fd <-> handle conversion#419
Conversation
options/posix: Implement uname
d67deea to
81b97fd
Compare
avdgrinten
left a comment
There was a problem hiding this comment.
Architecturally, the PR is good now. Some minor issues still need to be fixed.
| auto ret = _buffers.insert({handle, bo}); | ||
| assert(ret.second); |
There was a problem hiding this comment.
Hopefully not, but this is a sanity check to catch the (unlikely) case of duplicate handles.
| void writeToState(const Assignment assignment, std::unique_ptr<AtomicState> &state) override { | ||
| state->crtc(assignment.object->id())->active = assignment.intValue; | ||
| } |
There was a problem hiding this comment.
Unrelated change? Seems that this function is never called.
There was a problem hiding this comment.
While unused now, I have some patches to drivers that make this necessary as some piece of software relied on this property.
There was a problem hiding this comment.
Then this function should be added in a future PR that also adds consumers.
avdgrinten
left a comment
There was a problem hiding this comment.
Okay, the handle-related issue is solved now, but now I don't understand why we need _primeBufferMap at all. The only place where this is read is importBufferObject(). Can't we just adjust importBufferObject() to either return the existing handle (that we get via getHandle()) or create a new handle (via createHandle()), without looking at _primeBufferMap? Or am I missing something?
The remainder of the PR now looks good to me.
Co-authored-by: Kacper Słomiński <kacper.slominski72@gmail.com>
This commit adds support for the `PRIME_HANDLE_TO_FD` and `PRIME_FD_TO_HANDLE` ioctls. These convert between a DRM handle (as used for the MAP_DUMB ioctl) and a fd, which supports the regular operations, including being sent over a UNIX socket and being `dup`ed. This is achieved by managing the shared buffers at the device level by being exported and imported. The shared buffers are identified by the credentials (a unique identifier) of the passthrough lane servicing the file operations, as fds are obviously not stable across threads.
|
Removed |
avdgrinten
left a comment
There was a problem hiding this comment.
LGTM, thank you for the PR!
This is rough code for making the PRIME ioctls work for sway. The code is not optimal and the naming is weird, but I couldn't come up with something better.
Posting as draft, as I don't expect this to survive review unchanged.
mlibc counterpart is managarm/mlibc#367.