From de59576293f82ee285ef5edb31f7169c84403368 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 16 Dec 2014 12:29:59 +0100 Subject: bochs: ignore device if there isn't enougth memory The qemu stdvga can be configured with a wide range of video memory, from 1 MB to 256 MB (default is 16 MB). In case it is configured with only 1 or 2 MB it isn't really usable with bochsdrm, due to depths other than 32bpp not being supported so that isn't enough memory for a reasonable sized framebuffer. So skip the device and let vgacon or vesafb+fbcon handle the it. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/bochs/bochs_drv.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c index abace82de6ea..aaae5e50d7c8 100644 --- a/drivers/gpu/drm/bochs/bochs_drv.c +++ b/drivers/gpu/drm/bochs/bochs_drv.c @@ -162,8 +162,15 @@ static int bochs_kick_out_firmware_fb(struct pci_dev *pdev) static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { + unsigned long fbsize; int ret; + fbsize = pci_resource_len(pdev, 0); + if (fbsize < 4 * 1024 * 1024) { + DRM_ERROR("less than 4 MB video memory, ignoring device\n"); + return -ENOMEM; + } + ret = bochs_kick_out_firmware_fb(pdev); if (ret) return ret; -- cgit v1.2.3 From 4532b241a4b7b0ca372a80baf900ce4ea2015412 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Fri, 9 Sep 2016 11:09:05 -0400 Subject: drm/qxl: reapply cursor after SetCrtc calls The qxl driver currently destroys and recreates the qxl "primary" any time the first crtc is set. A side-effect of destroying the primary is mouse state associated with the crtc is lost, which leads to disappearing mouse cursors on wayland sessions. This commit changes the driver to reapply the cursor any time SetCrtc is called. It achieves this by keeping a reference to the cursor bo on the qxl_crtc struct. Signed-off-by: Ray Strode Message-id: 1473433745-11016-1-git-send-email-halfline@gmail.com https://bugzilla.redhat.com/show_bug.cgi?id=1200901 Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/qxl/qxl_display.c | 56 ++++++++++++++++++++++++++++++++++++++- drivers/gpu/drm/qxl/qxl_drv.h | 1 + 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c index 3aef12742a53..a61c0d460ec2 100644 --- a/drivers/gpu/drm/qxl/qxl_display.c +++ b/drivers/gpu/drm/qxl/qxl_display.c @@ -211,6 +211,7 @@ static void qxl_crtc_destroy(struct drm_crtc *crtc) struct qxl_crtc *qxl_crtc = to_qxl_crtc(crtc); drm_crtc_cleanup(crtc); + qxl_bo_unref(&qxl_crtc->cursor_bo); kfree(qxl_crtc); } @@ -296,6 +297,52 @@ qxl_hide_cursor(struct qxl_device *qdev) return 0; } +static int qxl_crtc_apply_cursor(struct drm_crtc *crtc) +{ + struct qxl_crtc *qcrtc = to_qxl_crtc(crtc); + struct drm_device *dev = crtc->dev; + struct qxl_device *qdev = dev->dev_private; + struct qxl_cursor_cmd *cmd; + struct qxl_release *release; + int ret = 0; + + if (!qcrtc->cursor_bo) + return 0; + + ret = qxl_alloc_release_reserved(qdev, sizeof(*cmd), + QXL_RELEASE_CURSOR_CMD, + &release, NULL); + if (ret) + return ret; + + ret = qxl_release_list_add(release, qcrtc->cursor_bo); + if (ret) + goto out_free_release; + + ret = qxl_release_reserve_list(release, false); + if (ret) + goto out_free_release; + + cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release); + cmd->type = QXL_CURSOR_SET; + cmd->u.set.position.x = qcrtc->cur_x + qcrtc->hot_spot_x; + cmd->u.set.position.y = qcrtc->cur_y + qcrtc->hot_spot_y; + + cmd->u.set.shape = qxl_bo_physical_address(qdev, qcrtc->cursor_bo, 0); + + cmd->u.set.visible = 1; + qxl_release_unmap(qdev, release, &cmd->release_info); + + qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false); + qxl_release_fence_buffer_objects(release); + + return ret; + +out_free_release: + qxl_release_free(qdev, release); + return ret; +} + static int qxl_crtc_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv, uint32_t handle, @@ -400,7 +447,8 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc, } drm_gem_object_unreference_unlocked(obj); - qxl_bo_unref(&cursor_bo); + qxl_bo_unref (&qcrtc->cursor_bo); + qcrtc->cursor_bo = cursor_bo; return ret; @@ -655,6 +703,12 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc, bo->surf.stride, bo->surf.format); qxl_io_create_primary(qdev, 0, bo); bo->is_primary = true; + + ret = qxl_crtc_apply_cursor(crtc); + if (ret) { + DRM_ERROR("could not set cursor after modeset"); + ret = 0; + } } if (bo->is_primary) { diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h index 8e633caa4078..5f3e5ad99de7 100644 --- a/drivers/gpu/drm/qxl/qxl_drv.h +++ b/drivers/gpu/drm/qxl/qxl_drv.h @@ -137,6 +137,7 @@ struct qxl_crtc { int cur_y; int hot_spot_x; int hot_spot_y; + struct qxl_bo *cursor_bo; }; struct qxl_output { -- cgit v1.2.3 From b28c69dd3d563676db079a678a2deabf37461fbf Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 21 Aug 2016 23:06:06 +0200 Subject: virtio-gpu: avoid possible NULL pointer dereference If output is NULL it is not permissable to dereference it. So we should leave the respective function in this case. The inconsistency was indicated by cppcheck. No actual NULL pointer dereference was observed. Signed-off-by: Heinrich Schuchardt Message-id: 1471813566-5324-1-git-send-email-xypron.glpk@gmx.de Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_plane.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c index 925ca25209df..ba28c0f6f28a 100644 --- a/drivers/gpu/drm/virtio/virtgpu_plane.c +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c @@ -76,7 +76,8 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane, output = drm_crtc_to_virtio_gpu_output(plane->state->crtc); if (old_state->crtc) output = drm_crtc_to_virtio_gpu_output(old_state->crtc); - WARN_ON(!output); + if (WARN_ON(!output)) + return; if (plane->state->fb) { vgfb = to_virtio_gpu_framebuffer(plane->state->fb); @@ -129,7 +130,8 @@ static void virtio_gpu_cursor_plane_update(struct drm_plane *plane, output = drm_crtc_to_virtio_gpu_output(plane->state->crtc); if (old_state->crtc) output = drm_crtc_to_virtio_gpu_output(old_state->crtc); - WARN_ON(!output); + if (WARN_ON(!output)) + return; if (plane->state->fb) { vgfb = to_virtio_gpu_framebuffer(plane->state->fb); -- cgit v1.2.3 From 5c32c3dd8501b017e0ce139a2abcd23cc471b773 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Wed, 31 Aug 2016 12:26:52 -0400 Subject: drm/virtio: drop virtio_gpu_execbuffer_ioctl() wrapping Instead of wrapping virtio_gpu_execbuffer() to execute the ioctl just execute it directly. Signed-off-by: Gustavo Padovan Message-id: 1472660813-28219-1-git-send-email-gustavo@padovan.org Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index c046903cb47b..e0613a9c2833 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -89,10 +89,16 @@ static void virtio_gpu_unref_list(struct list_head *head) } } -static int virtio_gpu_execbuffer(struct drm_device *dev, - struct drm_virtgpu_execbuffer *exbuf, +/* + * Usage of execbuffer: + * Relocations need to take into account the full VIRTIO_GPUDrawable size. + * However, the command as passed from user space must *not* contain the initial + * VIRTIO_GPUReleaseInfo struct (first XXX bytes) + */ +static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, struct drm_file *drm_file) { + struct drm_virtgpu_execbuffer *exbuf = data; struct virtio_gpu_device *vgdev = dev->dev_private; struct virtio_gpu_fpriv *vfpriv = drm_file->driver_priv; struct drm_gem_object *gobj; @@ -182,20 +188,6 @@ out_free: return ret; } -/* - * Usage of execbuffer: - * Relocations need to take into account the full VIRTIO_GPUDrawable size. - * However, the command as passed from user space must *not* contain the initial - * VIRTIO_GPUReleaseInfo struct (first XXX bytes) - */ -static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv) -{ - struct drm_virtgpu_execbuffer *execbuffer = data; - return virtio_gpu_execbuffer(dev, execbuffer, file_priv); -} - - static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { -- cgit v1.2.3 From 30b9c96cf7b44d53b9165649c8be34ac234be324 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Wed, 31 Aug 2016 12:26:53 -0400 Subject: drm/virtio: add real fence context and seqno virtio fences were created with no fence context, which would make then clash with an allocated fence context. Signed-off-by: Gustavo Padovan Message-id: 1472660813-28219-2-git-send-email-gustavo@padovan.org Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_drv.h | 1 + drivers/gpu/drm/virtio/virtgpu_fence.c | 2 +- drivers/gpu/drm/virtio/virtgpu_kms.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index b18ef3111f0c..06ad9238044e 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -75,6 +75,7 @@ typedef void (*virtio_gpu_resp_cb)(struct virtio_gpu_device *vgdev, struct virtio_gpu_fence_driver { atomic64_t last_seq; uint64_t sync_seq; + uint64_t context; struct list_head fences; spinlock_t lock; }; diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c index cf4418709e76..f3f70fa8a4c7 100644 --- a/drivers/gpu/drm/virtio/virtgpu_fence.c +++ b/drivers/gpu/drm/virtio/virtgpu_fence.c @@ -89,7 +89,7 @@ int virtio_gpu_fence_emit(struct virtio_gpu_device *vgdev, (*fence)->drv = drv; (*fence)->seq = ++drv->sync_seq; fence_init(&(*fence)->f, &virtio_fence_ops, &drv->lock, - 0, (*fence)->seq); + drv->context, (*fence)->seq); fence_get(&(*fence)->f); list_add_tail(&(*fence)->node, &drv->fences); spin_unlock_irqrestore(&drv->lock, irq_flags); diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index 4150873d432e..036b0fbae0fb 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -159,6 +159,7 @@ int virtio_gpu_driver_load(struct drm_device *dev, unsigned long flags) virtio_gpu_init_vq(&vgdev->ctrlq, virtio_gpu_dequeue_ctrl_func); virtio_gpu_init_vq(&vgdev->cursorq, virtio_gpu_dequeue_cursor_func); + vgdev->fence_drv.context = fence_context_alloc(1); spin_lock_init(&vgdev->fence_drv.lock); INIT_LIST_HEAD(&vgdev->fence_drv.fences); INIT_LIST_HEAD(&vgdev->cap_cache); -- cgit v1.2.3