Message ID | 1461722609-32474-4-git-send-email-airlied@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi, On 27 April 2016 at 03:03, Dave Airlie <airlied@gmail.com> wrote: > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c > index 9d5e3c8..d899dac 100644 > --- a/drivers/gpu/drm/drm_atomic.c > +++ b/drivers/gpu/drm/drm_atomic.c > @@ -1179,6 +1179,15 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state, > > conn_state->crtc = crtc; > > + /* If we had no crtc then got one, add a reference, > + * if we had a crtc and are going to none, drop a reference, > + * otherwise just keep the reference we have. > + */ > + if (!had_crtc && crtc) > + drm_connector_reference(conn_state->connector); > + else if (!crtc && had_crtc) > + drm_connector_unreference(conn_state->connector); Similarly to the non-atomic comments, can you drop the had_crtc test here, and always ref if crtc, and unref if !crtc? Cheers, Daniel
Hi, On 27 April 2016 at 03:03, Dave Airlie <airlied@gmail.com> wrote: > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c > index 9d5e3c8..d899dac 100644 > --- a/drivers/gpu/drm/drm_atomic.c > +++ b/drivers/gpu/drm/drm_atomic.c > @@ -1179,6 +1179,15 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state, > > conn_state->crtc = crtc; > > + /* If we had no crtc then got one, add a reference, > + * if we had a crtc and are going to none, drop a reference, > + * otherwise just keep the reference we have. > + */ > + if (!had_crtc && crtc) > + drm_connector_reference(conn_state->connector); > + else if (!crtc && had_crtc) > + drm_connector_unreference(conn_state->connector); Similarly to the non-atomic comments, can you drop the had_crtc test here, and always ref if crtc, and unref if !crtc? Cheers, Daniel
On Wed, Apr 27, 2016 at 08:13:04AM +0100, Daniel Stone wrote: > Hi, > > On 27 April 2016 at 03:03, Dave Airlie <airlied@gmail.com> wrote: > > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c > > index 9d5e3c8..d899dac 100644 > > --- a/drivers/gpu/drm/drm_atomic.c > > +++ b/drivers/gpu/drm/drm_atomic.c > > @@ -1179,6 +1179,15 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state, > > > > conn_state->crtc = crtc; > > > > + /* If we had no crtc then got one, add a reference, > > + * if we had a crtc and are going to none, drop a reference, > > + * otherwise just keep the reference we have. > > + */ > > + if (!had_crtc && crtc) > > + drm_connector_reference(conn_state->connector); > > + else if (!crtc && had_crtc) > > + drm_connector_unreference(conn_state->connector); > > Similarly to the non-atomic comments, can you drop the had_crtc test > here, and always ref if crtc, and unref if !crtc? Yeah, that's more in line with how we refcount other stuff in atomic. With that bikeshed: Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> > > Cheers, > Daniel > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 9d5e3c8..d899dac 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1159,7 +1159,7 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state, struct drm_crtc *crtc) { struct drm_crtc_state *crtc_state; - + bool had_crtc = conn_state->crtc ? true : false; if (conn_state->crtc && conn_state->crtc != crtc) { crtc_state = drm_atomic_get_existing_crtc_state(conn_state->state, conn_state->crtc); @@ -1179,6 +1179,15 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state, conn_state->crtc = crtc; + /* If we had no crtc then got one, add a reference, + * if we had a crtc and are going to none, drop a reference, + * otherwise just keep the reference we have. + */ + if (!had_crtc && crtc) + drm_connector_reference(conn_state->connector); + else if (!crtc && had_crtc) + drm_connector_unreference(conn_state->connector); + if (crtc) DRM_DEBUG_ATOMIC("Link connector state %p to [CRTC:%d:%s]\n", conn_state, crtc->base.id, crtc->name); diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index d25abce..a29deac 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -2762,6 +2762,8 @@ __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector, struct drm_connector_state *state) { memcpy(state, connector->state, sizeof(*state)); + if (state->crtc) + drm_connector_reference(connector); } EXPORT_SYMBOL(__drm_atomic_helper_connector_duplicate_state); @@ -2889,6 +2891,8 @@ __drm_atomic_helper_connector_destroy_state(struct drm_connector *connector, * state will automatically do the right thing if code is ever added * to this function. */ + if (state->crtc) + drm_connector_unreference(connector); } EXPORT_SYMBOL(__drm_atomic_helper_connector_destroy_state);