All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/19] drm/atomic: Use less confusing iterator names.
@ 2016-10-17 12:36 Maarten Lankhorst
  2016-10-17 12:37 ` [PATCH 01/19] drm/atomic: Add new iterators over all state Maarten Lankhorst
                   ` (19 more replies)
  0 siblings, 20 replies; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:36 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Add for_each_(old,new)_(crtc,connector,plane)_in_state iterators, and
re-use for_each_*_in_state to be a iterator with the old and the new
state.

This will be less confusing than the previous case, in which
for_each_*_in_state could refer to the old or the new state.

The oldnew macro names are temporary in this series, until
all drivers are converted to use the old, new or both states.

This series applies to the topic/drm-misc branch, and will probably
conflict with a lot of other stuff. This is why I post this right
after the merge window.

Compile tested on arm and tested for i915 on x86.

Maarten Lankhorst (19):
  drm/atomic: Add new iterators over all state
  drm/atmel-hlcdc: Use new atomic iterator macros.
  drm/exynos: Use new atomic iterator macros.
  drm/blend: Use new atomic iterator macros.
  drm/atomic: Make add_affected_connectors look at crtc_state.
  drm/atomic: Use new atomic iterator macros.
  drm/atomic: Fix atomic helpers to use the new iterator macros.
  drm/vc4: Use new atomic iterator macros.
  drm/rockchip: Use new atomic iterator macros.
  drm/rcar-du: Use new atomic iterator macros.
  drm/omap: Use new atomic iterator macros
  drm/msm: Use new atomic iterator macros
  drm/imx: Use new atomic iterator macros
  drm/mediatek: Use new atomic iterator macros
  drm/i915: Use new atomic iterator macros in ddi
  drm/i915: Use new atomic iterator macros in fbc
  drm/i915: Use new atomic iterator macros in wm code
  drm/i915: Use new atomic iterator macros in display code
  drm/atomic: Rename atomic oldnew iterator

 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c |   2 +-
 drivers/gpu/drm/drm_atomic.c                   |  27 +-
 drivers/gpu/drm/drm_atomic_helper.c            | 354 ++++++++++++++-----------
 drivers/gpu/drm/drm_blend.c                    |  22 +-
 drivers/gpu/drm/exynos/exynos_drm_drv.c        |   2 +-
 drivers/gpu/drm/i915/intel_ddi.c               |   4 +-
 drivers/gpu/drm/i915/intel_display.c           | 167 ++++++------
 drivers/gpu/drm/i915/intel_drv.h               |   2 -
 drivers/gpu/drm/i915/intel_fbc.c               |   6 +-
 drivers/gpu/drm/i915/intel_pm.c                |  12 +-
 drivers/gpu/drm/imx/imx-drm-core.c             |  10 +-
 drivers/gpu/drm/mediatek/mtk_drm_drv.c         |   4 +-
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c        |   4 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c        |   6 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h        |   3 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c      |   4 +-
 drivers/gpu/drm/msm/msm_atomic.c               |  16 +-
 drivers/gpu/drm/omapdrm/omap_drv.c             |   8 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c          |   2 +-
 drivers/gpu/drm/rcar-du/rcar_du_plane.c        |   4 +-
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c    |   6 +-
 drivers/gpu/drm/vc4/vc4_kms.c                  |   6 +-
 include/drm/drm_atomic.h                       |  83 ++++--
 include/drm/drm_atomic_helper.h                |   3 +
 24 files changed, 442 insertions(+), 315 deletions(-)

-- 
2.7.4

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

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH 01/19] drm/atomic: Add new iterators over all state
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-11-01 13:09   ` [Intel-gfx] " Ville Syrjälä
  2016-10-17 12:37 ` [PATCH 02/19] drm/atmel-hlcdc: Use new atomic iterator macros Maarten Lankhorst
                   ` (18 subsequent siblings)
  19 siblings, 1 reply; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Add for_each_(old)(new)_(plane,connector,crtc)_in_state iterators to
replace the old for_each_xxx_in_state ones. This is useful for >1 flip
depth and getting rid of all xxx->state dereferences.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/drm_atomic.c         |  6 +++
 drivers/gpu/drm/drm_atomic_helper.c  | 52 +++++++++++++++++++++--
 drivers/gpu/drm/i915/intel_display.c | 11 ++---
 include/drm/drm_atomic.h             | 81 ++++++++++++++++++++++++++++++++++--
 include/drm/drm_atomic_helper.h      |  3 ++
 5 files changed, 142 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 5dd70540219c..120775fcfb70 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -278,6 +278,8 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
 		return ERR_PTR(-ENOMEM);
 
 	state->crtcs[index].state = crtc_state;
+	state->crtcs[index].old_state = crtc->state;
+	state->crtcs[index].new_state = crtc_state;
 	state->crtcs[index].ptr = crtc;
 	crtc_state->state = state;
 
@@ -640,6 +642,8 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,
 
 	state->planes[index].state = plane_state;
 	state->planes[index].ptr = plane;
+	state->planes[index].old_state = plane->state;
+	state->planes[index].new_state = plane_state;
 	plane_state->state = state;
 
 	DRM_DEBUG_ATOMIC("Added [PLANE:%d:%s] %p state to %p\n",
@@ -931,6 +935,8 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
 
 	drm_connector_reference(connector);
 	state->connectors[index].state = connector_state;
+	state->connectors[index].old_state = connector->state;
+	state->connectors[index].new_state = connector_state;
 	state->connectors[index].ptr = connector;
 	connector_state->state = state;
 
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 07b432f43b98..fcb6e5b55217 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -2495,7 +2495,7 @@ EXPORT_SYMBOL(drm_atomic_helper_disable_all);
  *
  * See also:
  * drm_atomic_helper_duplicate_state(), drm_atomic_helper_disable_all(),
- * drm_atomic_helper_resume()
+ * drm_atomic_helper_resume(), drm_atomic_helper_commit_duplicated_state()
  */
 struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev)
 {
@@ -2536,6 +2536,52 @@ unlock:
 EXPORT_SYMBOL(drm_atomic_helper_suspend);
 
 /**
+ * drm_atomic_helper_commit_duplicated_state - commit duplicated state
+ * @state: duplicated atomic state to commit
+ * @ctx: pointer to acquire_ctx to use for commit.
+ * @nonblock: commit the state non-blocking.
+ *
+ * The state returned by drm_atomic_helper_duplicate_state() and
+ * drm_atomic_helper_suspend() is partially invalid, and needs to
+ * be fixed up before commit.
+ *
+ * Returns:
+ * 0 on success or a negative error code on failure.
+ *
+ * See also:
+ * drm_atomic_helper_suspend()
+ */
+int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
+					      struct drm_modeset_acquire_ctx *ctx,
+					      bool nonblock)
+{
+	int i;
+	struct drm_plane *plane;
+	struct drm_plane_state *plane_state;
+	struct drm_connector *connector;
+	struct drm_connector_state *conn_state;
+	struct drm_crtc *crtc;
+	struct drm_crtc_state *crtc_state;
+
+	state->acquire_ctx = ctx;
+
+	for_each_new_plane_in_state(state, plane, plane_state, i)
+		state->planes[i].old_state = plane->state;
+
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i)
+		state->crtcs[i].old_state = crtc->state;
+
+	for_each_new_connector_in_state(state, connector, conn_state, i)
+		state->connectors[i].old_state = connector->state;
+
+	if (nonblock)
+		return drm_atomic_nonblocking_commit(state);
+	else
+		return drm_atomic_commit(state);
+}
+EXPORT_SYMBOL(drm_atomic_helper_commit_duplicated_state);
+
+/**
  * drm_atomic_helper_resume - subsystem-level resume helper
  * @dev: DRM device
  * @state: atomic state to resume to
@@ -2558,9 +2604,9 @@ int drm_atomic_helper_resume(struct drm_device *dev,
 	int err;
 
 	drm_mode_config_reset(dev);
+
 	drm_modeset_lock_all(dev);
-	state->acquire_ctx = config->acquire_ctx;
-	err = drm_atomic_commit(state);
+	err = drm_atomic_helper_commit_duplicated_state(state, config->acquire_ctx, false);
 	drm_modeset_unlock_all(dev);
 
 	return err;
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index a12e093c54cf..3bd3f6a93c12 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3497,7 +3497,8 @@ static void intel_update_primary_planes(struct drm_device *dev)
 
 static int
 __intel_display_resume(struct drm_device *dev,
-		       struct drm_atomic_state *state)
+		       struct drm_atomic_state *state,
+		       struct drm_modeset_acquire_ctx *ctx)
 {
 	struct drm_crtc_state *crtc_state;
 	struct drm_crtc *crtc;
@@ -3521,7 +3522,7 @@ __intel_display_resume(struct drm_device *dev,
 	/* ignore any reset values/BIOS leftovers in the WM registers */
 	to_intel_atomic_state(state)->skip_intermediate_wm = true;
 
-	ret = drm_atomic_commit(state);
+	ret = drm_atomic_helper_commit_duplicated_state(state, ctx, false);
 
 	WARN_ON(ret == -EDEADLK);
 	return ret;
@@ -3617,7 +3618,7 @@ void intel_finish_reset(struct drm_i915_private *dev_priv)
 			 */
 			intel_update_primary_planes(dev);
 		} else {
-			ret = __intel_display_resume(dev, state);
+			ret = __intel_display_resume(dev, state, ctx);
 			if (ret)
 				DRM_ERROR("Restoring old state failed with %i\n", ret);
 		}
@@ -3636,7 +3637,7 @@ void intel_finish_reset(struct drm_i915_private *dev_priv)
 			dev_priv->display.hpd_irq_setup(dev_priv);
 		spin_unlock_irq(&dev_priv->irq_lock);
 
-		ret = __intel_display_resume(dev, state);
+		ret = __intel_display_resume(dev, state, ctx);
 		if (ret)
 			DRM_ERROR("Restoring old state failed with %i\n", ret);
 
@@ -16937,7 +16938,7 @@ void intel_display_resume(struct drm_device *dev)
 	}
 
 	if (!ret)
-		ret = __intel_display_resume(dev, state);
+		ret = __intel_display_resume(dev, state, &ctx);
 
 	drm_modeset_drop_locks(&ctx);
 	drm_modeset_acquire_fini(&ctx);
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index fc8af53b18aa..09fb6b316ca9 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -137,18 +137,18 @@ struct drm_crtc_commit {
 
 struct __drm_planes_state {
 	struct drm_plane *ptr;
-	struct drm_plane_state *state;
+	struct drm_plane_state *state, *old_state, *new_state;
 };
 
 struct __drm_crtcs_state {
 	struct drm_crtc *ptr;
-	struct drm_crtc_state *state;
+	struct drm_crtc_state *state, *old_state, *new_state;
 	struct drm_crtc_commit *commit;
 };
 
 struct __drm_connnectors_state {
 	struct drm_connector *ptr;
-	struct drm_connector_state *state;
+	struct drm_connector_state *state, *old_state, *new_state;
 };
 
 /**
@@ -372,6 +372,31 @@ int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
 	     (__i)++)							\
 		for_each_if (connector)
 
+#define for_each_oldnew_connector_in_state(__state, connector, old_connector_state, new_connector_state, __i) \
+	for ((__i) = 0;								\
+	     (__i) < (__state)->num_connector &&				\
+	     ((connector) = (__state)->connectors[__i].ptr,			\
+	     (old_connector_state) = (__state)->connectors[__i].old_state,	\
+	     (new_connector_state) = (__state)->connectors[__i].new_state, 1); 	\
+	     (__i)++)							\
+		for_each_if (connector)
+
+#define for_each_old_connector_in_state(__state, connector, old_connector_state, __i) \
+	for ((__i) = 0;								\
+	     (__i) < (__state)->num_connector &&				\
+	     ((connector) = (__state)->connectors[__i].ptr,			\
+	     (old_connector_state) = (__state)->connectors[__i].old_state, 1); 	\
+	     (__i)++)							\
+		for_each_if (connector)
+
+#define for_each_new_connector_in_state(__state, connector, new_connector_state, __i) \
+	for ((__i) = 0;								\
+	     (__i) < (__state)->num_connector &&				\
+	     ((connector) = (__state)->connectors[__i].ptr,			\
+	     (new_connector_state) = (__state)->connectors[__i].new_state, 1); 	\
+	     (__i)++)							\
+		for_each_if (connector)
+
 #define for_each_crtc_in_state(__state, crtc, crtc_state, __i)	\
 	for ((__i) = 0;						\
 	     (__i) < (__state)->dev->mode_config.num_crtc &&	\
@@ -380,6 +405,31 @@ int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
 	     (__i)++)						\
 		for_each_if (crtc_state)
 
+#define for_each_oldnew_crtc_in_state(__state, crtc, old_crtc_state, new_crtc_state, __i) \
+	for ((__i) = 0;							\
+	     (__i) < (__state)->dev->mode_config.num_crtc &&		\
+	     ((crtc) = (__state)->crtcs[__i].ptr,			\
+	     (old_crtc_state) = (__state)->crtcs[__i].old_state,	\
+	     (new_crtc_state) = (__state)->crtcs[__i].new_state, 1);	\
+	     (__i)++)							\
+		for_each_if (crtc)
+
+#define for_each_old_crtc_in_state(__state, crtc, old_crtc_state, __i)	\
+	for ((__i) = 0;							\
+	     (__i) < (__state)->dev->mode_config.num_crtc &&		\
+	     ((crtc) = (__state)->crtcs[__i].ptr,			\
+	     (old_crtc_state) = (__state)->crtcs[__i].old_state, 1);	\
+	     (__i)++)							\
+		for_each_if (crtc)
+
+#define for_each_new_crtc_in_state(__state, crtc, new_crtc_state, __i)	\
+	for ((__i) = 0;							\
+	     (__i) < (__state)->dev->mode_config.num_crtc &&		\
+	     ((crtc) = (__state)->crtcs[__i].ptr,			\
+	     (new_crtc_state) = (__state)->crtcs[__i].new_state, 1);	\
+	     (__i)++)							\
+		for_each_if (crtc)
+
 #define for_each_plane_in_state(__state, plane, plane_state, __i)		\
 	for ((__i) = 0;							\
 	     (__i) < (__state)->dev->mode_config.num_total_plane &&	\
@@ -388,6 +438,31 @@ int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
 	     (__i)++)							\
 		for_each_if (plane_state)
 
+#define for_each_oldnew_plane_in_state(__state, plane, old_plane_state, new_plane_state, __i) \
+	for ((__i) = 0;							\
+	     (__i) < (__state)->dev->mode_config.num_total_plane &&	\
+	     ((plane) = (__state)->planes[__i].ptr,			\
+	     (old_plane_state) = (__state)->planes[__i].old_state,	\
+	     (new_plane_state) = (__state)->planes[__i].new_state, 1);	\
+	     (__i)++)							\
+		for_each_if (plane)
+
+#define for_each_old_plane_in_state(__state, plane, old_plane_state, __i) \
+	for ((__i) = 0;							\
+	     (__i) < (__state)->dev->mode_config.num_total_plane &&	\
+	     ((plane) = (__state)->planes[__i].ptr,			\
+	     (old_plane_state) = (__state)->planes[__i].old_state, 1);	\
+	     (__i)++)							\
+		for_each_if (plane)
+
+#define for_each_new_plane_in_state(__state, plane, new_plane_state, __i) \
+	for ((__i) = 0;							\
+	     (__i) < (__state)->dev->mode_config.num_total_plane &&	\
+	     ((plane) = (__state)->planes[__i].ptr,			\
+	     (new_plane_state) = (__state)->planes[__i].new_state, 1);	\
+	     (__i)++)							\
+		for_each_if (plane)
+
 /**
  * drm_atomic_crtc_needs_modeset - compute combined modeset need
  * @state: &drm_crtc_state for the CRTC
diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
index 7ff92b09fd9c..613bb731ba36 100644
--- a/include/drm/drm_atomic_helper.h
+++ b/include/drm/drm_atomic_helper.h
@@ -108,6 +108,9 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set,
 int drm_atomic_helper_disable_all(struct drm_device *dev,
 				  struct drm_modeset_acquire_ctx *ctx);
 struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev);
+int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
+					      struct drm_modeset_acquire_ctx *ctx,
+					      bool nonblock);
 int drm_atomic_helper_resume(struct drm_device *dev,
 			     struct drm_atomic_state *state);
 
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 02/19] drm/atmel-hlcdc: Use new atomic iterator macros.
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
  2016-10-17 12:37 ` [PATCH 01/19] drm/atomic: Add new iterators over all state Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-10-17 12:37 ` [PATCH 03/19] drm/exynos: " Maarten Lankhorst
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 9b17a66cf0e1..b5af77097033 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -268,7 +268,7 @@ static int atmel_hlcdc_crtc_select_output_mode(struct drm_crtc_state *state)
 
 	crtc = drm_crtc_to_atmel_hlcdc_crtc(state->crtc);
 
-	for_each_connector_in_state(state->state, connector, cstate, i) {
+	for_each_new_connector_in_state(state->state, connector, cstate, i) {
 		struct drm_display_info *info = &connector->display_info;
 		unsigned int supported_fmts = 0;
 		int j;
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 03/19] drm/exynos: Use new atomic iterator macros.
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
  2016-10-17 12:37 ` [PATCH 01/19] drm/atomic: Add new iterators over all state Maarten Lankhorst
  2016-10-17 12:37 ` [PATCH 02/19] drm/atmel-hlcdc: Use new atomic iterator macros Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-10-17 12:37 ` [PATCH 04/19] drm/blend: " Maarten Lankhorst
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 4a21a745c373..fc54f3f0a42c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -243,7 +243,7 @@ int exynos_atomic_commit(struct drm_device *dev, struct drm_atomic_state *state,
 	/* Wait until all affected CRTCs have completed previous commits and
 	 * mark them as pending.
 	 */
-	for_each_crtc_in_state(state, crtc, crtc_state, i)
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i)
 		commit->crtcs |= drm_crtc_mask(crtc);
 
 	wait_event(priv->wait, !commit_is_pending(priv, commit->crtcs));
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 04/19] drm/blend: Use new atomic iterator macros.
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (2 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 03/19] drm/exynos: " Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-11-03 15:26   ` Ville Syrjälä
  2016-10-17 12:37 ` [PATCH 05/19] drm/atomic: Make add_affected_connectors look at crtc_state Maarten Lankhorst
                   ` (15 subsequent siblings)
  19 siblings, 1 reply; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/drm_blend.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c
