Re: [PATCH 17/24] drm/virtio: implement blob resources: implement vram object

2020-08-13 Thread kernel test robot
Hi Gurchetan,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip linus/master next-20200814]
[cannot apply to tegra-drm/drm/tegra/for-next drm/drm-next 
drm-exynos/exynos-drm-next v5.8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Gurchetan-Singh/Blob-prerequisites-blob-resources/20200814-104250
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: parisc-randconfig-s031-20200813 (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-168-g9554805c-dirty
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=parisc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


sparse warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/virtio/virtgpu_vq.c:1210:23: sparse: sparse: incorrect type 
>> in assignment (different base types) @@ expected restricted __le64 
>> [usertype] offset @@ got unsigned long long [usertype] offset @@
>> drivers/gpu/drm/virtio/virtgpu_vq.c:1210:23: sparse: expected restricted 
>> __le64 [usertype] offset
>> drivers/gpu/drm/virtio/virtgpu_vq.c:1210:23: sparse: got unsigned long 
>> long [usertype] offset

vim +1210 drivers/gpu/drm/virtio/virtgpu_vq.c

  1188  
  1189  int virtio_gpu_cmd_map(struct virtio_gpu_device *vgdev,
  1190 struct virtio_gpu_object_array *objs, uint64_t 
offset)
  1191  {
  1192  struct virtio_gpu_resource_map_blob *cmd_p;
  1193  struct virtio_gpu_object *bo = 
gem_to_virtio_gpu_obj(objs->objs[0]);
  1194  struct virtio_gpu_vbuffer *vbuf;
  1195  struct virtio_gpu_resp_map_info *resp_buf;
  1196  
  1197  resp_buf = kzalloc(sizeof(*resp_buf), GFP_KERNEL);
  1198  if (!resp_buf) {
  1199  virtio_gpu_array_put_free(objs);
  1200  return -ENOMEM;
  1201  }
  1202  
  1203  cmd_p = virtio_gpu_alloc_cmd_resp(vgdev,
  1204  virtio_gpu_cmd_resource_map_cb, , sizeof(*cmd_p),
  1205  sizeof(struct virtio_gpu_resp_map_info), resp_buf);
  1206  memset(cmd_p, 0, sizeof(*cmd_p));
  1207  
  1208  cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB);
  1209  cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
> 1210  cmd_p->offset = offset;
  1211  vbuf->objs = objs;
  1212  
  1213  virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
  1214  return 0;
  1215  }
  1216  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 17/24] drm/virtio: implement blob resources: implement vram object

2020-08-13 Thread Gurchetan Singh
From: Gerd Hoffmann 

A virtio-gpu vram object is based on range-based allocation.
No guest shmemfs backing, so we call drm_gem_private_object_init.

This is for host memory without any guest backing (atleast initially).

Signed-off-by: Gerd Hoffmann 
Co-developed-by: Gurchetan Singh 
Signed-off-by: Gurchetan Singh 
Acked-by: Tomeu Vizoso 
---
 drivers/gpu/drm/virtio/Makefile  |   2 +-
 drivers/gpu/drm/virtio/virtgpu_debugfs.c |  18 +++
 drivers/gpu/drm/virtio/virtgpu_drv.h |  23 
 drivers/gpu/drm/virtio/virtgpu_kms.c |   8 ++
 drivers/gpu/drm/virtio/virtgpu_object.c  |  12 ++
 drivers/gpu/drm/virtio/virtgpu_vq.c  |  66 +
 drivers/gpu/drm/virtio/virtgpu_vram.c| 162 +++
 7 files changed, 290 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/virtio/virtgpu_vram.c

diff --git a/drivers/gpu/drm/virtio/Makefile b/drivers/gpu/drm/virtio/Makefile
index 92aa2b3d349d..b99fa4a73b68 100644
--- a/drivers/gpu/drm/virtio/Makefile
+++ b/drivers/gpu/drm/virtio/Makefile
@@ -3,7 +3,7 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
 
-virtio-gpu-y := virtgpu_drv.o virtgpu_kms.o virtgpu_gem.o \
+virtio-gpu-y := virtgpu_drv.o virtgpu_kms.o virtgpu_gem.o virtgpu_vram.o \
virtgpu_display.o virtgpu_vq.o \
virtgpu_fence.o virtgpu_object.o virtgpu_debugfs.o virtgpu_plane.o \
virtgpu_ioctl.o virtgpu_prime.o virtgpu_trace_points.o
diff --git a/drivers/gpu/drm/virtio/virtgpu_debugfs.c 
b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
index ea27cae28ab4..f81cfbff8c0b 100644
--- a/drivers/gpu/drm/virtio/virtgpu_debugfs.c
+++ b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
@@ -71,9 +71,27 @@ virtio_gpu_debugfs_irq_info(struct seq_file *m, void *data)
return 0;
 }
 
+static int
+virtio_gpu_debugfs_host_visible_mm(struct seq_file *m, void *data)
+{
+   struct drm_info_node *node = (struct drm_info_node *) m->private;
+   struct virtio_gpu_device *vgdev = node->minor->dev->dev_private;
+   struct drm_printer p;
+
+   if (!vgdev->has_host_visible) {
+   seq_printf(m, "Host allocations not visible to guest\n");
+   return 0;
+   }
+
+   p = drm_seq_file_printer(m);
+   drm_mm_print(>host_visible_mm, );
+   return 0;
+}
+
 static struct drm_info_list virtio_gpu_debugfs_list[] = {
{ "virtio-gpu-features", virtio_gpu_features },
{ "virtio-gpu-irq-fence", virtio_gpu_debugfs_irq_info, 0, NULL },
+   { "virtio-gpu-host-visible-mm", virtio_gpu_debugfs_host_visible_mm },
 };
 
 #define VIRTIO_GPU_DEBUGFS_ENTRIES ARRAY_SIZE(virtio_gpu_debugfs_list)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h 
b/drivers/gpu/drm/virtio/virtgpu_drv.h
index 34636cb5a93c..61f57b04525b 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -99,9 +99,19 @@ struct virtio_gpu_object_shmem {
uint32_t mapped;
 };
 
+struct virtio_gpu_object_vram {
+   struct virtio_gpu_object base;
+   uint32_t map_state;
+   uint32_t map_info;
+   struct drm_mm_node vram_node;
+};
+
 #define to_virtio_gpu_shmem(virtio_gpu_object) \
container_of((virtio_gpu_object), struct virtio_gpu_object_shmem, base)
 
+#define to_virtio_gpu_vram(virtio_gpu_object) \
+   container_of((virtio_gpu_object), struct virtio_gpu_object_vram, base)
+
 struct virtio_gpu_object_array {
struct ww_acquire_ctx ticket;
struct list_head next;
@@ -222,6 +232,7 @@ struct virtio_gpu_device {
bool has_resource_blob;
bool has_host_visible;
struct virtio_shm_region host_visible_region;
+   struct drm_mm host_visible_mm;
 
struct work_struct config_changed_work;
 
@@ -234,6 +245,7 @@ struct virtio_gpu_device {
struct list_head cap_cache;
 
spinlock_t resource_export_lock;
+   spinlock_t host_visible_lock;
 };
 
 struct virtio_gpu_fpriv {
@@ -364,6 +376,12 @@ int
 virtio_gpu_cmd_resource_assign_uuid(struct virtio_gpu_device *vgdev,
struct virtio_gpu_object_array *objs);
 
+int virtio_gpu_cmd_map(struct virtio_gpu_device *vgdev,
+  struct virtio_gpu_object_array *objs, uint64_t offset);
+
+void virtio_gpu_cmd_unmap(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_object *bo);
+
 /* virtgpu_display.c */
 void virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev);
 void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev);
@@ -410,4 +428,9 @@ struct drm_gem_object *virtgpu_gem_prime_import_sg_table(
 /* virtgpu_debugfs.c */
 void virtio_gpu_debugfs_init(struct drm_minor *minor);
 
+/* virtgpu_vram.c */
+bool virtio_gpu_is_vram(struct virtio_gpu_object *bo);
+int virtio_gpu_vram_create(struct virtio_gpu_device *vgdev,
+  struct virtio_gpu_object_params *params,
+  struct