Skip to contentSkip to conversation

drm/i915: Atomic mode setting / page flip, yet again

PATCH In review [email protected] 2 participants 85 messages Dec 12, 2012 – Dec 14, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover drm/i915: Atomic mode setting / page flip, yet again

Another month, another massive atomic patchset.

I managed to clean up warts left over from the modeset-rework rebase, but other than that I haven't really found the time to touch this too much since the last time I posted patches from this set.

Seeing as my schedule isn't getting any less busy in the forseeable future, it would be nice to get this monster merged sooner rather than never.

Ever since the code started to resemble something sane, I've tried to avoid squashing patches, just in case someone was actually trying to follow what's changed. But clearly some of the patches can be squashed, and that would probably allow some of the earlier ones to be dropped entirely.

What's clearly needed is a test tool that will stresss the mode setting side of the code more. My glplane test just changes the modes in the beginning, and then just does flips and other plane stuff. I'll try to get something done on that front before Christmas.

Repo is here:
https://gitorious.org/vsyrjala/linux/commits/drm_atomic_23

The repo also contains 64bit get_user() implementation for x86-32, which I sent to lkml and x86 people for review. So this should now be testable even on a 32bit system.

#1 lore raw

PATCH 1/81 drm: Add struct drm_region and assorted utility functions

From: Ville Syrjälä <[email protected]>

struct drm_region represents a two dimensional region. The utility functions are there to help driver writers.

---
 drivers/gpu/drm/drm_crtc.c |  155 ++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_crtc.h     |   24 +++++++
 2 files changed, 179 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc.c +155 -0
index d6d0072..f64e572 100644
@@ -3923,3 +3923,158 @@ int drm_format_vert_chroma_subsampling(uint32_t format)
 	}
 }
 EXPORT_SYMBOL(drm_format_vert_chroma_subsampling);
+
+/**
+ * drm_region_adjust_size - adjust the size of the region
+ * @r: region to be adjusted
+ * @x: horizontal adjustment
+ * @y: vertical adjustment
+ *
+ * Change the size of region @r by @x in the horizontal direction,
+ * and by @y in the vertical direction, while keeping the center
+ * of @r stationary.
+ *
+ * Positive @x and @y increase the size, negative values decrease it.
+ */
+void drm_region_adjust_size(struct drm_region *r, int x, int y)
+{
+	r->x1 -= x >> 1;
+	r->y1 -= y >> 1;
+	r->x2 += (x + 1) >> 1;
+	r->y2 += (y + 1) >> 1;
+}
+EXPORT_SYMBOL(drm_region_adjust_size);
+
+/**
+ * drm_region_translate - translate the region
+ * @r: region to be tranlated
+ * @x: horizontal translation
+ * @y: vertical translation
+ *
+ * Move region @r by @x in the horizontal direction,
+ * and by @y in the vertical direction.
+ */
+void drm_region_translate(struct drm_region *r, int x, int y)
+{
+	r->x1 += x;
+	r->y1 += y;
+	r->x2 += x;
+	r->y2 += y;
+}
+EXPORT_SYMBOL(drm_region_translate);
+
+/**
+ * drm_region_subsample - subsample a region
+ * @r: region to be subsampled
+ * @hsub: horizontal subsampling factor
+ * @vsub: vertical subsampling factor
+ *
+ * Divide the coordinates of region @r by @hsub and @vsub.
+ */
+void drm_region_subsample(struct drm_region *r, int hsub, int vsub)
+{
+	r->x1 /= hsub;
+	r->y1 /= vsub;
+	r->x2 /= hsub;
+	r->y2 /= vsub;
+}
+EXPORT_SYMBOL(drm_region_subsample);
+
+/**
+ * drm_region_width - determine the region width
+ * @r: region whose width is returned
+ *
+ * RETURNS:
+ * The width of the region.
+ */
+int drm_region_width(const struct drm_region *r)
+{
+	return r->x2 - r->x1;
+}
+EXPORT_SYMBOL(drm_region_width);
+
+/**
+ * drm_region_height - determine the region height
+ * @r: region whose height is returned
+ *
+ * RETURNS:
+ * The height of the region.
+ */
+int drm_region_height(const struct drm_region *r)
+{
+	return r->y2 - r->y1;
+}
+EXPORT_SYMBOL(drm_region_height);
+
+/**
+ * drm_region_visible - determine if the the region is visible
+ * @r: region whose visibility is returned
+ *
+ * RETURNS:
+ * @true if the region is visible, @false otherwise.
+ */
+bool drm_region_visible(const struct drm_region *r)
+{
+	return drm_region_width(r) > 0 && drm_region_height(r) > 0;
+}
+EXPORT_SYMBOL(drm_region_visible);
+
+/**
+ * drm_region_clip - clip one region by another region
+ * @r: region to be clipped
+ * @clip: clip region
+ *
+ * Clip region @r by region @clip.
+ *
+ * RETURNS:
+ * @true if the region is still visible after being clipped,
+ * @false otherwise.
+ */
+bool drm_region_clip(struct drm_region *r, const struct drm_region *clip)
+{
+	r->x1 = max(r->x1, clip->x1);
+	r->y1 = max(r->y1, clip->y1);
+	r->x2 = min(r->x2, clip->x2);
+	r->y2 = min(r->y2, clip->y2);
+
+	return drm_region_visible(r);
+}
+EXPORT_SYMBOL(drm_region_clip);
+
+/**
+ * drm_region_clip_scaled - perform a scaled clip operation
+ * @src: source window region
+ * @dst: destination window region
+ * @clip: clip region
+ * @hscale: horizontal scaling factor
+ * @vscale: vertical scaling factor
+ *
+ * Clip region @dst by region @clip. Clip region @src by the same
+ * amounts multiplied by @hscale and @vscale.
+ *
+ * RETUTRNS:
+ * @true if region @dst is still visible after being clipped,
+ * @false otherwise
+ */
+bool drm_region_clip_scaled(struct drm_region *src, struct drm_region *dst,
+			    const struct drm_region *clip,
+			    int hscale, int vscale)
+{
+	int diff;
+
+	diff = clip->x1 - dst->x1;
+	if (diff > 0)
+		src->x1 += diff * hscale;
+	diff = clip->y1 - dst->y1;
+	if (diff > 0)
+		src->y1 += diff * vscale;
+	diff = dst->x2 - clip->x2;
+	if (diff > 0)
+		src->x2 -= diff * hscale;
+	diff = dst->y2 - clip->y2;
+	if (diff > 0)
+		src->y2 -= diff * vscale;
+
+	return drm_region_clip(dst, clip);
+}
+EXPORT_SYMBOL(drm_region_clip_scaled);
include/drm/drm_crtc.h +24 -0
index 3538eda..0ac6d83 100644
@@ -1082,4 +1082,28 @@ extern int drm_format_plane_cpp(uint32_t format, int plane);
 extern int drm_format_horz_chroma_subsampling(uint32_t format);
 extern int drm_format_vert_chroma_subsampling(uint32_t format);
 
+/**
+ * drm_region - two dimensional region
+ * @x1: horizontal starting coordinate (inclusive)
+ * @x2: horizontal ending coordinate (exclusive)
+ * @y1: vertical starting coordinate (inclusive)
+ * @y2: vertical ending coordinate (exclusive)
+ */
+struct drm_region {
+	int x1, y1, x2, y2;
+};
+
+extern void drm_region_adjust_size(struct drm_region *r, int x, int y);
+extern void drm_region_translate(struct drm_region *r, int x, int y);
+extern void drm_region_subsample(struct drm_region *r, int hsub, int vsub);
+extern int drm_region_width(const struct drm_region *r);
+extern int drm_region_height(const struct drm_region *r);
+extern bool drm_region_visible(const struct drm_region *r);
+extern bool drm_region_clip(struct drm_region *r,
+			    const struct drm_region *clip);
+extern bool drm_region_clip_scaled(struct drm_region *src,
+				   struct drm_region *dst,
+				   const struct drm_region *clip,
+				   int hscale, int vscale);
+
 #endif /* __DRM_CRTC_H__ */
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

PATCH 2/81 drm: Add drm_calc_{hscale, vscale}() utility functions

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

---
 drivers/gpu/drm/drm_crtc.c |  102 ++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_crtc.h     |    4 ++
 2 files changed, 106 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc.c +102 -0
index f64e572..8918179 100644
@@ -4078,3 +4078,105 @@ bool drm_region_clip_scaled(struct drm_region *src, struct drm_region *dst,
 	return drm_region_clip(dst, clip);
 }
 EXPORT_SYMBOL(drm_region_clip_scaled);
+
+/**
+ * drm_calc_hscale - calculate the horizontal scaling factor
+ * @src: source window region
+ * @dst: destination window region
+ * @min_hscale: minimum allowed horizontal scaling factor
+ * @max_hscale: maximum allowed horizontal scaling factor
+ *
+ * Calculate the horizontal scaling factor as
+ * (@src width) / (@dst width).
+ *
+ * If the calculated scaling factor is below @min_hscale,
+ * decrease the width of region @dst to compensate.
+ *
+ * If the calculcated scaling factor is above @max_hscale,
+ * decrease the width of region @src to compensate.
+ *
+ * RETURNS:
+ * The horizontal scaling factor.
+ */
+int drm_calc_hscale(struct drm_region *src, struct drm_region *dst,
+		    int min_hscale, int max_hscale)
+{
+	int src_w = drm_region_width(src);
+	int dst_w = drm_region_width(dst);
+	int hscale;
+
+	if (dst_w <= 0)
+		return 0;
+
+	hscale = src_w / dst_w;
+
+	if (hscale < min_hscale) {
+		int max_dst_w = src_w / min_hscale;
+
+		drm_region_adjust_size(dst, max_dst_w - dst_w, 0);
+
+		return min_hscale;
+	}
+
+	if (hscale > max_hscale) {
+		int max_src_w = dst_w * max_hscale;
+
+		drm_region_adjust_size(src, max_src_w - src_w, 0);
+
+		return max_hscale;
+	}
+
+	return hscale;
+}
+EXPORT_SYMBOL(drm_calc_hscale);
+
+/**
+ * drm_calc_vscale - calculate the vertical scaling factor
+ * @src: source window region
+ * @dst: destination window region
+ * @min_vscale: minimum allowed vertical scaling factor
+ * @max_vscale: maximum allowed vertical scaling factor
+ *
+ * Calculate the vertical scaling factor as
+ * (@src height) / (@dst height).
+ *
+ * If the calculated scaling factor is below @min_vscale,
+ * decrease the height of region @dst to compensate.
+ *
+ * If the calculcated scaling factor is above @max_vscale,
+ * decrease the height of region @src to compensate.
+ *
+ * RETURNS:
+ * The vertical scaling factor.
+ */
+int drm_calc_vscale(struct drm_region *src, struct drm_region *dst,
+		    int min_vscale, int max_vscale)
+{
+	int src_h = drm_region_height(src);
+	int dst_h = drm_region_height(dst);
+	int vscale;
+
+	if (dst_h <= 0)
+		return 0;
+
+	vscale = src_h / dst_h;
+
+	if (vscale < min_vscale) {
+		int max_dst_h = src_h / min_vscale;
+
+		drm_region_adjust_size(dst, 0, max_dst_h - dst_h);
+
+		return min_vscale;
+	}
+
+	if (vscale > max_vscale) {
+		int max_src_h = dst_h * max_vscale;
+
+		drm_region_adjust_size(src, 0, max_src_h - src_h);
+
+		return max_vscale;
+	}
+
+	return vscale;
+}
+EXPORT_SYMBOL(drm_calc_vscale);
include/drm/drm_crtc.h +4 -0
index 0ac6d83..a80a346 100644
@@ -1105,5 +1105,9 @@ extern bool drm_region_clip_scaled(struct drm_region *src,
 				   struct drm_region *dst,
 				   const struct drm_region *clip,
 				   int hscale, int vscale);
+extern int drm_calc_hscale(struct drm_region *src, struct drm_region *dst,
+			   int min_hscale, int max_hscale);
+extern int drm_calc_vscale(struct drm_region *src, struct drm_region *dst,
+			   int min_vscale, int max_vscale);
 
 #endif /* __DRM_CRTC_H__ */
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH 3/81 drm: Keep a copy of last plane coordinates

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

If the update_plane() operation succeeds, make a copy of the requested src and crtc coordinates, so that the the plane may be reclipped if the display mode changed later.

---
 drivers/gpu/drm/drm_crtc.c |    8 ++++++++
 include/drm/drm_crtc.h     |    4 ++++
 2 files changed, 12 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc.c +8 -0
index 8918179..3164131 100644
@@ -1852,6 +1852,14 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
 	if (!ret) {
 		plane->crtc = crtc;
 		plane->fb = fb;
+		plane->crtc_x = plane_req->crtc_x;
+		plane->crtc_y = plane_req->crtc_y;
+		plane->crtc_w = plane_req->crtc_w;
+		plane->crtc_h = plane_req->crtc_h;
+		plane->src_x = plane_req->src_x;
+		plane->src_y = plane_req->src_y;
+		plane->src_w = plane_req->src_w;
+		plane->src_h = plane_req->src_h;
 	}
 
 out:
include/drm/drm_crtc.h +4 -0
index a80a346..6b7d809 100644
@@ -672,6 +672,10 @@ struct drm_plane {
 	void *helper_private;
 
 	struct drm_object_properties properties;
+
+	uint32_t src_x, src_y, src_w, src_h;
+	int32_t crtc_x, crtc_y;
+	uint32_t crtc_w, crtc_h;
 };
 
 /**
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

PATCH 4/81 drm: Add restore_fbdev_mode() hook to drm_fb_helper

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Add an optional driver specific restore_fbdev_mode() hook to drm_fb_helper. If the driver doesn't provide the hook, drm_fb_helper_restore_fbdev_mode() is called directly as before.

In this hook the driver can disable additional planes, cursors etc. that shouldn't be visible while fbdev is in control.

---
 drivers/gpu/drm/drm_fb_helper.c |    5 ++++-
 include/drm/drm_fb_helper.h     |    1 +
 2 files changed, 5 insertions(+), 1 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +4 -1
index 05e623a..6902097 100644
@@ -265,7 +265,10 @@ static bool drm_fb_helper_force_kernel_mode(void)
 		if (helper->dev->switch_power_state == DRM_SWITCH_POWER_OFF)
 			continue;
 
-		ret = drm_fb_helper_restore_fbdev_mode(helper);
+		if (helper->funcs->restore_fbdev_mode)
+			ret = helper->funcs->restore_fbdev_mode(helper);
+		else
+			ret = drm_fb_helper_restore_fbdev_mode(helper);
 		if (ret)
 			error = true;
 	}
include/drm/drm_fb_helper.h +1 -0
index 5120b01..7f76e9c 100644
@@ -56,6 +56,7 @@ struct drm_fb_helper_funcs {
 
 	int (*fb_probe)(struct drm_fb_helper *helper,
 			struct drm_fb_helper_surface_size *sizes);
+	int (*restore_fbdev_mode)(struct drm_fb_helper *helper);
 };
 
 struct drm_fb_helper_connector {
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH 5/81 drm: Export drm_property_create_blob() and drm_property_destroy_blob()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

---
 drivers/gpu/drm/drm_crtc.c |    8 +++++---
 include/drm/drm_crtc.h     |    4 ++++
 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +5 -3
index 3164131..38b8ce3 100644
@@ -3112,8 +3112,8 @@ done:
 	return ret;
 }
 
-static struct drm_property_blob *drm_property_create_blob(struct drm_device *dev, int length,
-							  void *data)
+struct drm_property_blob *drm_property_create_blob(struct drm_device *dev, int length,
+						   void *data)
 {
 	struct drm_property_blob *blob;
 	int ret;
@@ -3138,14 +3138,16 @@ static struct drm_property_blob *drm_property_create_blob(struct drm_device *dev
 	list_add_tail(&blob->head, &dev->mode_config.property_blob_list);
 	return blob;
 }
+EXPORT_SYMBOL(drm_property_create_blob);
 
-static void drm_property_destroy_blob(struct drm_device *dev,
+void drm_property_destroy_blob(struct drm_device *dev,
 			       struct drm_property_blob *blob)
 {
 	drm_mode_object_put(dev, &blob->base);
 	list_del(&blob->head);
 	kfree(blob);
 }
+EXPORT_SYMBOL(drm_property_destroy_blob);
 
 int drm_mode_getblob_ioctl(struct drm_device *dev,
 			   void *data, struct drm_file *file_priv)
include/drm/drm_crtc.h +4 -0
index 6b7d809..27812e0 100644
@@ -970,6 +970,10 @@ struct drm_property *drm_property_create_range(struct drm_device *dev, int flags
 					 const char *name,
 					 uint64_t min, uint64_t max);
 extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
+extern struct drm_property_blob *drm_property_create_blob(struct drm_device *dev,
+							  int length, void *data);
+extern void drm_property_destroy_blob(struct drm_device *dev,
+				      struct drm_property_blob *blob);
 extern int drm_property_add_enum(struct drm_property *property, int index,
 				 uint64_t value, const char *name);
 extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw

PATCH 6/81 drm: Allow signed values for range properties

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Treat a range property as signed when the unsigned minimum value is larger than the unsigned maximum value.

---
 drivers/gpu/drm/drm_crtc.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +14 -3
index 38b8ce3..7badd2a 100644
@@ -3213,14 +3213,25 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
 }
 EXPORT_SYMBOL(drm_mode_connector_update_edid_property);
 
-static bool drm_property_change_is_valid(struct drm_property *property,
+static bool range_property_is_signed(const struct drm_property *property)
+{
+	return property->values[0] > property->values[1];
+}
+
+static bool drm_property_change_is_valid(const struct drm_property *property,
 					 uint64_t value)
 {
 	if (property->flags & DRM_MODE_PROP_IMMUTABLE)
 		return false;
 	if (property->flags & DRM_MODE_PROP_RANGE) {
-		if (value < property->values[0] || value > property->values[1])
-			return false;
+		if (range_property_is_signed(property)) {
+			if ((int64_t)value < (int64_t)property->values[0] ||
+			    (int64_t)value > (int64_t)property->values[1])
+				return false;
+		} else {
+			if (value < property->values[0] || value > property->values[1])
+				return false;
+		}
 		return true;
 	} else if (property->flags & DRM_MODE_PROP_BITMASK) {
 		int i;
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

PATCH 7/81 drm: Allow drm_mode_object_find() to look up an object of any type

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

To avoid having to pass object types from userspace for atomic mode setting ioctl, allow drm_mode_object_find() to look up an object of any type. This will only work as long as the all object types share the ID space.

---
 drivers/gpu/drm/drm_crtc.c |    3 ++-
 include/drm/drm_crtc.h     |    1 +
 2 files changed, 3 insertions(+), 1 deletions(-)
drivers/gpu/drm/drm_crtc.c +2 -1
index 7badd2a..2dd3649 100644
@@ -267,7 +267,8 @@ struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
 
 	mutex_lock(&dev->mode_config.idr_mutex);
 	obj = idr_find(&dev->mode_config.crtc_idr, id);
-	if (!obj || (obj->type != type) || (obj->id != id))
+	if (!obj || (type != DRM_MODE_OBJECT_ANY && obj->type != type) ||
+	    (obj->id != id))
 		obj = NULL;
 	mutex_unlock(&dev->mode_config.idr_mutex);
 
include/drm/drm_crtc.h +1 -0
index 27812e0..28a972a 100644
@@ -48,6 +48,7 @@ struct drm_object_properties;
 #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
 #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
 #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
+#define DRM_MODE_OBJECT_ANY 0
 
 struct drm_mode_object {
 	uint32_t id;
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

PATCH 8/81 drm: Export drm_encoder_crtc_ok

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

---
 drivers/gpu/drm/drm_crtc_helper.c |    5 +++--
 include/drm/drm_crtc_helper.h     |    3 +++
 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_crtc_helper.c +3 -2
index 7b2d378..0d62c94 100644
@@ -312,8 +312,8 @@ EXPORT_SYMBOL(drm_helper_disable_unused_functions);
  *
  * Return false if @encoder can't be driven by @crtc, true otherwise.
  */
-static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
-				struct drm_crtc *crtc)
+bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
+			 struct drm_crtc *crtc)
 {
 	struct drm_device *dev;
 	struct drm_crtc *tmp;
@@ -333,6 +333,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
 		return true;
 	return false;
 }
+EXPORT_SYMBOL(drm_encoder_crtc_ok);
 
 /*
  * Check the CRTC we're going to map each output to vs. its current
include/drm/drm_crtc_helper.h +3 -0
index f43d556..5abae74 100644
@@ -169,4 +169,7 @@ extern void drm_kms_helper_hotplug_event(struct drm_device *dev);
 extern void drm_kms_helper_poll_disable(struct drm_device *dev);
 extern void drm_kms_helper_poll_enable(struct drm_device *dev);
 
+extern bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
+				struct drm_crtc *crtc);
+
 #endif
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

PATCH 9/81 drm: Export drm_crtc_prepare_encoders()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

---
 drivers/gpu/drm/drm_crtc_helper.c |    3 ++-
 include/drm/drm_crtc_helper.h     |    1 +
 2 files changed, 3 insertions(+), 1 deletions(-)
drivers/gpu/drm/drm_crtc_helper.c +2 -1
index 0d62c94..30eb557 100644
@@ -340,7 +340,7 @@ EXPORT_SYMBOL(drm_encoder_crtc_ok);
  * CRTC.  If they don't match, we have to disable the output and the CRTC
  * since the driver will have to re-route things.
  */
-static void
+void
 drm_crtc_prepare_encoders(struct drm_device *dev)
 {
 	struct drm_encoder_helper_funcs *encoder_funcs;
@@ -357,6 +357,7 @@ drm_crtc_prepare_encoders(struct drm_device *dev)
 			drm_encoder_disable(encoder);
 	}
 }
+EXPORT_SYMBOL(drm_crtc_prepare_encoders);
 
 /**
  * drm_crtc_helper_set_mode - internal helper to set a mode
include/drm/drm_crtc_helper.h +1 -0
index 5abae74..7702a3a 100644
@@ -171,5 +171,6 @@ extern void drm_kms_helper_poll_enable(struct drm_device *dev);
 
 extern bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
 				struct drm_crtc *crtc);
+extern void drm_crtc_prepare_encoders(struct drm_device *dev);
 
 #endif
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw

PATCH 10/81 drm: Refactor object property check code

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Refactor the code to check whether an object has a specific property to a new function.

---
 drivers/gpu/drm/drm_crtc.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_crtc.c +14 -6
index 2dd3649..0a9a7cb 100644
@@ -3374,6 +3374,19 @@ out:
 	return ret;
 }
 
+static bool object_has_prop(const struct drm_mode_object *obj, u32 prop_id)
+{
+	int i;
+
+	if (!obj->properties)
+		return false;
+
+	for (i = 0; i < obj->properties->count; i++)
+		if (obj->properties->ids[i] == prop_id)
+			return true;
+	return false;
+}
+
 int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,
 				    struct drm_file *file_priv)
 {
@@ -3382,7 +3395,6 @@ int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,
 	struct drm_mode_object *prop_obj;
 	struct drm_property *property;
 	int ret = -EINVAL;
-	int i;
 
 	if (!drm_core_check_feature(dev, DRIVER_MODESET))
 		return -EINVAL;
@@ -3395,11 +3407,7 @@ int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,
 	if (!arg_obj->properties)
 		goto out;
 
-	for (i = 0; i < arg_obj->properties->count; i++)
-		if (arg_obj->properties->ids[i] == arg->prop_id)
-			break;
-
-	if (i == arg_obj->properties->count)
+	if (!object_has_prop(arg_obj, arg->prop_id))
 		goto out;
 
 	prop_obj = drm_mode_object_find(dev, arg->prop_id,
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw

PATCH 11/81 drm: Export mode<->umode conversion functions

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Export drm_crtc_convert_to_umode() and drm_crtc_convert_umode().

---
 drivers/gpu/drm/drm_crtc.c |   10 ++++++----
 include/drm/drm_crtc.h     |    4 ++++
 2 files changed, 10 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_crtc.c +6 -4
index 0a9a7cb..3709f8c 100644
@@ -1119,8 +1119,8 @@ EXPORT_SYMBOL(drm_mode_config_cleanup);
  * Convert a drm_display_mode into a drm_mode_modeinfo structure to return to
  * the user.
  */
