All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: DRI Development <dri-devel@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: [PATCH] drm: Don't update property values for atomic drivers
Date: Tue, 25 Jul 2017 14:01:37 +0200	[thread overview]
Message-ID: <20170725120137.1903-1-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <20170725080122.20548-3-daniel.vetter@ffwll.ch>

Atomic drivers only use the property value store for immutable (i.e.
can't be set by userspace, but the kernel can still adjust it)
properties. The only tricky part is the removal of the update in
drm_atomic_helper_update_legacy_modeset_state().

This was added in

commit 8c10342cb48f3140d9abeadcfd2fa6625d447282 (tag: topic/drm-misc-2015-07-28)
Author: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Date:   Mon Jul 27 13:24:29 2015 +0200

    drm/atomic: Update legacy DPMS state during modesets, v3.

by copying it from the i915 code, where it was originally added in

commit 68d3472047a572936551f8ff0b6f4016c5a1fdef
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Thu Sep 6 22:08:35 2012 +0200

    drm/i915: update dpms property in set_mode

for the legacy modeset code. The reason we needed this hack was that
i915 didn't yet set DRIVER_ATOMIC, and we checked for that instead of
the newer-ish drm_drv_uses_atomic_modeset(), which avoids such
troubles. With the correct feature checks this isn't needed anymore at
all.

Also make sure that drivers don't accidentally get this wrong by
making the exported version of drm_object_property_get_value() only
work for legacy drivers. Only gma500 uses it anyway.

v2: Fixup the uses_atomic_modeset() checks (Maarten)

Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_atomic_helper.c |  4 ---
 drivers/gpu/drm/drm_connector.c     |  3 +--
 drivers/gpu/drm/drm_crtc.c          |  2 +-
 drivers/gpu/drm/drm_mode_object.c   | 49 +++++++++++++++++++++++--------------
 drivers/gpu/drm/drm_plane.c         |  2 +-
 5 files changed, 33 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 7582bbc5decc..4a960c741e35 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -921,16 +921,12 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
 		crtc = new_conn_state->crtc;
 		if ((!crtc && old_conn_state->crtc) ||
 		    (crtc && drm_atomic_crtc_needs_modeset(crtc->state))) {
-			struct drm_property *dpms_prop =
-				dev->mode_config.dpms_property;
 			int mode = DRM_MODE_DPMS_OFF;
 
 			if (crtc && crtc->state->active)
 				mode = DRM_MODE_DPMS_ON;
 
 			connector->dpms = mode;
-			drm_object_property_set_value(&connector->base,
-						      dpms_prop, mode);
 		}
 	}
 
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 8072e6e4c62c..0e9e3161bdd0 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -1225,8 +1225,7 @@ int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
 	} else if (connector->funcs->set_property)
 		ret = connector->funcs->set_property(connector, property, value);
 
