drm: Disable the cursor plane on atomic contexts with virtualized drivers
authorjsg <jsg@openbsd.org>
Fri, 2 Feb 2024 03:11:16 +0000 (03:11 +0000)
committerjsg <jsg@openbsd.org>
Fri, 2 Feb 2024 03:11:16 +0000 (03:11 +0000)
From Zack Rusin
87b3b45ce7b4dd745506f9437b968c5e35b87dda in linux-6.6.y/6.6.15
4e3b70da64a53784683cfcbac2deda5d6e540407 in mainline linux

sys/dev/pci/drm/drm_plane.c
sys/dev/pci/drm/include/drm/drm_drv.h
sys/dev/pci/drm/include/drm/drm_file.h

index 01fbd3f..311e179 100644 (file)
@@ -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))
index 89d7dcb..5c855a1 100644 (file)
@@ -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. */
 
index 7d5259a..6e966a8 100644 (file)
@@ -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:
         *