index 85172a977bf3..70c03eb032fc 100644
--- a/drivers/gpu/drm/drm_blend.c
+++ b/drivers/gpu/drm/drm_blend.c
@@ -367,27 +367,27 @@ int drm_atomic_normalize_zpos(struct drm_device *dev,
 			      struct drm_atomic_state *state)
 {
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct drm_plane *plane;
-	struct drm_plane_state *plane_state;
+	struct drm_plane_state *old_plane_state, *new_plane_state;
 	int i, ret = 0;
 
-	for_each_plane_in_state(state, plane, plane_state, i) {
-		crtc = plane_state->crtc;
+	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
+		crtc = new_plane_state->crtc;
 		if (!crtc)
 			continue;
-		if (plane->state->zpos != plane_state->zpos) {
-			crtc_state =
+		if (old_plane_state->zpos != new_plane_state->zpos) {
+			new_crtc_state =
 				drm_atomic_get_existing_crtc_state(state, crtc);
-			crtc_state->zpos_changed = true;
+			new_crtc_state->zpos_changed = true;
 		}
 	}
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
-		if (crtc_state->plane_mask != crtc->state->plane_mask ||
-		    crtc_state->zpos_changed) {
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+		if (old_crtc_state->plane_mask != new_crtc_state->plane_mask ||
+		    new_crtc_state->zpos_changed) {
 			ret = drm_atomic_helper_crtc_normalize_zpos(crtc,
-								    crtc_state);
+								    new_crtc_state);
 			if (ret)
 				return ret;
 		}
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 05/19] drm/atomic: Make add_affected_connectors look at crtc_state.
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (3 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 04/19] drm/blend: " Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-11-03 15:32   ` Ville Syrjälä
  2016-10-17 12:37 ` [PATCH 06/19] drm/atomic: Use new atomic iterator macros Maarten Lankhorst
                   ` (14 subsequent siblings)
  19 siblings, 1 reply; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

This kills another dereference of connector->state. connector_mask
holds all unchanged connectors at least and any changed connectors
are already in state anyway.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/drm_atomic.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 120775fcfb70..1915ec44f7eb 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1230,8 +1230,13 @@ drm_atomic_add_affected_connectors(struct drm_atomic_state *state,
 	struct drm_mode_config *config = &state->dev->mode_config;
 	struct drm_connector *connector;
 	struct drm_connector_state *conn_state;
+	struct drm_crtc_state *crtc_state;
 	int ret;
 
+	crtc_state = drm_atomic_get_crtc_state(state, crtc);
+	if (IS_ERR(crtc_state))
+		return PTR_ERR(crtc_state);
+
 	ret = drm_modeset_lock(&config->connection_mutex, state->acquire_ctx);
 	if (ret)
 		return ret;
@@ -1240,11 +1245,11 @@ drm_atomic_add_affected_connectors(struct drm_atomic_state *state,
 			 crtc->base.id, crtc->name, state);
 
 	/*
-	 * Changed connectors are already in @state, so only need to look at the
-	 * current configuration.
+	 * Changed connectors are already in @state, so only need to look
+	 * at the connector_mask in crtc_state.
 	 */
 	drm_for_each_connector(connector, state->dev) {
-		if (connector->state->crtc != crtc)
+		if (!(crtc_state->connector_mask & (1 << drm_connector_index(connector))))
 			continue;
 
 		conn_state = drm_atomic_get_connector_state(state, connector);
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 06/19] drm/atomic: Use new atomic iterator macros.
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (4 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 05/19] drm/atomic: Make add_affected_connectors look at crtc_state Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-11-03 15:35   ` [Intel-gfx] " Ville Syrjälä
  2016-10-17 12:37 ` [PATCH 07/19] drm/atomic: Fix atomic helpers to use the new " Maarten Lankhorst
                   ` (13 subsequent siblings)
  19 siblings, 1 reply; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/drm_atomic.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 1915ec44f7eb..6672ea93ee73 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1369,7 +1369,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
 
 	DRM_DEBUG_ATOMIC("checking %p\n", state);
 
-	for_each_plane_in_state(state, plane, plane_state, i) {
+	for_each_new_plane_in_state(state, plane, plane_state, i) {
 		ret = drm_atomic_plane_check(plane, plane_state);
 		if (ret) {
 			DRM_DEBUG_ATOMIC("[PLANE:%d:%s] atomic core check failed\n",
@@ -1378,7 +1378,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
 		}
 	}
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 		ret = drm_atomic_crtc_check(crtc, crtc_state);
 		if (ret) {
 			DRM_DEBUG_ATOMIC("[CRTC:%d:%s] atomic core check failed\n",
@@ -1391,7 +1391,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
 		ret = config->funcs->atomic_check(state->dev, state);
 
 	if (!state->allow_modeset) {
-		for_each_crtc_in_state(state, crtc, crtc_state, i) {
+		for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 			if (drm_atomic_crtc_needs_modeset(crtc_state)) {
 				DRM_DEBUG_ATOMIC("[CRTC:%d:%s] requires full modeset\n",
 						 crtc->base.id, crtc->name);
@@ -1732,7 +1732,7 @@ retry:
 	}
 
 	if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
-		for_each_crtc_in_state(state, crtc, crtc_state, i) {
+		for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 			struct drm_pending_vblank_event *e;
 
 			e = create_vblank_event(dev, file_priv, NULL,
@@ -1768,7 +1768,7 @@ out:
 		 * for TEST_ONLY too.
 		 */
 
-		for_each_crtc_in_state(state, crtc, crtc_state, i) {
+		for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 			if (!crtc_state->event)
 				continue;
 
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 07/19] drm/atomic: Fix atomic helpers to use the new iterator macros.
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (5 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 06/19] drm/atomic: Use new atomic iterator macros Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-11-03 16:22   ` Ville Syrjälä
  2016-10-17 12:37 ` [PATCH 08/19] drm/vc4: Use new atomic " Maarten Lankhorst
                   ` (12 subsequent siblings)
  19 siblings, 1 reply; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/drm_atomic_helper.c | 302 +++++++++++++++++++-----------------
 1 file changed, 157 insertions(+), 145 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index fcb6e5b55217..c8aba493fc17 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -103,7 +103,7 @@ static int handle_conflicting_encoders(struct drm_atomic_state *state,
 	 * part of the state. If the same encoder is assigned to multiple
 	 * connectors bail out.
 	 */
-	for_each_connector_in_state(state, connector, conn_state, i) {
+	for_each_new_connector_in_state(state, connector, conn_state, i) {
 		const struct drm_connector_helper_funcs *funcs = connector->helper_private;
 		struct drm_encoder *new_encoder;
 
@@ -238,22 +238,22 @@ steal_encoder(struct drm_atomic_state *state,
 {
 	struct drm_crtc_state *crtc_state;
 	struct drm_connector *connector;
-	struct drm_connector_state *connector_state;
+	struct drm_connector_state *old_connector_state, *new_connector_state;
 	int i;
 
-	for_each_connector_in_state(state, connector, connector_state, i) {
+	for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i) {
 		struct drm_crtc *encoder_crtc;
 
-		if (connector_state->best_encoder != encoder)
+		if (new_connector_state->best_encoder != encoder)
 			continue;
 
-		encoder_crtc = connector->state->crtc;
+		encoder_crtc = old_connector_state->crtc;
 
 		DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] in use on [CRTC:%d:%s], stealing it\n",
 				 encoder->base.id, encoder->name,
 				 encoder_crtc->base.id, encoder_crtc->name);
 
-		set_best_encoder(state, connector_state, NULL);
+		set_best_encoder(state, new_connector_state, NULL);
 
 		crtc_state = drm_atomic_get_existing_crtc_state(state, encoder_crtc);
 		crtc_state->connectors_changed = true;
@@ -265,7 +265,8 @@ steal_encoder(struct drm_atomic_state *state,
 static int
 update_connector_routing(struct drm_atomic_state *state,
 			 struct drm_connector *connector,
-			 struct drm_connector_state *connector_state)
+			 struct drm_connector_state *old_connector_state,
+			 struct drm_connector_state *new_connector_state)
 {
 	const struct drm_connector_helper_funcs *funcs;
 	struct drm_encoder *new_encoder;
@@ -275,24 +276,24 @@ update_connector_routing(struct drm_atomic_state *state,
 			 connector->base.id,
 			 connector->name);
 
-	if (connector->state->crtc != connector_state->crtc) {
-		if (connector->state->crtc) {
-			crtc_state = drm_atomic_get_existing_crtc_state(state, connector->state->crtc);
+	if (old_connector_state->crtc != new_connector_state->crtc) {
+		if (old_connector_state->crtc) {
+			crtc_state = drm_atomic_get_existing_crtc_state(state, old_connector_state->crtc);
 			crtc_state->connectors_changed = true;
 		}
 
-		if (connector_state->crtc) {
-			crtc_state = drm_atomic_get_existing_crtc_state(state, connector_state->crtc);
+		if (new_connector_state->crtc) {
+			crtc_state = drm_atomic_get_existing_crtc_state(state, new_connector_state->crtc);
 			crtc_state->connectors_changed = true;
 		}
 	}
 
-	if (!connector_state->crtc) {
+	if (!new_connector_state->crtc) {
 		DRM_DEBUG_ATOMIC("Disabling [CONNECTOR:%d:%s]\n",
 				connector->base.id,
 				connector->name);
 
-		set_best_encoder(state, connector_state, NULL);
+		set_best_encoder(state, new_connector_state, NULL);
 
 		return 0;
 	}
@@ -301,7 +302,7 @@ update_connector_routing(struct drm_atomic_state *state,
 
 	if (funcs->atomic_best_encoder)
 		new_encoder = funcs->atomic_best_encoder(connector,
-							 connector_state);
+							 new_connector_state);
 	else if (funcs->best_encoder)
 		new_encoder = funcs->best_encoder(connector);
 	else
@@ -314,33 +315,33 @@ update_connector_routing(struct drm_atomic_state *state,
 		return -EINVAL;
 	}
 
-	if (!drm_encoder_crtc_ok(new_encoder, connector_state->crtc)) {
+	if (!drm_encoder_crtc_ok(new_encoder, new_connector_state->crtc)) {
 		DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] incompatible with [CRTC:%d]\n",
 				 new_encoder->base.id,
 				 new_encoder->name,
-				 connector_state->crtc->base.id);
+				 new_connector_state->crtc->base.id);
 		return -EINVAL;
 	}
 
-	if (new_encoder == connector_state->best_encoder) {
-		set_best_encoder(state, connector_state, new_encoder);
+	if (new_encoder == new_connector_state->best_encoder) {
+		set_best_encoder(state, new_connector_state, new_encoder);
 
 		DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] keeps [ENCODER:%d:%s], now on [CRTC:%d:%s]\n",
 				 connector->base.id,
 				 connector->name,
 				 new_encoder->base.id,
 				 new_encoder->name,
-				 connector_state->crtc->base.id,
-				 connector_state->crtc->name);
+				 new_connector_state->crtc->base.id,
+				 new_connector_state->crtc->name);
 
 		return 0;
 	}
 
 	steal_encoder(state, new_encoder);
 
-	set_best_encoder(state, connector_state, new_encoder);
+	set_best_encoder(state, new_connector_state, new_encoder);
 
-	crtc_state = drm_atomic_get_existing_crtc_state(state, connector_state->crtc);
+	crtc_state = drm_atomic_get_existing_crtc_state(state, new_connector_state->crtc);
 	crtc_state->connectors_changed = true;
 
 	DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] using [ENCODER:%d:%s] on [CRTC:%d:%s]\n",
@@ -348,8 +349,8 @@ update_connector_routing(struct drm_atomic_state *state,
 			 connector->name,
 			 new_encoder->base.id,
 			 new_encoder->name,
-			 connector_state->crtc->base.id,
-			 connector_state->crtc->name);
+			 new_connector_state->crtc->base.id,
+			 new_connector_state->crtc->name);
 
 	return 0;
 }
@@ -364,7 +365,7 @@ mode_fixup(struct drm_atomic_state *state)
 	int i;
 	bool ret;
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 		if (!crtc_state->mode_changed &&
 		    !crtc_state->connectors_changed)
 			continue;
@@ -372,7 +373,7 @@ mode_fixup(struct drm_atomic_state *state)
 		drm_mode_copy(&crtc_state->adjusted_mode, &crtc_state->mode);
 	}
 
-	for_each_connector_in_state(state, connector, conn_state, i) {
+	for_each_new_connector_in_state(state, connector, conn_state, i) {
 		const struct drm_encoder_helper_funcs *funcs;
 		struct drm_encoder *encoder;
 
@@ -417,7 +418,7 @@ mode_fixup(struct drm_atomic_state *state)
 		}
 	}
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 		const struct drm_crtc_helper_funcs *funcs;
 
 		if (!crtc_state->enable)
@@ -476,19 +477,19 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 				struct drm_atomic_state *state)
 {
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct drm_connector *connector;
-	struct drm_connector_state *connector_state;
+	struct drm_connector_state *old_connector_state, *new_connector_state;
 	int i, ret;
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
-		if (!drm_mode_equal(&crtc->state->mode, &crtc_state->mode)) {
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+		if (!drm_mode_equal(&old_crtc_state->mode, &new_crtc_state->mode)) {
 			DRM_DEBUG_ATOMIC("[CRTC:%d:%s] mode changed\n",
 					 crtc->base.id, crtc->name);
-			crtc_state->mode_changed = true;
+			new_crtc_state->mode_changed = true;
 		}
 
-		if (crtc->state->enable != crtc_state->enable) {
+		if (old_crtc_state->enable != new_crtc_state->enable) {
 			DRM_DEBUG_ATOMIC("[CRTC:%d:%s] enable changed\n",
 					 crtc->base.id, crtc->name);
 
@@ -500,8 +501,8 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 			 * The other way around is true as well. enable != 0
 			 * iff connectors are attached and a mode is set.
 			 */
-			crtc_state->mode_changed = true;
-			crtc_state->connectors_changed = true;
+			new_crtc_state->mode_changed = true;
+			new_crtc_state->connectors_changed = true;
 		}
 	}
 
@@ -509,14 +510,15 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	for_each_connector_in_state(state, connector, connector_state, i) {
+	for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i) {
 		/*
 		 * This only sets crtc->connectors_changed for routing changes,
 		 * drivers must set crtc->connectors_changed themselves when
 		 * connector properties need to be updated.
 		 */
 		ret = update_connector_routing(state, connector,
-					       connector_state);
+					       old_connector_state,
+					       new_connector_state);
 		if (ret)
 			return ret;
 	}
@@ -527,28 +529,28 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 	 * configuration. This must be done before calling mode_fixup in case a
 	 * crtc only changed its mode but has the same set of connectors.
 	 */
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		bool has_connectors =
-			!!crtc_state->connector_mask;
+			!!new_crtc_state->connector_mask;
 
 		/*
 		 * We must set ->active_changed after walking connectors for
 		 * otherwise an update that only changes active would result in
 		 * a full modeset because update_connector_routing force that.
 		 */
-		if (crtc->state->active != crtc_state->active) {
+		if (old_crtc_state->active != new_crtc_state->active) {
 			DRM_DEBUG_ATOMIC("[CRTC:%d:%s] active changed\n",
 					 crtc->base.id, crtc->name);
-			crtc_state->active_changed = true;
+			new_crtc_state->active_changed = true;
 		}
 
-		if (!drm_atomic_crtc_needs_modeset(crtc_state))
+		if (!drm_atomic_crtc_needs_modeset(new_crtc_state))
 			continue;
 
 		DRM_DEBUG_ATOMIC("[CRTC:%d:%s] needs all connectors, enable: %c, active: %c\n",
 				 crtc->base.id, crtc->name,
-				 crtc_state->enable ? 'y' : 'n',
-				 crtc_state->active ? 'y' : 'n');
+				 new_crtc_state->enable ? 'y' : 'n',
+				 new_crtc_state->active ? 'y' : 'n');
 
 		ret = drm_atomic_add_affected_connectors(state, crtc);
 		if (ret != 0)
@@ -558,7 +560,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 		if (ret != 0)
 			return ret;
 
-		if (crtc_state->enable != has_connectors) {
+		if (new_crtc_state->enable != has_connectors) {
 			DRM_DEBUG_ATOMIC("[CRTC:%d:%s] enabled/connectors mismatch\n",
 					 crtc->base.id, crtc->name);
 
@@ -599,7 +601,7 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	for_each_plane_in_state(state, plane, plane_state, i) {
+	for_each_new_plane_in_state(state, plane, plane_state, i) {
 		const struct drm_plane_helper_funcs *funcs;
 
 		funcs = plane->helper_private;
@@ -617,7 +619,7 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
 		}
 	}
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 		const struct drm_crtc_helper_funcs *funcs;
 
 		funcs = crtc->helper_private;
@@ -678,12 +680,12 @@ static void
 disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
 	struct drm_connector *connector;
-	struct drm_connector_state *old_conn_state;
+	struct drm_connector_state *old_conn_state, *new_conn_state;
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	int i;
 
-	for_each_connector_in_state(old_state, connector, old_conn_state, i) {
+	for_each_oldnew_connector_in_state(old_state, connector, old_conn_state, new_conn_state, i) {
 		const struct drm_encoder_helper_funcs *funcs;
 		struct drm_encoder *encoder;
 
@@ -720,7 +722,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 
 		/* Right function depends upon target state. */
 		if (funcs) {
-			if (connector->state->crtc && funcs->prepare)
+			if (new_conn_state->crtc && funcs->prepare)
 				funcs->prepare(encoder);
 			else if (funcs->disable)
 				funcs->disable(encoder);
@@ -731,11 +733,11 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 		drm_bridge_post_disable(encoder->bridge);
 	}
 
-	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
+	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
 		const struct drm_crtc_helper_funcs *funcs;
 
 		/* Shut down everything that needs a full modeset. */
-		if (!drm_atomic_crtc_needs_modeset(crtc->state))
+		if (!drm_atomic_crtc_needs_modeset(new_crtc_state))
 			continue;
 
 		if (!old_crtc_state->active)
@@ -748,7 +750,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 
 
 		/* Right function depends upon target state. */
-		if (crtc->state->enable && funcs->prepare)
+		if (new_crtc_state->enable && funcs->prepare)
 			funcs->prepare(crtc);
 		else if (funcs->atomic_disable)
 			funcs->atomic_disable(crtc, old_crtc_state);
@@ -777,13 +779,13 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
 					      struct drm_atomic_state *old_state)
 {
 	struct drm_connector *connector;
-	struct drm_connector_state *old_conn_state;
+	struct drm_connector_state *old_conn_state, *new_conn_state;
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state;
+	struct drm_crtc_state *crtc_state;
 	int i;
 
 	/* clear out existing links and update dpms */
-	for_each_connector_in_state(old_state, connector, old_conn_state, i) {
+	for_each_oldnew_connector_in_state(old_state, connector, old_conn_state, new_conn_state, i) {
 		if (connector->encoder) {
 			WARN_ON(!connector->encoder->crtc);
 
@@ -791,7 +793,7 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
 			connector->encoder = NULL;
 		}
 
-		crtc = connector->state->crtc;
+		crtc = new_conn_state->crtc;
 		if ((!crtc && old_conn_state->crtc) ||
 		    (crtc && drm_atomic_crtc_needs_modeset(crtc->state))) {
 			struct drm_property *dpms_prop =
@@ -808,23 +810,23 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
 	}
 
 	/* set new links */
-	for_each_connector_in_state(old_state, connector, old_conn_state, i) {
-		if (!connector->state->crtc)
+	for_each_new_connector_in_state(old_state, connector, new_conn_state, i) {
+		if (!new_conn_state->crtc)
 			continue;
 
-		if (WARN_ON(!connector->state->best_encoder))
+		if (WARN_ON(!new_conn_state->best_encoder))
 			continue;
 
-		connector->encoder = connector->state->best_encoder;
-		connector->encoder->crtc = connector->state->crtc;
+		connector->encoder = new_conn_state->best_encoder;
+		connector->encoder->crtc = new_conn_state->crtc;
 	}
 
 	/* set legacy state in the crtc structure */
-	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
+	for_each_new_crtc_in_state(old_state, crtc, crtc_state, i) {
 		struct drm_plane *primary = crtc->primary;
 
-		crtc->mode = crtc->state->mode;
-		crtc->enabled = crtc->state->enable;
+		crtc->mode = crtc_state->mode;
+		crtc->enabled = crtc_state->enable;
 
 		if (drm_atomic_get_existing_plane_state(old_state, primary) &&
 		    primary->state->crtc == crtc) {
@@ -832,9 +834,9 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
 			crtc->y = primary->state->src_y >> 16;
 		}
 
-		if (crtc->state->enable)
+		if (crtc_state->enable)
 			drm_calc_timestamping_constants(crtc,
-							&crtc->state->adjusted_mode);
+							&crtc_state->adjusted_mode);
 	}
 }
 EXPORT_SYMBOL(drm_atomic_helper_update_legacy_modeset_state);
@@ -843,20 +845,20 @@ static void
 crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state;
+	struct drm_crtc_state *crtc_state;
 	struct drm_connector *connector;
-	struct drm_connector_state *old_conn_state;
+	struct drm_connector_state *conn_state;
 	int i;
 
-	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
+	for_each_new_crtc_in_state(old_state, crtc, crtc_state, i) {
 		const struct drm_crtc_helper_funcs *funcs;
 
-		if (!crtc->state->mode_changed)
+		if (!crtc_state->mode_changed)
 			continue;
 
 		funcs = crtc->helper_private;
 
-		if (crtc->state->enable && funcs->mode_set_nofb) {
+		if (crtc_state->enable && funcs->mode_set_nofb) {
 			DRM_DEBUG_ATOMIC("modeset on [CRTC:%d:%s]\n",
 					 crtc->base.id, crtc->name);
 
@@ -864,18 +866,18 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
 		}
 	}
 
-	for_each_connector_in_state(old_state, connector, old_conn_state, i) {
+	for_each_new_connector_in_state(old_state, connector, conn_state, i) {
 		const struct drm_encoder_helper_funcs *funcs;
 		struct drm_crtc_state *new_crtc_state;
 		struct drm_encoder *encoder;
 		struct drm_display_mode *mode, *adjusted_mode;
 
-		if (!connector->state->best_encoder)
+		if (!conn_state->best_encoder)
 			continue;
 
-		encoder = connector->state->best_encoder;
+		encoder = conn_state->best_encoder;
 		funcs = encoder->helper_private;
-		new_crtc_state = connector->state->crtc->state;
+		new_crtc_state = conn_state->crtc->state;
 		mode = &new_crtc_state->mode;
 		adjusted_mode = &new_crtc_state->adjusted_mode;
 
@@ -891,7 +893,7 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
 		 */
 		if (funcs && funcs->atomic_mode_set) {
 			funcs->atomic_mode_set(encoder, new_crtc_state,
-					       connector->state);
+					       conn_state);
 		} else if (funcs && funcs->mode_set) {
 			funcs->mode_set(encoder, mode, adjusted_mode);
 		}
@@ -943,24 +945,24 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
 					      struct drm_atomic_state *old_state)
 {
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state;
+	struct drm_crtc_state *crtc_state;
 	struct drm_connector *connector;
-	struct drm_connector_state *old_conn_state;
+	struct drm_connector_state *conn_state;
 	int i;
 
-	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
+	for_each_new_crtc_in_state(old_state, crtc, crtc_state, i) {
 		const struct drm_crtc_helper_funcs *funcs;
 
 		/* Need to filter out CRTCs where only planes change. */
-		if (!drm_atomic_crtc_needs_modeset(crtc->state))
+		if (!drm_atomic_crtc_needs_modeset(crtc_state))
 			continue;
 
-		if (!crtc->state->active)
+		if (!crtc_state->active)
 			continue;
 
 		funcs = crtc->helper_private;
 
-		if (crtc->state->enable) {
+		if (crtc_state->enable) {
 			DRM_DEBUG_ATOMIC("enabling [CRTC:%d:%s]\n",
 					 crtc->base.id, crtc->name);
 
@@ -971,18 +973,18 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
 		}
 	}
 
-	for_each_connector_in_state(old_state, connector, old_conn_state, i) {
+	for_each_new_connector_in_state(old_state, connector, conn_state, i) {
 		const struct drm_encoder_helper_funcs *funcs;
 		struct drm_encoder *encoder;
 
-		if (!connector->state->best_encoder)
+		if (!conn_state->best_encoder)
 			continue;
 
-		if (!connector->state->crtc->state->active ||
-		    !drm_atomic_crtc_needs_modeset(connector->state->crtc->state))
+		if (!conn_state->crtc->state->active ||
+		    !drm_atomic_crtc_needs_modeset(conn_state->crtc->state))
 			continue;
 
-		encoder = connector->state->best_encoder;
+		encoder = conn_state->best_encoder;
 		funcs = encoder->helper_private;
 
 		DRM_DEBUG_ATOMIC("enabling [ENCODER:%d:%s]\n",
@@ -1027,10 +1029,7 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev,
 	struct drm_plane_state *plane_state;
 	int i, ret;
 
-	for_each_plane_in_state(state, plane, plane_state, i) {
-		if (!pre_swap)
-			plane_state = plane->state;
-
+	for_each_new_plane_in_state(state, plane, plane_state, i) {
 		if (!plane_state->fence)
 			continue;
 
@@ -1072,15 +1071,15 @@ bool drm_atomic_helper_framebuffer_changed(struct drm_device *dev,
 					   struct drm_crtc *crtc)
 {
 	struct drm_plane *plane;
-	struct drm_plane_state *old_plane_state;
+	struct drm_plane_state *old_plane_state, *new_plane_state;
 	int i;
 
-	for_each_plane_in_state(old_state, plane, old_plane_state, i) {
-		if (plane->state->crtc != crtc &&
+	for_each_oldnew_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
+		if (new_plane_state->crtc != crtc &&
 		    old_plane_state->crtc != crtc)
 			continue;
 
-		if (plane->state->fb != old_plane_state->fb)
+		if (new_plane_state->fb != old_plane_state->fb)
 			return true;
 	}
 
@@ -1104,21 +1103,21 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
 		struct drm_atomic_state *old_state)
 {
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	int i, ret;
 
-	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
+	/* Legacy cursor ioctls are completely unsynced, and userspace
+	 * relies on that (by doing tons of cursor updates). */
+	if (old_state->legacy_cursor_update)
+		return;
+
+	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
 		/* No one cares about the old state, so abuse it for tracking
 		 * and store whether we hold a vblank reference (and should do a
 		 * vblank wait) in the ->enable boolean. */
 		old_crtc_state->enable = false;
 
-		if (!crtc->state->enable)
-			continue;
-
-		/* Legacy cursor ioctls are completely unsynced, and userspace
-		 * relies on that (by doing tons of cursor updates). */
-		if (old_state->legacy_cursor_update)
+		if (!new_crtc_state->enable)
 			continue;
 
 		if (!drm_atomic_helper_framebuffer_changed(dev,
@@ -1133,7 +1132,7 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
 		old_crtc_state->last_vblank_count = drm_crtc_vblank_count(crtc);
 	}
 
-	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
+	for_each_old_crtc_in_state(old_state, crtc, old_crtc_state, i) {
 		if (!old_crtc_state->enable)
 			continue;
 
@@ -1432,11 +1431,11 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 				   bool nonblock)
 {
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *crtc_state;
+	struct drm_crtc_state *old_crtc_state, *crtc_state;
 	struct drm_crtc_commit *commit;
 	int i, ret;
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
 		commit = kzalloc(sizeof(*commit), GFP_KERNEL);
 		if (!commit)
 			return -ENOMEM;
@@ -1457,7 +1456,7 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 		/* Drivers only send out events when at least either current or
 		 * new CRTC state is active. Complete right away if everything
 		 * stays off. */
-		if (!crtc->state->active && !crtc_state->active) {
+		if (!old_crtc_state->active && !crtc_state->active) {
 			complete_all(&commit->flip_done);
 			continue;
 		}
@@ -1521,7 +1520,7 @@ void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *state)
 	int i;
 	long ret;
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 		spin_lock(&crtc->commit_lock);
 		commit = preceeding_commit(crtc);
 		if (commit)
@@ -1572,13 +1571,13 @@ void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *state)
 	struct drm_crtc_commit *commit;
 	int i;
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 		commit = state->crtcs[i].commit;
 		if (!commit)
 			continue;
 
 		/* backend must have consumed any event by now */
-		WARN_ON(crtc->state->event);
+		WARN_ON(crtc_state->event);
 		spin_lock(&crtc->commit_lock);
 		complete_all(&commit->hw_done);
 		spin_unlock(&crtc->commit_lock);
@@ -1605,7 +1604,7 @@ void drm_atomic_helper_commit_cleanup_done(struct drm_atomic_state *state)
 	int i;
 	long ret;
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 		commit = state->crtcs[i].commit;
 		if (WARN_ON(!commit))
 			continue;
@@ -1658,7 +1657,7 @@ int drm_atomic_helper_prepare_planes(struct drm_device *dev,
 	struct drm_plane_state *plane_state;
 	int ret, i, j;
 
-	for_each_plane_in_state(state, plane, plane_state, i) {
+	for_each_new_plane_in_state(state, plane, plane_state, i) {
 		const struct drm_plane_helper_funcs *funcs;
 
 		funcs = plane->helper_private;
@@ -1676,7 +1675,7 @@ int drm_atomic_helper_prepare_planes(struct drm_device *dev,
 	return 0;
 
 fail:
-	for_each_plane_in_state(state, plane, plane_state, j) {
+	for_each_new_plane_in_state(state, plane, plane_state, j) {
 		const struct drm_plane_helper_funcs *funcs;
 
 		if (j >= i)
@@ -1746,14 +1745,14 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 				     uint32_t flags)
 {
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct drm_plane *plane;
-	struct drm_plane_state *old_plane_state;
+	struct drm_plane_state *old_plane_state, *new_plane_state;
 	int i;
 	bool active_only = flags & DRM_PLANE_COMMIT_ACTIVE_ONLY;
 	bool no_disable = flags & DRM_PLANE_COMMIT_NO_DISABLE_AFTER_MODESET;
 
-	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
+	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
 		const struct drm_crtc_helper_funcs *funcs;
 
 		funcs = crtc->helper_private;
@@ -1761,13 +1760,13 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 		if (!funcs || !funcs->atomic_begin)
 			continue;
 
-		if (active_only && !crtc->state->active)
+		if (active_only && !new_crtc_state->active)
 			continue;
 
 		funcs->atomic_begin(crtc, old_crtc_state);
 	}
 
-	for_each_plane_in_state(old_state, plane, old_plane_state, i) {
+	for_each_oldnew_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
 		const struct drm_plane_helper_funcs *funcs;
 		bool disabling;
 
@@ -1786,7 +1785,7 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 			 * CRTC to avoid skipping planes being disabled on an
 			 * active CRTC.
 			 */
-			if (!disabling && !plane_crtc_active(plane->state))
+			if (!disabling && !plane_crtc_active(new_plane_state))
 				continue;
 			if (disabling && !plane_crtc_active(old_plane_state))
 				continue;
@@ -1805,12 +1804,12 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 				continue;
 
 			funcs->atomic_disable(plane, old_plane_state);
-		} else if (plane->state->crtc || disabling) {
+		} else if (new_plane_state->crtc || disabling) {
 			funcs->atomic_update(plane, old_plane_state);
 		}
 	}
 
-	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
+	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
 		const struct drm_crtc_helper_funcs *funcs;
 
 		funcs = crtc->helper_private;
@@ -1818,7 +1817,7 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 		if (!funcs || !funcs->atomic_flush)
 			continue;
 
-		if (active_only && !crtc->state->active)
+		if (active_only && !new_crtc_state->active)
 			continue;
 
 		funcs->atomic_flush(crtc, old_crtc_state);
@@ -1945,12 +1944,19 @@ void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
 				      struct drm_atomic_state *old_state)
 {
 	struct drm_plane *plane;
-	struct drm_plane_state *plane_state;
+	struct drm_plane_state *plane_state, *new_plane_state;
 	int i;
 
-	for_each_plane_in_state(old_state, plane, plane_state, i) {
+	for_each_oldnew_plane_in_state(old_state, plane, plane_state, new_plane_state, i) {
 		const struct drm_plane_helper_funcs *funcs;
 
+		/*
+		 * This might be called before swapping when commit is aborted,
+		 * in which case we have to free the new state.
+		 */
+		if (plane_state == plane->state)
+			plane_state = new_plane_state;
+
 		if (!drm_atomic_helper_framebuffer_changed(dev, old_state, plane_state->crtc))
 			continue;
 
@@ -1998,15 +2004,15 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,
 	int i;
 	long ret;
 	struct drm_connector *connector;
-	struct drm_connector_state *conn_state;
+	struct drm_connector_state *old_conn_state, *new_conn_state;
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct drm_plane *plane;
-	struct drm_plane_state *plane_state;
+	struct drm_plane_state *old_plane_state, *new_plane_state;
 	struct drm_crtc_commit *commit;
 
 	if (stall) {
-		for_each_crtc_in_state(state, crtc, crtc_state, i) {
+		for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
 			spin_lock(&crtc->commit_lock);
 			commit = list_first_entry_or_null(&crtc->commit_list,
 					struct drm_crtc_commit, commit_entry);
@@ -2026,16 +2032,20 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,
 		}
 	}
 
-	for_each_connector_in_state(state, connector, conn_state, i) {
-		connector->state->state = state;
-		swap(state->connectors[i].state, connector->state);
-		connector->state->state = NULL;
+	for_each_oldnew_connector_in_state(state, connector, old_conn_state, new_conn_state, i) {
+		old_conn_state->state = state;
+		new_conn_state->state = NULL;
+
+		state->connectors[i].state = old_conn_state;
+		connector->state = new_conn_state;
 	}
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
-		crtc->state->state = state;
-		swap(state->crtcs[i].state, crtc->state);
-		crtc->state->state = NULL;
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+		old_crtc_state->state = state;
+		new_crtc_state->state = NULL;
+
+		state->crtcs[i].state = old_crtc_state;
+		crtc->state = new_crtc_state;
 
 		if (state->crtcs[i].commit) {
 			spin_lock(&crtc->commit_lock);
@@ -2047,10 +2057,12 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,
 		}
 	}
 
-	for_each_plane_in_state(state, plane, plane_state, i) {
-		plane->state->state = state;
-		swap(state->planes[i].state, plane->state);
-		plane->state->state = NULL;
+	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
+		old_plane_state->state = state;
+		new_plane_state->state = NULL;
+
+		state->planes[i].state = old_plane_state;
+		plane->state = new_plane_state;
 	}
 }
 EXPORT_SYMBOL(drm_atomic_helper_swap_state);
@@ -2248,7 +2260,7 @@ static int update_output_state(struct drm_atomic_state *state,
 	if (ret)
 		return ret;
 
-	for_each_connector_in_state(state, connector, conn_state, i) {
+	for_each_new_connector_in_state(state, connector, conn_state, i) {
 		if (conn_state->crtc == set->crtc) {
 			ret = drm_atomic_set_crtc_for_connector(conn_state,
 								NULL);
@@ -2270,7 +2282,7 @@ static int update_output_state(struct drm_atomic_state *state,
 			return ret;
 	}
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 		/* Don't update ->enable for the CRTC in the set_config request,
 		 * since a mismatch would indicate a bug in the upper layers.
 		 * The actual modeset code later on will catch any
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 08/19] drm/vc4: Use new atomic iterator macros.
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (6 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 07/19] drm/atomic: Fix atomic helpers to use the new " Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-10-17 12:37 ` [PATCH 09/19] drm/rockchip: " Maarten Lankhorst
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/vc4/vc4_kms.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
index f31f72af8551..76cc9b374215 100644
--- a/drivers/gpu/drm/vc4/vc4_kms.c
+++ b/drivers/gpu/drm/vc4/vc4_kms.c
@@ -111,7 +111,7 @@ static int vc4_atomic_commit(struct drm_device *dev,
 	uint64_t wait_seqno = 0;
 	struct vc4_commit *c;
 	struct drm_plane *plane;
-	struct drm_plane_state *new_state;
+	struct drm_plane_state *old_state, *new_state;
 
 	c = commit_init(state);
 	if (!c)
@@ -139,8 +139,8 @@ static int vc4_atomic_commit(struct drm_device *dev,
 		return ret;
 	}
 
-	for_each_plane_in_state(state, plane, new_state, i) {
-		if ((plane->state->fb != new_state->fb) && new_state->fb) {
+	for_each_oldnew_plane_in_state(state, plane, old_state, new_state, i) {
+		if (old_state->fb != new_state->fb && new_state->fb) {
 			struct drm_gem_cma_object *cma_bo =
 				drm_fb_cma_get_gem_obj(new_state->fb, 0);
 			struct vc4_bo *bo = to_vc4_bo(&cma_bo->base);
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 09/19] drm/rockchip: Use new atomic iterator macros.
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (7 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 08/19] drm/vc4: Use new atomic " Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-10-17 12:37 ` [PATCH 10/19] drm/rcar-du: " Maarten Lankhorst
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index c7eba305c488..5c0625e5dca1 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -1009,7 +1009,7 @@ static void vop_crtc_atomic_flush(struct drm_crtc *crtc,
 				  struct drm_crtc_state *old_crtc_state)
 {
 	struct drm_atomic_state *old_state = old_crtc_state->state;
-	struct drm_plane_state *old_plane_state;
+	struct drm_plane_state *old_plane_state, *new_plane_state;
 	struct vop *vop = to_vop(crtc);
 	struct drm_plane *plane;
 	int i;
@@ -1040,11 +1040,11 @@ static void vop_crtc_atomic_flush(struct drm_crtc *crtc,
 	}
 	spin_unlock_irq(&crtc->dev->event_lock);
 
-	for_each_plane_in_state(old_state, plane, old_plane_state, i) {
+	for_each_oldnew_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
 		if (!old_plane_state->fb)
 			continue;
 
-		if (old_plane_state->fb == plane->state->fb)
+		if (old_plane_state->fb == new_plane_state->fb)
 			continue;
 
 		drm_framebuffer_reference(old_plane_state->fb);
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 10/19] drm/rcar-du: Use new atomic iterator macros.
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (8 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 09/19] drm/rockchip: " Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-10-17 12:37 ` [PATCH 11/19] drm/omap: " Maarten Lankhorst
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   | 2 +-
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index c76ed9ee6a01..153dafac753c 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -312,7 +312,7 @@ static int rcar_du_atomic_commit(struct drm_device *dev,
 	/* Wait until all affected CRTCs have completed previous commits and
 	 * mark them as pending.
 	 */
-	for_each_crtc_in_state(state, crtc, crtc_state, i)
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i)
 		commit->crtcs |= drm_crtc_mask(crtc);
 
 	spin_lock(&rcdu->commit.wait.lock);
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index a74f8ed8ca2e..b8c35ad9db34 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -144,7 +144,7 @@ int rcar_du_atomic_check_planes(struct drm_device *dev,
 	struct drm_plane_state *drm_plane_state;
 
 	/* Check if hardware planes need to be reallocated. */
-	for_each_plane_in_state(state, drm_plane, drm_plane_state, i) {
+	for_each_new_plane_in_state(state, drm_plane, drm_plane_state, i) {
 		struct rcar_du_plane_state *plane_state;
 		struct rcar_du_plane *plane;
 		unsigned int index;
@@ -246,7 +246,7 @@ int rcar_du_atomic_check_planes(struct drm_device *dev,
 	}
 
 	/* Reallocate hardware planes for each plane that needs it. */
-	for_each_plane_in_state(state, drm_plane, drm_plane_state, i) {
+	for_each_new_plane_in_state(state, drm_plane, drm_plane_state, i) {
 		struct rcar_du_plane_state *plane_state;
 		struct rcar_du_plane *plane;
 		unsigned int crtc_planes;
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 11/19] drm/omap: Use new atomic iterator macros
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (9 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 10/19] drm/rcar-du: " Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-10-17 12:37 ` [PATCH 12/19] drm/msm: " Maarten Lankhorst
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 1735c7accf72..74f9519878a2 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -69,13 +69,13 @@ struct omap_atomic_state_commit {
 static void omap_atomic_wait_for_completion(struct drm_device *dev,
 					    struct drm_atomic_state *old_state)
 {
-	struct drm_crtc_state *old_crtc_state;
+	struct drm_crtc_state *crtc_state;
 	struct drm_crtc *crtc;
 	unsigned int i;
 	int ret;
 
-	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
-		if (!crtc->state->enable)
+	for_each_new_crtc_in_state(old_state, crtc, crtc_state, i) {
+		if (!crtc_state->enable)
 			continue;
 
 		ret = omap_crtc_wait_pending(crtc);
@@ -164,7 +164,7 @@ static int omap_atomic_commit(struct drm_device *dev,
 	/* Wait until all affected CRTCs have completed previous commits and
 	 * mark them as pending.
 	 */
-	for_each_crtc_in_state(state, crtc, crtc_state, i)
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i)
 		commit->crtcs |= drm_crtc_mask(crtc);
 
 	wait_event(priv->commit.wait, !omap_atomic_is_pending(priv, commit));
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 12/19] drm/msm: Use new atomic iterator macros
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (10 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 11/19] drm/omap: " Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-11-03 16:37   ` [Intel-gfx] " Ville Syrjälä
  2016-10-17 12:37 ` [PATCH 13/19] drm/imx: " Maarten Lankhorst
                   ` (7 subsequent siblings)
  19 siblings, 1 reply; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c   |  4 ++--
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   |  6 +++---
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h   |  3 ++-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c |  4 ++--
 drivers/gpu/drm/msm/msm_atomic.c          | 16 ++++++++--------
 5 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
index 571a91ee9607..d18d0a0e0a35 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
@@ -113,7 +113,7 @@ static void mdp4_prepare_commit(struct msm_kms *kms, struct drm_atomic_state *st
 	mdp4_enable(mdp4_kms);
 
 	/* see 119ecb7fd */
-	for_each_crtc_in_state(state, crtc, crtc_state, i)
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i)
 		drm_crtc_vblank_get(crtc);
 }
 
@@ -125,7 +125,7 @@ static void mdp4_complete_commit(struct msm_kms *kms, struct drm_atomic_state *s
 	struct drm_crtc_state *crtc_state;
 
 	/* see 119ecb7fd */
-	for_each_crtc_in_state(state, crtc, crtc_state, i)
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i)
 		drm_crtc_vblank_put(crtc);
 
 	mdp4_disable(mdp4_kms);
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
index ed7143d35b25..7cfeb0455039 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
@@ -82,10 +82,10 @@ static void mdp5_complete_commit(struct msm_kms *kms, struct drm_atomic_state *s
 	int i;
 	struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
 	struct drm_plane *plane;
-	struct drm_plane_state *plane_state;
+	struct drm_plane_state *old_state, *new_state;
 
-	for_each_plane_in_state(state, plane, plane_state, i)
-		mdp5_plane_complete_commit(plane, plane_state);
+	for_each_oldnew_plane_in_state(state, plane, old_state, new_state, i)
+		mdp5_plane_complete_commit(plane, old_state, new_state);
 
 	mdp5_disable(mdp5_kms);
 }
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
index 03738927be10..90e80619fc54 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
@@ -198,7 +198,8 @@ void mdp5_irq_domain_fini(struct mdp5_kms *mdp5_kms);
 uint32_t mdp5_plane_get_flush(struct drm_plane *plane);
 void mdp5_plane_complete_flip(struct drm_plane *plane);
 void mdp5_plane_complete_commit(struct drm_plane *plane,
-	struct drm_plane_state *state);
+	struct drm_plane_state *old_state,
+	struct drm_plane_state *new_state);
 enum mdp5_pipe mdp5_plane_pipe(struct drm_plane *plane);
 struct drm_plane *mdp5_plane_init(struct drm_device *dev,
 		enum mdp5_pipe pipe, bool private_plane,
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index 951c002b05df..19c44b968f4e 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -859,13 +859,13 @@ uint32_t mdp5_plane_get_flush(struct drm_plane *plane)
 
 /* called after vsync in thread context */
 void mdp5_plane_complete_commit(struct drm_plane *plane,
-	struct drm_plane_state *state)
+	struct drm_plane_state *old_state, struct drm_plane_state *new_state)
 {
 	struct mdp5_kms *mdp5_kms = get_kms(plane);
 	struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
 	enum mdp5_pipe pipe = mdp5_plane->pipe;
 
-	if (!plane_enabled(plane->state) && mdp5_kms->smp) {
+	if (!plane_enabled(new_state) && mdp5_kms->smp) {
 		DBG("%s: free SMP", mdp5_plane->name);
 		mdp5_smp_release(mdp5_kms->smp, pipe);
 	}
diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c
index db193f835298..333c379e6561 100644
--- a/drivers/gpu/drm/msm/msm_atomic.c
+++ b/drivers/gpu/drm/msm/msm_atomic.c
@@ -89,8 +89,8 @@ static void msm_atomic_wait_for_commit_done(struct drm_device *dev,
 	struct msm_kms *kms = priv->kms;
 	int i;
 
-	for_each_crtc_in_state(old_state, crtc, crtc_state, i) {
-		if (!crtc->state->enable)
+	for_each_new_crtc_in_state(old_state, crtc, crtc_state, i) {
+		if (!crtc_state->enable)
 			continue;
 
 		/* Legacy cursor ioctls are completely unsynced, and userspace
@@ -191,7 +191,7 @@ int msm_atomic_commit(struct drm_device *dev,
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *crtc_state;
 	struct drm_plane *plane;
-	struct drm_plane_state *plane_state;
+	struct drm_plane_state *new_plane_state, *old_plane_state;
 	int i, ret;
 
 	ret = drm_atomic_helper_prepare_planes(dev, state);
@@ -207,18 +207,18 @@ int msm_atomic_commit(struct drm_device *dev,
 	/*
 	 * Figure out what crtcs we have:
 	 */
-	for_each_crtc_in_state(state, crtc, crtc_state, i)
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i)
 		c->crtc_mask |= drm_crtc_mask(crtc);
 
 	/*
 	 * Figure out what fence to wait for:
 	 */
-	for_each_plane_in_state(state, plane, plane_state, i) {
-		if ((plane->state->fb != plane_state->fb) && plane_state->fb) {
-			struct drm_gem_object *obj = msm_framebuffer_bo(plane_state->fb, 0);
+	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
+		if (old_plane_state->fb != new_plane_state->fb && new_plane_state->fb) {
+			struct drm_gem_object *obj = msm_framebuffer_bo(new_plane_state->fb, 0);
 			struct msm_gem_object *msm_obj = to_msm_bo(obj);
 
-			plane_state->fence = reservation_object_get_excl_rcu(msm_obj->resv);
+			new_plane_state->fence = reservation_object_get_excl_rcu(msm_obj->resv);
 		}
 	}
 
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 13/19] drm/imx: Use new atomic iterator macros
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (11 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 12/19] drm/msm: " Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-10-17 12:37 ` [PATCH 14/19] drm/mediatek: " Maarten Lankhorst
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/imx/imx-drm-core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index 98df09c2b388..d484af773460 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -155,7 +155,7 @@ static int imx_drm_atomic_commit(struct drm_device *dev,
 				 struct drm_atomic_state *state,
 				 bool nonblock)
 {
-	struct drm_plane_state *plane_state;
+	struct drm_plane_state *old_plane_state, *new_plane_state;
 	struct drm_plane *plane;
 	struct dma_buf *dma_buf;
 	int i;
@@ -164,13 +164,13 @@ static int imx_drm_atomic_commit(struct drm_device *dev,
 	 * If the plane fb has an dma-buf attached, fish out the exclusive
 	 * fence for the atomic helper to wait on.
 	 */
-	for_each_plane_in_state(state, plane, plane_state, i) {
-		if ((plane->state->fb != plane_state->fb) && plane_state->fb) {
-			dma_buf = drm_fb_cma_get_gem_obj(plane_state->fb,
+	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
+		if ((old_plane_state->fb != new_plane_state->fb) && new_plane_state->fb) {
+			dma_buf = drm_fb_cma_get_gem_obj(new_plane_state->fb,
 							 0)->base.dma_buf;
 			if (!dma_buf)
 				continue;
-			plane_state->fence =
+			new_plane_state->fence =
 				reservation_object_get_excl_rcu(dma_buf->resv);
 		}
 	}
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 14/19] drm/mediatek: Use new atomic iterator macros
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (12 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 13/19] drm/imx: " Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-11-03 16:39   ` Ville Syrjälä
  2016-10-17 12:37 ` [PATCH 15/19] drm/i915: Use new atomic iterator macros in ddi Maarten Lankhorst
                   ` (5 subsequent siblings)
  19 siblings, 1 reply; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index db61aa5f32ef..414e848d8cbf 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -50,8 +50,8 @@ static void mtk_atomic_wait_for_fences(struct drm_atomic_state *state)
 	struct drm_plane_state *plane_state;
 	int i;
 
-	for_each_plane_in_state(state, plane, plane_state, i)
-		mtk_fb_wait(plane->state->fb);
+	for_each_new_plane_in_state(state, plane, plane_state, i)
+		mtk_fb_wait(plane_state->fb);
 }
 
 static void mtk_atomic_complete(struct mtk_drm_private *private,
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 15/19] drm/i915: Use new atomic iterator macros in ddi
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (13 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 14/19] drm/mediatek: " Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-11-03 17:07   ` Ville Syrjälä
  2016-10-17 12:37 ` [PATCH 16/19] drm/i915: Use new atomic iterator macros in fbc Maarten Lankhorst
                   ` (4 subsequent siblings)
  19 siblings, 1 reply; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Also make the function static, it's only used inside intel_ddi.c

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_ddi.c | 4 ++--
 drivers/gpu/drm/i915/intel_drv.h | 2 --
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 15d47c87def6..0e79c84e14e0 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -740,7 +740,7 @@ intel_ddi_get_crtc_encoder(struct drm_crtc *crtc)
 	return ret;
 }
 
-struct intel_encoder *
+static struct intel_encoder *
 intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state)
 {
 	struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
@@ -753,7 +753,7 @@ intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state)
 
 	state = crtc_state->base.state;
 
-	for_each_connector_in_state(state, connector, connector_state, i) {
+	for_each_new_connector_in_state(state, connector, connector_state, i) {
 		if (connector_state->crtc != crtc_state->base.crtc)
 			continue;
 
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 8fd16adf069b..588d8af68043 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1156,8 +1156,6 @@ void intel_ddi_prepare_link_retrain(struct intel_dp *intel_dp);
 bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
 void intel_ddi_get_config(struct intel_encoder *encoder,
 			  struct intel_crtc_state *pipe_config);
-struct intel_encoder *
-intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state);
 
 void intel_ddi_init_dp_buf_reg(struct intel_encoder *encoder);
 void intel_ddi_clock_get(struct intel_encoder *encoder,
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 16/19] drm/i915: Use new atomic iterator macros in fbc
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (14 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 15/19] drm/i915: Use new atomic iterator macros in ddi Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-11-03 16:45   ` Ville Syrjälä
  2016-10-17 12:37 ` [PATCH 17/19] drm/i915: Use new atomic iterator macros in wm code Maarten Lankhorst
                   ` (3 subsequent siblings)
  19 siblings, 1 reply; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_fbc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
index faa67624e1ed..0028335fc1bb 100644
--- a/drivers/gpu/drm/i915/intel_fbc.c
+++ b/drivers/gpu/drm/i915/intel_fbc.c
@@ -1060,7 +1060,7 @@ void intel_fbc_choose_crtc(struct drm_i915_private *dev_priv,
 
 	mutex_lock(&fbc->lock);
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 		if (fbc->crtc == to_intel_crtc(crtc)) {
 			fbc_crtc_present = true;
 			break;
@@ -1074,14 +1074,14 @@ void intel_fbc_choose_crtc(struct drm_i915_private *dev_priv,
 	 * plane. We could go for fancier schemes such as checking the plane
 	 * size, but this would just affect the few platforms that don't tie FBC
 	 * to pipe or plane A. */
-	for_each_plane_in_state(state, plane, plane_state, i) {
+	for_each_new_plane_in_state(state, plane, plane_state, i) {
 		struct intel_plane_state *intel_plane_state =
 			to_intel_plane_state(plane_state);
 
 		if (!intel_plane_state->base.visible)
 			continue;
 
-		for_each_crtc_in_state(state, crtc, crtc_state, j) {
+		for_each_new_crtc_in_state(state, crtc, crtc_state, j) {
 			struct intel_crtc_state *intel_crtc_state =
 				to_intel_crtc_state(crtc_state);
 
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 17/19] drm/i915: Use new atomic iterator macros in wm code
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (15 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 16/19] drm/i915: Use new atomic iterator macros in fbc Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-11-03 16:49   ` [Intel-gfx] " Ville Syrjälä
  2016-10-17 12:37 ` [PATCH 18/19] drm/i915: Use new atomic iterator macros in display code Maarten Lankhorst
                   ` (2 subsequent siblings)
  19 siblings, 1 reply; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_pm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 2df06b703e3d..163b73b493bf 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -3227,7 +3227,7 @@ skl_get_total_relative_data_rate(struct intel_crtc_state *intel_cstate)
 		return 0;
 
 	/* Calculate and cache data rate for each plane */
-	for_each_plane_in_state(state, plane, pstate, i) {
+	for_each_new_plane_in_state(state, plane, pstate, i) {
 		id = skl_wm_plane_id(to_intel_plane(plane));
 		intel_plane = to_intel_plane(plane);
 
@@ -3364,14 +3364,14 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate,
 	alloc_size -= cursor_blocks;
 
 	/* 1. Allocate the mininum required blocks for each active plane */
-	for_each_plane_in_state(state, plane, pstate, i) {
+	for_each_new_plane_in_state(state, plane, pstate, i) {
 		intel_plane = to_intel_plane(plane);
 		id = skl_wm_plane_id(intel_plane);
 
 		if (intel_plane->pipe != pipe)
 			continue;
 
-		if (!to_intel_plane_state(pstate)->base.visible) {
+		if (!pstate->visible) {
 			minimum[id] = 0;
 			y_minimum[id] = 0;
 			continue;
@@ -3933,7 +3933,7 @@ pipes_modified(struct drm_atomic_state *state)
 	struct drm_crtc_state *cstate;
 	uint32_t i, ret = 0;
 
-	for_each_crtc_in_state(state, crtc, cstate, i)
+	for_each_new_crtc_in_state(state, crtc, cstate, i)
 		ret |= drm_crtc_mask(crtc);
 
 	return ret;
@@ -4048,7 +4048,7 @@ skl_compute_wm(struct drm_atomic_state *state)
 	 * since any racing commits that want to update them would need to
 	 * hold _all_ CRTC state mutexes.
 	 */
-	for_each_crtc_in_state(state, crtc, cstate, i)
+	for_each_new_crtc_in_state(state, crtc, cstate, i)
 		changed = true;
 	if (!changed)
 		return 0;
@@ -4070,7 +4070,7 @@ skl_compute_wm(struct drm_atomic_state *state)
 	 * should allow skl_update_pipe_wm() to return failure in cases where
 	 * no suitable watermark values can be found.
 	 */
-	for_each_crtc_in_state(state, crtc, cstate, i) {
+	for_each_new_crtc_in_state(state, crtc, cstate, i) {
 		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 		struct intel_crtc_state *intel_cstate =
 			to_intel_crtc_state(cstate);
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 18/19] drm/i915: Use new atomic iterator macros in display code
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (16 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 17/19] drm/i915: Use new atomic iterator macros in wm code Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-11-03 17:04   ` [Intel-gfx] " Ville Syrjälä
  2016-10-17 12:37 ` [PATCH 19/19] drm/atomic: Rename atomic oldnew iterator Maarten Lankhorst
  2016-10-17 13:25 ` ✗ Fi.CI.BAT: warning for drm/atomic: Use less confusing iterator names Patchwork
  19 siblings, 1 reply; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 156 ++++++++++++++++++-----------------
 1 file changed, 80 insertions(+), 76 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 3bd3f6a93c12..d310abace86a 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3510,7 +3510,12 @@ __intel_display_resume(struct drm_device *dev,
 	if (!state)
 		return 0;
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	/*
+	 * We've duplicated the state, pointers to the old state are invalid.
+	 *
+	 * Don't attempt to use the old state until we commit the duplicated state.
+	 */
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 		/*
 		 * Force recalculation even if we restore
 		 * current state. With fast modeset this may not result
@@ -5078,13 +5083,12 @@ static void intel_post_plane_update(struct intel_crtc_state *old_crtc_state)
 	}
 }
 
-static void intel_pre_plane_update(struct intel_crtc_state *old_crtc_state)
+static void intel_pre_plane_update(struct intel_crtc_state *old_crtc_state,
+				   struct intel_crtc_state *pipe_config)
 {
 	struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc);
 	struct drm_device *dev = crtc->base.dev;
 	struct drm_i915_private *dev_priv = to_i915(dev);
-	struct intel_crtc_state *pipe_config =
-		to_intel_crtc_state(crtc->base.state);
 	struct drm_atomic_state *old_state = old_crtc_state->base.state;
 	struct drm_plane *primary = crtc->base.primary;
 	struct drm_plane_state *old_pri_state =
@@ -5186,12 +5190,11 @@ static void intel_encoders_pre_pll_enable(struct drm_crtc *crtc,
 					  struct intel_crtc_state *crtc_state,
 					  struct drm_atomic_state *old_state)
 {
-	struct drm_connector_state *old_conn_state;
+	struct drm_connector_state *conn_state;
 	struct drm_connector *conn;
 	int i;
 
-	for_each_connector_in_state(old_state, conn, old_conn_state, i) {
-		struct drm_connector_state *conn_state = conn->state;
+	for_each_new_connector_in_state(old_state, conn, conn_state, i) {
 		struct intel_encoder *encoder =
 			to_intel_encoder(conn_state->best_encoder);
 
@@ -5207,12 +5210,11 @@ static void intel_encoders_pre_enable(struct drm_crtc *crtc,
 				      struct intel_crtc_state *crtc_state,
 				      struct drm_atomic_state *old_state)
 {
-	struct drm_connector_state *old_conn_state;
+	struct drm_connector_state *conn_state;
 	struct drm_connector *conn;
 	int i;
 
-	for_each_connector_in_state(old_state, conn, old_conn_state, i) {
-		struct drm_connector_state *conn_state = conn->state;
+	for_each_new_connector_in_state(old_state, conn, conn_state, i) {
 		struct intel_encoder *encoder =
 			to_intel_encoder(conn_state->best_encoder);
 
@@ -5228,12 +5230,11 @@ static void intel_encoders_enable(struct drm_crtc *crtc,
 				  struct intel_crtc_state *crtc_state,
 				  struct drm_atomic_state *old_state)
 {
-	struct drm_connector_state *old_conn_state;
+	struct drm_connector_state *conn_state;
 	struct drm_connector *conn;
 	int i;
 
-	for_each_connector_in_state(old_state, conn, old_conn_state, i) {
-		struct drm_connector_state *conn_state = conn->state;
+	for_each_new_connector_in_state(old_state, conn, conn_state, i) {
 		struct intel_encoder *encoder =
 			to_intel_encoder(conn_state->best_encoder);
 
@@ -5253,7 +5254,7 @@ static void intel_encoders_disable(struct drm_crtc *crtc,
 	struct drm_connector *conn;
 	int i;
 
-	for_each_connector_in_state(old_state, conn, old_conn_state, i) {
+	for_each_old_connector_in_state(old_state, conn, old_conn_state, i) {
 		struct intel_encoder *encoder =
 			to_intel_encoder(old_conn_state->best_encoder);
 
@@ -5273,7 +5274,7 @@ static void intel_encoders_post_disable(struct drm_crtc *crtc,
 	struct drm_connector *conn;
 	int i;
 
-	for_each_connector_in_state(old_state, conn, old_conn_state, i) {
+	for_each_old_connector_in_state(old_state, conn, old_conn_state, i) {
 		struct intel_encoder *encoder =
 			to_intel_encoder(old_conn_state->best_encoder);
 
@@ -5293,7 +5294,7 @@ static void intel_encoders_post_pll_disable(struct drm_crtc *crtc,
 	struct drm_connector *conn;
 	int i;
 
-	for_each_connector_in_state(old_state, conn, old_conn_state, i) {
+	for_each_old_connector_in_state(old_state, conn, old_conn_state, i) {
 		struct intel_encoder *encoder =
 			to_intel_encoder(old_conn_state->best_encoder);
 
@@ -6573,7 +6574,7 @@ static int intel_mode_max_pixclk(struct drm_device *dev,
 	memcpy(intel_state->min_pixclk, dev_priv->min_pixclk,
 	       sizeof(intel_state->min_pixclk));
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 		int pixclk = 0;
 
 		if (crtc_state->enable)
@@ -10238,7 +10239,7 @@ static int ilk_max_pixel_rate(struct drm_atomic_state *state)
 	memcpy(intel_state->min_pixclk, dev_priv->min_pixclk,
 	       sizeof(intel_state->min_pixclk));
 
-	for_each_crtc_in_state(state, crtc, cstate, i) {
+	for_each_new_crtc_in_state(state, crtc, cstate, i) {
 		int pixel_rate;
 
 		crtc_state = to_intel_crtc_state(cstate);
@@ -12530,7 +12531,7 @@ static bool check_single_encoder_cloning(struct drm_atomic_state *state,
 	struct drm_connector_state *connector_state;
 	int i;
 
-	for_each_connector_in_state(state, connector, connector_state, i) {
+	for_each_new_connector_in_state(state, connector, connector_state, i) {
 		if (connector_state->crtc != &crtc->base)
 			continue;
 
@@ -12700,7 +12701,7 @@ compute_baseline_pipe_bpp(struct intel_crtc *crtc,
 	state = pipe_config->base.state;
 
 	/* Clamp display bpp to EDID value */
-	for_each_connector_in_state(state, connector, connector_state, i) {
+	for_each_new_connector_in_state(state, connector, connector_state, i) {
 		if (connector_state->crtc != &crtc->base)
 			continue;
 
@@ -12992,7 +12993,7 @@ intel_modeset_pipe_config(struct drm_crtc *crtc,
 			       &pipe_config->pipe_src_w,
 			       &pipe_config->pipe_src_h);
 
-	for_each_connector_in_state(state, connector, connector_state, i) {
+	for_each_new_connector_in_state(state, connector, connector_state, i) {
 		if (connector_state->crtc != crtc)
 			continue;
 
@@ -13023,7 +13024,7 @@ encoder_retry:
 	 * adjust it according to limitations or connector properties, and also
 	 * a chance to reject the mode entirely.
 	 */
-	for_each_connector_in_state(state, connector, connector_state, i) {
+	for_each_new_connector_in_state(state, connector, connector_state, i) {
 		if (connector_state->crtc != crtc)
 			continue;
 
@@ -13072,16 +13073,16 @@ static void
 intel_modeset_update_crtc_state(struct drm_atomic_state *state)
 {
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *crtc_state;
+	struct drm_crtc_state *new_crtc_state;
 	int i;
 
 	/* Double check state. */
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
-		to_intel_crtc(crtc)->config = to_intel_crtc_state(crtc->state);
+	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
+		to_intel_crtc(crtc)->config = to_intel_crtc_state(new_crtc_state);
 
 		/* Update hwmode for vblank functions */
-		if (crtc->state->active)
-			crtc->hwmode = crtc->state->adjusted_mode;
+		if (new_crtc_state->active)
+			crtc->hwmode = new_crtc_state->adjusted_mode;
 		else
 			crtc->hwmode.crtc_clock = 0;
 
@@ -13753,21 +13754,21 @@ static void intel_modeset_clear_plls(struct drm_atomic_state *state)
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct intel_shared_dpll_config *shared_dpll = NULL;
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	int i;
 
 	if (!dev_priv->display.crtc_compute_clock)
 		return;
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 		struct intel_shared_dpll *old_dpll =
-			to_intel_crtc_state(crtc->state)->shared_dpll;
+			to_intel_crtc_state(old_crtc_state)->shared_dpll;
 
-		if (!needs_modeset(crtc_state))
+		if (!needs_modeset(new_crtc_state))
 			continue;
 
-		to_intel_crtc_state(crtc_state)->shared_dpll = NULL;
+		to_intel_crtc_state(new_crtc_state)->shared_dpll = NULL;
 
 		if (!old_dpll)
 			continue;
@@ -13796,7 +13797,7 @@ static int haswell_mode_set_planes_workaround(struct drm_atomic_state *state)
 	int i;
 
 	/* look at all crtc's that are going to be enabled in during modeset */
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 		intel_crtc = to_intel_crtc(crtc);
 
 		if (!crtc_state->active || !needs_modeset(crtc_state))
@@ -13878,7 +13879,7 @@ static int intel_modeset_checks(struct drm_atomic_state *state)
 	struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
 	struct drm_i915_private *dev_priv = to_i915(state->dev);
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	int ret = 0, i;
 
 	if (!check_digital_port_conflicts(state)) {
@@ -13889,13 +13890,13 @@ static int intel_modeset_checks(struct drm_atomic_state *state)
 	intel_state->modeset = true;
 	intel_state->active_crtcs = dev_priv->active_crtcs;
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
-		if (crtc_state->active)
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+		if (new_crtc_state->active)
 			intel_state->active_crtcs |= 1 << i;
 		else
 			intel_state->active_crtcs &= ~(1 << i);
 
-		if (crtc_state->active != crtc->state->active)
+		if (old_crtc_state->active != new_crtc_state->active)
 			intel_state->active_pipe_changes |= drm_crtc_mask(crtc);
 	}
 
@@ -13964,7 +13965,7 @@ static int intel_atomic_check(struct drm_device *dev,
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *crtc_state;
+	struct drm_crtc_state *old_crtc_state, *crtc_state;
 	int ret, i;
 	bool any_ms = false;
 
@@ -13972,12 +13973,12 @@ static int intel_atomic_check(struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
 		struct intel_crtc_state *pipe_config =
 			to_intel_crtc_state(crtc_state);
 
 		/* Catch I915_MODE_FLAG_INHERITED */
-		if (crtc_state->mode.private_flags != crtc->state->mode.private_flags)
+		if (crtc_state->mode.private_flags != old_crtc_state->mode.private_flags)
 			crtc_state->mode_changed = true;
 
 		if (!needs_modeset(crtc_state))
@@ -14004,7 +14005,7 @@ static int intel_atomic_check(struct drm_device *dev,
 
 		if (i915.fastboot &&
 		    intel_pipe_config_compare(dev,
-					to_intel_crtc_state(crtc->state),
+					to_intel_crtc_state(old_crtc_state),
 					pipe_config, true)) {
 			crtc_state->mode_changed = false;
 			to_intel_crtc_state(crtc_state)->update_pipe = true;
@@ -14049,7 +14050,7 @@ static int intel_atomic_prepare_commit(struct drm_device *dev,
 	struct drm_crtc *crtc;
 	int i, ret;
 
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
 		if (state->legacy_cursor_update)
 			continue;
 
@@ -14069,7 +14070,7 @@ static int intel_atomic_prepare_commit(struct drm_device *dev,
 	mutex_unlock(&dev->struct_mutex);
 
 	if (!ret && !nonblock) {
-		for_each_plane_in_state(state, plane, plane_state, i) {
+		for_each_new_plane_in_state(state, plane, plane_state, i) {
 			struct intel_plane_state *intel_plane_state =
 				to_intel_plane_state(plane_state);
 
@@ -14171,19 +14172,21 @@ static bool needs_vblank_wait(struct intel_crtc_state *crtc_state)
 static void intel_update_crtc(struct drm_crtc *crtc,
 			      struct drm_atomic_state *state,
 			      struct drm_crtc_state *old_crtc_state,
+			      struct drm_crtc_state *new_crtc_state,
 			      unsigned int *crtc_vblank_mask)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-	struct intel_crtc_state *pipe_config = to_intel_crtc_state(crtc->state);
-	bool modeset = needs_modeset(crtc->state);
+	struct intel_crtc_state *pipe_config = to_intel_crtc_state(new_crtc_state);
+	bool modeset = needs_modeset(new_crtc_state);
 
 	if (modeset) {
 		update_scanline_offset(intel_crtc);
 		dev_priv->display.crtc_enable(pipe_config, state);
 	} else {
-		intel_pre_plane_update(to_intel_crtc_state(old_crtc_state));
+		intel_pre_plane_update(to_intel_crtc_state(old_crtc_state),
+				       pipe_config);
 	}
 
 	if (drm_atomic_get_existing_plane_state(state, crtc->primary)) {
@@ -14202,15 +14205,15 @@ static void intel_update_crtcs(struct drm_atomic_state *state,
 			       unsigned int *crtc_vblank_mask)
 {
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	int i;
 
-	for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
-		if (!crtc->state->active)
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+		if (!new_crtc_state->active)
 			continue;
 
 		intel_update_crtc(crtc, state, old_crtc_state,
-				  crtc_vblank_mask);
+				  new_crtc_state, crtc_vblank_mask);
 	}
 }
 
@@ -14221,7 +14224,7 @@ static void skl_update_crtcs(struct drm_atomic_state *state,
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct skl_ddb_allocation *new_ddb = &intel_state->wm_results.ddb;
 	struct skl_ddb_allocation *cur_ddb = &dev_priv->wm.skl_hw.ddb;
 	unsigned int updated = 0;
@@ -14238,12 +14241,12 @@ static void skl_update_crtcs(struct drm_atomic_state *state,
 		int i;
 		progress = false;
 
-		for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
+		for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 			bool vbl_wait = false;
 			unsigned int cmask = drm_crtc_mask(crtc);
 			pipe = to_intel_crtc(crtc)->pipe;
 
-			if (updated & cmask || !crtc->state->active)
+			if (updated & cmask || !new_crtc_state->active)
 				continue;
 			if (skl_ddb_allocation_overlaps(state, cur_ddb, new_ddb,
 							pipe))
@@ -14258,12 +14261,12 @@ static void skl_update_crtcs(struct drm_atomic_state *state,
 			 * new ddb allocation to take effect.
 			 */
 			if (!skl_ddb_allocation_equals(cur_ddb, new_ddb, pipe) &&
-			    !crtc->state->active_changed &&
+			    !new_crtc_state->active_changed &&
 			    intel_state->wm_results.dirty_pipes != updated)
 				vbl_wait = true;
 
 			intel_update_crtc(crtc, state, old_crtc_state,
-					  crtc_vblank_mask);
+					  new_crtc_state, crtc_vblank_mask);
 
 			if (vbl_wait)
 				intel_wait_for_vblank(dev, pipe);
@@ -14278,7 +14281,7 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
 	struct drm_device *dev = state->dev;
 	struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
 	struct drm_i915_private *dev_priv = to_i915(dev);
-	struct drm_crtc_state *old_crtc_state;
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct drm_crtc *crtc;
 	struct intel_crtc_state *intel_cstate;
 	struct drm_plane *plane;
@@ -14288,7 +14291,7 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
 	unsigned crtc_vblank_mask = 0;
 	int i, ret;
 
-	for_each_plane_in_state(state, plane, plane_state, i) {
+	for_each_new_plane_in_state(state, plane, plane_state, i) {
 		struct intel_plane_state *intel_plane_state =
 			to_intel_plane_state(plane_state);
 
@@ -14313,22 +14316,23 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
 		intel_display_power_get(dev_priv, POWER_DOMAIN_MODESET);
 	}
 
-	for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 
-		if (needs_modeset(crtc->state) ||
-		    to_intel_crtc_state(crtc->state)->update_pipe) {
+		if (needs_modeset(new_crtc_state) ||
+		    to_intel_crtc_state(new_crtc_state)->update_pipe) {
 			hw_check = true;
 
 			put_domains[to_intel_crtc(crtc)->pipe] =
 				modeset_get_crtc_power_domains(crtc,
-					to_intel_crtc_state(crtc->state));
+					to_intel_crtc_state(new_crtc_state));
 		}
 
-		if (!needs_modeset(crtc->state))
+		if (!needs_modeset(new_crtc_state))
 			continue;
 
-		intel_pre_plane_update(to_intel_crtc_state(old_crtc_state));
+		intel_pre_plane_update(to_intel_crtc_state(old_crtc_state),
+				       to_intel_crtc_state(new_crtc_state));
 
 		if (old_crtc_state->active) {
 			intel_crtc_disable_planes(crtc, old_crtc_state->plane_mask);
@@ -14372,16 +14376,16 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
 	}
 
 	/* Complete the events for pipes that have now been disabled */
-	for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
-		bool modeset = needs_modeset(crtc->state);
+	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
+		bool modeset = needs_modeset(new_crtc_state);
 
 		/* Complete events for now disable pipes here. */
-		if (modeset && !crtc->state->active && crtc->state->event) {
+		if (modeset && !new_crtc_state->active && new_crtc_state->event) {
 			spin_lock_irq(&dev->event_lock);
-			drm_crtc_send_vblank_event(crtc, crtc->state->event);
+			drm_crtc_send_vblank_event(crtc, new_crtc_state->event);
 			spin_unlock_irq(&dev->event_lock);
 
-			crtc->state->event = NULL;
+			new_crtc_state->event = NULL;
 		}
 	}
 
@@ -14407,20 +14411,20 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
 	 *
 	 * TODO: Move this (and other cleanup) to an async worker eventually.
 	 */
-	for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
-		intel_cstate = to_intel_crtc_state(crtc->state);
+	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
+		intel_cstate = to_intel_crtc_state(new_crtc_state);
 
 		if (dev_priv->display.optimize_watermarks)
 			dev_priv->display.optimize_watermarks(intel_cstate);
 	}
 
-	for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
+	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		intel_post_plane_update(to_intel_crtc_state(old_crtc_state));
 
 		if (put_domains[i])
 			modeset_put_power_domains(dev_priv, put_domains[i]);
 
-		intel_modeset_verify_crtc(crtc, old_crtc_state, crtc->state);
+		intel_modeset_verify_crtc(crtc, old_crtc_state, new_crtc_state);
 	}
 
 	if (IS_SKYLAKE(dev_priv) && intel_state->modeset &&
@@ -14464,13 +14468,13 @@ static void intel_atomic_commit_work(struct work_struct *work)
 
 static void intel_atomic_track_fbs(struct drm_atomic_state *state)
 {
-	struct drm_plane_state *old_plane_state;
+	struct drm_plane_state *old_plane_state, *new_plane_state;
 	struct drm_plane *plane;
 	int i;
 
-	for_each_plane_in_state(state, plane, old_plane_state, i)
+	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i)
 		i915_gem_track_fb(intel_fb_obj(old_plane_state->fb),
-				  intel_fb_obj(plane->state->fb),
+				  intel_fb_obj(new_plane_state->fb),
 				  to_intel_plane(plane)->frontbuffer_bit);
 }
 
@@ -16299,7 +16303,7 @@ retry:
 	}
 
 	/* Write calculated watermark values back */
-	for_each_crtc_in_state(state, crtc, cstate, i) {
+	for_each_new_crtc_in_state(state, crtc, cstate, i) {
 		struct intel_crtc_state *cs = to_intel_crtc_state(cstate);
 
 		cs->wm.need_postvbl_update = true;
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH 19/19] drm/atomic: Rename atomic oldnew iterator
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (17 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 18/19] drm/i915: Use new atomic iterator macros in display code Maarten Lankhorst
@ 2016-10-17 12:37 ` Maarten Lankhorst
  2016-11-03 17:11   ` [Intel-gfx] " Ville Syrjälä
  2016-10-17 13:25 ` ✗ Fi.CI.BAT: warning for drm/atomic: Use less confusing iterator names Patchwork
  19 siblings, 1 reply; 45+ messages in thread
From: Maarten Lankhorst @ 2016-10-17 12:37 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

With the old users of for_each_obj_in_state gone, we can rename
for_each_oldnew_obj_in_state back to that name. It's slightly less
ugly.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/drm_atomic_helper.c         | 34 ++++++++++++++---------------
 drivers/gpu/drm/drm_blend.c                 |  4 ++--
 drivers/gpu/drm/i915/intel_display.c        | 16 +++++++-------
 drivers/gpu/drm/imx/imx-drm-core.c          |  2 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c     |  2 +-
 drivers/gpu/drm/msm/msm_atomic.c            |  2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c |  2 +-
 drivers/gpu/drm/vc4/vc4_kms.c               |  2 +-
 include/drm/drm_atomic.h                    | 30 +++----------------------
 9 files changed, 35 insertions(+), 59 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index c8aba493fc17..8fb955181641 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -241,7 +241,7 @@ steal_encoder(struct drm_atomic_state *state,
 	struct drm_connector_state *old_connector_state, *new_connector_state;
 	int i;
 
-	for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i) {
+	for_each_connector_in_state(state, connector, old_connector_state, new_connector_state, i) {
 		struct drm_crtc *encoder_crtc;
 
 		if (new_connector_state->best_encoder != encoder)
@@ -482,7 +482,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 	struct drm_connector_state *old_connector_state, *new_connector_state;
 	int i, ret;
 
-	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		if (!drm_mode_equal(&old_crtc_state->mode, &new_crtc_state->mode)) {
 			DRM_DEBUG_ATOMIC("[CRTC:%d:%s] mode changed\n",
 					 crtc->base.id, crtc->name);
@@ -510,7 +510,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i) {
+	for_each_connector_in_state(state, connector, old_connector_state, new_connector_state, i) {
 		/*
 		 * This only sets crtc->connectors_changed for routing changes,
 		 * drivers must set crtc->connectors_changed themselves when
@@ -529,7 +529,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 	 * configuration. This must be done before calling mode_fixup in case a
 	 * crtc only changed its mode but has the same set of connectors.
 	 */
-	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		bool has_connectors =
 			!!new_crtc_state->connector_mask;
 
@@ -685,7 +685,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	int i;
 
-	for_each_oldnew_connector_in_state(old_state, connector, old_conn_state, new_conn_state, i) {
+	for_each_connector_in_state(old_state, connector, old_conn_state, new_conn_state, i) {
 		const struct drm_encoder_helper_funcs *funcs;
 		struct drm_encoder *encoder;
 
@@ -733,7 +733,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 		drm_bridge_post_disable(encoder->bridge);
 	}
 
-	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
+	for_each_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
 		const struct drm_crtc_helper_funcs *funcs;
 
 		/* Shut down everything that needs a full modeset. */
@@ -785,7 +785,7 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
 	int i;
 
 	/* clear out existing links and update dpms */
-	for_each_oldnew_connector_in_state(old_state, connector, old_conn_state, new_conn_state, i) {
+	for_each_connector_in_state(old_state, connector, old_conn_state, new_conn_state, i) {
 		if (connector->encoder) {
 			WARN_ON(!connector->encoder->crtc);
 
@@ -1074,7 +1074,7 @@ bool drm_atomic_helper_framebuffer_changed(struct drm_device *dev,
 	struct drm_plane_state *old_plane_state, *new_plane_state;
 	int i;
 
-	for_each_oldnew_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
+	for_each_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
 		if (new_plane_state->crtc != crtc &&
 		    old_plane_state->crtc != crtc)
 			continue;
@@ -1111,7 +1111,7 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
 	if (old_state->legacy_cursor_update)
 		return;
 
-	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
+	for_each_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
 		/* No one cares about the old state, so abuse it for tracking
 		 * and store whether we hold a vblank reference (and should do a
 		 * vblank wait) in the ->enable boolean. */
@@ -1435,7 +1435,7 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 	struct drm_crtc_commit *commit;
 	int i, ret;
 
-	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
+	for_each_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
 		commit = kzalloc(sizeof(*commit), GFP_KERNEL);
 		if (!commit)
 			return -ENOMEM;
@@ -1752,7 +1752,7 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 	bool active_only = flags & DRM_PLANE_COMMIT_ACTIVE_ONLY;
 	bool no_disable = flags & DRM_PLANE_COMMIT_NO_DISABLE_AFTER_MODESET;
 
-	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
+	for_each_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
 		const struct drm_crtc_helper_funcs *funcs;
 
 		funcs = crtc->helper_private;
@@ -1766,7 +1766,7 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 		funcs->atomic_begin(crtc, old_crtc_state);
 	}
 
-	for_each_oldnew_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
+	for_each_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
 		const struct drm_plane_helper_funcs *funcs;
 		bool disabling;
 
@@ -1809,7 +1809,7 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
 		}
 	}
 
-	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
+	for_each_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
 		const struct drm_crtc_helper_funcs *funcs;
 
 		funcs = crtc->helper_private;
@@ -1947,7 +1947,7 @@ void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
 	struct drm_plane_state *plane_state, *new_plane_state;
 	int i;
 
-	for_each_oldnew_plane_in_state(old_state, plane, plane_state, new_plane_state, i) {
+	for_each_plane_in_state(old_state, plane, plane_state, new_plane_state, i) {
 		const struct drm_plane_helper_funcs *funcs;
 
 		/*
@@ -2032,7 +2032,7 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,
 		}
 	}
 
-	for_each_oldnew_connector_in_state(state, connector, old_conn_state, new_conn_state, i) {
+	for_each_connector_in_state(state, connector, old_conn_state, new_conn_state, i) {
 		old_conn_state->state = state;
 		new_conn_state->state = NULL;
 
@@ -2040,7 +2040,7 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,
 		connector->state = new_conn_state;
 	}
 
-	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		old_crtc_state->state = state;
 		new_crtc_state->state = NULL;
 
@@ -2057,7 +2057,7 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,
 		}
 	}
 
-	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
+	for_each_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
 		old_plane_state->state = state;
 		new_plane_state->state = NULL;
 
diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c
index 70c03eb032fc..ed8e366f1c02 100644
--- a/drivers/gpu/drm/drm_blend.c
+++ b/drivers/gpu/drm/drm_blend.c
@@ -372,7 +372,7 @@ int drm_atomic_normalize_zpos(struct drm_device *dev,
 	struct drm_plane_state *old_plane_state, *new_plane_state;
 	int i, ret = 0;
 
-	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
+	for_each_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
 		crtc = new_plane_state->crtc;
 		if (!crtc)
 			continue;
@@ -383,7 +383,7 @@ int drm_atomic_normalize_zpos(struct drm_device *dev,
 		}
 	}
 
-	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		if (old_crtc_state->plane_mask != new_crtc_state->plane_mask ||
 		    new_crtc_state->zpos_changed) {
 			ret = drm_atomic_helper_crtc_normalize_zpos(crtc,
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index d310abace86a..bac0fc342f8d 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13760,7 +13760,7 @@ static void intel_modeset_clear_plls(struct drm_atomic_state *state)
 	if (!dev_priv->display.crtc_compute_clock)
 		return;
 
-	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 		struct intel_shared_dpll *old_dpll =
 			to_intel_crtc_state(old_crtc_state)->shared_dpll;
@@ -13890,7 +13890,7 @@ static int intel_modeset_checks(struct drm_atomic_state *state)
 	intel_state->modeset = true;
 	intel_state->active_crtcs = dev_priv->active_crtcs;
 
-	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		if (new_crtc_state->active)
 			intel_state->active_crtcs |= 1 << i;
 		else
@@ -13973,7 +13973,7 @@ static int intel_atomic_check(struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
+	for_each_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
 		struct intel_crtc_state *pipe_config =
 			to_intel_crtc_state(crtc_state);
 
@@ -14208,7 +14208,7 @@ static void intel_update_crtcs(struct drm_atomic_state *state,
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	int i;
 
-	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		if (!new_crtc_state->active)
 			continue;
 
@@ -14241,7 +14241,7 @@ static void skl_update_crtcs(struct drm_atomic_state *state,
 		int i;
 		progress = false;
 
-		for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+		for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 			bool vbl_wait = false;
 			unsigned int cmask = drm_crtc_mask(crtc);
 			pipe = to_intel_crtc(crtc)->pipe;
@@ -14316,7 +14316,7 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
 		intel_display_power_get(dev_priv, POWER_DOMAIN_MODESET);
 	}
 
-	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 
 		if (needs_modeset(new_crtc_state) ||
@@ -14418,7 +14418,7 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
 			dev_priv->display.optimize_watermarks(intel_cstate);
 	}
 
-	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
 		intel_post_plane_update(to_intel_crtc_state(old_crtc_state));
 
 		if (put_domains[i])
@@ -14472,7 +14472,7 @@ static void intel_atomic_track_fbs(struct drm_atomic_state *state)
 	struct drm_plane *plane;
 	int i;
 
-	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i)
+	for_each_plane_in_state(state, plane, old_plane_state, new_plane_state, i)
 		i915_gem_track_fb(intel_fb_obj(old_plane_state->fb),
 				  intel_fb_obj(new_plane_state->fb),
 				  to_intel_plane(plane)->frontbuffer_bit);
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index d484af773460..48be1483b263 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -164,7 +164,7 @@ static int imx_drm_atomic_commit(struct drm_device *dev,
 	 * If the plane fb has an dma-buf attached, fish out the exclusive
 	 * fence for the atomic helper to wait on.
 	 */
-	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
+	for_each_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
 		if ((old_plane_state->fb != new_plane_state->fb) && new_plane_state->fb) {
 			dma_buf = drm_fb_cma_get_gem_obj(new_plane_state->fb,
 							 0)->base.dma_buf;
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
index 7cfeb0455039..398e2e9a4135 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
@@ -84,7 +84,7 @@ static void mdp5_complete_commit(struct msm_kms *kms, struct drm_atomic_state *s
 	struct drm_plane *plane;
 	struct drm_plane_state *old_state, *new_state;
 
-	for_each_oldnew_plane_in_state(state, plane, old_state, new_state, i)
+	for_each_plane_in_state(state, plane, old_state, new_state, i)
 		mdp5_plane_complete_commit(plane, old_state, new_state);
 
 	mdp5_disable(mdp5_kms);
diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c
index 333c379e6561..5508e3a2e4ef 100644
--- a/drivers/gpu/drm/msm/msm_atomic.c
+++ b/drivers/gpu/drm/msm/msm_atomic.c
@@ -213,7 +213,7 @@ int msm_atomic_commit(struct drm_device *dev,
 	/*
 	 * Figure out what fence to wait for:
 	 */
-	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
+	for_each_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
 		if (old_plane_state->fb != new_plane_state->fb && new_plane_state->fb) {
 			struct drm_gem_object *obj = msm_framebuffer_bo(new_plane_state->fb, 0);
 			struct msm_gem_object *msm_obj = to_msm_bo(obj);
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 5c0625e5dca1..7a0806c24776 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -1040,7 +1040,7 @@ static void vop_crtc_atomic_flush(struct drm_crtc *crtc,
 	}
 	spin_unlock_irq(&crtc->dev->event_lock);
 
-	for_each_oldnew_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
+	for_each_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
 		if (!old_plane_state->fb)
 			continue;
 
diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
index 76cc9b374215..d9329a918014 100644
--- a/drivers/gpu/drm/vc4/vc4_kms.c
+++ b/drivers/gpu/drm/vc4/vc4_kms.c
@@ -139,7 +139,7 @@ static int vc4_atomic_commit(struct drm_device *dev,
 		return ret;
 	}
 
-	for_each_oldnew_plane_in_state(state, plane, old_state, new_state, i) {
+	for_each_plane_in_state(state, plane, old_state, new_state, i) {
 		if (old_state->fb != new_state->fb && new_state->fb) {
 			struct drm_gem_cma_object *cma_bo =
 				drm_fb_cma_get_gem_obj(new_state->fb, 0);
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 09fb6b316ca9..c02ea85de9ca 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -364,15 +364,7 @@ int __must_check drm_atomic_check_only(struct drm_atomic_state *state);
 int __must_check drm_atomic_commit(struct drm_atomic_state *state);
 int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
 
-#define for_each_connector_in_state(__state, connector, connector_state, __i) \
-	for ((__i) = 0;							\
-	     (__i) < (__state)->num_connector &&				\
-	     ((connector) = (__state)->connectors[__i].ptr,			\
-	     (connector_state) = (__state)->connectors[__i].state, 1); 	\
-	     (__i)++)							\
-		for_each_if (connector)
-
-#define for_each_oldnew_connector_in_state(__state, connector, old_connector_state, new_connector_state, __i) \
+#define for_each_connector_in_state(__state, connector, old_connector_state, new_connector_state, __i) \
 	for ((__i) = 0;								\
 	     (__i) < (__state)->num_connector &&				\
 	     ((connector) = (__state)->connectors[__i].ptr,			\
@@ -397,15 +389,7 @@ int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
 	     (__i)++)							\
 		for_each_if (connector)
 
-#define for_each_crtc_in_state(__state, crtc, crtc_state, __i)	\
-	for ((__i) = 0;						\
-	     (__i) < (__state)->dev->mode_config.num_crtc &&	\
-	     ((crtc) = (__state)->crtcs[__i].ptr,			\
-	     (crtc_state) = (__state)->crtcs[__i].state, 1);	\
-	     (__i)++)						\
-		for_each_if (crtc_state)
-
-#define for_each_oldnew_crtc_in_state(__state, crtc, old_crtc_state, new_crtc_state, __i) \
+#define for_each_crtc_in_state(__state, crtc, old_crtc_state, new_crtc_state, __i) \
 	for ((__i) = 0;							\
 	     (__i) < (__state)->dev->mode_config.num_crtc &&		\
 	     ((crtc) = (__state)->crtcs[__i].ptr,			\
@@ -430,15 +414,7 @@ int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
 	     (__i)++)							\
 		for_each_if (crtc)
 
-#define for_each_plane_in_state(__state, plane, plane_state, __i)		\
-	for ((__i) = 0;							\
-	     (__i) < (__state)->dev->mode_config.num_total_plane &&	\
-	     ((plane) = (__state)->planes[__i].ptr,				\
-	     (plane_state) = (__state)->planes[__i].state, 1);		\
-	     (__i)++)							\
-		for_each_if (plane_state)
-
-#define for_each_oldnew_plane_in_state(__state, plane, old_plane_state, new_plane_state, __i) \
+#define for_each_plane_in_state(__state, plane, old_plane_state, new_plane_state, __i) \
 	for ((__i) = 0;							\
 	     (__i) < (__state)->dev->mode_config.num_total_plane &&	\
 	     ((plane) = (__state)->planes[__i].ptr,			\
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* ✗ Fi.CI.BAT: warning for drm/atomic: Use less confusing iterator names.
  2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
                   ` (18 preceding siblings ...)
  2016-10-17 12:37 ` [PATCH 19/19] drm/atomic: Rename atomic oldnew iterator Maarten Lankhorst
@ 2016-10-17 13:25 ` Patchwork
  19 siblings, 0 replies; 45+ messages in thread
From: Patchwork @ 2016-10-17 13:25 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx

== Series Details ==

Series: drm/atomic: Use less confusing iterator names.
URL   : https://patchwork.freedesktop.org/series/13869/
State : warning

== Summary ==

Series 13869v1 drm/atomic: Use less confusing iterator names.
https://patchwork.freedesktop.org/api/1.0/series/13869/revisions/1/mbox/

Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                dmesg-warn -> PASS       (fi-byt-j1900)
Test vgem_basic:
        Subgroup unload:
                pass       -> SKIP       (fi-hsw-4770)
                pass       -> SKIP       (fi-kbl-7200u)
                skip       -> PASS       (fi-skl-6770hq)

fi-bdw-5557u     total:246  pass:231  dwarn:0   dfail:0   fail:0   skip:15 
fi-bsw-n3050     total:246  pass:204  dwarn:0   dfail:0   fail:0   skip:42 
fi-byt-j1900     total:246  pass:213  dwarn:1   dfail:0   fail:1   skip:31 
fi-byt-n2820     total:246  pass:210  dwarn:0   dfail:0   fail:1   skip:35 
fi-hsw-4770      total:246  pass:223  dwarn:0   dfail:0   fail:0   skip:23 
fi-hsw-4770r     total:246  pass:224  dwarn:0   dfail:0   fail:0   skip:22 
fi-ilk-650       total:246  pass:184  dwarn:0   dfail:0   fail:2   skip:60 
fi-ivb-3520m     total:246  pass:221  dwarn:0   dfail:0   fail:0   skip:25 
fi-ivb-3770      total:246  pass:221  dwarn:0   dfail:0   fail:0   skip:25 
fi-kbl-7200u     total:246  pass:221  dwarn:0   dfail:0   fail:0   skip:25 
fi-skl-6260u     total:246  pass:232  dwarn:0   dfail:0   fail:0   skip:14 
fi-skl-6700hq    total:246  pass:223  dwarn:0   dfail:0   fail:0   skip:23 
fi-skl-6700k     total:246  pass:221  dwarn:1   dfail:0   fail:0   skip:24 
fi-skl-6770hq    total:246  pass:230  dwarn:1   dfail:0   fail:1   skip:14 
fi-snb-2520m     total:246  pass:210  dwarn:0   dfail:0   fail:0   skip:36 
fi-snb-2600      total:246  pass:209  dwarn:0   dfail:0   fail:0   skip:37 

Results at /archive/results/CI_IGT_test/Patchwork_2737/

15dfed2b90e84e7c277f81842fc3f19355293061 drm-intel-nightly: 2016y-10m-16d-23h-15m-00s UTC integration manifest
ea8593b drm/atomic: Use new atomic iterator macros.
57e7629 drm/atomic: Make add_affected_connectors look at crtc_state.
288fbb6 drm/blend: Use new atomic iterator macros.
18176fd drm/exynos: Use new atomic iterator macros.
19b0930 drm/atmel-hlcdc: Use new atomic iterator macros.
caf279e drm/atomic: Add new iterators over all state

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

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [Intel-gfx] [PATCH 01/19] drm/atomic: Add new iterators over all state
  2016-10-17 12:37 ` [PATCH 01/19] drm/atomic: Add new iterators over all state Maarten Lankhorst
@ 2016-11-01 13:09   ` Ville Syrjälä
  2016-11-01 13:34     ` Maarten Lankhorst
  0 siblings, 1 reply; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-01 13:09 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx, dri-devel

On Mon, Oct 17, 2016 at 02:37:00PM +0200, Maarten Lankhorst wrote:
> Add for_each_(old)(new)_(plane,connector,crtc)_in_state iterators to
> replace the old for_each_xxx_in_state ones. This is useful for >1 flip
> depth and getting rid of all xxx->state dereferences.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_atomic.c         |  6 +++
>  drivers/gpu/drm/drm_atomic_helper.c  | 52 +++++++++++++++++++++--
>  drivers/gpu/drm/i915/intel_display.c | 11 ++---
>  include/drm/drm_atomic.h             | 81 ++++++++++++++++++++++++++++++++++--
>  include/drm/drm_atomic_helper.h      |  3 ++
>  5 files changed, 142 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 5dd70540219c..120775fcfb70 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -278,6 +278,8 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
>  		return ERR_PTR(-ENOMEM);
>  
>  	state->crtcs[index].state = crtc_state;
> +	state->crtcs[index].old_state = crtc->state;
> +	state->crtcs[index].new_state = crtc_state;
>  	state->crtcs[index].ptr = crtc;
>  	crtc_state->state = state;
>  
> @@ -640,6 +642,8 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,
>  
>  	state->planes[index].state = plane_state;
>  	state->planes[index].ptr = plane;
> +	state->planes[index].old_state = plane->state;
> +	state->planes[index].new_state = plane_state;
>  	plane_state->state = state;
>  
>  	DRM_DEBUG_ATOMIC("Added [PLANE:%d:%s] %p state to %p\n",
> @@ -931,6 +935,8 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
>  
>  	drm_connector_reference(connector);
>  	state->connectors[index].state = connector_state;
> +	state->connectors[index].old_state = connector->state;
> +	state->connectors[index].new_state = connector_state;
>  	state->connectors[index].ptr = connector;
>  	connector_state->state = state;
>  
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 07b432f43b98..fcb6e5b55217 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -2495,7 +2495,7 @@ EXPORT_SYMBOL(drm_atomic_helper_disable_all);
>   *
>   * See also:
>   * drm_atomic_helper_duplicate_state(), drm_atomic_helper_disable_all(),
> - * drm_atomic_helper_resume()
> + * drm_atomic_helper_resume(), drm_atomic_helper_commit_duplicated_state()
>   */
>  struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev)
>  {
> @@ -2536,6 +2536,52 @@ unlock:
>  EXPORT_SYMBOL(drm_atomic_helper_suspend);
>  
>  /**
> + * drm_atomic_helper_commit_duplicated_state - commit duplicated state
> + * @state: duplicated atomic state to commit
> + * @ctx: pointer to acquire_ctx to use for commit.
> + * @nonblock: commit the state non-blocking.
> + *
> + * The state returned by drm_atomic_helper_duplicate_state() and
> + * drm_atomic_helper_suspend() is partially invalid, and needs to
> + * be fixed up before commit.

So the old_state pointers are potentially invalid because whatever->state
may have changed since we duplicated the state?

> + *
> + * Returns:
> + * 0 on success or a negative error code on failure.
> + *
> + * See also:
> + * drm_atomic_helper_suspend()
> + */
> +int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
> +					      struct drm_modeset_acquire_ctx *ctx,
> +					      bool nonblock)
> +{
> +	int i;
> +	struct drm_plane *plane;
> +	struct drm_plane_state *plane_state;
> +	struct drm_connector *connector;
> +	struct drm_connector_state *conn_state;
> +	struct drm_crtc *crtc;
> +	struct drm_crtc_state *crtc_state;
> +
> +	state->acquire_ctx = ctx;
> +
> +	for_each_new_plane_in_state(state, plane, plane_state, i)
> +		state->planes[i].old_state = plane->state;
> +
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i)
> +		state->crtcs[i].old_state = crtc->state;
> +
> +	for_each_new_connector_in_state(state, connector, conn_state, i)
> +		state->connectors[i].old_state = connector->state;
> +
> +	if (nonblock)
> +		return drm_atomic_nonblocking_commit(state);
> +	else
> +		return drm_atomic_commit(state);
> +}
> +EXPORT_SYMBOL(drm_atomic_helper_commit_duplicated_state);
> +
> +/**
>   * drm_atomic_helper_resume - subsystem-level resume helper
>   * @dev: DRM device
>   * @state: atomic state to resume to
> @@ -2558,9 +2604,9 @@ int drm_atomic_helper_resume(struct drm_device *dev,
>  	int err;
>  
>  	drm_mode_config_reset(dev);
> +
>  	drm_modeset_lock_all(dev);
> -	state->acquire_ctx = config->acquire_ctx;
> -	err = drm_atomic_commit(state);
> +	err = drm_atomic_helper_commit_duplicated_state(state, config->acquire_ctx, false);
>  	drm_modeset_unlock_all(dev);
>  
>  	return err;
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index a12e093c54cf..3bd3f6a93c12 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -3497,7 +3497,8 @@ static void intel_update_primary_planes(struct drm_device *dev)
>  
>  static int
>  __intel_display_resume(struct drm_device *dev,
> -		       struct drm_atomic_state *state)
> +		       struct drm_atomic_state *state,
> +		       struct drm_modeset_acquire_ctx *ctx)
>  {
>  	struct drm_crtc_state *crtc_state;
>  	struct drm_crtc *crtc;
> @@ -3521,7 +3522,7 @@ __intel_display_resume(struct drm_device *dev,
>  	/* ignore any reset values/BIOS leftovers in the WM registers */
>  	to_intel_atomic_state(state)->skip_intermediate_wm = true;
>  
> -	ret = drm_atomic_commit(state);
> +	ret = drm_atomic_helper_commit_duplicated_state(state, ctx, false);
>  
>  	WARN_ON(ret == -EDEADLK);
>  	return ret;
> @@ -3617,7 +3618,7 @@ void intel_finish_reset(struct drm_i915_private *dev_priv)
>  			 */
>  			intel_update_primary_planes(dev);
>  		} else {
> -			ret = __intel_display_resume(dev, state);
> +			ret = __intel_display_resume(dev, state, ctx);
>  			if (ret)
>  				DRM_ERROR("Restoring old state failed with %i\n", ret);
>  		}
> @@ -3636,7 +3637,7 @@ void intel_finish_reset(struct drm_i915_private *dev_priv)
>  			dev_priv->display.hpd_irq_setup(dev_priv);
>  		spin_unlock_irq(&dev_priv->irq_lock);
>  
> -		ret = __intel_display_resume(dev, state);
> +		ret = __intel_display_resume(dev, state, ctx);
>  		if (ret)
>  			DRM_ERROR("Restoring old state failed with %i\n", ret);
>  
> @@ -16937,7 +16938,7 @@ void intel_display_resume(struct drm_device *dev)
>  	}
>  
>  	if (!ret)
> -		ret = __intel_display_resume(dev, state);
> +		ret = __intel_display_resume(dev, state, &ctx);
>  
>  	drm_modeset_drop_locks(&ctx);
>  	drm_modeset_acquire_fini(&ctx);
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index fc8af53b18aa..09fb6b316ca9 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -137,18 +137,18 @@ struct drm_crtc_commit {
>  
>  struct __drm_planes_state {
>  	struct drm_plane *ptr;
> -	struct drm_plane_state *state;
> +	struct drm_plane_state *state, *old_state, *new_state;
>  };
>  
>  struct __drm_crtcs_state {
>  	struct drm_crtc *ptr;
> -	struct drm_crtc_state *state;
> +	struct drm_crtc_state *state, *old_state, *new_state;
>  	struct drm_crtc_commit *commit;
>  };
>  
>  struct __drm_connnectors_state {
>  	struct drm_connector *ptr;
> -	struct drm_connector_state *state;
> +	struct drm_connector_state *state, *old_state, *new_state;
>  };
>  
>  /**
> @@ -372,6 +372,31 @@ int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
>  	     (__i)++)							\
>  		for_each_if (connector)
>  
> +#define for_each_oldnew_connector_in_state(__state, connector, old_connector_state, new_connector_state, __i) \
> +	for ((__i) = 0;								\
> +	     (__i) < (__state)->num_connector &&				\
> +	     ((connector) = (__state)->connectors[__i].ptr,			\
> +	     (old_connector_state) = (__state)->connectors[__i].old_state,	\
> +	     (new_connector_state) = (__state)->connectors[__i].new_state, 1); 	\
> +	     (__i)++)							\
> +		for_each_if (connector)
> +
> +#define for_each_old_connector_in_state(__state, connector, old_connector_state, __i) \
> +	for ((__i) = 0;								\
> +	     (__i) < (__state)->num_connector &&				\
> +	     ((connector) = (__state)->connectors[__i].ptr,			\
> +	     (old_connector_state) = (__state)->connectors[__i].old_state, 1); 	\
> +	     (__i)++)							\
> +		for_each_if (connector)
> +
> +#define for_each_new_connector_in_state(__state, connector, new_connector_state, __i) \
> +	for ((__i) = 0;								\
> +	     (__i) < (__state)->num_connector &&				\
> +	     ((connector) = (__state)->connectors[__i].ptr,			\
> +	     (new_connector_state) = (__state)->connectors[__i].new_state, 1); 	\
> +	     (__i)++)							\
> +		for_each_if (connector)
> +
>  #define for_each_crtc_in_state(__state, crtc, crtc_state, __i)	\
>  	for ((__i) = 0;						\
>  	     (__i) < (__state)->dev->mode_config.num_crtc &&	\
> @@ -380,6 +405,31 @@ int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
>  	     (__i)++)						\
>  		for_each_if (crtc_state)
>  
> +#define for_each_oldnew_crtc_in_state(__state, crtc, old_crtc_state, new_crtc_state, __i) \
> +	for ((__i) = 0;							\
> +	     (__i) < (__state)->dev->mode_config.num_crtc &&		\
> +	     ((crtc) = (__state)->crtcs[__i].ptr,			\
> +	     (old_crtc_state) = (__state)->crtcs[__i].old_state,	\
> +	     (new_crtc_state) = (__state)->crtcs[__i].new_state, 1);	\
> +	     (__i)++)							\
> +		for_each_if (crtc)
> +
> +#define for_each_old_crtc_in_state(__state, crtc, old_crtc_state, __i)	\
> +	for ((__i) = 0;							\
> +	     (__i) < (__state)->dev->mode_config.num_crtc &&		\
> +	     ((crtc) = (__state)->crtcs[__i].ptr,			\
> +	     (old_crtc_state) = (__state)->crtcs[__i].old_state, 1);	\
> +	     (__i)++)							\
> +		for_each_if (crtc)
> +
> +#define for_each_new_crtc_in_state(__state, crtc, new_crtc_state, __i)	\
> +	for ((__i) = 0;							\
> +	     (__i) < (__state)->dev->mode_config.num_crtc &&		\
> +	     ((crtc) = (__state)->crtcs[__i].ptr,			\
> +	     (new_crtc_state) = (__state)->crtcs[__i].new_state, 1);	\
> +	     (__i)++)							\
> +		for_each_if (crtc)
> +
>  #define for_each_plane_in_state(__state, plane, plane_state, __i)		\
>  	for ((__i) = 0;							\
>  	     (__i) < (__state)->dev->mode_config.num_total_plane &&	\
> @@ -388,6 +438,31 @@ int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
>  	     (__i)++)							\
>  		for_each_if (plane_state)
>  
> +#define for_each_oldnew_plane_in_state(__state, plane, old_plane_state, new_plane_state, __i) \
> +	for ((__i) = 0;							\
> +	     (__i) < (__state)->dev->mode_config.num_total_plane &&	\
> +	     ((plane) = (__state)->planes[__i].ptr,			\
> +	     (old_plane_state) = (__state)->planes[__i].old_state,	\
> +	     (new_plane_state) = (__state)->planes[__i].new_state, 1);	\
> +	     (__i)++)							\
> +		for_each_if (plane)
> +
> +#define for_each_old_plane_in_state(__state, plane, old_plane_state, __i) \
> +	for ((__i) = 0;							\
> +	     (__i) < (__state)->dev->mode_config.num_total_plane &&	\
> +	     ((plane) = (__state)->planes[__i].ptr,			\
> +	     (old_plane_state) = (__state)->planes[__i].old_state, 1);	\
> +	     (__i)++)							\
> +		for_each_if (plane)
> +
> +#define for_each_new_plane_in_state(__state, plane, new_plane_state, __i) \
> +	for ((__i) = 0;							\
> +	     (__i) < (__state)->dev->mode_config.num_total_plane &&	\
> +	     ((plane) = (__state)->planes[__i].ptr,			\
> +	     (new_plane_state) = (__state)->planes[__i].new_state, 1);	\
> +	     (__i)++)							\
> +		for_each_if (plane)
> +
>  /**
>   * drm_atomic_crtc_needs_modeset - compute combined modeset need
>   * @state: &drm_crtc_state for the CRTC
> diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
> index 7ff92b09fd9c..613bb731ba36 100644
> --- a/include/drm/drm_atomic_helper.h
> +++ b/include/drm/drm_atomic_helper.h
> @@ -108,6 +108,9 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set,
>  int drm_atomic_helper_disable_all(struct drm_device *dev,
>  				  struct drm_modeset_acquire_ctx *ctx);
>  struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev);
> +int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
> +					      struct drm_modeset_acquire_ctx *ctx,
> +					      bool nonblock);
>  int drm_atomic_helper_resume(struct drm_device *dev,
>  			     struct drm_atomic_state *state);
>  
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 01/19] drm/atomic: Add new iterators over all state
  2016-11-01 13:09   ` [Intel-gfx] " Ville Syrjälä
@ 2016-11-01 13:34     ` Maarten Lankhorst
  2016-11-01 13:41       ` Ville Syrjälä
  2016-11-08  8:50       ` [Intel-gfx] " Daniel Vetter
  0 siblings, 2 replies; 45+ messages in thread
From: Maarten Lankhorst @ 2016-11-01 13:34 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, dri-devel

Op 01-11-16 om 14:09 schreef Ville Syrjälä:
> On Mon, Oct 17, 2016 at 02:37:00PM +0200, Maarten Lankhorst wrote:
>> Add for_each_(old)(new)_(plane,connector,crtc)_in_state iterators to
>> replace the old for_each_xxx_in_state ones. This is useful for >1 flip
>> depth and getting rid of all xxx->state dereferences.
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> ---
>>  drivers/gpu/drm/drm_atomic.c         |  6 +++
>>  drivers/gpu/drm/drm_atomic_helper.c  | 52 +++++++++++++++++++++--
>>  drivers/gpu/drm/i915/intel_display.c | 11 ++---
>>  include/drm/drm_atomic.h             | 81 ++++++++++++++++++++++++++++++++++--
>>  include/drm/drm_atomic_helper.h      |  3 ++
>>  5 files changed, 142 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
>> index 5dd70540219c..120775fcfb70 100644
>> --- a/drivers/gpu/drm/drm_atomic.c
>> +++ b/drivers/gpu/drm/drm_atomic.c
>> @@ -278,6 +278,8 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
>>  		return ERR_PTR(-ENOMEM);
>>  
>>  	state->crtcs[index].state = crtc_state;
>> +	state->crtcs[index].old_state = crtc->state;
>> +	state->crtcs[index].new_state = crtc_state;
>>  	state->crtcs[index].ptr = crtc;
>>  	crtc_state->state = state;
>>  
>> @@ -640,6 +642,8 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,
>>  
>>  	state->planes[index].state = plane_state;
>>  	state->planes[index].ptr = plane;
>> +	state->planes[index].old_state = plane->state;
>> +	state->planes[index].new_state = plane_state;
>>  	plane_state->state = state;
>>  
>>  	DRM_DEBUG_ATOMIC("Added [PLANE:%d:%s] %p state to %p\n",
>> @@ -931,6 +935,8 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
>>  
>>  	drm_connector_reference(connector);
>>  	state->connectors[index].state = connector_state;
>> +	state->connectors[index].old_state = connector->state;
>> +	state->connectors[index].new_state = connector_state;
>>  	state->connectors[index].ptr = connector;
>>  	connector_state->state = state;
>>  
>> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
>> index 07b432f43b98..fcb6e5b55217 100644
>> --- a/drivers/gpu/drm/drm_atomic_helper.c
>> +++ b/drivers/gpu/drm/drm_atomic_helper.c
>> @@ -2495,7 +2495,7 @@ EXPORT_SYMBOL(drm_atomic_helper_disable_all);
>>   *
>>   * See also:
>>   * drm_atomic_helper_duplicate_state(), drm_atomic_helper_disable_all(),
>> - * drm_atomic_helper_resume()
>> + * drm_atomic_helper_resume(), drm_atomic_helper_commit_duplicated_state()
>>   */
>>  struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev)
>>  {
>> @@ -2536,6 +2536,52 @@ unlock:
>>  EXPORT_SYMBOL(drm_atomic_helper_suspend);
>>  
>>  /**
>> + * drm_atomic_helper_commit_duplicated_state - commit duplicated state
>> + * @state: duplicated atomic state to commit
>> + * @ctx: pointer to acquire_ctx to use for commit.
>> + * @nonblock: commit the state non-blocking.
>> + *
>> + * The state returned by drm_atomic_helper_duplicate_state() and
>> + * drm_atomic_helper_suspend() is partially invalid, and needs to
>> + * be fixed up before commit.
> So the old_state pointers are potentially invalid because whatever->state
> may have changed since we duplicated the state?

Yes when you use drm_atomic_helper_duplicate_state, and commit a different state before committing the duplicated state.
This only happens during suspend/resume and gpu reset.

~Maarten

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

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 01/19] drm/atomic: Add new iterators over all state
  2016-11-01 13:34     ` Maarten Lankhorst
@ 2016-11-01 13:41       ` Ville Syrjälä
  2016-11-02  8:28         ` Maarten Lankhorst
  2016-11-08  8:50       ` [Intel-gfx] " Daniel Vetter
  1 sibling, 1 reply; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-01 13:41 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx, dri-devel

On Tue, Nov 01, 2016 at 02:34:00PM +0100, Maarten Lankhorst wrote:
> Op 01-11-16 om 14:09 schreef Ville Syrjälä:
> > On Mon, Oct 17, 2016 at 02:37:00PM +0200, Maarten Lankhorst wrote:
> >> Add for_each_(old)(new)_(plane,connector,crtc)_in_state iterators to
> >> replace the old for_each_xxx_in_state ones. This is useful for >1 flip
> >> depth and getting rid of all xxx->state dereferences.
> >>
> >> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> >> ---
> >>  drivers/gpu/drm/drm_atomic.c         |  6 +++
> >>  drivers/gpu/drm/drm_atomic_helper.c  | 52 +++++++++++++++++++++--
> >>  drivers/gpu/drm/i915/intel_display.c | 11 ++---
> >>  include/drm/drm_atomic.h             | 81 ++++++++++++++++++++++++++++++++++--
> >>  include/drm/drm_atomic_helper.h      |  3 ++
> >>  5 files changed, 142 insertions(+), 11 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> >> index 5dd70540219c..120775fcfb70 100644
> >> --- a/drivers/gpu/drm/drm_atomic.c
> >> +++ b/drivers/gpu/drm/drm_atomic.c
> >> @@ -278,6 +278,8 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
> >>  		return ERR_PTR(-ENOMEM);
> >>  
> >>  	state->crtcs[index].state = crtc_state;
> >> +	state->crtcs[index].old_state = crtc->state;
> >> +	state->crtcs[index].new_state = crtc_state;
> >>  	state->crtcs[index].ptr = crtc;
> >>  	crtc_state->state = state;
> >>  
> >> @@ -640,6 +642,8 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,
> >>  
> >>  	state->planes[index].state = plane_state;
> >>  	state->planes[index].ptr = plane;
> >> +	state->planes[index].old_state = plane->state;
> >> +	state->planes[index].new_state = plane_state;
> >>  	plane_state->state = state;
> >>  
> >>  	DRM_DEBUG_ATOMIC("Added [PLANE:%d:%s] %p state to %p\n",
> >> @@ -931,6 +935,8 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
> >>  
> >>  	drm_connector_reference(connector);
> >>  	state->connectors[index].state = connector_state;
> >> +	state->connectors[index].old_state = connector->state;
> >> +	state->connectors[index].new_state = connector_state;
> >>  	state->connectors[index].ptr = connector;
> >>  	connector_state->state = state;
> >>  
> >> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> >> index 07b432f43b98..fcb6e5b55217 100644
> >> --- a/drivers/gpu/drm/drm_atomic_helper.c
> >> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> >> @@ -2495,7 +2495,7 @@ EXPORT_SYMBOL(drm_atomic_helper_disable_all);
> >>   *
> >>   * See also:
> >>   * drm_atomic_helper_duplicate_state(), drm_atomic_helper_disable_all(),
> >> - * drm_atomic_helper_resume()
> >> + * drm_atomic_helper_resume(), drm_atomic_helper_commit_duplicated_state()
> >>   */
> >>  struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev)
> >>  {
> >> @@ -2536,6 +2536,52 @@ unlock:
> >>  EXPORT_SYMBOL(drm_atomic_helper_suspend);
> >>  
> >>  /**
> >> + * drm_atomic_helper_commit_duplicated_state - commit duplicated state
> >> + * @state: duplicated atomic state to commit
> >> + * @ctx: pointer to acquire_ctx to use for commit.
> >> + * @nonblock: commit the state non-blocking.
> >> + *
> >> + * The state returned by drm_atomic_helper_duplicate_state() and
> >> + * drm_atomic_helper_suspend() is partially invalid, and needs to
> >> + * be fixed up before commit.
> > So the old_state pointers are potentially invalid because whatever->state
> > may have changed since we duplicated the state?
> 
> Yes when you use drm_atomic_helper_duplicate_state, and commit a different state before committing the duplicated state.
> This only happens during suspend/resume and gpu reset.

Should we maybe have something like drm_atomic_refresh_old_state(state)?
Would allow the caller then to check something in the old vs. new state
before committing?

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 01/19] drm/atomic: Add new iterators over all state
  2016-11-01 13:41       ` Ville Syrjälä
@ 2016-11-02  8:28         ` Maarten Lankhorst
  2016-11-03 15:11           ` [Intel-gfx] " Ville Syrjälä
  0 siblings, 1 reply; 45+ messages in thread
From: Maarten Lankhorst @ 2016-11-02  8:28 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, dri-devel

Op 01-11-16 om 14:41 schreef Ville Syrjälä:
> On Tue, Nov 01, 2016 at 02:34:00PM +0100, Maarten Lankhorst wrote:
>> Op 01-11-16 om 14:09 schreef Ville Syrjälä:
>>> On Mon, Oct 17, 2016 at 02:37:00PM +0200, Maarten Lankhorst wrote:
>>>> Add for_each_(old)(new)_(plane,connector,crtc)_in_state iterators to
>>>> replace the old for_each_xxx_in_state ones. This is useful for >1 flip
>>>> depth and getting rid of all xxx->state dereferences.
>>>>
>>>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>>>> ---
>>>>  drivers/gpu/drm/drm_atomic.c         |  6 +++
>>>>  drivers/gpu/drm/drm_atomic_helper.c  | 52 +++++++++++++++++++++--
>>>>  drivers/gpu/drm/i915/intel_display.c | 11 ++---
>>>>  include/drm/drm_atomic.h             | 81 ++++++++++++++++++++++++++++++++++--
>>>>  include/drm/drm_atomic_helper.h      |  3 ++
>>>>  5 files changed, 142 insertions(+), 11 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
>>>> index 5dd70540219c..120775fcfb70 100644
>>>> --- a/drivers/gpu/drm/drm_atomic.c
>>>> +++ b/drivers/gpu/drm/drm_atomic.c
>>>> @@ -278,6 +278,8 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
>>>>  		return ERR_PTR(-ENOMEM);
>>>>  
>>>>  	state->crtcs[index].state = crtc_state;
>>>> +	state->crtcs[index].old_state = crtc->state;
>>>> +	state->crtcs[index].new_state = crtc_state;
>>>>  	state->crtcs[index].ptr = crtc;
>>>>  	crtc_state->state = state;
>>>>  
>>>> @@ -640,6 +642,8 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,
>>>>  
>>>>  	state->planes[index].state = plane_state;
>>>>  	state->planes[index].ptr = plane;
>>>> +	state->planes[index].old_state = plane->state;
>>>> +	state->planes[index].new_state = plane_state;
>>>>  	plane_state->state = state;
>>>>  
>>>>  	DRM_DEBUG_ATOMIC("Added [PLANE:%d:%s] %p state to %p\n",
>>>> @@ -931,6 +935,8 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
>>>>  
>>>>  	drm_connector_reference(connector);
>>>>  	state->connectors[index].state = connector_state;
>>>> +	state->connectors[index].old_state = connector->state;
>>>> +	state->connectors[index].new_state = connector_state;
>>>>  	state->connectors[index].ptr = connector;
>>>>  	connector_state->state = state;
>>>>  
>>>> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
>>>> index 07b432f43b98..fcb6e5b55217 100644
>>>> --- a/drivers/gpu/drm/drm_atomic_helper.c
>>>> +++ b/drivers/gpu/drm/drm_atomic_helper.c
>>>> @@ -2495,7 +2495,7 @@ EXPORT_SYMBOL(drm_atomic_helper_disable_all);
>>>>   *
>>>>   * See also:
>>>>   * drm_atomic_helper_duplicate_state(), drm_atomic_helper_disable_all(),
>>>> - * drm_atomic_helper_resume()
>>>> + * drm_atomic_helper_resume(), drm_atomic_helper_commit_duplicated_state()
>>>>   */
>>>>  struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev)
>>>>  {
>>>> @@ -2536,6 +2536,52 @@ unlock:
>>>>  EXPORT_SYMBOL(drm_atomic_helper_suspend);
>>>>  
>>>>  /**
>>>> + * drm_atomic_helper_commit_duplicated_state - commit duplicated state
>>>> + * @state: duplicated atomic state to commit
>>>> + * @ctx: pointer to acquire_ctx to use for commit.
>>>> + * @nonblock: commit the state non-blocking.
>>>> + *
>>>> + * The state returned by drm_atomic_helper_duplicate_state() and
>>>> + * drm_atomic_helper_suspend() is partially invalid, and needs to
>>>> + * be fixed up before commit.
>>> So the old_state pointers are potentially invalid because whatever->state
>>> may have changed since we duplicated the state?
>> Yes when you use drm_atomic_helper_duplicate_state, and commit a different state before committing the duplicated state.
>> This only happens during suspend/resume and gpu reset.
> Should we maybe have something like drm_atomic_refresh_old_state(state)?
> Would allow the caller then to check something in the old vs. new state
> before committing?

iirc that was the first approach I took, but then you shouldn't do anything with a duplicated state after
creating a except commit it, so creating a commit_duplicated_state should be enough.

Can you think of any case where you do the following?

Duplicate state
commit different state
Look at duplicated state, tinker with it, commit it.

~Maarten

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

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [Intel-gfx] [PATCH 01/19] drm/atomic: Add new iterators over all state
  2016-11-02  8:28         ` Maarten Lankhorst
@ 2016-11-03 15:11           ` Ville Syrjälä
  2016-11-16 12:56             ` Maarten Lankhorst
  0 siblings, 1 reply; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-03 15:11 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx, dri-devel

On Wed, Nov 02, 2016 at 09:28:46AM +0100, Maarten Lankhorst wrote:
> Op 01-11-16 om 14:41 schreef Ville Syrjälä:
> > On Tue, Nov 01, 2016 at 02:34:00PM +0100, Maarten Lankhorst wrote:
> >> Op 01-11-16 om 14:09 schreef Ville Syrjälä:
> >>> On Mon, Oct 17, 2016 at 02:37:00PM +0200, Maarten Lankhorst wrote:
> >>>> Add for_each_(old)(new)_(plane,connector,crtc)_in_state iterators to
> >>>> replace the old for_each_xxx_in_state ones. This is useful for >1 flip
> >>>> depth and getting rid of all xxx->state dereferences.
> >>>>
> >>>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> >>>> ---
> >>>>  drivers/gpu/drm/drm_atomic.c         |  6 +++
> >>>>  drivers/gpu/drm/drm_atomic_helper.c  | 52 +++++++++++++++++++++--
> >>>>  drivers/gpu/drm/i915/intel_display.c | 11 ++---
> >>>>  include/drm/drm_atomic.h             | 81 ++++++++++++++++++++++++++++++++++--
> >>>>  include/drm/drm_atomic_helper.h      |  3 ++
> >>>>  5 files changed, 142 insertions(+), 11 deletions(-)
> >>>>
> >>>> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> >>>> index 5dd70540219c..120775fcfb70 100644
> >>>> --- a/drivers/gpu/drm/drm_atomic.c
> >>>> +++ b/drivers/gpu/drm/drm_atomic.c
> >>>> @@ -278,6 +278,8 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
> >>>>  		return ERR_PTR(-ENOMEM);
> >>>>  
> >>>>  	state->crtcs[index].state = crtc_state;
> >>>> +	state->crtcs[index].old_state = crtc->state;
> >>>> +	state->crtcs[index].new_state = crtc_state;
> >>>>  	state->crtcs[index].ptr = crtc;
> >>>>  	crtc_state->state = state;
> >>>>  
> >>>> @@ -640,6 +642,8 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,
> >>>>  
> >>>>  	state->planes[index].state = plane_state;
> >>>>  	state->planes[index].ptr = plane;
> >>>> +	state->planes[index].old_state = plane->state;
> >>>> +	state->planes[index].new_state = plane_state;
> >>>>  	plane_state->state = state;
> >>>>  
> >>>>  	DRM_DEBUG_ATOMIC("Added [PLANE:%d:%s] %p state to %p\n",
> >>>> @@ -931,6 +935,8 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
> >>>>  
> >>>>  	drm_connector_reference(connector);
> >>>>  	state->connectors[index].state = connector_state;
> >>>> +	state->connectors[index].old_state = connector->state;
> >>>> +	state->connectors[index].new_state = connector_state;
> >>>>  	state->connectors[index].ptr = connector;
> >>>>  	connector_state->state = state;
> >>>>  
> >>>> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> >>>> index 07b432f43b98..fcb6e5b55217 100644
> >>>> --- a/drivers/gpu/drm/drm_atomic_helper.c
> >>>> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> >>>> @@ -2495,7 +2495,7 @@ EXPORT_SYMBOL(drm_atomic_helper_disable_all);
> >>>>   *
> >>>>   * See also:
> >>>>   * drm_atomic_helper_duplicate_state(), drm_atomic_helper_disable_all(),
> >>>> - * drm_atomic_helper_resume()
> >>>> + * drm_atomic_helper_resume(), drm_atomic_helper_commit_duplicated_state()
> >>>>   */
> >>>>  struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev)
> >>>>  {
> >>>> @@ -2536,6 +2536,52 @@ unlock:
> >>>>  EXPORT_SYMBOL(drm_atomic_helper_suspend);
> >>>>  
> >>>>  /**
> >>>> + * drm_atomic_helper_commit_duplicated_state - commit duplicated state
> >>>> + * @state: duplicated atomic state to commit
> >>>> + * @ctx: pointer to acquire_ctx to use for commit.
> >>>> + * @nonblock: commit the state non-blocking.
> >>>> + *
> >>>> + * The state returned by drm_atomic_helper_duplicate_state() and
> >>>> + * drm_atomic_helper_suspend() is partially invalid, and needs to
> >>>> + * be fixed up before commit.
> >>> So the old_state pointers are potentially invalid because whatever->state
> >>> may have changed since we duplicated the state?
> >> Yes when you use drm_atomic_helper_duplicate_state, and commit a different state before committing the duplicated state.
> >> This only happens during suspend/resume and gpu reset.
> > Should we maybe have something like drm_atomic_refresh_old_state(state)?
> > Would allow the caller then to check something in the old vs. new state
> > before committing?
> 
> iirc that was the first approach I took, but then you shouldn't do anything with a duplicated state after
> creating a except commit it, so creating a commit_duplicated_state should be enough.
> 
> Can you think of any case where you do the following?
> 
> Duplicate state
> commit different state
> Look at duplicated state, tinker with it, commit it.

Not really. Oh, and we do still run the thing through the check phase
when we commit it, don't we? That sounds like it should let the driver
do whatever it needs to do.

So my only other concern is just the 'bool nonblock' parameter. It's a
bit funny looking that we pass that in, then branch off to the nonblocking
vs. blocking commits, which then just pass another bool parameter to the
commit hook. Should we have block vs. nonblocking variants of this
function as well or just remove drm_atomic_nonblocking_commit() and have
callers pass the parameter straight from the beginning?

drm_atomic_commit() and drm_atomic_nonblocking_commit() could also use
some code deduplication I think. Should we decice to keep them around.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 04/19] drm/blend: Use new atomic iterator macros.
  2016-10-17 12:37 ` [PATCH 04/19] drm/blend: " Maarten Lankhorst
@ 2016-11-03 15:26   ` Ville Syrjälä
  0 siblings, 0 replies; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-03 15:26 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx, dri-devel

On Mon, Oct 17, 2016 at 02:37:03PM +0200, Maarten Lankhorst wrote:
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>

Patches 02-04 looks sane to me, so for them
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---
>  drivers/gpu/drm/drm_blend.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c
> index 85172a977bf3..70c03eb032fc 100644
> --- a/drivers/gpu/drm/drm_blend.c
> +++ b/drivers/gpu/drm/drm_blend.c
> @@ -367,27 +367,27 @@ int drm_atomic_normalize_zpos(struct drm_device *dev,
>  			      struct drm_atomic_state *state)
>  {
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *crtc_state;
> +	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
>  	struct drm_plane *plane;
> -	struct drm_plane_state *plane_state;
> +	struct drm_plane_state *old_plane_state, *new_plane_state;
>  	int i, ret = 0;
>  
> -	for_each_plane_in_state(state, plane, plane_state, i) {
> -		crtc = plane_state->crtc;
> +	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
> +		crtc = new_plane_state->crtc;
>  		if (!crtc)
>  			continue;
> -		if (plane->state->zpos != plane_state->zpos) {
> -			crtc_state =
> +		if (old_plane_state->zpos != new_plane_state->zpos) {
> +			new_crtc_state =
>  				drm_atomic_get_existing_crtc_state(state, crtc);
> -			crtc_state->zpos_changed = true;
> +			new_crtc_state->zpos_changed = true;
>  		}
>  	}
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> -		if (crtc_state->plane_mask != crtc->state->plane_mask ||
> -		    crtc_state->zpos_changed) {
> +	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +		if (old_crtc_state->plane_mask != new_crtc_state->plane_mask ||
> +		    new_crtc_state->zpos_changed) {
>  			ret = drm_atomic_helper_crtc_normalize_zpos(crtc,
> -								    crtc_state);
> +								    new_crtc_state);
>  			if (ret)
>  				return ret;
>  		}
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 05/19] drm/atomic: Make add_affected_connectors look at crtc_state.
  2016-10-17 12:37 ` [PATCH 05/19] drm/atomic: Make add_affected_connectors look at crtc_state Maarten Lankhorst
@ 2016-11-03 15:32   ` Ville Syrjälä
  2016-11-08  8:51     ` [Intel-gfx] " Daniel Vetter
  0 siblings, 1 reply; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-03 15:32 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx, dri-devel

On Mon, Oct 17, 2016 at 02:37:04PM +0200, Maarten Lankhorst wrote:
> This kills another dereference of connector->state. connector_mask
> holds all unchanged connectors at least and any changed connectors
> are already in state anyway.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_atomic.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 120775fcfb70..1915ec44f7eb 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -1230,8 +1230,13 @@ drm_atomic_add_affected_connectors(struct drm_atomic_state *state,
>  	struct drm_mode_config *config = &state->dev->mode_config;
>  	struct drm_connector *connector;
>  	struct drm_connector_state *conn_state;
> +	struct drm_crtc_state *crtc_state;
>  	int ret;
>  
> +	crtc_state = drm_atomic_get_crtc_state(state, crtc);
> +	if (IS_ERR(crtc_state))
> +		return PTR_ERR(crtc_state);
> +
>  	ret = drm_modeset_lock(&config->connection_mutex, state->acquire_ctx);
>  	if (ret)
>  		return ret;
> @@ -1240,11 +1245,11 @@ drm_atomic_add_affected_connectors(struct drm_atomic_state *state,
>  			 crtc->base.id, crtc->name, state);
>  
>  	/*
> -	 * Changed connectors are already in @state, so only need to look at the
> -	 * current configuration.
> +	 * Changed connectors are already in @state, so only need to look
> +	 * at the connector_mask in crtc_state.
>  	 */
>  	drm_for_each_connector(connector, state->dev) {
> -		if (connector->state->crtc != crtc)
> +		if (!(crtc_state->connector_mask & (1 << drm_connector_index(connector))))
>  			continue;

So this being the new crtc state, connector_mask will include all newly enabled
connectors (these will have been already added to the top level state), and
also any connector that was already enabled and isn't getting disabled (these
are the ones we need to explicitly add to the top level state here).

/me wishes the top level state would be renamed to drm_atomic_transaction or something...

Any connector that is getting disabled will already have been added to
the top level state as well, so them not being included in the new crtc
state's connectors_mask is fine.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

>  
>  		conn_state = drm_atomic_get_connector_state(state, connector);
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [Intel-gfx] [PATCH 06/19] drm/atomic: Use new atomic iterator macros.
  2016-10-17 12:37 ` [PATCH 06/19] drm/atomic: Use new atomic iterator macros Maarten Lankhorst
@ 2016-11-03 15:35   ` Ville Syrjälä
  0 siblings, 0 replies; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-03 15:35 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx, dri-devel

On Mon, Oct 17, 2016 at 02:37:05PM +0200, Maarten Lankhorst wrote:
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_atomic.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 1915ec44f7eb..6672ea93ee73 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -1369,7 +1369,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
>  
>  	DRM_DEBUG_ATOMIC("checking %p\n", state);
>  
> -	for_each_plane_in_state(state, plane, plane_state, i) {
> +	for_each_new_plane_in_state(state, plane, plane_state, i) {
>  		ret = drm_atomic_plane_check(plane, plane_state);
>  		if (ret) {
>  			DRM_DEBUG_ATOMIC("[PLANE:%d:%s] atomic core check failed\n",
> @@ -1378,7 +1378,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
>  		}
>  	}
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
>  		ret = drm_atomic_crtc_check(crtc, crtc_state);
>  		if (ret) {
>  			DRM_DEBUG_ATOMIC("[CRTC:%d:%s] atomic core check failed\n",
> @@ -1391,7 +1391,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
>  		ret = config->funcs->atomic_check(state->dev, state);
>  
>  	if (!state->allow_modeset) {
> -		for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +		for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
>  			if (drm_atomic_crtc_needs_modeset(crtc_state)) {
>  				DRM_DEBUG_ATOMIC("[CRTC:%d:%s] requires full modeset\n",
>  						 crtc->base.id, crtc->name);

All part of the check phase. Check.

> @@ -1732,7 +1732,7 @@ retry:
>  	}
>  
>  	if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
> -		for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +		for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
>  			struct drm_pending_vblank_event *e;
>  
>  			e = create_vblank_event(dev, file_priv, NULL,
> @@ -1768,7 +1768,7 @@ out:
>  		 * for TEST_ONLY too.
>  		 */
>  
> -		for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +		for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
>  			if (!crtc_state->event)
>  				continue;

This latter one runs after the commit, but since it's only executed when
the check/commit failed, we wouldn't have swapped the state yet.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

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

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 07/19] drm/atomic: Fix atomic helpers to use the new iterator macros.
  2016-10-17 12:37 ` [PATCH 07/19] drm/atomic: Fix atomic helpers to use the new " Maarten Lankhorst
@ 2016-11-03 16:22   ` Ville Syrjälä
  2016-11-08  8:53     ` Daniel Vetter
  0 siblings, 1 reply; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-03 16:22 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx, dri-devel

On Mon, Oct 17, 2016 at 02:37:06PM +0200, Maarten Lankhorst wrote:
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 302 +++++++++++++++++++-----------------
>  1 file changed, 157 insertions(+), 145 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index fcb6e5b55217..c8aba493fc17 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -103,7 +103,7 @@ static int handle_conflicting_encoders(struct drm_atomic_state *state,
>  	 * part of the state. If the same encoder is assigned to multiple
>  	 * connectors bail out.
>  	 */
> -	for_each_connector_in_state(state, connector, conn_state, i) {
> +	for_each_new_connector_in_state(state, connector, conn_state, i) {
>  		const struct drm_connector_helper_funcs *funcs = connector->helper_private;
>  		struct drm_encoder *new_encoder;
>  
> @@ -238,22 +238,22 @@ steal_encoder(struct drm_atomic_state *state,
>  {
>  	struct drm_crtc_state *crtc_state;
>  	struct drm_connector *connector;
> -	struct drm_connector_state *connector_state;
> +	struct drm_connector_state *old_connector_state, *new_connector_state;
>  	int i;
>  
> -	for_each_connector_in_state(state, connector, connector_state, i) {
> +	for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i) {
>  		struct drm_crtc *encoder_crtc;
>  
> -		if (connector_state->best_encoder != encoder)
> +		if (new_connector_state->best_encoder != encoder)
>  			continue;
>  
> -		encoder_crtc = connector->state->crtc;
> +		encoder_crtc = old_connector_state->crtc;
>  
>  		DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] in use on [CRTC:%d:%s], stealing it\n",
>  				 encoder->base.id, encoder->name,
>  				 encoder_crtc->base.id, encoder_crtc->name);
>  
> -		set_best_encoder(state, connector_state, NULL);
> +		set_best_encoder(state, new_connector_state, NULL);
>  
>  		crtc_state = drm_atomic_get_existing_crtc_state(state, encoder_crtc);
>  		crtc_state->connectors_changed = true;
> @@ -265,7 +265,8 @@ steal_encoder(struct drm_atomic_state *state,
>  static int
>  update_connector_routing(struct drm_atomic_state *state,
>  			 struct drm_connector *connector,
> -			 struct drm_connector_state *connector_state)
> +			 struct drm_connector_state *old_connector_state,
> +			 struct drm_connector_state *new_connector_state)
>  {
>  	const struct drm_connector_helper_funcs *funcs;
>  	struct drm_encoder *new_encoder;
> @@ -275,24 +276,24 @@ update_connector_routing(struct drm_atomic_state *state,
>  			 connector->base.id,
>  			 connector->name);
>  
> -	if (connector->state->crtc != connector_state->crtc) {
> -		if (connector->state->crtc) {
> -			crtc_state = drm_atomic_get_existing_crtc_state(state, connector->state->crtc);
> +	if (old_connector_state->crtc != new_connector_state->crtc) {
> +		if (old_connector_state->crtc) {
> +			crtc_state = drm_atomic_get_existing_crtc_state(state, old_connector_state->crtc);
>  			crtc_state->connectors_changed = true;
>  		}
>  
> -		if (connector_state->crtc) {
> -			crtc_state = drm_atomic_get_existing_crtc_state(state, connector_state->crtc);
> +		if (new_connector_state->crtc) {
> +			crtc_state = drm_atomic_get_existing_crtc_state(state, new_connector_state->crtc);
>  			crtc_state->connectors_changed = true;
>  		}
>  	}
>  
> -	if (!connector_state->crtc) {
> +	if (!new_connector_state->crtc) {
>  		DRM_DEBUG_ATOMIC("Disabling [CONNECTOR:%d:%s]\n",
>  				connector->base.id,
>  				connector->name);
>  
> -		set_best_encoder(state, connector_state, NULL);
> +		set_best_encoder(state, new_connector_state, NULL);
>  
>  		return 0;
>  	}
> @@ -301,7 +302,7 @@ update_connector_routing(struct drm_atomic_state *state,
>  
>  	if (funcs->atomic_best_encoder)
>  		new_encoder = funcs->atomic_best_encoder(connector,
> -							 connector_state);
> +							 new_connector_state);
>  	else if (funcs->best_encoder)
>  		new_encoder = funcs->best_encoder(connector);
>  	else
> @@ -314,33 +315,33 @@ update_connector_routing(struct drm_atomic_state *state,
>  		return -EINVAL;
>  	}
>  
> -	if (!drm_encoder_crtc_ok(new_encoder, connector_state->crtc)) {
> +	if (!drm_encoder_crtc_ok(new_encoder, new_connector_state->crtc)) {
>  		DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] incompatible with [CRTC:%d]\n",
>  				 new_encoder->base.id,
>  				 new_encoder->name,
> -				 connector_state->crtc->base.id);
> +				 new_connector_state->crtc->base.id);
>  		return -EINVAL;
>  	}
>  
> -	if (new_encoder == connector_state->best_encoder) {
> -		set_best_encoder(state, connector_state, new_encoder);
> +	if (new_encoder == new_connector_state->best_encoder) {
> +		set_best_encoder(state, new_connector_state, new_encoder);
>  
>  		DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] keeps [ENCODER:%d:%s], now on [CRTC:%d:%s]\n",
>  				 connector->base.id,
>  				 connector->name,
>  				 new_encoder->base.id,
>  				 new_encoder->name,
> -				 connector_state->crtc->base.id,
> -				 connector_state->crtc->name);
> +				 new_connector_state->crtc->base.id,
> +				 new_connector_state->crtc->name);
>  
>  		return 0;
>  	}
>  
>  	steal_encoder(state, new_encoder);
>  
> -	set_best_encoder(state, connector_state, new_encoder);
> +	set_best_encoder(state, new_connector_state, new_encoder);
>  
> -	crtc_state = drm_atomic_get_existing_crtc_state(state, connector_state->crtc);
> +	crtc_state = drm_atomic_get_existing_crtc_state(state, new_connector_state->crtc);
>  	crtc_state->connectors_changed = true;
>  
>  	DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] using [ENCODER:%d:%s] on [CRTC:%d:%s]\n",
> @@ -348,8 +349,8 @@ update_connector_routing(struct drm_atomic_state *state,
>  			 connector->name,
>  			 new_encoder->base.id,
>  			 new_encoder->name,
> -			 connector_state->crtc->base.id,
> -			 connector_state->crtc->name);
> +			 new_connector_state->crtc->base.id,
> +			 new_connector_state->crtc->name);
>  
>  	return 0;
>  }
> @@ -364,7 +365,7 @@ mode_fixup(struct drm_atomic_state *state)
>  	int i;
>  	bool ret;
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
>  		if (!crtc_state->mode_changed &&
>  		    !crtc_state->connectors_changed)
>  			continue;
> @@ -372,7 +373,7 @@ mode_fixup(struct drm_atomic_state *state)
>  		drm_mode_copy(&crtc_state->adjusted_mode, &crtc_state->mode);
>  	}
>  
> -	for_each_connector_in_state(state, connector, conn_state, i) {
> +	for_each_new_connector_in_state(state, connector, conn_state, i) {
>  		const struct drm_encoder_helper_funcs *funcs;
>  		struct drm_encoder *encoder;
>  
> @@ -417,7 +418,7 @@ mode_fixup(struct drm_atomic_state *state)
>  		}
>  	}
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
>  		const struct drm_crtc_helper_funcs *funcs;
>  
>  		if (!crtc_state->enable)
> @@ -476,19 +477,19 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
>  				struct drm_atomic_state *state)
>  {
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *crtc_state;
> +	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
>  	struct drm_connector *connector;
> -	struct drm_connector_state *connector_state;
> +	struct drm_connector_state *old_connector_state, *new_connector_state;
>  	int i, ret;
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> -		if (!drm_mode_equal(&crtc->state->mode, &crtc_state->mode)) {
> +	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +		if (!drm_mode_equal(&old_crtc_state->mode, &new_crtc_state->mode)) {
>  			DRM_DEBUG_ATOMIC("[CRTC:%d:%s] mode changed\n",
>  					 crtc->base.id, crtc->name);
> -			crtc_state->mode_changed = true;
> +			new_crtc_state->mode_changed = true;
>  		}
>  
> -		if (crtc->state->enable != crtc_state->enable) {
> +		if (old_crtc_state->enable != new_crtc_state->enable) {
>  			DRM_DEBUG_ATOMIC("[CRTC:%d:%s] enable changed\n",
>  					 crtc->base.id, crtc->name);
>  
> @@ -500,8 +501,8 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
>  			 * The other way around is true as well. enable != 0
>  			 * iff connectors are attached and a mode is set.
>  			 */
> -			crtc_state->mode_changed = true;
> -			crtc_state->connectors_changed = true;
> +			new_crtc_state->mode_changed = true;
> +			new_crtc_state->connectors_changed = true;
>  		}
>  	}
>  
> @@ -509,14 +510,15 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
>  	if (ret)
>  		return ret;
>  
> -	for_each_connector_in_state(state, connector, connector_state, i) {
> +	for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i) {
>  		/*
>  		 * This only sets crtc->connectors_changed for routing changes,
>  		 * drivers must set crtc->connectors_changed themselves when
>  		 * connector properties need to be updated.
>  		 */
>  		ret = update_connector_routing(state, connector,
> -					       connector_state);
> +					       old_connector_state,
> +					       new_connector_state);
>  		if (ret)
>  			return ret;
>  	}
> @@ -527,28 +529,28 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
>  	 * configuration. This must be done before calling mode_fixup in case a
>  	 * crtc only changed its mode but has the same set of connectors.
>  	 */
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>  		bool has_connectors =
> -			!!crtc_state->connector_mask;
> +			!!new_crtc_state->connector_mask;
>  
>  		/*
>  		 * We must set ->active_changed after walking connectors for
>  		 * otherwise an update that only changes active would result in
>  		 * a full modeset because update_connector_routing force that.
>  		 */
> -		if (crtc->state->active != crtc_state->active) {
> +		if (old_crtc_state->active != new_crtc_state->active) {
>  			DRM_DEBUG_ATOMIC("[CRTC:%d:%s] active changed\n",
>  					 crtc->base.id, crtc->name);
> -			crtc_state->active_changed = true;
> +			new_crtc_state->active_changed = true;
>  		}
>  
> -		if (!drm_atomic_crtc_needs_modeset(crtc_state))
> +		if (!drm_atomic_crtc_needs_modeset(new_crtc_state))
>  			continue;
>  
>  		DRM_DEBUG_ATOMIC("[CRTC:%d:%s] needs all connectors, enable: %c, active: %c\n",
>  				 crtc->base.id, crtc->name,
> -				 crtc_state->enable ? 'y' : 'n',
> -				 crtc_state->active ? 'y' : 'n');
> +				 new_crtc_state->enable ? 'y' : 'n',
> +				 new_crtc_state->active ? 'y' : 'n');
>  
>  		ret = drm_atomic_add_affected_connectors(state, crtc);
>  		if (ret != 0)
> @@ -558,7 +560,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
>  		if (ret != 0)
>  			return ret;
>  
> -		if (crtc_state->enable != has_connectors) {
> +		if (new_crtc_state->enable != has_connectors) {
>  			DRM_DEBUG_ATOMIC("[CRTC:%d:%s] enabled/connectors mismatch\n",
>  					 crtc->base.id, crtc->name);
>  
> @@ -599,7 +601,7 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
>  	if (ret)
>  		return ret;
>  
> -	for_each_plane_in_state(state, plane, plane_state, i) {
> +	for_each_new_plane_in_state(state, plane, plane_state, i) {
>  		const struct drm_plane_helper_funcs *funcs;
>  
>  		funcs = plane->helper_private;
> @@ -617,7 +619,7 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
>  		}
>  	}
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
>  		const struct drm_crtc_helper_funcs *funcs;
>  
>  		funcs = crtc->helper_private;

Up to here everything runs in the check phase, so the straightforwared
s/state/new_state/ and s/foo->state/old_state/ looks correct.

> @@ -678,12 +680,12 @@ static void
>  disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
>  {
>  	struct drm_connector *connector;
> -	struct drm_connector_state *old_conn_state;
> +	struct drm_connector_state *old_conn_state, *new_conn_state;
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *old_crtc_state;
> +	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
>  	int i;
>  
> -	for_each_connector_in_state(old_state, connector, old_conn_state, i) {
> +	for_each_oldnew_connector_in_state(old_state, connector, old_conn_state, new_conn_state, i) {
>  		const struct drm_encoder_helper_funcs *funcs;
>  		struct drm_encoder *encoder;
>  
> @@ -720,7 +722,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
>  
>  		/* Right function depends upon target state. */
>  		if (funcs) {
> -			if (connector->state->crtc && funcs->prepare)
> +			if (new_conn_state->crtc && funcs->prepare)
>  				funcs->prepare(encoder);
>  			else if (funcs->disable)
>  				funcs->disable(encoder);
> @@ -731,11 +733,11 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
>  		drm_bridge_post_disable(encoder->bridge);
>  	}
>  
> -	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
> +	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
>  		const struct drm_crtc_helper_funcs *funcs;
>  
>  		/* Shut down everything that needs a full modeset. */
> -		if (!drm_atomic_crtc_needs_modeset(crtc->state))
> +		if (!drm_atomic_crtc_needs_modeset(new_crtc_state))
>  			continue;
>  
>  		if (!old_crtc_state->active)
> @@ -748,7 +750,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
>  
>  
>  		/* Right function depends upon target state. */
> -		if (crtc->state->enable && funcs->prepare)
> +		if (new_crtc_state->enable && funcs->prepare)
>  			funcs->prepare(crtc);
>  		else if (funcs->atomic_disable)
>  			funcs->atomic_disable(crtc, old_crtc_state);

And this sucker is executed after we've swapped the state, so we need to
do the s/foo->state/new_state/ replacement. Looks correct to me.

Not sure how worried I should be that we might forget some foo->state
dereference somewhere. Should we try rename that pointer to something else
to make sure we've caught everything?

> @@ -777,13 +779,13 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
>  					      struct drm_atomic_state *old_state)
>  {
>  	struct drm_connector *connector;
> -	struct drm_connector_state *old_conn_state;
> +	struct drm_connector_state *old_conn_state, *new_conn_state;
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *old_crtc_state;
> +	struct drm_crtc_state *crtc_state;
>  	int i;
>  
>  	/* clear out existing links and update dpms */
> -	for_each_connector_in_state(old_state, connector, old_conn_state, i) {
> +	for_each_oldnew_connector_in_state(old_state, connector, old_conn_state, new_conn_state, i) {
>  		if (connector->encoder) {
>  			WARN_ON(!connector->encoder->crtc);
>  
> @@ -791,7 +793,7 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
>  			connector->encoder = NULL;
>  		}
>  
> -		crtc = connector->state->crtc;
> +		crtc = new_conn_state->crtc;
>  		if ((!crtc && old_conn_state->crtc) ||
>  		    (crtc && drm_atomic_crtc_needs_modeset(crtc->state))) {
                                                           ^^^^^^^^^^^^
Like this guy here. That should be new_crtc_state, no?

>  			struct drm_property *dpms_prop =
> @@ -808,23 +810,23 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
>  	}
>  
>  	/* set new links */
> -	for_each_connector_in_state(old_state, connector, old_conn_state, i) {
> -		if (!connector->state->crtc)
> +	for_each_new_connector_in_state(old_state, connector, new_conn_state, i) {
> +		if (!new_conn_state->crtc)
>  			continue;
>  
> -		if (WARN_ON(!connector->state->best_encoder))
> +		if (WARN_ON(!new_conn_state->best_encoder))
>  			continue;
>  
> -		connector->encoder = connector->state->best_encoder;
> -		connector->encoder->crtc = connector->state->crtc;
> +		connector->encoder = new_conn_state->best_encoder;
> +		connector->encoder->crtc = new_conn_state->crtc;
>  	}
>  
>  	/* set legacy state in the crtc structure */
> -	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
> +	for_each_new_crtc_in_state(old_state, crtc, crtc_state, i) {
>  		struct drm_plane *primary = crtc->primary;
>  
> -		crtc->mode = crtc->state->mode;
> -		crtc->enabled = crtc->state->enable;
> +		crtc->mode = crtc_state->mode;
> +		crtc->enabled = crtc_state->enable;
>  
>  		if (drm_atomic_get_existing_plane_state(old_state, primary) &&
>  		    primary->state->crtc == crtc) {
                    ^^^^^^^^^^^^^^
new_plane_state or something?

> @@ -832,9 +834,9 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
>  			crtc->y = primary->state->src_y >> 16;
>  		}
>  
> -		if (crtc->state->enable)
> +		if (crtc_state->enable)
>  			drm_calc_timestamping_constants(crtc,
> -							&crtc->state->adjusted_mode);
> +							&crtc_state->adjusted_mode);
>  	}
>  }
>  EXPORT_SYMBOL(drm_atomic_helper_update_legacy_modeset_state);
> @@ -843,20 +845,20 @@ static void
>  crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
>  {
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *old_crtc_state;
> +	struct drm_crtc_state *crtc_state;
>  	struct drm_connector *connector;
> -	struct drm_connector_state *old_conn_state;
> +	struct drm_connector_state *conn_state;
>  	int i;
>  
> -	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
> +	for_each_new_crtc_in_state(old_state, crtc, crtc_state, i) {
>  		const struct drm_crtc_helper_funcs *funcs;
>  
> -		if (!crtc->state->mode_changed)
> +		if (!crtc_state->mode_changed)
>  			continue;
>  
>  		funcs = crtc->helper_private;
>  
> -		if (crtc->state->enable && funcs->mode_set_nofb) {
> +		if (crtc_state->enable && funcs->mode_set_nofb) {
>  			DRM_DEBUG_ATOMIC("modeset on [CRTC:%d:%s]\n",
>  					 crtc->base.id, crtc->name);
>  
> @@ -864,18 +866,18 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
>  		}
>  	}
>  
> -	for_each_connector_in_state(old_state, connector, old_conn_state, i) {
> +	for_each_new_connector_in_state(old_state, connector, conn_state, i) {
>  		const struct drm_encoder_helper_funcs *funcs;
>  		struct drm_crtc_state *new_crtc_state;
>  		struct drm_encoder *encoder;
>  		struct drm_display_mode *mode, *adjusted_mode;
>  
> -		if (!connector->state->best_encoder)
> +		if (!conn_state->best_encoder)
>  			continue;
>  
> -		encoder = connector->state->best_encoder;
> +		encoder = conn_state->best_encoder;
>  		funcs = encoder->helper_private;
> -		new_crtc_state = connector->state->crtc->state;
> +		new_crtc_state = conn_state->crtc->state;
>  		mode = &new_crtc_state->mode;
>  		adjusted_mode = &new_crtc_state->adjusted_mode;
>  
> @@ -891,7 +893,7 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
>  		 */
>  		if (funcs && funcs->atomic_mode_set) {
>  			funcs->atomic_mode_set(encoder, new_crtc_state,
> -					       connector->state);
> +					       conn_state);
>  		} else if (funcs && funcs->mode_set) {
>  			funcs->mode_set(encoder, mode, adjusted_mode);
>  		}
> @@ -943,24 +945,24 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
>  					      struct drm_atomic_state *old_state)
>  {
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *old_crtc_state;
> +	struct drm_crtc_state *crtc_state;
>  	struct drm_connector *connector;
> -	struct drm_connector_state *old_conn_state;
> +	struct drm_connector_state *conn_state;
>  	int i;
>  
> -	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
> +	for_each_new_crtc_in_state(old_state, crtc, crtc_state, i) {
>  		const struct drm_crtc_helper_funcs *funcs;
>  
>  		/* Need to filter out CRTCs where only planes change. */
> -		if (!drm_atomic_crtc_needs_modeset(crtc->state))
> +		if (!drm_atomic_crtc_needs_modeset(crtc_state))
>  			continue;
>  
> -		if (!crtc->state->active)
> +		if (!crtc_state->active)
>  			continue;
>  
>  		funcs = crtc->helper_private;
>  
> -		if (crtc->state->enable) {
> +		if (crtc_state->enable) {
>  			DRM_DEBUG_ATOMIC("enabling [CRTC:%d:%s]\n",
>  					 crtc->base.id, crtc->name);
>  
> @@ -971,18 +973,18 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
>  		}
>  	}
>  
> -	for_each_connector_in_state(old_state, connector, old_conn_state, i) {
> +	for_each_new_connector_in_state(old_state, connector, conn_state, i) {
>  		const struct drm_encoder_helper_funcs *funcs;
>  		struct drm_encoder *encoder;
>  
> -		if (!connector->state->best_encoder)
> +		if (!conn_state->best_encoder)
>  			continue;
>  
> -		if (!connector->state->crtc->state->active ||
> -		    !drm_atomic_crtc_needs_modeset(connector->state->crtc->state))
> +		if (!conn_state->crtc->state->active ||
> +		    !drm_atomic_crtc_needs_modeset(conn_state->crtc->state))

More foo->state stuff remaining

>  			continue;
>  
> -		encoder = connector->state->best_encoder;
> +		encoder = conn_state->best_encoder;
>  		funcs = encoder->helper_private;
>  
>  		DRM_DEBUG_ATOMIC("enabling [ENCODER:%d:%s]\n",
> @@ -1027,10 +1029,7 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev,
>  	struct drm_plane_state *plane_state;
>  	int i, ret;
>  
> -	for_each_plane_in_state(state, plane, plane_state, i) {
> -		if (!pre_swap)
> -			plane_state = plane->state;
> -
> +	for_each_new_plane_in_state(state, plane, plane_state, i) {

Nice. Can we kill the pre_swap flag now? Hmm, no, we pass it to
dma_fence_wait() to indicate interruptible vs. not. Maybe we can rename
it to convey its only remaining function better?

>  		if (!plane_state->fence)
>  			continue;
>  
> @@ -1072,15 +1071,15 @@ bool drm_atomic_helper_framebuffer_changed(struct drm_device *dev,
>  					   struct drm_crtc *crtc)
>  {
>  	struct drm_plane *plane;
> -	struct drm_plane_state *old_plane_state;
> +	struct drm_plane_state *old_plane_state, *new_plane_state;
>  	int i;
>  
> -	for_each_plane_in_state(old_state, plane, old_plane_state, i) {
> -		if (plane->state->crtc != crtc &&
> +	for_each_oldnew_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
> +		if (new_plane_state->crtc != crtc &&
>  		    old_plane_state->crtc != crtc)
>  			continue;
>  
> -		if (plane->state->fb != old_plane_state->fb)
> +		if (new_plane_state->fb != old_plane_state->fb)
>  			return true;
>  	}

This thing was totally broken, but I guess now it actually should
work regardless of when we call it. Cool.

I was actually wonder if we manage to plumb the old+new state everywhere
maybe we could kill off some of the need_whatever flags? Not quite sure.

>  
> @@ -1104,21 +1103,21 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
>  		struct drm_atomic_state *old_state)
>  {
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *old_crtc_state;
> +	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
>  	int i, ret;
>  
> -	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
> +	/* Legacy cursor ioctls are completely unsynced, and userspace
> +	 * relies on that (by doing tons of cursor updates). */
> +	if (old_state->legacy_cursor_update)
> +		return;
> +

We seem to have a change of behaviour here. Should be in a separate
patch if we actually want it.

> +	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
>  		/* No one cares about the old state, so abuse it for tracking
>  		 * and store whether we hold a vblank reference (and should do a
>  		 * vblank wait) in the ->enable boolean. */
>  		old_crtc_state->enable = false;
>  
> -		if (!crtc->state->enable)
> -			continue;
> -
> -		/* Legacy cursor ioctls are completely unsynced, and userspace
> -		 * relies on that (by doing tons of cursor updates). */
> -		if (old_state->legacy_cursor_update)
> +		if (!new_crtc_state->enable)
>  			continue;
>  
>  		if (!drm_atomic_helper_framebuffer_changed(dev,
> @@ -1133,7 +1132,7 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
>  		old_crtc_state->last_vblank_count = drm_crtc_vblank_count(crtc);
>  	}
>  
> -	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
> +	for_each_old_crtc_in_state(old_state, crtc, old_crtc_state, i) {
>  		if (!old_crtc_state->enable)
>  			continue;
>  

I think pretty much evething up to this point (from the last checkpoint)
is executed after swapping the state, with
drm_atomic_helper_framebuffer_changed() being the oddball that might be
called from anywhere.

> @@ -1432,11 +1431,11 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
>  				   bool nonblock)
>  {
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *crtc_state;
> +	struct drm_crtc_state *old_crtc_state, *crtc_state;
>  	struct drm_crtc_commit *commit;
>  	int i, ret;
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
>  		commit = kzalloc(sizeof(*commit), GFP_KERNEL);
>  		if (!commit)
>  			return -ENOMEM;
> @@ -1457,7 +1456,7 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
>  		/* Drivers only send out events when at least either current or
>  		 * new CRTC state is active. Complete right away if everything
>  		 * stays off. */
> -		if (!crtc->state->active && !crtc_state->active) {
> +		if (!old_crtc_state->active && !crtc_state->active) {
>  			complete_all(&commit->flip_done);
>  			continue;
>  		}

This guy is pre state swap. Looks correct.

> @@ -1521,7 +1520,7 @@ void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *state)
>  	int i;
>  	long ret;
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {

This is post state swap, but we don't actually use the new or the old
state here, so this looks fine.

>  		spin_lock(&crtc->commit_lock);
>  		commit = preceeding_commit(crtc);
>  		if (commit)
> @@ -1572,13 +1571,13 @@ void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *state)
>  	struct drm_crtc_commit *commit;
>  	int i;
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
>  		commit = state->crtcs[i].commit;
>  		if (!commit)
>  			continue;
>  
>  		/* backend must have consumed any event by now */
> -		WARN_ON(crtc->state->event);
> +		WARN_ON(crtc_state->event);

Post swap. Looks correct.

>  		spin_lock(&crtc->commit_lock);
>  		complete_all(&commit->hw_done);
>  		spin_unlock(&crtc->commit_lock);
> @@ -1605,7 +1604,7 @@ void drm_atomic_helper_commit_cleanup_done(struct drm_atomic_state *state)
>  	int i;
>  	long ret;
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {

Post swap. State not used, so fine.

>  		commit = state->crtcs[i].commit;
>  		if (WARN_ON(!commit))
>  			continue;
> @@ -1658,7 +1657,7 @@ int drm_atomic_helper_prepare_planes(struct drm_device *dev,
>  	struct drm_plane_state *plane_state;
>  	int ret, i, j;
>  
> -	for_each_plane_in_state(state, plane, plane_state, i) {
> +	for_each_new_plane_in_state(state, plane, plane_state, i) {
>  		const struct drm_plane_helper_funcs *funcs;
>  
>  		funcs = plane->helper_private;
> @@ -1676,7 +1675,7 @@ int drm_atomic_helper_prepare_planes(struct drm_device *dev,
>  	return 0;
>  
>  fail:
> -	for_each_plane_in_state(state, plane, plane_state, j) {
> +	for_each_new_plane_in_state(state, plane, plane_state, j) {

Pre swap stuff. Fine.

>  		const struct drm_plane_helper_funcs *funcs;
>  
>  		if (j >= i)
> @@ -1746,14 +1745,14 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
>  				     uint32_t flags)
>  {
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *old_crtc_state;
> +	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
>  	struct drm_plane *plane;
> -	struct drm_plane_state *old_plane_state;
> +	struct drm_plane_state *old_plane_state, *new_plane_state;
>  	int i;
>  	bool active_only = flags & DRM_PLANE_COMMIT_ACTIVE_ONLY;
>  	bool no_disable = flags & DRM_PLANE_COMMIT_NO_DISABLE_AFTER_MODESET;
>  
> -	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
> +	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
>  		const struct drm_crtc_helper_funcs *funcs;
>  
>  		funcs = crtc->helper_private;
> @@ -1761,13 +1760,13 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
>  		if (!funcs || !funcs->atomic_begin)
>  			continue;
>  
> -		if (active_only && !crtc->state->active)
> +		if (active_only && !new_crtc_state->active)
>  			continue;
>  
>  		funcs->atomic_begin(crtc, old_crtc_state);
>  	}
>  
> -	for_each_plane_in_state(old_state, plane, old_plane_state, i) {
> +	for_each_oldnew_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
>  		const struct drm_plane_helper_funcs *funcs;
>  		bool disabling;
>  
> @@ -1786,7 +1785,7 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
>  			 * CRTC to avoid skipping planes being disabled on an
>  			 * active CRTC.
>  			 */
> -			if (!disabling && !plane_crtc_active(plane->state))
> +			if (!disabling && !plane_crtc_active(new_plane_state))
>  				continue;
>  			if (disabling && !plane_crtc_active(old_plane_state))
>  				continue;
> @@ -1805,12 +1804,12 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
>  				continue;
>  
>  			funcs->atomic_disable(plane, old_plane_state);
> -		} else if (plane->state->crtc || disabling) {
> +		} else if (new_plane_state->crtc || disabling) {
>  			funcs->atomic_update(plane, old_plane_state);
>  		}
>  	}
>  
> -	for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
> +	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
>  		const struct drm_crtc_helper_funcs *funcs;
>  
>  		funcs = crtc->helper_private;
> @@ -1818,7 +1817,7 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
>  		if (!funcs || !funcs->atomic_flush)
>  			continue;
>  
> -		if (active_only && !crtc->state->active)
> +		if (active_only && !new_crtc_state->active)
>  			continue;
>  
>  		funcs->atomic_flush(crtc, old_crtc_state);
> @@ -1945,12 +1944,19 @@ void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
>  				      struct drm_atomic_state *old_state)
>  {
>  	struct drm_plane *plane;
> -	struct drm_plane_state *plane_state;
> +	struct drm_plane_state *plane_state, *new_plane_state;
>  	int i;
>  
> -	for_each_plane_in_state(old_state, plane, plane_state, i) {
> +	for_each_oldnew_plane_in_state(old_state, plane, plane_state, new_plane_state, i) {
>  		const struct drm_plane_helper_funcs *funcs;
>  
> +		/*
> +		 * This might be called before swapping when commit is aborted,
> +		 * in which case we have to free the new state.
> +		 */
> +		if (plane_state == plane->state)
> +			plane_state = new_plane_state;

Oh dear. Can we make this nicer somehow? I can't actually see any use
like that currently. Am I blind?

I was wondering if we should add some kind of asserts to a bunch of
these functions to make sure they are called during the correct phase
of the operation. We could track the progress in the top level state I
guess.

> +
>  		if (!drm_atomic_helper_framebuffer_changed(dev, old_state, plane_state->crtc))
>  			continue;
>  
> @@ -1998,15 +2004,15 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,
>  	int i;
>  	long ret;
>  	struct drm_connector *connector;
> -	struct drm_connector_state *conn_state;
> +	struct drm_connector_state *old_conn_state, *new_conn_state;
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *crtc_state;
> +	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
>  	struct drm_plane *plane;
> -	struct drm_plane_state *plane_state;
> +	struct drm_plane_state *old_plane_state, *new_plane_state;
>  	struct drm_crtc_commit *commit;
>  
>  	if (stall) {
> -		for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +		for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
>  			spin_lock(&crtc->commit_lock);
>  			commit = list_first_entry_or_null(&crtc->commit_list,
>  					struct drm_crtc_commit, commit_entry);
> @@ -2026,16 +2032,20 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,
>  		}
>  	}
>  
> -	for_each_connector_in_state(state, connector, conn_state, i) {
> -		connector->state->state = state;
> -		swap(state->connectors[i].state, connector->state);
> -		connector->state->state = NULL;
> +	for_each_oldnew_connector_in_state(state, connector, old_conn_state, new_conn_state, i) {
> +		old_conn_state->state = state;
> +		new_conn_state->state = NULL;
> +
> +		state->connectors[i].state = old_conn_state;
> +		connector->state = new_conn_state;
>  	}
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> -		crtc->state->state = state;
> -		swap(state->crtcs[i].state, crtc->state);
> -		crtc->state->state = NULL;
> +	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +		old_crtc_state->state = state;
> +		new_crtc_state->state = NULL;
> +
> +		state->crtcs[i].state = old_crtc_state;
> +		crtc->state = new_crtc_state;
>  
>  		if (state->crtcs[i].commit) {
>  			spin_lock(&crtc->commit_lock);
> @@ -2047,10 +2057,12 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,
>  		}
>  	}
>  
> -	for_each_plane_in_state(state, plane, plane_state, i) {
> -		plane->state->state = state;
> -		swap(state->planes[i].state, plane->state);
> -		plane->state->state = NULL;
> +	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
> +		old_plane_state->state = state;
> +		new_plane_state->state = NULL;
> +
> +		state->planes[i].state = old_plane_state;
> +		plane->state = new_plane_state;
>  	}
>  }

lgtm

>  EXPORT_SYMBOL(drm_atomic_helper_swap_state);
> @@ -2248,7 +2260,7 @@ static int update_output_state(struct drm_atomic_state *state,
>  	if (ret)
>  		return ret;
>  
> -	for_each_connector_in_state(state, connector, conn_state, i) {
> +	for_each_new_connector_in_state(state, connector, conn_state, i) {
>  		if (conn_state->crtc == set->crtc) {
>  			ret = drm_atomic_set_crtc_for_connector(conn_state,
>  								NULL);
> @@ -2270,7 +2282,7 @@ static int update_output_state(struct drm_atomic_state *state,
>  			return ret;
>  	}
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
>  		/* Don't update ->enable for the CRTC in the set_config request,
>  		 * since a mismatch would indicate a bug in the upper layers.
>  		 * The actual modeset code later on will catch any

Building up the new state. Looks correct.


Phew! Apart from some of the lingering foo->state dereferences and the
change in behaviour for legacy cursors, and the slight oddballness in
the plane_cleanup() I didn't spot anything wrong.

This thing could use a commit message I think. Could at least lay out
the basic rules on the foo->state/foo_state vs. old_state/new_state
replacements. Might help someone understand it who doesn't know so much
about the current state swapping mechanism.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [Intel-gfx] [PATCH 12/19] drm/msm: Use new atomic iterator macros
  2016-10-17 12:37 ` [PATCH 12/19] drm/msm: " Maarten Lankhorst
@ 2016-11-03 16:37   ` Ville Syrjälä
  0 siblings, 0 replies; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-03 16:37 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx, dri-devel

On Mon, Oct 17, 2016 at 02:37:11PM +0200, Maarten Lankhorst wrote:
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c   |  4 ++--
>  drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c   |  6 +++---
>  drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h   |  3 ++-
>  drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c |  4 ++--
>  drivers/gpu/drm/msm/msm_atomic.c          | 16 ++++++++--------
>  5 files changed, 17 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
> index 571a91ee9607..d18d0a0e0a35 100644
> --- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
> +++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
> @@ -113,7 +113,7 @@ static void mdp4_prepare_commit(struct msm_kms *kms, struct drm_atomic_state *st
>  	mdp4_enable(mdp4_kms);
>  
>  	/* see 119ecb7fd */
> -	for_each_crtc_in_state(state, crtc, crtc_state, i)
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i)
>  		drm_crtc_vblank_get(crtc);
>  }
>  
> @@ -125,7 +125,7 @@ static void mdp4_complete_commit(struct msm_kms *kms, struct drm_atomic_state *s
>  	struct drm_crtc_state *crtc_state;
>  
>  	/* see 119ecb7fd */
> -	for_each_crtc_in_state(state, crtc, crtc_state, i)
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i)
>  		drm_crtc_vblank_put(crtc);

post-swap, but crtc_state not used in either. So lgtm.

I wonder if you should go all in and try to rename all the foo_state variables
as new_foo_state and old_foo_state to make sure you didn't miss any uses which
might not agree with your new choice if iterator macro? Eg. if in this
case crtc_state was actually used but you failed notice it you would have
just broken something by using the _new_ iterator.

>  
>  	mdp4_disable(mdp4_kms);
> diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
> index ed7143d35b25..7cfeb0455039 100644
> --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
> +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
> @@ -82,10 +82,10 @@ static void mdp5_complete_commit(struct msm_kms *kms, struct drm_atomic_state *s
>  	int i;
>  	struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
>  	struct drm_plane *plane;
> -	struct drm_plane_state *plane_state;
> +	struct drm_plane_state *old_state, *new_state;
>  
> -	for_each_plane_in_state(state, plane, plane_state, i)
> -		mdp5_plane_complete_commit(plane, plane_state);
> +	for_each_oldnew_plane_in_state(state, plane, old_state, new_state, i)
> +		mdp5_plane_complete_commit(plane, old_state, new_state);
>  
>  	mdp5_disable(mdp5_kms);
>  }
> diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
> index 03738927be10..90e80619fc54 100644
> --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
> +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
> @@ -198,7 +198,8 @@ void mdp5_irq_domain_fini(struct mdp5_kms *mdp5_kms);
>  uint32_t mdp5_plane_get_flush(struct drm_plane *plane);
>  void mdp5_plane_complete_flip(struct drm_plane *plane);
>  void mdp5_plane_complete_commit(struct drm_plane *plane,
> -	struct drm_plane_state *state);
> +	struct drm_plane_state *old_state,
> +	struct drm_plane_state *new_state);
>  enum mdp5_pipe mdp5_plane_pipe(struct drm_plane *plane);
>  struct drm_plane *mdp5_plane_init(struct drm_device *dev,
>  		enum mdp5_pipe pipe, bool private_plane,
> diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
> index 951c002b05df..19c44b968f4e 100644
> --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
> +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
> @@ -859,13 +859,13 @@ uint32_t mdp5_plane_get_flush(struct drm_plane *plane)
>  
>  /* called after vsync in thread context */
>  void mdp5_plane_complete_commit(struct drm_plane *plane,
> -	struct drm_plane_state *state)
> +	struct drm_plane_state *old_state, struct drm_plane_state *new_state)
>  {
>  	struct mdp5_kms *mdp5_kms = get_kms(plane);
>  	struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
>  	enum mdp5_pipe pipe = mdp5_plane->pipe;
>  
> -	if (!plane_enabled(plane->state) && mdp5_kms->smp) {
> +	if (!plane_enabled(new_state) && mdp5_kms->smp) {
>  		DBG("%s: free SMP", mdp5_plane->name);
>  		mdp5_smp_release(mdp5_kms->smp, pipe);
>  	}

Doesn't look like this guy actually needs the old state. Not sure why it
was getting passed in. The replacement for plane->state looks correct
nonetheless.

> diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c
> index db193f835298..333c379e6561 100644
> --- a/drivers/gpu/drm/msm/msm_atomic.c
> +++ b/drivers/gpu/drm/msm/msm_atomic.c
> @@ -89,8 +89,8 @@ static void msm_atomic_wait_for_commit_done(struct drm_device *dev,
>  	struct msm_kms *kms = priv->kms;
>  	int i;
>  
> -	for_each_crtc_in_state(old_state, crtc, crtc_state, i) {
> -		if (!crtc->state->enable)
> +	for_each_new_crtc_in_state(old_state, crtc, crtc_state, i) {
> +		if (!crtc_state->enable)
>  			continue;

post-swap, lgtm.

>  
>  		/* Legacy cursor ioctls are completely unsynced, and userspace
> @@ -191,7 +191,7 @@ int msm_atomic_commit(struct drm_device *dev,
>  	struct drm_crtc *crtc;
>  	struct drm_crtc_state *crtc_state;
>  	struct drm_plane *plane;
> -	struct drm_plane_state *plane_state;
> +	struct drm_plane_state *new_plane_state, *old_plane_state;
>  	int i, ret;
>  
>  	ret = drm_atomic_helper_prepare_planes(dev, state);
> @@ -207,18 +207,18 @@ int msm_atomic_commit(struct drm_device *dev,
>  	/*
>  	 * Figure out what crtcs we have:
>  	 */
> -	for_each_crtc_in_state(state, crtc, crtc_state, i)
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i)
>  		c->crtc_mask |= drm_crtc_mask(crtc);
>  
>  	/*
>  	 * Figure out what fence to wait for:
>  	 */
> -	for_each_plane_in_state(state, plane, plane_state, i) {
> -		if ((plane->state->fb != plane_state->fb) && plane_state->fb) {
> -			struct drm_gem_object *obj = msm_framebuffer_bo(plane_state->fb, 0);
> +	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
> +		if (old_plane_state->fb != new_plane_state->fb && new_plane_state->fb) {
> +			struct drm_gem_object *obj = msm_framebuffer_bo(new_plane_state->fb, 0);
>  			struct msm_gem_object *msm_obj = to_msm_bo(obj);
>  
> -			plane_state->fence = reservation_object_get_excl_rcu(msm_obj->resv);
> +			new_plane_state->fence = reservation_object_get_excl_rcu(msm_obj->resv);
>  		}

pre-swap, lgtm.

Patches 08-12
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

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

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 14/19] drm/mediatek: Use new atomic iterator macros
  2016-10-17 12:37 ` [PATCH 14/19] drm/mediatek: " Maarten Lankhorst
@ 2016-11-03 16:39   ` Ville Syrjälä
  0 siblings, 0 replies; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-03 16:39 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx, dri-devel

On Mon, Oct 17, 2016 at 02:37:13PM +0200, Maarten Lankhorst wrote:
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>

Patches 13-14
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index db61aa5f32ef..414e848d8cbf 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -50,8 +50,8 @@ static void mtk_atomic_wait_for_fences(struct drm_atomic_state *state)
>  	struct drm_plane_state *plane_state;
>  	int i;
>  
> -	for_each_plane_in_state(state, plane, plane_state, i)
> -		mtk_fb_wait(plane->state->fb);
> +	for_each_new_plane_in_state(state, plane, plane_state, i)
> +		mtk_fb_wait(plane_state->fb);
>  }
>  
>  static void mtk_atomic_complete(struct mtk_drm_private *private,
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 16/19] drm/i915: Use new atomic iterator macros in fbc
  2016-10-17 12:37 ` [PATCH 16/19] drm/i915: Use new atomic iterator macros in fbc Maarten Lankhorst
@ 2016-11-03 16:45   ` Ville Syrjälä
  2016-11-03 17:45     ` Paulo Zanoni
  0 siblings, 1 reply; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-03 16:45 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx, Paulo Zanoni, dri-devel

On Mon, Oct 17, 2016 at 02:37:15PM +0200, Maarten Lankhorst wrote:
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_fbc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
> index faa67624e1ed..0028335fc1bb 100644
> --- a/drivers/gpu/drm/i915/intel_fbc.c
> +++ b/drivers/gpu/drm/i915/intel_fbc.c
> @@ -1060,7 +1060,7 @@ void intel_fbc_choose_crtc(struct drm_i915_private *dev_priv,
>  
>  	mutex_lock(&fbc->lock);
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
>  		if (fbc->crtc == to_intel_crtc(crtc)) {
>  			fbc_crtc_present = true;
>  			break;
> @@ -1074,14 +1074,14 @@ void intel_fbc_choose_crtc(struct drm_i915_private *dev_priv,
>  	 * plane. We could go for fancier schemes such as checking the plane
>  	 * size, but this would just affect the few platforms that don't tie FBC
>  	 * to pipe or plane A. */
> -	for_each_plane_in_state(state, plane, plane_state, i) {
> +	for_each_new_plane_in_state(state, plane, plane_state, i) {
>  		struct intel_plane_state *intel_plane_state =
>  			to_intel_plane_state(plane_state);
>  
>  		if (!intel_plane_state->base.visible)
>  			continue;

Unrelated but this thing looks somewhat bogus. FBC is tied to the
primary plane only, so why do we care about the visibility of the other
planes? Adding Paulo to Cc...

>  
> -		for_each_crtc_in_state(state, crtc, crtc_state, j) {
> +		for_each_new_crtc_in_state(state, crtc, crtc_state, j) {

Also, can't this inner loop be replaced with a simple
crtc = plane_state->crtc ?

>  			struct intel_crtc_state *intel_crtc_state =
>  				to_intel_crtc_state(crtc_state);
>  
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [Intel-gfx] [PATCH 17/19] drm/i915: Use new atomic iterator macros in wm code
  2016-10-17 12:37 ` [PATCH 17/19] drm/i915: Use new atomic iterator macros in wm code Maarten Lankhorst
@ 2016-11-03 16:49   ` Ville Syrjälä
  2016-11-03 17:53     ` Paulo Zanoni
  0 siblings, 1 reply; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-03 16:49 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: Lyude, intel-gfx, Paulo Zanoni, dri-devel

On Mon, Oct 17, 2016 at 02:37:16PM +0200, Maarten Lankhorst wrote:
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_pm.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index 2df06b703e3d..163b73b493bf 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -3227,7 +3227,7 @@ skl_get_total_relative_data_rate(struct intel_crtc_state *intel_cstate)
>  		return 0;
>  
>  	/* Calculate and cache data rate for each plane */
> -	for_each_plane_in_state(state, plane, pstate, i) {
> +	for_each_new_plane_in_state(state, plane, pstate, i) {

Looks like this patch needs a refresh due to my tardiness in reviewing
it.

Also unrelated, but I recently noticed that
skl_get_total_relative_data_rate() doesn't exclude the cursor plane
from the calculation. I'm thinking it should. Adding some Cc:s...

>  		id = skl_wm_plane_id(to_intel_plane(plane));
>  		intel_plane = to_intel_plane(plane);
>  
> @@ -3364,14 +3364,14 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate,
>  	alloc_size -= cursor_blocks;
>  
>  	/* 1. Allocate the mininum required blocks for each active plane */
> -	for_each_plane_in_state(state, plane, pstate, i) {
> +	for_each_new_plane_in_state(state, plane, pstate, i) {
>  		intel_plane = to_intel_plane(plane);
>  		id = skl_wm_plane_id(intel_plane);
>  
>  		if (intel_plane->pipe != pipe)
>  			continue;
>  
> -		if (!to_intel_plane_state(pstate)->base.visible) {
> +		if (!pstate->visible) {
>  			minimum[id] = 0;
>  			y_minimum[id] = 0;
>  			continue;
> @@ -3933,7 +3933,7 @@ pipes_modified(struct drm_atomic_state *state)
>  	struct drm_crtc_state *cstate;
>  	uint32_t i, ret = 0;
>  
> -	for_each_crtc_in_state(state, crtc, cstate, i)
> +	for_each_new_crtc_in_state(state, crtc, cstate, i)
>  		ret |= drm_crtc_mask(crtc);
>  
>  	return ret;
> @@ -4048,7 +4048,7 @@ skl_compute_wm(struct drm_atomic_state *state)
>  	 * since any racing commits that want to update them would need to
>  	 * hold _all_ CRTC state mutexes.
>  	 */
> -	for_each_crtc_in_state(state, crtc, cstate, i)
> +	for_each_new_crtc_in_state(state, crtc, cstate, i)
>  		changed = true;
>  	if (!changed)
>  		return 0;
> @@ -4070,7 +4070,7 @@ skl_compute_wm(struct drm_atomic_state *state)
>  	 * should allow skl_update_pipe_wm() to return failure in cases where
>  	 * no suitable watermark values can be found.
>  	 */
> -	for_each_crtc_in_state(state, crtc, cstate, i) {
> +	for_each_new_crtc_in_state(state, crtc, cstate, i) {
>  		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>  		struct intel_crtc_state *intel_cstate =
>  			to_intel_crtc_state(cstate);
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [Intel-gfx] [PATCH 18/19] drm/i915: Use new atomic iterator macros in display code
  2016-10-17 12:37 ` [PATCH 18/19] drm/i915: Use new atomic iterator macros in display code Maarten Lankhorst
@ 2016-11-03 17:04   ` Ville Syrjälä
  0 siblings, 0 replies; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-03 17:04 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx, dri-devel

On Mon, Oct 17, 2016 at 02:37:17PM +0200, Maarten Lankhorst wrote:
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 156 ++++++++++++++++++-----------------
>  1 file changed, 80 insertions(+), 76 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 3bd3f6a93c12..d310abace86a 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -3510,7 +3510,12 @@ __intel_display_resume(struct drm_device *dev,
>  	if (!state)
>  		return 0;
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	/*
> +	 * We've duplicated the state, pointers to the old state are invalid.
> +	 *
> +	 * Don't attempt to use the old state until we commit the duplicated state.
> +	 */
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
>  		/*
>  		 * Force recalculation even if we restore
>  		 * current state. With fast modeset this may not result
> @@ -5078,13 +5083,12 @@ static void intel_post_plane_update(struct intel_crtc_state *old_crtc_state)
>  	}
>  }
>  
> -static void intel_pre_plane_update(struct intel_crtc_state *old_crtc_state)
> +static void intel_pre_plane_update(struct intel_crtc_state *old_crtc_state,
> +				   struct intel_crtc_state *pipe_config)
>  {
>  	struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc);
>  	struct drm_device *dev = crtc->base.dev;
>  	struct drm_i915_private *dev_priv = to_i915(dev);
> -	struct intel_crtc_state *pipe_config =
> -		to_intel_crtc_state(crtc->base.state);
>  	struct drm_atomic_state *old_state = old_crtc_state->base.state;
>  	struct drm_plane *primary = crtc->base.primary;
>  	struct drm_plane_state *old_pri_state =
> @@ -5186,12 +5190,11 @@ static void intel_encoders_pre_pll_enable(struct drm_crtc *crtc,
>  					  struct intel_crtc_state *crtc_state,
>  					  struct drm_atomic_state *old_state)
>  {
> -	struct drm_connector_state *old_conn_state;
> +	struct drm_connector_state *conn_state;
>  	struct drm_connector *conn;
>  	int i;
>  
> -	for_each_connector_in_state(old_state, conn, old_conn_state, i) {
> -		struct drm_connector_state *conn_state = conn->state;
> +	for_each_new_connector_in_state(old_state, conn, conn_state, i) {
>  		struct intel_encoder *encoder =
>  			to_intel_encoder(conn_state->best_encoder);
>  
> @@ -5207,12 +5210,11 @@ static void intel_encoders_pre_enable(struct drm_crtc *crtc,
>  				      struct intel_crtc_state *crtc_state,
>  				      struct drm_atomic_state *old_state)
>  {
> -	struct drm_connector_state *old_conn_state;
> +	struct drm_connector_state *conn_state;
>  	struct drm_connector *conn;
>  	int i;
>  
> -	for_each_connector_in_state(old_state, conn, old_conn_state, i) {
> -		struct drm_connector_state *conn_state = conn->state;
> +	for_each_new_connector_in_state(old_state, conn, conn_state, i) {
>  		struct intel_encoder *encoder =
>  			to_intel_encoder(conn_state->best_encoder);
>  
> @@ -5228,12 +5230,11 @@ static void intel_encoders_enable(struct drm_crtc *crtc,
>  				  struct intel_crtc_state *crtc_state,
>  				  struct drm_atomic_state *old_state)
>  {
> -	struct drm_connector_state *old_conn_state;
> +	struct drm_connector_state *conn_state;
>  	struct drm_connector *conn;
>  	int i;
>  
> -	for_each_connector_in_state(old_state, conn, old_conn_state, i) {
> -		struct drm_connector_state *conn_state = conn->state;
> +	for_each_new_connector_in_state(old_state, conn, conn_state, i) {
>  		struct intel_encoder *encoder =
>  			to_intel_encoder(conn_state->best_encoder);
>  
> @@ -5253,7 +5254,7 @@ static void intel_encoders_disable(struct drm_crtc *crtc,
>  	struct drm_connector *conn;
>  	int i;
>  
> -	for_each_connector_in_state(old_state, conn, old_conn_state, i) {
> +	for_each_old_connector_in_state(old_state, conn, old_conn_state, i) {
>  		struct intel_encoder *encoder =
>  			to_intel_encoder(old_conn_state->best_encoder);
>  
> @@ -5273,7 +5274,7 @@ static void intel_encoders_post_disable(struct drm_crtc *crtc,
>  	struct drm_connector *conn;
>  	int i;
>  
> -	for_each_connector_in_state(old_state, conn, old_conn_state, i) {
> +	for_each_old_connector_in_state(old_state, conn, old_conn_state, i) {
>  		struct intel_encoder *encoder =
>  			to_intel_encoder(old_conn_state->best_encoder);
>  
> @@ -5293,7 +5294,7 @@ static void intel_encoders_post_pll_disable(struct drm_crtc *crtc,
>  	struct drm_connector *conn;
>  	int i;
>  
> -	for_each_connector_in_state(old_state, conn, old_conn_state, i) {
> +	for_each_old_connector_in_state(old_state, conn, old_conn_state, i) {
>  		struct intel_encoder *encoder =
>  			to_intel_encoder(old_conn_state->best_encoder);
>  
> @@ -6573,7 +6574,7 @@ static int intel_mode_max_pixclk(struct drm_device *dev,
>  	memcpy(intel_state->min_pixclk, dev_priv->min_pixclk,
>  	       sizeof(intel_state->min_pixclk));
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
>  		int pixclk = 0;
>  
>  		if (crtc_state->enable)
> @@ -10238,7 +10239,7 @@ static int ilk_max_pixel_rate(struct drm_atomic_state *state)
>  	memcpy(intel_state->min_pixclk, dev_priv->min_pixclk,
>  	       sizeof(intel_state->min_pixclk));
>  
> -	for_each_crtc_in_state(state, crtc, cstate, i) {
> +	for_each_new_crtc_in_state(state, crtc, cstate, i) {
>  		int pixel_rate;
>  
>  		crtc_state = to_intel_crtc_state(cstate);
> @@ -12530,7 +12531,7 @@ static bool check_single_encoder_cloning(struct drm_atomic_state *state,
>  	struct drm_connector_state *connector_state;
>  	int i;
>  
> -	for_each_connector_in_state(state, connector, connector_state, i) {
> +	for_each_new_connector_in_state(state, connector, connector_state, i) {
>  		if (connector_state->crtc != &crtc->base)
>  			continue;
>  
> @@ -12700,7 +12701,7 @@ compute_baseline_pipe_bpp(struct intel_crtc *crtc,
>  	state = pipe_config->base.state;
>  
>  	/* Clamp display bpp to EDID value */
> -	for_each_connector_in_state(state, connector, connector_state, i) {
> +	for_each_new_connector_in_state(state, connector, connector_state, i) {
>  		if (connector_state->crtc != &crtc->base)
>  			continue;
>  
> @@ -12992,7 +12993,7 @@ intel_modeset_pipe_config(struct drm_crtc *crtc,
>  			       &pipe_config->pipe_src_w,
>  			       &pipe_config->pipe_src_h);
>  
> -	for_each_connector_in_state(state, connector, connector_state, i) {
> +	for_each_new_connector_in_state(state, connector, connector_state, i) {
>  		if (connector_state->crtc != crtc)
>  			continue;
>  
> @@ -13023,7 +13024,7 @@ encoder_retry:
>  	 * adjust it according to limitations or connector properties, and also
>  	 * a chance to reject the mode entirely.
>  	 */
> -	for_each_connector_in_state(state, connector, connector_state, i) {
> +	for_each_new_connector_in_state(state, connector, connector_state, i) {
>  		if (connector_state->crtc != crtc)
>  			continue;
>  
> @@ -13072,16 +13073,16 @@ static void
>  intel_modeset_update_crtc_state(struct drm_atomic_state *state)
>  {
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *crtc_state;
> +	struct drm_crtc_state *new_crtc_state;
>  	int i;
>  
>  	/* Double check state. */
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> -		to_intel_crtc(crtc)->config = to_intel_crtc_state(crtc->state);
> +	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
> +		to_intel_crtc(crtc)->config = to_intel_crtc_state(new_crtc_state);
>  
>  		/* Update hwmode for vblank functions */
> -		if (crtc->state->active)
> -			crtc->hwmode = crtc->state->adjusted_mode;
> +		if (new_crtc_state->active)
> +			crtc->hwmode = new_crtc_state->adjusted_mode;
>  		else
>  			crtc->hwmode.crtc_clock = 0;
>  

There's some primary->state stuff left after this point.

> @@ -13753,21 +13754,21 @@ static void intel_modeset_clear_plls(struct drm_atomic_state *state)
>  	struct drm_i915_private *dev_priv = to_i915(dev);
>  	struct intel_shared_dpll_config *shared_dpll = NULL;
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *crtc_state;
> +	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
>  	int i;
>  
>  	if (!dev_priv->display.crtc_compute_clock)
>  		return;
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>  		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>  		struct intel_shared_dpll *old_dpll =
> -			to_intel_crtc_state(crtc->state)->shared_dpll;
> +			to_intel_crtc_state(old_crtc_state)->shared_dpll;
>  
> -		if (!needs_modeset(crtc_state))
> +		if (!needs_modeset(new_crtc_state))
>  			continue;
>  
> -		to_intel_crtc_state(crtc_state)->shared_dpll = NULL;
> +		to_intel_crtc_state(new_crtc_state)->shared_dpll = NULL;
>  
>  		if (!old_dpll)
>  			continue;
> @@ -13796,7 +13797,7 @@ static int haswell_mode_set_planes_workaround(struct drm_atomic_state *state)
>  	int i;
>  
>  	/* look at all crtc's that are going to be enabled in during modeset */
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
>  		intel_crtc = to_intel_crtc(crtc);
>  
>  		if (!crtc_state->active || !needs_modeset(crtc_state))
> @@ -13878,7 +13879,7 @@ static int intel_modeset_checks(struct drm_atomic_state *state)
>  	struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
>  	struct drm_i915_private *dev_priv = to_i915(state->dev);
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *crtc_state;
> +	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
>  	int ret = 0, i;
>  
>  	if (!check_digital_port_conflicts(state)) {
> @@ -13889,13 +13890,13 @@ static int intel_modeset_checks(struct drm_atomic_state *state)
>  	intel_state->modeset = true;
>  	intel_state->active_crtcs = dev_priv->active_crtcs;
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> -		if (crtc_state->active)
> +	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +		if (new_crtc_state->active)
>  			intel_state->active_crtcs |= 1 << i;
>  		else
>  			intel_state->active_crtcs &= ~(1 << i);
>  
> -		if (crtc_state->active != crtc->state->active)
> +		if (old_crtc_state->active != new_crtc_state->active)

Almost caught me with rearragning the order ;)

>  			intel_state->active_pipe_changes |= drm_crtc_mask(crtc);
>  	}
>  
> @@ -13964,7 +13965,7 @@ static int intel_atomic_check(struct drm_device *dev,
>  	struct drm_i915_private *dev_priv = to_i915(dev);
>  	struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *crtc_state;
> +	struct drm_crtc_state *old_crtc_state, *crtc_state;
>  	int ret, i;
>  	bool any_ms = false;
>  
> @@ -13972,12 +13973,12 @@ static int intel_atomic_check(struct drm_device *dev,
>  	if (ret)
>  		return ret;
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
>  		struct intel_crtc_state *pipe_config =
>  			to_intel_crtc_state(crtc_state);
>  
>  		/* Catch I915_MODE_FLAG_INHERITED */
> -		if (crtc_state->mode.private_flags != crtc->state->mode.private_flags)
> +		if (crtc_state->mode.private_flags != old_crtc_state->mode.private_flags)
>  			crtc_state->mode_changed = true;
>  
>  		if (!needs_modeset(crtc_state))
> @@ -14004,7 +14005,7 @@ static int intel_atomic_check(struct drm_device *dev,
>  
>  		if (i915.fastboot &&
>  		    intel_pipe_config_compare(dev,
> -					to_intel_crtc_state(crtc->state),
> +					to_intel_crtc_state(old_crtc_state),
>  					pipe_config, true)) {
>  			crtc_state->mode_changed = false;
>  			to_intel_crtc_state(crtc_state)->update_pipe = true;
> @@ -14049,7 +14050,7 @@ static int intel_atomic_prepare_commit(struct drm_device *dev,
>  	struct drm_crtc *crtc;
>  	int i, ret;
>  
> -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
>  		if (state->legacy_cursor_update)
>  			continue;
>  
> @@ -14069,7 +14070,7 @@ static int intel_atomic_prepare_commit(struct drm_device *dev,
>  	mutex_unlock(&dev->struct_mutex);
>  
>  	if (!ret && !nonblock) {
> -		for_each_plane_in_state(state, plane, plane_state, i) {
> +		for_each_new_plane_in_state(state, plane, plane_state, i) {
>  			struct intel_plane_state *intel_plane_state =
>  				to_intel_plane_state(plane_state);
>  
> @@ -14171,19 +14172,21 @@ static bool needs_vblank_wait(struct intel_crtc_state *crtc_state)
>  static void intel_update_crtc(struct drm_crtc *crtc,
>  			      struct drm_atomic_state *state,
>  			      struct drm_crtc_state *old_crtc_state,
> +			      struct drm_crtc_state *new_crtc_state,
>  			      unsigned int *crtc_vblank_mask)
>  {
>  	struct drm_device *dev = crtc->dev;
>  	struct drm_i915_private *dev_priv = to_i915(dev);
>  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> -	struct intel_crtc_state *pipe_config = to_intel_crtc_state(crtc->state);
> -	bool modeset = needs_modeset(crtc->state);
> +	struct intel_crtc_state *pipe_config = to_intel_crtc_state(new_crtc_state);
> +	bool modeset = needs_modeset(new_crtc_state);
>  
>  	if (modeset) {
>  		update_scanline_offset(intel_crtc);
>  		dev_priv->display.crtc_enable(pipe_config, state);
>  	} else {
> -		intel_pre_plane_update(to_intel_crtc_state(old_crtc_state));
> +		intel_pre_plane_update(to_intel_crtc_state(old_crtc_state),
> +				       pipe_config);
>  	}
>  
>  	if (drm_atomic_get_existing_plane_state(state, crtc->primary)) {
> @@ -14202,15 +14205,15 @@ static void intel_update_crtcs(struct drm_atomic_state *state,
>  			       unsigned int *crtc_vblank_mask)
>  {
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *old_crtc_state;
> +	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
>  	int i;
>  
> -	for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
> -		if (!crtc->state->active)
> +	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +		if (!new_crtc_state->active)
>  			continue;
>  
>  		intel_update_crtc(crtc, state, old_crtc_state,
> -				  crtc_vblank_mask);
> +				  new_crtc_state, crtc_vblank_mask);
>  	}
>  }
>  
> @@ -14221,7 +14224,7 @@ static void skl_update_crtcs(struct drm_atomic_state *state,
>  	struct drm_i915_private *dev_priv = to_i915(dev);
>  	struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
>  	struct drm_crtc *crtc;
> -	struct drm_crtc_state *old_crtc_state;
> +	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
>  	struct skl_ddb_allocation *new_ddb = &intel_state->wm_results.ddb;
>  	struct skl_ddb_allocation *cur_ddb = &dev_priv->wm.skl_hw.ddb;
>  	unsigned int updated = 0;
> @@ -14238,12 +14241,12 @@ static void skl_update_crtcs(struct drm_atomic_state *state,
>  		int i;
>  		progress = false;
>  
> -		for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
> +		for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>  			bool vbl_wait = false;
>  			unsigned int cmask = drm_crtc_mask(crtc);
>  			pipe = to_intel_crtc(crtc)->pipe;
>  
> -			if (updated & cmask || !crtc->state->active)
> +			if (updated & cmask || !new_crtc_state->active)
>  				continue;
>  			if (skl_ddb_allocation_overlaps(state, cur_ddb, new_ddb,
>  							pipe))
> @@ -14258,12 +14261,12 @@ static void skl_update_crtcs(struct drm_atomic_state *state,
>  			 * new ddb allocation to take effect.
>  			 */
>  			if (!skl_ddb_allocation_equals(cur_ddb, new_ddb, pipe) &&
> -			    !crtc->state->active_changed &&
> +			    !new_crtc_state->active_changed &&
>  			    intel_state->wm_results.dirty_pipes != updated)
>  				vbl_wait = true;
>  
>  			intel_update_crtc(crtc, state, old_crtc_state,
> -					  crtc_vblank_mask);
> +					  new_crtc_state, crtc_vblank_mask);
>  
>  			if (vbl_wait)
>  				intel_wait_for_vblank(dev, pipe);
> @@ -14278,7 +14281,7 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
>  	struct drm_device *dev = state->dev;
>  	struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
>  	struct drm_i915_private *dev_priv = to_i915(dev);
> -	struct drm_crtc_state *old_crtc_state;
> +	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
>  	struct drm_crtc *crtc;
>  	struct intel_crtc_state *intel_cstate;
>  	struct drm_plane *plane;
> @@ -14288,7 +14291,7 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
>  	unsigned crtc_vblank_mask = 0;
>  	int i, ret;
>  
> -	for_each_plane_in_state(state, plane, plane_state, i) {
> +	for_each_new_plane_in_state(state, plane, plane_state, i) {
>  		struct intel_plane_state *intel_plane_state =
>  			to_intel_plane_state(plane_state);
>  
> @@ -14313,22 +14316,23 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
>  		intel_display_power_get(dev_priv, POWER_DOMAIN_MODESET);
>  	}
>  
> -	for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
> +	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>  		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>  
> -		if (needs_modeset(crtc->state) ||
> -		    to_intel_crtc_state(crtc->state)->update_pipe) {
> +		if (needs_modeset(new_crtc_state) ||
> +		    to_intel_crtc_state(new_crtc_state)->update_pipe) {
>  			hw_check = true;
>  
>  			put_domains[to_intel_crtc(crtc)->pipe] =
>  				modeset_get_crtc_power_domains(crtc,
> -					to_intel_crtc_state(crtc->state));
> +					to_intel_crtc_state(new_crtc_state));
>  		}
>  
> -		if (!needs_modeset(crtc->state))
> +		if (!needs_modeset(new_crtc_state))
>  			continue;
>  
> -		intel_pre_plane_update(to_intel_crtc_state(old_crtc_state));
> +		intel_pre_plane_update(to_intel_crtc_state(old_crtc_state),
> +				       to_intel_crtc_state(new_crtc_state));
>  
>  		if (old_crtc_state->active) {
>  			intel_crtc_disable_planes(crtc, old_crtc_state->plane_mask);
> @@ -14372,16 +14376,16 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
>  	}
>  
>  	/* Complete the events for pipes that have now been disabled */
> -	for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
> -		bool modeset = needs_modeset(crtc->state);
> +	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
> +		bool modeset = needs_modeset(new_crtc_state);
>  
>  		/* Complete events for now disable pipes here. */
> -		if (modeset && !crtc->state->active && crtc->state->event) {
> +		if (modeset && !new_crtc_state->active && new_crtc_state->event) {
>  			spin_lock_irq(&dev->event_lock);
> -			drm_crtc_send_vblank_event(crtc, crtc->state->event);
> +			drm_crtc_send_vblank_event(crtc, new_crtc_state->event);
>  			spin_unlock_irq(&dev->event_lock);
>  
> -			crtc->state->event = NULL;
> +			new_crtc_state->event = NULL;
>  		}
>  	}
>  
> @@ -14407,20 +14411,20 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
>  	 *
>  	 * TODO: Move this (and other cleanup) to an async worker eventually.
>  	 */
> -	for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
> -		intel_cstate = to_intel_crtc_state(crtc->state);
> +	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
> +		intel_cstate = to_intel_crtc_state(new_crtc_state);
>  
>  		if (dev_priv->display.optimize_watermarks)
>  			dev_priv->display.optimize_watermarks(intel_cstate);
>  	}
>  
> -	for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
> +	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>  		intel_post_plane_update(to_intel_crtc_state(old_crtc_state));
>  
>  		if (put_domains[i])
>  			modeset_put_power_domains(dev_priv, put_domains[i]);
>  
> -		intel_modeset_verify_crtc(crtc, old_crtc_state, crtc->state);
> +		intel_modeset_verify_crtc(crtc, old_crtc_state, new_crtc_state);
>  	}
>  
>  	if (IS_SKYLAKE(dev_priv) && intel_state->modeset &&
> @@ -14464,13 +14468,13 @@ static void intel_atomic_commit_work(struct work_struct *work)
>  
>  static void intel_atomic_track_fbs(struct drm_atomic_state *state)
>  {
> -	struct drm_plane_state *old_plane_state;
> +	struct drm_plane_state *old_plane_state, *new_plane_state;
>  	struct drm_plane *plane;
>  	int i;
>  
> -	for_each_plane_in_state(state, plane, old_plane_state, i)
> +	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i)
>  		i915_gem_track_fb(intel_fb_obj(old_plane_state->fb),
> -				  intel_fb_obj(plane->state->fb),
> +				  intel_fb_obj(new_plane_state->fb),
>  				  to_intel_plane(plane)->frontbuffer_bit);
>  }
>  
> @@ -16299,7 +16303,7 @@ retry:
>  	}
>  
>  	/* Write calculated watermark values back */
> -	for_each_crtc_in_state(state, crtc, cstate, i) {
> +	for_each_new_crtc_in_state(state, crtc, cstate, i) {
>  		struct intel_crtc_state *cs = to_intel_crtc_state(cstate);
>  
>  		cs->wm.need_postvbl_update = true;

Apart from that lingering primary->state stuff this seems good. I can't
say how many other foo->state dereferences still remain as I didn't
crawl through the entire codebase.

With that caveat in mind this is
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

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

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 15/19] drm/i915: Use new atomic iterator macros in ddi
  2016-10-17 12:37 ` [PATCH 15/19] drm/i915: Use new atomic iterator macros in ddi Maarten Lankhorst
@ 2016-11-03 17:07   ` Ville Syrjälä
  0 siblings, 0 replies; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-03 17:07 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx, dri-devel

On Mon, Oct 17, 2016 at 02:37:14PM +0200, Maarten Lankhorst wrote:
> Also make the function static, it's only used inside intel_ddi.c
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_ddi.c | 4 ++--
>  drivers/gpu/drm/i915/intel_drv.h | 2 --
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> index 15d47c87def6..0e79c84e14e0 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -740,7 +740,7 @@ intel_ddi_get_crtc_encoder(struct drm_crtc *crtc)
>  	return ret;
>  }
>  
> -struct intel_encoder *
> +static struct intel_encoder *
>  intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state)
>  {
>  	struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
> @@ -753,7 +753,7 @@ intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state)
>  
>  	state = crtc_state->base.state;
>  
> -	for_each_connector_in_state(state, connector, connector_state, i) {
> +	for_each_new_connector_in_state(state, connector, connector_state, i) {
>  		if (connector_state->crtc != crtc_state->base.crtc)
>  			continue;

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

>  
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 8fd16adf069b..588d8af68043 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -1156,8 +1156,6 @@ void intel_ddi_prepare_link_retrain(struct intel_dp *intel_dp);
>  bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
>  void intel_ddi_get_config(struct intel_encoder *encoder,
>  			  struct intel_crtc_state *pipe_config);
> -struct intel_encoder *
> -intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state);
>  
>  void intel_ddi_init_dp_buf_reg(struct intel_encoder *encoder);
>  void intel_ddi_clock_get(struct intel_encoder *encoder,
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [Intel-gfx] [PATCH 19/19] drm/atomic: Rename atomic oldnew iterator
  2016-10-17 12:37 ` [PATCH 19/19] drm/atomic: Rename atomic oldnew iterator Maarten Lankhorst
@ 2016-11-03 17:11   ` Ville Syrjälä
  0 siblings, 0 replies; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-03 17:11 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx, dri-devel

On Mon, Oct 17, 2016 at 02:37:18PM +0200, Maarten Lankhorst wrote:
> With the old users of for_each_obj_in_state gone, we can rename
> for_each_oldnew_obj_in_state back to that name. It's slightly less
> ugly.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>

Simple sed/coccinelle job I presume. Assuming the tool works
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---
>  drivers/gpu/drm/drm_atomic_helper.c         | 34 ++++++++++++++---------------
>  drivers/gpu/drm/drm_blend.c                 |  4 ++--
>  drivers/gpu/drm/i915/intel_display.c        | 16 +++++++-------
>  drivers/gpu/drm/imx/imx-drm-core.c          |  2 +-
>  drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c     |  2 +-
>  drivers/gpu/drm/msm/msm_atomic.c            |  2 +-
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c |  2 +-
>  drivers/gpu/drm/vc4/vc4_kms.c               |  2 +-
>  include/drm/drm_atomic.h                    | 30 +++----------------------
>  9 files changed, 35 insertions(+), 59 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index c8aba493fc17..8fb955181641 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -241,7 +241,7 @@ steal_encoder(struct drm_atomic_state *state,
>  	struct drm_connector_state *old_connector_state, *new_connector_state;
>  	int i;
>  
> -	for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i) {
> +	for_each_connector_in_state(state, connector, old_connector_state, new_connector_state, i) {
>  		struct drm_crtc *encoder_crtc;
>  
>  		if (new_connector_state->best_encoder != encoder)
> @@ -482,7 +482,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
>  	struct drm_connector_state *old_connector_state, *new_connector_state;
>  	int i, ret;
>  
> -	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>  		if (!drm_mode_equal(&old_crtc_state->mode, &new_crtc_state->mode)) {
>  			DRM_DEBUG_ATOMIC("[CRTC:%d:%s] mode changed\n",
>  					 crtc->base.id, crtc->name);
> @@ -510,7 +510,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
>  	if (ret)
>  		return ret;
>  
> -	for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i) {
> +	for_each_connector_in_state(state, connector, old_connector_state, new_connector_state, i) {
>  		/*
>  		 * This only sets crtc->connectors_changed for routing changes,
>  		 * drivers must set crtc->connectors_changed themselves when
> @@ -529,7 +529,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
>  	 * configuration. This must be done before calling mode_fixup in case a
>  	 * crtc only changed its mode but has the same set of connectors.
>  	 */
> -	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>  		bool has_connectors =
>  			!!new_crtc_state->connector_mask;
>  
> @@ -685,7 +685,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
>  	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
>  	int i;
>  
> -	for_each_oldnew_connector_in_state(old_state, connector, old_conn_state, new_conn_state, i) {
> +	for_each_connector_in_state(old_state, connector, old_conn_state, new_conn_state, i) {
>  		const struct drm_encoder_helper_funcs *funcs;
>  		struct drm_encoder *encoder;
>  
> @@ -733,7 +733,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
>  		drm_bridge_post_disable(encoder->bridge);
>  	}
>  
> -	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
> +	for_each_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
>  		const struct drm_crtc_helper_funcs *funcs;
>  
>  		/* Shut down everything that needs a full modeset. */
> @@ -785,7 +785,7 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
>  	int i;
>  
>  	/* clear out existing links and update dpms */
> -	for_each_oldnew_connector_in_state(old_state, connector, old_conn_state, new_conn_state, i) {
> +	for_each_connector_in_state(old_state, connector, old_conn_state, new_conn_state, i) {
>  		if (connector->encoder) {
>  			WARN_ON(!connector->encoder->crtc);
>  
> @@ -1074,7 +1074,7 @@ bool drm_atomic_helper_framebuffer_changed(struct drm_device *dev,
>  	struct drm_plane_state *old_plane_state, *new_plane_state;
>  	int i;
>  
> -	for_each_oldnew_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
> +	for_each_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
>  		if (new_plane_state->crtc != crtc &&
>  		    old_plane_state->crtc != crtc)
>  			continue;
> @@ -1111,7 +1111,7 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
>  	if (old_state->legacy_cursor_update)
>  		return;
>  
> -	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
> +	for_each_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
>  		/* No one cares about the old state, so abuse it for tracking
>  		 * and store whether we hold a vblank reference (and should do a
>  		 * vblank wait) in the ->enable boolean. */
> @@ -1435,7 +1435,7 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
>  	struct drm_crtc_commit *commit;
>  	int i, ret;
>  
> -	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
> +	for_each_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
>  		commit = kzalloc(sizeof(*commit), GFP_KERNEL);
>  		if (!commit)
>  			return -ENOMEM;
> @@ -1752,7 +1752,7 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
>  	bool active_only = flags & DRM_PLANE_COMMIT_ACTIVE_ONLY;
>  	bool no_disable = flags & DRM_PLANE_COMMIT_NO_DISABLE_AFTER_MODESET;
>  
> -	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
> +	for_each_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
>  		const struct drm_crtc_helper_funcs *funcs;
>  
>  		funcs = crtc->helper_private;
> @@ -1766,7 +1766,7 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
>  		funcs->atomic_begin(crtc, old_crtc_state);
>  	}
>  
> -	for_each_oldnew_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
> +	for_each_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
>  		const struct drm_plane_helper_funcs *funcs;
>  		bool disabling;
>  
> @@ -1809,7 +1809,7 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
>  		}
>  	}
>  
> -	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
> +	for_each_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
>  		const struct drm_crtc_helper_funcs *funcs;
>  
>  		funcs = crtc->helper_private;
> @@ -1947,7 +1947,7 @@ void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
>  	struct drm_plane_state *plane_state, *new_plane_state;
>  	int i;
>  
> -	for_each_oldnew_plane_in_state(old_state, plane, plane_state, new_plane_state, i) {
> +	for_each_plane_in_state(old_state, plane, plane_state, new_plane_state, i) {
>  		const struct drm_plane_helper_funcs *funcs;
>  
>  		/*
> @@ -2032,7 +2032,7 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,
>  		}
>  	}
>  
> -	for_each_oldnew_connector_in_state(state, connector, old_conn_state, new_conn_state, i) {
> +	for_each_connector_in_state(state, connector, old_conn_state, new_conn_state, i) {
>  		old_conn_state->state = state;
>  		new_conn_state->state = NULL;
>  
> @@ -2040,7 +2040,7 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,
>  		connector->state = new_conn_state;
>  	}
>  
> -	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>  		old_crtc_state->state = state;
>  		new_crtc_state->state = NULL;
>  
> @@ -2057,7 +2057,7 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,
>  		}
>  	}
>  
> -	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
> +	for_each_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
>  		old_plane_state->state = state;
>  		new_plane_state->state = NULL;
>  
> diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c
> index 70c03eb032fc..ed8e366f1c02 100644
> --- a/drivers/gpu/drm/drm_blend.c
> +++ b/drivers/gpu/drm/drm_blend.c
> @@ -372,7 +372,7 @@ int drm_atomic_normalize_zpos(struct drm_device *dev,
>  	struct drm_plane_state *old_plane_state, *new_plane_state;
>  	int i, ret = 0;
>  
> -	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
> +	for_each_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
>  		crtc = new_plane_state->crtc;
>  		if (!crtc)
>  			continue;
> @@ -383,7 +383,7 @@ int drm_atomic_normalize_zpos(struct drm_device *dev,
>  		}
>  	}
>  
> -	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>  		if (old_crtc_state->plane_mask != new_crtc_state->plane_mask ||
>  		    new_crtc_state->zpos_changed) {
>  			ret = drm_atomic_helper_crtc_normalize_zpos(crtc,
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index d310abace86a..bac0fc342f8d 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -13760,7 +13760,7 @@ static void intel_modeset_clear_plls(struct drm_atomic_state *state)
>  	if (!dev_priv->display.crtc_compute_clock)
>  		return;
>  
> -	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>  		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>  		struct intel_shared_dpll *old_dpll =
>  			to_intel_crtc_state(old_crtc_state)->shared_dpll;
> @@ -13890,7 +13890,7 @@ static int intel_modeset_checks(struct drm_atomic_state *state)
>  	intel_state->modeset = true;
>  	intel_state->active_crtcs = dev_priv->active_crtcs;
>  
> -	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>  		if (new_crtc_state->active)
>  			intel_state->active_crtcs |= 1 << i;
>  		else
> @@ -13973,7 +13973,7 @@ static int intel_atomic_check(struct drm_device *dev,
>  	if (ret)
>  		return ret;
>  
> -	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
> +	for_each_crtc_in_state(state, crtc, old_crtc_state, crtc_state, i) {
>  		struct intel_crtc_state *pipe_config =
>  			to_intel_crtc_state(crtc_state);
>  
> @@ -14208,7 +14208,7 @@ static void intel_update_crtcs(struct drm_atomic_state *state,
>  	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
>  	int i;
>  
> -	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>  		if (!new_crtc_state->active)
>  			continue;
>  
> @@ -14241,7 +14241,7 @@ static void skl_update_crtcs(struct drm_atomic_state *state,
>  		int i;
>  		progress = false;
>  
> -		for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +		for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>  			bool vbl_wait = false;
>  			unsigned int cmask = drm_crtc_mask(crtc);
>  			pipe = to_intel_crtc(crtc)->pipe;
> @@ -14316,7 +14316,7 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
>  		intel_display_power_get(dev_priv, POWER_DOMAIN_MODESET);
>  	}
>  
> -	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>  		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>  
>  		if (needs_modeset(new_crtc_state) ||
> @@ -14418,7 +14418,7 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
>  			dev_priv->display.optimize_watermarks(intel_cstate);
>  	}
>  
> -	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +	for_each_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>  		intel_post_plane_update(to_intel_crtc_state(old_crtc_state));
>  
>  		if (put_domains[i])
> @@ -14472,7 +14472,7 @@ static void intel_atomic_track_fbs(struct drm_atomic_state *state)
>  	struct drm_plane *plane;
>  	int i;
>  
> -	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i)
> +	for_each_plane_in_state(state, plane, old_plane_state, new_plane_state, i)
>  		i915_gem_track_fb(intel_fb_obj(old_plane_state->fb),
>  				  intel_fb_obj(new_plane_state->fb),
>  				  to_intel_plane(plane)->frontbuffer_bit);
> diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
> index d484af773460..48be1483b263 100644
> --- a/drivers/gpu/drm/imx/imx-drm-core.c
> +++ b/drivers/gpu/drm/imx/imx-drm-core.c
> @@ -164,7 +164,7 @@ static int imx_drm_atomic_commit(struct drm_device *dev,
>  	 * If the plane fb has an dma-buf attached, fish out the exclusive
>  	 * fence for the atomic helper to wait on.
>  	 */
> -	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
> +	for_each_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
>  		if ((old_plane_state->fb != new_plane_state->fb) && new_plane_state->fb) {
>  			dma_buf = drm_fb_cma_get_gem_obj(new_plane_state->fb,
>  							 0)->base.dma_buf;
> diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
> index 7cfeb0455039..398e2e9a4135 100644
> --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
> +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
> @@ -84,7 +84,7 @@ static void mdp5_complete_commit(struct msm_kms *kms, struct drm_atomic_state *s
>  	struct drm_plane *plane;
>  	struct drm_plane_state *old_state, *new_state;
>  
> -	for_each_oldnew_plane_in_state(state, plane, old_state, new_state, i)
> +	for_each_plane_in_state(state, plane, old_state, new_state, i)
>  		mdp5_plane_complete_commit(plane, old_state, new_state);
>  
>  	mdp5_disable(mdp5_kms);
> diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c
> index 333c379e6561..5508e3a2e4ef 100644
> --- a/drivers/gpu/drm/msm/msm_atomic.c
> +++ b/drivers/gpu/drm/msm/msm_atomic.c
> @@ -213,7 +213,7 @@ int msm_atomic_commit(struct drm_device *dev,
>  	/*
>  	 * Figure out what fence to wait for:
>  	 */
> -	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
> +	for_each_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
>  		if (old_plane_state->fb != new_plane_state->fb && new_plane_state->fb) {
>  			struct drm_gem_object *obj = msm_framebuffer_bo(new_plane_state->fb, 0);
>  			struct msm_gem_object *msm_obj = to_msm_bo(obj);
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index 5c0625e5dca1..7a0806c24776 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -1040,7 +1040,7 @@ static void vop_crtc_atomic_flush(struct drm_crtc *crtc,
>  	}
>  	spin_unlock_irq(&crtc->dev->event_lock);
>  
> -	for_each_oldnew_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
> +	for_each_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
>  		if (!old_plane_state->fb)
>  			continue;
>  
> diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
> index 76cc9b374215..d9329a918014 100644
> --- a/drivers/gpu/drm/vc4/vc4_kms.c
> +++ b/drivers/gpu/drm/vc4/vc4_kms.c
> @@ -139,7 +139,7 @@ static int vc4_atomic_commit(struct drm_device *dev,
>  		return ret;
>  	}
>  
> -	for_each_oldnew_plane_in_state(state, plane, old_state, new_state, i) {
> +	for_each_plane_in_state(state, plane, old_state, new_state, i) {
>  		if (old_state->fb != new_state->fb && new_state->fb) {
>  			struct drm_gem_cma_object *cma_bo =
>  				drm_fb_cma_get_gem_obj(new_state->fb, 0);
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index 09fb6b316ca9..c02ea85de9ca 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -364,15 +364,7 @@ int __must_check drm_atomic_check_only(struct drm_atomic_state *state);
>  int __must_check drm_atomic_commit(struct drm_atomic_state *state);
>  int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
>  
> -#define for_each_connector_in_state(__state, connector, connector_state, __i) \
> -	for ((__i) = 0;							\
> -	     (__i) < (__state)->num_connector &&				\
> -	     ((connector) = (__state)->connectors[__i].ptr,			\
> -	     (connector_state) = (__state)->connectors[__i].state, 1); 	\
> -	     (__i)++)							\
> -		for_each_if (connector)
> -
> -#define for_each_oldnew_connector_in_state(__state, connector, old_connector_state, new_connector_state, __i) \
> +#define for_each_connector_in_state(__state, connector, old_connector_state, new_connector_state, __i) \
>  	for ((__i) = 0;								\
>  	     (__i) < (__state)->num_connector &&				\
>  	     ((connector) = (__state)->connectors[__i].ptr,			\
> @@ -397,15 +389,7 @@ int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
>  	     (__i)++)							\
>  		for_each_if (connector)
>  
> -#define for_each_crtc_in_state(__state, crtc, crtc_state, __i)	\
> -	for ((__i) = 0;						\
> -	     (__i) < (__state)->dev->mode_config.num_crtc &&	\
> -	     ((crtc) = (__state)->crtcs[__i].ptr,			\
> -	     (crtc_state) = (__state)->crtcs[__i].state, 1);	\
> -	     (__i)++)						\
> -		for_each_if (crtc_state)
> -
> -#define for_each_oldnew_crtc_in_state(__state, crtc, old_crtc_state, new_crtc_state, __i) \
> +#define for_each_crtc_in_state(__state, crtc, old_crtc_state, new_crtc_state, __i) \
>  	for ((__i) = 0;							\
>  	     (__i) < (__state)->dev->mode_config.num_crtc &&		\
>  	     ((crtc) = (__state)->crtcs[__i].ptr,			\
> @@ -430,15 +414,7 @@ int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
>  	     (__i)++)							\
>  		for_each_if (crtc)
>  
> -#define for_each_plane_in_state(__state, plane, plane_state, __i)		\
> -	for ((__i) = 0;							\
> -	     (__i) < (__state)->dev->mode_config.num_total_plane &&	\
> -	     ((plane) = (__state)->planes[__i].ptr,				\
> -	     (plane_state) = (__state)->planes[__i].state, 1);		\
> -	     (__i)++)							\
> -		for_each_if (plane_state)
> -
> -#define for_each_oldnew_plane_in_state(__state, plane, old_plane_state, new_plane_state, __i) \
> +#define for_each_plane_in_state(__state, plane, old_plane_state, new_plane_state, __i) \
>  	for ((__i) = 0;							\
>  	     (__i) < (__state)->dev->mode_config.num_total_plane &&	\
>  	     ((plane) = (__state)->planes[__i].ptr,			\
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 16/19] drm/i915: Use new atomic iterator macros in fbc
  2016-11-03 16:45   ` Ville Syrjälä
@ 2016-11-03 17:45     ` Paulo Zanoni
  2016-11-03 17:55       ` [Intel-gfx] " Ville Syrjälä
  0 siblings, 1 reply; 45+ messages in thread
From: Paulo Zanoni @ 2016-11-03 17:45 UTC (permalink / raw)
  To: Ville Syrjälä, Maarten Lankhorst; +Cc: intel-gfx, dri-devel

Em Qui, 2016-11-03 às 18:45 +0200, Ville Syrjälä escreveu:
> On Mon, Oct 17, 2016 at 02:37:15PM +0200, Maarten Lankhorst wrote:
> > 
> > Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com
> > >
> > ---
> >  drivers/gpu/drm/i915/intel_fbc.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_fbc.c
> > b/drivers/gpu/drm/i915/intel_fbc.c
> > index faa67624e1ed..0028335fc1bb 100644
> > --- a/drivers/gpu/drm/i915/intel_fbc.c
> > +++ b/drivers/gpu/drm/i915/intel_fbc.c
> > @@ -1060,7 +1060,7 @@ void intel_fbc_choose_crtc(struct
> > drm_i915_private *dev_priv,
> >  
> >  	mutex_lock(&fbc->lock);
> >  
> > -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> > +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
> >  		if (fbc->crtc == to_intel_crtc(crtc)) {
> >  			fbc_crtc_present = true;
> >  			break;
> > @@ -1074,14 +1074,14 @@ void intel_fbc_choose_crtc(struct
> > drm_i915_private *dev_priv,
> >  	 * plane. We could go for fancier schemes such as checking
> > the plane
> >  	 * size, but this would just affect the few platforms that
> > don't tie FBC
> >  	 * to pipe or plane A. */
> > -	for_each_plane_in_state(state, plane, plane_state, i) {
> > +	for_each_new_plane_in_state(state, plane, plane_state, i)
> > {
> >  		struct intel_plane_state *intel_plane_state =
> >  			to_intel_plane_state(plane_state);
> >  
> >  		if (!intel_plane_state->base.visible)
> >  			continue;
> 
> Unrelated but this thing looks somewhat bogus. FBC is tied to the
> primary plane only, so why do we care about the visibility of the
> other
> planes? Adding Paulo to Cc...

Looks like you've found a bug... Thanks! We should really be iterating
over primary planes only. Adding to the TODO list.

> 
> > 
> >  
> > -		for_each_crtc_in_state(state, crtc, crtc_state, j)
> > {
> > +		for_each_new_crtc_in_state(state, crtc,
> > crtc_state, j) {
> 
> Also, can't this inner loop be replaced with a simple
> crtc = plane_state->crtc ?

Is there a way to get the proposed crtc_state without the loop?


> 
> > 
> >  			struct intel_crtc_state *intel_crtc_state
> > =
> >  				to_intel_crtc_state(crtc_state);
> >  
> > -- 
> > 2.7.4
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 17/19] drm/i915: Use new atomic iterator macros in wm code
  2016-11-03 16:49   ` [Intel-gfx] " Ville Syrjälä
@ 2016-11-03 17:53     ` Paulo Zanoni
  0 siblings, 0 replies; 45+ messages in thread
From: Paulo Zanoni @ 2016-11-03 17:53 UTC (permalink / raw)
  To: Ville Syrjälä, Maarten Lankhorst; +Cc: intel-gfx, dri-devel

Em Qui, 2016-11-03 às 18:49 +0200, Ville Syrjälä escreveu:
> On Mon, Oct 17, 2016 at 02:37:16PM +0200, Maarten Lankhorst wrote:
> > 
> > Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com
> > >
> > ---
> >  drivers/gpu/drm/i915/intel_pm.c | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_pm.c
> > b/drivers/gpu/drm/i915/intel_pm.c
> > index 2df06b703e3d..163b73b493bf 100644
> > --- a/drivers/gpu/drm/i915/intel_pm.c
> > +++ b/drivers/gpu/drm/i915/intel_pm.c
> > @@ -3227,7 +3227,7 @@ skl_get_total_relative_data_rate(struct
> > intel_crtc_state *intel_cstate)
> >  		return 0;
> >  
> >  	/* Calculate and cache data rate for each plane */
> > -	for_each_plane_in_state(state, plane, pstate, i) {
> > +	for_each_new_plane_in_state(state, plane, pstate, i) {
> 
> Looks like this patch needs a refresh due to my tardiness in
> reviewing
> it.
> 
> Also unrelated, but I recently noticed that
> skl_get_total_relative_data_rate() doesn't exclude the cursor plane
> from the calculation. I'm thinking it should. Adding some Cc:s...

It seems we're safe because skl_plane_relative_data_rate() returns 0
for cursor. But an explicitly check at the caller would probably be
much much better instead of hidden deep in the code. OTOH, Matt's plans
to exclude cursor case-handling would remove this need again.

> 
> > 
> >  		id = skl_wm_plane_id(to_intel_plane(plane));
> >  		intel_plane = to_intel_plane(plane);
> >  
> > @@ -3364,14 +3364,14 @@ skl_allocate_pipe_ddb(struct
> > intel_crtc_state *cstate,
> >  	alloc_size -= cursor_blocks;
> >  
> >  	/* 1. Allocate the mininum required blocks for each active
> > plane */
> > -	for_each_plane_in_state(state, plane, pstate, i) {
> > +	for_each_new_plane_in_state(state, plane, pstate, i) {
> >  		intel_plane = to_intel_plane(plane);
> >  		id = skl_wm_plane_id(intel_plane);
> >  
> >  		if (intel_plane->pipe != pipe)
> >  			continue;
> >  
> > -		if (!to_intel_plane_state(pstate)->base.visible) {
> > +		if (!pstate->visible) {
> >  			minimum[id] = 0;
> >  			y_minimum[id] = 0;
> >  			continue;
> > @@ -3933,7 +3933,7 @@ pipes_modified(struct drm_atomic_state
> > *state)
> >  	struct drm_crtc_state *cstate;
> >  	uint32_t i, ret = 0;
> >  
> > -	for_each_crtc_in_state(state, crtc, cstate, i)
> > +	for_each_new_crtc_in_state(state, crtc, cstate, i)
> >  		ret |= drm_crtc_mask(crtc);
> >  
> >  	return ret;
> > @@ -4048,7 +4048,7 @@ skl_compute_wm(struct drm_atomic_state
> > *state)
> >  	 * since any racing commits that want to update them would
> > need to
> >  	 * hold _all_ CRTC state mutexes.
> >  	 */
> > -	for_each_crtc_in_state(state, crtc, cstate, i)
> > +	for_each_new_crtc_in_state(state, crtc, cstate, i)
> >  		changed = true;
> >  	if (!changed)
> >  		return 0;
> > @@ -4070,7 +4070,7 @@ skl_compute_wm(struct drm_atomic_state
> > *state)
> >  	 * should allow skl_update_pipe_wm() to return failure in
> > cases where
> >  	 * no suitable watermark values can be found.
> >  	 */
> > -	for_each_crtc_in_state(state, crtc, cstate, i) {
> > +	for_each_new_crtc_in_state(state, crtc, cstate, i) {
> >  		struct intel_crtc *intel_crtc =
> > to_intel_crtc(crtc);
> >  		struct intel_crtc_state *intel_cstate =
> >  			to_intel_crtc_state(cstate);
> > -- 
> > 2.7.4
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [Intel-gfx] [PATCH 16/19] drm/i915: Use new atomic iterator macros in fbc
  2016-11-03 17:45     ` Paulo Zanoni
@ 2016-11-03 17:55       ` Ville Syrjälä
  2016-11-03 17:59         ` Ville Syrjälä
  0 siblings, 1 reply; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-03 17:55 UTC (permalink / raw)
  To: Paulo Zanoni; +Cc: intel-gfx, dri-devel

On Thu, Nov 03, 2016 at 03:45:43PM -0200, Paulo Zanoni wrote:
> Em Qui, 2016-11-03 às 18:45 +0200, Ville Syrjälä escreveu:
> > On Mon, Oct 17, 2016 at 02:37:15PM +0200, Maarten Lankhorst wrote:
> > > 
> > > Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com
> > > >
> > > ---
> > >  drivers/gpu/drm/i915/intel_fbc.c | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/i915/intel_fbc.c
> > > b/drivers/gpu/drm/i915/intel_fbc.c
> > > index faa67624e1ed..0028335fc1bb 100644
> > > --- a/drivers/gpu/drm/i915/intel_fbc.c
> > > +++ b/drivers/gpu/drm/i915/intel_fbc.c
> > > @@ -1060,7 +1060,7 @@ void intel_fbc_choose_crtc(struct
> > > drm_i915_private *dev_priv,
> > >  
> > >  	mutex_lock(&fbc->lock);
> > >  
> > > -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> > > +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
> > >  		if (fbc->crtc == to_intel_crtc(crtc)) {
> > >  			fbc_crtc_present = true;
> > >  			break;
> > > @@ -1074,14 +1074,14 @@ void intel_fbc_choose_crtc(struct
> > > drm_i915_private *dev_priv,
> > >  	 * plane. We could go for fancier schemes such as checking
> > > the plane
> > >  	 * size, but this would just affect the few platforms that
> > > don't tie FBC
> > >  	 * to pipe or plane A. */
> > > -	for_each_plane_in_state(state, plane, plane_state, i) {
> > > +	for_each_new_plane_in_state(state, plane, plane_state, i)
> > > {
> > >  		struct intel_plane_state *intel_plane_state =
> > >  			to_intel_plane_state(plane_state);
> > >  
> > >  		if (!intel_plane_state->base.visible)
> > >  			continue;
> > 
> > Unrelated but this thing looks somewhat bogus. FBC is tied to the
> > primary plane only, so why do we care about the visibility of the
> > other
> > planes? Adding Paulo to Cc...
> 
> Looks like you've found a bug... Thanks! We should really be iterating
> over primary planes only. Adding to the TODO list.
> 
> > 
> > > 
> > >  
> > > -		for_each_crtc_in_state(state, crtc, crtc_state, j)
> > > {
> > > +		for_each_new_crtc_in_state(state, crtc,
> > > crtc_state, j) {
> > 
> > Also, can't this inner loop be replaced with a simple
> > crtc = plane_state->crtc ?
> 
> Is there a way to get the proposed crtc_state without the loop?

...get_existing_crtc_state(plane_state->crtc);

since the plane is part of the state the crtc should be too, I think.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [Intel-gfx] [PATCH 16/19] drm/i915: Use new atomic iterator macros in fbc
  2016-11-03 17:55       ` [Intel-gfx] " Ville Syrjälä
@ 2016-11-03 17:59         ` Ville Syrjälä
  0 siblings, 0 replies; 45+ messages in thread
From: Ville Syrjälä @ 2016-11-03 17:59 UTC (permalink / raw)
  To: Paulo Zanoni; +Cc: intel-gfx, dri-devel

On Thu, Nov 03, 2016 at 07:55:20PM +0200, Ville Syrjälä wrote:
> On Thu, Nov 03, 2016 at 03:45:43PM -0200, Paulo Zanoni wrote:
> > Em Qui, 2016-11-03 às 18:45 +0200, Ville Syrjälä escreveu:
> > > On Mon, Oct 17, 2016 at 02:37:15PM +0200, Maarten Lankhorst wrote:
> > > > 
> > > > Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com
> > > > >
> > > > ---
> > > >  drivers/gpu/drm/i915/intel_fbc.c | 6 +++---
> > > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/i915/intel_fbc.c
> > > > b/drivers/gpu/drm/i915/intel_fbc.c
> > > > index faa67624e1ed..0028335fc1bb 100644
> > > > --- a/drivers/gpu/drm/i915/intel_fbc.c
> > > > +++ b/drivers/gpu/drm/i915/intel_fbc.c
> > > > @@ -1060,7 +1060,7 @@ void intel_fbc_choose_crtc(struct
> > > > drm_i915_private *dev_priv,
> > > >  
> > > >  	mutex_lock(&fbc->lock);
> > > >  
> > > > -	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> > > > +	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
> > > >  		if (fbc->crtc == to_intel_crtc(crtc)) {
> > > >  			fbc_crtc_present = true;
> > > >  			break;
> > > > @@ -1074,14 +1074,14 @@ void intel_fbc_choose_crtc(struct
> > > > drm_i915_private *dev_priv,
> > > >  	 * plane. We could go for fancier schemes such as checking
> > > > the plane
> > > >  	 * size, but this would just affect the few platforms that
> > > > don't tie FBC
> > > >  	 * to pipe or plane A. */
> > > > -	for_each_plane_in_state(state, plane, plane_state, i) {
> > > > +	for_each_new_plane_in_state(state, plane, plane_state, i)
> > > > {
> > > >  		struct intel_plane_state *intel_plane_state =
> > > >  			to_intel_plane_state(plane_state);
> > > >  
> > > >  		if (!intel_plane_state->base.visible)
> > > >  			continue;
> > > 
> > > Unrelated but this thing looks somewhat bogus. FBC is tied to the
> > > primary plane only, so why do we care about the visibility of the
> > > other
> > > planes? Adding Paulo to Cc...
> > 
> > Looks like you've found a bug... Thanks! We should really be iterating
> > over primary planes only. Adding to the TODO list.
> > 
> > > 
> > > > 
> > > >  
> > > > -		for_each_crtc_in_state(state, crtc, crtc_state, j)
> > > > {
> > > > +		for_each_new_crtc_in_state(state, crtc,
> > > > crtc_state, j) {
> > > 
> > > Also, can't this inner loop be replaced with a simple
> > > crtc = plane_state->crtc ?
> > 
> > Is there a way to get the proposed crtc_state without the loop?
> 
> ...get_existing_crtc_state(plane_state->crtc);
> 
> since the plane is part of the state the crtc should be too, I think.

Well, I guess Maarten wants to change it to get_new_state() soon enough.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [Intel-gfx] [PATCH 01/19] drm/atomic: Add new iterators over all state
  2016-11-01 13:34     ` Maarten Lankhorst
  2016-11-01 13:41       ` Ville Syrjälä
@ 2016-11-08  8:50       ` Daniel Vetter
  1 sibling, 0 replies; 45+ messages in thread
From: Daniel Vetter @ 2016-11-08  8:50 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx, dri-devel

On Tue, Nov 01, 2016 at 02:34:00PM +0100, Maarten Lankhorst wrote:
> Op 01-11-16 om 14:09 schreef Ville Syrjälä:
> > On Mon, Oct 17, 2016 at 02:37:00PM +0200, Maarten Lankhorst wrote:
> >> Add for_each_(old)(new)_(plane,connector,crtc)_in_state iterators to
> >> replace the old for_each_xxx_in_state ones. This is useful for >1 flip
> >> depth and getting rid of all xxx->state dereferences.
> >>
> >> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> >> ---
> >>  drivers/gpu/drm/drm_atomic.c         |  6 +++
> >>  drivers/gpu/drm/drm_atomic_helper.c  | 52 +++++++++++++++++++++--
> >>  drivers/gpu/drm/i915/intel_display.c | 11 ++---
> >>  include/drm/drm_atomic.h             | 81 ++++++++++++++++++++++++++++++++++--
> >>  include/drm/drm_atomic_helper.h      |  3 ++
> >>  5 files changed, 142 insertions(+), 11 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> >> index 5dd70540219c..120775fcfb70 100644
> >> --- a/drivers/gpu/drm/drm_atomic.c
> >> +++ b/drivers/gpu/drm/drm_atomic.c
> >> @@ -278,6 +278,8 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
> >>  		return ERR_PTR(-ENOMEM);
> >>  
> >>  	state->crtcs[index].state = crtc_state;
> >> +	state->crtcs[index].old_state = crtc->state;
> >> +	state->crtcs[index].new_state = crtc_state;
> >>  	state->crtcs[index].ptr = crtc;
> >>  	crtc_state->state = state;
> >>  
> >> @@ -640,6 +642,8 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,
> >>  
> >>  	state->planes[index].state = plane_state;
> >>  	state->planes[index].ptr = plane;
> >> +	state->planes[index].old_state = plane->state;
> >> +	state->planes[index].new_state = plane_state;
> >>  	plane_state->state = state;
> >>  
> >>  	DRM_DEBUG_ATOMIC("Added [PLANE:%d:%s] %p state to %p\n",
> >> @@ -931,6 +935,8 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
> >>  
> >>  	drm_connector_reference(connector);
> >>  	state->connectors[index].state = connector_state;
> >> +	state->connectors[index].old_state = connector->state;
> >> +	state->connectors[index].new_state = connector_state;
> >>  	state->connectors[index].ptr = connector;
> >>  	connector_state->state = state;
> >>  
> >> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> >> index 07b432f43b98..fcb6e5b55217 100644
> >> --- a/drivers/gpu/drm/drm_atomic_helper.c
> >> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> >> @@ -2495,7 +2495,7 @@ EXPORT_SYMBOL(drm_atomic_helper_disable_all);
> >>   *
> >>   * See also:
> >>   * drm_atomic_helper_duplicate_state(), drm_atomic_helper_disable_all(),
> >> - * drm_atomic_helper_resume()
> >> + * drm_atomic_helper_resume(), drm_atomic_helper_commit_duplicated_state()
> >>   */
> >>  struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev)
> >>  {
> >> @@ -2536,6 +2536,52 @@ unlock:
> >>  EXPORT_SYMBOL(drm_atomic_helper_suspend);
> >>  
> >>  /**
> >> + * drm_atomic_helper_commit_duplicated_state - commit duplicated state
> >> + * @state: duplicated atomic state to commit
> >> + * @ctx: pointer to acquire_ctx to use for commit.
> >> + * @nonblock: commit the state non-blocking.
> >> + *
> >> + * The state returned by drm_atomic_helper_duplicate_state() and
> >> + * drm_atomic_helper_suspend() is partially invalid, and needs to
> >> + * be fixed up before commit.
> > So the old_state pointers are potentially invalid because whatever->state
> > may have changed since we duplicated the state?
> 
> Yes when you use drm_atomic_helper_duplicate_state, and commit a different state before committing the duplicated state.
> This only happens during suspend/resume and gpu reset.

Kerneldoc should imo mention that suspend/resume is the only case this is
valid, and even then it depends upon the driver. Proper atomic commits
never keep drm_atomic_state around when dropping locks, so this can't
happen with an atomic ioctl. Please also directly cross-reference all
these functions.
-Daniel

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

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [Intel-gfx] [PATCH 05/19] drm/atomic: Make add_affected_connectors look at crtc_state.
  2016-11-03 15:32   ` Ville Syrjälä
@ 2016-11-08  8:51     ` Daniel Vetter
  0 siblings, 0 replies; 45+ messages in thread
From: Daniel Vetter @ 2016-11-08  8:51 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, dri-devel

On Thu, Nov 03, 2016 at 05:32:42PM +0200, Ville Syrjälä wrote:
> On Mon, Oct 17, 2016 at 02:37:04PM +0200, Maarten Lankhorst wrote:
> > This kills another dereference of connector->state. connector_mask
> > holds all unchanged connectors at least and any changed connectors
> > are already in state anyway.
> > 
> > Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_atomic.c | 11 ++++++++---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> > index 120775fcfb70..1915ec44f7eb 100644
> > --- a/drivers/gpu/drm/drm_atomic.c
> > +++ b/drivers/gpu/drm/drm_atomic.c
> > @@ -1230,8 +1230,13 @@ drm_atomic_add_affected_connectors(struct drm_atomic_state *state,
> >  	struct drm_mode_config *config = &state->dev->mode_config;
> >  	struct drm_connector *connector;
> >  	struct drm_connector_state *conn_state;
> > +	struct drm_crtc_state *crtc_state;
> >  	int ret;
> >  
> > +	crtc_state = drm_atomic_get_crtc_state(state, crtc);
> > +	if (IS_ERR(crtc_state))
> > +		return PTR_ERR(crtc_state);
> > +
> >  	ret = drm_modeset_lock(&config->connection_mutex, state->acquire_ctx);
> >  	if (ret)
> >  		return ret;
> > @@ -1240,11 +1245,11 @@ drm_atomic_add_affected_connectors(struct drm_atomic_state *state,
> >  			 crtc->base.id, crtc->name, state);
> >  
> >  	/*
> > -	 * Changed connectors are already in @state, so only need to look at the
> > -	 * current configuration.
> > +	 * Changed connectors are already in @state, so only need to look
> > +	 * at the connector_mask in crtc_state.
> >  	 */
> >  	drm_for_each_connector(connector, state->dev) {
> > -		if (connector->state->crtc != crtc)
> > +		if (!(crtc_state->connector_mask & (1 << drm_connector_index(connector))))
> >  			continue;
> 
> So this being the new crtc state, connector_mask will include all newly enabled
> connectors (these will have been already added to the top level state), and
> also any connector that was already enabled and isn't getting disabled (these
> are the ones we need to explicitly add to the top level state here).
> 
> /me wishes the top level state would be renamed to drm_atomic_transaction or something...

+1 on drm_atomic_transaction, that's an awesome name. Not sure how bad it
would be to roll this out though ...
-Daniel

> 
> Any connector that is getting disabled will already have been added to
> the top level state as well, so them not being included in the new crtc
> state's connectors_mask is fine.
> 
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> >  
> >  		conn_state = drm_atomic_get_connector_state(state, connector);
> > -- 
> > 2.7.4
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> -- 
> Ville Syrjälä
> Intel OTC
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 07/19] drm/atomic: Fix atomic helpers to use the new iterator macros.
  2016-11-03 16:22   ` Ville Syrjälä
@ 2016-11-08  8:53     ` Daniel Vetter
  0 siblings, 0 replies; 45+ messages in thread
From: Daniel Vetter @ 2016-11-08  8:53 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, dri-devel

On Thu, Nov 03, 2016 at 06:22:05PM +0200, Ville Syrjälä wrote:
> This thing could use a commit message I think. Could at least lay out
> the basic rules on the foo->state/foo_state vs. old_state/new_state
> replacements. Might help someone understand it who doesn't know so much
> about the current state swapping mechanism.

Yup. I know Maarten doesn't like typing them, but except for
trival&obvious stuff they're needed.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH 01/19] drm/atomic: Add new iterators over all state
  2016-11-03 15:11           ` [Intel-gfx] " Ville Syrjälä
@ 2016-11-16 12:56             ` Maarten Lankhorst
  0 siblings, 0 replies; 45+ messages in thread
From: Maarten Lankhorst @ 2016-11-16 12:56 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, dri-devel

Op 03-11-16 om 16:11 schreef Ville Syrjälä:
> On Wed, Nov 02, 2016 at 09:28:46AM +0100, Maarten Lankhorst wrote:
>> Op 01-11-16 om 14:41 schreef Ville Syrjälä:
>>> On Tue, Nov 01, 2016 at 02:34:00PM +0100, Maarten Lankhorst wrote:
>>>> Op 01-11-16 om 14:09 schreef Ville Syrjälä:
>>>>> On Mon, Oct 17, 2016 at 02:37:00PM +0200, Maarten Lankhorst wrote:
>>>>>> Add for_each_(old)(new)_(plane,connector,crtc)_in_state iterators to
>>>>>> replace the old for_each_xxx_in_state ones. This is useful for >1 flip
>>>>>> depth and getting rid of all xxx->state dereferences.
>>>>>>
>>>>>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>>>>>> ---
>>>>>>  drivers/gpu/drm/drm_atomic.c         |  6 +++
>>>>>>  drivers/gpu/drm/drm_atomic_helper.c  | 52 +++++++++++++++++++++--
>>>>>>  drivers/gpu/drm/i915/intel_display.c | 11 ++---
>>>>>>  include/drm/drm_atomic.h             | 81 ++++++++++++++++++++++++++++++++++--
>>>>>>  include/drm/drm_atomic_helper.h      |  3 ++
>>>>>>  5 files changed, 142 insertions(+), 11 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
>>>>>> index 5dd70540219c..120775fcfb70 100644
>>>>>> --- a/drivers/gpu/drm/drm_atomic.c
>>>>>> +++ b/drivers/gpu/drm/drm_atomic.c
>>>>>> @@ -278,6 +278,8 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
>>>>>>  		return ERR_PTR(-ENOMEM);
>>>>>>  
>>>>>>  	state->crtcs[index].state = crtc_state;
>>>>>> +	state->crtcs[index].old_state = crtc->state;
>>>>>> +	state->crtcs[index].new_state = crtc_state;
>>>>>>  	state->crtcs[index].ptr = crtc;
>>>>>>  	crtc_state->state = state;
>>>>>>  
>>>>>> @@ -640,6 +642,8 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,
>>>>>>  
>>>>>>  	state->planes[index].state = plane_state;
>>>>>>  	state->planes[index].ptr = plane;
>>>>>> +	state->planes[index].old_state = plane->state;
>>>>>> +	state->planes[index].new_state = plane_state;
>>>>>>  	plane_state->state = state;
>>>>>>  
>>>>>>  	DRM_DEBUG_ATOMIC("Added [PLANE:%d:%s] %p state to %p\n",
>>>>>> @@ -931,6 +935,8 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
>>>>>>  
>>>>>>  	drm_connector_reference(connector);
>>>>>>  	state->connectors[index].state = connector_state;
>>>>>> +	state->connectors[index].old_state = connector->state;
>>>>>> +	state->connectors[index].new_state = connector_state;
>>>>>>  	state->connectors[index].ptr = connector;
>>>>>>  	connector_state->state = state;
>>>>>>  
>>>>>> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
>>>>>> index 07b432f43b98..fcb6e5b55217 100644
>>>>>> --- a/drivers/gpu/drm/drm_atomic_helper.c
>>>>>> +++ b/drivers/gpu/drm/drm_atomic_helper.c
>>>>>> @@ -2495,7 +2495,7 @@ EXPORT_SYMBOL(drm_atomic_helper_disable_all);
>>>>>>   *
>>>>>>   * See also:
>>>>>>   * drm_atomic_helper_duplicate_state(), drm_atomic_helper_disable_all(),
>>>>>> - * drm_atomic_helper_resume()
>>>>>> + * drm_atomic_helper_resume(), drm_atomic_helper_commit_duplicated_state()
>>>>>>   */
>>>>>>  struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev)
>>>>>>  {
>>>>>> @@ -2536,6 +2536,52 @@ unlock:
>>>>>>  EXPORT_SYMBOL(drm_atomic_helper_suspend);
>>>>>>  
>>>>>>  /**
>>>>>> + * drm_atomic_helper_commit_duplicated_state - commit duplicated state
>>>>>> + * @state: duplicated atomic state to commit
>>>>>> + * @ctx: pointer to acquire_ctx to use for commit.
>>>>>> + * @nonblock: commit the state non-blocking.
>>>>>> + *
>>>>>> + * The state returned by drm_atomic_helper_duplicate_state() and
>>>>>> + * drm_atomic_helper_suspend() is partially invalid, and needs to
>>>>>> + * be fixed up before commit.
>>>>> So the old_state pointers are potentially invalid because whatever->state
>>>>> may have changed since we duplicated the state?
>>>> Yes when you use drm_atomic_helper_duplicate_state, and commit a different state before committing the duplicated state.
>>>> This only happens during suspend/resume and gpu reset.
>>> Should we maybe have something like drm_atomic_refresh_old_state(state)?
>>> Would allow the caller then to check something in the old vs. new state
>>> before committing?
>> iirc that was the first approach I took, but then you shouldn't do anything with a duplicated state after
>> creating a except commit it, so creating a commit_duplicated_state should be enough.
>>
>> Can you think of any case where you do the following?
>>
>> Duplicate state
>> commit different state
>> Look at duplicated state, tinker with it, commit it.
> Not really. Oh, and we do still run the thing through the check phase
> when we commit it, don't we? That sounds like it should let the driver
> do whatever it needs to do.
> So my only other concern is just the 'bool nonblock' parameter. It's a
> bit funny looking that we pass that in, then branch off to the nonblocking
> vs. blocking commits, which then just pass another bool parameter to the
> commit hook. Should we have block vs. nonblocking variants of this
> function as well or just remove drm_atomic_nonblocking_commit() and have
> callers pass the parameter straight from the beginning?
>
> drm_atomic_commit() and drm_atomic_nonblocking_commit() could also use
> some code deduplication I think. Should we decice to keep them around.

I could have done the check and commit manually, but would rather use the dedicated atomic commands for it.
However nowhere we end up using the nonblocking version, so I think I will remove the nonblock parameter
and leave the decision on what to do with nonblocking commit for another day. :)

~Maarten

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

^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2016-11-16 12:56 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-17 12:36 [PATCH 00/19] drm/atomic: Use less confusing iterator names Maarten Lankhorst
2016-10-17 12:37 ` [PATCH 01/19] drm/atomic: Add new iterators over all state Maarten Lankhorst
2016-11-01 13:09   ` [Intel-gfx] " Ville Syrjälä
2016-11-01 13:34     ` Maarten Lankhorst
2016-11-01 13:41       ` Ville Syrjälä
2016-11-02  8:28         ` Maarten Lankhorst
2016-11-03 15:11           ` [Intel-gfx] " Ville Syrjälä
2016-11-16 12:56             ` Maarten Lankhorst
2016-11-08  8:50       ` [Intel-gfx] " Daniel Vetter
2016-10-17 12:37 ` [PATCH 02/19] drm/atmel-hlcdc: Use new atomic iterator macros Maarten Lankhorst
2016-10-17 12:37 ` [PATCH 03/19] drm/exynos: " Maarten Lankhorst
2016-10-17 12:37 ` [PATCH 04/19] drm/blend: " Maarten Lankhorst
2016-11-03 15:26   ` Ville Syrjälä
2016-10-17 12:37 ` [PATCH 05/19] drm/atomic: Make add_affected_connectors look at crtc_state Maarten Lankhorst
2016-11-03 15:32   ` Ville Syrjälä
2016-11-08  8:51     ` [Intel-gfx] " Daniel Vetter
2016-10-17 12:37 ` [PATCH 06/19] drm/atomic: Use new atomic iterator macros Maarten Lankhorst
2016-11-03 15:35   ` [Intel-gfx] " Ville Syrjälä
2016-10-17 12:37 ` [PATCH 07/19] drm/atomic: Fix atomic helpers to use the new " Maarten Lankhorst
2016-11-03 16:22   ` Ville Syrjälä
2016-11-08  8:53     ` Daniel Vetter
2016-10-17 12:37 ` [PATCH 08/19] drm/vc4: Use new atomic " Maarten Lankhorst
2016-10-17 12:37 ` [PATCH 09/19] drm/rockchip: " Maarten Lankhorst
2016-10-17 12:37 ` [PATCH 10/19] drm/rcar-du: " Maarten Lankhorst
2016-10-17 12:37 ` [PATCH 11/19] drm/omap: " Maarten Lankhorst
2016-10-17 12:37 ` [PATCH 12/19] drm/msm: " Maarten Lankhorst
2016-11-03 16:37   ` [Intel-gfx] " Ville Syrjälä
2016-10-17 12:37 ` [PATCH 13/19] drm/imx: " Maarten Lankhorst
2016-10-17 12:37 ` [PATCH 14/19] drm/mediatek: " Maarten Lankhorst
2016-11-03 16:39   ` Ville Syrjälä
2016-10-17 12:37 ` [PATCH 15/19] drm/i915: Use new atomic iterator macros in ddi Maarten Lankhorst
2016-11-03 17:07   ` Ville Syrjälä
2016-10-17 12:37 ` [PATCH 16/19] drm/i915: Use new atomic iterator macros in fbc Maarten Lankhorst
2016-11-03 16:45   ` Ville Syrjälä
2016-11-03 17:45     ` Paulo Zanoni
2016-11-03 17:55       ` [Intel-gfx] " Ville Syrjälä
2016-11-03 17:59         ` Ville Syrjälä
2016-10-17 12:37 ` [PATCH 17/19] drm/i915: Use new atomic iterator macros in wm code Maarten Lankhorst
2016-11-03 16:49   ` [Intel-gfx] " Ville Syrjälä
2016-11-03 17:53     ` Paulo Zanoni
2016-10-17 12:37 ` [PATCH 18/19] drm/i915: Use new atomic iterator macros in display code Maarten Lankhorst
2016-11-03 17:04   ` [Intel-gfx] " Ville Syrjälä
2016-10-17 12:37 ` [PATCH 19/19] drm/atomic: Rename atomic oldnew iterator Maarten Lankhorst
2016-11-03 17:11   ` [Intel-gfx] " Ville Syrjälä
2016-10-17 13:25 ` ✗ Fi.CI.BAT: warning for drm/atomic: Use less confusing iterator names Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.