uio: add support for ioctl
PATCH 1/1 uio: add support for ioctl
Allow UIO device specific driver to provide ioctl interface. This mechanism is used in DPDK uio_msi driver to allow creating VFIO like events.
drivers/uio/uio.c +15 -0
@@ -576,6 +576,20 @@ static ssize_t uio_write(struct file *fireturn retval ? retval :sizeof (s32); } +static long uio_ioctl (struct file *filep,unsigned int cmd,unsigned long arg) +{ +struct uio_listener *listener = filep->private_data; +struct uio_device *idev = listener->dev; + +if (!idev->info) +return -EIO ; + +if (!idev->info->ioctl) +return -ENOTTY ; + +return idev->info->ioctl (idev->info, cmd, arg); +} +static int uio_find_mem_index (struct vm_area_struct *vma) {struct uio_device *idev = vma->vm_private_data;
@@ -712,6 +726,7 @@ static const struct file_operations uio_ .write = uio_write, .mmap = uio_mmap, .poll = uio_poll, + .unlocked_ioctl = uio_ioctl, .fasync = uio_fasync, .llseek = noop_llseek, };
include/linux/uio_driver.h +2 -0
@@ -89,6 +89,7 @@ struct uio_device {* @mmap: mmap operation for this uio device * @open: open operation for this uio device * @release: release operation for this uio device +* @ioctl: ioctl handler * @irqcontrol: disable/enable irqs when 0/1 is written to /dev/uioX */ struct uio_info {
@@ -105,6 +106,7 @@ struct uio_info {int (*open)(struct uio_info *info,struct inode *inode);int (*release)(struct uio_info *info,struct inode *inode);int (*irqcontrol)(struct uio_info *info,s32 irq_on); +int (*ioctl)(struct uio_info *info,unsigned int cmd,unsigned long arg); }; extern int __must_check
Quoted 3 lines · Stephen Hemminger
Allow UIO device specific driver to provide ioctl interface. This mechanism is used in DPDK
uio_msidriver to allow creating VFIO like events.
I can't find that driver anywhere in the kernel tree, and there is no point adding new hooks just for out of tree code that doesn't even get tested in tree.
Quoted 9 lines · On Mon, 18 May 2015 10:36:05 -0700 Christoph Hellwig <[email protected]> wrote:
Quoted 3 lines · Stephen Hemminger
Allow UIO device specific driver to provide ioctl interface. This mechanism is used in DPDK
uio_msidriver to allow creating VFIO like events.I can't find that driver anywhere in the kernel tree, and there is no point adding new hooks just for out of tree code that doesn't even get tested in tree.
I will send that driver as soon as the DPDK folks are ready, like a couple of days from now.
Quoted 2 lines · Stephen Hemminger
I will send that driver as soon as the DPDK folks are ready, like a couple of days from now.
Then jsut send the preparation patch that isn't useful without it together with that one.