-static void drm_crtc_convert_to_umode(struct drm_mode_modeinfo *out,
-				      const struct drm_display_mode *in)
+void drm_crtc_convert_to_umode(struct drm_mode_modeinfo *out,
+			       const struct drm_display_mode *in)
 {
 	WARN(in->hdisplay > USHRT_MAX || in->hsync_start > USHRT_MAX ||
 	     in->hsync_end > USHRT_MAX || in->htotal > USHRT_MAX ||
@@ -1146,6 +1146,7 @@ static void drm_crtc_convert_to_umode(struct drm_mode_modeinfo *out,
 	strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN);
 	out->name[DRM_DISPLAY_MODE_LEN-1] = 0;
 }
+EXPORT_SYMBOL(drm_crtc_convert_to_umode);
 
 /**
  * drm_crtc_convert_to_umode - convert a modeinfo into a drm_display_mode
@@ -1161,8 +1162,8 @@ static void drm_crtc_convert_to_umode(struct drm_mode_modeinfo *out,
  * RETURNS:
  * Zero on success, errno on failure.
  */
-static int drm_crtc_convert_umode(struct drm_display_mode *out,
-				  const struct drm_mode_modeinfo *in)
+int drm_crtc_convert_umode(struct drm_display_mode *out,
+			   const struct drm_mode_modeinfo *in)
 {
 	if (in->clock > INT_MAX || in->vrefresh > INT_MAX)
 		return -ERANGE;
@@ -1186,6 +1187,7 @@ static int drm_crtc_convert_umode(struct drm_display_mode *out,
 
 	return 0;
 }
+EXPORT_SYMBOL(drm_crtc_convert_umode);
 
 /**
  * drm_mode_getresources - get graphics configuration
include/drm/drm_crtc.h +4 -0
index 28a972a..23f2f37 100644
@@ -1090,6 +1090,10 @@ extern int drm_format_num_planes(uint32_t format);
 extern int drm_format_plane_cpp(uint32_t format, int plane);
 extern int drm_format_horz_chroma_subsampling(uint32_t format);
 extern int drm_format_vert_chroma_subsampling(uint32_t format);
+extern void drm_crtc_convert_to_umode(struct drm_mode_modeinfo *out,
+				      const struct drm_display_mode *in);
+extern int drm_crtc_convert_umode(struct drm_display_mode *out,
+				  const struct drm_mode_modeinfo *in);
 
 /**
  * drm_region - two dimensional region
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#12 lore raw

PATCH 12/81 drm: Make blobs resizeable

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

When first allocated blobs can be given a maximum size for which memory is allocated. Later the data inside the blob can be replaced, assuming that the maximum size is not exceeded.

---
 drivers/gpu/drm/drm_crtc.c |   45 ++++++++++++++++++++++++++++++++++++++-----
 include/drm/drm_crtc.h     |    8 ++++++-
 2 files changed, 46 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_crtc.c +39 -6
index 3709f8c..aeda9f4 100644
@@ -2926,6 +2926,9 @@ void drm_property_destroy(struct drm_device *dev, struct drm_property *property)
 {
 	struct drm_property_enum *prop_enum, *pt;
 
+	if (!property)
+		return;
+
 	list_for_each_entry_safe(prop_enum, pt, &property->enum_blob_list, head) {
 		list_del(&prop_enum->head);
 		kfree(prop_enum);
@@ -3115,16 +3118,24 @@ done:
 	return ret;
 }
 
-struct drm_property_blob *drm_property_create_blob(struct drm_device *dev, int length,
-						   void *data)
+struct drm_property_blob *drm_property_create_blob(struct drm_device *dev,
+						   unsigned int length,
+						   unsigned int max_length,
+						   const void *data)
 {
 	struct drm_property_blob *blob;
 	int ret;
 
-	if (!length || !data)
+	if (!!length != !!data)
 		return NULL;
 
-	blob = kzalloc(sizeof(struct drm_property_blob)+length, GFP_KERNEL);
+	if (max_length < length)
+		max_length = length;
+
+	if (max_length == 0)
+		return NULL;
+
+	blob = kzalloc(sizeof(struct drm_property_blob)+max_length, GFP_KERNEL);
 	if (!blob)
 		return NULL;
 
@@ -3134,18 +3145,40 @@ struct drm_property_blob *drm_property_create_blob(struct drm_device *dev, int l
 		return NULL;
 	}
 
+	blob->max_length = max_length;
 	blob->length = length;
 
-	memcpy(blob->data, data, length);
+	if (length)
+		memcpy(blob->data, data, length);
 
 	list_add_tail(&blob->head, &dev->mode_config.property_blob_list);
 	return blob;
 }
 EXPORT_SYMBOL(drm_property_create_blob);
 
+int drm_property_blob_replace_data(struct drm_property_blob *blob,
+				   unsigned int length, const void *data)
+{
+	if (!!length != !!data)
+		return -EINVAL;
+
+	if (length > blob->max_length)
+		return -ENOSPC;
+
+	blob->length = length;
+	if (length)
+		memcpy(blob->data, data, length);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_property_blob_replace_data);
+
 void drm_property_destroy_blob(struct drm_device *dev,
 			       struct drm_property_blob *blob)
 {
+	if (!blob)
+		return;
+
 	drm_mode_object_put(dev, &blob->base);
 	list_del(&blob->head);
 	kfree(blob);
@@ -3204,7 +3237,7 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
 
 	size = EDID_LENGTH * (1 + edid->extensions);
 	connector->edid_blob_ptr = drm_property_create_blob(connector->dev,
-							    size, edid);
+							    size, 0, edid);
 	if (!connector->edid_blob_ptr)
 		return -EINVAL;
 
include/drm/drm_crtc.h +7 -1
index 23f2f37..5b8b1b7 100644
@@ -276,6 +276,7 @@ struct drm_property_blob {
 	struct drm_mode_object base;
 	struct list_head head;
 	unsigned int length;
+	unsigned int max_length;
 	unsigned char data[];
 };
 
@@ -972,7 +973,12 @@ struct drm_property *drm_property_create_range(struct drm_device *dev, int flags
 					 uint64_t min, uint64_t max);
 extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
 extern struct drm_property_blob *drm_property_create_blob(struct drm_device *dev,
-							  int length, void *data);
+							  unsigned int level,
+							  unsigned int max_length,
+							  const void *data);
+extern int drm_property_blob_replace_data(struct drm_property_blob *blob,
+					  unsigned int length,
+					  const void *data);
 extern void drm_property_destroy_blob(struct drm_device *dev,
 				      struct drm_property_blob *blob);
 extern int drm_property_add_enum(struct drm_property *property, int index,
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw

PATCH 13/81 drm: Add drm_flip helper

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

The drm_flip mechanism can be used to implement robust page flipping support, and also to synchronize the flips on multiple hardware scanout engines (eg. CRTCs and overlays).

---
 drivers/gpu/drm/Makefile   |    2 +-
 drivers/gpu/drm/drm_flip.c |  376 ++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_flip.h     |  244 ++++++++++++++++++++++++++++
 3 files changed, 621 insertions(+), 1 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_flip.c
 create mode 100644 include/drm/drm_flip.h
drivers/gpu/drm/Makefile +1 -1
index 6f58c81..f2965de 100644
@@ -12,7 +12,7 @@ drm-y       :=	drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \
 		drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \
 		drm_crtc.o drm_modes.o drm_edid.o \
 		drm_info.o drm_debugfs.o drm_encoder_slave.o \
-		drm_trace_points.o drm_global.o drm_prime.o
+		drm_trace_points.o drm_global.o drm_prime.o drm_flip.o
 
 drm-$(CONFIG_COMPAT) += drm_ioc32.o
 drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o
drivers/gpu/drm/drm_flip.c new file +376 -0

376 lines not on this page · raw message

include/drm/drm_flip.h new file +244 -0

244 lines not on this page · raw message

Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#14 lore raw

PATCH 14/81 drm: Add mode_blob and connector_ids_blob to drm_crtc

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

These will be ued by standard properties MODE and CONNECTOR_IDS.

---
 include/drm/drm_crtc.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/drm/drm_crtc.h +3 -0
index 5b8b1b7..d05d302 100644
@@ -423,6 +423,9 @@ struct drm_crtc {
 	void *helper_private;
 
 	struct drm_object_properties properties;
+
+	struct drm_property_blob *mode_blob;
+	struct drm_property_blob *connector_ids_blob;
 };
 
 
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#15 lore raw

PATCH 15/81 drm: Add the atomic modeset ioctl

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

This new ioctl can be used to update an arbitrary set of object properties in one operation.

The ioctl simply takes a list of object IDs and property IDs and their values. For setting values of blob properties, the property value indicates the length of the data, and the actual data is passed via another blob pointer.

Three flags are currently supported to alter the behaviour of the ioctl:
- DRM_MODE_ATOMIC_TEST_ONLY indicates that the new state chould only be checked for validity, but not hardware state is to be modified.
- DRM_MODE_ATOMIC_EVENT requests that asynchronous completion events be sent back to user space. A new event type is added for this purpose.
- DRM_MODE_ATOMIC_NONBLOCK indicates that the operation must be completed asynchronously without blocking the the caller for significant amounts of time.

Internally the driver must implement the functions pointers in struct drm_atomic_funcs to support the new ioctl.

---
 drivers/gpu/drm/drm_crtc.c  |  146 +++++++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_drv.c   |    1 +
 include/drm/drmP.h          |    8 +++
 include/drm/drm_crtc.h      |   13 ++++
 include/uapi/drm/drm.h      |   12 ++++
 include/uapi/drm/drm_mode.h |   17 +++++
 6 files changed, 197 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc.c +146 -0
index aeda9f4..897ff46 100644
@@ -4245,3 +4245,149 @@ int drm_calc_vscale(struct drm_region *src, struct drm_region *dst,
 	return vscale;
 }
 EXPORT_SYMBOL(drm_calc_vscale);
+
+int drm_mode_atomic_ioctl(struct drm_device *dev,
+			  void *data, struct drm_file *file_priv)
+{
+	struct drm_mode_atomic *arg = data;
+	uint32_t __user *objs_ptr = (uint32_t __user *)(unsigned long)(arg->objs_ptr);
+	uint32_t __user *count_props_ptr = (uint32_t __user *)(unsigned long)(arg->count_props_ptr);
+	uint32_t __user *props_ptr = (uint32_t __user *)(unsigned long)(arg->props_ptr);
+	uint64_t __user *prop_values_ptr = (uint64_t __user *)(unsigned long)(arg->prop_values_ptr);
+	uint64_t __user *blob_values_ptr = (uint64_t __user *)(unsigned long)(arg->blob_values_ptr);
+	unsigned int copied_objs = 0;
+	unsigned int copied_props = 0;
+	unsigned int copied_blobs = 0;
+	void *state;
+	int ret = 0;
+	unsigned int i, j;
+
+	if (!dev->driver->atomic_funcs ||
+	    !dev->driver->atomic_funcs->begin ||
+	    !dev->driver->atomic_funcs->set ||
+	    !dev->driver->atomic_funcs->check ||
+	    !dev->driver->atomic_funcs->commit ||
+	    !dev->driver->atomic_funcs->end)
+		return -ENOSYS;
+
+	if (arg->flags & ~(DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_EVENT | DRM_MODE_ATOMIC_NONBLOCK))
+		return -EINVAL;
+
+	/* can't test and expect an event at the same time. */
+	if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY && arg->flags & DRM_MODE_ATOMIC_EVENT)
+		return -EINVAL;
+
+	mutex_lock(&dev->mode_config.mutex);
+
+	state = dev->driver->atomic_funcs->begin(dev, file_priv, arg->flags, arg->user_data);
+	if (IS_ERR(state)) {
+		ret = PTR_ERR(state);
+		goto unlock;
+	}
+
+	for (i = 0; i < arg->count_objs; i++) {
+		uint32_t obj_id, count_props;
+		struct drm_mode_object *obj;
+
+		if (get_user(obj_id, objs_ptr + copied_objs)) {
+			ret = -EFAULT;
+			goto out;
+		}
+
+		obj = drm_mode_object_find(dev, obj_id, DRM_MODE_OBJECT_ANY);
+		if (!obj || !obj->properties) {
+			ret = -ENOENT;
+			goto out;
+		}
+
+		if (get_user(count_props, count_props_ptr + copied_objs)) {
+			ret = -EFAULT;
+			goto out;
+		}
+
+		copied_objs++;
+
+		for (j = 0; j < count_props; j++) {
+			uint32_t prop_id;
+			uint64_t prop_value;
+			struct drm_mode_object *prop_obj;
+			struct drm_property *prop;
+			void *blob_data = NULL;
+
+			if (get_user(prop_id, props_ptr + copied_props)) {
+				ret = -EFAULT;
+				goto out;
+			}
+
+			if (!object_has_prop(obj, prop_id)) {
+				ret = -EINVAL;
+				goto out;
+			}
+
+			prop_obj = drm_mode_object_find(dev, prop_id, DRM_MODE_OBJECT_PROPERTY);
+			if (!prop_obj) {
+				ret = -ENOENT;
+				goto out;
+			}
+			prop = obj_to_property(prop_obj);
+
+			if (get_user(prop_value, prop_values_ptr + copied_props)) {
+				ret = -EFAULT;
+				goto out;
+			}
+
+			if (!drm_property_change_is_valid(prop, prop_value)) {
+				ret = -EINVAL;
+				goto out;
+			}
+
+			if (prop->flags & DRM_MODE_PROP_BLOB && prop_value) {
+				uint64_t blob_ptr;
+
+				if (get_user(blob_ptr, blob_values_ptr + copied_blobs)) {
+					ret = -EFAULT;
+					goto out;
+				}
+
+				blob_data = kmalloc(prop_value, GFP_KERNEL);
+				if (!blob_data) {
+					ret = -ENOMEM;
+					goto out;
+				}
+
+				if (copy_from_user(blob_data, (void __user *)(unsigned long)blob_ptr, prop_value)) {
+					kfree(blob_data);
+					ret = -EFAULT;
+					goto out;
+				}
+			}
+
+			/* User space sends the blob pointer even if we don't use it (length==0). */
+			if (prop->flags & DRM_MODE_PROP_BLOB)
+				copied_blobs++;
+
+			/* The driver will be in charge of blob_data from now on. */
+			ret = dev->driver->atomic_funcs->set(dev, state, obj, prop, prop_value, blob_data);
+			if (ret)
+				goto out;
+
+			copied_props++;
+		}
+	}
+
+	ret = dev->driver->atomic_funcs->check(dev, state);
+	if (ret)
+		goto out;
+
+	if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY)
+		goto out;
+
+	ret = dev->driver->atomic_funcs->commit(dev, state);
+
+ out:
+	dev->driver->atomic_funcs->end(dev, state);
+ unlock:
+	mutex_unlock(&dev->mode_config.mutex);
+
+	return ret;
+}
drivers/gpu/drm/drm_drv.c +1 -0
index be174ca..dbef305 100644
@@ -166,6 +166,7 @@ static struct drm_ioctl_desc drm_ioctls[] = {
 	DRM_IOCTL_DEF(DRM_IOCTL_MODE_DESTROY_DUMB, drm_mode_destroy_dumb_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_MODE_OBJ_GETPROPERTIES, drm_mode_obj_get_properties_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_MODE_OBJ_SETPROPERTY, drm_mode_obj_set_property_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+	DRM_IOCTL_DEF(DRM_IOCTL_MODE_ATOMIC, drm_mode_atomic_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 };
 
 #define DRM_CORE_IOCTL_COUNT	ARRAY_SIZE( drm_ioctls )
include/drm/drmP.h +8 -0
index fad21c9..1773812 100644
@@ -958,6 +958,8 @@ struct drm_driver {
 
 	/* List of devices hanging off this driver */
 	struct list_head device_list;
+
+	const struct drm_atomic_funcs *atomic_funcs;
 };
 
 #define DRM_MINOR_UNASSIGNED 0
@@ -1051,6 +1053,12 @@ struct drm_pending_vblank_event {
 	struct drm_event_vblank event;
 };
 
+struct drm_pending_atomic_event {
+	struct drm_pending_event base;
+	int pipe;
+	struct drm_event_atomic event;
+};
+
 /**
  * DRM device structure. This structure represent a complete card that
  * may contain multiple heads.
include/drm/drm_crtc.h +13 -0
index d05d302..77f08a3 100644
@@ -1092,6 +1092,8 @@ extern int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
 					     struct drm_file *file_priv);
 extern int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,
 					   struct drm_file *file_priv);
+extern int drm_mode_atomic_ioctl(struct drm_device *dev,
+				 void *data, struct drm_file *file_priv);
 
 extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
 				 int *bpp);
@@ -1132,4 +1134,15 @@ extern int drm_calc_hscale(struct drm_region *src, struct drm_region *dst,
 extern int drm_calc_vscale(struct drm_region *src, struct drm_region *dst,
 			   int min_vscale, int max_vscale);
 
+struct drm_atomic_funcs {
+	void *(*begin)(struct drm_device *dev, struct drm_file *file,
+		       uint32_t flags, uint64_t user_data);
+	int (*set)(struct drm_device *dev, void *state,
+		   struct drm_mode_object *obj, struct drm_property *prop,
+		   uint64_t value, void *blob_data);
+	int (*check)(struct drm_device *dev, void *state);
+	int (*commit)(struct drm_device *dev, void *state);
+	void (*end)(struct drm_device *dev, void *state);
+};
+
 #endif /* __DRM_CRTC_H__ */
include/uapi/drm/drm.h +12 -0
index 8d1e2bb..7b057ca 100644
@@ -732,6 +732,7 @@ struct drm_prime_handle {
 #define DRM_IOCTL_MODE_ADDFB2		DRM_IOWR(0xB8, struct drm_mode_fb_cmd2)
 #define DRM_IOCTL_MODE_OBJ_GETPROPERTIES	DRM_IOWR(0xB9, struct drm_mode_obj_get_properties)
 #define DRM_IOCTL_MODE_OBJ_SETPROPERTY	DRM_IOWR(0xBA, struct drm_mode_obj_set_property)
+#define DRM_IOCTL_MODE_ATOMIC	DRM_IOWR(0xBB, struct drm_mode_atomic)
 
 /**
  * Device specific ioctls should only be in their respective headers
@@ -763,6 +764,7 @@ struct drm_event {
 
 #define DRM_EVENT_VBLANK 0x01
 #define DRM_EVENT_FLIP_COMPLETE 0x02
+#define DRM_EVENT_ATOMIC_COMPLETE 0x03
 
 struct drm_event_vblank {
 	struct drm_event base;
@@ -773,6 +775,16 @@ struct drm_event_vblank {
 	__u32 reserved;
 };
 
+struct drm_event_atomic {
+	struct drm_event base;
+	__u64 user_data;
+	__u32 tv_sec;
+	__u32 tv_usec;
+	__u32 sequence;
+	__u32 obj_id;
+	__u32 old_fb_id;
+};
+
 #define DRM_CAP_DUMB_BUFFER 0x1
 #define DRM_CAP_VBLANK_HIGH_CRTC 0x2
 #define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3
include/uapi/drm/drm_mode.h +17 -0
index 3d6301b..71f5e0d 100644
@@ -460,4 +460,21 @@ struct drm_mode_destroy_dumb {
 	uint32_t handle;
 };
 
+
+#define DRM_MODE_ATOMIC_TEST_ONLY (1<<0)
+#define DRM_MODE_ATOMIC_EVENT (1<<1)
+#define DRM_MODE_ATOMIC_NONBLOCK (1<<2)
+
+/* FIXME come up with some sane error reporting mechanism? */
+struct drm_mode_atomic {
+	__u32 flags;
+	__u32 count_objs;
+	__u64 objs_ptr;
+	__u64 count_props_ptr;
+	__u64 props_ptr;
+	__u64 prop_values_ptr;
+	__u64 blob_values_ptr;
+	__u64 user_data;
+};
+
 #endif
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#16 lore raw

PATCH 16/81 drm/i915: Use drm_format_plane_cpp() rather than bits_per_pixel/8

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

bits_per_pixel may not be populated for all pixel formats, so let's just use drm_format_plane_cpp().

---
 drivers/gpu/drm/i915/intel_display.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_display.c +6 -6
index 21dd4db..a4e71e5 100644
@@ -1991,6 +1991,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 	unsigned long linear_offset;
 	u32 dspcntr;
 	u32 reg;
+	unsigned int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
 
 	switch (plane) {
 	case 0:
@@ -2049,13 +2050,12 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 
 	I915_WRITE(reg, dspcntr);
 
-	linear_offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
+	linear_offset = y * fb->pitches[0] + x * cpp;
 
 	if (INTEL_INFO(dev)->gen >= 4) {
 		intel_crtc->dspaddr_offset =
 			intel_gen4_compute_offset_xtiled(&x, &y,
-							 fb->bits_per_pixel / 8,
-							 fb->pitches[0]);
+							 cpp, fb->pitches[0]);
 		linear_offset -= intel_crtc->dspaddr_offset;
 	} else {
 		intel_crtc->dspaddr_offset = linear_offset;
@@ -2088,6 +2088,7 @@ static int ironlake_update_plane(struct drm_crtc *crtc,
 	unsigned long linear_offset;
 	u32 dspcntr;
 	u32 reg;
+	unsigned int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
 
 	switch (plane) {
 	case 0:
@@ -2144,11 +2145,10 @@ static int ironlake_update_plane(struct drm_crtc *crtc,
 
 	I915_WRITE(reg, dspcntr);
 
-	linear_offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
+	linear_offset = y * fb->pitches[0] + x * cpp;
 	intel_crtc->dspaddr_offset =
 		intel_gen4_compute_offset_xtiled(&x, &y,
-						 fb->bits_per_pixel / 8,
-						 fb->pitches[0]);
+						 cpp, fb->pitches[0]);
 	linear_offset -= intel_crtc->dspaddr_offset;
 
 	DRM_DEBUG_KMS("Writing base %08X %08lX %d %d %d\n",
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#17 lore raw

PATCH 17/81 drm/i915: Implement proper clipping for video sprites

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Properly clip the source when the destination gets clipped by the pipe dimensions.

Sadly the video sprite hardware is rather limited so it can't do proper sub-pixel postitioning. Resort to a best effort approach, where the source coordinates are rounded to the nearest (macro)pixel boundary.

Also do some additional checking against various hardware limits.

---
 drivers/gpu/drm/i915/intel_sprite.c |  171 +++++++++++++++++++++++------------
 1 files changed, 111 insertions(+), 60 deletions(-)
drivers/gpu/drm/i915/intel_sprite.c +111 -60
index 827dcd4..77ca0da 100644
@@ -120,11 +120,10 @@ ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
 	I915_WRITE(SPRSTRIDE(pipe), fb->pitches[0]);
 	I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x);
 
-	linear_offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
+	linear_offset = y * fb->pitches[0] + x * pixel_size;
 	sprsurf_offset =
 		intel_gen4_compute_offset_xtiled(&x, &y,
-						 fb->bits_per_pixel / 8,
-						 fb->pitches[0]);
+						 pixel_size, fb->pitches[0]);
 	linear_offset -= sprsurf_offset;
 
 	/* HSW consolidates SPRTILEOFF and SPRLINOFF into a single SPROFFSET
@@ -286,11 +285,10 @@ ilk_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
 	I915_WRITE(DVSSTRIDE(pipe), fb->pitches[0]);
 	I915_WRITE(DVSPOS(pipe), (crtc_y << 16) | crtc_x);
 
-	linear_offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
+	linear_offset = y * fb->pitches[0] + x * pixel_size;
 	dvssurf_offset =
 		intel_gen4_compute_offset_xtiled(&x, &y,
-						 fb->bits_per_pixel / 8,
-						 fb->pitches[0]);
+						 pixel_size, fb->pitches[0]);
 	linear_offset -= dvssurf_offset;
 
 	if (obj->tiling_mode != I915_TILING_NONE)
@@ -409,6 +407,20 @@ ilk_get_colorkey(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key)
 		key->flags = I915_SET_COLORKEY_NONE;
 }
 
+static bool
+format_is_yuv(uint32_t format)
+{
+	switch (format) {
+	case DRM_FORMAT_YUYV:
+	case DRM_FORMAT_UYVY:
+	case DRM_FORMAT_VYUY:
+	case DRM_FORMAT_YVYU:
+		return true;
+	default:
+		return false;
+	}
+}
+
 static int
 intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 		   struct drm_framebuffer *fb, int crtc_x, int crtc_y,
@@ -420,35 +432,68 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_plane *intel_plane = to_intel_plane(plane);
-	struct intel_framebuffer *intel_fb;
-	struct drm_i915_gem_object *obj, *old_obj;
+	struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
+	struct drm_i915_gem_object *obj = intel_fb->obj;
+	struct drm_i915_gem_object *old_obj = intel_plane->obj;
 	int pipe = intel_plane->pipe;
 	enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv,
 								      pipe);
 	int ret = 0;
-	int x = src_x >> 16, y = src_y >> 16;
 	int primary_w = crtc->mode.hdisplay, primary_h = crtc->mode.vdisplay;
 	bool disable_primary = false;
-
-	intel_fb = to_intel_framebuffer(fb);
-	obj = intel_fb->obj;
-
-	old_obj = intel_plane->obj;
-
-	src_w = src_w >> 16;
-	src_h = src_h >> 16;
-
-	/* Pipe must be running... */
-	if (!(I915_READ(PIPECONF(cpu_transcoder)) & PIPECONF_ENABLE))
-		return -EINVAL;
-
-	if (crtc_x >= primary_w || crtc_y >= primary_h)
-		return -EINVAL;
+	bool visible;
+	int hscale, vscale;
+	int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+	struct drm_region src = {
+		.x1 = src_x,
+		.x2 = src_x + src_w,
+		.y1 = src_y,
+		.y2 = src_y + src_h,
+	};
+	struct drm_region dst = {
+		.x1 = crtc_x,
+		.x2 = crtc_x + crtc_w,
+		.y1 = crtc_y,
+		.y2 = crtc_y + crtc_h,
+	};
+	const struct drm_region clip = {
+		.x2 = crtc->mode.hdisplay,
+		.y2 = crtc->mode.vdisplay,
+	};
 
 	/* Don't modify another pipe's plane */
 	if (intel_plane->pipe != intel_crtc->pipe)
 		return -EINVAL;
 
+	if (fb->width < 3 || fb->height < 3 || fb->pitches[0] > 16384)
+		return -EINVAL;
+
+	/*
+	 * We may not have a scaler, eg. HSW does not have it any more
+	 */
+	if (!intel_plane->can_scale && (((uint64_t) crtc_w << 16) != src_w ||
+					((uint64_t) crtc_h << 16) != src_h))
+		return -EINVAL;
+
+	/*
+	 * FIXME the following code does a bunch of fuzzy adjustments to the
+	 * coordinates and sizes. We probably need some way to decide whether
+	 * strict checking should be done instead.
+	 */
+	hscale = drm_calc_hscale(&src, &dst, 1, intel_plane->max_downscale << 16);
+	vscale = drm_calc_vscale(&src, &dst, 1, intel_plane->max_downscale << 16);
+
+	visible = drm_region_clip_scaled(&src, &dst, &clip, hscale, vscale);
+
+	crtc_x = dst.x1;
+	crtc_y = dst.y1;
+	crtc_w = drm_region_width(&dst);
+	crtc_h = drm_region_height(&dst);
+
+	/* HW doesn't seem to like smaller sprite, even when scaling */
+	if (crtc_w < 3 || crtc_h < 3)
+		visible = false;
+
 	/* Sprite planes can be linear or x-tiled surfaces */
 	switch (obj->tiling_mode) {
 		case I915_TILING_NONE:
@@ -459,43 +504,47 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	}
 
 	/*
-	 * Clamp the width & height into the visible area.  Note we don't
-	 * try to scale the source if part of the visible region is offscreen.
-	 * The caller must handle that by adjusting source offset and size.
+	 * Hardware doesn't handle subpixel coordinates.
+	 * Round to nearest (macro)pixel boundary.
 	 */
-	if ((crtc_x < 0) && ((crtc_x + crtc_w) > 0)) {
-		crtc_w += crtc_x;
-		crtc_x = 0;
+	if (format_is_yuv(fb->pixel_format)) {
+		src_x = ((src.x1 + 0x10000) >> 17) << 1;
+		src_w = (((src.x2 + 0x10000) >> 17) << 1) - src_x;
+	} else {
+		src_x = (src.x1 + 0x8000) >> 16;
+		src_w = ((src.x2 + 0x8000) >> 16) - src_x;
 	}
-	if ((crtc_x + crtc_w) <= 0) /* Nothing to display */
-		goto out;
-	if ((crtc_x + crtc_w) > primary_w)
-		crtc_w = primary_w - crtc_x;
+	src_y = (src.y1 + 0x8000) >> 16;
+	src_h = ((src.y2 + 0x8000) >> 16) - src_y;
 
-	if ((crtc_y < 0) && ((crtc_y + crtc_h) > 0)) {
-		crtc_h += crtc_y;
-		crtc_y = 0;
-	}
-	if ((crtc_y + crtc_h) <= 0) /* Nothing to display */
-		goto out;
-	if (crtc_y + crtc_h > primary_h)
-		crtc_h = primary_h - crtc_y;
+	/* Account for minimum source size when scaling */
+	if (visible && (src_w != crtc_w || src_h != crtc_h)) {
+		unsigned int min_w = format_is_yuv(fb->pixel_format) ? 4 : 3;
 
-	if (!crtc_w || !crtc_h) /* Again, nothing to display */
-		goto out;
+		if (src_w < min_w) {
+			src_w = min_w;
+			if (src_x > fb->width - src_w)
+				src_x = fb->width - src_w;
+		}
 
-	/*
-	 * We may not have a scaler, eg. HSW does not have it any more
-	 */
-	if (!intel_plane->can_scale && (crtc_w != src_w || crtc_h != src_h))
-		return -EINVAL;
+		/* FIXME interlacing */
+		if (src_h < 3) {
+			src_h = 3;
+			if (src_y > fb->height - src_h)
+				src_y = fb->height - src_h;
+		}
+	}
 
-	/*
-	 * We can take a larger source and scale it down, but
-	 * only so much...  16x is the max on SNB.
-	 */
-	if (((src_w * src_h) / (crtc_w * crtc_h)) > intel_plane->max_downscale)
-		return -EINVAL;
+	/* Check size restrictions when scaling */
+	if (visible && (src_w != crtc_w || src_h != crtc_h)) {
+		if (src_w > 2048 || src_h > 2048 ||
+		    src_w * cpp > 4096 - 64 || fb->pitches[0] > 4096)
+			return -EINVAL;
+	}
+
+	/* Pipe must be running... */
+	if (!(I915_READ(PIPECONF(pipe)) & PIPECONF_ENABLE))
+		return 0;
 
 	/*
 	 * If the sprite is completely covering the primary plane,
@@ -520,11 +569,14 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	if (!disable_primary)
 		intel_enable_primary(crtc);
 
-	intel_plane->update_plane(plane, fb, obj, crtc_x, crtc_y,
-				  crtc_w, crtc_h, x, y, src_w, src_h);
+	if (visible) {
+		intel_plane->update_plane(plane, fb, obj, crtc_x, crtc_y,
+					  crtc_w, crtc_h, src_x, src_y, src_w, src_h);
 
-	if (disable_primary)
-		intel_disable_primary(crtc);
+		if (disable_primary)
+			intel_disable_primary(crtc);
+	} else
+		intel_plane->disable_plane(plane);
 
 	/* Unpin old obj after new one is active to avoid ugliness */
 	if (old_obj) {
@@ -544,7 +596,6 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 
 out_unlock:
 	mutex_unlock(&dev->struct_mutex);
-out:
 	return ret;
 }
 
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#18 lore raw

PATCH 18/81 drm/i915: Implement restore_fbdev_mode hook

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Convert intel_fb_restore_mode to be useable as the drm_fb_helper.restore_fbdev_mode hook. This will cause all planes to be disabled when swithing back to fbcon.

---
 drivers/gpu/drm/i915/i915_dma.c  |    2 +-
 drivers/gpu/drm/i915/intel_drv.h |    2 +-
 drivers/gpu/drm/i915/intel_fb.c  |   14 ++++++++++----
 3 files changed, 12 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +1 -1
index 6fec5d4..392c9a1 100644
@@ -1790,7 +1790,7 @@ void i915_driver_lastclose(struct drm_device * dev)
 		return;
 
 	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
-		intel_fb_restore_mode(dev);
+		intel_fb_restore_mode(&dev_priv->fbdev->helper);
 		vga_switcheroo_process_delayed_switch();
 		return;
 	}
drivers/gpu/drm/i915/intel_drv.h +1 -1
index 6724be8..16770cb 100644
@@ -606,7 +606,7 @@ extern int intel_overlay_attrs(struct drm_device *dev, void *data,
 			       struct drm_file *file_priv);
 
 extern void intel_fb_output_poll_changed(struct drm_device *dev);
-extern void intel_fb_restore_mode(struct drm_device *dev);
+extern int intel_fb_restore_mode(struct drm_fb_helper *helper);
 
 extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
 			bool state);
drivers/gpu/drm/i915/intel_fb.c +10 -4
index b7773e5..3ab7967 100644
@@ -195,6 +195,7 @@ static struct drm_fb_helper_funcs intel_fb_helper_funcs = {
 	.gamma_set = intel_crtc_fb_gamma_set,
 	.gamma_get = intel_crtc_fb_gamma_get,
 	.fb_probe = intel_fb_find_or_create_single,
+	.restore_fbdev_mode = intel_fb_restore_mode,
 };
 
 static void intel_fbdev_destroy(struct drm_device *dev,
@@ -275,22 +276,27 @@ void intel_fb_output_poll_changed(struct drm_device *dev)
 	drm_fb_helper_hotplug_event(&dev_priv->fbdev->helper);
 }
 
-void intel_fb_restore_mode(struct drm_device *dev)
+int intel_fb_restore_mode(struct drm_fb_helper *helper)
 {
+	struct drm_device *dev = helper->dev;
 	int ret;
-	drm_i915_private_t *dev_priv = dev->dev_private;
 	struct drm_mode_config *config = &dev->mode_config;
 	struct drm_plane *plane;
 
 	mutex_lock(&dev->mode_config.mutex);
 
-	ret = drm_fb_helper_restore_fbdev_mode(&dev_priv->fbdev->helper);
-	if (ret)
+	ret = drm_fb_helper_restore_fbdev_mode(helper);
+	if (ret) {
 		DRM_DEBUG("failed to restore crtc mode\n");
+		goto out;
+	}
 
 	/* Be sure to shut off any planes that may be active */
 	list_for_each_entry(plane, &config->plane_list, head)
 		plane->funcs->disable_plane(plane);
 
+out:
 	mutex_unlock(&dev->mode_config.mutex);
+
+	return ret;
 }
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#19 lore raw

PATCH 19/81 drm/i915: Split clipping and checking from update_plane hook

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Split the update_plane() codepath into two separate steps. The first step checkis and clips the plane, and the second step actually commits the changes to the hardware. This allows the atomic modesetting code to perform all checks before clobering hardware state.

The update_plane() hook is reduced to a thin wrapper calling both check and commit functions.

Buffer (un)pinning is still being performed in the commit step. This needs to be changed as well, so that the atomic modesetting code can try to pin all new buffers before touching the hardware.

---
 drivers/gpu/drm/i915/intel_drv.h    |   15 +-
 drivers/gpu/drm/i915/intel_sprite.c |  411 ++++++++++++++++++++++-------------
 2 files changed, 266 insertions(+), 160 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +10 -5
index 16770cb..0d7c2fc 100644
@@ -231,6 +231,15 @@ struct intel_crtc {
 	uint32_t ddi_pll_sel;
 };
 
+struct intel_plane_coords {
+	/* disabled or fully clipped? */
+	bool visible;
+	/* coordinates clipped against pipe dimensions */
+	int32_t crtc_x, crtc_y;
+	uint32_t crtc_w, crtc_h;
+	uint32_t src_x, src_y, src_w, src_h;
+};
+
 struct intel_plane {
 	struct drm_plane base;
 	enum pipe pipe;
@@ -240,11 +249,7 @@ struct intel_plane {
 	u32 lut_r[1024], lut_g[1024], lut_b[1024];
 	void (*update_plane)(struct drm_plane *plane,
 			     struct drm_framebuffer *fb,
-			     struct drm_i915_gem_object *obj,
-			     int crtc_x, int crtc_y,
-			     unsigned int crtc_w, unsigned int crtc_h,
-			     uint32_t x, uint32_t y,
-			     uint32_t src_w, uint32_t src_h);
+			     const struct intel_plane_coords *clip);
 	void (*disable_plane)(struct drm_plane *plane);
 	int (*update_colorkey)(struct drm_plane *plane,
 			       struct drm_intel_sprite_colorkey *key);
drivers/gpu/drm/i915/intel_sprite.c +256 -155

473 lines not on this page · raw message

Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#20 lore raw

PATCH 20/81 drm/i915: Factor out i9xx_compute_clocks() like ironlake_compute_clocks()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Split the clock stuff out.

---
 drivers/gpu/drm/i915/intel_display.c |  128 ++++++++++++++++++++--------------
 1 files changed, 75 insertions(+), 53 deletions(-)
drivers/gpu/drm/i915/intel_display.c +75 -53
index a4e71e5..0fa9c2a 100644
@@ -4544,6 +4544,76 @@ static void intel_set_pipe_timings(struct intel_crtc *intel_crtc,
 		   ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1));
 }
 
+static bool i9xx_compute_clocks(struct drm_crtc *crtc,
+				struct drm_display_mode *adjusted_mode,
+				intel_clock_t *clock,
+				bool *has_reduced_clock,
+				intel_clock_t *reduced_clock,
+				int *refclk, int *num_connectors, bool *is_dp)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_encoder *encoder;
+	const intel_limit_t *limit;
+	bool ret, is_sdvo = false, is_tv = false, is_lvds = false;
+
+	*num_connectors = 0;
+
+	for_each_encoder_on_crtc(dev, crtc, encoder) {
+		switch (encoder->type) {
+		case INTEL_OUTPUT_LVDS:
+			is_lvds = true;
+			break;
+		case INTEL_OUTPUT_SDVO:
+		case INTEL_OUTPUT_HDMI:
+			is_sdvo = true;
+			if (encoder->needs_tv_clock)
+				is_tv = true;
+			break;
+		case INTEL_OUTPUT_TVOUT:
+			is_tv = true;
+			break;
+		case INTEL_OUTPUT_DISPLAYPORT:
+			*is_dp = true;
+			break;
+		}
+
+		(*num_connectors)++;
+	}
+
+	*refclk = i9xx_get_refclk(crtc, *num_connectors);
+
+	/*
+	 * Returns a set of divisors for the desired target clock with the given
+	 * refclk, or FALSE.  The returned values represent the clock equation:
+	 * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2.
+	 */
+	limit = intel_limit(crtc, *refclk);
+	ret = limit->find_pll(limit, crtc, adjusted_mode->clock, *refclk, NULL,
+			      clock);
+	if (!ret)
+		return false;
+
+	if (is_lvds && dev_priv->lvds_downclock_avail) {
+		/*
+		 * Ensure we match the reduced clock's P to the target clock.
+		 * If the clocks don't match, we can't switch the display clock
+		 * by using the FP0/FP1. In such case we will disable the LVDS
+		 * downclock feature.
+		*/
+		*has_reduced_clock = limit->find_pll(limit, crtc,
+						     dev_priv->lvds_downclock,
+						     *refclk,
+						     clock,
+						     reduced_clock);
+	}
+
+	if (is_sdvo && is_tv)
+		i9xx_adjust_sdvo_tv_clock(adjusted_mode, clock);
+
+	return true;
+}
+
 static int i9xx_crtc_mode_set(struct drm_crtc *crtc,
 			      struct drm_display_mode *mode,
 			      struct drm_display_mode *adjusted_mode,
@@ -4558,44 +4628,13 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc,
 	int refclk, num_connectors = 0;
 	intel_clock_t clock, reduced_clock;
 	u32 dspcntr, pipeconf;
-	bool ok, has_reduced_clock = false, is_sdvo = false;
-	bool is_lvds = false, is_tv = false, is_dp = false;
-	struct intel_encoder *encoder;
-	const intel_limit_t *limit;
+	bool ok, has_reduced_clock = false;
+	bool is_dp = false;
 	int ret;
 
-	for_each_encoder_on_crtc(dev, crtc, encoder) {
-		switch (encoder->type) {
-		case INTEL_OUTPUT_LVDS:
-			is_lvds = true;
-			break;
-		case INTEL_OUTPUT_SDVO:
-		case INTEL_OUTPUT_HDMI:
-			is_sdvo = true;
-			if (encoder->needs_tv_clock)
-				is_tv = true;
-			break;
-		case INTEL_OUTPUT_TVOUT:
-			is_tv = true;
-			break;
-		case INTEL_OUTPUT_DISPLAYPORT:
-			is_dp = true;
-			break;
-		}
-
-		num_connectors++;
-	}
-
-	refclk = i9xx_get_refclk(crtc, num_connectors);
-
-	/*
-	 * Returns a set of divisors for the desired target clock with the given
-	 * refclk, or FALSE.  The returned values represent the clock equation:
-	 * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2.
-	 */
-	limit = intel_limit(crtc, refclk);
-	ok = limit->find_pll(limit, crtc, adjusted_mode->clock, refclk, NULL,
-			     &clock);
+	ok = i9xx_compute_clocks(crtc, adjusted_mode, &clock,
+				 &has_reduced_clock, &reduced_clock,
+				 &refclk, &num_connectors, &is_dp);
 	if (!ok) {
 		DRM_ERROR("Couldn't find PLL settings for mode!\n");
 		return -EINVAL;
@@ -4604,23 +4643,6 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc,
 	/* Ensure that the cursor is valid for the new mode before changing... */
 	intel_crtc_update_cursor(crtc, true);
 
-	if (is_lvds && dev_priv->lvds_downclock_avail) {
-		/*
-		 * Ensure we match the reduced clock's P to the target clock.
-		 * If the clocks don't match, we can't switch the display clock
-		 * by using the FP0/FP1. In such case we will disable the LVDS
-		 * downclock feature.
-		*/
-		has_reduced_clock = limit->find_pll(limit, crtc,
-						    dev_priv->lvds_downclock,
-						    refclk,
-						    &clock,
-						    &reduced_clock);
-	}
-
-	if (is_sdvo && is_tv)
-		i9xx_adjust_sdvo_tv_clock(adjusted_mode, &clock);
-
 	if (IS_GEN2(dev))
 		i8xx_update_pll(crtc, adjusted_mode, &clock,
 				has_reduced_clock ? &reduced_clock : NULL,
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#21 lore raw

PATCH 21/81 drm/i915: Consitify adjusted_mode parameter

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

i9xx_adjust_sdvo_tv_clock(), i9xx_compute_clocks() and ironlake_compute_clocks() do not modify the adjusted_mode passed in, so pass it as const.

---
 drivers/gpu/drm/i915/intel_display.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -3
index 0fa9c2a..2a2c664 100644
@@ -4159,7 +4159,7 @@ static int i9xx_get_refclk(struct drm_crtc *crtc, int num_connectors)
 	return refclk;
 }
 
-static void i9xx_adjust_sdvo_tv_clock(struct drm_display_mode *adjusted_mode,
+static void i9xx_adjust_sdvo_tv_clock(const struct drm_display_mode *adjusted_mode,
 				      intel_clock_t *clock)
 {
 	/* SDVO TV has fixed PLL values depend on its clock range,
@@ -4545,7 +4545,7 @@ static void intel_set_pipe_timings(struct intel_crtc *intel_crtc,
 }
 
 static bool i9xx_compute_clocks(struct drm_crtc *crtc,
-				struct drm_display_mode *adjusted_mode,
+				const struct drm_display_mode *adjusted_mode,
 				intel_clock_t *clock,
 				bool *has_reduced_clock,
 				intel_clock_t *reduced_clock,
@@ -5135,7 +5135,7 @@ static void haswell_set_pipeconf(struct drm_crtc *crtc,
 }
 
 static bool ironlake_compute_clocks(struct drm_crtc *crtc,
-				    struct drm_display_mode *adjusted_mode,
+				    const struct drm_display_mode *adjusted_mode,
 				    intel_clock_t *clock,
 				    bool *has_reduced_clock,
 				    intel_clock_t *reduced_clock)
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#22 lore raw

PATCH 22/81 drm/i915: Add intel_check_clock()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

intel_check_clock() can be used to check clock validity w/o modifying hardware state.

---
 drivers/gpu/drm/i915/i915_drv.h      |    2 ++
 drivers/gpu/drm/i915/intel_display.c |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index ab0bd29..c41982e 100644
@@ -1719,6 +1719,8 @@ extern bool intel_fbc_enabled(struct drm_device *dev);
 extern void intel_disable_fbc(struct drm_device *dev);
 extern bool ironlake_set_drps(struct drm_device *dev, u8 val);
 extern void intel_init_pch_refclk(struct drm_device *dev);
+extern int intel_check_clock(struct drm_crtc *crtc,
+			     const struct drm_display_mode *adjusted_mode);
 extern void gen6_set_rps(struct drm_device *dev, u8 val);
 extern void intel_detect_pch(struct drm_device *dev);
 extern int intel_trans_dp_port_sel(struct drm_crtc *crtc);
drivers/gpu/drm/i915/intel_display.c +34 -0
index 2a2c664..dcd61fb 100644
@@ -5686,6 +5686,40 @@ static int haswell_crtc_mode_set(struct drm_crtc *crtc,
 	return ret;
 }
 
+int intel_check_clock(struct drm_crtc *crtc,
+		      const struct drm_display_mode *adjusted_mode)
+{
+	struct drm_device *dev = crtc->dev;
+	intel_clock_t clock, reduced_clock;
+	bool has_reduced_clock = false;
+	bool ok;
+
+	if (IS_HASWELL(dev)) {
+		if (!intel_ddi_pll_mode_set(crtc, adjusted_mode->clock))
+			return -EINVAL;
+
+		if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev)) {
+			ok = ironlake_compute_clocks(crtc, adjusted_mode, &clock,
+						     &has_reduced_clock,
+						     &reduced_clock);
+		} else
+			ok = true;
+	} else if (HAS_PCH_SPLIT(dev)) {
+		ok = ironlake_compute_clocks(crtc, adjusted_mode, &clock,
+					     &has_reduced_clock, &reduced_clock);
+	} else {
+		int num_connectors = 0;
+		bool is_dp = false;
+		int refclk;
+
+		ok = i9xx_compute_clocks(crtc, adjusted_mode, &clock,
+					 &has_reduced_clock, &reduced_clock,
+					 &refclk, &num_connectors, &is_dp);
+	}
+
+	return ok ? 0 : -EINVAL;
+}
+
 static int intel_crtc_mode_set(struct drm_crtc *crtc,
 			       struct drm_display_mode *mode,
 			       struct drm_display_mode *adjusted_mode,
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#23 lore raw

PATCH 23/81 drm/i915: store cursor_handle in struct intel_crtc

In reply to [email protected]

From: Ander Conselvan de Oliveira <[email protected]>

This way it is possible to check if the cursor changed without doing any setup. Will be useful for the atomic modesetting api.

---
 drivers/gpu/drm/i915/intel_display.c |    1 +
 drivers/gpu/drm/i915/intel_drv.h     |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -0
index dcd61fb..2a32cb0 100644
@@ -6260,6 +6260,7 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
 	mutex_unlock(&dev->struct_mutex);
 
 	intel_crtc->cursor_addr = addr;
+	intel_crtc->cursor_handle = handle;
 	intel_crtc->cursor_bo = obj;
 	intel_crtc->cursor_width = width;
 	intel_crtc->cursor_height = height;
drivers/gpu/drm/i915/intel_drv.h +1 -1
index 0d7c2fc..e77202c 100644
@@ -220,7 +220,7 @@ struct intel_crtc {
 	unsigned long dspaddr_offset;
 
 	struct drm_i915_gem_object *cursor_bo;
-	uint32_t cursor_addr;
+	uint32_t cursor_addr, cursor_handle;
 	int16_t cursor_x, cursor_y;
 	int16_t cursor_width, cursor_height;
 	bool cursor_visible;
Signature · 1 line
1.7.8.6
#24 lore raw

PATCH 24/81 drm/i915: split cursor setting code into prepare/commit/unref parts

In reply to [email protected]

From: Ander Conselvan de Oliveira <[email protected]>

The atomic mode setting API will need to pin the cursor bo without making changes to the current setup. Only on a later stage the cursor registers can be written and the previous bo released.

This patch splits intel_crtc_cursor_set() into three parts: prepare, commit and unref. intel_crtc_cursor_prepare() will pin the cursor bo and return a gem object and the address to be written to the cursor registers. intel_crtc_cursor_commit() takes that object and address and actually changes the cursor. intel_crtc_cursor_unref() is used to release the previous cursor bo.

---
 drivers/gpu/drm/i915/intel_display.c |   90 +++++++++++++++++++++++++--------
 1 files changed, 68 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/intel_display.c +68 -22
index 2a32cb0..0f25a07 100644
@@ -6173,10 +6173,12 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 	}
 }
 
-static int intel_crtc_cursor_set(struct drm_crtc *crtc,
+static int intel_crtc_cursor_prepare(struct drm_crtc *crtc,
 				 struct drm_file *file,
 				 uint32_t handle,
-				 uint32_t width, uint32_t height)
+				 uint32_t width, uint32_t height,
+				 struct drm_i915_gem_object **obj_ret,
+				 uint32_t *addr_ret)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -6188,10 +6190,9 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
 	/* if we want to turn off the cursor ignore width and height */
 	if (!handle) {
 		DRM_DEBUG_KMS("cursor off\n");
-		addr = 0;
-		obj = NULL;
-		mutex_lock(&dev->struct_mutex);
-		goto finish;
+		*addr_ret = 0;
+		*obj_ret = NULL;
+		return 0;
 	}
 
 	/* Currently we only support 64x64 cursors */
@@ -6247,17 +6248,46 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
 	if (IS_GEN2(dev))
 		I915_WRITE(CURSIZE, (height << 12) | width);
 
- finish:
-	if (intel_crtc->cursor_bo) {
-		if (dev_priv->info->cursor_needs_physical) {
-			if (intel_crtc->cursor_bo != obj)
-				i915_gem_detach_phys_object(dev, intel_crtc->cursor_bo);
-		} else
-			i915_gem_object_unpin(intel_crtc->cursor_bo);
-		drm_gem_object_unreference(&intel_crtc->cursor_bo->base);
-	}
+	mutex_unlock(&dev->struct_mutex);
+
+	*obj_ret = obj;
+	*addr_ret = addr;
+
+	return 0;
+fail_unpin:
+	i915_gem_object_unpin(obj);
+fail_locked:
+	mutex_unlock(&dev->struct_mutex);
+fail:
+	drm_gem_object_unreference_unlocked(&obj->base);
+	return ret;
+}
+
+static void intel_crtc_cursor_bo_unref(struct drm_crtc *crtc,
+				       struct drm_i915_gem_object *obj)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+
+	mutex_lock(&dev->struct_mutex);
+
+	if (dev_priv->info->cursor_needs_physical) {
+		if (obj != intel_crtc->cursor_bo)
+			i915_gem_detach_phys_object(dev, obj);
+	} else
+		i915_gem_object_unpin(obj);
+	drm_gem_object_unreference(&obj->base);
 
 	mutex_unlock(&dev->struct_mutex);
+}
+
+static void intel_crtc_cursor_commit(struct drm_crtc *crtc, uint32_t handle,
+				     uint32_t width, uint32_t height,
+				     struct drm_i915_gem_object *obj,
+				     uint32_t addr)
+{
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 
 	intel_crtc->cursor_addr = addr;
 	intel_crtc->cursor_handle = handle;
@@ -6266,15 +6296,31 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
 	intel_crtc->cursor_height = height;
 
 	intel_crtc_update_cursor(crtc, true);
+}
+
+static int intel_crtc_cursor_set(struct drm_crtc *crtc,
+				 struct drm_file *file,
+				 uint32_t handle,
+				 uint32_t width, uint32_t height)
+{
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	int ret;
+	struct drm_i915_gem_object *obj, *old_obj;
+	uint32_t addr;
+
+	ret = intel_crtc_cursor_prepare(crtc, file, handle, width, height,
+					&obj, &addr);
+	if (ret)
+		return ret;
+
+	old_obj = intel_crtc->cursor_bo;
+
+	intel_crtc_cursor_commit(crtc, handle, width, height, obj, addr);
+
+	if (old_obj)
+		intel_crtc_cursor_bo_unref(crtc, old_obj);
 
 	return 0;
-fail_unpin:
-	i915_gem_object_unpin(obj);
-fail_locked:
-	mutex_unlock(&dev->struct_mutex);
-fail:
-	drm_gem_object_unreference_unlocked(&obj->base);
-	return ret;
 }
 
 static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
Signature · 1 line
1.7.8.6
#25 lore raw

PATCH 25/81 drm/i915: unstatic cursor functions for use with atomic modesetting

In reply to [email protected]

From: Ander Conselvan de Oliveira <[email protected]>

---
 drivers/gpu/drm/i915/intel_display.c |   24 ++++++++++++------------
 drivers/gpu/drm/i915/intel_drv.h     |   13 +++++++++++++
 2 files changed, 25 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/intel_display.c +12 -12
index 0f25a07..2f72881 100644
@@ -6173,12 +6173,12 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 	}
 }
 
-static int intel_crtc_cursor_prepare(struct drm_crtc *crtc,
-				 struct drm_file *file,
-				 uint32_t handle,
-				 uint32_t width, uint32_t height,
-				 struct drm_i915_gem_object **obj_ret,
-				 uint32_t *addr_ret)
+int intel_crtc_cursor_prepare(struct drm_crtc *crtc,
+			      struct drm_file *file,
+			      uint32_t handle,
+			      uint32_t width, uint32_t height,
+			      struct drm_i915_gem_object **obj_ret,
+			      uint32_t *addr_ret)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -6263,8 +6263,8 @@ fail:
 	return ret;
 }
 
-static void intel_crtc_cursor_bo_unref(struct drm_crtc *crtc,
-				       struct drm_i915_gem_object *obj)
+void intel_crtc_cursor_bo_unref(struct drm_crtc *crtc,
+				struct drm_i915_gem_object *obj)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -6282,10 +6282,10 @@ static void intel_crtc_cursor_bo_unref(struct drm_crtc *crtc,
 	mutex_unlock(&dev->struct_mutex);
 }
 
-static void intel_crtc_cursor_commit(struct drm_crtc *crtc, uint32_t handle,
-				     uint32_t width, uint32_t height,
-				     struct drm_i915_gem_object *obj,
-				     uint32_t addr)
+void intel_crtc_cursor_commit(struct drm_crtc *crtc, uint32_t handle,
+			      uint32_t width, uint32_t height,
+			      struct drm_i915_gem_object *obj,
+			      uint32_t addr)
 {
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 
drivers/gpu/drm/i915/intel_drv.h +13 -0
index e77202c..785fa04 100644
@@ -679,4 +679,17 @@ extern bool
 intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
 extern void intel_ddi_fdi_disable(struct drm_crtc *crtc);
 
+extern int intel_crtc_cursor_prepare(struct drm_crtc *crtc,
+				     struct drm_file *file,
+				     uint32_t handle,
+				     uint32_t width, uint32_t height,
+				     struct drm_i915_gem_object **obj_ret,
+				     uint32_t *addr_ret);
+extern void intel_crtc_cursor_bo_unref(struct drm_crtc *crtc,
+				       struct drm_i915_gem_object *obj);
+extern void intel_crtc_cursor_commit(struct drm_crtc *crtc, uint32_t handle,
+				     uint32_t width, uint32_t height,
+				     struct drm_i915_gem_object *obj,
+				     uint32_t addr);
+
 #endif /* __INTEL_DRV_H__ */
Signature · 1 line
1.7.8.6
#26 lore raw

PATCH 26/81 drm/i915: Unstatic intel_finish_fb()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

intel_finish_fb() will be used by the atomic modeset code, so make it non-static.

---
 drivers/gpu/drm/i915/intel_display.c |    2 +-
 drivers/gpu/drm/i915/intel_drv.h     |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
index 2f72881..a184b70 100644
@@ -2182,7 +2182,7 @@ intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 	return dev_priv->display.update_plane(crtc, fb, x, y);
 }
 
-static int
+int
 intel_finish_fb(struct drm_framebuffer *old_fb)
 {
 	struct drm_i915_gem_object *obj = to_intel_framebuffer(old_fb)->obj;
drivers/gpu/drm/i915/intel_drv.h +1 -0
index 785fa04..59ca0c3 100644
@@ -590,6 +590,7 @@ extern int intel_pin_and_fence_fb_obj(struct drm_device *dev,
 				      struct drm_i915_gem_object *obj,
 				      struct intel_ring_buffer *pipelined);
 extern void intel_unpin_fb_obj(struct drm_i915_gem_object *obj);
+extern int intel_finish_fb(struct drm_framebuffer *old_fb);
 
 extern int intel_framebuffer_init(struct drm_device *dev,
 				  struct intel_framebuffer *ifb,
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#27 lore raw

PATCH 27/81 drm/i915: Pull intel_pipe_set_base() out of the crtc_mode_set() functions

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

intel_pipe_set_base() (un)pins the buffers, so it can't be called from the atomic modeset paths. Pull the intel_pipe_set_base() and watermark modifications out of i9xx_crtc_mode_set() and ironlake_crtc_mode_set() into intel_crtc_mode_set(), so that the former two can be used from the atomic modeset paths.

---
 drivers/gpu/drm/i915/intel_display.c |   35 ++++++++++++---------------------
 1 files changed, 13 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/intel_display.c +13 -22
index a184b70..6522e1e 100644
@@ -4630,7 +4630,6 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc,
 	u32 dspcntr, pipeconf;
 	bool ok, has_reduced_clock = false;
 	bool is_dp = false;
-	int ret;
 
 	ok = i9xx_compute_clocks(crtc, adjusted_mode, &clock,
 				 &has_reduced_clock, &reduced_clock,
@@ -4738,11 +4737,7 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc,
 	I915_WRITE(DSPCNTR(plane), dspcntr);
 	POSTING_READ(DSPCNTR(plane));
 
-	ret = intel_pipe_set_base(crtc, x, y, fb);
-
-	intel_update_watermarks(dev);
-
-	return ret;
+	return 0;
 }
 
 static void ironlake_init_pch_refclk(struct drm_device *dev)
@@ -5479,7 +5474,6 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc,
 	bool ok, has_reduced_clock = false;
 	bool is_lvds = false, is_dp = false, is_cpu_edp = false;
 	struct intel_encoder *encoder;
-	int ret;
 	bool dither, fdi_config_ok;
 
 	for_each_encoder_on_crtc(dev, crtc, encoder) {
@@ -5590,13 +5584,7 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc,
 	I915_WRITE(DSPCNTR(plane), DISPPLANE_GAMMA_ENABLE);
 	POSTING_READ(DSPCNTR(plane));
 
-	ret = intel_pipe_set_base(crtc, x, y, fb);
-
-	intel_update_watermarks(dev);
-
-	intel_update_linetime_watermarks(dev, pipe, adjusted_mode);
-
-	return fdi_config_ok ? ret : -EINVAL;
+	return fdi_config_ok ? 0 : -EINVAL;
 }
 
 static int haswell_crtc_mode_set(struct drm_crtc *crtc,
@@ -5613,7 +5601,6 @@ static int haswell_crtc_mode_set(struct drm_crtc *crtc,
 	int num_connectors = 0;
 	bool is_dp = false, is_cpu_edp = false;
 	struct intel_encoder *encoder;
-	int ret;
 	bool dither;
 
 	for_each_encoder_on_crtc(dev, crtc, encoder) {
@@ -5677,13 +5664,7 @@ static int haswell_crtc_mode_set(struct drm_crtc *crtc,
 	I915_WRITE(DSPCNTR(plane), DISPPLANE_GAMMA_ENABLE);
 	POSTING_READ(DSPCNTR(plane));
 
-	ret = intel_pipe_set_base(crtc, x, y, fb);
-
-	intel_update_watermarks(dev);
-
-	intel_update_linetime_watermarks(dev, pipe, adjusted_mode);
-
-	return ret;
+	return 0;
 }
 
 int intel_check_clock(struct drm_crtc *crtc,
@@ -5738,6 +5719,16 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
 
 	ret = dev_priv->display.crtc_mode_set(crtc, mode, adjusted_mode,
 					      x, y, fb);
+
+	if (!ret) {
+		ret = intel_pipe_set_base(crtc, x, y, fb);
+
+		intel_update_watermarks(dev);
+
+		if (HAS_PCH_SPLIT(dev))
+			intel_update_linetime_watermarks(dev, pipe, adjusted_mode);
+	}
+
 	drm_vblank_post_modeset(dev, pipe);
 
 	if (ret != 0)
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#28 lore raw

PATCH 28/81 drm/i915: Unstatic intel_crtc_update_sarea()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Make intel_crtc_update_sarea() available for the atomic mode setting code.

---
 drivers/gpu/drm/i915/intel_display.c |    4 ++--
 drivers/gpu/drm/i915/intel_drv.h     |    2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +2 -2
index 6522e1e..9918dcb 100644
@@ -3652,8 +3652,8 @@ static void i9xx_crtc_off(struct drm_crtc *crtc)
 {
 }
 
-static void intel_crtc_update_sarea(struct drm_crtc *crtc,
-				    bool enabled)
+void intel_crtc_update_sarea(struct drm_crtc *crtc,
+			     bool enabled)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_master_private *master_priv;
drivers/gpu/drm/i915/intel_drv.h +2 -0
index 59ca0c3..c1fee22 100644
@@ -693,4 +693,6 @@ extern void intel_crtc_cursor_commit(struct drm_crtc *crtc, uint32_t handle,
 				     struct drm_i915_gem_object *obj,
 				     uint32_t addr);
 
+extern void intel_crtc_update_sarea(struct drm_crtc *crtc, bool enabled);
+
 #endif /* __INTEL_DRV_H__ */
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#29 lore raw

PATCH 29/81 drm/i915: Unstatic intel_crtc_update_sarea_pos()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Make intel_crtc_update_sarea_pos() available to the atomic mode setting code.

---
 drivers/gpu/drm/i915/intel_display.c |    2 +-
 drivers/gpu/drm/i915/intel_drv.h     |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
index 9918dcb..f7190d2 100644
@@ -2209,7 +2209,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb)
 	return ret;
 }
 
-static void intel_crtc_update_sarea_pos(struct drm_crtc *crtc, int x, int y)
+void intel_crtc_update_sarea_pos(struct drm_crtc *crtc, int x, int y)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_master_private *master_priv;
drivers/gpu/drm/i915/intel_drv.h +1 -0
index c1fee22..a7d8df8 100644
@@ -694,5 +694,6 @@ extern void intel_crtc_cursor_commit(struct drm_crtc *crtc, uint32_t handle,
 				     uint32_t addr);
 
 extern void intel_crtc_update_sarea(struct drm_crtc *crtc, bool enabled);
+extern void intel_crtc_update_sarea_pos(struct drm_crtc *crtc, int x, int y);
 
 #endif /* __INTEL_DRV_H__ */
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#30 lore raw

PATCH 30/81 drm/i915: Constify mode argument to intel_modeset_adjusted_mode()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

intel_modeset_adjusted_mode() doesn't modify the passed display mode. So pass it as const.

---
 drivers/gpu/drm/i915/intel_display.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
index f7190d2..dac80c4 100644
@@ -7401,7 +7401,7 @@ static void intel_modeset_commit_output_state(struct drm_device *dev)
 
 static struct drm_display_mode *
 intel_modeset_adjusted_mode(struct drm_crtc *crtc,
-			    struct drm_display_mode *mode)
+			    const struct drm_display_mode *mode)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_display_mode *adjusted_mode;
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#31 lore raw

PATCH 31/81 drm/i915: Unstatic intel_crtc_mode_fixup()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Make intel_crtc_mode_fixup() available for the upcoming atomic modesetting code.

---
 drivers/gpu/drm/i915/intel_display.c |    6 +++---
 drivers/gpu/drm/i915/intel_drv.h     |    4 ++++
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -3
index dac80c4..2c2fcda 100644
@@ -3851,9 +3851,9 @@ bool intel_connector_get_hw_state(struct intel_connector *connector)
 	return encoder->get_hw_state(encoder, &pipe);
 }
 
-static bool intel_crtc_mode_fixup(struct drm_crtc *crtc,
-				  const struct drm_display_mode *mode,
-				  struct drm_display_mode *adjusted_mode)
+bool intel_crtc_mode_fixup(struct drm_crtc *crtc,
+			   const struct drm_display_mode *mode,
+			   struct drm_display_mode *adjusted_mode)
 {
 	struct drm_device *dev = crtc->dev;
 
drivers/gpu/drm/i915/intel_drv.h +4 -0
index a7d8df8..ee6c85f 100644
@@ -696,4 +696,8 @@ extern void intel_crtc_cursor_commit(struct drm_crtc *crtc, uint32_t handle,
 extern void intel_crtc_update_sarea(struct drm_crtc *crtc, bool enabled);
 extern void intel_crtc_update_sarea_pos(struct drm_crtc *crtc, int x, int y);
 
+extern bool intel_crtc_mode_fixup(struct drm_crtc *crtc,
+				  const struct drm_display_mode *mode,
+				  struct drm_display_mode *adjusted_mode);
+
 #endif /* __INTEL_DRV_H__ */
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#32 lore raw

PATCH 32/81 drm/i915: Introduce intel_plane_regs

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

intel_plane_regs can be used to shadow all the typical plane registers.

---
 drivers/gpu/drm/i915/intel_drv.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +14 -0
index ee6c85f..b11510a 100644
@@ -194,6 +194,20 @@ struct intel_connector {
 	struct edid *edid;
 };
 
+struct intel_plane_regs {
+	u32 cntr;
+	u32 linoff;
+	u32 stride;
+	u32 pos;
+	u32 size;
+	u32 keyval;
+	u32 keymsk;
+	u32 surf;
+	u32 keymaxval;
+	u32 tileoff;
+	u32 scale;
+};
+
 struct intel_crtc {
 	struct drm_crtc base;
 	enum pipe pipe;
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#33 lore raw

PATCH 33/81 drm/i915: Split primary plane update_plane() into calc+commit phases

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Separate the part that calculates the register values from the part that writes the registers. This will be useful in the atomic page flip code.

---
 drivers/gpu/drm/i915/i915_drv.h      |    3 +
 drivers/gpu/drm/i915/intel_display.c |  154 ++++++++++++++++++++++------------
 drivers/gpu/drm/i915/intel_drv.h     |    1 +
 3 files changed, 105 insertions(+), 53 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index c41982e..66b3b64 100644
@@ -297,6 +297,9 @@ struct drm_i915_display_funcs {
 			  struct drm_i915_gem_object *obj);
 	int (*update_plane)(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			    int x, int y);
+	int (*calc_plane)(struct drm_crtc *crtc, struct drm_framebuffer *fb,
+			  int x, int y);
+	void (*commit_plane)(struct drm_crtc *crtc);
 	/* clock updates for mode set */
 	/* cursor updates */
 	/* render clock increase/decrease */
drivers/gpu/drm/i915/intel_display.c +101 -53

277 lines not on this page · raw message

drivers/gpu/drm/i915/intel_drv.h +1 -0
index b11510a..4798f54 100644
@@ -243,6 +243,7 @@ struct intel_crtc {
 	/* We can share PLLs across outputs if the timings match */
 	struct intel_pch_pll *pch_pll;
 	uint32_t ddi_pll_sel;
+	struct intel_plane_regs primary_regs;
 };
 
 struct intel_plane_coords {
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#34 lore raw

PATCH 34/81 drm/i915: Split sprite update_plane() into calc+commit phases

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Separate the part that calculates the register values from the part that writes the registers. This will be useful in the atomic page flip code. Also move the watermark magic into a prepare function that can be performed outside the critical parts of the atomic page flip code.

---
 drivers/gpu/drm/i915/intel_drv.h    |    5 +
 drivers/gpu/drm/i915/intel_sprite.c |  416 ++++++++++++++++++++++-------------
 2 files changed, 273 insertions(+), 148 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +5 -0
index 4798f54..05afdd1 100644
@@ -270,6 +270,11 @@ struct intel_plane {
 			       struct drm_intel_sprite_colorkey *key);
 	void (*get_colorkey)(struct drm_plane *plane,
 			     struct drm_intel_sprite_colorkey *key);
+	void (*calc)(struct drm_plane *plane, struct drm_framebuffer *fb,
+		     const struct intel_plane_coords *clip);
+	void (*prepare)(struct drm_plane *plane);
+	void (*commit)(struct drm_plane *plane);
+	struct intel_plane_regs regs;
 };
 
 struct intel_watermark_params {
drivers/gpu/drm/i915/intel_sprite.c +268 -148

639 lines not on this page · raw message

Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#35 lore raw

PATCH 35/81 drm/i915: Implement atomic modesetting

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Implement the mandatory hooks for the atomic modeset ioctl.

The code first makes a backup of the current state, then proceeds to modify the state as properties are modified. After all the properties have been handled the new state is checked, and if everything checks out, the new state is commited to hardware. Finally we clean up any temporary storage.

In theory everything is checked before the hardware state is clobbered, so there should be no need for rollback. But as the current modesetting code can still return errors from some of of the operation, the rollback code is included.

---
 drivers/gpu/drm/i915/Makefile        |    1 +
 drivers/gpu/drm/i915/intel_atomic.c  | 1625 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_display.c |    5 +
 drivers/gpu/drm/i915/intel_drv.h     |    3 +
 include/drm/drm_crtc.h               |    2 +
 5 files changed, 1636 insertions(+), 0 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_atomic.c
drivers/gpu/drm/i915/Makefile +1 -0
index 0f2c549..cca14e4 100644
@@ -16,6 +16,7 @@ i915-y := i915_drv.o i915_dma.o i915_irq.o \
 	  i915_gem_tiling.o \
 	  i915_sysfs.o \
 	  i915_trace_points.o \
+	  intel_atomic.o \
 	  intel_display.o \
 	  intel_crt.o \
 	  intel_lvds.o \
drivers/gpu/drm/i915/intel_atomic.c new file +1625 -0

1,625 lines not on this page · raw message

drivers/gpu/drm/i915/intel_display.c +5 -0
index c0db749..62e2a56 100644
@@ -8409,6 +8409,9 @@ static void intel_setup_outputs(struct drm_device *dev)
 			intel_encoder_clones(encoder);
 	}
 
+	/* FIXME error handling */
+	intel_atomic_init(dev);
+
 	intel_init_pch_refclk(dev);
 
 	drm_helper_move_panel_connectors_to_head(dev);
@@ -9187,6 +9190,8 @@ void intel_modeset_cleanup(struct drm_device *dev)
 	/* flush any delayed tasks or pending work */
 	flush_scheduled_work();
 
+	intel_atomic_fini(dev);
+
 	drm_mode_config_cleanup(dev);
 }
 
drivers/gpu/drm/i915/intel_drv.h +3 -0
index 05afdd1..103d104 100644
@@ -720,4 +720,7 @@ extern bool intel_crtc_mode_fixup(struct drm_crtc *crtc,
 				  const struct drm_display_mode *mode,
 				  struct drm_display_mode *adjusted_mode);
 
+extern int intel_atomic_init(struct drm_device *dev);
+extern void intel_atomic_fini(struct drm_device *dev);
+
 #endif /* __INTEL_DRV_H__ */
include/drm/drm_crtc.h +2 -0
index 77f08a3..897c110 100644
@@ -509,6 +509,7 @@ struct drm_encoder {
 	struct drm_crtc *crtc;
 	const struct drm_encoder_funcs *funcs;
 	void *helper_private;
+	struct drm_crtc *old_crtc;
 };
 
 enum drm_connector_force {
@@ -614,6 +615,7 @@ struct drm_connector {
 	int audio_latency[2];
 	int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */
 	unsigned bad_edid_counter;
+	struct drm_encoder *old_encoder;
 };
 
 /**
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#36 lore raw

PATCH 36/81 drm/i915: Add support for atomic modesetting completion events

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Send completion events when the atomic modesetting operations has finished succesfully.

---
 drivers/gpu/drm/i915/intel_atomic.c |  195 ++++++++++++++++++++++++++++++++++-
 1 files changed, 192 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +192 -3
index 4899f8c..3adb140 100644
@@ -53,6 +53,7 @@ struct intel_plane_state {
 	bool dirty;
 	bool pinned;
 	bool changed;
+	struct drm_pending_atomic_event *event;
 
 	struct {
 		struct drm_crtc *crtc;
@@ -74,6 +75,7 @@ struct intel_crtc_state {
 	unsigned long connectors_bitmask;
 	unsigned long encoders_bitmask;
 	bool changed;
+	struct drm_pending_atomic_event *event;
 
 	struct {
 		bool enabled;
@@ -922,6 +924,111 @@ int intel_commit_plane_nopin(struct drm_plane *plane,
 			     struct drm_framebuffer *fb,
 			     const struct intel_plane_coords *coords);
 
+static struct drm_pending_atomic_event *alloc_event(struct drm_device *dev,
+						    struct drm_file *file_priv,
+						    uint64_t user_data)
+{
+	struct drm_pending_atomic_event *e;
+	unsigned long flags;
+
+	spin_lock_irqsave(&dev->event_lock, flags);
+
+	if (file_priv->event_space < sizeof e->event) {
+		spin_unlock_irqrestore(&dev->event_lock, flags);
+		return ERR_PTR(-ENOSPC);
+	}
+
+	file_priv->event_space -= sizeof e->event;
+	spin_unlock_irqrestore(&dev->event_lock, flags);
+
+	e = kzalloc(sizeof *e, GFP_KERNEL);
+	if (!e) {
+		spin_lock_irqsave(&dev->event_lock, flags);
+		file_priv->event_space += sizeof e->event;
+		spin_unlock_irqrestore(&dev->event_lock, flags);
+
+		return ERR_PTR(-ENOMEM);
+	}
+
+	e->event.base.type = DRM_EVENT_ATOMIC_COMPLETE;
+	e->event.base.length = sizeof e->event;
+	e->event.user_data = user_data;
+	e->base.event = &e->event.base;
+	e->base.file_priv = file_priv;
+	e->base.destroy = (void (*) (struct drm_pending_event *)) kfree;
+
+	return e;
+}
+
+static void free_event(struct drm_pending_atomic_event *e)
+{
+	e->base.file_priv->event_space += sizeof e->event;
+	kfree(e);
+}
+
+static void queue_event(struct drm_device *dev, struct drm_crtc *crtc,
+			struct drm_pending_atomic_event *e)
+{
+	struct timeval tvbl;
+
+	if (crtc) {
+		int pipe = to_intel_crtc(crtc)->pipe;
+
+		/* FIXME this is wrong for flips that are completed not at vblank */
+		e->event.sequence = drm_vblank_count_and_time(dev, pipe, &tvbl);
+		e->event.tv_sec = tvbl.tv_sec;
+		e->event.tv_usec = tvbl.tv_usec;
+	} else {
+		e->event.sequence = 0;
+		e->event.tv_sec = 0;
+		e->event.tv_usec = 0;
+	}
+
+	list_add_tail(&e->base.link, &e->base.file_priv->event_list);
+	wake_up_interruptible(&e->base.file_priv->event_wait);
+}
+
+static void queue_remaining_events(struct drm_device *dev, struct intel_atomic_state *s)
+{
+	int i;
+
+	for (i = 0; i < dev->mode_config.num_crtc; i++) {
+		struct intel_crtc_state *st = &s->crtc[i];
+
+		if (st->event) {
+			if (st->old.fb)
+				st->event->event.old_fb_id = st->old.fb->base.id;
+
+			spin_lock_irq(&dev->event_lock);
+			queue_event(dev, st->crtc, st->event);
+			spin_unlock_irq(&dev->event_lock);
+
+			st->event = NULL;
+		}
+	}
+
+	for (i = 0; i < dev->mode_config.num_plane; i++) {
+		struct intel_plane_state *st = &s->plane[i];
+		struct drm_crtc *crtc;
+
+		if (!st->event)
+			continue;
+
+		crtc = st->plane->crtc;
+		if (!crtc)
+			crtc = st->old.crtc;
+
+		if (st->old.fb)
+			st->event->event.old_fb_id = st->old.fb->base.id;
+
+		spin_lock_irq(&dev->event_lock);
+		queue_event(dev, crtc, st->event);
+		spin_unlock_irq(&dev->event_lock);
+
+		st->event = NULL;
+	}
+}
+
 static void swap_old_new(struct drm_device *dev,
 			 struct intel_atomic_state *s)
 {
@@ -1426,6 +1533,73 @@ static void update_crtc(struct drm_device *dev,
 	}
 }
 
+static int alloc_flip_data(struct drm_device *dev, struct intel_atomic_state *s)
+{
+	int i;
+
+	for (i = 0; i < dev->mode_config.num_crtc; i++) {
+		struct intel_crtc_state *st = &s->crtc[i];
+
+		if (st->changed && s->flags & DRM_MODE_ATOMIC_EVENT) {
+			struct drm_pending_atomic_event *e;
+
+			e = alloc_event(dev, s->file, s->user_data);
+			if (IS_ERR(e))
+				return PTR_ERR(e);
+
+			e->event.obj_id = st->crtc->base.id;
+
+			st->event = e;
+		}
+	}
+
+
+	for (i = 0; i < dev->mode_config.num_plane; i++) {
+		struct intel_plane_state *st = &s->plane[i];
+
+		if (st->changed && s->flags & DRM_MODE_ATOMIC_EVENT) {
+			struct drm_pending_atomic_event *e;
+
+			e = alloc_event(dev, s->file, s->user_data);
+			if (IS_ERR(e))
+				return PTR_ERR(e);
+
+			e->event.obj_id = st->plane->base.id;
+
+			st->event = e;
+		}
+	}
+
+	return 0;
+}
+
+static void free_flip_data(struct drm_device *dev, struct intel_atomic_state *s)
+{
+	int i;
+
+	for (i = 0; i < dev->mode_config.num_crtc; i++) {
+		struct intel_crtc_state *st = &s->crtc[i];
+
+		if (st->event) {
+			spin_lock_irq(&dev->event_lock);
+			free_event(st->event);
+			spin_unlock_irq(&dev->event_lock);
+			st->event = NULL;
+		}
+	}
+
+	for (i = 0; i < dev->mode_config.num_plane; i++) {
+		struct intel_plane_state *st = &s->plane[i];
+
+		if (st->event) {
+			spin_lock_irq(&dev->event_lock);
+			free_event(st->event);
+			spin_unlock_irq(&dev->event_lock);
+			st->event = NULL;
+		}
+	}
+}
+
 static int intel_atomic_commit(struct drm_device *dev, void *state)
 {
 	struct intel_atomic_state *s = state;
@@ -1434,12 +1608,13 @@ static int intel_atomic_commit(struct drm_device *dev, void *state)
 	if (s->flags & DRM_MODE_ATOMIC_NONBLOCK)
 		return -ENOSYS;
 
-	if (s->flags & DRM_MODE_ATOMIC_EVENT)
-		return -ENOSYS;
-
 	if (!s->dirty)
 		return 0;
 
+	ret = alloc_flip_data(dev, s);
+	if (ret)
+		return ret;
+
 	ret = pin_fbs(dev, s);
 	if (ret)
 		return ret;
@@ -1460,6 +1635,17 @@ static int intel_atomic_commit(struct drm_device *dev, void *state)
 	unpin_old_cursors(dev, s);
 	unpin_old_fbs(dev, s);
 
+	/*
+	 * Either we took the blocking code path, or perhaps the state of
+	 * some objects didn't actually change? Nonetheless the user wanted
+	 * events for all objects he touched, so queue up any events that
+	 * are still pending.
+	 *
+	 * FIXME this needs more work. If the previous flip is still pending
+	 * we shouldn't send this event until that flip completes.
+	 */
+	queue_remaining_events(dev, s);
+
 	update_plane_obj(dev, s);
 
 	update_crtc(dev, s);
@@ -1473,6 +1659,9 @@ static void intel_atomic_end(struct drm_device *dev, void *state)
 {
 	struct intel_atomic_state *s = state;
 
+	/* don't send events when restoring old state */
+	free_flip_data(dev, state);
+
 	/* restore the state of all objects */
 	if (s->restore_state)
 		restore_state(dev, state);
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#37 lore raw

PATCH 37/81 drm/i915: Add atomic page flip support

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Add support for the DRM_MODE_ATOMIC_NONBLOCK flag.

The drm_flip helper provides the necessary logic to track the progress of the flips. drm_flip is driven by a few extra calls from the interrupt handling and crtc_disable code paths.

Since the hardware doesn't provide inter-plane synchronization, some extra software magic is required to avoid flips for multiple planes ending up on the wrong sides of the vblank leading edge.

---
 drivers/gpu/drm/i915/i915_dma.c      |    3 +
 drivers/gpu/drm/i915/i915_drv.h      |    4 +
 drivers/gpu/drm/i915/i915_irq.c      |   16 +-
 drivers/gpu/drm/i915/intel_atomic.c  |  622 +++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_display.c |    2 +
 drivers/gpu/drm/i915/intel_drv.h     |    7 +
 6 files changed, 637 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +3 -0
index 392c9a1..8501bf3 100644
@@ -1764,6 +1764,8 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file)
 
 	idr_init(&file_priv->context_idr);
 
+	INIT_LIST_HEAD(&file_priv->pending_flips);
+
 	return 0;
 }
 
@@ -1804,6 +1806,7 @@ void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv)
 {
 	i915_gem_context_close(dev, file_priv);
 	i915_gem_release(dev, file_priv);
+	intel_atomic_free_events(dev, file_priv);
 }
 
 void i915_driver_postclose(struct drm_device *dev, struct drm_file *file)
drivers/gpu/drm/i915/i915_drv.h +4 -0
index 66b3b64..0bafe7f 100644
@@ -38,6 +38,7 @@
 #include <linux/io-mapping.h>
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
+#include <drm/drm_flip.h>
 #include <drm/intel-gtt.h>
 #include <linux/backlight.h>
 #include <linux/intel-iommu.h>
@@ -957,6 +958,8 @@ typedef struct drm_i915_private {
 	/* Old dri1 support infrastructure, beware the dragons ya fools entering
 	 * here! */
 	struct i915_dri1_state dri1;
+
+	struct drm_flip_driver flip_driver;
 } drm_i915_private_t;
 
 /* Iterate over initialised rings */
@@ -1179,6 +1182,7 @@ struct drm_i915_file_private {
 		struct list_head request_list;
 	} mm;
 	struct idr context_idr;
+	struct list_head pending_flips;
 };
 
 #define INTEL_INFO(dev)	(((struct drm_i915_private *) (dev)->dev_private)->info)
drivers/gpu/drm/i915/i915_irq.c +12 -4
index d02e022..430f201 100644
@@ -581,8 +581,10 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
 		spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
 
 		for_each_pipe(pipe) {
-			if (pipe_stats[pipe] & PIPE_VBLANK_INTERRUPT_STATUS)
+			if (pipe_stats[pipe] & PIPE_VBLANK_INTERRUPT_STATUS) {
 				drm_handle_vblank(dev, pipe);
+				intel_atomic_handle_vblank(dev, pipe);
+			}
 
 			if (pipe_stats[pipe] & PLANE_FLIPDONE_INT_STATUS_VLV) {
 				intel_prepare_page_flip(dev, pipe);
@@ -727,8 +729,10 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
 			intel_opregion_gse_intr(dev);
 
 		for (i = 0; i < 3; i++) {
-			if (de_iir & (DE_PIPEA_VBLANK_IVB << (5 * i)))
+			if (de_iir & (DE_PIPEA_VBLANK_IVB << (5 * i))) {
 				drm_handle_vblank(dev, i);
+				intel_atomic_handle_vblank(dev, i);
+			}
 			if (de_iir & (DE_PLANEA_FLIP_DONE_IVB << (5 * i))) {
 				intel_prepare_page_flip(dev, i);
 				intel_finish_page_flip_plane(dev, i);
@@ -807,11 +811,15 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
 	if (de_iir & DE_GSE)
 		intel_opregion_gse_intr(dev);
 
-	if (de_iir & DE_PIPEA_VBLANK)
+	if (de_iir & DE_PIPEA_VBLANK) {
 		drm_handle_vblank(dev, 0);
+		intel_atomic_handle_vblank(dev, 0);
+	}
 
-	if (de_iir & DE_PIPEB_VBLANK)
+	if (de_iir & DE_PIPEB_VBLANK) {
 		drm_handle_vblank(dev, 1);
+		intel_atomic_handle_vblank(dev, 1);
+	}
 
 	if (de_iir & DE_PLANEA_FLIP_DONE) {
 		intel_prepare_page_flip(dev, 0);
drivers/gpu/drm/i915/intel_atomic.c +609 -13

716 lines not on this page · raw message

drivers/gpu/drm/i915/intel_display.c +2 -0
index 62e2a56..7394aca 100644
@@ -3554,6 +3554,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 		encoder->disable(encoder);
 
 	intel_crtc_wait_for_pending_flips(crtc);
+	drm_flip_helper_clear(&intel_crtc->flip_helper);
 	drm_vblank_off(dev, pipe);
 	intel_crtc_update_cursor(crtc, false);
 
@@ -3674,6 +3675,7 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)
 
 	/* Give the overlay scaler a chance to disable if it's on this pipe */
 	intel_crtc_wait_for_pending_flips(crtc);
+	drm_flip_helper_clear(&intel_crtc->flip_helper);
 	drm_vblank_off(dev, pipe);
 	intel_crtc_dpms_overlay(intel_crtc, false);
 	intel_crtc_update_cursor(crtc, false);
drivers/gpu/drm/i915/intel_drv.h +7 -0
index 103d104..cd37428 100644
@@ -32,6 +32,7 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_dp_helper.h>
+#include <drm/drm_flip.h>
 
 #define _wait_for(COND, MS, W) ({ \
 	unsigned long timeout__ = jiffies + msecs_to_jiffies(MS);	\
@@ -244,6 +245,9 @@ struct intel_crtc {
 	struct intel_pch_pll *pch_pll;
 	uint32_t ddi_pll_sel;
 	struct intel_plane_regs primary_regs;
+	struct drm_flip_helper flip_helper;
+	wait_queue_head_t vbl_wait;
+	bool vbl_received;
 };
 
 struct intel_plane_coords {
@@ -275,6 +279,7 @@ struct intel_plane {
 	void (*prepare)(struct drm_plane *plane);
 	void (*commit)(struct drm_plane *plane);
 	struct intel_plane_regs regs;
+	struct drm_flip_helper flip_helper;
 };
 
 struct intel_watermark_params {
@@ -722,5 +727,7 @@ extern bool intel_crtc_mode_fixup(struct drm_crtc *crtc,
 
 extern int intel_atomic_init(struct drm_device *dev);
 extern void intel_atomic_fini(struct drm_device *dev);
+extern void intel_atomic_free_events(struct drm_device *dev, struct drm_file *file);
+extern void intel_atomic_handle_vblank(struct drm_device *dev, int pipe);
 
 #endif /* __INTEL_DRV_H__ */
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#38 lore raw

PATCH 38/81 drm/i915: Unstatic intel_enable_primary() and intel_disable_primary()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

intel_enable_primary() and intel_disable_primary() are needed in the atomic mode setting code.

---
 drivers/gpu/drm/i915/intel_drv.h    |    3 +++
 drivers/gpu/drm/i915/intel_sprite.c |    4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +3 -0
index cd37428..92a9518 100644
@@ -730,4 +730,7 @@ extern void intel_atomic_fini(struct drm_device *dev);
 extern void intel_atomic_free_events(struct drm_device *dev, struct drm_file *file);
 extern void intel_atomic_handle_vblank(struct drm_device *dev, int pipe);
 
+extern void intel_enable_primary(struct drm_crtc *crtc);
+extern void intel_disable_primary(struct drm_crtc *crtc);
+
 #endif /* __INTEL_DRV_H__ */
drivers/gpu/drm/i915/intel_sprite.c +2 -2
index 88644df..693b265 100644
@@ -610,7 +610,7 @@ void intel_calc_sprite(struct drm_plane *plane,
 		ilk_calc_plane(plane, fb, coords);
 }
 
-static void
+void
 intel_enable_primary(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
@@ -629,7 +629,7 @@ intel_enable_primary(struct drm_crtc *crtc)
 	dev_priv->display.commit_plane(crtc);
 }
 
-static void
+void
 intel_disable_primary(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#39 lore raw

PATCH 39/81 drm/i915: Respect primary_disabled in crtc_enable()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Check primary_disabled state before enabling the primary plane in crtc_enable() hooks.

---
 drivers/gpu/drm/i915/intel_display.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +6 -3
index 7394aca..957907c 100644
@@ -3349,7 +3349,8 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc_load_lut(crtc);
 
 	intel_enable_pipe(dev_priv, pipe, is_pch_port);
-	intel_enable_plane(dev_priv, plane, pipe);
+	if (!intel_crtc->primary_disabled)
+		intel_enable_plane(dev_priv, plane, pipe);
 
 	if (is_pch_port)
 		ironlake_pch_enable(crtc);
@@ -3429,7 +3430,8 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 	intel_ddi_enable_pipe_func(crtc);
 
 	intel_enable_pipe(dev_priv, pipe, is_pch_port);
-	intel_enable_plane(dev_priv, plane, pipe);
+	if (!intel_crtc->primary_disabled)
+		intel_enable_plane(dev_priv, plane, pipe);
 
 	if (is_pch_port)
 		lpt_pch_enable(crtc);
@@ -3644,7 +3646,8 @@ static void i9xx_crtc_enable(struct drm_crtc *crtc)
 
 	intel_enable_pll(dev_priv, pipe);
 	intel_enable_pipe(dev_priv, pipe, false);
-	intel_enable_plane(dev_priv, plane, pipe);
+	if (!intel_crtc->primary_disabled)
+		intel_enable_plane(dev_priv, plane, pipe);
 
 	intel_crtc_load_lut(crtc);
 	intel_update_fbc(dev);
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#40 lore raw

PATCH 40/81 drm/i915: Enable/disable primary plane in calc_plane()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Check the active and primary_disabled flags and set the DISPLAY_PLANE_ENABLE bit accordingly in calc_plane() hook for the primary plane.

---
 drivers/gpu/drm/i915/intel_display.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/intel_display.c +10 -0
index 957907c..9903456 100644
@@ -2068,6 +2068,11 @@ static int i9xx_calc_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			regs->cntr &= ~DISPPLANE_TILED;
 	}
 
+	if (intel_crtc->active && !intel_crtc->primary_disabled)
+		regs->cntr |= DISPLAY_PLANE_ENABLE;
+	else
+		regs->cntr &= ~DISPLAY_PLANE_ENABLE;
+
 	linear_offset = y * fb->pitches[0] + x * cpp;
 
 	if (INTEL_INFO(dev)->gen >= 4) {
@@ -2175,6 +2180,11 @@ static int ironlake_calc_plane(struct drm_crtc *crtc,
 	/* must disable */
 	regs->cntr |= DISPPLANE_TRICKLE_FEED_DISABLE;
 
+	if (intel_crtc->active && !intel_crtc->primary_disabled)
+		regs->cntr |= DISPLAY_PLANE_ENABLE;
+	else
+		regs->cntr &= ~DISPLAY_PLANE_ENABLE;
+
 	linear_offset = y * fb->pitches[0] + x * cpp;
 	intel_crtc->dspaddr_offset =
 		intel_gen4_compute_offset_xtiled(&x, &y,
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#41 lore raw

PATCH 41/81 drm/i915: Add primary plane disable logic to atomic mode setting code

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Enable/disable the primary plane accordingly when the sprite plane coverage changes.

---
 drivers/gpu/drm/i915/intel_atomic.c |   41 +++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +41 -0
index 238a843..41885fa 100644
@@ -93,6 +93,7 @@ struct intel_crtc_state {
 	bool changed;
 	struct drm_pending_atomic_event *event;
 	struct intel_flip *flip;
+	bool primary_disabled;
 
 	struct {
 		bool enabled;
@@ -318,6 +319,8 @@ static void *intel_atomic_begin(struct drm_device *dev, struct drm_file *file,
 
 		s->old.connectors_bitmask = s->connectors_bitmask;
 		s->old.encoders_bitmask = s->encoders_bitmask;
+
+		s->primary_disabled = intel_crtc->primary_disabled;
 	}
 
 	i = 0;
@@ -1157,6 +1160,9 @@ static int apply_config(struct drm_device *dev,
 						 intel_crtc->cursor_addr);
 		}
 
+		if (!st->primary_disabled)
+			intel_enable_primary(crtc);
+
 		for (j = 0; j < dev->mode_config.num_plane; j++) {
 			struct intel_plane_state *pst = &s->plane[j];
 			struct drm_plane *plane = pst->plane;
@@ -1170,6 +1176,9 @@ static int apply_config(struct drm_device *dev,
 			else if (!pst->coords.visible && pst->old.crtc == crtc)
 				intel_plane->disable_plane(plane);
 		}
+
+		if (st->primary_disabled)
+			intel_disable_primary(crtc);
 	}
 
 	/* don't restore the old state in end() */
@@ -1207,6 +1216,7 @@ static void restore_state(struct drm_device *dev,
 		intel_crtc->cursor_width = s->saved_crtcs[i].cursor_width;
 		intel_crtc->cursor_height = s->saved_crtcs[i].cursor_height;
 		intel_crtc->cursor_visible = s->saved_crtcs[i].cursor_visible;
+		intel_crtc->primary_disabled = s->saved_crtcs[i].primary_disabled;
 
 		i++;
 	}
@@ -1346,6 +1356,28 @@ static int check_crtc(struct intel_crtc_state *s)
 	return 0;
 }
 
+static void update_primary_visibility(struct drm_device *dev,
+				      struct intel_atomic_state *s,
+				      const struct drm_crtc *crtc,
+				      const struct drm_plane *plane,
+				      const struct intel_plane_coords *coords)
+{
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	bool primary_disabled =
+		coords->visible &&
+		coords->crtc_x == 0 &&
+		coords->crtc_y == 0 &&
+		coords->crtc_w == crtc->mode.hdisplay &&
+		coords->crtc_h == crtc->mode.vdisplay;
+
+	if (primary_disabled != intel_crtc->primary_disabled) {
+		struct intel_crtc_state *st = get_crtc_state(dev, s, crtc);
+		st->fb_dirty = true;
+		st->primary_disabled = primary_disabled;
+		s->dirty = true;
+	}
+}
+
 static int intel_atomic_check(struct drm_device *dev, void *state)
 {
 	struct intel_atomic_state *s = state;
@@ -1430,6 +1462,12 @@ static int intel_atomic_check(struct drm_device *dev, void *state)
 		ret = intel_check_plane(plane, plane->crtc, plane->fb, &st->coords);
 		if (ret)
 			return ret;
+
+		/* FIXME doesn't correctly handle cases where plane moves between crtcs */
+		if (plane->crtc)
+			update_primary_visibility(dev, s, plane->crtc, plane, &st->coords);
+		else if (st->old.crtc)
+			update_primary_visibility(dev, s, st->old.crtc, plane, &st->coords);
 	}
 
 	return 0;
@@ -2295,6 +2333,9 @@ static void atomic_pipe_commit(struct drm_device *dev,
 
 		intel_flip->crtc = crtc;
 
+		/* update primary_disabled befoer calc_plane() */
+		intel_crtc->primary_disabled = st->primary_disabled;
+
 		/* should already be checked so can't fail */
 		/* FIXME refactor the failing parts? */
 		dev_priv->display.calc_plane(crtc, crtc->fb, crtc->x, crtc->y);
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#42 lore raw

PATCH 42/81 drm: Add missing EXPORT_SYMBOL()s for drm_flip

In reply to [email protected]

From: Ander Conselvan de Oliveira <[email protected]>

---
 drivers/gpu/drm/drm_flip.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_flip.c +11 -0
index 6ccc3f8..a20e6a4 100644
@@ -24,6 +24,7 @@
  * Ville Syrjälä <[email protected]>
  */
 
+#include <linux/export.h>
 #include <drm/drm_flip.h>
 
 static void drm_flip_driver_cleanup(struct work_struct *work)
@@ -141,6 +142,7 @@ void drm_flip_helper_init(struct drm_flip_helper *helper,
 	helper->driver = driver;
 	helper->funcs = funcs;
 }
+EXPORT_SYMBOL(drm_flip_helper_init);
 
 void drm_flip_helper_clear(struct drm_flip_helper *helper)
 {
@@ -176,6 +178,7 @@ void drm_flip_helper_clear(struct drm_flip_helper *helper)
 	if (need_cleanup)
 		queue_work(driver->wq, &driver->cleanup_work);
 }
+EXPORT_SYMBOL(drm_flip_helper_clear);
 
 void drm_flip_helper_fini(struct drm_flip_helper *helper)
 {
@@ -186,6 +189,7 @@ void drm_flip_helper_fini(struct drm_flip_helper *helper)
 	flush_work_sync(&driver->finish_work);
 	flush_work_sync(&driver->cleanup_work);
 }
+EXPORT_SYMBOL(drm_flip_helper_fini);
 
 void drm_flip_helper_vblank(struct drm_flip_helper *helper)
 {
@@ -223,6 +227,7 @@ void drm_flip_helper_vblank(struct drm_flip_helper *helper)
 	if (need_cleanup)
 		queue_work(driver->wq, &driver->cleanup_work);
 }
+EXPORT_SYMBOL(drm_flip_helper_vblank);
 
 void drm_flip_driver_init(struct drm_flip_driver *driver,
 			  const struct drm_flip_driver_funcs *funcs)
@@ -239,6 +244,7 @@ void drm_flip_driver_init(struct drm_flip_driver *driver,
 
 	driver->wq = create_singlethread_workqueue("drm_flip");
 }
+EXPORT_SYMBOL(drm_flip_driver_init);
 
 void drm_flip_driver_fini(struct drm_flip_driver *driver)
 {
@@ -248,6 +254,7 @@ void drm_flip_driver_fini(struct drm_flip_driver *driver)
 	WARN_ON(!list_empty(&driver->finish_list));
 	WARN_ON(!list_empty(&driver->cleanup_list));
 }
+EXPORT_SYMBOL(drm_flip_driver_fini);
 
 void drm_flip_driver_schedule_flips(struct drm_flip_driver *driver,
 				    struct list_head *flips)
@@ -298,6 +305,7 @@ void drm_flip_driver_schedule_flips(struct drm_flip_driver *driver,
 	if (need_cleanup)
 		queue_work(driver->wq, &driver->cleanup_work);
 }
+EXPORT_SYMBOL(drm_flip_driver_schedule_flips);
 
 void drm_flip_driver_prepare_flips(struct drm_flip_driver *driver,
 				   struct list_head *flips)
@@ -311,6 +319,7 @@ void drm_flip_driver_prepare_flips(struct drm_flip_driver *driver,
 			helper->funcs->prepare(flip);
 	}
 }
+EXPORT_SYMBOL(drm_flip_driver_prepare_flips);
 
 void drm_flip_driver_complete_flips(struct drm_flip_driver *driver,
 				    struct list_head *flips)
@@ -365,6 +374,7 @@ void drm_flip_driver_complete_flips(struct drm_flip_driver *driver,
 	if (need_cleanup)
 		queue_work(driver->wq, &driver->cleanup_work);
 }
+EXPORT_SYMBOL(drm_flip_driver_complete_flips);
 
 void drm_flip_init(struct drm_flip *flip,
 		   struct drm_flip_helper *helper)
@@ -374,3 +384,4 @@ void drm_flip_init(struct drm_flip *flip,
 	flip->finished = false;
 	INIT_LIST_HEAD(&flip->list);
 }
+EXPORT_SYMBOL(drm_flip_init);
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#43 lore raw

PATCH 43/81 drm/i915: Clear flip helpers for sprites too

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Don't leave stale flips hanging around the sprites' flip helpers when the crtc is being disabled.

---
 drivers/gpu/drm/i915/intel_atomic.c  |   15 +++++++++++++++
 drivers/gpu/drm/i915/intel_display.c |    4 ++--
 drivers/gpu/drm/i915/intel_drv.h     |    1 +
 3 files changed, 18 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +15 -0
index 41885fa..41fd0d5 100644
@@ -2449,3 +2449,18 @@ void intel_atomic_handle_vblank(struct drm_device *dev, int pipe)
 			drm_flip_helper_vblank(&intel_plane->flip_helper);
 	}
 }
+
+void intel_atomic_clear_flips(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	struct intel_plane *intel_plane;
+	int pipe = intel_crtc->pipe;
+
+	drm_flip_helper_clear(&intel_crtc->flip_helper);
+
+	list_for_each_entry(intel_plane, &dev->mode_config.plane_list, base.head) {
+		if (intel_plane->pipe == pipe)
+			drm_flip_helper_clear(&intel_plane->flip_helper);
+	}
+}
drivers/gpu/drm/i915/intel_display.c +2 -2
index 9903456..566bf29 100644
@@ -3566,7 +3566,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 		encoder->disable(encoder);
 
 	intel_crtc_wait_for_pending_flips(crtc);
-	drm_flip_helper_clear(&intel_crtc->flip_helper);
+	intel_atomic_clear_flips(crtc);
 	drm_vblank_off(dev, pipe);
 	intel_crtc_update_cursor(crtc, false);
 
@@ -3688,7 +3688,7 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)
 
 	/* Give the overlay scaler a chance to disable if it's on this pipe */
 	intel_crtc_wait_for_pending_flips(crtc);
-	drm_flip_helper_clear(&intel_crtc->flip_helper);
+	intel_atomic_clear_flips(crtc);
 	drm_vblank_off(dev, pipe);
 	intel_crtc_dpms_overlay(intel_crtc, false);
 	intel_crtc_update_cursor(crtc, false);
drivers/gpu/drm/i915/intel_drv.h +1 -0
index 92a9518..5b0789f 100644
@@ -729,6 +729,7 @@ extern int intel_atomic_init(struct drm_device *dev);
 extern void intel_atomic_fini(struct drm_device *dev);
 extern void intel_atomic_free_events(struct drm_device *dev, struct drm_file *file);
 extern void intel_atomic_handle_vblank(struct drm_device *dev, int pipe);
+extern void intel_atomic_clear_flips(struct drm_crtc *crtc);
 
 extern void intel_enable_primary(struct drm_crtc *crtc);
 extern void intel_disable_primary(struct drm_crtc *crtc);
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#44 lore raw

PATCH 44/81 drm/i915: Refactor property handling in atomic code

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Move the property code around a bit to make it easier to move it out to the drm core later.

---
 drivers/gpu/drm/i915/intel_atomic.c |  423 ++++++++++++++++++++---------------
 drivers/gpu/drm/i915/intel_drv.h    |    3 +
 include/drm/drm_crtc.h              |   12 +
 3 files changed, 252 insertions(+), 186 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +237 -186
index 41fd0d5..0e37cf5 100644
@@ -1473,87 +1473,6 @@ static int intel_atomic_check(struct drm_device *dev, void *state)
 	return 0;
 }
 
-static void update_plane_props(struct drm_plane *plane)
-{
-	struct drm_mode_object *obj = &plane->base;
-
-	drm_object_property_set_value(obj, prop_src_x, plane->src_x);
-	drm_object_property_set_value(obj, prop_src_y, plane->src_y);
-	drm_object_property_set_value(obj, prop_src_w, plane->src_w);
-	drm_object_property_set_value(obj, prop_src_h, plane->src_h);
-
-	drm_object_property_set_value(obj, prop_crtc_x, plane->crtc_x);
-	drm_object_property_set_value(obj, prop_crtc_y, plane->crtc_y);
-	drm_object_property_set_value(obj, prop_crtc_w, plane->crtc_w);
-	drm_object_property_set_value(obj, prop_crtc_h, plane->crtc_h);
-
-	drm_object_property_set_value(obj, prop_fb_id, plane->fb ? plane->fb->base.id : 0);
-	drm_object_property_set_value(obj, prop_crtc_id, plane->crtc ? plane->crtc->base.id : 0);
-}
-
-static int update_prop_connector_ids(struct drm_crtc *crtc)
-{
-	struct drm_device *dev = crtc->dev;
-	struct drm_connector *connector;
-	uint64_t value = 0;
-	int i = 0;
-	uint32_t connector_ids[dev->mode_config.num_connector];
-
-	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
-		if (connector->encoder && connector->encoder->crtc == crtc)
-			connector_ids[i++] = connector->base.id;
-	}
-
-	if (i) {
-		drm_property_blob_replace_data(crtc->connector_ids_blob,
-					       i * sizeof connector_ids[0], connector_ids);
-		value = crtc->connector_ids_blob->base.id;
-	} else
-		drm_property_blob_replace_data(crtc->connector_ids_blob, 0, NULL);
-
-	drm_object_property_set_value(&crtc->base, prop_connector_ids, value);
-
-	return 0;
-}
-
-static int update_prop_mode(struct drm_crtc *crtc)
-{
-	uint64_t value = 0;
-
-	if (crtc->enabled) {
-		struct drm_mode_modeinfo umode;
-
-		drm_crtc_convert_to_umode(&umode, &crtc->mode);
-		drm_property_blob_replace_data(crtc->mode_blob, sizeof umode, &umode);
-		value = crtc->mode_blob->base.id;
-	} else
-		drm_property_blob_replace_data(crtc->mode_blob, 0, NULL);
-
-	drm_object_property_set_value(&crtc->base, prop_mode, value);
-
-	return 0;
-}
-
-static void update_crtc_props(struct drm_crtc *crtc)
-{
-	struct drm_mode_object *obj = &crtc->base;
-	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
-	drm_object_property_set_value(obj, prop_src_x, crtc->x);
-	drm_object_property_set_value(obj, prop_src_y, crtc->y);
-
-	drm_object_property_set_value(obj, prop_fb_id, crtc->fb ? crtc->fb->base.id : 0);
-
-	drm_object_property_set_value(obj, prop_cursor_id, intel_crtc->cursor_handle);
-	drm_object_property_set_value(obj, prop_cursor_x, intel_crtc->cursor_x);
-	drm_object_property_set_value(obj, prop_cursor_y, intel_crtc->cursor_y);
-	drm_object_property_set_value(obj, prop_cursor_w, intel_crtc->cursor_width);
-	drm_object_property_set_value(obj, prop_cursor_h, intel_crtc->cursor_height);
-
-	update_prop_mode(crtc);
-	update_prop_connector_ids(crtc);
-}
-
 static void update_props(struct drm_device *dev,
 			 struct intel_atomic_state *s)
 {
@@ -1565,7 +1484,7 @@ static void update_props(struct drm_device *dev,
 		if (!st->fb_dirty && !st->mode_dirty)
 			continue;
 
-		update_crtc_props(st->crtc);
+		intel_crtc_update_properties(st->crtc);
 	}
 
 	for (i = 0; i < dev->mode_config.num_plane; i++) {
@@ -1574,7 +1493,7 @@ static void update_props(struct drm_device *dev,
 		if (!st->dirty)
 			continue;
 
-		update_plane_props(st->plane);
+		drm_plane_update_properties(st->plane);
 	}
 }
 
@@ -1829,32 +1748,6 @@ static const struct drm_atomic_funcs intel_atomic_funcs = {
 	.end = intel_atomic_end,
 };
 
-static struct {
-	struct drm_property **prop;
-	const char *name;
-	uint64_t min;
-	uint64_t max;
-} props[] = {
-	{ &prop_src_x, "SRC_X", 0, UINT_MAX },
-	{ &prop_src_y, "SRC_Y", 0, UINT_MAX },
-	{ &prop_src_w, "SRC_W", 0, UINT_MAX },
-	{ &prop_src_h, "SRC_H", 0, UINT_MAX },
-
-	{ &prop_crtc_x, "CRTC_X", INT_MIN, INT_MAX },
-	{ &prop_crtc_y, "CRTC_Y", INT_MIN, INT_MAX },
-	{ &prop_crtc_w, "CRTC_W", 0, INT_MAX },
-	{ &prop_crtc_h, "CRTC_H", 0, INT_MAX },
-
-	{ &prop_fb_id, "FB_ID", 0, UINT_MAX },
-	{ &prop_crtc_id, "CRTC_ID", 0, UINT_MAX },
-
-	{ &prop_cursor_id, "CURSOR_ID", 0, UINT_MAX },
-	{ &prop_cursor_w, "CURSOR_W", 0, UINT_MAX },
-	{ &prop_cursor_h, "CURSOR_H", 0, UINT_MAX },
-	{ &prop_cursor_x, "CURSOR_X", INT_MIN, INT_MAX },
-	{ &prop_cursor_y, "CURSOR_Y", INT_MIN, INT_MAX },
-};
-
 static void intel_flip_init(struct drm_device *dev);
 static void intel_flip_fini(struct drm_device *dev);
 
@@ -1862,71 +1755,25 @@ int intel_atomic_init(struct drm_device *dev)
 {
 	struct drm_crtc *crtc;
 	struct drm_plane *plane;
-	int ret = -ENOMEM;
-	unsigned int i;
+	int ret;
 
-	for (i = 0; i < ARRAY_SIZE(props); i++) {
-		*props[i].prop =
-			drm_property_create_range(dev, 0, props[i].name,
-						  props[i].min, props[i].max);
-		if (!*props[i].prop)
-			goto out;
-	}
-
-	/* FIXME create special object ID list property type? */
-	prop_connector_ids = drm_property_create(dev, DRM_MODE_PROP_BLOB, "CONNECTOR_IDS", 0);
-	if (!prop_connector_ids)
-		goto out;
-
-	prop_mode = drm_property_create(dev, DRM_MODE_PROP_BLOB, "MODE", 0);
-	if (!prop_mode)
+	ret = drm_mode_create_properties(dev);
+	if (ret)
 		goto out;
 
 	list_for_each_entry(plane, &dev->mode_config.plane_list, head) {
-		struct drm_mode_object *obj = &plane->base;
-
-		drm_object_attach_property(obj, prop_src_x, 0);
-		drm_object_attach_property(obj, prop_src_y, 0);
-		drm_object_attach_property(obj, prop_src_w, 0);
-		drm_object_attach_property(obj, prop_src_h, 0);
-
-		drm_object_attach_property(obj, prop_crtc_x, 0);
-		drm_object_attach_property(obj, prop_crtc_y, 0);
-		drm_object_attach_property(obj, prop_crtc_w, 0);
-		drm_object_attach_property(obj, prop_crtc_h, 0);
-
-		drm_object_attach_property(obj, prop_fb_id, 0);
-		drm_object_attach_property(obj, prop_crtc_id, 0);
-
-		update_plane_props(plane);
+		drm_plane_attach_properties(plane);
+		drm_plane_update_properties(plane);
 	}
 
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-		struct drm_mode_object *obj = &crtc->base;
+		intel_crtc_attach_properties(crtc);
 
-		drm_object_attach_property(obj, prop_src_x, 0);
-		drm_object_attach_property(obj, prop_src_y, 0);
+		ret = drm_crtc_create_blobs(crtc);
+		if (ret)
+			goto destroy_props;
 
-		drm_object_attach_property(obj, prop_fb_id, 0);
-		drm_object_attach_property(obj, prop_mode, 0);
-		drm_object_attach_property(obj, prop_connector_ids, 0);
-
-		drm_object_attach_property(obj, prop_cursor_id, 0);
-		drm_object_attach_property(obj, prop_cursor_x, 0);
-		drm_object_attach_property(obj, prop_cursor_y, 0);
-		drm_object_attach_property(obj, prop_cursor_w, 0);
-		drm_object_attach_property(obj, prop_cursor_h, 0);
-
-		crtc->mode_blob = drm_property_create_blob(dev, 0, sizeof(struct drm_mode_modeinfo), NULL);
-		if (!crtc->mode_blob)
-			goto out;
-
-		crtc->connector_ids_blob = drm_property_create_blob(dev, 0,
-								    dev->mode_config.num_connector * sizeof(uint32_t), NULL);
-		if (!crtc->connector_ids_blob)
-			goto out;
-
-		update_crtc_props(crtc);
+		intel_crtc_update_properties(crtc);
 	}
 
 	dev->driver->atomic_funcs = &intel_atomic_funcs;
@@ -1935,12 +1782,9 @@ int intel_atomic_init(struct drm_device *dev)
 
 	return 0;
 
+ destroy_props:
+	drm_mode_destroy_properties(dev);
  out:
-	drm_property_destroy(dev, prop_mode);
-	drm_property_destroy(dev, prop_connector_ids);
-
-	while (i--)
-		drm_property_destroy(dev, *props[i].prop);
 
 	return ret;
 }
@@ -1952,24 +1796,10 @@ void intel_atomic_fini(struct drm_device *dev)
 	intel_flip_fini(dev);
 
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-		drm_property_destroy_blob(dev, crtc->mode_blob);
-		drm_property_destroy_blob(dev, crtc->connector_ids_blob);
+		drm_crtc_destroy_blobs(crtc);
 	}
 
-	drm_property_destroy(dev, prop_connector_ids);
-	drm_property_destroy(dev, prop_mode);
-	drm_property_destroy(dev, prop_crtc_id);
-	drm_property_destroy(dev, prop_fb_id);
-
-	drm_property_destroy(dev, prop_crtc_h);
-	drm_property_destroy(dev, prop_crtc_w);
-	drm_property_destroy(dev, prop_crtc_y);
-	drm_property_destroy(dev, prop_crtc_x);
-
-	drm_property_destroy(dev, prop_src_h);
-	drm_property_destroy(dev, prop_src_w);
-	drm_property_destroy(dev, prop_src_y);
-	drm_property_destroy(dev, prop_src_x);
+	drm_mode_destroy_properties(dev);
 }
 
 enum {
@@ -2464,3 +2294,224 @@ void intel_atomic_clear_flips(struct drm_crtc *crtc)
 			drm_flip_helper_clear(&intel_plane->flip_helper);
 	}
 }
+
+static void drm_crtc_update_connector_ids_property(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_connector *connector;
+	uint64_t value = 0;
+	int i = 0;
+	uint32_t connector_ids[dev->mode_config.num_connector];
+
+	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
+		if (connector->encoder && connector->encoder->crtc == crtc)
+			connector_ids[i++] = connector->base.id;
+	}
+
+	if (i) {
+		drm_property_blob_replace_data(crtc->connector_ids_blob,
+					       i * sizeof connector_ids[0], connector_ids);
+		value = crtc->connector_ids_blob->base.id;
+	} else
+		drm_property_blob_replace_data(crtc->connector_ids_blob, 0, NULL);
+
+	drm_object_property_set_value(&crtc->base, prop_connector_ids, value);
+}
+
+static void drm_crtc_update_mode_property(struct drm_crtc *crtc)
+{
+	uint64_t value = 0;
+
+	if (crtc->enabled) {
+		struct drm_mode_modeinfo umode;
+
+		drm_crtc_convert_to_umode(&umode, &crtc->mode);
+		drm_property_blob_replace_data(crtc->mode_blob, sizeof umode, &umode);
+		value = crtc->mode_blob->base.id;
+	} else
+		drm_property_blob_replace_data(crtc->mode_blob, 0, NULL);
+
+	drm_object_property_set_value(&crtc->base, prop_mode, value);
+}
+
+void drm_crtc_update_properties(struct drm_crtc *crtc)
+{
+	struct drm_mode_object *obj = &crtc->base;
+
+	drm_object_property_set_value(obj, prop_src_x, crtc->x);
+	drm_object_property_set_value(obj, prop_src_y, crtc->y);
+	drm_object_property_set_value(obj, prop_fb_id, crtc->fb ? crtc->fb->base.id : 0);
+
+	drm_crtc_update_mode_property(crtc);
+	drm_crtc_update_connector_ids_property(crtc);
+}
+
+void intel_crtc_update_properties(struct drm_crtc *crtc)
+{
+	struct drm_mode_object *obj = &crtc->base;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+
+	drm_crtc_update_properties(crtc);
+
+	drm_object_property_set_value(obj, prop_cursor_id, intel_crtc->cursor_handle);
+	drm_object_property_set_value(obj, prop_cursor_x, intel_crtc->cursor_x);
+	drm_object_property_set_value(obj, prop_cursor_y, intel_crtc->cursor_y);
+	drm_object_property_set_value(obj, prop_cursor_w, intel_crtc->cursor_width);
+	drm_object_property_set_value(obj, prop_cursor_h, intel_crtc->cursor_height);
+}
+
+void drm_plane_update_properties(struct drm_plane *plane)
+{
+	struct drm_mode_object *obj = &plane->base;
+
+	drm_object_property_set_value(obj, prop_src_x, plane->src_x);
+	drm_object_property_set_value(obj, prop_src_y, plane->src_y);
+	drm_object_property_set_value(obj, prop_src_w, plane->src_w);
+	drm_object_property_set_value(obj, prop_src_h, plane->src_h);
+
+	drm_object_property_set_value(obj, prop_crtc_x, plane->crtc_x);
+	drm_object_property_set_value(obj, prop_crtc_y, plane->crtc_y);
+	drm_object_property_set_value(obj, prop_crtc_w, plane->crtc_w);
+	drm_object_property_set_value(obj, prop_crtc_h, plane->crtc_h);
+
+	drm_object_property_set_value(obj, prop_fb_id, plane->fb ? plane->fb->base.id : 0);
+	drm_object_property_set_value(obj, prop_crtc_id, plane->crtc ? plane->crtc->base.id : 0);
+}
+
+int drm_crtc_create_blobs(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+
+	crtc->mode_blob = drm_property_create_blob(dev, 0, sizeof(struct drm_mode_modeinfo), NULL);
+	if (!crtc->mode_blob)
+		return -ENOMEM;
+
+	crtc->connector_ids_blob = drm_property_create_blob(dev, 0, dev->mode_config.num_connector * sizeof(uint32_t), NULL);
+	if (!crtc->connector_ids_blob)
+		return -ENOMEM;
+
+	return 0;
+}
+
+void drm_crtc_destroy_blobs(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+
+	drm_property_destroy_blob(dev, crtc->mode_blob);
+	drm_property_destroy_blob(dev, crtc->connector_ids_blob);
+}
+
+void drm_mode_destroy_properties(struct drm_device *dev)
+{
+	drm_property_destroy(dev, prop_connector_ids);
+	drm_property_destroy(dev, prop_mode);
+	drm_property_destroy(dev, prop_crtc_id);
+	drm_property_destroy(dev, prop_fb_id);
+
+	drm_property_destroy(dev, prop_crtc_h);
+	drm_property_destroy(dev, prop_crtc_w);
+	drm_property_destroy(dev, prop_crtc_y);
+	drm_property_destroy(dev, prop_crtc_x);
+
+	drm_property_destroy(dev, prop_src_h);
+	drm_property_destroy(dev, prop_src_w);
+	drm_property_destroy(dev, prop_src_y);
+	drm_property_destroy(dev, prop_src_x);
+}
+
+static struct {
+	struct drm_property **prop;
+	const char *name;
+	uint64_t min;
+	uint64_t max;
+} props[] = {
+	{ &prop_src_x, "SRC_X", 0, UINT_MAX },
+	{ &prop_src_y, "SRC_Y", 0, UINT_MAX },
+	{ &prop_src_w, "SRC_W", 0, UINT_MAX },
+	{ &prop_src_h, "SRC_H", 0, UINT_MAX },
+
+	{ &prop_crtc_x, "CRTC_X", INT_MIN, INT_MAX },
+	{ &prop_crtc_y, "CRTC_Y", INT_MIN, INT_MAX },
+	{ &prop_crtc_w, "CRTC_W", 0, INT_MAX },
+	{ &prop_crtc_h, "CRTC_H", 0, INT_MAX },
+
+	{ &prop_fb_id, "FB_ID", 0, UINT_MAX },
+	{ &prop_crtc_id, "CRTC_ID", 0, UINT_MAX },
+
+	{ &prop_cursor_id, "CURSOR_ID", 0, UINT_MAX },
+	{ &prop_cursor_w, "CURSOR_W", 0, UINT_MAX },
+	{ &prop_cursor_h, "CURSOR_H", 0, UINT_MAX },
+	{ &prop_cursor_x, "CURSOR_X", INT_MIN, INT_MAX },
+	{ &prop_cursor_y, "CURSOR_Y", INT_MIN, INT_MAX },
+};
+
+int drm_mode_create_properties(struct drm_device *dev)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(props); i++) {
+		*props[i].prop = drm_property_create_range(dev, 0, props[i].name, props[i].min, props[i].max);
+		if (!*props[i].prop)
+			goto out;
+	}
+
+	/* FIXME create special object ID list property type? */
+	prop_connector_ids = drm_property_create(dev, DRM_MODE_PROP_BLOB, "CONNECTOR_IDS", 0);
+	if (!prop_connector_ids)
+		goto out;
+
+	prop_mode = drm_property_create(dev, DRM_MODE_PROP_BLOB, "MODE", 0);
+	if (!prop_mode)
+		goto out;
+
+	return 0;
+
+ out:
+	drm_property_destroy(dev, prop_mode);
+	drm_property_destroy(dev, prop_connector_ids);
+
+	while (i--)
+		drm_property_destroy(dev, *props[i].prop);
+
+	return -ENOMEM; /* FIXME? */
+}
+
+void drm_plane_attach_properties(struct drm_plane *plane)
+{
+	struct drm_mode_object *obj = &plane->base;
+
+	drm_object_attach_property(obj, prop_src_x, 0);
+	drm_object_attach_property(obj, prop_src_y, 0);
+	drm_object_attach_property(obj, prop_src_w, 0);
+	drm_object_attach_property(obj, prop_src_h, 0);
+	drm_object_attach_property(obj, prop_crtc_x, 0);
+	drm_object_attach_property(obj, prop_crtc_y, 0);
+	drm_object_attach_property(obj, prop_crtc_w, 0);
+	drm_object_attach_property(obj, prop_crtc_h, 0);
+	drm_object_attach_property(obj, prop_fb_id, 0);
+	drm_object_attach_property(obj, prop_crtc_id, 0);
+}
+
+void drm_crtc_attach_properties(struct drm_crtc *crtc)
+{
+	struct drm_mode_object *obj = &crtc->base;
+
+	drm_object_attach_property(obj, prop_src_x, 0);
+	drm_object_attach_property(obj, prop_src_y, 0);
+	drm_object_attach_property(obj, prop_fb_id, 0);
+	drm_object_attach_property(obj, prop_mode, 0);
+	drm_object_attach_property(obj, prop_connector_ids, 0);
+}
+
+void intel_crtc_attach_properties(struct drm_crtc *crtc)
+{
+	struct drm_mode_object *obj = &crtc->base;
+
+	drm_crtc_attach_properties(crtc);
+
+	drm_object_attach_property(obj, prop_cursor_id, 0);
+	drm_object_attach_property(obj, prop_cursor_x, 0);
+	drm_object_attach_property(obj, prop_cursor_y, 0);
+	drm_object_attach_property(obj, prop_cursor_w, 0);
+	drm_object_attach_property(obj, prop_cursor_h, 0);
+}
drivers/gpu/drm/i915/intel_drv.h +3 -0
index 5b0789f..1230c1b 100644
@@ -734,4 +734,7 @@ extern void intel_atomic_clear_flips(struct drm_crtc *crtc);
 extern void intel_enable_primary(struct drm_crtc *crtc);
 extern void intel_disable_primary(struct drm_crtc *crtc);
 
+extern void intel_crtc_attach_properties(struct drm_crtc *crtc);
+extern void intel_crtc_update_properties(struct drm_crtc *crtc);
+
 #endif /* __INTEL_DRV_H__ */
include/drm/drm_crtc.h +12 -0
index 897c110..74fb5a8 100644
@@ -1147,4 +1147,16 @@ struct drm_atomic_funcs {
 	void (*end)(struct drm_device *dev, void *state);
 };
 
+extern int drm_mode_create_properties(struct drm_device *dev);
+extern void drm_mode_destroy_properties(struct drm_device *dev);
+
+extern int drm_crtc_create_blobs(struct drm_crtc *crtc);
+extern void drm_crtc_destroy_blobs(struct drm_crtc *crtc);
+
+extern void drm_crtc_attach_properties(struct drm_crtc *crtc);
+extern void drm_plane_attach_properties(struct drm_plane *plane);
+
+extern void drm_crtc_update_properties(struct drm_crtc *crtc);
+extern void drm_plane_update_properties(struct drm_plane *plane);
+
 #endif /* __DRM_CRTC_H__ */
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#45 lore raw

PATCH 45/81 drm/i915: Move standard properties under mode_config

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Standard connector properties are kept in the mode_config structure. Move the CRTC and plane properties there as well.

---
 drivers/gpu/drm/i915/intel_atomic.c |  293 +++++++++++++++++++----------------
 include/drm/drm_crtc.h              |   19 +++
 2 files changed, 175 insertions(+), 137 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +156 -137
index 0e37cf5..0def947 100644
@@ -30,24 +30,6 @@
 
 #include "intel_drv.h"
 
-static struct drm_property *prop_src_x;
-static struct drm_property *prop_src_y;
-static struct drm_property *prop_src_w;
-static struct drm_property *prop_src_h;
-static struct drm_property *prop_crtc_x;
-static struct drm_property *prop_crtc_y;
-static struct drm_property *prop_crtc_w;
-static struct drm_property *prop_crtc_h;
-static struct drm_property *prop_fb_id;
-static struct drm_property *prop_crtc_id;
-static struct drm_property *prop_mode;
-static struct drm_property *prop_connector_ids;
-static struct drm_property *prop_cursor_id;
-static struct drm_property *prop_cursor_x;
-static struct drm_property *prop_cursor_y;
-static struct drm_property *prop_cursor_w;
-static struct drm_property *prop_cursor_h;
-
 struct intel_flip {
 	struct drm_flip base;
 	u32 vbl_count;
@@ -368,27 +350,28 @@ static int plane_set(struct intel_atomic_state *s,
 		     uint64_t value)
 {
 	struct drm_plane *plane = state->plane;
+	struct drm_mode_config *config = &plane->dev->mode_config;
 	struct drm_mode_object *obj;
 
 	state->changed = true;
 
-	if (prop == prop_src_x) {
+	if (prop == config->src_x_prop) {
 		plane->src_x = value;
-	} else if (prop == prop_src_y) {
+	} else if (prop == config->src_y_prop) {
 		plane->src_y = value;
-	} else if (prop == prop_src_w) {
+	} else if (prop == config->src_w_prop) {
 		plane->src_w = value;
-	} else if (prop == prop_src_h) {
+	} else if (prop == config->src_h_prop) {
 		plane->src_h = value;
-	} else if (prop == prop_crtc_x) {
+	} else if (prop == config->crtc_x_prop) {
 		plane->crtc_x = value;
-	} else if (prop == prop_crtc_y) {
+	} else if (prop == config->crtc_y_prop) {
 		plane->crtc_y = value;
-	} else if (prop == prop_crtc_w) {
+	} else if (prop == config->crtc_w_prop) {
 		plane->crtc_w = value;
-	} else if (prop == prop_crtc_h) {
+	} else if (prop == config->crtc_h_prop) {
 		plane->crtc_h = value;
-	} else if (prop == prop_crtc_id) {
+	} else if (prop == config->crtc_id_prop) {
 		if (value) {
 			obj = drm_mode_object_find(plane->dev, value, DRM_MODE_OBJECT_CRTC);
 			if (!obj) {
@@ -398,7 +381,7 @@ static int plane_set(struct intel_atomic_state *s,
 			plane->crtc = obj_to_crtc(obj);
 		} else
 			plane->crtc = NULL;
-	} else if (prop == prop_fb_id) {
+	} else if (prop == config->fb_id_prop) {
 		if (value) {
 			obj = drm_mode_object_find(plane->dev, value, DRM_MODE_OBJECT_FB);
 			if (!obj) {
@@ -422,16 +405,17 @@ static int crtc_set(struct intel_atomic_state *s,
 		    uint64_t value, const void *blob_data)
 {
 	struct drm_crtc *crtc = state->crtc;
+	struct drm_mode_config *config = &crtc->dev->mode_config;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct drm_mode_object *obj;
 
 	state->changed = true;
 
-	if (prop == prop_src_x) {
+	if (prop == config->src_x_prop) {
 		crtc->x = value;
-	} else if (prop == prop_src_y) {
+	} else if (prop == config->src_y_prop) {
 		crtc->y = value;
-	} else if (prop == prop_mode) {
+	} else if (prop == config->mode_prop) {
 		const struct drm_mode_modeinfo *umode = blob_data;
 
 		if (value != 0 && value != sizeof *umode) {
@@ -462,7 +446,7 @@ static int crtc_set(struct intel_atomic_state *s,
 			drm_mode_destroy(crtc->dev, mode);
 		} else
 			crtc->enabled = false;
-	} else if (prop == prop_fb_id) {
+	} else if (prop == config->fb_id_prop) {
 		if (value) {
 			obj = drm_mode_object_find(crtc->dev, value, DRM_MODE_OBJECT_FB);
 			if (!obj) {
@@ -472,7 +456,7 @@ static int crtc_set(struct intel_atomic_state *s,
 			crtc->fb = obj_to_fb(obj);
 		} else
 			crtc->fb = NULL;
-	} else if (prop == prop_connector_ids) {
+	} else if (prop == config->connector_ids_prop) {
 		const uint32_t *ids = blob_data;
 		uint64_t count_ids = value / sizeof(uint32_t);
 		int ret;
@@ -482,7 +466,7 @@ static int crtc_set(struct intel_atomic_state *s,
 			return -EINVAL;
 		}
 
-		if (count_ids > crtc->dev->mode_config.num_connector) {
+		if (count_ids > config->num_connector) {
 			DRM_DEBUG_KMS("Too many connectors specified\n");
 			return -ERANGE;
 		}
@@ -490,19 +474,19 @@ static int crtc_set(struct intel_atomic_state *s,
 		ret = process_connectors(state, ids, count_ids);
 		if (ret)
 			return ret;
-	} else if (prop == prop_cursor_id) {
+	} else if (prop == config->cursor_id_prop) {
 		intel_crtc->cursor_handle = value;
-	} else if (prop == prop_cursor_x) {
+	} else if (prop == config->cursor_x_prop) {
 		intel_crtc->cursor_x = value;
-	} else if (prop == prop_cursor_y) {
+	} else if (prop == config->cursor_y_prop) {
 		intel_crtc->cursor_y = value;
-	} else if (prop == prop_cursor_w) {
+	} else if (prop == config->cursor_w_prop) {
 		if (value != 0 && value != 64) {
 			DRM_DEBUG_KMS("only 64x64 cursor sprites are supported\n");
 			return -EINVAL;
 		}
 		intel_crtc->cursor_width = value;
-	} else if (prop == prop_cursor_h) {
+	} else if (prop == config->cursor_h_prop) {
 		if (value != 0 && value != 64) {
 			DRM_DEBUG_KMS("only 64x64 cursor sprites are supported\n");
 			return -EINVAL;
@@ -2297,13 +2281,13 @@ void intel_atomic_clear_flips(struct drm_crtc *crtc)
 
 static void drm_crtc_update_connector_ids_property(struct drm_crtc *crtc)
 {
-	struct drm_device *dev = crtc->dev;
+	struct drm_mode_config *config = &crtc->dev->mode_config;
 	struct drm_connector *connector;
 	uint64_t value = 0;
 	int i = 0;
-	uint32_t connector_ids[dev->mode_config.num_connector];
+	uint32_t connector_ids[config->num_connector];
 
-	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
+	list_for_each_entry(connector, &config->connector_list, head) {
 		if (connector->encoder && connector->encoder->crtc == crtc)
 			connector_ids[i++] = connector->base.id;
 	}
@@ -2315,11 +2299,12 @@ static void drm_crtc_update_connector_ids_property(struct drm_crtc *crtc)
 	} else
 		drm_property_blob_replace_data(crtc->connector_ids_blob, 0, NULL);
 
-	drm_object_property_set_value(&crtc->base, prop_connector_ids, value);
+	drm_object_property_set_value(&crtc->base, config->connector_ids_prop, value);
 }
 
 static void drm_crtc_update_mode_property(struct drm_crtc *crtc)
 {
+	struct drm_mode_config *config = &crtc->dev->mode_config;
 	uint64_t value = 0;
 
 	if (crtc->enabled) {
@@ -2331,16 +2316,17 @@ static void drm_crtc_update_mode_property(struct drm_crtc *crtc)
 	} else
 		drm_property_blob_replace_data(crtc->mode_blob, 0, NULL);
 
-	drm_object_property_set_value(&crtc->base, prop_mode, value);
+	drm_object_property_set_value(&crtc->base, config->mode_prop, value);
 }
 
 void drm_crtc_update_properties(struct drm_crtc *crtc)
 {
 	struct drm_mode_object *obj = &crtc->base;
+	struct drm_mode_config *config = &crtc->dev->mode_config;
 
-	drm_object_property_set_value(obj, prop_src_x, crtc->x);
-	drm_object_property_set_value(obj, prop_src_y, crtc->y);
-	drm_object_property_set_value(obj, prop_fb_id, crtc->fb ? crtc->fb->base.id : 0);
+	drm_object_property_set_value(obj, config->src_x_prop, crtc->x);
+	drm_object_property_set_value(obj, config->src_y_prop, crtc->y);
+	drm_object_property_set_value(obj, config->fb_id_prop, crtc->fb ? crtc->fb->base.id : 0);
 
 	drm_crtc_update_mode_property(crtc);
 	drm_crtc_update_connector_ids_property(crtc);
@@ -2349,33 +2335,35 @@ void drm_crtc_update_properties(struct drm_crtc *crtc)
 void intel_crtc_update_properties(struct drm_crtc *crtc)
 {
 	struct drm_mode_object *obj = &crtc->base;
+	struct drm_mode_config *config = &crtc->dev->mode_config;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 
 	drm_crtc_update_properties(crtc);
 
-	drm_object_property_set_value(obj, prop_cursor_id, intel_crtc->cursor_handle);
-	drm_object_property_set_value(obj, prop_cursor_x, intel_crtc->cursor_x);
-	drm_object_property_set_value(obj, prop_cursor_y, intel_crtc->cursor_y);
-	drm_object_property_set_value(obj, prop_cursor_w, intel_crtc->cursor_width);
-	drm_object_property_set_value(obj, prop_cursor_h, intel_crtc->cursor_height);
+	drm_object_property_set_value(obj, config->cursor_id_prop, intel_crtc->cursor_handle);
+	drm_object_property_set_value(obj, config->cursor_x_prop, intel_crtc->cursor_x);
+	drm_object_property_set_value(obj, config->cursor_y_prop, intel_crtc->cursor_y);
+	drm_object_property_set_value(obj, config->cursor_w_prop, intel_crtc->cursor_width);
+	drm_object_property_set_value(obj, config->cursor_h_prop, intel_crtc->cursor_height);
 }
 
 void drm_plane_update_properties(struct drm_plane *plane)
 {
 	struct drm_mode_object *obj = &plane->base;
+	struct drm_mode_config *config = &plane->dev->mode_config;
 
-	drm_object_property_set_value(obj, prop_src_x, plane->src_x);
-	drm_object_property_set_value(obj, prop_src_y, plane->src_y);
-	drm_object_property_set_value(obj, prop_src_w, plane->src_w);
-	drm_object_property_set_value(obj, prop_src_h, plane->src_h);
+	drm_object_property_set_value(obj, config->src_x_prop, plane->src_x);
+	drm_object_property_set_value(obj, config->src_y_prop, plane->src_y);
+	drm_object_property_set_value(obj, config->src_w_prop, plane->src_w);
+	drm_object_property_set_value(obj, config->src_h_prop, plane->src_h);
 
-	drm_object_property_set_value(obj, prop_crtc_x, plane->crtc_x);
-	drm_object_property_set_value(obj, prop_crtc_y, plane->crtc_y);
-	drm_object_property_set_value(obj, prop_crtc_w, plane->crtc_w);
-	drm_object_property_set_value(obj, prop_crtc_h, plane->crtc_h);
+	drm_object_property_set_value(obj, config->crtc_x_prop, plane->crtc_x);
+	drm_object_property_set_value(obj, config->crtc_y_prop, plane->crtc_y);
+	drm_object_property_set_value(obj, config->crtc_w_prop, plane->crtc_w);
+	drm_object_property_set_value(obj, config->crtc_h_prop, plane->crtc_h);
 
-	drm_object_property_set_value(obj, prop_fb_id, plane->fb ? plane->fb->base.id : 0);
-	drm_object_property_set_value(obj, prop_crtc_id, plane->crtc ? plane->crtc->base.id : 0);
+	drm_object_property_set_value(obj, config->fb_id_prop, plane->fb ? plane->fb->base.id : 0);
+	drm_object_property_set_value(obj, config->crtc_id_prop, plane->crtc ? plane->crtc->base.id : 0);
 }
 
 int drm_crtc_create_blobs(struct drm_crtc *crtc)
@@ -2401,77 +2389,105 @@ void drm_crtc_destroy_blobs(struct drm_crtc *crtc)
 	drm_property_destroy_blob(dev, crtc->connector_ids_blob);
 }
 
+void drm_property_destroy_null(struct drm_device *dev, struct drm_property **prop)
+{
+	drm_property_destroy(dev, *prop);
+	*prop = NULL;
+}
+
 void drm_mode_destroy_properties(struct drm_device *dev)
 {
-	drm_property_destroy(dev, prop_connector_ids);
-	drm_property_destroy(dev, prop_mode);
-	drm_property_destroy(dev, prop_crtc_id);
-	drm_property_destroy(dev, prop_fb_id);
-
-	drm_property_destroy(dev, prop_crtc_h);
-	drm_property_destroy(dev, prop_crtc_w);
-	drm_property_destroy(dev, prop_crtc_y);
-	drm_property_destroy(dev, prop_crtc_x);
-
-	drm_property_destroy(dev, prop_src_h);
-	drm_property_destroy(dev, prop_src_w);
-	drm_property_destroy(dev, prop_src_y);
-	drm_property_destroy(dev, prop_src_x);
+	struct drm_mode_config *config = &dev->mode_config;
+
+	drm_property_destroy_null(dev, &config->cursor_h_prop);
+	drm_property_destroy_null(dev, &config->cursor_w_prop);
+	drm_property_destroy_null(dev, &config->cursor_y_prop);
+	drm_property_destroy_null(dev, &config->cursor_x_prop);
+	drm_property_destroy_null(dev, &config->cursor_id_prop);
+
+	drm_property_destroy_null(dev, &config->connector_ids_prop);
+	drm_property_destroy_null(dev, &config->mode_prop);
+
+	drm_property_destroy_null(dev, &config->crtc_id_prop);
+	drm_property_destroy_null(dev, &config->fb_id_prop);
+
+	drm_property_destroy_null(dev, &config->crtc_h_prop);
+	drm_property_destroy_null(dev, &config->crtc_w_prop);
+	drm_property_destroy_null(dev, &config->crtc_y_prop);
+	drm_property_destroy_null(dev, &config->crtc_x_prop);
+
+	drm_property_destroy_null(dev, &config->src_h_prop);
+	drm_property_destroy_null(dev, &config->src_w_prop);
+	drm_property_destroy_null(dev, &config->src_y_prop);
+	drm_property_destroy_null(dev, &config->src_x_prop);
 }
 
-static struct {
-	struct drm_property **prop;
-	const char *name;
-	uint64_t min;
-	uint64_t max;
-} props[] = {
-	{ &prop_src_x, "SRC_X", 0, UINT_MAX },
-	{ &prop_src_y, "SRC_Y", 0, UINT_MAX },
-	{ &prop_src_w, "SRC_W", 0, UINT_MAX },
-	{ &prop_src_h, "SRC_H", 0, UINT_MAX },
-
-	{ &prop_crtc_x, "CRTC_X", INT_MIN, INT_MAX },
-	{ &prop_crtc_y, "CRTC_Y", INT_MIN, INT_MAX },
-	{ &prop_crtc_w, "CRTC_W", 0, INT_MAX },
-	{ &prop_crtc_h, "CRTC_H", 0, INT_MAX },
-
-	{ &prop_fb_id, "FB_ID", 0, UINT_MAX },
-	{ &prop_crtc_id, "CRTC_ID", 0, UINT_MAX },
-
-	{ &prop_cursor_id, "CURSOR_ID", 0, UINT_MAX },
-	{ &prop_cursor_w, "CURSOR_W", 0, UINT_MAX },
-	{ &prop_cursor_h, "CURSOR_H", 0, UINT_MAX },
-	{ &prop_cursor_x, "CURSOR_X", INT_MIN, INT_MAX },
-	{ &prop_cursor_y, "CURSOR_Y", INT_MIN, INT_MAX },
-};
-
 int drm_mode_create_properties(struct drm_device *dev)
 {
-	int i;
+	struct drm_mode_config *config = &dev->mode_config;
 
-	for (i = 0; i < ARRAY_SIZE(props); i++) {
-		*props[i].prop = drm_property_create_range(dev, 0, props[i].name, props[i].min, props[i].max);
-		if (!*props[i].prop)
-			goto out;
-	}
+	config->src_x_prop = drm_property_create_range(dev, 0, "SRC_X", 0, UINT_MAX);
+	if (!config->src_x_prop)
+		goto out;
+	config->src_y_prop = drm_property_create_range(dev, 0, "SRC_Y", 0, UINT_MAX);
+	if (!config->src_y_prop)
+		goto out;
+	config->src_w_prop = drm_property_create_range(dev, 0, "SRC_W", 0, UINT_MAX);
+	if (!config->src_w_prop)
+		goto out;
+	config->src_h_prop = drm_property_create_range(dev, 0, "SRC_H", 0, UINT_MAX);
+	if (!config->src_h_prop)
+		goto out;
+
+	config->crtc_x_prop = drm_property_create_range(dev, 0, "CRTC_X", INT_MIN, INT_MAX);
+	if (!config->crtc_x_prop)
+		goto out;
+	config->crtc_y_prop = drm_property_create_range(dev, 0, "CRTC_Y", INT_MIN, INT_MAX);
+	if (!config->crtc_y_prop)
+		goto out;
+	config->crtc_w_prop = drm_property_create_range(dev, 0, "CRTC_W", 0, UINT_MAX);
+	if (!config->crtc_w_prop)
+		goto out;
+	config->crtc_h_prop = drm_property_create_range(dev, 0, "CRTC_H", 0, UINT_MAX);
+	if (!config->crtc_h_prop)
+		goto out;
+
+	config->fb_id_prop = drm_property_create_range(dev, 0, "FB_ID", 0, UINT_MAX);
+	if (!config->fb_id_prop)
+		goto out;
+	config->crtc_id_prop = drm_property_create_range(dev, 0, "CRTC_ID", 0, UINT_MAX);
+	if (!config->crtc_id_prop)
+		goto out;
+
+	config->cursor_id_prop = drm_property_create_range(dev, 0, "CURSOR_ID", 0, UINT_MAX);
+	if (!config->cursor_id_prop)
+		goto out;
+	config->cursor_x_prop = drm_property_create_range(dev, 0, "CURSOR_X", INT_MIN, INT_MAX);
+	if (!config->cursor_x_prop)
+		goto out;
+	config->cursor_y_prop = drm_property_create_range(dev, 0, "CURSOR_Y", INT_MIN, INT_MAX);
+	if (!config->cursor_y_prop)
+		goto out;
+	config->cursor_w_prop = drm_property_create_range(dev, 0, "CURSOR_W", 0, UINT_MAX);
+	if (!config->cursor_w_prop)
+		goto out;
+	config->cursor_h_prop = drm_property_create_range(dev, 0, "CURSOR_H", 0, UINT_MAX);
+	if (!config->cursor_h_prop)
+		goto out;
 
 	/* FIXME create special object ID list property type? */
-	prop_connector_ids = drm_property_create(dev, DRM_MODE_PROP_BLOB, "CONNECTOR_IDS", 0);
-	if (!prop_connector_ids)
+	config->connector_ids_prop = drm_property_create(dev, DRM_MODE_PROP_BLOB, "CONNECTOR_IDS", 0);
+	if (!config->connector_ids_prop)
 		goto out;
 
-	prop_mode = drm_property_create(dev, DRM_MODE_PROP_BLOB, "MODE", 0);
-	if (!prop_mode)
+	config->mode_prop = drm_property_create(dev, DRM_MODE_PROP_BLOB, "MODE", 0);
+	if (!config->mode_prop)
 		goto out;
 
 	return 0;
 
  out:
-	drm_property_destroy(dev, prop_mode);
-	drm_property_destroy(dev, prop_connector_ids);
-
-	while (i--)
-		drm_property_destroy(dev, *props[i].prop);
+	drm_mode_destroy_properties(dev);
 
 	return -ENOMEM; /* FIXME? */
 }
@@ -2479,39 +2495,42 @@ int drm_mode_create_properties(struct drm_device *dev)
 void drm_plane_attach_properties(struct drm_plane *plane)
 {
 	struct drm_mode_object *obj = &plane->base;
+	struct drm_mode_config *config = &plane->dev->mode_config;
 
-	drm_object_attach_property(obj, prop_src_x, 0);
-	drm_object_attach_property(obj, prop_src_y, 0);
-	drm_object_attach_property(obj, prop_src_w, 0);
-	drm_object_attach_property(obj, prop_src_h, 0);
-	drm_object_attach_property(obj, prop_crtc_x, 0);
-	drm_object_attach_property(obj, prop_crtc_y, 0);
-	drm_object_attach_property(obj, prop_crtc_w, 0);
-	drm_object_attach_property(obj, prop_crtc_h, 0);
-	drm_object_attach_property(obj, prop_fb_id, 0);
-	drm_object_attach_property(obj, prop_crtc_id, 0);
+	drm_object_attach_property(obj, config->src_x_prop, 0);
+	drm_object_attach_property(obj, config->src_y_prop, 0);
+	drm_object_attach_property(obj, config->src_w_prop, 0);
+	drm_object_attach_property(obj, config->src_h_prop, 0);
+	drm_object_attach_property(obj, config->crtc_x_prop, 0);
+	drm_object_attach_property(obj, config->crtc_y_prop, 0);
+	drm_object_attach_property(obj, config->crtc_w_prop, 0);
+	drm_object_attach_property(obj, config->crtc_h_prop, 0);
+	drm_object_attach_property(obj, config->fb_id_prop, 0);
+	drm_object_attach_property(obj, config->crtc_id_prop, 0);
 }
 
 void drm_crtc_attach_properties(struct drm_crtc *crtc)
 {
 	struct drm_mode_object *obj = &crtc->base;
+	struct drm_mode_config *config = &crtc->dev->mode_config;
 
-	drm_object_attach_property(obj, prop_src_x, 0);
-	drm_object_attach_property(obj, prop_src_y, 0);
-	drm_object_attach_property(obj, prop_fb_id, 0);
-	drm_object_attach_property(obj, prop_mode, 0);
-	drm_object_attach_property(obj, prop_connector_ids, 0);
+	drm_object_attach_property(obj, config->src_x_prop, 0);
+	drm_object_attach_property(obj, config->src_y_prop, 0);
+	drm_object_attach_property(obj, config->fb_id_prop, 0);
+	drm_object_attach_property(obj, config->mode_prop, 0);
+	drm_object_attach_property(obj, config->connector_ids_prop, 0);
 }
 
 void intel_crtc_attach_properties(struct drm_crtc *crtc)
 {
 	struct drm_mode_object *obj = &crtc->base;
+	struct drm_mode_config *config = &crtc->dev->mode_config;
 
 	drm_crtc_attach_properties(crtc);
 
-	drm_object_attach_property(obj, prop_cursor_id, 0);
-	drm_object_attach_property(obj, prop_cursor_x, 0);
-	drm_object_attach_property(obj, prop_cursor_y, 0);
-	drm_object_attach_property(obj, prop_cursor_w, 0);
-	drm_object_attach_property(obj, prop_cursor_h, 0);
+	drm_object_attach_property(obj, config->cursor_id_prop, 0);
+	drm_object_attach_property(obj, config->cursor_x_prop, 0);
+	drm_object_attach_property(obj, config->cursor_y_prop, 0);
+	drm_object_attach_property(obj, config->cursor_w_prop, 0);
+	drm_object_attach_property(obj, config->cursor_h_prop, 0);
 }
include/drm/drm_crtc.h +19 -0
index 74fb5a8..c8cea87 100644
@@ -835,6 +835,25 @@ struct drm_mode_config {
 	struct drm_property *dithering_mode_property;
 	struct drm_property *dirty_info_property;
 
+	/* CRTC/plane properties */
+	struct drm_property *src_x_prop;
+	struct drm_property *src_y_prop;
+	struct drm_property *src_w_prop;
+	struct drm_property *src_h_prop;
+	struct drm_property *crtc_x_prop;
+	struct drm_property *crtc_y_prop;
+	struct drm_property *crtc_w_prop;
+	struct drm_property *crtc_h_prop;
+	struct drm_property *fb_id_prop;
+	struct drm_property *crtc_id_prop;
+	struct drm_property *mode_prop;
+	struct drm_property *connector_ids_prop;
+	struct drm_property *cursor_id_prop;
+	struct drm_property *cursor_x_prop;
+	struct drm_property *cursor_y_prop;
+	struct drm_property *cursor_w_prop;
+	struct drm_property *cursor_h_prop;
+
 	/* dumb ioctl parameters */
 	uint32_t preferred_depth, prefer_shadow;
 };
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#46 lore raw

PATCH 46/81 drm_crtc_helper: Update standard crtc properties after modeset

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Keep the new CRTC properties when doing modeset through the legacy code paths.

---
 drivers/gpu/drm/drm_crtc_helper.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc_helper.c +10 -0
index 30eb557..19444cd 100644
@@ -782,6 +782,11 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
 	kfree(save_connectors);
 	kfree(save_encoders);
 	kfree(save_crtcs);
+
+	/* changes in one CRTC can affect the others */
+	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
+		drm_crtc_update_properties(crtc);
+
 	return 0;
 
 fail:
@@ -810,6 +815,11 @@ fail:
 	kfree(save_connectors);
 	kfree(save_encoders);
 	kfree(save_crtcs);
+
+	/* changes in one CRTC can affect the others */
+	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
+		drm_crtc_update_properties(crtc);
+
 	return ret;
 }
 EXPORT_SYMBOL(drm_crtc_helper_set_config);
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#47 lore raw

PATCH 47/81 drm: Update standard plane properties after update_plane/disable_plane

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Keep the new plane properties when doing operations through the legacy code paths.

---
 drivers/gpu/drm/drm_crtc.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc.c +6 -0
index 897ff46..9d8738f 100644
@@ -407,6 +407,8 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
 			/* disconnect the plane from the fb and crtc: */
 			plane->fb = NULL;
 			plane->crtc = NULL;
+
+			drm_plane_update_properties(plane);
 		}
 	}
 
@@ -1780,6 +1782,8 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
 		plane->funcs->disable_plane(plane);
 		plane->crtc = NULL;
 		plane->fb = NULL;
+
+		drm_plane_update_properties(plane);
 		goto out;
 	}
 
@@ -1863,6 +1867,8 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
 		plane->src_y = plane_req->src_y;
 		plane->src_w = plane_req->src_w;
 		plane->src_h = plane_req->src_h;
+
+		drm_plane_update_properties(plane);
 	}
 
 out:
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#48 lore raw

PATCH 48/81 drm/i915: Update CRTC properties after modeset

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Update cursor related CRTC properties after a modeset. The cursor properties aren't handled by the drm core since not all CRTCs have cursors.

---
 drivers/gpu/drm/i915/intel_display.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/intel_display.c +15 -0
index 566bf29..321c840 100644
@@ -6368,6 +6368,8 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
 	if (old_obj)
 		intel_crtc_cursor_bo_unref(crtc, old_obj);
 
+	intel_crtc_update_properties(crtc);
+
 	return 0;
 }
 
@@ -6380,6 +6382,8 @@ static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
 
 	intel_crtc_update_cursor(crtc, true);
 
+	intel_crtc_update_properties(crtc);
+
 	return 0;
 }
 
@@ -7341,6 +7345,8 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 
 	trace_i915_flip_request(intel_crtc->plane, obj);
 
+	intel_crtc_update_properties(crtc);
+
 	return 0;
 
 cleanup_pending:
@@ -8067,6 +8073,7 @@ next_encoder:
 static int intel_crtc_set_config(struct drm_mode_set *set)
 {
 	struct drm_device *dev;
+	struct drm_crtc *crtc;
 	struct drm_mode_set save_set;
 	struct intel_set_config *config;
 	int ret;
@@ -8140,6 +8147,10 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
 
 	intel_set_config_free(config);
 
+	/* changes in one CRTC can affect the others */
+	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
+		intel_crtc_update_properties(crtc);
+
 	return 0;
 
 fail:
@@ -8151,6 +8162,10 @@ fail:
 			    save_set.x, save_set.y, save_set.fb))
 		DRM_ERROR("failed to restore config after modeset failure\n");
 
+	/* changes in one CRTC can affect the others */
+	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
+		intel_crtc_update_properties(crtc);
+
 out_config:
 	intel_set_config_free(config);
 	return ret;
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#49 lore raw

PATCH 49/81 drm: Move standard crtc/plane prop handling to drm_crtc.c

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Move some of the property code to drm_crtc.c since it should be shared by everyone.

---
 drivers/gpu/drm/drm_crtc.c           |  235 +++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_atomic.c  |  256 ----------------------------------
 drivers/gpu/drm/i915/intel_display.c |   29 ++++
 3 files changed, 264 insertions(+), 256 deletions(-)
drivers/gpu/drm/drm_crtc.c +235 -0
index 9d8738f..527b35b 100644
@@ -4397,3 +4397,238 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 
 	return ret;
 }
+
+static void drm_crtc_update_connector_ids_property(struct drm_crtc *crtc)
+{
+	struct drm_mode_config *config = &crtc->dev->mode_config;
+	struct drm_connector *connector;
+	uint64_t value = 0;
+	int i = 0;
+	uint32_t connector_ids[config->num_connector];
+
+	list_for_each_entry(connector, &config->connector_list, head) {
+		if (connector->encoder && connector->encoder->crtc == crtc)
+			connector_ids[i++] = connector->base.id;
+	}
+
+	if (i) {
+		drm_property_blob_replace_data(crtc->connector_ids_blob,
+					       i * sizeof connector_ids[0], connector_ids);
+		value = crtc->connector_ids_blob->base.id;
+	} else
+		drm_property_blob_replace_data(crtc->connector_ids_blob, 0, NULL);
+
+	drm_object_property_set_value(&crtc->base, config->connector_ids_prop, value);
+}
+
+static void drm_crtc_update_mode_property(struct drm_crtc *crtc)
+{
+	struct drm_mode_config *config = &crtc->dev->mode_config;
+	uint64_t value = 0;
+
+	if (crtc->enabled) {
+		struct drm_mode_modeinfo umode;
+
+		drm_crtc_convert_to_umode(&umode, &crtc->mode);
+		drm_property_blob_replace_data(crtc->mode_blob, sizeof umode, &umode);
+		value = crtc->mode_blob->base.id;
+	} else
+		drm_property_blob_replace_data(crtc->mode_blob, 0, NULL);
+
+	drm_object_property_set_value(&crtc->base, config->mode_prop, value);
+}
+
+void drm_crtc_update_properties(struct drm_crtc *crtc)
+{
+	struct drm_mode_object *obj = &crtc->base;
+	struct drm_mode_config *config = &crtc->dev->mode_config;
+
+	drm_object_property_set_value(obj, config->src_x_prop, crtc->x);
+	drm_object_property_set_value(obj, config->src_y_prop, crtc->y);
+	drm_object_property_set_value(obj, config->fb_id_prop, crtc->fb ? crtc->fb->base.id : 0);
+
+	drm_crtc_update_mode_property(crtc);
+	drm_crtc_update_connector_ids_property(crtc);
+}
+EXPORT_SYMBOL(drm_crtc_update_properties);
+
+void drm_plane_update_properties(struct drm_plane *plane)
+{
+	struct drm_mode_object *obj = &plane->base;
+	struct drm_mode_config *config = &plane->dev->mode_config;
+
+	drm_object_property_set_value(obj, config->src_x_prop, plane->src_x);
+	drm_object_property_set_value(obj, config->src_y_prop, plane->src_y);
+	drm_object_property_set_value(obj, config->src_w_prop, plane->src_w);
+	drm_object_property_set_value(obj, config->src_h_prop, plane->src_h);
+
+	drm_object_property_set_value(obj, config->crtc_x_prop, plane->crtc_x);
+	drm_object_property_set_value(obj, config->crtc_y_prop, plane->crtc_y);
+	drm_object_property_set_value(obj, config->crtc_w_prop, plane->crtc_w);
+	drm_object_property_set_value(obj, config->crtc_h_prop, plane->crtc_h);
+
+	drm_object_property_set_value(obj, config->fb_id_prop, plane->fb ? plane->fb->base.id : 0);
+	drm_object_property_set_value(obj, config->crtc_id_prop, plane->crtc ? plane->crtc->base.id : 0);
+}
+EXPORT_SYMBOL(drm_plane_update_properties);
+
+int drm_crtc_create_blobs(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+
+	crtc->mode_blob = drm_property_create_blob(dev, 0, sizeof(struct drm_mode_modeinfo), NULL);
+	if (!crtc->mode_blob)
+		return -ENOMEM;
+
+	crtc->connector_ids_blob = drm_property_create_blob(dev, 0, dev->mode_config.num_connector * sizeof(uint32_t), NULL);
+	if (!crtc->connector_ids_blob)
+		return -ENOMEM;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_crtc_create_blobs);
+
+void drm_crtc_destroy_blobs(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+
+	drm_property_destroy_blob(dev, crtc->mode_blob);
+	drm_property_destroy_blob(dev, crtc->connector_ids_blob);
+}
+EXPORT_SYMBOL(drm_crtc_destroy_blobs);
+
+static void drm_property_destroy_null(struct drm_device *dev, struct drm_property **prop)
+{
+	drm_property_destroy(dev, *prop);
+	*prop = NULL;
+}
+
+void drm_mode_destroy_properties(struct drm_device *dev)
+{
+	struct drm_mode_config *config = &dev->mode_config;
+
+	drm_property_destroy_null(dev, &config->cursor_h_prop);
+	drm_property_destroy_null(dev, &config->cursor_w_prop);
+	drm_property_destroy_null(dev, &config->cursor_y_prop);
+	drm_property_destroy_null(dev, &config->cursor_x_prop);
+	drm_property_destroy_null(dev, &config->cursor_id_prop);
+
+	drm_property_destroy_null(dev, &config->connector_ids_prop);
+	drm_property_destroy_null(dev, &config->mode_prop);
+
+	drm_property_destroy_null(dev, &config->crtc_id_prop);
+	drm_property_destroy_null(dev, &config->fb_id_prop);
+
+	drm_property_destroy_null(dev, &config->crtc_h_prop);
+	drm_property_destroy_null(dev, &config->crtc_w_prop);
+	drm_property_destroy_null(dev, &config->crtc_y_prop);
+	drm_property_destroy_null(dev, &config->crtc_x_prop);
+
+	drm_property_destroy_null(dev, &config->src_h_prop);
+	drm_property_destroy_null(dev, &config->src_w_prop);
+	drm_property_destroy_null(dev, &config->src_y_prop);
+	drm_property_destroy_null(dev, &config->src_x_prop);
+}
+EXPORT_SYMBOL(drm_mode_destroy_properties);
+
+int drm_mode_create_properties(struct drm_device *dev)
+{
+	struct drm_mode_config *config = &dev->mode_config;
+
+	config->src_x_prop = drm_property_create_range(dev, 0, "SRC_X", 0, UINT_MAX);
+	if (!config->src_x_prop)
+		goto out;
+	config->src_y_prop = drm_property_create_range(dev, 0, "SRC_Y", 0, UINT_MAX);
+	if (!config->src_y_prop)
+		goto out;
+	config->src_w_prop = drm_property_create_range(dev, 0, "SRC_W", 0, UINT_MAX);
+	if (!config->src_w_prop)
+		goto out;
+	config->src_h_prop = drm_property_create_range(dev, 0, "SRC_H", 0, UINT_MAX);
+	if (!config->src_h_prop)
+		goto out;
+
+	config->crtc_x_prop = drm_property_create_range(dev, 0, "CRTC_X", INT_MIN, INT_MAX);
+	if (!config->crtc_x_prop)
+		goto out;
+	config->crtc_y_prop = drm_property_create_range(dev, 0, "CRTC_Y", INT_MIN, INT_MAX);
+	if (!config->crtc_y_prop)
+		goto out;
+	config->crtc_w_prop = drm_property_create_range(dev, 0, "CRTC_W", 0, UINT_MAX);
+	if (!config->crtc_w_prop)
+		goto out;
+	config->crtc_h_prop = drm_property_create_range(dev, 0, "CRTC_H", 0, UINT_MAX);
+	if (!config->crtc_h_prop)
+		goto out;
+
+	config->fb_id_prop = drm_property_create_range(dev, 0, "FB_ID", 0, UINT_MAX);
+	if (!config->fb_id_prop)
+		goto out;
+	config->crtc_id_prop = drm_property_create_range(dev, 0, "CRTC_ID", 0, UINT_MAX);
+	if (!config->crtc_id_prop)
+		goto out;
+
+	config->cursor_id_prop = drm_property_create_range(dev, 0, "CURSOR_ID", 0, UINT_MAX);
+	if (!config->cursor_id_prop)
+		goto out;
+	config->cursor_x_prop = drm_property_create_range(dev, 0, "CURSOR_X", INT_MIN, INT_MAX);
+	if (!config->cursor_x_prop)
+		goto out;
+	config->cursor_y_prop = drm_property_create_range(dev, 0, "CURSOR_Y", INT_MIN, INT_MAX);
+	if (!config->cursor_y_prop)
+		goto out;
+	config->cursor_w_prop = drm_property_create_range(dev, 0, "CURSOR_W", 0, UINT_MAX);
+	if (!config->cursor_w_prop)
+		goto out;
+	config->cursor_h_prop = drm_property_create_range(dev, 0, "CURSOR_H", 0, UINT_MAX);
+	if (!config->cursor_h_prop)
+		goto out;
+
+	/* FIXME create special object ID list property type? */
+	config->connector_ids_prop = drm_property_create(dev, DRM_MODE_PROP_BLOB, "CONNECTOR_IDS", 0);
+	if (!config->connector_ids_prop)
+		goto out;
+
+	config->mode_prop = drm_property_create(dev, DRM_MODE_PROP_BLOB, "MODE", 0);
+	if (!config->mode_prop)
+		goto out;
+
+	return 0;
+
+ out:
+	drm_mode_destroy_properties(dev);
+
+	return -ENOMEM; /* FIXME? */
+}
+EXPORT_SYMBOL(drm_mode_create_properties);
+
+void drm_plane_attach_properties(struct drm_plane *plane)
+{
+	struct drm_mode_object *obj = &plane->base;
+	struct drm_mode_config *config = &plane->dev->mode_config;
+
+	drm_object_attach_property(obj, config->src_x_prop, 0);
+	drm_object_attach_property(obj, config->src_y_prop, 0);
+	drm_object_attach_property(obj, config->src_w_prop, 0);
+	drm_object_attach_property(obj, config->src_h_prop, 0);
+	drm_object_attach_property(obj, config->crtc_x_prop, 0);
+	drm_object_attach_property(obj, config->crtc_y_prop, 0);
+	drm_object_attach_property(obj, config->crtc_w_prop, 0);
+	drm_object_attach_property(obj, config->crtc_h_prop, 0);
+	drm_object_attach_property(obj, config->fb_id_prop, 0);
+	drm_object_attach_property(obj, config->crtc_id_prop, 0);
+}
+EXPORT_SYMBOL(drm_plane_attach_properties);
+
+void drm_crtc_attach_properties(struct drm_crtc *crtc)
+{
+	struct drm_mode_object *obj = &crtc->base;
+	struct drm_mode_config *config = &crtc->dev->mode_config;
+
+	drm_object_attach_property(obj, config->src_x_prop, 0);
+	drm_object_attach_property(obj, config->src_y_prop, 0);
+	drm_object_attach_property(obj, config->fb_id_prop, 0);
+	drm_object_attach_property(obj, config->mode_prop, 0);
+	drm_object_attach_property(obj, config->connector_ids_prop, 0);
+}
+EXPORT_SYMBOL(drm_crtc_attach_properties);
drivers/gpu/drm/i915/intel_atomic.c +0 -256

259 lines not on this page · raw message

drivers/gpu/drm/i915/intel_display.c +29 -0
index 321c840..451cc3d 100644
@@ -9372,3 +9372,32 @@ intel_display_print_error_state(struct seq_file *m,
 	}
 }
 #endif
+
+void intel_crtc_update_properties(struct drm_crtc *crtc)
+{
+	struct drm_mode_object *obj = &crtc->base;
+	struct drm_mode_config *config = &crtc->dev->mode_config;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+
+	drm_crtc_update_properties(crtc);
+
+	drm_object_property_set_value(obj, config->cursor_id_prop, intel_crtc->cursor_handle);
+	drm_object_property_set_value(obj, config->cursor_x_prop, intel_crtc->cursor_x);
+	drm_object_property_set_value(obj, config->cursor_y_prop, intel_crtc->cursor_y);
+	drm_object_property_set_value(obj, config->cursor_w_prop, intel_crtc->cursor_width);
+	drm_object_property_set_value(obj, config->cursor_h_prop, intel_crtc->cursor_height);
+}
+
+void intel_crtc_attach_properties(struct drm_crtc *crtc)
+{
+	struct drm_mode_object *obj = &crtc->base;
+	struct drm_mode_config *config = &crtc->dev->mode_config;
+
+	drm_crtc_attach_properties(crtc);
+
+	drm_object_attach_property(obj, config->cursor_id_prop, 0);
+	drm_object_attach_property(obj, config->cursor_x_prop, 0);
+	drm_object_attach_property(obj, config->cursor_y_prop, 0);
+	drm_object_attach_property(obj, config->cursor_w_prop, 0);
+	drm_object_attach_property(obj, config->cursor_h_prop, 0);
+}
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#50 lore raw

PATCH 50/81 drm/i915: Use intel_best_encoder() directly

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

All connectors use intel_best_encoder() as their best_encoder() func, so just call it directly w/o the indirection.

---
 drivers/gpu/drm/i915/intel_atomic.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +2 -8
index 6dd07fb..e58ec3f 100644
@@ -152,8 +152,6 @@ static int process_connectors(struct intel_crtc_state *s, const uint32_t *ids, i
 	int i;
 
 	for (i = 0; i < count_ids; i++) {
-		struct drm_encoder *encoder;
-		const struct drm_connector_helper_funcs *connector_funcs;
 		struct drm_mode_object *obj;
 		int j;
 
@@ -169,9 +167,8 @@ static int process_connectors(struct intel_crtc_state *s, const uint32_t *ids, i
 		}
 
 		connector = obj_to_connector(obj);
-		connector_funcs = connector->helper_private;
 
-		encoder = connector_funcs->best_encoder(connector);
+		encoder = intel_best_encoder(connector);
 
 		if (!drm_encoder_crtc_ok(encoder, crtc))
 			return -EINVAL;
@@ -180,9 +177,6 @@ static int process_connectors(struct intel_crtc_state *s, const uint32_t *ids, i
 	}
 
 	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
-		const struct drm_connector_helper_funcs *connector_funcs =
-			connector->helper_private;
-
 		for (i = 0; i < count_ids; i++) {
 			if (connector == connectors[i])
 				break;
@@ -196,7 +190,7 @@ static int process_connectors(struct intel_crtc_state *s, const uint32_t *ids, i
 			continue;
 		}
 
-		encoder = connector_funcs->best_encoder(connector);
+		encoder = intel_best_encoder(connector);
 
 		connector->encoder = encoder;
 		encoder->crtc = crtc;
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#51 lore raw

PATCH 51/81 drm/i915: Unstatic intel_modeset_update_staged_output_state()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

The atomic code needs intel_modeset_update_staged_output_state().

---
 drivers/gpu/drm/i915/intel_display.c |    2 +-
 drivers/gpu/drm/i915/intel_drv.h     |    2 ++
 2 files changed, 3 insertions(+), 1 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
index 451cc3d..c84a839 100644
@@ -7423,7 +7423,7 @@ static bool intel_encoder_crtc_ok(struct drm_encoder *encoder,
  * Updates the staged output configuration state, e.g. after we've read out the
  * current hw state.
  */
-static void intel_modeset_update_staged_output_state(struct drm_device *dev)
+void intel_modeset_update_staged_output_state(struct drm_device *dev)
 {
 	struct intel_encoder *encoder;
 	struct intel_connector *connector;
drivers/gpu/drm/i915/intel_drv.h +2 -0
index 1230c1b..24dc192 100644
@@ -737,4 +737,6 @@ extern void intel_disable_primary(struct drm_crtc *crtc);
 extern void intel_crtc_attach_properties(struct drm_crtc *crtc);
 extern void intel_crtc_update_properties(struct drm_crtc *crtc);
 
+extern void intel_modeset_update_staged_output_state(struct drm_device *dev);
+
 #endif /* __INTEL_DRV_H__ */
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#52 lore raw

PATCH 52/81 drm/i915: Update new_crtc and new_encoder fields after atomic modeset

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

The i915 modeset logic requires that these be kept in sync with the other crtc and encoder pointers.

---
 drivers/gpu/drm/i915/intel_atomic.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +2 -0
index e58ec3f..c5558cc 100644
@@ -1701,6 +1701,8 @@ static int intel_atomic_commit(struct drm_device *dev, void *state)
 
 	update_props(dev, s);
 
+	intel_modeset_update_staged_output_state(dev);
+
 	return 0;
 }
 
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#53 lore raw

PATCH 53/81 drm/i915: Update connector DPMS state after an atomic modeset

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Update the connector DPMS state after atomic modeset operations.

---
 drivers/gpu/drm/i915/intel_atomic.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +31 -0
index c5558cc..1fce359 100644
@@ -1475,6 +1475,36 @@ static void update_props(struct drm_device *dev,
 	}
 }
 
+/*
+ * FIXME
+ * Perhaps atomic modeset shouldn't actually change the DPMS state,
+ * unless explicitly asked to do so. That's the way we treat everything
+ * else, so it makes sense. Although the dpms property is already a bit
+ * special in the legacy codepaths, so maybe we should follow the same
+ * pattern. Ie. a modeset forces DPMS to on (which is what we do here).
+ */
+static void update_connector_dpms(struct drm_device *dev, struct drm_crtc *crtc)
+{
+	struct drm_connector *connector;
+
+	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
+		int dpms = connector->dpms;
+
+		if (connector->encoder && connector->encoder->crtc == crtc)
+			dpms = DRM_MODE_DPMS_ON;
+		else if (!connector->encoder || !connector->encoder->crtc)
+			dpms = DRM_MODE_DPMS_OFF;
+
+		if (connector->dpms == dpms)
+			continue;
+
+		connector->dpms = dpms;
+		drm_connector_property_set_value(connector,
+						 dev->mode_config.dpms_property,
+						 dpms);
+	}
+}
+
 static void update_crtc(struct drm_device *dev,
 			struct intel_atomic_state *s)
 {
@@ -1494,6 +1524,7 @@ static void update_crtc(struct drm_device *dev,
 		if (st->mode_dirty) {
 			drm_calc_timestamping_constants(crtc);
 			intel_crtc_update_sarea(crtc, crtc->enabled);
+			update_connector_dpms(dev, crtc);
 		}
 
 		if (st->fb_dirty)
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#54 lore raw

PATCH 54/81 drm/i915: Kill the pending_flip counter manipulations

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

The pending_flip counter is probably going to be remove entirely, along with i915_gem_execbuffer_wait_for_flips() so don't even try to use it.

---
 drivers/gpu/drm/i915/intel_atomic.c |   74 +----------------------------------
 1 files changed, 2 insertions(+), 72 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +2 -72
index 1fce359..ac7fe88 100644
@@ -1536,45 +1536,9 @@ static void atomic_pipe_commit(struct drm_device *dev,
 			       struct intel_atomic_state *state,
 			       int pipe);
 
-static int apply_nonblocking(struct drm_device *dev, struct intel_atomic_state *s)
+static void apply_nonblocking(struct drm_device *dev, struct intel_atomic_state *s)
 {
 	struct intel_crtc *intel_crtc;
-	int i;
-
-	for (i = 0; i < dev->mode_config.num_crtc; i++) {
-		struct intel_crtc_state *st = &s->crtc[i];
-		struct intel_crtc *intel_crtc = to_intel_crtc(st->crtc);
-		struct drm_i915_gem_object *obj;
-
-		if (!st->old.fb)
-			continue;
-
-		obj = to_intel_framebuffer(st->old.fb)->obj;
-
-		/* Only one bit per plane in pending_flips */
-		if (atomic_read(&obj->pending_flip) & (1 << intel_crtc->plane))
-			return -EBUSY;
-	}
-
-	for (i = 0; i < dev->mode_config.num_plane; i++) {
-		struct intel_plane_state *st = &s->plane[i];
-		struct intel_plane *intel_plane = to_intel_plane(st->plane);
-		struct drm_i915_gem_object *obj;
-
-		if (!st->old.fb)
-			continue;
-
-		obj = to_intel_framebuffer(st->old.fb)->obj;
-
-		if (!st->old.fb)
-			continue;
-
-		obj = to_intel_framebuffer(st->old.fb)->obj;
-
-		/* Only one bit per plane in pending_flips */
-		if (atomic_read(&obj->pending_flip) & (1 << (16 + intel_plane->pipe)))
-			return -EBUSY;
-	}
 
 	list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list, base.head)
 		atomic_pipe_commit(dev, s, intel_crtc->pipe);
@@ -1582,8 +1546,6 @@ static int apply_nonblocking(struct drm_device *dev, struct intel_atomic_state *
 	/* don't restore the old state in end() */
 	s->dirty = false;
 	s->restore_state = false;
-
-	return 0;
 }
 
 static int alloc_flip_data(struct drm_device *dev, struct intel_atomic_state *s)
@@ -1695,12 +1657,7 @@ static int intel_atomic_commit(struct drm_device *dev, void *state)
 
 	/* try to apply in a non blocking manner */
 	if (s->flags & DRM_MODE_ATOMIC_NONBLOCK) {
-		ret = apply_nonblocking(dev, s);
-		if (ret) {
-			unpin_cursors(dev, s);
-			unpin_fbs(dev, s);
-			return ret;
-		}
+		apply_nonblocking(dev, s);
 	} else {
 		/* apply in a blocking manner */
 		ret = apply_config(dev, s);
@@ -1823,7 +1780,6 @@ static void intel_flip_complete(struct drm_flip *flip)
 	struct intel_flip *intel_flip =
 		container_of(flip, struct intel_flip, base);
 	struct drm_device *dev = intel_flip->crtc->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_crtc *crtc = intel_flip->crtc;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	int pipe = intel_crtc->pipe;
@@ -1841,18 +1797,6 @@ static void intel_flip_complete(struct drm_flip *flip)
 
 	if (intel_flip->vblank_ref)
 		drm_vblank_put(dev, pipe);
-
-	/* Possibly allow rendering to old_bo again */
-	if (intel_flip->old_bo) {
-		if (intel_flip->plane) {
-			struct intel_plane *intel_plane = to_intel_plane(intel_flip->plane);
-			atomic_clear_mask(1 << (16 + intel_plane->pipe), &intel_flip->old_bo->pending_flip.counter);
-		} else
-			atomic_clear_mask(1 << intel_crtc->plane, &intel_flip->old_bo->pending_flip.counter);
-
-		if (atomic_read(&intel_flip->old_bo->pending_flip) == 0)
-			wake_up(&dev_priv->pending_flip_queue);
-	}
 }
 
 static void intel_flip_finish(struct drm_flip *flip)
@@ -2193,13 +2137,6 @@ static void atomic_pipe_commit(struct drm_device *dev,
 			mutex_lock(&dev->struct_mutex);
 			drm_gem_object_reference(&intel_flip->old_bo->base);
 			mutex_unlock(&dev->struct_mutex);
-
-			/*
-			 * Block clients from rendering to the new back buffer until
-			 * the flip occurs and the object is no longer visible.
-			 */
-			atomic_set_mask(1 << intel_crtc->plane,
-					&intel_flip->old_bo->pending_flip.counter);
 		}
 
 		list_add_tail(&intel_flip->base.list, &flips);
@@ -2244,13 +2181,6 @@ static void atomic_pipe_commit(struct drm_device *dev,
 			mutex_lock(&dev->struct_mutex);
 			drm_gem_object_reference(&intel_flip->old_bo->base);
 			mutex_unlock(&dev->struct_mutex);
-
-			/*
-			 * Block clients from rendering to the new back buffer until
-			 * the flip occurs and the object is no longer visible.
-			 */
-			atomic_set_mask(1 << (16 + intel_plane->pipe),
-					&intel_flip->old_bo->pending_flip.counter);
 		}
 
 		list_add_tail(&intel_flip->base.list, &flips);
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#55 lore raw

PATCH 55/81 drm/i915: Don't mark cursor as pinned, when we don't have a cursor bo

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Avoids a NULL pointer dereference if the atomic modeset fails.

---
 drivers/gpu/drm/i915/intel_atomic.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +2 -1
index ac7fe88..98af0ae 100644
@@ -726,7 +726,8 @@ static int pin_cursors(struct drm_device *dev,
 		if (ret)
 			goto unpin;
 
-		st->cursor_pinned = true;
+		if (intel_crtc->cursor_bo)
+			st->cursor_pinned = true;
 	}
 
 	return 0;
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#56 lore raw

PATCH 56/81 drm/i915: Fix sprite_scaling_enabled for multiple sprites

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

We have more than one sprite, so a boolean simply won't cut it. Turn sprite_scaling_enabled into a bitmask and track the state of sprite scaler for each sprite independently.

---
 drivers/gpu/drm/i915/i915_drv.h     |    2 +-
 drivers/gpu/drm/i915/intel_sprite.c |   11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 0bafe7f..6f865bf 100644
@@ -729,7 +729,7 @@ typedef struct drm_i915_private {
 
 	/* overlay */
 	struct intel_overlay *overlay;
-	bool sprite_scaling_enabled;
+	unsigned int sprite_scaling_enabled;
 
 	/* LVDS info */
 	int backlight_level;  /* restore backlight to this value */
drivers/gpu/drm/i915/intel_sprite.c +6 -5
index 693b265..ce3b950 100644
@@ -345,15 +345,16 @@ ivb_prepare_plane(struct drm_plane *plane)
 	 */
 	if (regs->scale & SPRITE_SCALE_ENABLE) {
 		if (!dev_priv->sprite_scaling_enabled) {
-			dev_priv->sprite_scaling_enabled = true;
+			dev_priv->sprite_scaling_enabled |= 1 << pipe;
 			intel_update_watermarks(dev);
 			intel_wait_for_vblank(dev, pipe);
 		}
 	} else {
-		if (dev_priv->sprite_scaling_enabled) {
-			dev_priv->sprite_scaling_enabled = false;
+		if (dev_priv->sprite_scaling_enabled & (1 << pipe)) {
+			dev_priv->sprite_scaling_enabled &= ~(1 << pipe);
 			/* potentially re-enable LP watermarks */
-			intel_update_watermarks(dev);
+			if (!dev_priv->sprite_scaling_enabled)
+				intel_update_watermarks(dev);
 		}
 	}
 }
@@ -389,7 +390,7 @@ ivb_disable_plane(struct drm_plane *plane)
 	ivb_commit_plane(plane);
 	POSTING_READ(SPRSURF(pipe));
 
-	dev_priv->sprite_scaling_enabled = false;
+	dev_priv->sprite_scaling_enabled &= ~(1 << pipe);
 	intel_update_watermarks(dev);
 }
 
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#57 lore raw

PATCH 57/81 drm/i915: Fix hiding the cursor with atomic ioctl

In reply to [email protected]

From: Ander Conselvan de Oliveira <[email protected]>

intel_crtc->cursor_visible is only changed on the commit phase, so the check for visibility was considering the previous state. Change this to intel_crtc->cursor_handle instead.

---
 drivers/gpu/drm/i915/intel_atomic.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +1 -1
index 98af0ae..c4cec40 100644
@@ -1304,7 +1304,7 @@ static int check_crtc(struct intel_crtc_state *s)
 		}
 	}
 
-	if (intel_crtc->cursor_visible &&
+	if (intel_crtc->cursor_handle &&
 	    (intel_crtc->cursor_width != 64 ||
 	     intel_crtc->cursor_height != 64)) {
 		return -EINVAL;
Signature · 1 line
1.7.8.6
#58 lore raw

PATCH 58/81 drm/i915: Fix plane src rectangle dirty check

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

---
 drivers/gpu/drm/i915/intel_atomic.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +3 -3
index c4cec40..bfc0563 100644
@@ -555,9 +555,9 @@ static void plane_compute_dirty(struct intel_atomic_state *s,
 		return;
 
 	if (plane->src_x != state->old.src_x ||
-	    plane->src_y != state->old.src_x ||
-	    plane->src_w != state->old.src_x ||
-	    plane->src_h != state->old.src_x ||
+	    plane->src_y != state->old.src_y ||
+	    plane->src_w != state->old.src_w ||
+	    plane->src_h != state->old.src_h ||
 	    plane->crtc_x != state->old.crtc_x ||
 	    plane->crtc_y != state->old.crtc_y ||
 	    plane->crtc_w != state->old.crtc_w ||
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#59 lore raw

PATCH 59/81 drm/i915: Send atomic completion events even if nothing changed

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

---
 drivers/gpu/drm/i915/intel_atomic.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +5 -3
index bfc0563..a119896 100644
@@ -1641,13 +1641,15 @@ static int intel_atomic_commit(struct drm_device *dev, void *state)
 	struct intel_atomic_state *s = state;
 	int ret;
 
-	if (!s->dirty)
-		return 0;
-
 	ret = alloc_flip_data(dev, s);
 	if (ret)
 		return ret;
 
+	if (!s->dirty) {
+		queue_remaining_events(dev, s);
+		return 0;
+	}
+
 	ret = pin_fbs(dev, s);
 	if (ret)
 		return ret;
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#60 lore raw

PATCH 60/81 drm/i915: Unpin old fbs only when appropriate

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Don't unpin the old fb after flips, unless a new fb was pinned, or we're disabling the plane/crtc.

---
 drivers/gpu/drm/i915/intel_atomic.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +6 -2
index a119896..b795cb2 100644
@@ -2133,8 +2133,10 @@ static void atomic_pipe_commit(struct drm_device *dev,
 			intel_flip->old_cursor_bo = st->old.cursor_bo;
 		}
 
-		if (st->old.fb) {
+		if (st->old.fb)
 			intel_flip->old_fb_id = st->old.fb->base.id;
+
+		if (st->fb_dirty && st->old.fb) {
 			intel_flip->old_bo = to_intel_framebuffer(st->old.fb)->obj;
 
 			mutex_lock(&dev->struct_mutex);
@@ -2177,8 +2179,10 @@ static void atomic_pipe_commit(struct drm_device *dev,
 
 		intel_plane->calc(plane, plane->fb, &st->coords);
 
-		if (st->old.fb) {
+		if (st->old.fb)
 			intel_flip->old_fb_id = st->old.fb->base.id;
+
+		if (st->dirty && st->old.fb) {
 			intel_flip->old_bo = to_intel_framebuffer(st->old.fb)->obj;
 
 			mutex_lock(&dev->struct_mutex);
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#61 lore raw

PATCH 61/81 drm/i915: Remove stale prototypes form atomic code

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

These function no longer exist.

---
 drivers/gpu/drm/i915/intel_atomic.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +0 -7
index b795cb2..7a7695b 100644
@@ -916,13 +916,6 @@ static void update_plane_obj(struct drm_device *dev,
 	}
 }
 
-/* FIXME need to refactor the sprite code some more */
-int intel_disable_plane_nopin(struct drm_plane *plane);
-int intel_commit_plane_nopin(struct drm_plane *plane,
-			     struct drm_crtc *crtc,
-			     struct drm_framebuffer *fb,
-			     const struct intel_plane_coords *coords);
-
 static struct drm_pending_atomic_event *alloc_event(struct drm_device *dev,
 						    struct drm_file *file_priv,
 						    uint64_t user_data)
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#62 lore raw

PATCH 62/81 drm/i915: Unstatic i915_gem_check_olr()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Atomic code might need i915_gem_check_olr().

---
 drivers/gpu/drm/i915/i915_drv.h |    1 +
 drivers/gpu/drm/i915/i915_gem.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 6f865bf..6bb8b3f 100644
@@ -1520,6 +1520,7 @@ void i915_gem_retire_requests(struct drm_device *dev);
 void i915_gem_retire_requests_ring(struct intel_ring_buffer *ring);
 int __must_check i915_gem_check_wedge(struct drm_i915_private *dev_priv,
 				      bool interruptible);
+int i915_gem_check_olr(struct intel_ring_buffer *ring, u32 seqno);
 
 void i915_gem_reset(struct drm_device *dev);
 void i915_gem_clflush_object(struct drm_i915_gem_object *obj);
drivers/gpu/drm/i915/i915_gem.c +1 -1
index 9530592..f2f63ba 100644
@@ -969,7 +969,7 @@ i915_gem_check_wedge(struct drm_i915_private *dev_priv,
  * Compare seqno against outstanding lazy request. Emit a request if they are
  * equal.
  */
-static int
+int
 i915_gem_check_olr(struct intel_ring_buffer *ring, u32 seqno)
 {
 	int ret;
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#63 lore raw

PATCH 63/81 drm/i915: Refactor atomic flip code

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Collect the part which takes care of issuing the flips to a new function. This makes the following patch nicer to look at.

---
 drivers/gpu/drm/i915/intel_atomic.c |   37 ++++++++++++++++++++--------------
 1 files changed, 22 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +22 -15
index 7a7695b..33357ec 100644
@@ -2075,15 +2075,35 @@ static void intel_flip_fini(struct drm_device *dev)
 	drm_flip_driver_fini(&dev_priv->flip_driver);
 }
 
+static void intel_atomic_schedule_flips(struct drm_i915_private *dev_priv,
+					struct intel_crtc *intel_crtc,
+					struct list_head *flips)
+{
+	if (!intel_crtc->active) {
+		drm_flip_driver_complete_flips(&dev_priv->flip_driver, flips);
+		return;
+	}
+
+	drm_flip_driver_prepare_flips(&dev_priv->flip_driver, flips);
+
+	local_irq_disable();
+
+	intel_pipe_vblank_evade(&intel_crtc->base);
+
+	drm_flip_driver_schedule_flips(&dev_priv->flip_driver, flips);
+
+	local_irq_enable();
+}
+
 static void atomic_pipe_commit(struct drm_device *dev,
 			       struct intel_atomic_state *state,
 			       int pipe)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_file_private *file_priv = state->file->driver_priv;
+	struct intel_crtc *intel_crtc = to_intel_crtc(intel_get_crtc_for_pipe(dev, pipe));
 	LIST_HEAD(flips);
 	int i;
-	bool pipe_enabled = to_intel_crtc(intel_get_crtc_for_pipe(dev, pipe))->active;
 
 	for (i = 0; i < dev->mode_config.num_crtc; i++) {
 		struct intel_crtc_state *st = &state->crtc[i];
@@ -2189,20 +2209,7 @@ static void atomic_pipe_commit(struct drm_device *dev,
 	if (list_empty(&flips))
 		return;
 
-	if (!pipe_enabled) {
-		drm_flip_driver_complete_flips(&dev_priv->flip_driver, &flips);
-		return;
-	}
-
-	drm_flip_driver_prepare_flips(&dev_priv->flip_driver, &flips);
-
-	local_irq_disable();
-
-	intel_pipe_vblank_evade(intel_get_crtc_for_pipe(dev, pipe));
-
-	drm_flip_driver_schedule_flips(&dev_priv->flip_driver, &flips);
-
-	local_irq_enable();
+	intel_atomic_schedule_flips(dev_priv, intel_crtc, &flips);
 }
 
 void intel_atomic_handle_vblank(struct drm_device *dev, int pipe)
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#64 lore raw

PATCH 64/81 drm/i915: Implement a non-blocking GPU synchronization mechanism for atomic page flips

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

After the atomic flip has been split up into individual flip requests for each scanout engine, put each such request into a FIFO. Then for each flip request add new request to the ring(s) in order to get an interrupt once the GPU has finished whatever it was doing with the new front buffer. Once the flip requests associated with the same atomic flip and the same pipe at the head of the queue are ready, pull them from the queue and issue the flips to the hardware.

---
 drivers/gpu/drm/i915/i915_drv.h     |    8 ++
 drivers/gpu/drm/i915/i915_irq.c     |    2 +
 drivers/gpu/drm/i915/intel_atomic.c |  215 ++++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_drv.h    |    1 +
 4 files changed, 222 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +8 -0
index 6bb8b3f..80b4b30 100644
@@ -960,6 +960,14 @@ typedef struct drm_i915_private {
 	struct i915_dri1_state dri1;
 
 	struct drm_flip_driver flip_driver;
+
+	struct {
+		struct list_head list;
+		spinlock_t lock;
+		struct work_struct work;
+		struct workqueue_struct *wq;
+		unsigned int next_flip_seq;
+	} flip;
 } drm_i915_private_t;
 
 /* Iterate over initialised rings */
drivers/gpu/drm/i915/i915_irq.c +2 -0
index 430f201..2f0dce2 100644
@@ -349,6 +349,8 @@ static void notify_ring(struct drm_device *dev,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	intel_atomic_notify_ring(dev, ring);
+
 	if (ring->obj == NULL)
 		return;
 
drivers/gpu/drm/i915/intel_atomic.c +211 -4

307 lines not on this page · raw message

drivers/gpu/drm/i915/intel_drv.h +1 -0
index 24dc192..446fa1c 100644
@@ -730,6 +730,7 @@ extern void intel_atomic_fini(struct drm_device *dev);
 extern void intel_atomic_free_events(struct drm_device *dev, struct drm_file *file);
 extern void intel_atomic_handle_vblank(struct drm_device *dev, int pipe);
 extern void intel_atomic_clear_flips(struct drm_crtc *crtc);
+extern void intel_atomic_notify_ring(struct drm_device *dev, struct intel_ring_buffer *ring);
 
 extern void intel_enable_primary(struct drm_crtc *crtc);
 extern void intel_disable_primary(struct drm_crtc *crtc);
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#65 lore raw

PATCH 65/81 drm/i915: Release all atomic flips when GPU hangs

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

If the GPU hangs, release all pending atomic flips from the queue.

---
 drivers/gpu/drm/i915/i915_irq.c     |    1 +
 drivers/gpu/drm/i915/intel_atomic.c |   29 +++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h    |    1 +
 3 files changed, 31 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +1 -0
index 2f0dce2..47d6067 100644
@@ -1486,6 +1486,7 @@ void i915_handle_error(struct drm_device *dev, bool wedged)
 		 */
 		for_each_ring(ring, dev_priv, i)
 			wake_up_all(&ring->irq_queue);
+		intel_atomic_wedged(dev);
 	}
 
 	queue_work(dev_priv->wq, &dev_priv->error_work);
drivers/gpu/drm/i915/intel_atomic.c +29 -0
index 2ebceec..f59be7f 100644
@@ -2232,6 +2232,30 @@ void intel_atomic_notify_ring(struct drm_device *dev,
 	spin_unlock_irqrestore(&dev_priv->flip.lock, flags);
 }
 
+void intel_atomic_wedged(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_flip *intel_flip;
+	unsigned long flags;
+
+	spin_lock_irqsave(&dev_priv->flip.lock, flags);
+
+	list_for_each_entry(intel_flip, &dev_priv->flip.list, base.list) {
+		struct intel_ring_buffer *ring = intel_flip->ring;
+
+		if (ring) {
+			intel_flip->ring = NULL;
+			ring->irq_put(ring);
+		}
+	}
+
+	/* all flips are "ready" so no need to check with intel_atomic_flips_ready() */
+	if (!list_empty(&dev_priv->flip.list))
+		queue_work(dev_priv->flip.wq, &dev_priv->flip.work);
+
+	spin_unlock_irqrestore(&dev_priv->flip.lock, flags);
+}
+
 static void atomic_pipe_commit(struct drm_device *dev,
 			       struct intel_atomic_state *state,
 			       int pipe)
@@ -2409,6 +2433,11 @@ static void atomic_pipe_commit(struct drm_device *dev,
 	if (rings_mask == 0)
 		return;
 
+	if (atomic_read(&dev_priv->mm.wedged)) {
+		intel_atomic_wedged(dev);
+		return;
+	}
+
 	/*
 	 * Double check to catch cases where the irq
 	 * fired before the flip was placed onto flip.list.
drivers/gpu/drm/i915/intel_drv.h +1 -0
index 446fa1c..33fac47 100644
@@ -731,6 +731,7 @@ extern void intel_atomic_free_events(struct drm_device *dev, struct drm_file *fi
 extern void intel_atomic_handle_vblank(struct drm_device *dev, int pipe);
 extern void intel_atomic_clear_flips(struct drm_crtc *crtc);
 extern void intel_atomic_notify_ring(struct drm_device *dev, struct intel_ring_buffer *ring);
+extern void intel_atomic_wedged(struct drm_device *dev);
 
 extern void intel_enable_primary(struct drm_crtc *crtc);
 extern void intel_disable_primary(struct drm_crtc *crtc);
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#66 lore raw

PATCH 66/81 drm/i915: Make a copy of the calculated plane regs

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

The register values are computed when the flip ioctl is issued, and they're used only after we've waited for the GPU to finish rendering. The computed values are store in the intel_crtc and intel_plane structs, so issuing another flip before the previous one has been fully completed would clobber those stored registers. Fix the problem by making a copy of the calculated register values inside the intel_flip structure. The copy is then used when it's time to commit the registers to the hardware.

---
 drivers/gpu/drm/i915/i915_drv.h      |    4 +++-
 drivers/gpu/drm/i915/intel_atomic.c  |    8 ++++++--
 drivers/gpu/drm/i915/intel_display.c |   14 ++++++++------
 drivers/gpu/drm/i915/intel_drv.h     |    2 +-
 drivers/gpu/drm/i915/intel_sprite.c  |   24 ++++++++++++------------
 5 files changed, 30 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -1
index 80b4b30..d8e8a4f 100644
@@ -269,6 +269,8 @@ struct drm_i915_error_state {
 	struct intel_display_error_state *display;
 };
 
+struct intel_plane_regs;
+
 struct drm_i915_display_funcs {
 	bool (*fbc_enabled)(struct drm_device *dev);
 	void (*enable_fbc)(struct drm_crtc *crtc, unsigned long interval);
@@ -300,7 +302,7 @@ struct drm_i915_display_funcs {
 			    int x, int y);
 	int (*calc_plane)(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			  int x, int y);
-	void (*commit_plane)(struct drm_crtc *crtc);
+	void (*commit_plane)(struct drm_crtc *crtc, const struct intel_plane_regs *regs);
 	/* clock updates for mode set */
 	/* cursor updates */
 	/* render clock increase/decrease */
drivers/gpu/drm/i915/intel_atomic.c +6 -2
index f59be7f..e52d92a 100644
@@ -47,6 +47,8 @@ struct intel_flip {
 	struct intel_ring_buffer *ring;
 	u32 seqno;
 	unsigned int flip_seq;
+	/* FIXME need cursor regs too */
+	struct intel_plane_regs regs;
 };
 
 struct intel_plane_state {
@@ -1986,11 +1988,11 @@ static bool intel_flip_flip(struct drm_flip *flip,
 		struct drm_plane *plane = intel_flip->plane;
 		struct intel_plane *intel_plane = to_intel_plane(plane);
 
-		intel_plane->commit(plane);
+		intel_plane->commit(plane, &intel_flip->regs);
 	} else {
 		struct drm_i915_private *dev_priv = dev->dev_private;
 
-		dev_priv->display.commit_plane(crtc);
+		dev_priv->display.commit_plane(crtc, &intel_flip->regs);
 	}
 
 	if (intel_flip->has_cursor)
@@ -2321,6 +2323,7 @@ static void atomic_pipe_commit(struct drm_device *dev,
 		/* should already be checked so can't fail */
 		/* FIXME refactor the failing parts? */
 		dev_priv->display.calc_plane(crtc, crtc->fb, crtc->x, crtc->y);
+		intel_flip->regs = intel_crtc->primary_regs;
 
 		if (st->cursor_dirty) {
 			intel_flip->has_cursor = true;
@@ -2387,6 +2390,7 @@ static void atomic_pipe_commit(struct drm_device *dev,
 		}
 
 		intel_plane->calc(plane, plane->fb, &st->coords);
+		intel_flip->regs = intel_plane->regs;
 
 		if (st->old.fb)
 			intel_flip->old_fb_id = st->old.fb->base.id;
drivers/gpu/drm/i915/intel_display.c +8 -6
index c84a839..390251d 100644
@@ -1979,13 +1979,13 @@ unsigned long intel_gen4_compute_offset_xtiled(int *x, int *y,
 	return tile_rows * pitch * 8 + tiles * 4096;
 }
 
-static void intel_commit_plane(struct drm_crtc *crtc)
+static void intel_commit_plane(struct drm_crtc *crtc,
+			       const struct intel_plane_regs *regs)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	int plane = intel_crtc->plane;
-	const struct intel_plane_regs *regs = &intel_crtc->primary_regs;
 
 	I915_WRITE(DSPCNTR(plane), regs->cntr);
 	I915_WRITE(DSPSTRIDE(plane), regs->stride);
@@ -2102,15 +2102,16 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			     int x, int y)
 {
 	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	int ret;
 
 	ret = i9xx_calc_plane(crtc, fb, x, y);
 	if (ret)
 		return ret;
 
-	intel_commit_plane(crtc);
+	intel_commit_plane(crtc, &intel_crtc->primary_regs);
 
-	POSTING_READ(DSPCNTR(to_intel_crtc(crtc)->plane));
+	POSTING_READ(DSPCNTR(intel_crtc->plane));
 
 	return 0;
 }
@@ -2206,15 +2207,16 @@ static int ironlake_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *
 				 int x, int y)
 {
 	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	int ret;
 
 	ret = ironlake_calc_plane(crtc, fb, x, y);
 	if (ret)
 		return ret;
 
-	intel_commit_plane(crtc);
+	intel_commit_plane(crtc, &intel_crtc->primary_regs);
 
-	POSTING_READ(DSPCNTR(to_intel_crtc(crtc)->plane));
+	POSTING_READ(DSPCNTR(intel_crtc->plane));
 
 	return 0;
 }
drivers/gpu/drm/i915/intel_drv.h +1 -1
index 33fac47..e39a10b 100644
@@ -277,7 +277,7 @@ struct intel_plane {
 	void (*calc)(struct drm_plane *plane, struct drm_framebuffer *fb,
 		     const struct intel_plane_coords *clip);
 	void (*prepare)(struct drm_plane *plane);
-	void (*commit)(struct drm_plane *plane);
+	void (*commit)(struct drm_plane *plane, const struct intel_plane_regs *regs);
 	struct intel_plane_regs regs;
 	struct drm_flip_helper flip_helper;
 };
drivers/gpu/drm/i915/intel_sprite.c +12 -12
index ce3b950..d960e19 100644
@@ -300,13 +300,13 @@ ivb_calc_plane(struct drm_plane *plane,
 }
 
 static void
-ivb_commit_plane(struct drm_plane *plane)
+ivb_commit_plane(struct drm_plane *plane,
+		 const struct intel_plane_regs *regs)
 {
 	struct drm_device *dev = plane->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_plane *intel_plane = to_intel_plane(plane);
 	int pipe = intel_plane->pipe;
-	const struct intel_plane_regs *regs = &intel_plane->regs;
 
 	I915_WRITE(SPRKEYVAL(pipe), regs->keyval);
 	I915_WRITE(SPRKEYMAX(pipe), regs->keymaxval);
@@ -371,7 +371,7 @@ ivb_update_plane(struct drm_plane *plane,
 
 	ivb_calc_plane(plane, fb, coords);
 	ivb_prepare_plane(plane);
-	ivb_commit_plane(plane);
+	ivb_commit_plane(plane, &intel_plane->regs);
 	POSTING_READ(SPRSURF(pipe));
 }
 
@@ -387,7 +387,7 @@ ivb_disable_plane(struct drm_plane *plane)
 	regs->cntr &= ~SPRITE_ENABLE;
 	/* Can't leave the scaler enabled... */
 	regs->scale = 0;
-	ivb_commit_plane(plane);
+	ivb_commit_plane(plane, regs);
 	POSTING_READ(SPRSURF(pipe));
 
 	dev_priv->sprite_scaling_enabled &= ~(1 << pipe);
@@ -413,7 +413,7 @@ ivb_update_colorkey(struct drm_plane *plane,
 	else if (key->flags & I915_SET_COLORKEY_SOURCE)
 		regs->cntr |= SPRITE_SOURCE_KEY;
 
-	ivb_commit_plane(plane);
+	ivb_commit_plane(plane, regs);
 	POSTING_READ(SPRKEYMSK(intel_plane->pipe));
 
 	return 0;
@@ -546,13 +546,13 @@ ilk_prepare_plane(struct drm_plane *plane)
 }
 
 static void
-ilk_commit_plane(struct drm_plane *plane)
+ilk_commit_plane(struct drm_plane *plane,
+		 const struct intel_plane_regs *regs)
 {
 	struct drm_device *dev = plane->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_plane *intel_plane = to_intel_plane(plane);
 	int pipe = intel_plane->pipe;
-	const struct intel_plane_regs *regs = &intel_plane->regs;
 
 	I915_WRITE(DVSKEYVAL(pipe), regs->keyval);
 	I915_WRITE(DVSKEYMAX(pipe), regs->keymaxval);
@@ -579,7 +579,7 @@ ilk_update_plane(struct drm_plane *plane,
 
 	ilk_calc_plane(plane, fb, coords);
 	ilk_prepare_plane(plane);
-	ilk_commit_plane(plane);
+	ilk_commit_plane(plane, &intel_plane->regs);
 	POSTING_READ(DVSSURF(pipe));
 }
 
@@ -595,7 +595,7 @@ ilk_disable_plane(struct drm_plane *plane)
 	regs->cntr &= ~DVS_ENABLE;
 	/* Disable the scaler */
 	regs->scale = 0;
-	ilk_commit_plane(plane);
+	ilk_commit_plane(plane, regs);
 	POSTING_READ(DVSSURF(pipe));
 }
 
@@ -627,7 +627,7 @@ intel_enable_primary(struct drm_crtc *crtc)
 	intel_update_fbc(dev);
 
 	regs->cntr = I915_READ(reg) | DISPLAY_PLANE_ENABLE;
-	dev_priv->display.commit_plane(crtc);
+	dev_priv->display.commit_plane(crtc, regs);
 }
 
 void
@@ -643,7 +643,7 @@ intel_disable_primary(struct drm_crtc *crtc)
 		return;
 
 	regs->cntr = I915_READ(reg) & ~DISPLAY_PLANE_ENABLE;
-	dev_priv->display.commit_plane(crtc);
+	dev_priv->display.commit_plane(crtc, regs);
 
 	intel_crtc->primary_disabled = true;
 	intel_update_fbc(dev);
@@ -668,7 +668,7 @@ ilk_update_colorkey(struct drm_plane *plane,
 	else if (key->flags & I915_SET_COLORKEY_SOURCE)
 		regs->cntr |= DVS_SOURCE_KEY;
 
-	ilk_commit_plane(plane);
+	ilk_commit_plane(plane, regs);
 	POSTING_READ(DVSKEYMSK(intel_plane->pipe));
 
 	return 0;
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#67 lore raw

PATCH 67/81 drm/i915: Clear pending flips in haswell_crtc_disable()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

---
 drivers/gpu/drm/i915/intel_display.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -0
index 390251d..2f518be 100644
@@ -3486,6 +3486,7 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc)
 		encoder->disable(encoder);
 
 	intel_crtc_wait_for_pending_flips(crtc);
+	intel_atomic_clear_flips(crtc);
 	drm_vblank_off(dev, pipe);
 	intel_crtc_update_cursor(crtc, false);
 
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#68 lore raw

PATCH 68/81 drm/i915: Drop all flips waiting for the GPU when the CRTC is about to be disabled

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

---
 drivers/gpu/drm/i915/intel_atomic.c |   36 +++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +36 -0
index e52d92a..36446d1 100644
@@ -2471,9 +2471,23 @@ void intel_atomic_handle_vblank(struct drm_device *dev, int pipe)
 void intel_atomic_clear_flips(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_plane *intel_plane;
+	struct intel_flip *intel_flip, *next;
 	int pipe = intel_crtc->pipe;
+	unsigned long flags;
+	LIST_HEAD(flips);
+
+	/*
+	 * If there are flips still waiting for the GPU, remove them
+	 * from the list, so that they won't be able to move over to
+	 * drm_flip_helpers' possession after we've called
+	 * drm_flip_helper_clear().
+	 */
+	spin_lock_irqsave(&dev_priv->flip.lock, flags);
+	list_cut_position(&flips, &dev_priv->flip.list, dev_priv->flip.list.prev);
+	spin_unlock_irqrestore(&dev_priv->flip.lock, flags);
 
 	drm_flip_helper_clear(&intel_crtc->flip_helper);
 
@@ -2481,4 +2495,26 @@ void intel_atomic_clear_flips(struct drm_crtc *crtc)
 		if (intel_plane->pipe == pipe)
 			drm_flip_helper_clear(&intel_plane->flip_helper);
 	}
+
+	/*
+	 * Drop all non-ready flips. Doing this after calling
+	 * drm_flip_helper_clear() maintaines the correct order
+	 * of completion events.
+	 */
+	list_for_each_entry_safe(intel_flip, next, &flips, base.list) {
+		struct intel_ring_buffer *ring = intel_flip->ring;
+
+		if (ring) {
+			intel_flip->ring = NULL;
+			ring->irq_put(ring);
+		}
+
+		intel_flip_complete(&intel_flip->base);
+		/*
+		 * FIXME drm_flip_helper calls the following functions
+		 * from a workqueue. Perhaps we should do the same here?
+		 */
+		intel_flip_finish(&intel_flip->base);
+		intel_flip_cleanup(&intel_flip->base);
+	}
 }
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#69 lore raw

PATCH 69/81 drm/i915: Refactor flip preaparation

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Most of the code for preparing the 'struct intel_flip' instances was identical betwen the CRTC and plane codepaths. Refactor the common parts into a single function.

---
 drivers/gpu/drm/i915/intel_atomic.c |  122 +++++++++++++++--------------------
 1 files changed, 52 insertions(+), 70 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +52 -70
index 36446d1..3717e89 100644
@@ -2258,6 +2258,50 @@ void intel_atomic_wedged(struct drm_device *dev)
 	spin_unlock_irqrestore(&dev_priv->flip.lock, flags);
 }
 
+static void intel_atomic_flip_init(struct intel_flip *intel_flip,
+				   struct drm_device *dev,
+				   u32 flip_seq,
+				   struct drm_i915_file_private *file_priv,
+				   struct drm_pending_atomic_event *event,
+				   struct drm_framebuffer *fb,
+				   bool unpin_old_fb, struct drm_framebuffer *old_fb)
+{
+	intel_flip->flip_seq = flip_seq;
+
+	if (event) {
+		intel_flip->event = event;
+
+		/* need to keep track of it in case process exits */
+		spin_lock_irq(&dev->event_lock);
+		list_add_tail(&intel_flip->pending_head, &file_priv->pending_flips);
+		spin_unlock_irq(&dev->event_lock);
+	}
+
+	if (fb) {
+		struct drm_i915_gem_object *obj = to_intel_framebuffer(fb)->obj;
+
+		mutex_lock(&dev->struct_mutex);
+#ifdef USE_WRITE_SEQNO
+		intel_flip->seqno = obj->last_write_seqno;
+#else
+		intel_flip->seqno = obj->last_read_seqno;
+#endif
+		intel_flip->ring = obj->ring;
+		mutex_unlock(&dev->struct_mutex);
+	}
+
+	if (old_fb)
+		intel_flip->old_fb_id = old_fb->base.id;
+
+	if (unpin_old_fb && old_fb) {
+		intel_flip->old_bo = to_intel_framebuffer(old_fb)->obj;
+
+		mutex_lock(&dev->struct_mutex);
+		drm_gem_object_reference(&intel_flip->old_bo->base);
+		mutex_unlock(&dev->struct_mutex);
+	}
+}
+
 static void atomic_pipe_commit(struct drm_device *dev,
 			       struct intel_atomic_state *state,
 			       int pipe)
@@ -2290,33 +2334,13 @@ static void atomic_pipe_commit(struct drm_device *dev,
 
 		drm_flip_init(&intel_flip->base, &intel_crtc->flip_helper);
 
-		intel_flip->flip_seq = flip_seq;
-
-		if (st->event) {
-			intel_flip->event = st->event;
-			st->event = NULL;
-			/* need to keep track of it in case process exits */
-			spin_lock_irq(&dev->event_lock);
-			list_add_tail(&intel_flip->pending_head,
-				      &file_priv->pending_flips);
-			spin_unlock_irq(&dev->event_lock);
-		}
+		intel_atomic_flip_init(intel_flip, dev, flip_seq,
+				       file_priv, st->event, crtc->fb,
+				       st->fb_dirty, st->old.fb);
+		st->event = NULL;
 
 		intel_flip->crtc = crtc;
 
-		if (crtc->fb) {
-			struct drm_i915_gem_object *obj = to_intel_framebuffer(crtc->fb)->obj;
-
-			mutex_lock(&dev->struct_mutex);
-#ifdef USE_WRITE_SEQNO
-			intel_flip->seqno = obj->last_write_seqno;
-#else
-			intel_flip->seqno = obj->last_read_seqno;
-#endif
-			intel_flip->ring = obj->ring;
-			mutex_unlock(&dev->struct_mutex);
-		}
-
 		/* update primary_disabled befoer calc_plane() */
 		intel_crtc->primary_disabled = st->primary_disabled;
 
@@ -2330,17 +2354,6 @@ static void atomic_pipe_commit(struct drm_device *dev,
 			intel_flip->old_cursor_bo = st->old.cursor_bo;
 		}
 
-		if (st->old.fb)
-			intel_flip->old_fb_id = st->old.fb->base.id;
-
-		if (st->fb_dirty && st->old.fb) {
-			intel_flip->old_bo = to_intel_framebuffer(st->old.fb)->obj;
-
-			mutex_lock(&dev->struct_mutex);
-			drm_gem_object_reference(&intel_flip->old_bo->base);
-			mutex_unlock(&dev->struct_mutex);
-		}
-
 		list_add_tail(&intel_flip->base.list, &flips);
 	}
 
@@ -2361,48 +2374,17 @@ static void atomic_pipe_commit(struct drm_device *dev,
 
 		drm_flip_init(&intel_flip->base, &intel_plane->flip_helper);
 
-		intel_flip->flip_seq = flip_seq;
-
-		if (st->event) {
-			intel_flip->event = st->event;
-			st->event = NULL;
-			/* need to keep track of it in case process exits */
-			spin_lock_irq(&dev->event_lock);
-			list_add_tail(&intel_flip->pending_head,
-				      &file_priv->pending_flips);
-			spin_unlock_irq(&dev->event_lock);
-		}
+		intel_atomic_flip_init(intel_flip, dev, flip_seq,
+				       file_priv, st->event, plane->fb,
+				       st->dirty, st->old.fb);
+		st->event = NULL;
 
 		intel_flip->crtc = intel_get_crtc_for_pipe(dev, pipe);
 		intel_flip->plane = plane;
 
-		if (plane->fb) {
-			struct drm_i915_gem_object *obj = to_intel_framebuffer(plane->fb)->obj;
-
-			mutex_lock(&dev->struct_mutex);
-#ifdef USE_WRITE_SEQNO
-			intel_flip->seqno = obj->last_write_seqno;
-#else
-			intel_flip->seqno = obj->last_read_seqno;
-#endif
-			intel_flip->ring = obj->ring;
-			mutex_unlock(&dev->struct_mutex);
-		}
-
 		intel_plane->calc(plane, plane->fb, &st->coords);
 		intel_flip->regs = intel_plane->regs;
 
-		if (st->old.fb)
-			intel_flip->old_fb_id = st->old.fb->base.id;
-
-		if (st->dirty && st->old.fb) {
-			intel_flip->old_bo = to_intel_framebuffer(st->old.fb)->obj;
-
-			mutex_lock(&dev->struct_mutex);
-			drm_gem_object_reference(&intel_flip->old_bo->base);
-			mutex_unlock(&dev->struct_mutex);
-		}
-
 		list_add_tail(&intel_flip->base.list, &flips);
 	}
 
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#70 lore raw

PATCH 70/81 drm/i915: Unstatic intel_modeset_commit_output_state()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

The atomic code will want to call intel_modeset_commit_output_state() too.

---
 drivers/gpu/drm/i915/intel_display.c |    2 +-
 drivers/gpu/drm/i915/intel_drv.h     |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
index 2f518be..d950939 100644
@@ -7449,7 +7449,7 @@ void intel_modeset_update_staged_output_state(struct drm_device *dev)
  *
  * This function copies the stage display pipe configuration to the real one.
  */
-static void intel_modeset_commit_output_state(struct drm_device *dev)
+void intel_modeset_commit_output_state(struct drm_device *dev)
 {
 	struct intel_encoder *encoder;
 	struct intel_connector *connector;
drivers/gpu/drm/i915/intel_drv.h +1 -0
index e39a10b..d0666d8 100644
@@ -740,5 +740,6 @@ extern void intel_crtc_attach_properties(struct drm_crtc *crtc);
 extern void intel_crtc_update_properties(struct drm_crtc *crtc);
 
 extern void intel_modeset_update_staged_output_state(struct drm_device *dev);
+extern void intel_modeset_commit_output_state(struct drm_device *dev);
 
 #endif /* __INTEL_DRV_H__ */
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#71 lore raw

PATCH 71/81 drm/i915: Eliminate swap_old_new() hack in the atomic code

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Use the new_crtc and new_encoder pointes inside the intel_encoder and intel_connector structures instead of swapping the crtc and encoder pointers in the drm base structures around the disable calls.

---
 drivers/gpu/drm/i915/intel_atomic.c |  115 ++++++++++++++--------------------
 1 files changed, 47 insertions(+), 68 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +47 -68
index 3717e89..3f093d6 100644
@@ -115,43 +115,57 @@ struct intel_atomic_state {
 	struct drm_encoder *saved_encoders;
 };
 
-static void update_connectors_bitmask(struct drm_crtc *crtc,
+static void update_connectors_bitmask(struct intel_crtc *intel_crtc,
 				      unsigned long *connectors_bitmask)
 {
-	struct drm_device *dev = crtc->dev;
-	struct drm_connector *connector;
+	struct drm_device *dev = intel_crtc->base.dev;
+	struct intel_connector *intel_connector;
 	unsigned int i = 0;
 
 	*connectors_bitmask = 0;
 
-	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
-		if (connector->encoder && connector->encoder->crtc == crtc)
+	list_for_each_entry(intel_connector, &dev->mode_config.connector_list, base.head) {
+		if (intel_connector->new_encoder &&
+		    intel_connector->new_encoder->new_crtc == intel_crtc)
 			__set_bit(i, connectors_bitmask);
 
 		i++;
 	}
 }
 
-static void update_encoders_bitmask(struct drm_crtc *crtc,
+static void update_encoders_bitmask(struct intel_crtc *intel_crtc,
 				    unsigned long *encoders_bitmask)
 {
-	struct drm_device *dev = crtc->dev;
-	struct drm_encoder *encoder;
+	struct drm_device *dev = intel_crtc->base.dev;
+	struct intel_encoder *intel_encoder;
 	unsigned int i = 0;
 
 	*encoders_bitmask = 0;
 
-	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
-		if (encoder->crtc == crtc)
+	list_for_each_entry(intel_encoder, &dev->mode_config.encoder_list, base.head) {
+		if (intel_encoder->new_crtc == intel_crtc)
 			__set_bit(i, encoders_bitmask);
 
 		i++;
 	}
 }
 
+static bool intel_encoder_in_use(struct intel_encoder *intel_encoder)
+{
+	struct drm_device *dev = intel_encoder->base.dev;
+	struct intel_connector *intel_connector;
+
+	list_for_each_entry(intel_connector, &dev->mode_config.connector_list, base.head)
+		if (intel_connector->new_encoder == intel_encoder)
+			return true;
+
+	return false;
+}
+
 static int process_connectors(struct intel_crtc_state *s, const uint32_t *ids, int count_ids)
 {
 	struct drm_crtc *crtc = s->crtc;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct drm_device *dev = crtc->dev;
 	struct drm_connector *connectors[count_ids];
 	struct drm_connector *connector;
@@ -184,6 +198,9 @@ static int process_connectors(struct intel_crtc_state *s, const uint32_t *ids, i
 	}
 
 	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
+		struct intel_connector *intel_connector = to_intel_connector(connector);
+		struct intel_encoder *intel_encoder;
+
 		for (i = 0; i < count_ids; i++) {
 			if (connector == connectors[i])
 				break;
@@ -192,25 +209,28 @@ static int process_connectors(struct intel_crtc_state *s, const uint32_t *ids, i
 		/* this connector isn't in the set */
 		if (i == count_ids) {
 			/* remove the link to the encoder if this crtc was set to drive it */
-			if (connector->encoder && connector->encoder->crtc == crtc)
-				connector->encoder = NULL;
+			if (intel_connector->new_encoder &&
+			    intel_connector->new_encoder->new_crtc == intel_crtc)
+				intel_connector->new_encoder = NULL;
 			continue;
 		}
 
-		encoder = intel_best_encoder(connector);
+		intel_encoder = to_intel_encoder(intel_best_encoder(connector));
 
-		connector->encoder = encoder;
-		encoder->crtc = crtc;
+		intel_connector->new_encoder = intel_encoder;
+		intel_encoder->new_crtc = intel_crtc;
 	}
 
 	/* prune dangling encoder->crtc links pointing to this crtc  */
 	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
-		if (encoder->crtc == crtc && !drm_helper_encoder_in_use(encoder))
-			encoder->crtc = NULL;
+		struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
+
+		if (intel_encoder->new_crtc == intel_crtc && !intel_encoder_in_use(intel_encoder))
+			intel_encoder->new_crtc = NULL;
 	}
 
-	update_connectors_bitmask(s->crtc, &s->connectors_bitmask);
-	update_encoders_bitmask(s->crtc, &s->encoders_bitmask);
+	update_connectors_bitmask(intel_crtc, &s->connectors_bitmask);
+	update_encoders_bitmask(intel_crtc, &s->encoders_bitmask);
 
 	return 0;
 }
@@ -232,19 +252,6 @@ static size_t intel_atomic_state_size(const struct drm_device *dev)
 		num_plane * sizeof state->saved_planes[0];
 }
 
-
-static void populate_old(struct drm_device *dev)
-{
-	struct drm_encoder *encoder;
-	struct drm_connector *connector;
-
-	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
-		encoder->old_crtc = encoder->crtc;
-
-	list_for_each_entry(connector, &dev->mode_config.connector_list, head)
-		connector->old_encoder = connector->encoder;
-}
-
 static void *intel_atomic_begin(struct drm_device *dev, struct drm_file *file,
 				uint32_t flags, uint64_t user_data)
 {
@@ -275,8 +282,6 @@ static void *intel_atomic_begin(struct drm_device *dev, struct drm_file *file,
 	state->saved_crtcs = (struct intel_crtc *)(state->saved_encoders + num_encoder);
 	state->saved_planes = (struct drm_plane *)(state->saved_crtcs + num_crtc);
 
-	populate_old(dev);
-
 	i = 0;
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
 		struct intel_crtc_state *s = &state->crtc[i++];
@@ -297,8 +302,8 @@ static void *intel_atomic_begin(struct drm_device *dev, struct drm_file *file,
 		s->old.x = crtc->x;
 		s->old.y = crtc->y;
 
-		update_connectors_bitmask(crtc, &s->connectors_bitmask);
-		update_encoders_bitmask(crtc, &s->encoders_bitmask);
+		update_connectors_bitmask(intel_crtc, &s->connectors_bitmask);
+		update_encoders_bitmask(intel_crtc, &s->encoders_bitmask);
 
 		s->old.connectors_bitmask = s->connectors_bitmask;
 		s->old.encoders_bitmask = s->encoders_bitmask;
@@ -1045,39 +1050,11 @@ static void queue_remaining_events(struct drm_device *dev, struct intel_atomic_s
 	}
 }
 
-static void swap_old_new(struct drm_device *dev,
-			 struct intel_atomic_state *s)
-{
-	struct drm_encoder *encoder;
-	struct drm_connector *connector;
-	int i;
-
-	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
-		swap(encoder->crtc, encoder->old_crtc);
-
-	list_for_each_entry(connector, &dev->mode_config.connector_list, head)
-		swap(connector->encoder, connector->old_encoder);
-
-	for (i = 0; i < dev->mode_config.num_crtc; i++) {
-		struct intel_crtc_state *st = &s->crtc[i];
-		struct drm_crtc *crtc = st->crtc;
-
-		swap(crtc->enabled, st->old.enabled);
-	}
-}
-
 static int apply_config(struct drm_device *dev,
 			struct intel_atomic_state *s)
 {
 	int i, ret;
 
-	/*
-	 * FIXME
-`	 * Hackish way to make crtc_disable() see the current
-	 * state (actually just some select pieces of it).
-	 */
-	swap_old_new(dev, s);
-
 	for (i = 0; i < dev->mode_config.num_crtc; i++) {
 		struct intel_crtc_state *st = &s->crtc[i];
 
@@ -1097,8 +1074,7 @@ static int apply_config(struct drm_device *dev,
 		crtc_prepare(st, st->crtc);
 	}
 
-	/* Undo the hack above. */
-	swap_old_new(dev, s);
+	intel_modeset_commit_output_state(dev);
 
 	for (i = 0; i < dev->mode_config.num_crtc; i++) {
 		struct intel_crtc_state *st = &s->crtc[i];
@@ -1204,6 +1180,9 @@ static void restore_state(struct drm_device *dev,
 	list_for_each_entry(plane, &dev->mode_config.plane_list, head)
 		*plane = s->saved_planes[i++];
 
+	/* must restore the new_crtc and new_encoder pointers as well */
+	intel_modeset_update_staged_output_state(dev);
+
 	/* FIXME props etc. */
 
 	/* was the hardware state clobbered? */
@@ -1318,8 +1297,9 @@ static int check_crtc(struct intel_crtc_state *s)
 
 	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
 		const struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private;
+		struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
 
-		if (encoder->crtc != crtc)
+		if (intel_encoder->new_crtc != intel_crtc)
 			continue;
 
 		if (!encoder_funcs->mode_fixup(encoder, &crtc->mode, &crtc->hwmode))
@@ -1693,7 +1673,6 @@ static int intel_atomic_commit(struct drm_device *dev, void *state)
 
 	update_props(dev, s);
 
-	intel_modeset_update_staged_output_state(dev);
 
 	return 0;
 }
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#72 lore raw

PATCH 72/81 drm: Drop old_crtc and old_encoder pointers

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

These are not needed anymore.

---
 include/drm/drm_crtc.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
include/drm/drm_crtc.h +0 -2
index c8cea87..da9abb6 100644
@@ -509,7 +509,6 @@ struct drm_encoder {
 	struct drm_crtc *crtc;
 	const struct drm_encoder_funcs *funcs;
 	void *helper_private;
-	struct drm_crtc *old_crtc;
 };
 
 enum drm_connector_force {
@@ -615,7 +614,6 @@ struct drm_connector {
 	int audio_latency[2];
 	int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */
 	unsigned bad_edid_counter;
-	struct drm_encoder *old_encoder;
 };
 
 /**
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#73 lore raw

PATCH 73/81 drm/i915: Use new_crtc when checking if CRTC is in use

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

The atomic check() hook is interested in the staged new configuration, so it must use the intel_encoder::new_crtc pointer when checking if a CRTC is in use or not.

---
 drivers/gpu/drm/i915/intel_atomic.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +14 -2
index 3f093d6..ec79354 100644
@@ -150,6 +150,18 @@ static void update_encoders_bitmask(struct intel_crtc *intel_crtc,
 	}
 }
 
+static bool intel_crtc_in_use(struct intel_crtc *intel_crtc)
+{
+	struct drm_device *dev = intel_crtc->base.dev;
+	struct intel_encoder *intel_encoder;
+
+	list_for_each_entry(intel_encoder, &dev->mode_config.encoder_list, base.head)
+		if (intel_encoder->new_crtc == intel_crtc)
+			return true;
+
+	return false;
+}
+
 static bool intel_encoder_in_use(struct intel_encoder *intel_encoder)
 {
 	struct drm_device *dev = intel_encoder->base.dev;
@@ -1246,12 +1258,12 @@ static int check_crtc(struct intel_crtc_state *s)
 	if (crtc->enabled) {
 		if (!fb)
 			return -EINVAL;
-		if (!drm_helper_crtc_in_use(crtc))
+		if (!intel_crtc_in_use(intel_crtc))
 			return -EINVAL;
 	} else {
 		if (fb)
 			return -EINVAL;
-		if (drm_helper_crtc_in_use(crtc))
+		if (intel_crtc_in_use(intel_crtc))
 			return -EINVAL;
 	}
 
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#74 lore raw

PATCH 74/81 drm/i915: Add some TODO items to the atomic code

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Add a comment that outlines some of the missign/incomplete parts of the atomic code.

---
 drivers/gpu/drm/i915/intel_atomic.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +15 -0
index ec79354..415cd72 100644
@@ -24,6 +24,21 @@
  * Ville Syrjälä <[email protected]>
  */
 
+/*
+ * TODO:
+ * - check crtc.enabled old vs. new state handling
+ * - generate a correct timestamp for override flips
+ * - send flip events at correct time when previous flip is pending,
+ *   and nothing changed in the later flip
+ * - flip_seq should be the same for all flips issued at the same time
+ * - make GPU reset handling robust
+ * - old style frame counter still has possible issues
+ * - move primary plane scanout handling into a drm_plane
+ * - cursor register handling needs work
+ * - should drm_plane be used for cursors too?
+ * - more refactoring and cleanups
+ */
+
 #include <drm/drmP.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_flip.h>
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#75 lore raw

PATCH 75/81 drm/i915: Drop some stale FIXMEs from the atomic code

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

---
 drivers/gpu/drm/i915/intel_atomic.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +0 -4
index 415cd72..efdaff3 100644
@@ -717,7 +717,6 @@ static void crtc_commit(struct drm_crtc *crtc)
 	dev_priv->display.crtc_enable(&intel_crtc->base);
 
 	/* FIXME need to check where this stuff is used really */
-	/* FIXME need to update DPMS state somewhere */
 	list_for_each_entry(intel_encoder, &dev->mode_config.encoder_list, base.head) {
 		if (intel_encoder->base.crtc == crtc)
 			intel_encoder->connectors_active = true;
@@ -1210,8 +1209,6 @@ static void restore_state(struct drm_device *dev,
 	/* must restore the new_crtc and new_encoder pointers as well */
 	intel_modeset_update_staged_output_state(dev);
 
-	/* FIXME props etc. */
-
 	/* was the hardware state clobbered? */
 	if (s->restore_hw)
 		apply_config(dev, s);
@@ -1523,7 +1520,6 @@ static void update_crtc(struct drm_device *dev,
 		struct intel_crtc_state *st = &s->crtc[i];
 		struct drm_crtc *crtc = st->crtc;
 
-		/* FIXME is this OK? */
 		if (st->fb_dirty && !st->mode_dirty) {
 			mutex_lock(&dev->struct_mutex);
 			intel_update_fbc(dev);
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#76 lore raw

PATCH 76/81 drm/i915: Add pin count trace point

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

A new trace point for tracking changes to gem object pin count.

---
 drivers/gpu/drm/i915/i915_gem.c   |    6 ++++++
 drivers/gpu/drm/i915/i915_trace.h |   19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +6 -0
index f2f63ba..d4b76d9 100644
@@ -3482,6 +3482,8 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj,
 	if (!obj->has_global_gtt_mapping && map_and_fenceable)
 		i915_gem_gtt_bind_object(obj, obj->cache_level);
 
+	trace_i915_gem_object_pin_count(obj, obj->pin_count, obj->pin_count + 1);
+
 	obj->pin_count++;
 	obj->pin_mappable |= map_and_fenceable;
 
@@ -3491,6 +3493,8 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj,
 void
 i915_gem_object_unpin(struct drm_i915_gem_object *obj)
 {
+	trace_i915_gem_object_pin_count(obj, obj->pin_count, obj->pin_count - 1);
+
 	BUG_ON(obj->pin_count == 0);
 	BUG_ON(obj->gtt_space == NULL);
 
@@ -3769,6 +3773,8 @@ void i915_gem_free_object(struct drm_gem_object *gem_obj)
 	if (obj->phys_obj)
 		i915_gem_detach_phys_object(dev, obj);
 
+	trace_i915_gem_object_pin_count(obj, obj->pin_count, 0);
+
 	obj->pin_count = 0;
 	if (WARN_ON(i915_gem_object_unbind(obj) == -ERESTARTSYS)) {
 		bool was_interruptible;
drivers/gpu/drm/i915/i915_trace.h +19 -0
index 3db4a68..44f8d40 100644
@@ -16,6 +16,25 @@
 
 /* object tracking */
 
+TRACE_EVENT(i915_gem_object_pin_count,
+	    TP_PROTO(struct drm_i915_gem_object *obj, u32 pin_count_pre, u32 pin_count_post),
+	    TP_ARGS(obj, pin_count_pre, pin_count_post),
+
+	    TP_STRUCT__entry(
+			     __field(struct drm_i915_gem_object *, obj)
+			     __field(u32, pin_count_pre)
+			     __field(u32, pin_count_post)
+			     ),
+
+	    TP_fast_assign(
+			   __entry->obj = obj;
+			   __entry->pin_count_pre = pin_count_pre;
+			   __entry->pin_count_post = pin_count_post;
+			   ),
+
+	    TP_printk("obj=%p, pin_count=%u->%u", __entry->obj, __entry->pin_count_pre, __entry->pin_count_post)
+);
+
 TRACE_EVENT(i915_gem_object_create,
 	    TP_PROTO(struct drm_i915_gem_object *obj),
 	    TP_ARGS(obj),
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#77 lore raw

PATCH 77/81 drm/i915: Add trace points for flip queue length

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

---
 drivers/gpu/drm/i915/i915_drv.h     |    1 +
 drivers/gpu/drm/i915/i915_trace.h   |   15 +++++++++++++++
 drivers/gpu/drm/i915/intel_atomic.c |    9 ++++++++-
 3 files changed, 24 insertions(+), 1 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index d8e8a4f..53998f41 100644
@@ -969,6 +969,7 @@ typedef struct drm_i915_private {
 		struct work_struct work;
 		struct workqueue_struct *wq;
 		unsigned int next_flip_seq;
+		unsigned int queue_len;
 	} flip;
 } drm_i915_private_t;
 
drivers/gpu/drm/i915/i915_trace.h +15 -0
index 44f8d40..f71e1b3 100644
@@ -16,6 +16,21 @@
 
 /* object tracking */
 
+TRACE_EVENT(i915_flip_queue_len,
+	    TP_PROTO(unsigned int queue_len),
+	    TP_ARGS(queue_len),
+
+	    TP_STRUCT__entry(
+			     __field(u32, queue_len)
+			     ),
+
+	    TP_fast_assign(
+			   __entry->queue_len = queue_len;
+			   ),
+
+	    TP_printk("queue_len=%u", __entry->queue_len)
+);
+
 TRACE_EVENT(i915_gem_object_pin_count,
 	    TP_PROTO(struct drm_i915_gem_object *obj, u32 pin_count_pre, u32 pin_count_post),
 	    TP_ARGS(obj, pin_count_pre, pin_count_post),
drivers/gpu/drm/i915/intel_atomic.c +8 -1
index efdaff3..ef5e352 100644
@@ -2179,9 +2179,12 @@ static void intel_atomic_process_flips_work(struct work_struct *work)
 				if (intel_flip->flip_seq != flip_seq)
 					break;
 				list_move_tail(&intel_flip->base.list, &flips);
+				dev_priv->flip.queue_len--;
 			}
 		}
 
+		trace_i915_flip_queue_len(dev_priv->flip.queue_len);
+
 		spin_unlock_irqrestore(&dev_priv->flip.lock, flags);
 
 		if (list_empty(&flips))
@@ -2407,8 +2410,12 @@ static void atomic_pipe_commit(struct drm_device *dev,
 
 	spin_lock_irqsave(&dev_priv->flip.lock, flags);
 
-	list_for_each_entry_safe(intel_flip, next, &flips, base.list)
+	list_for_each_entry_safe(intel_flip, next, &flips, base.list) {
 		list_move_tail(&intel_flip->base.list, &dev_priv->flip.list);
+		dev_priv->flip.queue_len++;
+	}
+
+	trace_i915_flip_queue_len(dev_priv->flip.queue_len);
 
 	/* if no rings are involved, we can avoid checking seqnos */
 	if (rings_mask == 0)
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#78 lore raw

PATCH 78/81 HACK: drm/i915: Make non-blocking GPU synchronization optional

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Add a module parameter that allows one to easily change between blocking and non-blocking GPU synchronization with atomic page flips.

---
 drivers/gpu/drm/drm_stub.c          |    5 ++
 drivers/gpu/drm/i915/i915_trace.h   |   49 ++++++++++++++
 drivers/gpu/drm/i915/intel_atomic.c |  119 ++++++++++++++++++++++++++++++++++-
 3 files changed, 172 insertions(+), 1 deletions(-)
drivers/gpu/drm/drm_stub.c +5 -0
index 200e104..b73fde8 100644
@@ -52,6 +52,9 @@ EXPORT_SYMBOL(drm_timestamp_precision);
  */
 unsigned int drm_timestamp_monotonic = 1;
 
+unsigned int drm_async_gpu = 1;	/* 1 to enable async gpu wait */
+EXPORT_SYMBOL(drm_async_gpu);
+
 MODULE_AUTHOR(CORE_AUTHOR);
 MODULE_DESCRIPTION(CORE_DESC);
 MODULE_LICENSE("GPL and additional rights");
@@ -59,11 +62,13 @@ MODULE_PARM_DESC(debug, "Enable debug output");
 MODULE_PARM_DESC(vblankoffdelay, "Delay until vblank irq auto-disable [msecs]");
 MODULE_PARM_DESC(timestamp_precision_usec, "Max. error on timestamps [usecs]");
 MODULE_PARM_DESC(timestamp_monotonic, "Use monotonic timestamps");
+MODULE_PARM_DESC(async_gpu, "Async GPU wait");
 
 module_param_named(debug, drm_debug, int, 0600);
 module_param_named(vblankoffdelay, drm_vblank_offdelay, int, 0600);
 module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 0600);
 module_param_named(timestamp_monotonic, drm_timestamp_monotonic, int, 0600);
+module_param_named(async_gpu, drm_async_gpu, int, 0600);
 
 struct idr drm_minors_idr;
 
drivers/gpu/drm/i915/i915_trace.h +49 -0

55 lines not on this page · raw message

drivers/gpu/drm/i915/intel_atomic.c +118 -1

192 lines not on this page · raw message

Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#79 lore raw

PATCH 79/81 drm/i915: Add some timing debugs to atomic flips

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

---
 drivers/gpu/drm/i915/intel_atomic.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +15 -0
index c964b64a..43767c2 100644
@@ -48,6 +48,7 @@
 #define USE_WRITE_SEQNO
 
 //#define SURFLIVE_DEBUG
+//#define FLIP_TIME_DEBUG
 
 struct intel_flip {
 	struct drm_flip base;
@@ -1842,6 +1843,10 @@ static void intel_flip_cleanup(struct drm_flip *flip)
 	kfree(intel_flip);
 }
 
+#ifdef FLIP_TIME_DEBUG
+static ktime_t tstart, tend, tdiff;
+#endif
+
 static void intel_flip_driver_flush(struct drm_flip_driver *driver)
 {
 	struct drm_i915_private *dev_priv =
@@ -1849,6 +1854,13 @@ static void intel_flip_driver_flush(struct drm_flip_driver *driver)
 
 	/* Flush posted writes */
 	I915_READ(PIPEDSL(PIPE_A));
+
+#ifdef FLIP_TIME_DEBUG
+	tend = ktime_get();
+	tdiff = ktime_sub(tend, tstart);
+	if (ktime_to_ns(tdiff) >= 10000ULL)
+		DRM_DEBUG_KMS("**** flip took %llu nsec ****\n", ktime_to_ns(tdiff));
+#endif
 }
 
 static bool intel_have_new_frmcount(struct drm_device *dev)
@@ -2242,6 +2254,9 @@ static void intel_atomic_schedule_flips(struct drm_i915_private *dev_priv,
 
 	intel_pipe_vblank_evade(&intel_crtc->base);
 
+#ifdef FLIP_TIME_DEBUG
+	tstart = ktime_get();
+#endif
 	drm_flip_driver_schedule_flips(&dev_priv->flip_driver, flips);
 
 	local_irq_enable();
Signature · 6 lines
1.7.8.6

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#80 lore raw

PATCH 80/81 drm/i915: Add post flush DSL readout for surflive debug

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

---
 drivers/gpu/drm/i915/i915_trace.h   |   19 +++++++++++++++++++
 drivers/gpu/drm/i915/intel_atomic.c |    4 ++++
 2 files changed, 23 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/i915_trace.h +19 -0
index 754a204..fb35edd 100644
@@ -16,6 +16,25 @@
 
 /* object tracking */
 
+TRACE_EVENT(i915_atomic_flush,
+	    TP_PROTO(u32 dsl0, u32 dsl1, u32 dsl2),
+	    TP_ARGS(dsl0, dsl1, dsl2),
+
+	    TP_STRUCT__entry(
+			     __field(u32, dsl0)
+			     __field(u32, dsl1)
+			     __field(u32, dsl2)
+			     ),
+	    TP_fast_assign(
+			   __entry->dsl0 = dsl0;
+			   __entry->dsl1 = dsl1;
+			   __entry->dsl2 = dsl2;
+			   ),
+
+	    TP_printk("dsl(0)=%u dsl(1)=%u dsl(2)=%u", __entry->dsl0, __entry->dsl1, __entry->dsl2)
+);
+
+
 TRACE_EVENT(i915_atomic_flip,
 	    TP_PROTO(bool sprite, int pipe, int action, u32 commit_surf, u32 commit_surflive, u32 surf, u32 surflive, u32 iir, u32 commit_dsl, u32 dsl, u32 flip_vbl_count, u32 vbl_count),
 	    TP_ARGS(sprite, pipe, action, commit_surf, commit_surflive, surf, surflive, iir, commit_dsl, dsl, flip_vbl_count, vbl_count),
drivers/gpu/drm/i915/intel_atomic.c +4 -0
index 43767c2..0270d7e 100644
@@ -1855,6 +1855,10 @@ static void intel_flip_driver_flush(struct drm_flip_driver *driver)
 	/* Flush posted writes */
 	I915_READ(PIPEDSL(PIPE_A));
 
+#ifdef SURFLIVE_DEBUG
+	trace_i915_atomic_flush(I915_READ(PIPEDSL(0)), I915_READ(PIPEDSL(1)), I915_READ(PIPEDSL(2)));
+#endif
+
 #ifdef FLIP_TIME_DEBUG
 	tend = ktime_get();
 	tdiff = ktime_sub(tend, tstart);
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#81 lore raw

PATCH 81/81 drm/i915: Add trace point for atomic flip vblank evade

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

---
 drivers/gpu/drm/i915/i915_trace.h   |   18 ++++++++++++++++++
 drivers/gpu/drm/i915/intel_atomic.c |    2 ++
 2 files changed, 20 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/i915_trace.h +18 -0
index fb35edd..2b529f2 100644
@@ -16,6 +16,24 @@
 
 /* object tracking */
 
+TRACE_EVENT(i915_atomic_evade,
+	    TP_PROTO(u32 dsl_min, u32 dsl_max, u32 dsl),
+	    TP_ARGS(dsl_min, dsl_max, dsl),
+
+	    TP_STRUCT__entry(
+			     __field(u32, dsl_min)
+			     __field(u32, dsl_max)
+			     __field(u32, dsl)
+			     ),
+	    TP_fast_assign(
+			   __entry->dsl_min = dsl_min;
+			   __entry->dsl_max = dsl_max;
+			   __entry->dsl = dsl;
+			   ),
+
+	    TP_printk("dsl_min=%u dsl_max=%u dsl=%u", __entry->dsl_min, __entry->dsl_max, __entry->dsl)
+);
+
 TRACE_EVENT(i915_atomic_flush,
 	    TP_PROTO(u32 dsl0, u32 dsl1, u32 dsl2),
 	    TP_ARGS(dsl0, dsl1, dsl2),
drivers/gpu/drm/i915/intel_atomic.c +2 -0
index 0270d7e..993a7dc 100644
@@ -1950,6 +1950,8 @@ static void intel_pipe_vblank_evade(struct drm_crtc *crtc)
 		intel_crtc->vbl_received = false;
 
 		val = I915_READ(PIPEDSL(pipe));
+
+		trace_i915_atomic_evade(min, max, val);
 	}
 
 	if (vblank_ref)
Signature · 6 lines
1.7.8.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#82 lore raw
In reply to [email protected]
Quoted 21 lines · On Wed, Dec 12, 2012 at 06:15:27PM +0200, [email protected] wrote:

Another month, another massive atomic patchset.

I managed to clean up warts left over from the modeset-rework rebase, but other than that I haven't really found the time to touch this too much since the last time I posted patches from this set.

Seeing as my schedule isn't getting any less busy in the forseeable future, it would be nice to get this monster merged sooner rather than never.

Ever since the code started to resemble something sane, I've tried to avoid squashing patches, just in case someone was actually trying to follow what's changed. But clearly some of the patches can be squashed, and that would probably allow some of the earlier ones to be dropped entirely.

What's clearly needed is a test tool that will stresss the mode setting side of the code more. My glplane test just changes the modes in the beginning, and then just does flips and other plane stuff. I'll try to get something done on that front before Christmas.

Quoted 6 lines

Repo is here:
https://gitorious.org/vsyrjala/linux/commits/drm_atomic_23

The repo also contains 64bit get_user() implementation for x86-32, which I sent to lkml and x86 people for review. So this should now be testable even on a 32bit system.

Can you please upload your testcase somewhere so that I can play around with this without too much hassle.

Thanks, Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#83 lore raw
Quoted 25 lines · Daniel Vetter
Quoted 24 lines · On Wed, Dec 12, 2012 at 06:15:27PM +0200, [email protected] wrote:

Another month, another massive atomic patchset.

I managed to clean up warts left over from the modeset-rework rebase, but other than that I haven't really found the time to touch this too much since the last time I posted patches from this set.

Seeing as my schedule isn't getting any less busy in the forseeable future, it would be nice to get this monster merged sooner rather than never.

Ever since the code started to resemble something sane, I've tried to avoid squashing patches, just in case someone was actually trying to follow what's changed. But clearly some of the patches can be squashed, and that would probably allow some of the earlier ones to be dropped entirely.

What's clearly needed is a test tool that will stresss the mode setting side of the code more. My glplane test just changes the modes in the beginning, and then just does flips and other plane stuff. I'll try to get something done on that front before Christmas.

Repo is here:
https://gitorious.org/vsyrjala/linux/commits/drm_atomic_23

Quoted 6 lines
Quoted 3 lines

The repo also contains 64bit get_user() implementation for x86-32, which I sent to lkml and x86 people for review. So this should now be testable even on a 32bit system.

Can you please upload your testcase somewhere so that I can play around with this without too much hassle.

It's here:
https://gitorious.org/vsyrjala/glplane

It responds to a bunch of keys in some way. Look near the end of main() in plane.c to see which keys do what.

You'll need libdrm too:
https://gitorious.org/vsyrjala/drm/commits/drm_atomic_7

And there's an older test here, but I'm not sure it works anymore:
https://gitorious.org/vsyrjala/plane

Signature · 2 lines
Ville Syrjälä
Intel OTC
#84 lore raw
In reply to [email protected]

On Wed, Dec 12, 2012 at 06:15:27PM +0200, [email protected] wrote:
...

Quoted 5 lines

Ever since the code started to resemble something sane, I've tried to avoid squashing patches, just in case someone was actually trying to follow what's changed. But clearly some of the patches can be squashed, and that would probably allow some of the earlier ones to be dropped entirely.

FYI I now squashed this down to 56 patches, with 6 being pure debug stuff, ~15 trivial unstatic/export stuff, and the rest are of varying complexity. So we're down to ~35 patches with substance.

Next week I can see about pulling some of the intel specific plane stuff out and send that separately. Those would involve a few framework type patches the core as well. By my quick calculation that could bring the final count down by another 15 or so.

There are also some core drm patches that could be merged at any point, but most of those wouldn't have any use until the atomic stuff starts taking advantage or them (signed range props, resizeable blobs, etc.).

The current set is here:
https://gitorious.org/vsyrjala/linux/commits/drm_atomic_24

Signature · 2 lines
Ville Syrjälä
Intel OTC