* [PATCH 1/2] drm/atomic: track bitmask of planes attached to crtc
@ 2014-11-21 20:28 Rob Clark
2014-11-21 20:28 ` [PATCH 2/2] drm/atomic: add plane iterator macros Rob Clark
2014-11-25 14:15 ` [PATCH 1/2] drm/atomic: track bitmask of planes attached to crtc Daniel Vetter
0 siblings, 2 replies; 7+ messages in thread
From: Rob Clark @ 2014-11-21 20:28 UTC (permalink / raw)
To: dri-devel
Chasing plane->state->crtc of planes that are *not* part of the same
atomic update is racy, making it incredibly awkward (or impossible) to
do something simple like iterate over all planes and figure out which
ones are attached to a crtc.
Solve this by adding a bitmask of currently attached planes in the
crtc-state.
Note that the transitional helpers do not maintain the plane_mask. But
they only support the legacy ioctls, which have sufficient brute-force
locking around plane updates that they can continue to loop over all
planes to see what is attached to a crtc the old way.
Signed-off-by: Rob Clark <robdclark@gmail.com>
---
drivers/gpu/drm/drm_atomic.c | 25 ++++++++++++++++++++-----
drivers/gpu/drm/drm_atomic_helper.c | 8 ++++----
include/drm/drm_atomic.h | 4 ++--
include/drm/drm_crtc.h | 14 +++++++++++---
4 files changed, 37 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index d3b4674..8effbba 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -350,7 +350,8 @@ EXPORT_SYMBOL(drm_atomic_get_connector_state);
/**
* drm_atomic_set_crtc_for_plane - set crtc for plane
- * @plane_state: atomic state object for the plane
+ * @state: the incoming atomic state
+ * @plane: the plane whose incoming state to update
* @crtc: crtc to use for the plane
*
* Changing the assigned crtc for a plane requires us to grab the lock and state
@@ -363,20 +364,34 @@ EXPORT_SYMBOL(drm_atomic_get_connector_state);
* sequence must be restarted. All other errors are fatal.
*/
int
-drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
- struct drm_crtc *crtc)
+drm_atomic_set_crtc_for_plane(struct drm_atomic_state *state,
+ struct drm_plane *plane, struct drm_crtc *crtc)
{
+ struct drm_plane_state *plane_state =
+ drm_atomic_get_plane_state(state, plane);
struct drm_crtc_state *crtc_state;
- if (crtc) {
+ /* acquire outgoing crtc lock, and clear bit in outgoing crtc mask: */
+ if (plane_state->crtc) {
crtc_state = drm_atomic_get_crtc_state(plane_state->state,
- crtc);
+ plane_state->crtc);
if (IS_ERR(crtc_state))
return PTR_ERR(crtc_state);
+
+ crtc_state->plane_mask &= ~(1 << drm_plane_index(plane));
}
plane_state->crtc = crtc;
+ /* acquire incoming crtc lock, and set bit in incoming crtc mask: */
+ if (crtc) {
+ crtc_state = drm_atomic_get_crtc_state(plane_state->state,
+ crtc);
+ if (IS_ERR(crtc_state))
+ return PTR_ERR(crtc_state);
+ crtc_state->plane_mask |= (1 << drm_plane_index(plane));
+ }
+
if (crtc)
DRM_DEBUG_KMS("Link plane state %p to [CRTC:%d]\n",
plane_state, crtc->base.id);
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index a17b8e9..d765d37 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1187,7 +1187,7 @@ retry:
goto fail;
}
- ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+ ret = drm_atomic_set_crtc_for_plane(state, plane, crtc);
if (ret != 0)
goto fail;
drm_atomic_set_fb_for_plane(plane_state, fb);
@@ -1255,7 +1255,7 @@ retry:
goto fail;
}
- ret = drm_atomic_set_crtc_for_plane(plane_state, NULL);
+ ret = drm_atomic_set_crtc_for_plane(state, plane, NULL);
if (ret != 0)
goto fail;
drm_atomic_set_fb_for_plane(plane_state, NULL);
@@ -1426,7 +1426,7 @@ retry:
goto fail;
}
- ret = drm_atomic_set_crtc_for_plane(primary_state, crtc);
+ ret = drm_atomic_set_crtc_for_plane(state, crtc->primary, crtc);
if (ret != 0)
goto fail;
drm_atomic_set_fb_for_plane(primary_state, set->fb);
@@ -1698,7 +1698,7 @@ retry:
goto fail;
}
- ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
+ ret = drm_atomic_set_crtc_for_plane(state, plane, crtc);
if (ret != 0)
goto fail;
drm_atomic_set_fb_for_plane(plane_state, fb);
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 9d91916..6ff8775 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -44,8 +44,8 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
struct drm_connector *connector);
int __must_check
-drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
- struct drm_crtc *crtc);
+drm_atomic_set_crtc_for_plane(struct drm_atomic_state *state,
+ struct drm_plane *plane, struct drm_crtc *crtc);
void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
struct drm_framebuffer *fb);
int __must_check
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index b459e8f..4cf6905 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -231,6 +231,7 @@ struct drm_atomic_state;
* struct drm_crtc_state - mutable CRTC state
* @enable: whether the CRTC should be enabled, gates all other state
* @mode_changed: for use by helpers and drivers when computing state updates
+ * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
* @last_vblank_count: for helpers and drivers to capture the vblank of the
* update to ensure framebuffer cleanup isn't done too early
* @planes_changed: for use by helpers and drivers when computing state updates
@@ -247,6 +248,13 @@ struct drm_crtc_state {
bool planes_changed : 1;
bool mode_changed : 1;
+ /* attached planes bitmask:
+ * WARNING: transitional helpers do not maintain plane_mask so
+ * drivers not converted over to atomic helpers should not rely
+ * on plane_mask being accurate!
+ */
+ u32 plane_mask;
+
/* last_vblank_count: for vblank waits before cleanup */
u32 last_vblank_count;
@@ -438,7 +446,7 @@ struct drm_crtc {
* @state: backpointer to global drm_atomic_state
*/
struct drm_connector_state {
- struct drm_crtc *crtc;
+ struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_connector() */
struct drm_encoder *best_encoder;
@@ -673,8 +681,8 @@ struct drm_connector {
* @state: backpointer to global drm_atomic_state
*/
struct drm_plane_state {
- struct drm_crtc *crtc;
- struct drm_framebuffer *fb;
+ struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */
+ struct drm_framebuffer *fb; /* do not write directly, use drm_atomic_set_fb_for_plane() */
struct fence *fence;
/* Signed dest location allows it to be partially off screen */
--
1.9.3
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/2] drm/atomic: add plane iterator macros
2014-11-21 20:28 [PATCH 1/2] drm/atomic: track bitmask of planes attached to crtc Rob Clark
@ 2014-11-21 20:28 ` Rob Clark
2014-11-21 20:38 ` Daniel Vetter
2014-11-21 20:46 ` Thierry Reding
2014-11-25 14:15 ` [PATCH 1/2] drm/atomic: track bitmask of planes attached to crtc Daniel Vetter
1 sibling, 2 replies; 7+ messages in thread
From: Rob Clark @ 2014-11-21 20:28 UTC (permalink / raw)
To: dri-devel
Add helper macros to iterate the current, or incoming set of planes
attached to a crtc. These helpers are only available for drivers
converted to use atomic-helpers.
Signed-off-by: Rob Clark <robdclark@gmail.com>
---
Documentation/DocBook/drm.tmpl | 1 +
include/drm/drm_atomic_helper.h | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 8c54f9a..3789f2d 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2343,6 +2343,7 @@ void intel_crt_init(struct drm_device *dev)
<title>Atomic State Reset and Initialization</title>
!Pdrivers/gpu/drm/drm_atomic_helper.c atomic state reset and initialization
</sect3>
+!Iinclude/drm/drm_atomic_helper.h
!Edrivers/gpu/drm/drm_atomic_helper.c
</sect2>
<sect2>
diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
index 64b4e91..42d56e6 100644
--- a/include/drm/drm_atomic_helper.h
+++ b/include/drm/drm_atomic_helper.h
@@ -96,5 +96,31 @@ drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector);
void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
struct drm_connector_state *state);
+/**
+ * drm_crtc_for_each_plane - iterate over planes currently attached to crtc
+ * @plane: the loop cursor
+ * @crtc: the crtc whose planes are iterated
+ *
+ * This iterates over the current state, useful (for example) when applying
+ * atomic state after it has been checked and swapped. To iterate over the
+ * planes which *will* be attached (for ->atomic_check()) see
+ * drm_crtc_for_each_pending_plane()
+ */
+#define drm_crtc_for_each_plane(plane, crtc) \
+ list_for_each_entry((plane), &(crtc)->dev->mode_config.plane_list, head) \
+ if ((crtc)->state->plane_mask & (1 << drm_plane_index(plane)))
+
+/**
+ * drm_crtc_for_each_pending_plane - iterate over attached planes in new state
+ * @plane: the loop cursor
+ * @crtc_state: the incoming crtc-state
+ *
+ * Similar to drm_crtc_for_each_plane(), but iterates the planes that will be
+ * attached if the specified state is applied. Useful during (for example)
+ * ->atomic_check() operations, to validate the incoming state
+ */
+#define drm_crtc_for_each_pending_plane(plane, crtc_state) \
+ list_for_each_entry((plane), &(crtc_state)->state->dev->mode_config.plane_list, head) \
+ if ((crtc_state)->plane_mask & (1 << drm_plane_index(plane)))
#endif /* DRM_ATOMIC_HELPER_H_ */
--
1.9.3
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 2/2] drm/atomic: add plane iterator macros
2014-11-21 20:28 ` [PATCH 2/2] drm/atomic: add plane iterator macros Rob Clark
@ 2014-11-21 20:38 ` Daniel Vetter
2014-11-21 20:42 ` Thierry Reding
2014-11-21 20:46 ` Thierry Reding
1 sibling, 1 reply; 7+ messages in thread
From: Daniel Vetter @ 2014-11-21 20:38 UTC (permalink / raw)
To: Rob Clark; +Cc: dri-devel
On Fri, Nov 21, 2014 at 03:28:32PM -0500, Rob Clark wrote:
> Add helper macros to iterate the current, or incoming set of planes
> attached to a crtc. These helpers are only available for drivers
> converted to use atomic-helpers.
>
> Signed-off-by: Rob Clark <robdclark@gmail.com>
> ---
> Documentation/DocBook/drm.tmpl | 1 +
> include/drm/drm_atomic_helper.h | 26 ++++++++++++++++++++++++++
> 2 files changed, 27 insertions(+)
>
> diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
> index 8c54f9a..3789f2d 100644
> --- a/Documentation/DocBook/drm.tmpl
> +++ b/Documentation/DocBook/drm.tmpl
> @@ -2343,6 +2343,7 @@ void intel_crt_init(struct drm_device *dev)
> <title>Atomic State Reset and Initialization</title>
> !Pdrivers/gpu/drm/drm_atomic_helper.c atomic state reset and initialization
> </sect3>
> +!Iinclude/drm/drm_atomic_helper.h
> !Edrivers/gpu/drm/drm_atomic_helper.c
> </sect2>
> <sect2>
> diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
> index 64b4e91..42d56e6 100644
> --- a/include/drm/drm_atomic_helper.h
> +++ b/include/drm/drm_atomic_helper.h
> @@ -96,5 +96,31 @@ drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector);
> void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
> struct drm_connector_state *state);
>
> +/**
> + * drm_crtc_for_each_plane - iterate over planes currently attached to crtc
> + * @plane: the loop cursor
> + * @crtc: the crtc whose planes are iterated
> + *
> + * This iterates over the current state, useful (for example) when applying
> + * atomic state after it has been checked and swapped. To iterate over the
> + * planes which *will* be attached (for ->atomic_check()) see
> + * drm_crtc_for_each_pending_plane()
> + */
> +#define drm_crtc_for_each_plane(plane, crtc) \
> + list_for_each_entry((plane), &(crtc)->dev->mode_config.plane_list, head) \
> + if ((crtc)->state->plane_mask & (1 << drm_plane_index(plane)))
Implement this as drm_crtc_for_each_pending_plane(plane, (crtc)->state)?
Which means _pending is a strange name ...
-Daniel
> +
> +/**
> + * drm_crtc_for_each_pending_plane - iterate over attached planes in new state
> + * @plane: the loop cursor
> + * @crtc_state: the incoming crtc-state
> + *
> + * Similar to drm_crtc_for_each_plane(), but iterates the planes that will be
> + * attached if the specified state is applied. Useful during (for example)
> + * ->atomic_check() operations, to validate the incoming state
> + */
> +#define drm_crtc_for_each_pending_plane(plane, crtc_state) \
> + list_for_each_entry((plane), &(crtc_state)->state->dev->mode_config.plane_list, head) \
> + if ((crtc_state)->plane_mask & (1 << drm_plane_index(plane)))
>
> #endif /* DRM_ATOMIC_HELPER_H_ */
> --
> 1.9.3
>
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - 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] 7+ messages in thread
* Re: [PATCH 2/2] drm/atomic: add plane iterator macros
2014-11-21 20:38 ` Daniel Vetter
@ 2014-11-21 20:42 ` Thierry Reding
2014-11-25 12:31 ` Daniel Vetter
0 siblings, 1 reply; 7+ messages in thread
From: Thierry Reding @ 2014-11-21 20:42 UTC (permalink / raw)
To: Daniel Vetter; +Cc: dri-devel
[-- Attachment #1.1: Type: text/plain, Size: 2496 bytes --]
On Fri, Nov 21, 2014 at 09:38:40PM +0100, Daniel Vetter wrote:
> On Fri, Nov 21, 2014 at 03:28:32PM -0500, Rob Clark wrote:
> > Add helper macros to iterate the current, or incoming set of planes
> > attached to a crtc. These helpers are only available for drivers
> > converted to use atomic-helpers.
> >
> > Signed-off-by: Rob Clark <robdclark@gmail.com>
> > ---
> > Documentation/DocBook/drm.tmpl | 1 +
> > include/drm/drm_atomic_helper.h | 26 ++++++++++++++++++++++++++
> > 2 files changed, 27 insertions(+)
> >
> > diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
> > index 8c54f9a..3789f2d 100644
> > --- a/Documentation/DocBook/drm.tmpl
> > +++ b/Documentation/DocBook/drm.tmpl
> > @@ -2343,6 +2343,7 @@ void intel_crt_init(struct drm_device *dev)
> > <title>Atomic State Reset and Initialization</title>
> > !Pdrivers/gpu/drm/drm_atomic_helper.c atomic state reset and initialization
> > </sect3>
> > +!Iinclude/drm/drm_atomic_helper.h
> > !Edrivers/gpu/drm/drm_atomic_helper.c
> > </sect2>
> > <sect2>
> > diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
> > index 64b4e91..42d56e6 100644
> > --- a/include/drm/drm_atomic_helper.h
> > +++ b/include/drm/drm_atomic_helper.h
> > @@ -96,5 +96,31 @@ drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector);
> > void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
> > struct drm_connector_state *state);
> >
> > +/**
> > + * drm_crtc_for_each_plane - iterate over planes currently attached to crtc
> > + * @plane: the loop cursor
> > + * @crtc: the crtc whose planes are iterated
> > + *
> > + * This iterates over the current state, useful (for example) when applying
> > + * atomic state after it has been checked and swapped. To iterate over the
> > + * planes which *will* be attached (for ->atomic_check()) see
> > + * drm_crtc_for_each_pending_plane()
> > + */
> > +#define drm_crtc_for_each_plane(plane, crtc) \
> > + list_for_each_entry((plane), &(crtc)->dev->mode_config.plane_list, head) \
> > + if ((crtc)->state->plane_mask & (1 << drm_plane_index(plane)))
>
> Implement this as drm_crtc_for_each_pending_plane(plane, (crtc)->state)?
> Which means _pending is a strange name ...
Yeah, I think the drm_crtc_for_each_pending_plane() could be
drm_crtc_state_for_each_plane(), then your suggestion makes perfect
sense.
Thierry
[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] drm/atomic: add plane iterator macros
2014-11-21 20:42 ` Thierry Reding
@ 2014-11-25 12:31 ` Daniel Vetter
0 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2014-11-25 12:31 UTC (permalink / raw)
To: Thierry Reding; +Cc: dri-devel
On Fri, Nov 21, 2014 at 09:42:25PM +0100, Thierry Reding wrote:
> On Fri, Nov 21, 2014 at 09:38:40PM +0100, Daniel Vetter wrote:
> > On Fri, Nov 21, 2014 at 03:28:32PM -0500, Rob Clark wrote:
> > > +#define drm_crtc_for_each_plane(plane, crtc) \
> > > + list_for_each_entry((plane), &(crtc)->dev->mode_config.plane_list, head) \
> > > + if ((crtc)->state->plane_mask & (1 << drm_plane_index(plane)))
> >
> > Implement this as drm_crtc_for_each_pending_plane(plane, (crtc)->state)?
> > Which means _pending is a strange name ...
>
> Yeah, I think the drm_crtc_for_each_pending_plane() could be
> drm_crtc_state_for_each_plane(), then your suggestion makes perfect
> sense.
I like Thierry's naming here. Rob can you apply that please?
Thanks, Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - 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] 7+ messages in thread
* Re: [PATCH 2/2] drm/atomic: add plane iterator macros
2014-11-21 20:28 ` [PATCH 2/2] drm/atomic: add plane iterator macros Rob Clark
2014-11-21 20:38 ` Daniel Vetter
@ 2014-11-21 20:46 ` Thierry Reding
1 sibling, 0 replies; 7+ messages in thread
From: Thierry Reding @ 2014-11-21 20:46 UTC (permalink / raw)
To: Rob Clark; +Cc: dri-devel
[-- Attachment #1.1: Type: text/plain, Size: 594 bytes --]
On Fri, Nov 21, 2014 at 03:28:32PM -0500, Rob Clark wrote:
> Add helper macros to iterate the current, or incoming set of planes
> attached to a crtc. These helpers are only available for drivers
> converted to use atomic-helpers.
>
> Signed-off-by: Rob Clark <robdclark@gmail.com>
> ---
> Documentation/DocBook/drm.tmpl | 1 +
> include/drm/drm_atomic_helper.h | 26 ++++++++++++++++++++++++++
> 2 files changed, 27 insertions(+)
I'd personally do s/crtc/CRTC/ in the commit message and kerneldoc
descriptions, but perhaps not everyone shares that same pedantry.
Thierry
[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] drm/atomic: track bitmask of planes attached to crtc
2014-11-21 20:28 [PATCH 1/2] drm/atomic: track bitmask of planes attached to crtc Rob Clark
2014-11-21 20:28 ` [PATCH 2/2] drm/atomic: add plane iterator macros Rob Clark
@ 2014-11-25 14:15 ` Daniel Vetter
1 sibling, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2014-11-25 14:15 UTC (permalink / raw)
To: Rob Clark; +Cc: dri-devel
On Fri, Nov 21, 2014 at 03:28:31PM -0500, Rob Clark wrote:
> Chasing plane->state->crtc of planes that are *not* part of the same
> atomic update is racy, making it incredibly awkward (or impossible) to
> do something simple like iterate over all planes and figure out which
> ones are attached to a crtc.
>
> Solve this by adding a bitmask of currently attached planes in the
> crtc-state.
>
> Note that the transitional helpers do not maintain the plane_mask. But
> they only support the legacy ioctls, which have sufficient brute-force
> locking around plane updates that they can continue to loop over all
> planes to see what is attached to a crtc the old way.
>
> Signed-off-by: Rob Clark <robdclark@gmail.com>
> ---
> drivers/gpu/drm/drm_atomic.c | 25 ++++++++++++++++++++-----
> drivers/gpu/drm/drm_atomic_helper.c | 8 ++++----
> include/drm/drm_atomic.h | 4 ++--
> include/drm/drm_crtc.h | 14 +++++++++++---
> 4 files changed, 37 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index d3b4674..8effbba 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -350,7 +350,8 @@ EXPORT_SYMBOL(drm_atomic_get_connector_state);
>
> /**
> * drm_atomic_set_crtc_for_plane - set crtc for plane
> - * @plane_state: atomic state object for the plane
> + * @state: the incoming atomic state
> + * @plane: the plane whose incoming state to update
> * @crtc: crtc to use for the plane
> *
> * Changing the assigned crtc for a plane requires us to grab the lock and state
> @@ -363,20 +364,34 @@ EXPORT_SYMBOL(drm_atomic_get_connector_state);
> * sequence must be restarted. All other errors are fatal.
> */
> int
> -drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
> - struct drm_crtc *crtc)
> +drm_atomic_set_crtc_for_plane(struct drm_atomic_state *state,
> + struct drm_plane *plane, struct drm_crtc *crtc)
> {
> + struct drm_plane_state *plane_state =
> + drm_atomic_get_plane_state(state, plane);
> struct drm_crtc_state *crtc_state;
>
> - if (crtc) {
> + /* acquire outgoing crtc lock, and clear bit in outgoing crtc mask: */
Ok still don't like these comments since at least for the old crtc it's
wrong: We already must both hold the lock and copied the state. So I've
dropped them (kerneldoc already mentions this too).
> + if (plane_state->crtc) {
> crtc_state = drm_atomic_get_crtc_state(plane_state->state,
> - crtc);
> + plane_state->crtc);
> if (IS_ERR(crtc_state))
And changed this to WARN_ON too to make sure this never fails. The pulled
it into my atomic-fixes branch.
-Daniel
> return PTR_ERR(crtc_state);
> +
> + crtc_state->plane_mask &= ~(1 << drm_plane_index(plane));
> }
>
> plane_state->crtc = crtc;
>
> + /* acquire incoming crtc lock, and set bit in incoming crtc mask: */
> + if (crtc) {
> + crtc_state = drm_atomic_get_crtc_state(plane_state->state,
> + crtc);
> + if (IS_ERR(crtc_state))
> + return PTR_ERR(crtc_state);
> + crtc_state->plane_mask |= (1 << drm_plane_index(plane));
> + }
> +
> if (crtc)
> DRM_DEBUG_KMS("Link plane state %p to [CRTC:%d]\n",
> plane_state, crtc->base.id);
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index a17b8e9..d765d37 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -1187,7 +1187,7 @@ retry:
> goto fail;
> }
>
> - ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
> + ret = drm_atomic_set_crtc_for_plane(state, plane, crtc);
> if (ret != 0)
> goto fail;
> drm_atomic_set_fb_for_plane(plane_state, fb);
> @@ -1255,7 +1255,7 @@ retry:
> goto fail;
> }
>
> - ret = drm_atomic_set_crtc_for_plane(plane_state, NULL);
> + ret = drm_atomic_set_crtc_for_plane(state, plane, NULL);
> if (ret != 0)
> goto fail;
> drm_atomic_set_fb_for_plane(plane_state, NULL);
> @@ -1426,7 +1426,7 @@ retry:
> goto fail;
> }
>
> - ret = drm_atomic_set_crtc_for_plane(primary_state, crtc);
> + ret = drm_atomic_set_crtc_for_plane(state, crtc->primary, crtc);
> if (ret != 0)
> goto fail;
> drm_atomic_set_fb_for_plane(primary_state, set->fb);
> @@ -1698,7 +1698,7 @@ retry:
> goto fail;
> }
>
> - ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
> + ret = drm_atomic_set_crtc_for_plane(state, plane, crtc);
> if (ret != 0)
> goto fail;
> drm_atomic_set_fb_for_plane(plane_state, fb);
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index 9d91916..6ff8775 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -44,8 +44,8 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
> struct drm_connector *connector);
>
> int __must_check
> -drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
> - struct drm_crtc *crtc);
> +drm_atomic_set_crtc_for_plane(struct drm_atomic_state *state,
> + struct drm_plane *plane, struct drm_crtc *crtc);
> void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
> struct drm_framebuffer *fb);
> int __must_check
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index b459e8f..4cf6905 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -231,6 +231,7 @@ struct drm_atomic_state;
> * struct drm_crtc_state - mutable CRTC state
> * @enable: whether the CRTC should be enabled, gates all other state
> * @mode_changed: for use by helpers and drivers when computing state updates
> + * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
> * @last_vblank_count: for helpers and drivers to capture the vblank of the
> * update to ensure framebuffer cleanup isn't done too early
> * @planes_changed: for use by helpers and drivers when computing state updates
> @@ -247,6 +248,13 @@ struct drm_crtc_state {
> bool planes_changed : 1;
> bool mode_changed : 1;
>
> + /* attached planes bitmask:
> + * WARNING: transitional helpers do not maintain plane_mask so
> + * drivers not converted over to atomic helpers should not rely
> + * on plane_mask being accurate!
> + */
> + u32 plane_mask;
> +
> /* last_vblank_count: for vblank waits before cleanup */
> u32 last_vblank_count;
>
> @@ -438,7 +446,7 @@ struct drm_crtc {
> * @state: backpointer to global drm_atomic_state
> */
> struct drm_connector_state {
> - struct drm_crtc *crtc;
> + struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_connector() */
>
> struct drm_encoder *best_encoder;
>
> @@ -673,8 +681,8 @@ struct drm_connector {
> * @state: backpointer to global drm_atomic_state
> */
> struct drm_plane_state {
> - struct drm_crtc *crtc;
> - struct drm_framebuffer *fb;
> + struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */
> + struct drm_framebuffer *fb; /* do not write directly, use drm_atomic_set_fb_for_plane() */
> struct fence *fence;
>
> /* Signed dest location allows it to be partially off screen */
> --
> 1.9.3
>
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - 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] 7+ messages in thread
end of thread, other threads:[~2014-11-25 14:15 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-21 20:28 [PATCH 1/2] drm/atomic: track bitmask of planes attached to crtc Rob Clark
2014-11-21 20:28 ` [PATCH 2/2] drm/atomic: add plane iterator macros Rob Clark
2014-11-21 20:38 ` Daniel Vetter
2014-11-21 20:42 ` Thierry Reding
2014-11-25 12:31 ` Daniel Vetter
2014-11-21 20:46 ` Thierry Reding
2014-11-25 14:15 ` [PATCH 1/2] drm/atomic: track bitmask of planes attached to crtc Daniel Vetter
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.