[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240411153126.16201-137-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:14:36 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 136/437] drm: switch drm_read() to be iterator based
First step of converting the GPU drivers to using read/write iterators,
convert the common file read helper to be iter based.
Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +-
drivers/gpu/drm/drm_file.c | 22 ++++++++++------------
drivers/gpu/drm/gma500/psb_drv.c | 2 +-
drivers/gpu/drm/i915/i915_driver.c | 2 +-
drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +-
drivers/gpu/drm/radeon/radeon_drv.c | 2 +-
drivers/gpu/drm/tegra/drm.c | 2 +-
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +-
drivers/gpu/drm/xe/xe_device.c | 2 +-
include/drm/drm_accel.h | 2 +-
include/drm/drm_file.h | 3 +--
include/drm/drm_gem.h | 2 +-
include/drm/drm_gem_dma_helper.h | 2 +-
13 files changed, 22 insertions(+), 25 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 80b9642f2bc4..d2369e852702 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2863,7 +2863,7 @@ static const struct file_operations amdgpu_driver_kms_fops = {
.unlocked_ioctl = amdgpu_drm_ioctl,
.mmap = drm_gem_mmap,
.poll = drm_poll,
- .read = drm_read,
+ .read_iter = drm_read,
#ifdef CONFIG_COMPAT
.compat_ioctl = amdgpu_kms_compat_ioctl,
#endif
diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index 638ffa4444f5..c5965b5a1afc 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -110,7 +110,7 @@ bool drm_dev_needs_global_mutex(struct drm_device *dev)
* .unlocked_ioctl = drm_ioctl,
* .compat_ioctl = drm_compat_ioctl, // NULL if CONFIG_COMPAT=n
* .poll = drm_poll,
- * .read = drm_read,
+ * .read_iter = drm_read,
* .llseek = no_llseek,
* .mmap = drm_gem_mmap,
* };
@@ -515,18 +515,16 @@ EXPORT_SYMBOL(drm_release_noglobal);
/**
* drm_read - read method for DRM file
- * @filp: file pointer
- * @buffer: userspace destination pointer for the read
- * @count: count in bytes to read
- * @offset: offset to read
+ * @iocb: metadata for IO
+ * @to: userspace destination pointer for the read
*
* This function must be used by drivers as their &file_operations.read
* method if they use DRM events for asynchronous signalling to userspace.
* Since events are used by the KMS API for vblank and page flip completion this
* means all modern display drivers must use it.
*
- * @offset is ignored, DRM events are read like a pipe. Polling support is
- * provided by drm_poll().
+ * offset in @iocb is ignored, DRM events are read like a pipe. Polling support
+ * is provided by drm_poll().
*
* This function will only ever read a full event. Therefore userspace must
* supply a big enough buffer to fit any event to ensure forward progress. Since
@@ -538,11 +536,11 @@ EXPORT_SYMBOL(drm_release_noglobal);
* Number of bytes read (always aligned to full events, and can be 0) or a
* negative error code on failure.
*/
-ssize_t drm_read(struct file *filp, char __user *buffer,
- size_t count, loff_t *offset)
+ssize_t drm_read(struct kiocb *iocb, struct iov_iter *to)
{
- struct drm_file *file_priv = filp->private_data;
+ struct drm_file *file_priv = iocb->ki_filp->private_data;
struct drm_device *dev = file_priv->minor->dev;
+ size_t count = iov_iter_count(to);
ssize_t ret;
ret = mutex_lock_interruptible(&file_priv->event_read_lock);
@@ -565,7 +563,7 @@ ssize_t drm_read(struct file *filp, char __user *buffer,
if (ret)
break;
- if (filp->f_flags & O_NONBLOCK) {
+ if (iocb->ki_filp->f_flags & O_NONBLOCK) {
ret = -EAGAIN;
break;
}
@@ -591,7 +589,7 @@ ssize_t drm_read(struct file *filp, char __user *buffer,
break;
}
- if (copy_to_user(buffer + ret, e->event, length)) {
+ if (!copy_to_iter_full(e->event, length, to)) {
if (ret == 0)
ret = -EFAULT;
goto put_back_event;
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 8b64f61ffaf9..7489d64bea98 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -497,7 +497,7 @@ static const struct file_operations psb_gem_fops = {
.compat_ioctl = drm_compat_ioctl,
.mmap = drm_gem_mmap,
.poll = drm_poll,
- .read = drm_read,
+ .read_iter = drm_read,
};
static const struct drm_driver driver = {
diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index 4b9233c07a22..a8328ee685e8 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -1729,7 +1729,7 @@ static const struct file_operations i915_driver_fops = {
.unlocked_ioctl = drm_ioctl,
.mmap = i915_gem_mmap,
.poll = drm_poll,
- .read = drm_read,
+ .read_iter = drm_read,
.compat_ioctl = i915_ioc32_compat_ioctl,
.llseek = noop_llseek,
#ifdef CONFIG_PROC_FS
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index a947e1d5f309..6b626d62781c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -1269,7 +1269,7 @@ nouveau_driver_fops = {
.unlocked_ioctl = nouveau_drm_ioctl,
.mmap = drm_gem_mmap,
.poll = drm_poll,
- .read = drm_read,
+ .read_iter = drm_read,
#if defined(CONFIG_COMPAT)
.compat_ioctl = nouveau_compat_ioctl,
#endif
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 7bf08164140e..7011ef3475a7 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -516,7 +516,7 @@ static const struct file_operations radeon_driver_kms_fops = {
.unlocked_ioctl = radeon_drm_ioctl,
.mmap = drm_gem_mmap,
.poll = drm_poll,
- .read = drm_read,
+ .read_iter = drm_read,
#ifdef CONFIG_COMPAT
.compat_ioctl = radeon_kms_compat_ioctl,
#endif
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 03d1c76aec2d..f455aa8339a3 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -798,7 +798,7 @@ static const struct file_operations tegra_drm_fops = {
.unlocked_ioctl = drm_ioctl,
.mmap = tegra_drm_mmap,
.poll = drm_poll,
- .read = drm_read,
+ .read_iter = drm_read,
.compat_ioctl = drm_compat_ioctl,
.llseek = noop_llseek,
};
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index c7d90f96d16a..fb68d49cff51 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1605,7 +1605,7 @@ static const struct file_operations vmwgfx_driver_fops = {
.unlocked_ioctl = vmw_unlocked_ioctl,
.mmap = drm_gem_mmap,
.poll = drm_poll,
- .read = drm_read,
+ .read_iter = drm_read,
#if defined(CONFIG_COMPAT)
.compat_ioctl = vmw_compat_ioctl,
#endif
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index d32ff3857e65..98ae007febe9 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -143,7 +143,7 @@ static const struct file_operations xe_driver_fops = {
.unlocked_ioctl = drm_ioctl,
.mmap = drm_gem_mmap,
.poll = drm_poll,
- .read = drm_read,
+ .read_iter = drm_read,
.compat_ioctl = drm_compat_ioctl,
.llseek = noop_llseek,
#ifdef CONFIG_PROC_FS
diff --git a/include/drm/drm_accel.h b/include/drm/drm_accel.h
index f4d3784b1dce..c757e0b1db46 100644
--- a/include/drm/drm_accel.h
+++ b/include/drm/drm_accel.h
@@ -26,7 +26,7 @@
.unlocked_ioctl = drm_ioctl,\
.compat_ioctl = drm_compat_ioctl,\
.poll = drm_poll,\
- .read = drm_read,\
+ .read_iter = drm_read,\
.llseek = noop_llseek, \
.mmap = drm_gem_mmap
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index ab230d3af138..19917ff0090c 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -436,8 +436,7 @@ void drm_file_update_pid(struct drm_file *);
int drm_open(struct inode *inode, struct file *filp);
int drm_open_helper(struct file *filp, struct drm_minor *minor);
-ssize_t drm_read(struct file *filp, char __user *buffer,
- size_t count, loff_t *offset);
+ssize_t drm_read(struct kiocb *iocb, struct iov_iter *to);
int drm_release(struct inode *inode, struct file *filp);
int drm_release_noglobal(struct inode *inode, struct file *filp);
__poll_t drm_poll(struct file *filp, struct poll_table_struct *wait);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index 2ebec3984cd4..29fe86ce8266 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -445,7 +445,7 @@ struct drm_gem_object {
.unlocked_ioctl = drm_ioctl,\
.compat_ioctl = drm_compat_ioctl,\
.poll = drm_poll,\
- .read = drm_read,\
+ .read_iter = drm_read,\
.llseek = noop_llseek,\
.mmap = drm_gem_mmap
diff --git a/include/drm/drm_gem_dma_helper.h b/include/drm/drm_gem_dma_helper.h
index a827bde494f6..907acd2b89fa 100644
--- a/include/drm/drm_gem_dma_helper.h
+++ b/include/drm/drm_gem_dma_helper.h
@@ -264,7 +264,7 @@ unsigned long drm_gem_dma_get_unmapped_area(struct file *filp,
.unlocked_ioctl = drm_ioctl,\
.compat_ioctl = drm_compat_ioctl,\
.poll = drm_poll,\
- .read = drm_read,\
+ .read_iter = drm_read,\
.llseek = noop_llseek,\
.mmap = drm_gem_mmap,\
DRM_GEM_DMA_UNMAPPED_AREA_FOPS \
--
2.43.0
Powered by blists - more mailing lists