drm/v3d: Move wait BO ioctl to the v3d_bo file
authorMelissa Wen <mwen@igalia.com>
Thu, 30 Nov 2023 16:40:25 +0000 (13:40 -0300)
committerMaíra Canal <mcanal@igalia.com>
Fri, 1 Dec 2023 12:33:56 +0000 (09:33 -0300)
IOCTLs related to BO operations reside on the file v3d_bo.c. The wait BO
ioctl is the only IOCTL regarding BOs that is placed in a different file.
So, move it to the v3d_bo.c file.

Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231130164420.932823-4-mcanal@igalia.com
drivers/gpu/drm/v3d/v3d_bo.c
drivers/gpu/drm/v3d/v3d_drv.h
drivers/gpu/drm/v3d/v3d_gem.c

index 8b3229a37c6df2c4adbf46eaacb133373568df6b..357a0da7e16aaedb0f77aadfddc6cf2f4184eecd 100644 (file)
@@ -233,3 +233,36 @@ int v3d_get_bo_offset_ioctl(struct drm_device *dev, void *data,
        drm_gem_object_put(gem_obj);
        return 0;
 }
+
+int
+v3d_wait_bo_ioctl(struct drm_device *dev, void *data,
+                 struct drm_file *file_priv)
+{
+       int ret;
+       struct drm_v3d_wait_bo *args = data;
+       ktime_t start = ktime_get();
+       u64 delta_ns;
+       unsigned long timeout_jiffies =
+               nsecs_to_jiffies_timeout(args->timeout_ns);
+
+       if (args->pad != 0)
+               return -EINVAL;
+
+       ret = drm_gem_dma_resv_wait(file_priv, args->handle,
+                                   true, timeout_jiffies);
+
+       /* Decrement the user's timeout, in case we got interrupted
+        * such that the ioctl will be restarted.
+        */
+       delta_ns = ktime_to_ns(ktime_sub(ktime_get(), start));
+       if (delta_ns < args->timeout_ns)
+               args->timeout_ns -= delta_ns;
+       else
+               args->timeout_ns = 0;
+
+       /* Asked to wait beyond the jiffie/scheduler precision? */
+       if (ret == -ETIME && args->timeout_ns)
+               ret = -EAGAIN;
+
+       return ret;
+}
index d8b392494eba54f9b28c156dffb933b43cfb1de3..fc04372d5cbd3de3dc065cbb2afc207a97a2b697 100644 (file)
@@ -385,6 +385,8 @@ int v3d_mmap_bo_ioctl(struct drm_device *dev, void *data,
                      struct drm_file *file_priv);
 int v3d_get_bo_offset_ioctl(struct drm_device *dev, void *data,
                            struct drm_file *file_priv);
+int v3d_wait_bo_ioctl(struct drm_device *dev, void *data,
+                     struct drm_file *file_priv);
 struct drm_gem_object *v3d_prime_import_sg_table(struct drm_device *dev,
                                                 struct dma_buf_attachment *attach,
                                                 struct sg_table *sgt);
@@ -405,8 +407,6 @@ int v3d_submit_tfu_ioctl(struct drm_device *dev, void *data,
                         struct drm_file *file_priv);
 int v3d_submit_csd_ioctl(struct drm_device *dev, void *data,
                         struct drm_file *file_priv);
-int v3d_wait_bo_ioctl(struct drm_device *dev, void *data,
-                     struct drm_file *file_priv);
 void v3d_job_cleanup(struct v3d_job *job);
 void v3d_job_put(struct v3d_job *job);
 void v3d_reset(struct v3d_dev *v3d);
index 9d2ac23c29e33e9283241ea96e3fa8f47a542fce..26f62a48d2260a690d59528634ec5988a3c4d8a0 100644 (file)
@@ -363,39 +363,6 @@ void v3d_job_put(struct v3d_job *job)
        kref_put(&job->refcount, job->free);
 }
 
-int
-v3d_wait_bo_ioctl(struct drm_device *dev, void *data,
-                 struct drm_file *file_priv)
-{
-       int ret;
-       struct drm_v3d_wait_bo *args = data;
-       ktime_t start = ktime_get();
-       u64 delta_ns;
-       unsigned long timeout_jiffies =
-               nsecs_to_jiffies_timeout(args->timeout_ns);
-
-       if (args->pad != 0)
-               return -EINVAL;
-
-       ret = drm_gem_dma_resv_wait(file_priv, args->handle,
-                                   true, timeout_jiffies);
-
-       /* Decrement the user's timeout, in case we got interrupted
-        * such that the ioctl will be restarted.
-        */
-       delta_ns = ktime_to_ns(ktime_sub(ktime_get(), start));
-       if (delta_ns < args->timeout_ns)
-               args->timeout_ns -= delta_ns;
-       else
-               args->timeout_ns = 0;
-
-       /* Asked to wait beyond the jiffie/scheduler precision? */
-       if (ret == -ETIME && args->timeout_ns)
-               ret = -EAGAIN;
-
-       return ret;
-}
-
 static int
 v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,
             void **container, size_t size, void (*free)(struct kref *ref),