* [PATCH 1/3] drm/atomic: add commit_planes_on_crtc helper
@ 2015-05-19 14:41 Maarten Lankhorst
2015-05-19 14:41 ` [PATCH 2/3] drm/atomic: add drm_atomic_add_affected_planes Maarten Lankhorst
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Maarten Lankhorst @ 2015-05-19 14:41 UTC (permalink / raw)
To: dri-devel; +Cc: intel-gfx
drm_atomic_helper_commit_planes calls all atomic_begin's first,
then updates all planes, finally calling atomic_flush.
Some drivers may want to things like disabling irq's
from their atomic_begin, in which case a second call to atomic_begin
will splat. By using commit_planes_on_crtc on each crtc in the
atomic state they'll evade that issue.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
drivers/gpu/drm/drm_atomic_helper.c | 53 +++++++++++++++++++++++++++++++++++++
include/drm/drm_atomic_helper.h | 1 +
2 files changed, 54 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index b82ef6262469..2da8a16bb39e 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1181,6 +1181,59 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
EXPORT_SYMBOL(drm_atomic_helper_commit_planes);
/**
+ * drm_atomic_helper_commit_planes_on_crtc - commit plane state for a crtc
+ * @old_crtc_state: atomic state object with the old crtc state
+ *
+ * This function commits the new plane state using the plane and atomic helper
+ * functions for planes on the specific crtc. It assumes that the atomic state
+ * has already been pushed into the relevant object state pointers, since this
+ * step can no longer fail.
+ *
+ * This function can only be used when planes are not allowed to move between
+ * different crtc's.
+ */
+void
+drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state)
+{
+ const struct drm_crtc_helper_funcs *crtc_funcs;
+ struct drm_crtc *crtc = old_crtc_state->crtc;
+ struct drm_atomic_state *old_state = old_crtc_state->state;
+ struct drm_plane *plane;
+ unsigned plane_mask;
+
+ plane_mask = old_crtc_state->plane_mask;
+ plane_mask |= crtc->state->plane_mask;
+
+ crtc_funcs = crtc->helper_private;
+ if (crtc_funcs && crtc_funcs->atomic_begin)
+ crtc_funcs->atomic_begin(crtc);
+
+ drm_for_each_plane_mask(plane, crtc->dev, plane_mask) {
+ struct drm_plane_state *old_plane_state =
+ drm_atomic_get_existing_plane_state(old_state, plane);
+ const struct drm_plane_helper_funcs *plane_funcs;
+
+ plane_funcs = plane->helper_private;
+
+ if (!old_plane_state || !plane_funcs)
+ continue;
+
+ WARN_ON(plane->state->crtc && plane->state->crtc != crtc);
+
+ if (drm_atomic_plane_disabling(plane, old_plane_state) &&
+ plane_funcs->atomic_disable)
+ plane_funcs->atomic_disable(plane, old_plane_state);
+ else if (plane->state->crtc ||
+ drm_atomic_plane_disabling(plane, old_plane_state))
+ plane_funcs->atomic_update(plane, old_plane_state);
+ }
+
+ if (crtc_funcs->atomic_flush)
+ crtc_funcs->atomic_flush(crtc);
+}
+EXPORT_SYMBOL(drm_atomic_helper_commit_planes_on_crtc);
+
+/**
* drm_atomic_helper_cleanup_planes - cleanup plane resources after commit
* @dev: DRM device
* @old_state: atomic state object with old state structures
diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
index 6ee0ee5b6143..cc1fee8a12d0 100644
--- a/include/drm/drm_atomic_helper.h
+++ b/include/drm/drm_atomic_helper.h
@@ -58,6 +58,7 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
struct drm_atomic_state *state);
void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
struct drm_atomic_state *old_state);
+void drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state);
void drm_atomic_helper_swap_state(struct drm_device *dev,
struct drm_atomic_state *state);
--
2.1.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/3] drm/atomic: add drm_atomic_add_affected_planes
2015-05-19 14:41 [PATCH 1/3] drm/atomic: add commit_planes_on_crtc helper Maarten Lankhorst
@ 2015-05-19 14:41 ` Maarten Lankhorst
2015-05-19 14:41 ` [PATCH 3/3] drm/atomic: add all affected planes in drm_atomic_helper_check_modeset Maarten Lankhorst
2015-05-19 17:03 ` [Intel-gfx] [PATCH 1/3] drm/atomic: add commit_planes_on_crtc helper Daniel Vetter
2 siblings, 0 replies; 4+ messages in thread
From: Maarten Lankhorst @ 2015-05-19 14:41 UTC (permalink / raw)
To: dri-devel; +Cc: intel-gfx
This is a convenience function to add all planes for a crtc,
similar to add_affected_connectors. This will be used in
drm_atomic_helper_check_modeset, but drivers can call it too
when they need to recalculate all state.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
drivers/gpu/drm/drm_atomic.c | 32 ++++++++++++++++++++++++++++++++
include/drm/drm_atomic.h | 4 ++++
2 files changed, 36 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index cd1b16b25716..c48b7db438b8 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -956,6 +956,38 @@ drm_atomic_add_affected_connectors(struct drm_atomic_state *state,
EXPORT_SYMBOL(drm_atomic_add_affected_connectors);
/**
+ * drm_atomic_add_affected_planes - add planes for crtc
+ * @state: atomic state
+ * @crtc: DRM crtc
+ *
+ * This function walks the current configuration and adds all planes
+ * currently used by @crtc to the atomic configuration @state.
+ *
+ * Returns:
+ * 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK
+ * then the w/w mutex code has detected a deadlock and the entire atomic
+ * sequence must be restarted. All other errors are fatal.
+ */
+int
+drm_atomic_add_affected_planes(struct drm_atomic_state *state,
+ struct drm_crtc *crtc)
+{
+ struct drm_plane *plane;
+
+ WARN_ON(!drm_atomic_get_existing_crtc_state(state, crtc));
+
+ drm_for_each_plane_mask(plane, state->dev, crtc->state->plane_mask) {
+ struct drm_plane_state *plane_state =
+ drm_atomic_get_plane_state(state, plane);
+
+ if (IS_ERR(plane_state))
+ return PTR_ERR(plane_state);
+ }
+ return 0;
+}
+EXPORT_SYMBOL(drm_atomic_add_affected_planes);
+
+/**
* drm_atomic_connectors_for_crtc - count number of connected outputs
* @state: atomic state
* @crtc: DRM crtc
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index f0d3a7387d99..e89db0c377ba 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -120,6 +120,10 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
int __must_check
drm_atomic_add_affected_connectors(struct drm_atomic_state *state,
struct drm_crtc *crtc);
+int __must_check
+drm_atomic_add_affected_planes(struct drm_atomic_state *state,
+ struct drm_crtc *crtc);
+
int
drm_atomic_connectors_for_crtc(struct drm_atomic_state *state,
struct drm_crtc *crtc);
--
2.1.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 3/3] drm/atomic: add all affected planes in drm_atomic_helper_check_modeset
2015-05-19 14:41 [PATCH 1/3] drm/atomic: add commit_planes_on_crtc helper Maarten Lankhorst
2015-05-19 14:41 ` [PATCH 2/3] drm/atomic: add drm_atomic_add_affected_planes Maarten Lankhorst
@ 2015-05-19 14:41 ` Maarten Lankhorst
2015-05-19 17:03 ` [Intel-gfx] [PATCH 1/3] drm/atomic: add commit_planes_on_crtc helper Daniel Vetter
2 siblings, 0 replies; 4+ messages in thread
From: Maarten Lankhorst @ 2015-05-19 14:41 UTC (permalink / raw)
To: dri-devel; +Cc: intel-gfx
Drivers may need to recalculate plane state when a modeset occurs,
not reliably adding them might cause hard to debug bugs.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
drivers/gpu/drm/drm_atomic_helper.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 2da8a16bb39e..4f5a427e9405 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -429,6 +429,10 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
if (ret != 0)
return ret;
+ ret = drm_atomic_add_affected_planes(state, crtc);
+ if (ret != 0)
+ return ret;
+
num_connectors = drm_atomic_connectors_for_crtc(state,
crtc);
--
2.1.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Intel-gfx] [PATCH 1/3] drm/atomic: add commit_planes_on_crtc helper
2015-05-19 14:41 [PATCH 1/3] drm/atomic: add commit_planes_on_crtc helper Maarten Lankhorst
2015-05-19 14:41 ` [PATCH 2/3] drm/atomic: add drm_atomic_add_affected_planes Maarten Lankhorst
2015-05-19 14:41 ` [PATCH 3/3] drm/atomic: add all affected planes in drm_atomic_helper_check_modeset Maarten Lankhorst
@ 2015-05-19 17:03 ` Daniel Vetter
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Vetter @ 2015-05-19 17:03 UTC (permalink / raw)
To: Maarten Lankhorst; +Cc: intel-gfx, dri-devel
On Tue, May 19, 2015 at 04:41:01PM +0200, Maarten Lankhorst wrote:
> drm_atomic_helper_commit_planes calls all atomic_begin's first,
> then updates all planes, finally calling atomic_flush.
>
> Some drivers may want to things like disabling irq's
> from their atomic_begin, in which case a second call to atomic_begin
> will splat. By using commit_planes_on_crtc on each crtc in the
> atomic state they'll evade that issue.
>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
All three patches merged to topic/drm-misc, thanks.
-Daniel
> ---
> drivers/gpu/drm/drm_atomic_helper.c | 53 +++++++++++++++++++++++++++++++++++++
> include/drm/drm_atomic_helper.h | 1 +
> 2 files changed, 54 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index b82ef6262469..2da8a16bb39e 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -1181,6 +1181,59 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
> EXPORT_SYMBOL(drm_atomic_helper_commit_planes);
>
> /**
> + * drm_atomic_helper_commit_planes_on_crtc - commit plane state for a crtc
> + * @old_crtc_state: atomic state object with the old crtc state
> + *
> + * This function commits the new plane state using the plane and atomic helper
> + * functions for planes on the specific crtc. It assumes that the atomic state
> + * has already been pushed into the relevant object state pointers, since this
> + * step can no longer fail.
> + *
> + * This function can only be used when planes are not allowed to move between
> + * different crtc's.
> + */
> +void
> +drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state)
> +{
> + const struct drm_crtc_helper_funcs *crtc_funcs;
> + struct drm_crtc *crtc = old_crtc_state->crtc;
> + struct drm_atomic_state *old_state = old_crtc_state->state;
> + struct drm_plane *plane;
> + unsigned plane_mask;
> +
> + plane_mask = old_crtc_state->plane_mask;
> + plane_mask |= crtc->state->plane_mask;
> +
> + crtc_funcs = crtc->helper_private;
> + if (crtc_funcs && crtc_funcs->atomic_begin)
> + crtc_funcs->atomic_begin(crtc);
> +
> + drm_for_each_plane_mask(plane, crtc->dev, plane_mask) {
> + struct drm_plane_state *old_plane_state =
> + drm_atomic_get_existing_plane_state(old_state, plane);
> + const struct drm_plane_helper_funcs *plane_funcs;
> +
> + plane_funcs = plane->helper_private;
> +
> + if (!old_plane_state || !plane_funcs)
> + continue;
> +
> + WARN_ON(plane->state->crtc && plane->state->crtc != crtc);
> +
> + if (drm_atomic_plane_disabling(plane, old_plane_state) &&
> + plane_funcs->atomic_disable)
> + plane_funcs->atomic_disable(plane, old_plane_state);
> + else if (plane->state->crtc ||
> + drm_atomic_plane_disabling(plane, old_plane_state))
> + plane_funcs->atomic_update(plane, old_plane_state);
> + }
> +
> + if (crtc_funcs->atomic_flush)
> + crtc_funcs->atomic_flush(crtc);
> +}
> +EXPORT_SYMBOL(drm_atomic_helper_commit_planes_on_crtc);
> +
> +/**
> * drm_atomic_helper_cleanup_planes - cleanup plane resources after commit
> * @dev: DRM device
> * @old_state: atomic state object with old state structures
> diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
> index 6ee0ee5b6143..cc1fee8a12d0 100644
> --- a/include/drm/drm_atomic_helper.h
> +++ b/include/drm/drm_atomic_helper.h
> @@ -58,6 +58,7 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
> struct drm_atomic_state *state);
> void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
> struct drm_atomic_state *old_state);
> +void drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state);
>
> void drm_atomic_helper_swap_state(struct drm_device *dev,
> struct drm_atomic_state *state);
> --
> 2.1.0
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://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
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-05-19 17:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-19 14:41 [PATCH 1/3] drm/atomic: add commit_planes_on_crtc helper Maarten Lankhorst
2015-05-19 14:41 ` [PATCH 2/3] drm/atomic: add drm_atomic_add_affected_planes Maarten Lankhorst
2015-05-19 14:41 ` [PATCH 3/3] drm/atomic: add all affected planes in drm_atomic_helper_check_modeset Maarten Lankhorst
2015-05-19 17:03 ` [Intel-gfx] [PATCH 1/3] drm/atomic: add commit_planes_on_crtc helper Daniel Vetter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox