From: jsg Date: Fri, 2 Feb 2024 03:11:16 +0000 (+0000) Subject: drm: Disable the cursor plane on atomic contexts with virtualized drivers X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=cab70de6fe9607b8bfe4ce63a61d57541fa174ed;p=openbsd drm: Disable the cursor plane on atomic contexts with virtualized drivers From Zack Rusin 87b3b45ce7b4dd745506f9437b968c5e35b87dda in linux-6.6.y/6.6.15 4e3b70da64a53784683cfcbac2deda5d6e540407 in mainline linux --- diff --git a/sys/dev/pci/drm/drm_plane.c b/sys/dev/pci/drm/drm_plane.c index 01fbd3fb7b9..311e179904a 100644 --- a/sys/dev/pci/drm/drm_plane.c +++ b/sys/dev/pci/drm/drm_plane.c @@ -678,6 +678,19 @@ int drm_mode_getplane_res(struct drm_device *dev, void *data, !file_priv->universal_planes) continue; + /* + * If we're running on a virtualized driver then, + * unless userspace advertizes support for the + * virtualized cursor plane, disable cursor planes + * because they'll be broken due to missing cursor + * hotspot info. + */ + if (plane->type == DRM_PLANE_TYPE_CURSOR && + drm_core_check_feature(dev, DRIVER_CURSOR_HOTSPOT) && + file_priv->atomic && + !file_priv->supports_virtualized_cursor_plane) + continue; + if (drm_lease_held(file_priv, plane->base.id)) { if (count < plane_resp->count_planes && put_user(plane->base.id, plane_ptr + count)) diff --git a/sys/dev/pci/drm/include/drm/drm_drv.h b/sys/dev/pci/drm/include/drm/drm_drv.h index 89d7dcb543e..5c855a1bce5 100644 --- a/sys/dev/pci/drm/include/drm/drm_drv.h +++ b/sys/dev/pci/drm/include/drm/drm_drv.h @@ -112,6 +112,15 @@ enum drm_driver_feature { * Driver supports user defined GPU VA bindings for GEM objects. */ DRIVER_GEM_GPUVA = BIT(8), + /** + * @DRIVER_CURSOR_HOTSPOT: + * + * Driver supports and requires cursor hotspot information in the + * cursor plane (e.g. cursor plane has to actually track the mouse + * cursor and the clients are required to set hotspot in order for + * the cursor planes to work correctly). + */ + DRIVER_CURSOR_HOTSPOT = BIT(9), /* IMPORTANT: Below are all the legacy flags, add new ones above. */ diff --git a/sys/dev/pci/drm/include/drm/drm_file.h b/sys/dev/pci/drm/include/drm/drm_file.h index 7d5259aef50..6e966a8e86b 100644 --- a/sys/dev/pci/drm/include/drm/drm_file.h +++ b/sys/dev/pci/drm/include/drm/drm_file.h @@ -231,6 +231,18 @@ struct drm_file { */ bool is_master; + /** + * @supports_virtualized_cursor_plane: + * + * This client is capable of handling the cursor plane with the + * restrictions imposed on it by the virtualized drivers. + * + * This implies that the cursor plane has to behave like a cursor + * i.e. track cursor movement. It also requires setting of the + * hotspot properties by the client on the cursor plane. + */ + bool supports_virtualized_cursor_plane; + /** * @master: *