Skip to content

Commit 4e3b70d

Browse files
zackrmartinezjavier
authored andcommitted
drm: Disable the cursor plane on atomic contexts with virtualized drivers
Cursor planes on virtualized drivers have special meaning and require that the clients handle them in specific ways, e.g. the cursor plane should react to the mouse movement the way a mouse cursor would be expected to and the client is required to set hotspot properties on it in order for the mouse events to be routed correctly. This breaks the contract as specified by the "universal planes". Fix it by disabling the cursor planes on virtualized drivers while adding a foundation on top of which it's possible to special case mouse cursor planes for clients that want it. Disabling the cursor planes makes some kms compositors which were broken, e.g. Weston, fallback to software cursor which works fine or at least better than currently while having no effect on others, e.g. gnome-shell or kwin, which put virtualized drivers on a deny-list when running in atomic context to make them fallback to legacy kms and avoid this issue. Signed-off-by: Zack Rusin <zackr@vmware.com> Fixes: 681e7ec ("drm: Allow userspace to ask for universal plane list (v2)") Cc: <stable@vger.kernel.org> # v5.4+ Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Maxime Ripard <mripard@kernel.org> Cc: Thomas Zimmermann <tzimmermann@suse.de> Cc: David Airlie <airlied@linux.ie> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Dave Airlie <airlied@redhat.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Gurchetan Singh <gurchetansingh@chromium.org> Cc: Chia-I Wu <olvaffe@gmail.com> Cc: dri-devel@lists.freedesktop.org Cc: virtualization@lists.linux-foundation.org Cc: spice-devel@lists.freedesktop.org Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Acked-by: Simon Ser <contact@emersion.fr> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20231023074613.41327-2-aesteve@redhat.com
1 parent e4d983a commit 4e3b70d

File tree

7 files changed

+38
-4
lines changed

7 files changed

+38
-4
lines changed

drivers/gpu/drm/drm_plane.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,19 @@ int drm_mode_getplane_res(struct drm_device *dev, void *data,
678678
!file_priv->universal_planes)
679679
continue;
680680

681+
/*
682+
* If we're running on a virtualized driver then,
683+
* unless userspace advertizes support for the
684+
* virtualized cursor plane, disable cursor planes
685+
* because they'll be broken due to missing cursor
686+
* hotspot info.
687+
*/
688+
if (plane->type == DRM_PLANE_TYPE_CURSOR &&
689+
drm_core_check_feature(dev, DRIVER_CURSOR_HOTSPOT) &&
690+
file_priv->atomic &&
691+
!file_priv->supports_virtualized_cursor_plane)
692+
continue;
693+
681694
if (drm_lease_held(file_priv, plane->base.id)) {
682695
if (count < plane_resp->count_planes &&
683696
put_user(plane->base.id, plane_ptr + count))

drivers/gpu/drm/qxl/qxl_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static const struct drm_ioctl_desc qxl_ioctls[] = {
285285
};
286286

287287
static struct drm_driver qxl_driver = {
288-
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
288+
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_CURSOR_HOTSPOT,
289289

290290
.dumb_create = qxl_mode_dumb_create,
291291
.dumb_map_offset = drm_gem_ttm_dumb_map_offset,

drivers/gpu/drm/vboxvideo/vbox_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ DEFINE_DRM_GEM_FOPS(vbox_fops);
182182

183183
static const struct drm_driver driver = {
184184
.driver_features =
185-
DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC,
185+
DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC | DRIVER_CURSOR_HOTSPOT,
186186

187187
.fops = &vbox_fops,
188188
.name = DRIVER_NAME,

drivers/gpu/drm/virtio/virtgpu_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static const struct drm_driver driver = {
177177
* out via drm_device::driver_features:
178178
*/
179179
.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_RENDER | DRIVER_ATOMIC |
180-
DRIVER_SYNCOBJ | DRIVER_SYNCOBJ_TIMELINE,
180+
DRIVER_SYNCOBJ | DRIVER_SYNCOBJ_TIMELINE | DRIVER_CURSOR_HOTSPOT,
181181
.open = virtio_gpu_driver_open,
182182
.postclose = virtio_gpu_driver_postclose,
183183

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ static const struct file_operations vmwgfx_driver_fops = {
16111611

16121612
static const struct drm_driver driver = {
16131613
.driver_features =
1614-
DRIVER_MODESET | DRIVER_RENDER | DRIVER_ATOMIC | DRIVER_GEM,
1614+
DRIVER_MODESET | DRIVER_RENDER | DRIVER_ATOMIC | DRIVER_GEM | DRIVER_CURSOR_HOTSPOT,
16151615
.ioctls = vmw_ioctls,
16161616
.num_ioctls = ARRAY_SIZE(vmw_ioctls),
16171617
.master_set = vmw_master_set,

include/drm/drm_drv.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ enum drm_driver_feature {
110110
* Driver supports user defined GPU VA bindings for GEM objects.
111111
*/
112112
DRIVER_GEM_GPUVA = BIT(8),
113+
/**
114+
* @DRIVER_CURSOR_HOTSPOT:
115+
*
116+
* Driver supports and requires cursor hotspot information in the
117+
* cursor plane (e.g. cursor plane has to actually track the mouse
118+
* cursor and the clients are required to set hotspot in order for
119+
* the cursor planes to work correctly).
120+
*/
121+
DRIVER_CURSOR_HOTSPOT = BIT(9),
113122

114123
/* IMPORTANT: Below are all the legacy flags, add new ones above. */
115124

include/drm/drm_file.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,18 @@ struct drm_file {
226226
*/
227227
bool is_master;
228228

229+
/**
230+
* @supports_virtualized_cursor_plane:
231+
*
232+
* This client is capable of handling the cursor plane with the
233+
* restrictions imposed on it by the virtualized drivers.
234+
*
235+
* This implies that the cursor plane has to behave like a cursor
236+
* i.e. track cursor movement. It also requires setting of the
237+
* hotspot properties by the client on the cursor plane.
238+
*/
239+
bool supports_virtualized_cursor_plane;
240+
229241
/**
230242
* @master:
231243
*

0 commit comments

Comments
 (0)