@@ -35,6 +35,7 @@
#include <drm/drm_file.h>
#include "virtgpu_drv.h"
+#include "virtgpu_gem.h"
static struct drm_driver driver;
@@ -216,40 +216,6 @@ void virtio_gpu_deinit(struct drm_device *dev);
int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file);
void virtio_gpu_driver_postclose(struct drm_device *dev, struct drm_file *file);
-/* virtio_gem.c */
-void virtio_gpu_gem_free_object(struct drm_gem_object *gem_obj);
-int virtio_gpu_gem_init(struct virtio_gpu_device *vgdev);
-void virtio_gpu_gem_fini(struct virtio_gpu_device *vgdev);
-int virtio_gpu_gem_create(struct drm_file *file,
- struct drm_device *dev,
- struct virtio_gpu_object_params *params,
- struct drm_gem_object **obj_p,
- uint32_t *handle_p);
-int virtio_gpu_gem_object_open(struct drm_gem_object *obj,
- struct drm_file *file);
-void virtio_gpu_gem_object_close(struct drm_gem_object *obj,
- struct drm_file *file);
-int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
- struct drm_device *dev,
- struct drm_mode_create_dumb *args);
-int virtio_gpu_mode_dumb_mmap(struct drm_file *file_priv,
- struct drm_device *dev,
- uint32_t handle, uint64_t *offset_p);
-
-struct virtio_gpu_object_array *virtio_gpu_array_alloc(u32 nents);
-struct virtio_gpu_object_array*
-virtio_gpu_array_from_handles(struct drm_file *drm_file, u32 *handles, u32 nents);
-void virtio_gpu_array_add_obj(struct virtio_gpu_object_array *objs,
- struct drm_gem_object *obj);
-int virtio_gpu_array_lock_resv(struct virtio_gpu_object_array *objs);
-void virtio_gpu_array_unlock_resv(struct virtio_gpu_object_array *objs);
-void virtio_gpu_array_add_fence(struct virtio_gpu_object_array *objs,
- struct dma_fence *fence);
-void virtio_gpu_array_put_free(struct virtio_gpu_object_array *objs);
-void virtio_gpu_array_put_free_delayed(struct virtio_gpu_device *vgdev,
- struct virtio_gpu_object_array *objs);
-void virtio_gpu_array_put_free_work(struct work_struct *work);
-
/* virtio_gpu_display.c */
void virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev);
void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev);
@@ -27,6 +27,7 @@
#include <drm/drm_fourcc.h>
#include "virtgpu_drv.h"
+#include "virtgpu_gem.h"
#include "virtgpu_vq.h"
int virtio_gpu_gem_create(struct drm_file *file,
new file mode 100644
@@ -0,0 +1,52 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef VIRTIO_GEM_H
+#define VIRTIO_GEM_H
+
+#include <linux/types.h>
+
+struct dma_fence;
+struct drm_device;
+struct drm_file;
+struct drm_gem_object;
+
+struct virtio_gpu_device;
+struct virtio_gpu_object_array;
+struct virtio_gpu_object_params;
+
+struct work_struct;
+
+void virtio_gpu_gem_free_object(struct drm_gem_object *gem_obj);
+int virtio_gpu_gem_init(struct virtio_gpu_device *vgdev);
+void virtio_gpu_gem_fini(struct virtio_gpu_device *vgdev);
+int virtio_gpu_gem_create(struct drm_file *file,
+ struct drm_device *dev,
+ struct virtio_gpu_object_params *params,
+ struct drm_gem_object **obj_p,
+ uint32_t *handle_p);
+int virtio_gpu_gem_object_open(struct drm_gem_object *obj,
+ struct drm_file *file);
+void virtio_gpu_gem_object_close(struct drm_gem_object *obj,
+ struct drm_file *file);
+int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
+ struct drm_device *dev,
+ struct drm_mode_create_dumb *args);
+int virtio_gpu_mode_dumb_mmap(struct drm_file *file_priv,
+ struct drm_device *dev,
+ uint32_t handle, uint64_t *offset_p);
+
+struct virtio_gpu_object_array *virtio_gpu_array_alloc(u32 nents);
+struct virtio_gpu_object_array*
+virtio_gpu_array_from_handles(struct drm_file *drm_file, u32 *handles,
+ u32 nents);
+void virtio_gpu_array_add_obj(struct virtio_gpu_object_array *objs,
+ struct drm_gem_object *obj);
+int virtio_gpu_array_lock_resv(struct virtio_gpu_object_array *objs);
+void virtio_gpu_array_unlock_resv(struct virtio_gpu_object_array *objs);
+void virtio_gpu_array_add_fence(struct virtio_gpu_object_array *objs,
+ struct dma_fence *fence);
+void virtio_gpu_array_put_free(struct virtio_gpu_object_array *objs);
+void virtio_gpu_array_put_free_delayed(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_object_array *objs);
+void virtio_gpu_array_put_free_work(struct work_struct *work);
+
+#endif /* VIRTGPU_GEM_H */
@@ -32,6 +32,7 @@
#include <drm/virtgpu_drm.h>
#include "virtgpu_drv.h"
+#include "virtgpu_gem.h"
#include "virtgpu_vq.h"
static int virtio_gpu_map_ioctl(struct drm_device *dev, void *data,
@@ -29,6 +29,7 @@
#include <drm/drm_file.h>
#include "virtgpu_drv.h"
+#include "virtgpu_gem.h"
#include "virtgpu_vq.h"
static void virtio_gpu_config_changed_work_func(struct work_struct *work)
@@ -26,6 +26,7 @@
#include <linux/moduleparam.h>
#include "virtgpu_drv.h"
+#include "virtgpu_gem.h"
#include "virtgpu_vq.h"
static int virtio_gpu_virglrenderer_workaround = 1;
@@ -28,6 +28,7 @@
#include <drm/drm_plane_helper.h>
#include "virtgpu_drv.h"
+#include "virtgpu_gem.h"
#include "virtgpu_vq.h"
static const uint32_t virtio_gpu_formats[] = {
@@ -32,6 +32,7 @@
#include <linux/virtio_ring.h>
#include "virtgpu_drv.h"
+#include "virtgpu_gem.h"
#include "virtgpu_trace.h"
#include "virtgpu_vq.h"
virtgpu_drv.h is getting very big, let's try to split it into smaller header files. This time, GEM functions. Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org> --- drivers/gpu/drm/virtio/virtgpu_drv.c | 1 + drivers/gpu/drm/virtio/virtgpu_drv.h | 34 ---------------- drivers/gpu/drm/virtio/virtgpu_gem.c | 1 + drivers/gpu/drm/virtio/virtgpu_gem.h | 52 +++++++++++++++++++++++++ drivers/gpu/drm/virtio/virtgpu_ioctl.c | 1 + drivers/gpu/drm/virtio/virtgpu_kms.c | 1 + drivers/gpu/drm/virtio/virtgpu_object.c | 1 + drivers/gpu/drm/virtio/virtgpu_plane.c | 1 + drivers/gpu/drm/virtio/virtgpu_vq.c | 1 + 9 files changed, 59 insertions(+), 34 deletions(-) create mode 100644 drivers/gpu/drm/virtio/virtgpu_gem.h