drm/virtio: enqueue virtio_gpu_create_context after the first 3D ioctl
For old userspace, initialization will still be implicit. For backwards compatibility, enqueue virtio_gpu_cmd_context_create after the first 3D ioctl. v3: staticify virtio_gpu_create_context remove notify to batch vm-exit v6: Remove nested 3D checks (emil.velikov): - unify 3D check in resource create v7: Remove check when getting capabilities Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com> Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/20200225000800.2966-4-gurchetansingh@chromium.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
d2a983b220
commit
72b48ae800
3 changed files with 16 additions and 16 deletions
|
@ -216,8 +216,6 @@ struct virtio_gpu_fpriv {
|
||||||
/* virtio_ioctl.c */
|
/* virtio_ioctl.c */
|
||||||
#define DRM_VIRTIO_NUM_IOCTLS 10
|
#define DRM_VIRTIO_NUM_IOCTLS 10
|
||||||
extern struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS];
|
extern struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS];
|
||||||
void virtio_gpu_create_context(struct drm_device *dev,
|
|
||||||
struct drm_file *file);
|
|
||||||
|
|
||||||
/* virtio_kms.c */
|
/* virtio_kms.c */
|
||||||
int virtio_gpu_init(struct drm_device *dev);
|
int virtio_gpu_init(struct drm_device *dev);
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
|
|
||||||
#include "virtgpu_drv.h"
|
#include "virtgpu_drv.h"
|
||||||
|
|
||||||
void virtio_gpu_create_context(struct drm_device *dev,
|
static void virtio_gpu_create_context(struct drm_device *dev,
|
||||||
struct drm_file *file)
|
struct drm_file *file)
|
||||||
{
|
{
|
||||||
struct virtio_gpu_device *vgdev = dev->dev_private;
|
struct virtio_gpu_device *vgdev = dev->dev_private;
|
||||||
struct virtio_gpu_fpriv *vfpriv = file->driver_priv;
|
struct virtio_gpu_fpriv *vfpriv = file->driver_priv;
|
||||||
|
@ -95,6 +95,7 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
|
||||||
|
|
||||||
exbuf->fence_fd = -1;
|
exbuf->fence_fd = -1;
|
||||||
|
|
||||||
|
virtio_gpu_create_context(dev, file);
|
||||||
if (exbuf->flags & VIRTGPU_EXECBUF_FENCE_FD_IN) {
|
if (exbuf->flags & VIRTGPU_EXECBUF_FENCE_FD_IN) {
|
||||||
struct dma_fence *in_fence;
|
struct dma_fence *in_fence;
|
||||||
|
|
||||||
|
@ -233,7 +234,17 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data,
|
||||||
uint32_t handle = 0;
|
uint32_t handle = 0;
|
||||||
struct virtio_gpu_object_params params = { 0 };
|
struct virtio_gpu_object_params params = { 0 };
|
||||||
|
|
||||||
if (vgdev->has_virgl_3d == false) {
|
if (vgdev->has_virgl_3d) {
|
||||||
|
virtio_gpu_create_context(dev, file);
|
||||||
|
params.virgl = true;
|
||||||
|
params.target = rc->target;
|
||||||
|
params.bind = rc->bind;
|
||||||
|
params.depth = rc->depth;
|
||||||
|
params.array_size = rc->array_size;
|
||||||
|
params.last_level = rc->last_level;
|
||||||
|
params.nr_samples = rc->nr_samples;
|
||||||
|
params.flags = rc->flags;
|
||||||
|
} else {
|
||||||
if (rc->depth > 1)
|
if (rc->depth > 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (rc->nr_samples > 1)
|
if (rc->nr_samples > 1)
|
||||||
|
@ -250,16 +261,6 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data,
|
||||||
params.width = rc->width;
|
params.width = rc->width;
|
||||||
params.height = rc->height;
|
params.height = rc->height;
|
||||||
params.size = rc->size;
|
params.size = rc->size;
|
||||||
if (vgdev->has_virgl_3d) {
|
|
||||||
params.virgl = true;
|
|
||||||
params.target = rc->target;
|
|
||||||
params.bind = rc->bind;
|
|
||||||
params.depth = rc->depth;
|
|
||||||
params.array_size = rc->array_size;
|
|
||||||
params.last_level = rc->last_level;
|
|
||||||
params.nr_samples = rc->nr_samples;
|
|
||||||
params.flags = rc->flags;
|
|
||||||
}
|
|
||||||
/* allocate a single page size object */
|
/* allocate a single page size object */
|
||||||
if (params.size == 0)
|
if (params.size == 0)
|
||||||
params.size = PAGE_SIZE;
|
params.size = PAGE_SIZE;
|
||||||
|
@ -319,6 +320,7 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev,
|
||||||
if (vgdev->has_virgl_3d == false)
|
if (vgdev->has_virgl_3d == false)
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
|
|
||||||
|
virtio_gpu_create_context(dev, file);
|
||||||
objs = virtio_gpu_array_from_handles(file, &args->bo_handle, 1);
|
objs = virtio_gpu_array_from_handles(file, &args->bo_handle, 1);
|
||||||
if (objs == NULL)
|
if (objs == NULL)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
@ -367,6 +369,7 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data,
|
||||||
args->box.w, args->box.h, args->box.x, args->box.y,
|
args->box.w, args->box.h, args->box.x, args->box.y,
|
||||||
objs, NULL);
|
objs, NULL);
|
||||||
} else {
|
} else {
|
||||||
|
virtio_gpu_create_context(dev, file);
|
||||||
ret = virtio_gpu_array_lock_resv(objs);
|
ret = virtio_gpu_array_lock_resv(objs);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto err_put_free;
|
goto err_put_free;
|
||||||
|
|
|
@ -268,7 +268,6 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file)
|
||||||
|
|
||||||
vfpriv->ctx_id = handle + 1;
|
vfpriv->ctx_id = handle + 1;
|
||||||
file->driver_priv = vfpriv;
|
file->driver_priv = vfpriv;
|
||||||
virtio_gpu_create_context(dev, file);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue