Skip to content
Permalink
Browse files
uio: add ioctl to uio
In TCMU, if backstore holds its own userspace buffer, for read cmd, the
data needs to be copied from userspace buffer to tcmu data area first,
and then needs to be copied from tcmu data area to scsi sgl pages again.

To solve this problem, add ioctl to uio to let userspace backstore can
copy data between scsi sgl pages and its own buffer directly.

Reviewed-by: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
  • Loading branch information
guixinliu1995 authored and intel-lab-lkp committed Feb 17, 2022
1 parent e6cb9c1 commit 8786f129af888d844bc38ed78db7a6788e45655c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
@@ -815,6 +815,24 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma)
return ret;
}

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;
long retval = 0;

mutex_lock(&idev->info_lock);
if (!idev->info || !idev->info->ioctl) {
retval = -EINVAL;
goto out;
}

retval = idev->info->ioctl(idev->info, cmd, arg);
out:
mutex_unlock(&idev->info_lock);
return retval;
}

static const struct file_operations uio_fops = {
.owner = THIS_MODULE,
.open = uio_open,
@@ -825,6 +843,10 @@ static const struct file_operations uio_fops = {
.poll = uio_poll,
.fasync = uio_fasync,
.llseek = noop_llseek,
.unlocked_ioctl = uio_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = uio_ioctl,
#endif
};

static int uio_major_init(void)
@@ -109,6 +109,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);
long (*ioctl)(struct uio_info *info, unsigned int cmd, unsigned long arg);
};

extern int __must_check

0 comments on commit 8786f12

Please sign in to comment.