-	/* store the property value if successful */
-	if (!ret)
+	if (!ret && !drm_drv_uses_atomic_modeset(property->dev))
 		drm_object_property_set_value(&connector->base, property, value);
 	return ret;
 }
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 5af25ce5bf7c..9271235d84b0 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -736,7 +736,7 @@ int drm_mode_crtc_set_obj_prop(struct drm_mode_object *obj,
 
 	if (crtc->funcs->set_property)
 		ret = crtc->funcs->set_property(crtc, property, value);
-	if (!ret)
+	if (!ret && !drm_drv_uses_atomic_modeset(property->dev))
 		drm_object_property_set_value(obj, property, value);
 
 	return ret;
diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
index da9a9adbcc98..92743a796bf0 100644
--- a/drivers/gpu/drm/drm_mode_object.c
+++ b/drivers/gpu/drm/drm_mode_object.c
@@ -233,6 +233,9 @@ int drm_object_property_set_value(struct drm_mode_object *obj,
 {
 	int i;
 
+	WARN_ON(drm_drv_uses_atomic_modeset(property->dev) &&
+		!(property->flags & DRM_MODE_PROP_IMMUTABLE));
+
 	for (i = 0; i < obj->properties->count; i++) {
 		if (obj->properties->properties[i] == property) {
 			obj->properties->values[i] = val;
@@ -244,24 +247,7 @@ int drm_object_property_set_value(struct drm_mode_object *obj,
 }
 EXPORT_SYMBOL(drm_object_property_set_value);
 
-/**
- * drm_object_property_get_value - retrieve the value of a property
- * @obj: drm mode object to get property value from
- * @property: property to retrieve
- * @val: storage for the property value
- *
- * This function retrieves the softare state of the given property for the given
- * property. Since there is no driver callback to retrieve the current property
- * value this might be out of sync with the hardware, depending upon the driver
- * and property.
- *
- * Atomic drivers should never call this function directly, the core will read
- * out property values through the various ->atomic_get_property callbacks.
- *
- * Returns:
- * Zero on success, error code on failure.
- */
-int drm_object_property_get_value(struct drm_mode_object *obj,
+int __drm_object_property_get_value(struct drm_mode_object *obj,
 				  struct drm_property *property, uint64_t *val)
 {
 	int i;
@@ -284,6 +270,31 @@ int drm_object_property_get_value(struct drm_mode_object *obj,
 
 	return -EINVAL;
 }
+
+/**
+ * drm_object_property_get_value - retrieve the value of a property
+ * @obj: drm mode object to get property value from
+ * @property: property to retrieve
+ * @val: storage for the property value
+ *
+ * This function retrieves the softare state of the given property for the given
+ * property. Since there is no driver callback to retrieve the current property
+ * value this might be out of sync with the hardware, depending upon the driver
+ * and property.
+ *
+ * Atomic drivers should never call this function directly, the core will read
+ * out property values through the various ->atomic_get_property callbacks.
+ *
+ * Returns:
+ * Zero on success, error code on failure.
+ */
+int drm_object_property_get_value(struct drm_mode_object *obj,
+				  struct drm_property *property, uint64_t *val)
+{
+	WARN_ON(drm_drv_uses_atomic_modeset(property->dev));
+
+	return __drm_object_property_get_value(obj, property, val);
+}
 EXPORT_SYMBOL(drm_object_property_get_value);
 
 /* helper for getconnector and getproperties ioctls */
@@ -302,7 +313,7 @@ int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
 			continue;
 
 		if (*arg_count_props > count) {
-			ret = drm_object_property_get_value(obj, prop, &val);
+			ret = __drm_object_property_get_value(obj, prop, &val);
 			if (ret)
 				return ret;
 
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 5dc8c4350602..186416f5e4c5 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -330,7 +330,7 @@ int drm_mode_plane_set_obj_prop(struct drm_plane *plane,
 
 	if (plane->funcs->set_property)
 		ret = plane->funcs->set_property(plane, property, value);
-	if (!ret)
+	if (!ret && !drm_drv_uses_atomic_modeset(property->dev))
 		drm_object_property_set_value(obj, property, value);
 
 	return ret;
-- 
2.13.3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-07-25 12:01 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25  8:01 [PATCH 0/8] acquire ctx for everyone! Daniel Vetter
2017-07-25  8:01 ` [PATCH 1/8] drm/omap: Simplify the rotation-on-crtc hack Daniel Vetter
2017-07-25  8:47   ` Maarten Lankhorst
2017-07-25  9:24     ` [Intel-gfx] " Daniel Vetter
2017-07-31 11:48       ` Laurent Pinchart
2017-07-31 11:56         ` Tomi Valkeinen
2017-07-31 10:54   ` [PATCH] drm/omap: Rework " Daniel Vetter
2017-07-31 11:57     ` Laurent Pinchart
2017-07-31 12:45   ` Daniel Vetter
2017-07-31 13:30     ` Laurent Pinchart
2017-07-31 15:42   ` Daniel Vetter
2017-08-01  5:59     ` Maarten Lankhorst
2017-08-01 10:20       ` Laurent Pinchart
2017-08-02  8:02         ` Daniel Vetter
2017-08-02 13:20           ` Maarten Lankhorst
2017-08-04  9:57             ` Tomi Valkeinen
2017-08-04 10:02               ` Daniel Vetter
2017-08-07  9:24                 ` Maarten Lankhorst
2017-08-07  9:56                 ` Maarten Lankhorst
2017-08-07 10:20                 ` [PATCH v7] " Maarten Lankhorst
2017-08-08 12:08                   ` Tomi Valkeinen
2017-07-25  8:01 ` [PATCH 2/8] drm: Don't update property values for atomic drivers Daniel Vetter
2017-07-25  8:32   ` Maarten Lankhorst
2017-07-25 12:01   ` Daniel Vetter [this message]
2017-08-11 22:20   ` Laurent Pinchart
2017-08-14  7:25     ` Daniel Vetter
2017-08-14 10:32       ` Laurent Pinchart
2017-08-14 14:09         ` Daniel Vetter
2017-07-25  8:01 ` [PATCH 3/8] drm: Handle properties in the core " Daniel Vetter
2017-07-25  9:36   ` Archit Taneja
2017-07-25 12:02   ` [PATCH] " Daniel Vetter
2017-07-25  8:01 ` [PATCH 4/8] drm: Nuke drm_atomic_helper_crtc_set_property Daniel Vetter
2017-07-25  9:38   ` Archit Taneja
2017-07-25 10:05   ` Philippe CORNU
2017-08-03 13:34   ` Thomas Hellstrom
2017-07-25  8:01 ` [PATCH 5/8] drm: Nuke drm_atomic_helper_plane_set_property Daniel Vetter
2017-07-25  8:01   ` Daniel Vetter
2017-07-25  8:01   ` Daniel Vetter
2017-07-25  9:38   ` Archit Taneja
2017-07-25  9:38     ` Archit Taneja
2017-07-25  9:38     ` Archit Taneja
2017-07-25 10:06   ` Philippe CORNU
2017-07-25 10:06     ` Philippe CORNU
2017-07-25 10:06     ` Philippe CORNU
2017-07-28 16:45   ` Liviu Dudau
2017-07-28 16:45     ` Liviu Dudau
2017-07-28 16:45     ` Liviu Dudau
2017-08-08 10:03   ` Vincent ABRIOU
2017-08-08 10:03     ` Vincent ABRIOU
2017-08-08 10:03     ` Vincent ABRIOU
2017-08-08 12:31   ` Laurent Pinchart
     [not found] ` <20170725080122.20548-1-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
2017-07-25  8:01   ` [PATCH 6/8] drm: Nuke drm_atomic_helper_connector_set_property Daniel Vetter
     [not found]     ` <20170725080122.20548-7-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
2017-07-25  9:23       ` [Intel-gfx] " Maarten Lankhorst
2017-07-25  9:26         ` Daniel Vetter
2017-08-08 10:04     ` Vincent ABRIOU
2017-07-25  8:01 ` [PATCH 7/8] drm: Nuke drm_atomic_helper_connector_dpms Daniel Vetter
2017-07-25  8:01   ` Daniel Vetter
2017-07-25  8:04   ` Neil Armstrong
2017-07-25  8:04     ` Neil Armstrong
2017-07-25  8:04   ` Neil Armstrong
2017-07-25  8:59   ` Philipp Zabel
2017-07-25  8:59     ` Philipp Zabel
2017-07-25  8:59   ` Philipp Zabel
2017-07-25  9:30   ` Archit Taneja
2017-07-25  9:30     ` Archit Taneja
2017-07-25  9:30   ` Archit Taneja
2017-07-25 10:07   ` Philippe CORNU
2017-07-25 10:07   ` Philippe CORNU
2017-07-25 10:07     ` Philippe CORNU
2017-07-25 14:01   ` Laurent Pinchart
2017-07-25 14:01   ` Laurent Pinchart
2017-07-25 14:42   ` Shawn Guo
2017-07-25 14:42   ` Shawn Guo
2017-07-25 14:42     ` Shawn Guo
2017-07-26 19:00   ` Noralf Trønnes
2017-07-26 19:00   ` Noralf Trønnes
2017-07-26 19:00     ` Noralf Trønnes
2017-08-08 10:05   ` Vincent ABRIOU
2017-08-08 10:05     ` Vincent ABRIOU
2017-08-08 10:05   ` Vincent ABRIOU
2017-07-25  8:01 ` [PATCH 8/8] drm: Nuke drm_atomic_legacy_backoff Daniel Vetter
2017-07-25  9:36   ` [Intel-gfx] " Maarten Lankhorst
2017-07-25  8:44 ` ✓ Fi.CI.BAT: success for acquire ctx for everyone! Patchwork
2017-07-25 12:05 ` ✗ Fi.CI.BAT: failure for acquire ctx for everyone! (rev3) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170725120137.1903-1-daniel.vetter@ffwll.ch \
    --to=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.