5 ms·
I almost certainly have no idea what I'm talking about but Can I write a device driver using io_uring? As in talk to i2c endpoints instead of normal files?
by unlinked_dll 6y ago
I almost certainly have no idea what I'm talking about but
Can I write a device driver using io_uring? As in talk to i2c endpoints instead of normal files?
- shuss 6y agoNope. io_uring is an API that helps with asynchronous I/O.
- unlinked_dll 6y agoThat's kind of my question. I want async I/O with a device, can io_uring help?
- Aissen 6y agoIf you have a character/block device that does read/write ops, you'd probably get io_uring support for free.
- navaati 6y agoAs neighbour says, io_uring is for really high performance (as in high throughput) stuff, so… not I2C ! But you can still want async I/O with an I2C device, of course, as in you don't want to block a thread to wait on a message. And for that I believe you can still use good old select/epoll as usual on your I2C device file, and as a consequence also just use your favourite async I/O framework of the day (libevent, node.js, what have you).
- asveikau 6y agoDoes your device have a file descriptor, as is traditional in Unix? Seems like the theoretical answer should then be yes.
- Skunkleton 6y agoi2c and high performance async IO are pretty rarely overlapping requirements. I’m curious what your use case is?
- Veserv 6y agoFrom what I understand and looking at the supported opcodes [0] io_uring allows submitting certain "system calls" (and some other auxiliary operations you would normally expect in an async API) asynchronously. So, if you can interact with your device driver using those system calls, then you should be able to do so. I am personally not familiar with Linux, so I am unsure if those system calls are sufficient for normal operation, but it lacks ioctl, so it is not sufficient for total replacement in all cases. [0]: https://github.com/torvalds/linux/blob/master/include/uapi/linux/io_uring.h https://github.com/torvalds/linux/blob/master/include/uapi/l... search IORING_OP_
- sly010 6y agoI don't know the answer to that question, but if you are developing an embedded project (and especially if it's a raspberry PI) you can mmap() the hardware I2C registers to userspace memory and use them directly. You will have to basically write the I2C driver in userspace and it won't be portable but it's not that hard and it will make for very low latency I2C communication. I had to do this once for latency.
- asdfasgasdgasdg 6y agoI don't know anything either, but I assume not? With a device driver you'd be handling interrupts directly by registering an interrupt service routine and all that good stuff. io_uring is a user->kernel API because userspace doesn't handle those interrupts directly. Instead, device driver ISRs fill buffers and what have you, then kernel notifies user via io_uring that data is ready.