public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Dave Airlie <airlied@gmail.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 2/5] drm/fb_helper: add connector reference counting.
Date: Wed, 27 Apr 2016 09:33:22 +0200	[thread overview]
Message-ID: <20160427073322.GO2558@phenom.ffwll.local> (raw)
In-Reply-To: <1461722609-32474-2-git-send-email-airlied@gmail.com>

On Wed, Apr 27, 2016 at 12:03:26PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This takes a reference count when fbdev adds the connector,
> and drops it when it removes the connector.
> 
> It also drops the now unneeded code to find connectors
> and remove the from the modeset as they are reference counted.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Ok, I screwed up part of my first review, and add_all_connectors calls
add_one_connector. That looks like we'll leak non-mst connectors when
unloading i915. I think we need to add a loop to drm_fb_helper_fini and
call drm_fb_helper_remove_one_connector on all the connectors still in the
helper list. I think otherwise it looks good.

Would be really good to give this is a spin with full debugging enabled
when reloading i915.ko. Just to make sure I didn't miss anything. Or cc
intel-gfx and CI should be able to pick it up and give it a spin.
-Daniel

> ---
>  drivers/gpu/drm/drm_fb_helper.c | 34 ++--------------------------------
>  1 file changed, 2 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 855108e..b2f58fb 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -153,40 +153,13 @@ int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct drm_
>  	if (!fb_helper_connector)
>  		return -ENOMEM;
>  
> +	drm_connector_reference(connector);
>  	fb_helper_connector->connector = connector;
>  	fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector;
>  	return 0;
>  }
>  EXPORT_SYMBOL(drm_fb_helper_add_one_connector);
>  
> -static void remove_from_modeset(struct drm_mode_set *set,
> -		struct drm_connector *connector)
> -{
> -	int i, j;
> -
> -	for (i = 0; i < set->num_connectors; i++) {
> -		if (set->connectors[i] == connector)
> -			break;
> -	}
> -
> -	if (i == set->num_connectors)
> -		return;
> -
> -	for (j = i + 1; j < set->num_connectors; j++) {
> -		set->connectors[j - 1] = set->connectors[j];
> -	}
> -	set->num_connectors--;
> -
> -	/*
> -	 * TODO maybe need to makes sure we set it back to !=NULL somewhere?
> -	 */
> -	if (set->num_connectors == 0) {
> -		set->fb = NULL;
> -		drm_mode_destroy(connector->dev, set->mode);
> -		set->mode = NULL;
> -	}
> -}
> -
>  int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
>  				       struct drm_connector *connector)
>  {
> @@ -206,6 +179,7 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
>  	if (i == fb_helper->connector_count)
>  		return -EINVAL;
>  	fb_helper_connector = fb_helper->connector_info[i];
> +	drm_connector_unreference(fb_helper_connector->connector);
>  
>  	for (j = i + 1; j < fb_helper->connector_count; j++) {
>  		fb_helper->connector_info[j - 1] = fb_helper->connector_info[j];
> @@ -213,10 +187,6 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
>  	fb_helper->connector_count--;
>  	kfree(fb_helper_connector);
>  
> -	/* also cleanup dangling references to the connector: */
> -	for (i = 0; i < fb_helper->crtc_count; i++)
> -		remove_from_modeset(&fb_helper->crtc_info[i].mode_set, connector);
> -
>  	return 0;
>  }
>  EXPORT_SYMBOL(drm_fb_helper_remove_one_connector);
> -- 
> 2.5.5
> 
> _______________________________________________
> 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

  reply	other threads:[~2016-04-27  7:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-27  2:03 [PATCH 1/5] drm/modes: add connector reference counting. (v2) Dave Airlie
2016-04-27  2:03 ` [PATCH 2/5] drm/fb_helper: add connector reference counting Dave Airlie
2016-04-27  7:33   ` Daniel Vetter [this message]
2016-04-27  2:03 ` [PATCH 3/5] drm/crtc: take references to connectors used in a modeset Dave Airlie
2016-04-27  7:07   ` Daniel Stone
2016-04-27  7:34   ` [Intel-gfx] " Daniel Vetter
2016-04-27  7:48     ` Daniel Vetter
2016-04-27  2:03 ` [PATCH 4/5] drm/atomic: use connector references Dave Airlie
2016-04-27  7:13   ` Daniel Stone
2016-04-27  7:47     ` [Intel-gfx] " Daniel Vetter
2016-04-27  7:22   ` Daniel Stone
2016-04-27  2:03 ` [PATCH 5/5] drm/i915/mst: use reference counted connectors. (v2) Dave Airlie
2016-04-27  7:52   ` Daniel Vetter
2016-04-27  7:28 ` [Intel-gfx] [PATCH 1/5] drm/modes: add connector reference counting. (v2) Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160427073322.GO2558@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox