Skip to content

Commit

Permalink
drm/virtio: implement blob resources: probe for host visible region
Browse files Browse the repository at this point in the history
The availability of the host visible region means host 3D
allocations can be directly mapped in the guest.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20200924003214.662-9-gurchetansingh@chromium.org
Co-developed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
  • Loading branch information
Gerd Hoffmann committed Sep 29, 2020
1 parent 6815cfe commit 6076a97
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions drivers/gpu/drm/virtio/virtgpu_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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;
}

Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/virtio/virtgpu_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
20 changes: 18 additions & 2 deletions drivers/gpu/drm/virtio/virtgpu_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,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, &vgdev->host_visible_region,
VIRTIO_GPU_SHM_ID_HOST_VISIBLE)) {
if (!devm_request_mem_region(&vgdev->vdev->dev,
vgdev->host_visible_region.addr,
vgdev->host_visible_region.len,
dev_name(&vgdev->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) {
Expand Down

0 comments on commit 6076a97

Please sign in to comment.