drm/virtio: Add drm_panic support
Subsystems (4)
PATCH v7 1/1 drm/virtio: Add drm_panic support
Virtio gpu supports the drm_panic module, which displays a message to the screen when a kernel panic occurs. It is supported where it has vmapped shmem BO.
---
v7:
- Reject no vmapped shmem BO. Also, insert comment and commit log about it.
- Restore MAX_INLINE_* and VBUFFER_SIZE definitions to the old place
v6:
https://lore.kernel.org/all/CAHpthZo=R=Csru2P8NVY8YKaasb2RTyrMYni-=8ri4K=xd8abA@mail.gmail.com/
Based on Dmitry's comment, fix the followings
- Reject external dmabufs backing the GEM object
- Allocate vbuf with kmem_cache_zalloc(..., GFP_ATOMIC) instead of drmm_kzalloc().
v5:
https://lore.kernel.org/all/CAHpthZrZ6DjsCQ4baQ80b2vOTdkR=vHDx=10W7DTS4ohxb6=pg@mail.gmail.com/
Based on Dmitry's comment, fix the followings
- Rename virtio_panic_buffer to panic_vbuf
- Remove some unnecessary dummy ret and return directly.
- Reject if the bo is VRAM BO
- Remove virtio_gpu_panic_put_vbuf() before notify
- Add description for panic buffer allocation
- Remove virtio_gpu_panic_object_array and use virtio_gpu_panic_array_alloc() to allocate objs instead of static allocation in stack.
v4:
https://lore.kernel.org/all/[email protected]/
- As per Dmitry's comment, make virtio_panic_buffer private to virtio_gpu_device.
v3:
https://lore.kernel.org/all/[email protected]/
- As per Jocelyn's comment, add a finite timeout 500usec in virtio_gpu_panic_put_vbuf() to avoid infinite loop
v2:
https://lore.kernel.org/all/[email protected]/
- Remove unnecessary virtio_gpu_vbuffer_inline
- Remove reclaim_list and just call drm_gem_object_put() if there is an obj
- Don't wait for an event in virtio_gpu_panic_queue_ctrl_sgs and just return -ENOMEM. Also add error handlers for this error.
- Use virtio_gpu_panic_queue_fenced_ctrl_buffer() in virtio_gpu_panic_cmd_resource_flush
- Remove fence and objs arguments because these are always NULL in panic handler.
- Rename virtio_gpu_panic_queue_fenced_ctrl_buffer to ..._queue_ctrl_buffer
- Rename virtio_gpu_panic_alloc_cmd to ..._panic_init_cmd
v1:
https://lore.kernel.org/all/[email protected]/
drivers/gpu/drm/virtio/virtgpu_drv.h | 11 ++ drivers/gpu/drm/virtio/virtgpu_gem.c | 14 +++ drivers/gpu/drm/virtio/virtgpu_plane.c | 96 ++++++++++++++++ drivers/gpu/drm/virtio/virtgpu_vq.c | 151 +++++++++++++++++++++++++ 4 files changed, 272 insertions(+)
drivers/gpu/drm/virtio/virtgpu_drv.h +11 -0
@@ -310,6 +310,7 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,struct drm_device *dev, struct drm_mode_create_dumb *args); +struct virtio_gpu_object_array *virtio_gpu_panic_array_alloc (void );struct virtio_gpu_object_array *virtio_gpu_array_alloc (u32 nents);struct virtio_gpu_object_array *virtio_gpu_array_from_handles (struct drm_file *drm_file,u32 *handles,u32 nents);
@@ -334,12 +335,21 @@ void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev, struct virtio_gpu_fence *fence);void virtio_gpu_cmd_unref_resource (struct virtio_gpu_device *vgdev,struct virtio_gpu_object *bo); +int virtio_gpu_panic_cmd_transfer_to_host_2d (struct virtio_gpu_device *vgdev, +uint64_t offset, +uint32_t width,uint32_t height, +uint32_t x,uint32_t y, +struct virtio_gpu_object_array *objs);void virtio_gpu_cmd_transfer_to_host_2d (struct virtio_gpu_device *vgdev,uint64_t offset,uint32_t width,uint32_t height,uint32_t x,uint32_t y,struct virtio_gpu_object_array *objs,struct virtio_gpu_fence *fence); +void virtio_gpu_panic_cmd_resource_flush (struct virtio_gpu_device *vgdev, +uint32_t resource_id, +uint32_t x,uint32_t y, +uint32_t width,uint32_t height); void virtio_gpu_cmd_resource_flush(struct virtio_gpu_device *vgdev, uint32_t resource_id, uint32_t x, uint32_t y,
@@ -408,6 +418,7 @@ void virtio_gpu_ctrl_ack(struct virtqueue *vq);void virtio_gpu_cursor_ack (struct virtqueue *vq);void virtio_gpu_dequeue_ctrl_func (struct work_struct *work);void virtio_gpu_dequeue_cursor_func (struct work_struct *work); +void virtio_gpu_panic_notify (struct virtio_gpu_device *vgdev);void virtio_gpu_notify (struct virtio_gpu_device *vgdev);int
drivers/gpu/drm/virtio/virtgpu_gem.c +14 -0
@@ -148,6 +148,20 @@ void virtio_gpu_gem_object_close(struct drm_gem_object *obj,virtio_gpu_notify (vgdev); } +/* For drm panic */ +struct virtio_gpu_object_array *virtio_gpu_panic_array_alloc (void ) +{ +struct virtio_gpu_object_array *objs; + + objs =kmalloc (sizeof (struct virtio_gpu_object_array ),GFP_ATOMIC ); +if (!objs) +return NULL ; + + objs->nents =0 ; + objs->total =1 ; +return objs; +} +struct virtio_gpu_object_array *virtio_gpu_array_alloc (u32 nents) {struct virtio_gpu_object_array *objs;
drivers/gpu/drm/virtio/virtgpu_plane.c +96 -0
125 lines not on this page · raw message
drivers/gpu/drm/virtio/virtgpu_vq.c +151 -0
193 lines not on this page · raw message
base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b
Signature · 1 line
2.47.1
Quoted 7 lines · Ryosuke Yasuoka
Virtio gpu supports the
drm_panicmodule, which displays a message to the screen when a kernel panic occurs. It is supported where it has vmapped shmem BO.Signed-off-by Jocelyn Falempe <[email protected]>Signed-off-by Ryosuke Yasuoka <[email protected]>---
Applied to misc-next, thanks!
I've tested v7 with a different capsets, works well. For a non-VT FB the vmap indeed will be needed. Looking forward to the atomic vmap support. The rough idea of the atomic vmap helper is to make vmap code paths fail whenever hitting path that needs to sleep. Likely will be easy to implement.
Signature · 2 lines
Best regards, Dmitry
Quoted 9 lines · Dmitry Osipenko
Quoted 7 lines · Ryosuke Yasuoka
Virtio gpu supports the
drm_panicmodule, which displays a message to the screen when a kernel panic occurs. It is supported where it has vmapped shmem BO.Signed-off-by Jocelyn Falempe <[email protected]>Signed-off-by Ryosuke Yasuoka <[email protected]>---
Quoted 7 lines
Applied to misc-next, thanks!
I've tested v7 with a different capsets, works well. For a non-VT FB the vmap indeed will be needed. Looking forward to the atomic vmap support. The rough idea of the atomic vmap helper is to make vmap code paths fail whenever hitting path that needs to sleep. Likely will be easy to implement.
Thanks for your support.
I will see if we can do something for atomic vmap support for shmem.
Best regards,
Signature · 1 line
Jocelyn
Quoted 21 lines · Jocelyn Falempe
Quoted 9 lines · Dmitry Osipenko
Quoted 7 lines · Ryosuke Yasuoka
Virtio gpu supports the
drm_panicmodule, which displays a message to the screen when a kernel panic occurs. It is supported where it has vmapped shmem BO.Signed-off-by Jocelyn Falempe <[email protected]>Signed-off-by Ryosuke Yasuoka <[email protected]>---
Quoted 7 lines
Applied to misc-next, thanks!
I've tested v7 with a different capsets, works well. For a non-VT FB the vmap indeed will be needed. Looking forward to the atomic vmap support. The rough idea of the atomic vmap helper is to make vmap code paths fail whenever hitting path that needs to sleep. Likely will be easy to implement.
Thanks for your support.
Quoted 8 lines
I will see if we can do something for atomic vmap support for shmem.
Best regards,
--
Jocelyn
Thank you for your kind support.
I'll try to write the atomic vmap support patch soon.
Best regards,
Ryosuke