linux/drivers/gpu/drm/qxl
Thomas Zimmermann c537fb4e3d drm/qxl: Pin buffer objects for internal mappings
Add qxl_bo_pin_and_vmap() that pins and vmaps a buffer object in one
step. Update callers of the regular qxl_bo_vmap(). Fixes a bug where
qxl accesses an unpinned buffer object while it is being moved; such
as with the monitor-description BO. An typical error is shown below.

[    4.303586] [drm:drm_atomic_helper_commit_planes] *ERROR* head 1 wrong: 65376256x16777216+0+0
[    4.586883] [drm:drm_atomic_helper_commit_planes] *ERROR* head 1 wrong: 65376256x16777216+0+0
[    4.904036] [drm:drm_atomic_helper_commit_planes] *ERROR* head 1 wrong: 65335296x16777216+0+0
[    5.374347] [drm:qxl_release_from_id_locked] *ERROR* failed to find id in release_idr

Commit b33651a5c9 ("drm/qxl: Do not pin buffer objects for vmap")
removed the implicit pin operation from qxl's vmap code. This is the
correct behavior for GEM and PRIME interfaces, but the pin is still
needed for qxl internal operation.

Also add a corresponding function qxl_bo_vunmap_and_unpin() and remove
the old qxl_bo_vmap() helpers.

Future directions: BOs should not be pinned or vmapped unnecessarily.
The pin-and-vmap operation should be removed from the driver and a
temporary mapping should be established with a vmap_local-like helper.
See the client helper drm_client_buffer_vmap_local() for semantics.

v2:
- unreserve BO on errors in qxl_bo_pin_and_vmap() (Dmitry)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: b33651a5c9 ("drm/qxl: Do not pin buffer objects for vmap")
Reported-by: David Kaplan <david.kaplan@amd.com>
Closes: https://lore.kernel.org/dri-devel/ab0fb17d-0f96-4ee6-8b21-65d02bb02655@suse.de/
Tested-by: David Kaplan <david.kaplan@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Zack Rusin <zack.rusin@broadcom.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux.dev
Cc: spice-devel@lists.freedesktop.org
Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Reviewed-by: Zack Rusin <zack.rusin@broadcom.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240708142208.194361-1-tzimmermann@suse.de
2024-07-10 09:12:42 +02:00
..
Kconfig
Makefile
qxl_cmd.c drm/qxl: remove unused count variable from qxl_surface_id_alloc() 2024-03-28 11:14:39 +01:00
qxl_debugfs.c dma-buf: add DMA_RESV_USAGE_BOOKKEEP v3 2022-04-07 12:53:54 +02:00
qxl_dev.h
qxl_display.c drm/qxl: Pin buffer objects for internal mappings 2024-07-10 09:12:42 +02:00
qxl_draw.c drm: Drop drm_framebuffer.h from drm_crtc.h 2022-06-20 23:53:55 +03:00
qxl_drv.c drm/fbdev-generic: Convert to fbdev-ttm 2024-05-02 11:33:32 +02:00
qxl_drv.h drm/qxl: remove unused declaration 2023-12-04 09:42:32 +01:00
qxl_dumb.c drm/qxl: fix UAF on handle creation 2023-08-18 06:57:38 +10:00
qxl_gem.c drm/qxl: fix UAF on handle creation 2023-08-18 06:57:38 +10:00
qxl_image.c
qxl_ioctl.c drm/qxl: remove unused variable from qxl_process_single_command() 2024-03-28 11:15:48 +01:00
qxl_irq.c
qxl_kms.c drm/qxl: drop set_prod_notify parameter from qxl_ring_create 2022-09-23 13:16:37 +02:00
qxl_object.c drm/qxl: Pin buffer objects for internal mappings 2024-07-10 09:12:42 +02:00
qxl_object.h drm/qxl: Pin buffer objects for internal mappings 2024-07-10 09:12:42 +02:00
qxl_prime.c drm/gem: Acquire reservation lock in drm_gem_{pin/unpin}() 2024-03-11 13:33:50 +01:00
qxl_release.c Reapply "drm/qxl: simplify qxl_fence_wait" 2024-05-06 13:28:59 -07:00
qxl_ttm.c drm/ttm: replace busy placement with flags v6 2024-01-25 09:59:44 +01:00