virtio-gpu: bugfixes, virgl/3d rendering support
Subsystems (5)
Gerd Hoffmann
maintainerv3 cover virtio-gpu: bugfixes, virgl/3d rendering support
Hi,
Here comes the 3d rendering support patch series for virtio-gpu, along with a few bugfixes and page-flip support. The latter needs some careful review.
Patches 1-3 carry bugfixes.
Patches 4-6 bring 3d rendering support.
Patch 7 brings page-flip support.
Corresponsing qemu patches have been posted too. Most recent patch series post is here (there will be an update soon, git tree is already more recent than that and is recommended for testing):
https://www.mail-archive.com/[email protected]/msg319956.html
Thee are also git branches with the kernel and qemu code:
https://www.kraxel.org/cgit/linux/log/?h=virtio-gpu
https://www.kraxel.org/cgit/qemu/log/?h=rebase/virgl-wip
please review,
Gerd
Dave Airlie (2):
virtio-gpu: add basic prime support
virtio-gpu: mark as a render gpu
Gerd Hoffmann (5):
virtio-gpu: add virtio_gpu_queue_ctrl_buffer_locked
virtio-gpu: add & use virtio_gpu_queue_fenced_ctrl_buffer
virtio-gpu: wait for cursor updates finish
virtio-gpu: add 3d/virgl support
[wip] virtio-gpu: add page flip support
drivers/gpu/drm/virtio/Makefile | 3 +- drivers/gpu/drm/virtio/virtgpu_display.c | 57 ++- drivers/gpu/drm/virtio/virtgpu_drv.c | 28 +- drivers/gpu/drm/virtio/virtgpu_drv.h | 72 ++++ drivers/gpu/drm/virtio/virtgpu_fence.c | 2 +- drivers/gpu/drm/virtio/virtgpu_gem.c | 41 +++ drivers/gpu/drm/virtio/virtgpu_ioctl.c | 572 +++++++++++++++++++++++++++++++ drivers/gpu/drm/virtio/virtgpu_kms.c | 133 ++++++- drivers/gpu/drm/virtio/virtgpu_prime.c | 71 ++++ drivers/gpu/drm/virtio/virtgpu_ttm.c | 1 + drivers/gpu/drm/virtio/virtgpu_vq.c | 322 ++++++++++++++++- include/uapi/drm/Kbuild | 1 + include/uapi/drm/virtgpu_drm.h | 167 +++++++++ include/uapi/linux/virtio_gpu.h | 112 +++++- 14 files changed, 1564 insertions(+), 18 deletions(-) create mode 100644 drivers/gpu/drm/virtio/virtgpu_ioctl.c create mode 100644 drivers/gpu/drm/virtio/virtgpu_prime.c create mode 100644 include/uapi/drm/virtgpu_drm.h
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v3 1/7 virtio-gpu: add virtio_gpu_queue_ctrl_buffer_locked
Add virtio_gpu_queue_ctrl_buffer_locked function, which does the same as virtio_gpu_queue_ctrl_buffer but does not take the virtqueue lock. The caller must hold the lock instead.
--- drivers/gpu/drm/virtio/virtgpu_vq.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/virtio/virtgpu_vq.c +13 -4
@@ -293,8 +293,8 @@ void virtio_gpu_dequeue_cursor_func(struct work_struct *work)wake_up (&vgdev->cursorq.ack_queue); } -static int virtio_gpu_queue_ctrl_buffer (struct virtio_gpu_device *vgdev, -struct virtio_gpu_vbuffer *vbuf) +static int virtio_gpu_queue_ctrl_buffer_locked (struct virtio_gpu_device *vgdev, +struct virtio_gpu_vbuffer *vbuf) {struct virtqueue *vq = vgdev->ctrlq.vq;struct scatterlist *sgs[3 ], vcmd, vout, vresp;
@@ -320,7 +320,6 @@ static int virtio_gpu_queue_ctrl_buffer(struct virtio_gpu_device *vgdev, incnt++; } -spin_lock (&vgdev->ctrlq.qlock); retry: ret =virtqueue_add_sgs (vq, sgs, outcnt, incnt, vbuf,GFP_ATOMIC );if (ret == -ENOSPC ) {
@@ -331,13 +330,23 @@ retry: }else {virtqueue_kick (vq); } -spin_unlock (&vgdev->ctrlq.qlock);if (!ret) ret = vq->num_free;return ret; } +static int virtio_gpu_queue_ctrl_buffer (struct virtio_gpu_device *vgdev, +struct virtio_gpu_vbuffer *vbuf) +{ +int rc; + +spin_lock (&vgdev->ctrlq.qlock); + rc =virtio_gpu_queue_ctrl_buffer_locked (vgdev, vbuf); +spin_unlock (&vgdev->ctrlq.qlock); +return rc; +} +static int virtio_gpu_queue_cursor (struct virtio_gpu_device *vgdev,struct virtio_gpu_vbuffer *vbuf) {
Signature · 1 line
1.8.3.1
Gerd Hoffmann
maintainerPATCH v3 1/7 virtio-gpu: add virtio_gpu_queue_ctrl_buffer_locked
In reply to Gerd HoffmannAdd virtio_gpu_queue_ctrl_buffer_locked function, which does the same as virtio_gpu_queue_ctrl_buffer but does not take the virtqueue lock. The caller must hold the lock instead.
--- drivers/gpu/drm/virtio/virtgpu_vq.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/virtio/virtgpu_vq.c +13 -4
@@ -293,8 +293,8 @@ void virtio_gpu_dequeue_cursor_func(struct work_struct *work)wake_up (&vgdev->cursorq.ack_queue); } -static int virtio_gpu_queue_ctrl_buffer (struct virtio_gpu_device *vgdev, -struct virtio_gpu_vbuffer *vbuf) +static int virtio_gpu_queue_ctrl_buffer_locked (struct virtio_gpu_device *vgdev, +struct virtio_gpu_vbuffer *vbuf) {struct virtqueue *vq = vgdev->ctrlq.vq;struct scatterlist *sgs[3 ], vcmd, vout, vresp;
@@ -320,7 +320,6 @@ static int virtio_gpu_queue_ctrl_buffer(struct virtio_gpu_device *vgdev, incnt++; } -spin_lock (&vgdev->ctrlq.qlock); retry: ret =virtqueue_add_sgs (vq, sgs, outcnt, incnt, vbuf,GFP_ATOMIC );if (ret == -ENOSPC ) {
@@ -331,13 +330,23 @@ retry: }else {virtqueue_kick (vq); } -spin_unlock (&vgdev->ctrlq.qlock);if (!ret) ret = vq->num_free;return ret; } +static int virtio_gpu_queue_ctrl_buffer (struct virtio_gpu_device *vgdev, +struct virtio_gpu_vbuffer *vbuf) +{ +int rc; + +spin_lock (&vgdev->ctrlq.qlock); + rc =virtio_gpu_queue_ctrl_buffer_locked (vgdev, vbuf); +spin_unlock (&vgdev->ctrlq.qlock); +return rc; +} +static int virtio_gpu_queue_cursor (struct virtio_gpu_device *vgdev,struct virtio_gpu_vbuffer *vbuf) {
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v3 2/7 virtio-gpu: add & use virtio_gpu_queue_fenced_ctrl_buffer
In reply to Gerd HoffmannAdd helper function to handle the submission of fenced control requests. Make sure we initialize the fence while holding the virtqueue lock, so requests can't be reordered.
--- drivers/gpu/drm/virtio/virtgpu_fence.c | 2 +- drivers/gpu/drm/virtio/virtgpu_vq.c | 40 +++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 7 deletions(-)
drivers/gpu/drm/virtio/virtgpu_fence.c +1 -1
@@ -81,7 +81,7 @@ int virtio_gpu_fence_emit(struct virtio_gpu_device *vgdev,struct virtio_gpu_fence_driver *drv = &vgdev->fence_drv;unsigned long irq_flags; - *fence =kmalloc (sizeof (struct virtio_gpu_fence ),GFP_KERNEL ); + *fence =kmalloc (sizeof (struct virtio_gpu_fence ),GFP_ATOMIC );if ((*fence) ==NULL )return -ENOMEM ;
drivers/gpu/drm/virtio/virtgpu_vq.c +34 -6
@@ -347,6 +347,38 @@ static int virtio_gpu_queue_ctrl_buffer(struct virtio_gpu_device *vgdev,return rc; } +static int virtio_gpu_queue_fenced_ctrl_buffer (struct virtio_gpu_device *vgdev, +struct virtio_gpu_vbuffer *vbuf, +struct virtio_gpu_ctrl_hdr *hdr, +struct virtio_gpu_fence **fence) +{ +struct virtqueue *vq = vgdev->ctrlq.vq; +int rc; + +again: +spin_lock (&vgdev->ctrlq.qlock); + +/* +* Make sure we have enouth space in the virtqueue. If not +* wait here until we have. +* +* Without that virtio_gpu_queue_ctrl_buffer_nolock might have +* to wait for free space, which can result in fence ids being +* submitted out-of-order. +*/ +if (vq->num_free <3 ) { +spin_unlock (&vgdev->ctrlq.qlock); +wait_event (vgdev->ctrlq.ack_queue, vq->num_free >=3 ); + goto again; + } + +if (fence) +virtio_gpu_fence_emit (vgdev, hdr, fence); + rc =virtio_gpu_queue_ctrl_buffer_locked (vgdev, vbuf); +spin_unlock (&vgdev->ctrlq.qlock); +return rc; +} +static int virtio_gpu_queue_cursor (struct virtio_gpu_device *vgdev,struct virtio_gpu_vbuffer *vbuf) {
@@ -499,9 +531,7 @@ void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev, cmd_p->r.x = x; cmd_p->r.y = y; -if (fence) -virtio_gpu_fence_emit (vgdev, &cmd_p->hdr, fence); -virtio_gpu_queue_ctrl_buffer (vgdev, vbuf); +virtio_gpu_queue_fenced_ctrl_buffer (vgdev, vbuf, &cmd_p->hdr, fence); } static void
@@ -524,9 +554,7 @@ virtio_gpu_cmd_resource_attach_backing(struct virtio_gpu_device *vgdev, vbuf->data_buf = ents; vbuf->data_size =sizeof (*ents) * nents; -if (fence) -virtio_gpu_fence_emit (vgdev, &cmd_p->hdr, fence); -virtio_gpu_queue_ctrl_buffer (vgdev, vbuf); +virtio_gpu_queue_fenced_ctrl_buffer (vgdev, vbuf, &cmd_p->hdr, fence); } static void virtio_gpu_cmd_get_display_info_cb(struct virtio_gpu_device *vgdev,
Signature · 1 line
1.8.3.1
Gerd Hoffmann
maintainerPATCH v3 2/7 virtio-gpu: add & use virtio_gpu_queue_fenced_ctrl_buffer
In reply to Gerd HoffmannAdd helper function to handle the submission of fenced control requests. Make sure we initialize the fence while holding the virtqueue lock, so requests can't be reordered.
--- drivers/gpu/drm/virtio/virtgpu_fence.c | 2 +- drivers/gpu/drm/virtio/virtgpu_vq.c | 40 +++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 7 deletions(-)
drivers/gpu/drm/virtio/virtgpu_fence.c +1 -1
@@ -81,7 +81,7 @@ int virtio_gpu_fence_emit(struct virtio_gpu_device *vgdev,struct virtio_gpu_fence_driver *drv = &vgdev->fence_drv;unsigned long irq_flags; - *fence =kmalloc (sizeof (struct virtio_gpu_fence ),GFP_KERNEL ); + *fence =kmalloc (sizeof (struct virtio_gpu_fence ),GFP_ATOMIC );if ((*fence) ==NULL )return -ENOMEM ;
drivers/gpu/drm/virtio/virtgpu_vq.c +34 -6
@@ -347,6 +347,38 @@ static int virtio_gpu_queue_ctrl_buffer(struct virtio_gpu_device *vgdev,return rc; } +static int virtio_gpu_queue_fenced_ctrl_buffer (struct virtio_gpu_device *vgdev, +struct virtio_gpu_vbuffer *vbuf, +struct virtio_gpu_ctrl_hdr *hdr, +struct virtio_gpu_fence **fence) +{ +struct virtqueue *vq = vgdev->ctrlq.vq; +int rc; + +again: +spin_lock (&vgdev->ctrlq.qlock); + +/* +* Make sure we have enouth space in the virtqueue. If not +* wait here until we have. +* +* Without that virtio_gpu_queue_ctrl_buffer_nolock might have +* to wait for free space, which can result in fence ids being +* submitted out-of-order. +*/ +if (vq->num_free <3 ) { +spin_unlock (&vgdev->ctrlq.qlock); +wait_event (vgdev->ctrlq.ack_queue, vq->num_free >=3 ); + goto again; + } + +if (fence) +virtio_gpu_fence_emit (vgdev, hdr, fence); + rc =virtio_gpu_queue_ctrl_buffer_locked (vgdev, vbuf); +spin_unlock (&vgdev->ctrlq.qlock); +return rc; +} +static int virtio_gpu_queue_cursor (struct virtio_gpu_device *vgdev,struct virtio_gpu_vbuffer *vbuf) {
@@ -499,9 +531,7 @@ void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev, cmd_p->r.x = x; cmd_p->r.y = y; -if (fence) -virtio_gpu_fence_emit (vgdev, &cmd_p->hdr, fence); -virtio_gpu_queue_ctrl_buffer (vgdev, vbuf); +virtio_gpu_queue_fenced_ctrl_buffer (vgdev, vbuf, &cmd_p->hdr, fence); } static void
@@ -524,9 +554,7 @@ virtio_gpu_cmd_resource_attach_backing(struct virtio_gpu_device *vgdev, vbuf->data_buf = ents; vbuf->data_size =sizeof (*ents) * nents; -if (fence) -virtio_gpu_fence_emit (vgdev, &cmd_p->hdr, fence); -virtio_gpu_queue_ctrl_buffer (vgdev, vbuf); +virtio_gpu_queue_fenced_ctrl_buffer (vgdev, vbuf, &cmd_p->hdr, fence); } static void virtio_gpu_cmd_get_display_info_cb(struct virtio_gpu_device *vgdev,
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v3 3/7 virtio-gpu: wait for cursor updates finish
In reply to Gerd Hoffmann--- drivers/gpu/drm/virtio/virtgpu_display.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/virtio/virtgpu_display.c +8 -0
@@ -90,6 +90,14 @@ static int virtio_gpu_crtc_cursor_set(struct drm_crtc *crtc,cpu_to_le32 (64 ),cpu_to_le32 (64 ), 0, 0, &fence); + ret =virtio_gpu_object_reserve (qobj, false); +if (!ret) { +reservation_object_add_excl_fence (qobj->tbo.resv, + &fence->f); +fence_put (&fence->f); +virtio_gpu_object_unreserve (qobj); +virtio_gpu_object_wait (qobj, false); + } output->cursor.hdr.type =cpu_to_le32 (VIRTIO_GPU_CMD_UPDATE_CURSOR ); output->cursor.resource_id =cpu_to_le32 (qobj->hw_res_handle);
Signature · 1 line
1.8.3.1
Gerd Hoffmann
maintainerPATCH v3 3/7 virtio-gpu: wait for cursor updates finish
In reply to Gerd Hoffmann--- drivers/gpu/drm/virtio/virtgpu_display.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/virtio/virtgpu_display.c +8 -0
@@ -90,6 +90,14 @@ static int virtio_gpu_crtc_cursor_set(struct drm_crtc *crtc,cpu_to_le32 (64 ),cpu_to_le32 (64 ), 0, 0, &fence); + ret =virtio_gpu_object_reserve (qobj, false); +if (!ret) { +reservation_object_add_excl_fence (qobj->tbo.resv, + &fence->f); +fence_put (&fence->f); +virtio_gpu_object_unreserve (qobj); +virtio_gpu_object_wait (qobj, false); + } output->cursor.hdr.type =cpu_to_le32 (VIRTIO_GPU_CMD_UPDATE_CURSOR ); output->cursor.resource_id =cpu_to_le32 (qobj->hw_res_handle);
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v3 4/7 virtio-gpu: add 3d/virgl support
In reply to Gerd HoffmannAdd the bits needed for opengl rendering support: query capabilities, new virtio commands, drm ioctls.
--- drivers/gpu/drm/virtio/Makefile | 3 +- drivers/gpu/drm/virtio/virtgpu_drv.c | 15 + drivers/gpu/drm/virtio/virtgpu_drv.h | 60 ++++ drivers/gpu/drm/virtio/virtgpu_gem.c | 41 +++ drivers/gpu/drm/virtio/virtgpu_ioctl.c | 572 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/virtio/virtgpu_kms.c | 133 +++++++- drivers/gpu/drm/virtio/virtgpu_ttm.c | 1 + drivers/gpu/drm/virtio/virtgpu_vq.c | 265 +++++++++++++++ include/uapi/drm/Kbuild | 1 + include/uapi/drm/virtgpu_drm.h | 167 ++++++++++ include/uapi/linux/virtio_gpu.h | 112 ++++++- 11 files changed, 1367 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/drm/virtio/virtgpu_ioctl.c create mode 100644 include/uapi/drm/virtgpu_drm.h
drivers/gpu/drm/virtio/Makefile +2 -1
@@ -6,6 +6,7 @@ ccflags-y := -Iinclude/drm virtio-gpu-y := virtgpu_drv.o virtgpu_kms.o virtgpu_drm_bus.o virtgpu_gem.o \ virtgpu_fb.o virtgpu_display.o virtgpu_vq.o virtgpu_ttm.o \ - virtgpu_fence.o virtgpu_object.o virtgpu_debugfs.o virtgpu_plane.o + virtgpu_fence.o virtgpu_object.o virtgpu_debugfs.o virtgpu_plane.o \ + virtgpu_ioctl.o obj-$(CONFIG_DRM_VIRTIO_GPU) += virtio-gpu.o
drivers/gpu/drm/virtio/virtgpu_drv.c +15 -0
@@ -73,6 +73,14 @@ static struct virtio_device_id id_table[] = { };static unsigned int features[] = { +#ifdef __LITTLE_ENDIAN +/* +* Gallium command stream send by virgl is native endian. +* Because of that we only support little endian guests on +* little endian hosts. +*/ +VIRTIO_GPU_F_VIRGL , +#endif };static struct virtio_driver virtio_gpu_driver = { .feature_table = features,
@@ -114,6 +122,8 @@ static struct drm_driver driver = { .set_busid = drm_virtio_set_busid, .load = virtio_gpu_driver_load, .unload = virtio_gpu_driver_unload, + .open = virtio_gpu_driver_open, + .postclose = virtio_gpu_driver_postclose, .dumb_create = virtio_gpu_mode_dumb_create, .dumb_map_offset = virtio_gpu_mode_dumb_mmap,
@@ -125,8 +135,13 @@ static struct drm_driver driver = {#endif .gem_free_object = virtio_gpu_gem_free_object, + .gem_open_object = virtio_gpu_gem_object_open, + .gem_close_object = virtio_gpu_gem_object_close, .fops = &virtio_gpu_driver_fops, + .ioctls = virtio_gpu_ioctls, + .num_ioctls = DRM_VIRTIO_NUM_IOCTLS, + .name = DRIVER_NAME, .desc = DRIVER_DESC, .date = DRIVER_DATE,
drivers/gpu/drm/virtio/virtgpu_drv.h +60 -0
95 lines not on this page · raw message
drivers/gpu/drm/virtio/virtgpu_gem.c +41 -0
44 lines not on this page · raw message
drivers/gpu/drm/virtio/virtgpu_ioctl.c new file +572 -0
572 lines not on this page · raw message
drivers/gpu/drm/virtio/virtgpu_kms.c +132 -1
184 lines not on this page · raw message
drivers/gpu/drm/virtio/virtgpu_ttm.c +1 -0
@@ -32,6 +32,7 @@#include <ttm/ttm_module.h> #include <drm/drmP.h> #include <drm/drm.h> +#include <drm/virtgpu_drm.h> #include "virtgpu_drv.h" #include <linux/delay.h>
drivers/gpu/drm/virtio/virtgpu_vq.c +265 -0
277 lines not on this page · raw message
include/uapi/drm/Kbuild +1 -0
@@ -17,3 +17,4 @@ header-y += tegra_drm.h header-y += via_drm.h header-y += vmwgfx_drm.h header-y += msm_drm.h +header-y += virtgpu_drm.h
include/uapi/drm/virtgpu_drm.h new file +167 -0
167 lines not on this page · raw message
include/uapi/linux/virtio_gpu.h +111 -1
142 lines not on this page · raw message
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v3 4/7 virtio-gpu: add 3d/virgl support
In reply to Gerd HoffmannAdd the bits needed for opengl rendering support: query capabilities, new virtio commands, drm ioctls.
--- drivers/gpu/drm/virtio/Makefile | 3 +- drivers/gpu/drm/virtio/virtgpu_drv.c | 15 + drivers/gpu/drm/virtio/virtgpu_drv.h | 60 ++++ drivers/gpu/drm/virtio/virtgpu_gem.c | 41 +++ drivers/gpu/drm/virtio/virtgpu_ioctl.c | 572 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/virtio/virtgpu_kms.c | 133 +++++++- drivers/gpu/drm/virtio/virtgpu_ttm.c | 1 + drivers/gpu/drm/virtio/virtgpu_vq.c | 265 +++++++++++++++ include/uapi/drm/Kbuild | 1 + include/uapi/drm/virtgpu_drm.h | 167 ++++++++++ include/uapi/linux/virtio_gpu.h | 112 ++++++- 11 files changed, 1367 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/drm/virtio/virtgpu_ioctl.c create mode 100644 include/uapi/drm/virtgpu_drm.h
drivers/gpu/drm/virtio/Makefile +2 -1
@@ -6,6 +6,7 @@ ccflags-y := -Iinclude/drm virtio-gpu-y := virtgpu_drv.o virtgpu_kms.o virtgpu_drm_bus.o virtgpu_gem.o \ virtgpu_fb.o virtgpu_display.o virtgpu_vq.o virtgpu_ttm.o \ - virtgpu_fence.o virtgpu_object.o virtgpu_debugfs.o virtgpu_plane.o + virtgpu_fence.o virtgpu_object.o virtgpu_debugfs.o virtgpu_plane.o \ + virtgpu_ioctl.o obj-$(CONFIG_DRM_VIRTIO_GPU) += virtio-gpu.o
drivers/gpu/drm/virtio/virtgpu_drv.c +15 -0
@@ -73,6 +73,14 @@ static struct virtio_device_id id_table[] = { };static unsigned int features[] = { +#ifdef __LITTLE_ENDIAN +/* +* Gallium command stream send by virgl is native endian. +* Because of that we only support little endian guests on +* little endian hosts. +*/ +VIRTIO_GPU_F_VIRGL , +#endif };static struct virtio_driver virtio_gpu_driver = { .feature_table = features,
@@ -114,6 +122,8 @@ static struct drm_driver driver = { .set_busid = drm_virtio_set_busid, .load = virtio_gpu_driver_load, .unload = virtio_gpu_driver_unload, + .open = virtio_gpu_driver_open, + .postclose = virtio_gpu_driver_postclose, .dumb_create = virtio_gpu_mode_dumb_create, .dumb_map_offset = virtio_gpu_mode_dumb_mmap,
@@ -125,8 +135,13 @@ static struct drm_driver driver = {#endif .gem_free_object = virtio_gpu_gem_free_object, + .gem_open_object = virtio_gpu_gem_object_open, + .gem_close_object = virtio_gpu_gem_object_close, .fops = &virtio_gpu_driver_fops, + .ioctls = virtio_gpu_ioctls, + .num_ioctls = DRM_VIRTIO_NUM_IOCTLS, + .name = DRIVER_NAME, .desc = DRIVER_DESC, .date = DRIVER_DATE,
drivers/gpu/drm/virtio/virtgpu_drv.h +60 -0
95 lines not on this page · raw message
drivers/gpu/drm/virtio/virtgpu_gem.c +41 -0
44 lines not on this page · raw message
drivers/gpu/drm/virtio/virtgpu_ioctl.c new file +572 -0
572 lines not on this page · raw message
drivers/gpu/drm/virtio/virtgpu_kms.c +132 -1
184 lines not on this page · raw message
drivers/gpu/drm/virtio/virtgpu_ttm.c +1 -0
@@ -32,6 +32,7 @@#include <ttm/ttm_module.h> #include <drm/drmP.h> #include <drm/drm.h> +#include <drm/virtgpu_drm.h> #include "virtgpu_drv.h" #include <linux/delay.h>
drivers/gpu/drm/virtio/virtgpu_vq.c +265 -0
277 lines not on this page · raw message
include/uapi/drm/Kbuild +1 -0
@@ -17,3 +17,4 @@ header-y += tegra_drm.h header-y += via_drm.h header-y += vmwgfx_drm.h header-y += msm_drm.h +header-y += virtgpu_drm.h
include/uapi/drm/virtgpu_drm.h new file +167 -0
167 lines not on this page · raw message
include/uapi/linux/virtio_gpu.h +111 -1
142 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Gerd Hoffmann
maintainerPATCH v3 5/7 virtio-gpu: add basic prime support
In reply to Gerd HoffmannFrom: Dave Airlie <[email protected]>
This is enough to enable DRI3.
--- drivers/gpu/drm/virtio/Makefile | 2 +- drivers/gpu/drm/virtio/virtgpu_drv.c | 13 ++++++- drivers/gpu/drm/virtio/virtgpu_drv.h | 12 ++++++ drivers/gpu/drm/virtio/virtgpu_prime.c | 71 ++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/virtio/virtgpu_prime.c
drivers/gpu/drm/virtio/Makefile +1 -1
@@ -7,6 +7,6 @@ ccflags-y := -Iinclude/drm virtio-gpu-y := virtgpu_drv.o virtgpu_kms.o virtgpu_drm_bus.o virtgpu_gem.o \ virtgpu_fb.o virtgpu_display.o virtgpu_vq.o virtgpu_ttm.o \ virtgpu_fence.o virtgpu_object.o virtgpu_debugfs.o virtgpu_plane.o \ - virtgpu_ioctl.o + virtgpu_ioctl.o virtgpu_prime.o obj-$(CONFIG_DRM_VIRTIO_GPU) += virtio-gpu.o
drivers/gpu/drm/virtio/virtgpu_drv.c +12 -1
@@ -118,7 +118,7 @@ static const struct file_operations virtio_gpu_driver_fops = {static struct drm_driver driver = { - .driver_features =DRIVER_MODESET |DRIVER_GEM , + .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_PRIME , .set_busid = drm_virtio_set_busid, .load = virtio_gpu_driver_load, .unload = virtio_gpu_driver_unload,
@@ -133,6 +133,17 @@ static struct drm_driver driver = { .debugfs_init = virtio_gpu_debugfs_init, .debugfs_cleanup = virtio_gpu_debugfs_takedown, #endif + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_export = drm_gem_prime_export, + .gem_prime_import = drm_gem_prime_import, + .gem_prime_pin = virtgpu_gem_prime_pin, + .gem_prime_unpin = virtgpu_gem_prime_unpin, + .gem_prime_get_sg_table = virtgpu_gem_prime_get_sg_table, + .gem_prime_import_sg_table = virtgpu_gem_prime_import_sg_table, + .gem_prime_vmap = virtgpu_gem_prime_vmap, + .gem_prime_vunmap = virtgpu_gem_prime_vunmap, + .gem_prime_mmap = virtgpu_gem_prime_mmap, .gem_free_object = virtio_gpu_gem_free_object, .gem_open_object = virtio_gpu_gem_object_open,
drivers/gpu/drm/virtio/virtgpu_drv.h +12 -0
@@ -359,6 +359,18 @@ int virtio_gpu_object_get_sg_table(struct virtio_gpu_device *qdev,void virtio_gpu_object_free_sg_table (struct virtio_gpu_object *bo);int virtio_gpu_object_wait (struct virtio_gpu_object *bo,bool no_wait); +/* virtgpu_prime.c */ +int virtgpu_gem_prime_pin (struct drm_gem_object *obj); +void virtgpu_gem_prime_unpin (struct drm_gem_object *obj); +struct sg_table *virtgpu_gem_prime_get_sg_table (struct drm_gem_object *obj); +struct drm_gem_object *virtgpu_gem_prime_import_sg_table ( +struct drm_device *dev,struct dma_buf_attachment *attach, +struct sg_table *sgt); +void *virtgpu_gem_prime_vmap (struct drm_gem_object *obj); +void virtgpu_gem_prime_vunmap (struct drm_gem_object *obj,void *vaddr); +int virtgpu_gem_prime_mmap (struct drm_gem_object *obj, +struct vm_area_struct *vma); +static inline struct virtio_gpu_object *virtio_gpu_object_ref (struct virtio_gpu_object *bo) {
drivers/gpu/drm/virtio/virtgpu_prime.c new file +71 -0
71 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Gerd Hoffmann
maintainerPATCH v3 5/7 virtio-gpu: add basic prime support
In reply to Gerd HoffmannFrom: Dave Airlie <[email protected]>
This is enough to enable DRI3.
--- drivers/gpu/drm/virtio/Makefile | 2 +- drivers/gpu/drm/virtio/virtgpu_drv.c | 13 ++++++- drivers/gpu/drm/virtio/virtgpu_drv.h | 12 ++++++ drivers/gpu/drm/virtio/virtgpu_prime.c | 71 ++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/virtio/virtgpu_prime.c
drivers/gpu/drm/virtio/Makefile +1 -1
@@ -7,6 +7,6 @@ ccflags-y := -Iinclude/drm virtio-gpu-y := virtgpu_drv.o virtgpu_kms.o virtgpu_drm_bus.o virtgpu_gem.o \ virtgpu_fb.o virtgpu_display.o virtgpu_vq.o virtgpu_ttm.o \ virtgpu_fence.o virtgpu_object.o virtgpu_debugfs.o virtgpu_plane.o \ - virtgpu_ioctl.o + virtgpu_ioctl.o virtgpu_prime.o obj-$(CONFIG_DRM_VIRTIO_GPU) += virtio-gpu.o
drivers/gpu/drm/virtio/virtgpu_drv.c +12 -1
@@ -118,7 +118,7 @@ static const struct file_operations virtio_gpu_driver_fops = {static struct drm_driver driver = { - .driver_features =DRIVER_MODESET |DRIVER_GEM , + .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_PRIME , .set_busid = drm_virtio_set_busid, .load = virtio_gpu_driver_load, .unload = virtio_gpu_driver_unload,
@@ -133,6 +133,17 @@ static struct drm_driver driver = { .debugfs_init = virtio_gpu_debugfs_init, .debugfs_cleanup = virtio_gpu_debugfs_takedown, #endif + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_export = drm_gem_prime_export, + .gem_prime_import = drm_gem_prime_import, + .gem_prime_pin = virtgpu_gem_prime_pin, + .gem_prime_unpin = virtgpu_gem_prime_unpin, + .gem_prime_get_sg_table = virtgpu_gem_prime_get_sg_table, + .gem_prime_import_sg_table = virtgpu_gem_prime_import_sg_table, + .gem_prime_vmap = virtgpu_gem_prime_vmap, + .gem_prime_vunmap = virtgpu_gem_prime_vunmap, + .gem_prime_mmap = virtgpu_gem_prime_mmap, .gem_free_object = virtio_gpu_gem_free_object, .gem_open_object = virtio_gpu_gem_object_open,
drivers/gpu/drm/virtio/virtgpu_drv.h +12 -0
@@ -359,6 +359,18 @@ int virtio_gpu_object_get_sg_table(struct virtio_gpu_device *qdev,void virtio_gpu_object_free_sg_table (struct virtio_gpu_object *bo);int virtio_gpu_object_wait (struct virtio_gpu_object *bo,bool no_wait); +/* virtgpu_prime.c */ +int virtgpu_gem_prime_pin (struct drm_gem_object *obj); +void virtgpu_gem_prime_unpin (struct drm_gem_object *obj); +struct sg_table *virtgpu_gem_prime_get_sg_table (struct drm_gem_object *obj); +struct drm_gem_object *virtgpu_gem_prime_import_sg_table ( +struct drm_device *dev,struct dma_buf_attachment *attach, +struct sg_table *sgt); +void *virtgpu_gem_prime_vmap (struct drm_gem_object *obj); +void virtgpu_gem_prime_vunmap (struct drm_gem_object *obj,void *vaddr); +int virtgpu_gem_prime_mmap (struct drm_gem_object *obj, +struct vm_area_struct *vma); +static inline struct virtio_gpu_object *virtio_gpu_object_ref (struct virtio_gpu_object *bo) {
drivers/gpu/drm/virtio/virtgpu_prime.c new file +71 -0
71 lines not on this page · raw message
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v3 6/7 virtio-gpu: mark as a render gpu
In reply to Gerd HoffmannFrom: Dave Airlie <[email protected]>
Also add DRM_RENDER_ALLOW to the ioctls.
--- drivers/gpu/drm/virtio/virtgpu_drv.c | 2 +- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/virtio/virtgpu_drv.c +1 -1
@@ -118,7 +118,7 @@ static const struct file_operations virtio_gpu_driver_fops = {static struct drm_driver driver = { - .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_PRIME , + .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_PRIME |DRIVER_RENDER , .set_busid = drm_virtio_set_busid, .load = virtio_gpu_driver_load, .unload = virtio_gpu_driver_unload,
drivers/gpu/drm/virtio/virtgpu_ioctl.c +9 -9
@@ -540,33 +540,33 @@ copy_exit:struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS ] = {DRM_IOCTL_DEF_DRV (VIRTGPU_MAP , virtio_gpu_map_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (VIRTGPU_EXECBUFFER , virtio_gpu_execbuffer_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (VIRTGPU_GETPARAM , virtio_gpu_getparam_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (VIRTGPU_RESOURCE_CREATE , virtio_gpu_resource_create_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (VIRTGPU_RESOURCE_INFO , virtio_gpu_resource_info_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),/* make transfer async to the main ring? - no sure, can we thread these in the underlying GL */ DRM_IOCTL_DEF_DRV (VIRTGPU_TRANSFER_FROM_HOST , virtio_gpu_transfer_from_host_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (VIRTGPU_TRANSFER_TO_HOST , virtio_gpu_transfer_to_host_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (VIRTGPU_WAIT , virtio_gpu_wait_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (VIRTGPU_GET_CAPS , virtio_gpu_get_caps_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ), };
Signature · 1 line
1.8.3.1
Gerd Hoffmann
maintainerPATCH v3 6/7 virtio-gpu: mark as a render gpu
In reply to Gerd HoffmannFrom: Dave Airlie <[email protected]>
Also add DRM_RENDER_ALLOW to the ioctls.
--- drivers/gpu/drm/virtio/virtgpu_drv.c | 2 +- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/virtio/virtgpu_drv.c +1 -1
@@ -118,7 +118,7 @@ static const struct file_operations virtio_gpu_driver_fops = {static struct drm_driver driver = { - .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_PRIME , + .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_PRIME |DRIVER_RENDER , .set_busid = drm_virtio_set_busid, .load = virtio_gpu_driver_load, .unload = virtio_gpu_driver_unload,
drivers/gpu/drm/virtio/virtgpu_ioctl.c +9 -9
@@ -540,33 +540,33 @@ copy_exit:struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS ] = {DRM_IOCTL_DEF_DRV (VIRTGPU_MAP , virtio_gpu_map_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (VIRTGPU_EXECBUFFER , virtio_gpu_execbuffer_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (VIRTGPU_GETPARAM , virtio_gpu_getparam_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (VIRTGPU_RESOURCE_CREATE , virtio_gpu_resource_create_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (VIRTGPU_RESOURCE_INFO , virtio_gpu_resource_info_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),/* make transfer async to the main ring? - no sure, can we thread these in the underlying GL */ DRM_IOCTL_DEF_DRV (VIRTGPU_TRANSFER_FROM_HOST , virtio_gpu_transfer_from_host_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (VIRTGPU_TRANSFER_TO_HOST , virtio_gpu_transfer_to_host_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (VIRTGPU_WAIT , virtio_gpu_wait_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (VIRTGPU_GET_CAPS , virtio_gpu_get_caps_ioctl, -DRM_AUTH |DRM_UNLOCKED ), +DRM_AUTH |DRM_UNLOCKED |DRM_RENDER_ALLOW ), };
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v3 7/7 virtio-gpu: add page flip support
In reply to Gerd Hoffmann--- drivers/gpu/drm/virtio/virtgpu_display.c | 49 ++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-)
drivers/gpu/drm/virtio/virtgpu_display.c +46 -3
@@ -125,6 +125,51 @@ static int virtio_gpu_crtc_cursor_move(struct drm_crtc *crtc,return 0 ; } +static int virtio_gpu_page_flip (struct drm_crtc *crtc, +struct drm_framebuffer *fb, +struct drm_pending_vblank_event *event, +uint32_t flags) +{ +struct virtio_gpu_device *vgdev = crtc->dev->dev_private; +struct virtio_gpu_output *output = + container_of(crtc, struct virtio_gpu_output, crtc); +struct drm_plane *plane = crtc->primary; +struct virtio_gpu_framebuffer *vgfb; +struct virtio_gpu_object *bo; +unsigned long irqflags; +uint32_t handle; + + plane->fb = fb; + vgfb =to_virtio_gpu_framebuffer (plane->fb); + bo =gem_to_virtio_gpu_obj (vgfb->obj); + handle = bo->hw_res_handle; + +DRM_DEBUG ("handle 0x%x%s, crtc %dx%d\n" , handle, + bo->dumb ?", dumb" :"" , + crtc->mode.hdisplay, crtc->mode.vdisplay); +if (bo->dumb) { +virtio_gpu_cmd_transfer_to_host_2d + (vgdev, handle,0 , +cpu_to_le32 (crtc->mode.hdisplay), +cpu_to_le32 (crtc->mode.vdisplay), +0 ,0 ,NULL ); + } +virtio_gpu_cmd_set_scanout (vgdev, output->index, handle, + crtc->mode.hdisplay, + crtc->mode.vdisplay,0 ,0 ); +virtio_gpu_cmd_resource_flush (vgdev, handle,0 ,0 , + crtc->mode.hdisplay, + crtc->mode.vdisplay); + +if (event) { +spin_lock_irqsave (&crtc->dev->event_lock, irqflags); +drm_send_vblank_event (crtc->dev,-1 , event); +spin_unlock_irqrestore (&crtc->dev->event_lock, irqflags); + } + +return 0 ; +} +static const struct drm_crtc_funcs virtio_gpu_crtc_funcs = { .cursor_set2 = virtio_gpu_crtc_cursor_set, .cursor_move = virtio_gpu_crtc_cursor_move,
@@ -132,9 +177,7 @@ static const struct drm_crtc_funcs virtio_gpu_crtc_funcs = { .set_config = drm_atomic_helper_set_config, .destroy = drm_crtc_cleanup, -#if 0 /* not (yet) working without vblank support according to docs */ - .page_flip = drm_atomic_helper_page_flip, -#endif + .page_flip = virtio_gpu_page_flip, .reset = drm_atomic_helper_crtc_reset, .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
Signature · 1 line
1.8.3.1
Gerd Hoffmann
maintainerPATCH v3 7/7 virtio-gpu: add page flip support
In reply to Gerd Hoffmann--- drivers/gpu/drm/virtio/virtgpu_display.c | 49 ++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-)
drivers/gpu/drm/virtio/virtgpu_display.c +46 -3
@@ -125,6 +125,51 @@ static int virtio_gpu_crtc_cursor_move(struct drm_crtc *crtc,return 0 ; } +static int virtio_gpu_page_flip (struct drm_crtc *crtc, +struct drm_framebuffer *fb, +struct drm_pending_vblank_event *event, +uint32_t flags) +{ +struct virtio_gpu_device *vgdev = crtc->dev->dev_private; +struct virtio_gpu_output *output = + container_of(crtc, struct virtio_gpu_output, crtc); +struct drm_plane *plane = crtc->primary; +struct virtio_gpu_framebuffer *vgfb; +struct virtio_gpu_object *bo; +unsigned long irqflags; +uint32_t handle; + + plane->fb = fb; + vgfb =to_virtio_gpu_framebuffer (plane->fb); + bo =gem_to_virtio_gpu_obj (vgfb->obj); + handle = bo->hw_res_handle; + +DRM_DEBUG ("handle 0x%x%s, crtc %dx%d\n" , handle, + bo->dumb ?", dumb" :"" , + crtc->mode.hdisplay, crtc->mode.vdisplay); +if (bo->dumb) { +virtio_gpu_cmd_transfer_to_host_2d + (vgdev, handle,0 , +cpu_to_le32 (crtc->mode.hdisplay), +cpu_to_le32 (crtc->mode.vdisplay), +0 ,0 ,NULL ); + } +virtio_gpu_cmd_set_scanout (vgdev, output->index, handle, + crtc->mode.hdisplay, + crtc->mode.vdisplay,0 ,0 ); +virtio_gpu_cmd_resource_flush (vgdev, handle,0 ,0 , + crtc->mode.hdisplay, + crtc->mode.vdisplay); + +if (event) { +spin_lock_irqsave (&crtc->dev->event_lock, irqflags); +drm_send_vblank_event (crtc->dev,-1 , event); +spin_unlock_irqrestore (&crtc->dev->event_lock, irqflags); + } + +return 0 ; +} +static const struct drm_crtc_funcs virtio_gpu_crtc_funcs = { .cursor_set2 = virtio_gpu_crtc_cursor_set, .cursor_move = virtio_gpu_crtc_cursor_move,
@@ -132,9 +177,7 @@ static const struct drm_crtc_funcs virtio_gpu_crtc_funcs = { .set_config = drm_atomic_helper_set_config, .destroy = drm_crtc_cleanup, -#if 0 /* not (yet) working without vblank support according to docs */ - .page_flip = drm_atomic_helper_page_flip, -#endif + .page_flip = virtio_gpu_page_flip, .reset = drm_atomic_helper_crtc_reset, .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
Quoted 1 line · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>
So I entirely missed this, but this isn't really how to implement page_flip for an atomic driver. Working on some stuff and will hack up a likely totally broken patch, but should be enough as guideline. -Daniel
Quoted 78 lines
--- drivers/gpu/drm/virtio/virtgpu_display.c | 49 ++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-)drivers/gpu/drm/virtio/virtgpu_display.c +46
-4@@ -125,6 +125,51 @@ static int virtio_gpu_crtc_cursor_move(struct drm_crtc *crtc,return 0 ; } +static int virtio_gpu_page_flip (struct drm_crtc *crtc, +struct drm_framebuffer *fb, +struct drm_pending_vblank_event *event, +uint32_t flags) +{ +struct virtio_gpu_device *vgdev = crtc->dev->dev_private; +struct virtio_gpu_output *output = + container_of(crtc, struct virtio_gpu_output, crtc); +struct drm_plane *plane = crtc->primary; +struct virtio_gpu_framebuffer *vgfb; +struct virtio_gpu_object *bo; +unsigned long irqflags; +uint32_t handle; + + plane->fb = fb; + vgfb =to_virtio_gpu_framebuffer (plane->fb); + bo =gem_to_virtio_gpu_obj (vgfb->obj); + handle = bo->hw_res_handle; + +DRM_DEBUG ("handle 0x%x%s, crtc %dx%d\n" , handle, + bo->dumb ?", dumb" :"" , + crtc->mode.hdisplay, crtc->mode.vdisplay); +if (bo->dumb) { +virtio_gpu_cmd_transfer_to_host_2d + (vgdev, handle,0 , +cpu_to_le32 (crtc->mode.hdisplay), +cpu_to_le32 (crtc->mode.vdisplay), +0 ,0 ,NULL ); + } +virtio_gpu_cmd_set_scanout (vgdev, output->index, handle, + crtc->mode.hdisplay, + crtc->mode.vdisplay,0 ,0 ); +virtio_gpu_cmd_resource_flush (vgdev, handle,0 ,0 , + crtc->mode.hdisplay, + crtc->mode.vdisplay); + +if (event) { +spin_lock_irqsave (&crtc->dev->event_lock, irqflags); +drm_send_vblank_event (crtc->dev,-1 , event); +spin_unlock_irqrestore (&crtc->dev->event_lock, irqflags); + } + +return 0 ; +} +static const struct drm_crtc_funcs virtio_gpu_crtc_funcs = { .cursor_set2 = virtio_gpu_crtc_cursor_set, .cursor_move = virtio_gpu_crtc_cursor_move,@@ -132,9 +177,7 @@ static const struct drm_crtc_funcs virtio_gpu_crtc_funcs = { .set_config = drm_atomic_helper_set_config, .destroy = drm_crtc_cleanup, -#if 0 /* not (yet) working without vblank support according to docs */ - .page_flip = drm_atomic_helper_page_flip, -#endif + .page_flip = virtio_gpu_page_flip, .reset = drm_atomic_helper_crtc_reset, .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, --1.8.3.1
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
In reply to Gerd HoffmannQuoted 1 line · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>
So I entirely missed this, but this isn't really how to implement page_flip for an atomic driver. Working on some stuff and will hack up a likely totally broken patch, but should be enough as guideline. -Daniel
Quoted 78 lines
--- drivers/gpu/drm/virtio/virtgpu_display.c | 49 ++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-)drivers/gpu/drm/virtio/virtgpu_display.c +46
-4@@ -125,6 +125,51 @@ static int virtio_gpu_crtc_cursor_move(struct drm_crtc *crtc,return 0 ; } +static int virtio_gpu_page_flip (struct drm_crtc *crtc, +struct drm_framebuffer *fb, +struct drm_pending_vblank_event *event, +uint32_t flags) +{ +struct virtio_gpu_device *vgdev = crtc->dev->dev_private; +struct virtio_gpu_output *output = + container_of(crtc, struct virtio_gpu_output, crtc); +struct drm_plane *plane = crtc->primary; +struct virtio_gpu_framebuffer *vgfb; +struct virtio_gpu_object *bo; +unsigned long irqflags; +uint32_t handle; + + plane->fb = fb; + vgfb =to_virtio_gpu_framebuffer (plane->fb); + bo =gem_to_virtio_gpu_obj (vgfb->obj); + handle = bo->hw_res_handle; + +DRM_DEBUG ("handle 0x%x%s, crtc %dx%d\n" , handle, + bo->dumb ?", dumb" :"" , + crtc->mode.hdisplay, crtc->mode.vdisplay); +if (bo->dumb) { +virtio_gpu_cmd_transfer_to_host_2d + (vgdev, handle,0 , +cpu_to_le32 (crtc->mode.hdisplay), +cpu_to_le32 (crtc->mode.vdisplay), +0 ,0 ,NULL ); + } +virtio_gpu_cmd_set_scanout (vgdev, output->index, handle, + crtc->mode.hdisplay, + crtc->mode.vdisplay,0 ,0 ); +virtio_gpu_cmd_resource_flush (vgdev, handle,0 ,0 , + crtc->mode.hdisplay, + crtc->mode.vdisplay); + +if (event) { +spin_lock_irqsave (&crtc->dev->event_lock, irqflags); +drm_send_vblank_event (crtc->dev,-1 , event); +spin_unlock_irqrestore (&crtc->dev->event_lock, irqflags); + } + +return 0 ; +} +static const struct drm_crtc_funcs virtio_gpu_crtc_funcs = { .cursor_set2 = virtio_gpu_crtc_cursor_set, .cursor_move = virtio_gpu_crtc_cursor_move,@@ -132,9 +177,7 @@ static const struct drm_crtc_funcs virtio_gpu_crtc_funcs = { .set_config = drm_atomic_helper_set_config, .destroy = drm_crtc_cleanup, -#if 0 /* not (yet) working without vblank support according to docs */ - .page_flip = drm_atomic_helper_page_flip, -#endif + .page_flip = virtio_gpu_page_flip, .reset = drm_atomic_helper_crtc_reset, .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, --1.8.3.1
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerRe: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
Quoted 7 lines · Daniel Vetter
Quoted 1 line · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>So I entirely missed this, but this isn't really how to implement
page_flipfor an atomic driver. Working on some stuff and will hack up a likely totally broken patch, but should be enough as guideline. -Daniel
Hmm, no patch in my inbox yet. Care to send it over or give some hints what is wrong with this?
thanks,
Gerd
Re: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
Quoted 11 lines · Gerd Hoffmann
Quoted 7 lines · Daniel Vetter
Quoted 1 line · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>So I entirely missed this, but this isn't really how to implement
page_flipfor an atomic driver. Working on some stuff and will hack up a likely totally broken patch, but should be enough as guideline. -DanielHmm, no patch in my inbox yet. Care to send it over or give some hints what is wrong with this?
You should use drm_atomic_helper_page_flip as .page_flip hook instead of rolling your own, when you have a brand-new atomic driver. If that helper doesn't work that means you have a bug in your driver somewhere.
And indeed virtio just plugs in drm_atomic_helper_commit, which thus far doesnt' do nonblocking commits, which means the page flip stuff won't work. I'm working on generic nonblocking atomic to fix this up. Currently still wip and buggy though, hence no patches.
But I'll take you up on the implied offer to help out and test ;-) -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
In reply to Gerd HoffmannQuoted 11 lines · Gerd Hoffmann
Quoted 7 lines · Daniel Vetter
Quoted 1 line · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>So I entirely missed this, but this isn't really how to implement
page_flipfor an atomic driver. Working on some stuff and will hack up a likely totally broken patch, but should be enough as guideline. -DanielHmm, no patch in my inbox yet. Care to send it over or give some hints what is wrong with this?
You should use drm_atomic_helper_page_flip as .page_flip hook instead of rolling your own, when you have a brand-new atomic driver. If that helper doesn't work that means you have a bug in your driver somewhere.
And indeed virtio just plugs in drm_atomic_helper_commit, which thus far doesnt' do nonblocking commits, which means the page flip stuff won't work. I'm working on generic nonblocking atomic to fix this up. Currently still wip and buggy though, hence no patches.
But I'll take you up on the implied offer to help out and test ;-) -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
Quoted 17 lines · Daniel Vetter
Quoted 11 lines · Gerd Hoffmann
Quoted 7 lines · Daniel Vetter
Quoted 1 line · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>So I entirely missed this, but this isn't really how to implement
page_flipfor an atomic driver. Working on some stuff and will hack up a likely totally broken patch, but should be enough as guideline. -DanielHmm, no patch in my inbox yet. Care to send it over or give some hints what is wrong with this?
You should use
drm_atomic_helper_page_flipas .page_flip hook instead of rolling your own, when you have a brand-new atomic driver. If that helper doesn't work that means you have a bug in your driver somewhere.
Quoted 6 lines
And indeed virtio just plugs in
drm_atomic_helper_commit, which thus far doesnt' do nonblocking commits, which means the page flip stuff won't work. I'm working on generic nonblocking atomic to fix this up. Currently still wip and buggy though, hence no patches.But I'll take you up on the implied offer to help out and test ;-)
Ok, patches are now on the list and also in my fdo repo at:
https://cgit.freedesktop.org/~danvet/drm/log/
git://people.freedesktop.org/~danvet/drm stuff
Would be really awesome if you could test this on virtio. Note that the new nonblocking helpers require that your atomic backend gets the drm event handling right. So if there's a bug in that logic then you'll see lots of dmesg noise about waits timing out (after 10s of waiting). From a quick inspection it should work though.
Upshot is that once you get normal modeset to work with those new helpers, then nonblocking should Just Work, and there's no need anymore for additional testing. Or at least shouldn't.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Gerd Hoffmann
maintainerRe: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
Hi,
Quoted 3 lines
Quoted 1 line
But I'll take you up on the implied offer to help out and test ;-)
git://people.freedesktop.org/~danvet/drmstuff
Tried that branch.
Quoted 5 lines
Would be really awesome if you could test this on virtio. Note that the new nonblocking helpers require that your atomic backend gets the drm event handling right. So if there's a bug in that logic then you'll see lots of dmesg noise about waits timing out (after 10s of waiting). From a quick inspection it should work though.
No timeouts. Yay!
But it seems crtcs can be (temporarely) disabled now, so we might have to pick up the crtc from old_state in virtio_gpu_plane_atomic_update to figure which virtual output needs to be turned off. Ran into this last week already. Happened with multihead setups only, but the same patch fixes this one too ;)
https://lists.freedesktop.org/archives/dri-devel/2016-May/108772.html
cheers,
Gerd
Re: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
Quoted 16 lines · Gerd Hoffmann
Hi,
Quoted 3 lines
Quoted 1 line
But I'll take you up on the implied offer to help out and test ;-)
git://people.freedesktop.org/~danvet/drmstuffTried that branch.
Quoted 5 lines
Would be really awesome if you could test this on virtio. Note that the new nonblocking helpers require that your atomic backend gets the drm event handling right. So if there's a bug in that logic then you'll see lots of dmesg noise about waits timing out (after 10s of waiting). From a quick inspection it should work though.
No timeouts. Yay!
Quoted 7 lines
But it seems crtcs can be (temporarely) disabled now, so we might have to pick up the crtc from
old_stateinvirtio_gpu_plane_atomic_updateto figure which virtual output needs to be turned off. Ran into this last week already. Happened with multihead setups only, but the same patch fixes this one too ;)https://lists.freedesktop.org/archives/dri-devel/2016-May/108772.html
Hm, smells more like virtio isn't too happy with the default ordering of the commit operation. The default is:
- Disable any crtc/encoders that need to be disabled/change.
- Bash new plane setup into hw.
- Enable all crtcs/encoders that need to be enabled/have changed.
There's two problems:
- some hw gets real grumpy if you bash in plane state without the crtc state yet matching.
- if you do runtime pm nothing is enabled and the writes get lost at best, or hang your interconnect at worst.
That's why you can overwrite atomic_commit_tail, and use something more sensible. See for example what it looks like for rockchip. I have a gut feeling that should also take care of your troubles. Using the old crtc is definitely not what you want.
Another option is that virtio isn't happy about bashing in plane state for disabled crtc. Again helpers have you covered, look at the active_only parameter for drm_atomic_helper_commit_planes().
Aside, if you wonder why these defaults: They match what the crtc helpers are doing, but they are a bit surprising indeed.
Cheers, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Gerd Hoffmann
maintainerRe: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
Hi,
Quoted 15 lines
Hm, smells more like virtio isn't too happy with the default ordering of the commit operation. The default is:
- Disable any crtc/encoders that need to be disabled/change.
- Bash new plane setup into hw.
- Enable all crtcs/encoders that need to be enabled/have changed.There's two problems:
- some hw gets real grumpy if you bash in plane state without the crtc state yet matching.
- if you do runtime pm nothing is enabled and the writes get lost at best, or hang your interconnect at worst.
Quoted 8 lines
That's why you can overwrite
atomic_commit_tail, and use something more sensible. See for example what it looks like for rockchip. I have a gut feeling that should also take care of your troubles. Using the old crtc is definitely not what you want.Another option is that virtio isn't happy about bashing in plane state for disabled crtc. Again helpers have you covered, look at the
active_onlyparameter fordrm_atomic_helper_commit_planes().
virtio-gpu is a bit simplified compared to real hardware, so there isn't really separate plane/crtc state.
Right now the virtual outputs are linked to drm_crtc. To apply any changes I need to lookup the crtc to figure which virtual output should be updated.
So, setting active_only should make sure I have a valid crtc pointer on plane updates, right? It probably also skips the disable + enable crtc steps on commit? What happens when outputs are disabled?
Maybe it makes sense to link our virtual outputs to (primary) planes not crtcs?
cheers,
Gerd
Gerd Hoffmann
maintainerRe: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
In reply to Daniel VetterHi,
Quoted 15 lines
Hm, smells more like virtio isn't too happy with the default ordering of the commit operation. The default is:
- Disable any crtc/encoders that need to be disabled/change.
- Bash new plane setup into hw.
- Enable all crtcs/encoders that need to be enabled/have changed.There's two problems:
- some hw gets real grumpy if you bash in plane state without the crtc state yet matching.
- if you do runtime pm nothing is enabled and the writes get lost at best, or hang your interconnect at worst.
Quoted 8 lines
That's why you can overwrite
atomic_commit_tail, and use something more sensible. See for example what it looks like for rockchip. I have a gut feeling that should also take care of your troubles. Using the old crtc is definitely not what you want.Another option is that virtio isn't happy about bashing in plane state for disabled crtc. Again helpers have you covered, look at the
active_onlyparameter fordrm_atomic_helper_commit_planes().
virtio-gpu is a bit simplified compared to real hardware, so there isn't really separate plane/crtc state.
Right now the virtual outputs are linked to drm_crtc. To apply any changes I need to lookup the crtc to figure which virtual output should be updated.
So, setting active_only should make sure I have a valid crtc pointer on plane updates, right? It probably also skips the disable + enable crtc steps on commit? What happens when outputs are disabled?
Maybe it makes sense to link our virtual outputs to (primary) planes not crtcs?
cheers,
Gerd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
Quoted 31 lines · Gerd Hoffmann
Quoted 15 lines
Hm, smells more like virtio isn't too happy with the default ordering of the commit operation. The default is:
- Disable any crtc/encoders that need to be disabled/change.
- Bash new plane setup into hw.
- Enable all crtcs/encoders that need to be enabled/have changed.There's two problems:
- some hw gets real grumpy if you bash in plane state without the crtc state yet matching.
- if you do runtime pm nothing is enabled and the writes get lost at best, or hang your interconnect at worst.Quoted 8 lines
That's why you can overwrite
atomic_commit_tail, and use something more sensible. See for example what it looks like for rockchip. I have a gut feeling that should also take care of your troubles. Using the old crtc is definitely not what you want.Another option is that virtio isn't happy about bashing in plane state for disabled crtc. Again helpers have you covered, look at the
active_onlyparameter fordrm_atomic_helper_commit_planes().virtio-gpu is a bit simplified compared to real hardware, so there isn't really separate plane/crtc state.
Right now the virtual outputs are linked to
drm_crtc. To apply any changes I need to lookup the crtc to figure which virtual output should be updated.
Quoted 6 lines
So, setting
active_onlyshould make sure I have a valid crtc pointer on plane updates, right? It probably also skips the disable + enable crtc steps on commit? What happens when outputs are disabled?Maybe it makes sense to link our virtual outputs to (primary) planes not crtcs?
Nah, I just misunderstood your patch. If it's all about finding the corresponding crtc, then you're all good. I thought there was some other reason (like the virtual hw getting upset about certain things). I'll pick up your patch into my nonblocking atomic branch to make sure virtio isn't accidentally broken. btw can you pls drop an ack or r-b onto my virtio conversion? I already added your tested-by.
Thanks, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Gerd Hoffmann
maintainerRe: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
Hi,
Quoted 10 lines
Quoted 7 lines
Right now the virtual outputs are linked to
drm_crtc. To apply any changes I need to lookup the crtc to figure which virtual output should be updated.So, setting
active_onlyshould make sure I have a valid crtc pointer on plane updates, right? It probably also skips the disable + enable crtc steps on commit? What happens when outputs are disabled?Nah, I just misunderstood your patch. If it's all about finding the corresponding crtc, then you're all good.
Yes, it's all about finding the crtc.
Quoted 2 lines
I thought there was some
other reason (like the virtual hw getting upset about certain things).
virtio wouldn't be upset.
It's a pointless exercise though to first disable the output, just to re-enable it the next moment with the new page-flipped framebuffer. So I guess I should look at the active_only thing nevertheless.
Quoted 2 lines
btw can you pls drop an ack or r-b
onto my virtio conversion? I already added your tested-by.
Grr, mail is not in my dri-devel folder. Guess that is the <censored> "avoid-duplicates" mailman option at work.
Feel free to just add the r-b too. Or I'll send it for the next version of the series.
cheers,
Gerd
Gerd Hoffmann
maintainerRe: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
In reply to Daniel VetterHi,
Quoted 10 lines
Quoted 7 lines
Right now the virtual outputs are linked to
drm_crtc. To apply any changes I need to lookup the crtc to figure which virtual output should be updated.So, setting
active_onlyshould make sure I have a valid crtc pointer on plane updates, right? It probably also skips the disable + enable crtc steps on commit? What happens when outputs are disabled?Nah, I just misunderstood your patch. If it's all about finding the corresponding crtc, then you're all good.
Yes, it's all about finding the crtc.
Quoted 2 lines
I thought there was some
other reason (like the virtual hw getting upset about certain things).
virtio wouldn't be upset.
It's a pointless exercise though to first disable the output, just to re-enable it the next moment with the new page-flipped framebuffer. So I guess I should look at the active_only thing nevertheless.
Quoted 2 lines
btw can you pls drop an ack or r-b
onto my virtio conversion? I already added your tested-by.
Grr, mail is not in my dri-devel folder. Guess that is the <censored> "avoid-duplicates" mailman option at work.
Feel free to just add the r-b too. Or I'll send it for the next version of the series.
cheers,
Gerd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
Quoted 15 lines · Gerd Hoffmann
Hi,
Quoted 10 lines
Quoted 7 lines
Right now the virtual outputs are linked to
drm_crtc. To apply any changes I need to lookup the crtc to figure which virtual output should be updated.So, setting
active_onlyshould make sure I have a valid crtc pointer on plane updates, right? It probably also skips the disable + enable crtc steps on commit? What happens when outputs are disabled?Nah, I just misunderstood your patch. If it's all about finding the corresponding crtc, then you're all good.
Yes, it's all about finding the crtc.
Quoted 8 lines
Quoted 2 lines
I thought there was some
other reason (like the virtual hw getting upset about certain things).virtio wouldn't be upset.
It's a pointless exercise though to first disable the output, just to re-enable it the next moment with the new page-flipped framebuffer. So I guess I should look at the
active_onlything nevertheless.
It's still possible that the plane can get disabled without it getting enabled. Userspace is allowed to do this. But since this suprises a lot of driver writers there's a special atomic_plane_disable hook you can use for the disable path. Instead of hand-rolling that check in your own code.
Quoted 8 lines
Quoted 2 lines
btw can you pls drop an ack or r-b
onto my virtio conversion? I already added your tested-by.Grr, mail is not in my dri-devel folder. Guess that is the <censored> "avoid-duplicates" mailman option at work.
Feel free to just add the r-b too. Or I'll send it for the next version of the series.
Added your r-b locally so it won't get lost on the next round.
Thanks, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
In reply to Gerd HoffmannQuoted 15 lines · Gerd Hoffmann
Hi,
Quoted 10 lines
Quoted 7 lines
Right now the virtual outputs are linked to
drm_crtc. To apply any changes I need to lookup the crtc to figure which virtual output should be updated.So, setting
active_onlyshould make sure I have a valid crtc pointer on plane updates, right? It probably also skips the disable + enable crtc steps on commit? What happens when outputs are disabled?Nah, I just misunderstood your patch. If it's all about finding the corresponding crtc, then you're all good.
Yes, it's all about finding the crtc.
Quoted 8 lines
Quoted 2 lines
I thought there was some
other reason (like the virtual hw getting upset about certain things).virtio wouldn't be upset.
It's a pointless exercise though to first disable the output, just to re-enable it the next moment with the new page-flipped framebuffer. So I guess I should look at the
active_onlything nevertheless.
It's still possible that the plane can get disabled without it getting enabled. Userspace is allowed to do this. But since this suprises a lot of driver writers there's a special atomic_plane_disable hook you can use for the disable path. Instead of hand-rolling that check in your own code.
Quoted 8 lines
Quoted 2 lines
btw can you pls drop an ack or r-b
onto my virtio conversion? I already added your tested-by.Grr, mail is not in my dri-devel folder. Guess that is the <censored> "avoid-duplicates" mailman option at work.
Feel free to just add the r-b too. Or I'll send it for the next version of the series.
Added your r-b locally so it won't get lost on the next round.
Thanks, Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
In reply to Gerd HoffmannQuoted 31 lines · Gerd Hoffmann
Quoted 15 lines
Hm, smells more like virtio isn't too happy with the default ordering of the commit operation. The default is:
- Disable any crtc/encoders that need to be disabled/change.
- Bash new plane setup into hw.
- Enable all crtcs/encoders that need to be enabled/have changed.There's two problems:
- some hw gets real grumpy if you bash in plane state without the crtc state yet matching.
- if you do runtime pm nothing is enabled and the writes get lost at best, or hang your interconnect at worst.Quoted 8 lines
That's why you can overwrite
atomic_commit_tail, and use something more sensible. See for example what it looks like for rockchip. I have a gut feeling that should also take care of your troubles. Using the old crtc is definitely not what you want.Another option is that virtio isn't happy about bashing in plane state for disabled crtc. Again helpers have you covered, look at the
active_onlyparameter fordrm_atomic_helper_commit_planes().virtio-gpu is a bit simplified compared to real hardware, so there isn't really separate plane/crtc state.
Right now the virtual outputs are linked to
drm_crtc. To apply any changes I need to lookup the crtc to figure which virtual output should be updated.
Quoted 6 lines
So, setting
active_onlyshould make sure I have a valid crtc pointer on plane updates, right? It probably also skips the disable + enable crtc steps on commit? What happens when outputs are disabled?Maybe it makes sense to link our virtual outputs to (primary) planes not crtcs?
Nah, I just misunderstood your patch. If it's all about finding the corresponding crtc, then you're all good. I thought there was some other reason (like the virtual hw getting upset about certain things). I'll pick up your patch into my nonblocking atomic branch to make sure virtio isn't accidentally broken. btw can you pls drop an ack or r-b onto my virtio conversion? I already added your tested-by.
Thanks, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
In reply to Gerd HoffmannQuoted 16 lines · Gerd Hoffmann
Hi,
Quoted 3 lines
Quoted 1 line
But I'll take you up on the implied offer to help out and test ;-)
git://people.freedesktop.org/~danvet/drmstuffTried that branch.
Quoted 5 lines
Would be really awesome if you could test this on virtio. Note that the new nonblocking helpers require that your atomic backend gets the drm event handling right. So if there's a bug in that logic then you'll see lots of dmesg noise about waits timing out (after 10s of waiting). From a quick inspection it should work though.
No timeouts. Yay!
Quoted 7 lines
But it seems crtcs can be (temporarely) disabled now, so we might have to pick up the crtc from
old_stateinvirtio_gpu_plane_atomic_updateto figure which virtual output needs to be turned off. Ran into this last week already. Happened with multihead setups only, but the same patch fixes this one too ;)https://lists.freedesktop.org/archives/dri-devel/2016-May/108772.html
Hm, smells more like virtio isn't too happy with the default ordering of the commit operation. The default is:
- Disable any crtc/encoders that need to be disabled/change.
- Bash new plane setup into hw.
- Enable all crtcs/encoders that need to be enabled/have changed.
There's two problems:
- some hw gets real grumpy if you bash in plane state without the crtc state yet matching.
- if you do runtime pm nothing is enabled and the writes get lost at best, or hang your interconnect at worst.
That's why you can overwrite atomic_commit_tail, and use something more sensible. See for example what it looks like for rockchip. I have a gut feeling that should also take care of your troubles. Using the old crtc is definitely not what you want.
Another option is that virtio isn't happy about bashing in plane state for disabled crtc. Again helpers have you covered, look at the active_only parameter for drm_atomic_helper_commit_planes().
Aside, if you wonder why these defaults: They match what the crtc helpers are doing, but they are a bit surprising indeed.
Cheers, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
In reply to Daniel VetterQuoted 17 lines · Daniel Vetter
Quoted 11 lines · Gerd Hoffmann
Quoted 7 lines · Daniel Vetter
Quoted 1 line · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>So I entirely missed this, but this isn't really how to implement
page_flipfor an atomic driver. Working on some stuff and will hack up a likely totally broken patch, but should be enough as guideline. -DanielHmm, no patch in my inbox yet. Care to send it over or give some hints what is wrong with this?
You should use
drm_atomic_helper_page_flipas .page_flip hook instead of rolling your own, when you have a brand-new atomic driver. If that helper doesn't work that means you have a bug in your driver somewhere.
Quoted 6 lines
And indeed virtio just plugs in
drm_atomic_helper_commit, which thus far doesnt' do nonblocking commits, which means the page flip stuff won't work. I'm working on generic nonblocking atomic to fix this up. Currently still wip and buggy though, hence no patches.But I'll take you up on the implied offer to help out and test ;-)
Ok, patches are now on the list and also in my fdo repo at:
https://cgit.freedesktop.org/~danvet/drm/log/
git://people.freedesktop.org/~danvet/drm stuff
Would be really awesome if you could test this on virtio. Note that the new nonblocking helpers require that your atomic backend gets the drm event handling right. So if there's a bug in that logic then you'll see lots of dmesg noise about waits timing out (after 10s of waiting). From a quick inspection it should work though.
Upshot is that once you get normal modeset to work with those new helpers, then nonblocking should Just Work, and there's no need anymore for additional testing. Or at least shouldn't.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Gerd Hoffmann
maintainerRe: [PATCH v3 7/7] [wip] virtio-gpu: add page flip support
In reply to Daniel VetterQuoted 7 lines · Daniel Vetter
Quoted 1 line · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>So I entirely missed this, but this isn't really how to implement
page_flipfor an atomic driver. Working on some stuff and will hack up a likely totally broken patch, but should be enough as guideline. -Daniel
Hmm, no patch in my inbox yet. Care to send it over or give some hints what is wrong with this?
thanks,
Gerd