-
-
Notifications
You must be signed in to change notification settings - Fork 84
posix: implement PRIME for fd <-> handle conversion #419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
options/posix: Implement uname
d67deea
to
81b97fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this ever fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully not, but this is a sanity check to catch the (unlikely) case of duplicate handles.
core/drm/src/core.cpp
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change? Seems that this function is never called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then this function should be added in a future PR that also adds consumers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.