public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] uio: add ioctl to uio
@ 2022-02-17  2:29 Guixin Liu
  2022-02-17  2:29 ` [PATCH 2/2] scsi:target:tcmu: reduce once copy by using uio ioctl Guixin Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Guixin Liu @ 2022-02-17  2:29 UTC (permalink / raw)
  To: gregkh, bostroesser, martin.petersen
  Cc: linux-scsi, target-devel, linux-kernel, xiaoguang.wang, xlpang

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>
---
 drivers/uio/uio.c          | 22 ++++++++++++++++++++++
 include/linux/uio_driver.h |  1 +
 2 files changed, 23 insertions(+)

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 43afbb7..0fb85a3 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -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 int uio_mmap(struct file *filep, struct vm_area_struct *vma)
 	.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)
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 47c5962..971d172b 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -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
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-02-28 10:47 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-17  2:29 [PATCH 1/2] uio: add ioctl to uio Guixin Liu
2022-02-17  2:29 ` [PATCH 2/2] scsi:target:tcmu: reduce once copy by using uio ioctl Guixin Liu
2022-02-17  6:45   ` kernel test robot
2022-02-17  8:07   ` kernel test robot
2022-02-17 10:15   ` Greg KH
2022-02-17 11:13     ` Xiaoguang Wang
2022-02-17 12:28       ` Greg KH
2022-02-17 11:10   ` [RFC PATCH] scsi:target:tcmu: tcmu_ioctl_copy_between_sgl_and_iovec() can be static kernel test robot
2022-02-17 11:12   ` [PATCH 2/2] scsi:target:tcmu: reduce once copy by using uio ioctl kernel test robot
2022-02-21 17:09   ` Bodo Stroesser
2022-02-28  8:52     ` Xiaoguang Wang
2022-02-28 10:47       ` Greg KH
2022-02-17  6:13 ` [PATCH 1/2] uio: add ioctl to uio Greg KH
     [not found]   ` <362edb61-b8ad-495e-2346-8020355c0938@linux.alibaba.com>
2022-02-17 12:30     ` Greg KH
2022-02-17 12:30   ` Xiaoguang Wang
2022-02-17  6:55 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox