diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index bd4b5d60f9b3..6df569d75930 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -85,6 +85,7 @@ struct virtio_gpu_object_params { uint32_t blob_mem; uint32_t blob_flags; uint64_t blob_id; + bool protected; }; struct virtio_gpu_object { @@ -97,6 +98,7 @@ struct virtio_gpu_object { int uuid_state; uuid_t uuid; + bool protected; }; #define gem_to_virtio_gpu_obj(gobj) \ container_of((gobj), struct virtio_gpu_object, base.base) diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c index e6ba0a4fe90c..512d90beb1e5 100644 --- a/drivers/gpu/drm/virtio/virtgpu_prime.c +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c @@ -211,8 +211,10 @@ struct drm_gem_object *virtgpu_gem_prime_import_sg_table( struct virtio_gpu_object_params params = { 0 }; struct virtio_gpu_object *bo; struct drm_gem_object *obj; + struct drm_gem_object *i915_obj; struct virtio_gpu_mem_entry *ents; unsigned int nents; + struct dma_buf *dmabuf; int ret; if (!vgdev->has_resource_blob || vgdev->has_virgl_3d) { @@ -234,13 +236,18 @@ struct drm_gem_object *virtgpu_gem_prime_import_sg_table( if (ret != 0) { goto err_put_id; } - + dmabuf = attach->dmabuf; + if (dmabuf && strcmp(module_name(dmabuf->owner), "i915") == 0) { + dmabuf = attach->dmabuf; + i915_obj = dmabuf->priv; + bo->protected = i915_obj->protected; + } bo->guest_blob = true; params.blob_mem = VIRTGPU_BLOB_MEM_GUEST; params.blob_flags = VIRTGPU_BLOB_FLAG_USE_SHAREABLE; params.blob = true; params.size = size; - + params.protected = bo->protected; virtio_gpu_cmd_resource_create_blob(vgdev, bo, ¶ms, ents, nents); virtio_gpu_object_save_restore_list(vgdev, bo, ¶ms); diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 3fcb720da3f4..35b18d5e1739 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -1552,6 +1552,7 @@ virtio_gpu_cmd_resource_create_blob(struct virtio_gpu_device *vgdev, cmd_p->blob_id = cpu_to_le64(params->blob_id); cmd_p->size = cpu_to_le64(params->size); cmd_p->nr_entries = cpu_to_le32(nents); + cmd_p->protected = cpu_to_le64(params->protected); vbuf->data_buf = ents; vbuf->data_size = sizeof(*ents) * nents; diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gpu.h index 2f784bde5810..daa29e1956a4 100644 --- a/include/uapi/linux/virtio_gpu.h +++ b/include/uapi/linux/virtio_gpu.h @@ -612,6 +612,7 @@ struct virtio_gpu_resource_create_blob { __le32 nr_entries; __le64 blob_id; __le64 size; + __le64 protected; /* * sizeof(nr_entries * virtio_gpu_mem_entry) bytes follow */