Re: [PATCH 14/24] drm/virtio: implement blob resources: probe for host visible region
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: i386-randconfig-m021-20200816 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot smatch warnings: drivers/gpu/drm/virtio/virtgpu_kms.c:227 virtio_gpu_init() error: uninitialized symbol 'ret'. # https://github.com/0day-ci/linux/commit/ded3d7b8bb13eb8599f8d410f184521214e13328 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Gurchetan-Singh/Blob-prerequisites-blob-resources/20200814-104250 git checkout ded3d7b8bb13eb8599f8d410f184521214e13328 vim +/ret +227 drivers/gpu/drm/virtio/virtgpu_kms.c 62fb7a5e10962a Gerd Hoffmann 2014-10-28 94 d516e75c71c985 Ezequiel Garcia2019-01-08 95 int virtio_gpu_init(struct drm_device *dev) dc5698e80cf724 Dave Airlie2013-09-09 96 { dc5698e80cf724 Dave Airlie2013-09-09 97 static vq_callback_t *callbacks[] = { dc5698e80cf724 Dave Airlie2013-09-09 98 virtio_gpu_ctrl_ack, virtio_gpu_cursor_ack dc5698e80cf724 Dave Airlie2013-09-09 99 }; f7ad26ff952b3c Stefan Hajnoczi2015-12-17 100 static const char * const names[] = { "control", "cursor" }; dc5698e80cf724 Dave Airlie2013-09-09 101 dc5698e80cf724 Dave Airlie2013-09-09 102 struct virtio_gpu_device *vgdev; dc5698e80cf724 Dave Airlie2013-09-09 103 /* this will expand later */ dc5698e80cf724 Dave Airlie2013-09-09 104 struct virtqueue *vqs[2]; 62fb7a5e10962a Gerd Hoffmann 2014-10-28 105 u32 num_scanouts, num_capsets; dc5698e80cf724 Dave Airlie2013-09-09 106 int ret; dc5698e80cf724 Dave Airlie2013-09-09 107 18e51064c42ca3 Daniel Vetter 2017-05-24 108 if (!virtio_has_feature(dev_to_virtio(dev->dev), VIRTIO_F_VERSION_1)) dc5698e80cf724 Dave Airlie2013-09-09 109 return -ENODEV; dc5698e80cf724 Dave Airlie2013-09-09 110 dc5698e80cf724 Dave Airlie2013-09-09 111 vgdev = kzalloc(sizeof(struct virtio_gpu_device), GFP_KERNEL); dc5698e80cf724 Dave Airlie2013-09-09 112 if (!vgdev) dc5698e80cf724 Dave Airlie2013-09-09 113 return -ENOMEM; dc5698e80cf724 Dave Airlie2013-09-09 114 dc5698e80cf724 Dave Airlie2013-09-09 115 vgdev->ddev = dev; dc5698e80cf724 Dave Airlie2013-09-09 116 dev->dev_private = vgdev; 18e51064c42ca3 Daniel Vetter 2017-05-24 117 vgdev->vdev = dev_to_virtio(dev->dev); dc5698e80cf724 Dave Airlie2013-09-09 118 vgdev->dev = dev->dev; dc5698e80cf724 Dave Airlie2013-09-09 119 dc5698e80cf724 Dave Airlie2013-09-09 120 spin_lock_init(>display_info_lock); f6e6d9eff0b4e9 David Stevens 2020-08-13 121 spin_lock_init(>resource_export_lock); 1938d1ae32fefa Matthew Wilcox 2018-09-26 122 ida_init(>ctx_id_ida); 1938d1ae32fefa Matthew Wilcox 2018-09-26 123 ida_init(>resource_ida); dc5698e80cf724 Dave Airlie2013-09-09 124 init_waitqueue_head(>resp_wq); dc5698e80cf724 Dave Airlie2013-09-09 125 virtio_gpu_init_vq(>ctrlq, virtio_gpu_dequeue_ctrl_func); dc5698e80cf724 Dave Airlie2013-09-09 126 virtio_gpu_init_vq(>cursorq, virtio_gpu_dequeue_cursor_func); dc5698e80cf724 Dave Airlie2013-09-09 127 f54d1867005c33 Chris Wilson 2016-10-25 128 vgdev->fence_drv.context = dma_fence_context_alloc(1); dc5698e80cf724 Dave Airlie2013-09-09 129 spin_lock_init(>fence_drv.lock); dc5698e80cf724 Dave Airlie2013-09-09 130 INIT_LIST_HEAD(>fence_drv.fences); 62fb7a5e10962a Gerd Hoffmann 2014-10-28 131 INIT_LIST_HEAD(>cap_cache); dc5698e80cf724 Dave Airlie2013-09-09 132 INIT_WORK(>config_changed_work, dc5698e80cf724 Dave Airlie2013-09-09 133 virtio_gpu_config_changed_work_func); dc5698e80cf724 Dave Airlie2013-09-09 134 f0c6cef7e7174b Gerd Hoffmann 2019-08-30 135 INIT_WORK(>obj_free_work, f0c6cef7e7174b Gerd Hoffmann 2019-08-30 136 virtio_gpu_array_put_free_work); f0c6cef7e7174b Gerd Hoffmann 2019-08-30 137 INIT_LIST_HEAD(>obj_free_list);
[PATCH 14/24] drm/virtio: implement blob resources: probe for host visible region
From: Gerd Hoffmann The availability of the host visible region means host 3D allocations can be directly mapped in the guest. Signed-off-by: Gerd Hoffmann Co-developed-by: Gurchetan Singh Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- drivers/gpu/drm/virtio/virtgpu_debugfs.c | 5 + drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++ drivers/gpu/drm/virtio/virtgpu_kms.c | 27 ++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_debugfs.c b/drivers/gpu/drm/virtio/virtgpu_debugfs.c index e99d1c3c0a66..ea27cae28ab4 100644 --- a/drivers/gpu/drm/virtio/virtgpu_debugfs.c +++ b/drivers/gpu/drm/virtio/virtgpu_debugfs.c @@ -51,6 +51,11 @@ static int virtio_gpu_features(struct seq_file *m, void *data) virtio_add_bool(m, "blob resources", vgdev->has_resource_blob); virtio_add_int(m, "cap sets", vgdev->num_capsets); virtio_add_int(m, "scanouts", vgdev->num_scanouts); + if (vgdev->host_visible_region.len) { + seq_printf(m, "%-16s : 0x%lx +0x%lx\n", "host visible region", + (unsigned long)vgdev->host_visible_region.addr, + (unsigned long)vgdev->host_visible_region.len); + } return 0; } diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index a529727d6114..c8405449c4a3 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -209,6 +209,8 @@ struct virtio_gpu_device { bool has_indirect; bool has_resource_assign_uuid; bool has_resource_blob; + bool has_host_visible; + struct virtio_shm_region host_visible_region; struct work_struct config_changed_work; diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index 4167673b97d6..d3641eda7077 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -153,11 +153,27 @@ int virtio_gpu_init(struct drm_device *dev) if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_RESOURCE_BLOB)) { vgdev->has_resource_blob = true; } + if (virtio_get_shm_region(vgdev->vdev, >host_visible_region, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE)) { + if (!devm_request_mem_region(>vdev->dev, +vgdev->host_visible_region.addr, +vgdev->host_visible_region.len, +dev_name(>vdev->dev))) { + DRM_ERROR("Could not reserve host visible region\n"); + goto err_vqs; + } + + DRM_INFO("Host memory window: 0x%lx +0x%lx\n", +(unsigned long)vgdev->host_visible_region.addr, +(unsigned long)vgdev->host_visible_region.len); + vgdev->has_host_visible = true; + } - DRM_INFO("features: %cvirgl %cedid %cresource_blob\n", + DRM_INFO("features: %cvirgl %cedid %cresource_blob %chost_visible\n", vgdev->has_virgl_3d? '+' : '-', vgdev->has_edid? '+' : '-', -vgdev->has_resource_blob ? '+' : '-'); +vgdev->has_resource_blob ? '+' : '-', +vgdev->has_host_visible ? '+' : '-'); ret = virtio_find_vqs(vgdev->vdev, 2, vqs, callbacks, names, NULL); if (ret) { @@ -241,6 +257,13 @@ void virtio_gpu_release(struct drm_device *dev) virtio_gpu_free_vbufs(vgdev); virtio_gpu_cleanup_cap_cache(vgdev); kfree(vgdev->capsets); + + if (vgdev->has_host_visible) { + devm_release_mem_region(>vdev->dev, + vgdev->host_visible_region.addr, + vgdev->host_visible_region.len); + } + kfree(vgdev); } -- 2.24.1 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel