From: Rob Clark <robdcl...@chromium.org>

This will allow userspace to control the scheduling policy and priority.
In particular if the userspace half of the display pipeline is SCHED_FIFO
then it will want to use the same scheduling policy and an appropriate
priority to ensure that it is not preempting commit_work.

Signed-off-by: Rob Clark <robdcl...@chromium.org>
---
 drivers/gpu/drm/drm_crtc.c        |  3 +++
 drivers/gpu/drm/drm_mode_config.c | 14 ++++++++++++++
 drivers/gpu/drm/drm_mode_object.c |  4 ++++
 include/drm/drm_mode_config.h     |  9 +++++++++
 include/drm/drm_property.h        |  9 +++++++++
 5 files changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 4f7c0bfce0a3..1828853542dc 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -334,6 +334,9 @@ int drm_crtc_init_with_planes(struct drm_device *dev, 
struct drm_crtc *crtc,
                        crtc->worker = NULL;
                        return ret;
                }
+
+               drm_object_attach_property(&crtc->base,
+                                          config->kwork_tid_property, 0);
        }
 
        return 0;
diff --git a/drivers/gpu/drm/drm_mode_config.c 
b/drivers/gpu/drm/drm_mode_config.c
index f1affc1bb679..b11a1fc8ed0d 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -215,6 +215,13 @@ static const struct drm_prop_enum_list 
drm_plane_type_enum_list[] = {
        { DRM_PLANE_TYPE_CURSOR, "Cursor" },
 };
 
+static int get_kwork_tid(struct drm_mode_object *obj, uint64_t *val)
+{
+       struct drm_crtc *crtc = obj_to_crtc(obj);
+       *val = task_pid_vnr(crtc->worker->task);
+       return 0;
+}
+
 static int drm_mode_create_standard_properties(struct drm_device *dev)
 {
        struct drm_property *prop;
@@ -371,6 +378,13 @@ static int drm_mode_create_standard_properties(struct 
drm_device *dev)
                return -ENOMEM;
        dev->mode_config.modifiers_property = prop;
 
+       prop = drm_property_create_range(dev, DRM_MODE_PROP_ATOMIC,
+                       "KWORK_TID", 0, UINT_MAX);
+       if (!prop)
+               return -ENOMEM;
+       prop->get_value = get_kwork_tid;
+       dev->mode_config.kwork_tid_property = prop;
+
        return 0;
 }
 
diff --git a/drivers/gpu/drm/drm_mode_object.c 
b/drivers/gpu/drm/drm_mode_object.c
index db05f386a709..1a4df65baf0f 100644
--- a/drivers/gpu/drm/drm_mode_object.c
+++ b/drivers/gpu/drm/drm_mode_object.c
@@ -285,6 +285,7 @@ int drm_object_property_set_value(struct drm_mode_object 
*obj,
 
        WARN_ON(drm_drv_uses_atomic_modeset(property->dev) &&
                !(property->flags & DRM_MODE_PROP_IMMUTABLE));
+       WARN_ON(property->get_value);
 
        for (i = 0; i < obj->properties->count; i++) {
                if (obj->properties->properties[i] == property) {
@@ -303,6 +304,9 @@ static int __drm_object_property_get_value(struct 
drm_mode_object *obj,
 {
        int i;
 
+       if (property->get_value)
+               return property->get_value(obj, val);
+
        /* read-only properties bypass atomic mechanism and still store
         * their value in obj->properties->values[].. mostly to avoid
         * having to deal w/ EDID and similar props in atomic paths:
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index c2d3d71d133c..7244df926a6d 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -926,6 +926,15 @@ struct drm_mode_config {
         */
        struct drm_property *modifiers_property;
 
+       /**
+        * @kwork_tid_property: CRTC property to expose the task-id of the per-
+        * CRTC kthread-worker, used for non-block atomic commit.  This is 
exposed
+        * to userspace, to allow userspace to control the scheduling policy and
+        * priority, as this is a decision that depends on how userspace 
structures
+        * it's rendering pipeline.
+        */
+       struct drm_property *kwork_tid_property;
+
        /* cursor size */
        uint32_t cursor_width, cursor_height;
 
diff --git a/include/drm/drm_property.h b/include/drm/drm_property.h
index 4a0a80d658c7..6843be6aa3ec 100644
--- a/include/drm/drm_property.h
+++ b/include/drm/drm_property.h
@@ -188,6 +188,15 @@ struct drm_property {
         * enum and bitmask values.
         */
        struct list_head enum_list;
+
+       /**
+        * @get_value: accessor to get current value for "virtual" properties
+        *
+        * For properties with dynamic values, where it is for whatever reason
+        * not feasible to keep updated with drm_object_property_set_value(),
+        * this callback can be used to retrieve the current value on demand.
+        */
+       int (*get_value)(struct drm_mode_object *obj, uint64_t *val);
 };
 
 /**
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to