All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>,
	dri-devel@lists.freedesktop.org, stable@vger.kernel.org,
	Carlos Santa <carlos.santa@intel.com>,
	"Kirill A . Shutemov" <kirill@shutemov.name>
Subject: Re: [PATCH v2 2/4] drm/fb-helper: Keep references for the current set of used connectors
Date: Wed, 26 Oct 2016 17:11:00 +0300	[thread overview]
Message-ID: <20161026141100.GH4617@intel.com> (raw)
In-Reply-To: <20161026135445.GR10167@nuc-i3427.alporthouse.com>

On Wed, Oct 26, 2016 at 02:54:45PM +0100, Chris Wilson wrote:
> On Wed, Oct 26, 2016 at 04:31:20PM +0300, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > The fbdev helper code keeps around two lists of connectors. One is the
> > list of all connectors it could use, and that list already holds
> > references for all the connectors. However the other list, or rather
> > lists, is the one actively being used. That list is tracked per-crtc
> > and currently doesn't hold any extra references. Let's grab those
> > extra references to avoid oopsing when the connector vanishes. The
> > list of all possible connectors should get updated when the hpd happens,
> > but the list of actively used connectors would not get updated until
> > the next time the fb-helper picks through the set of possible connectors.
> > And so we need to hang on to the connectors until that time.
> > 
> > Since we need to clean up in drm_fb_helper_crtc_free() as well,
> > let's pull the code to a common place. And while at it let's
> > pull in up the modeset->mode cleanup in there as well. The case
> > of modeset->fb is a bit less clear. I'm thinking we should probably
> > hold a reference to it, but for now I just slapped on a FIXME.
> > 
> > v2: Cleanup things drm_fb_helper_crtc_free() too (Chris)
> > 
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: stable@vger.kernel.org
> > Cc: Carlos Santa <carlos.santa@intel.com>
> > Cc: Kirill A. Shutemov <kirill@shutemov.name>
> > Tested-by: Carlos Santa <carlos.santa@intel.com> (v1)
> > Tested-by: Kirill A. Shutemov <kirill@shutemov.name> (v1)
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97666
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_fb_helper.c | 58 +++++++++++++++++++++++------------------
> >  1 file changed, 32 insertions(+), 26 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> > index db469d12d195..83961f1a97d2 100644
> > --- a/drivers/gpu/drm/drm_fb_helper.c
> > +++ b/drivers/gpu/drm/drm_fb_helper.c
> > @@ -605,6 +605,24 @@ int drm_fb_helper_blank(int blank, struct fb_info *info)
> >  }
> >  EXPORT_SYMBOL(drm_fb_helper_blank);
> >  
> > +static void drm_fb_helper_modeset_free(struct drm_fb_helper *helper,
> > +				       struct drm_mode_set *modeset)
> > +{
> > +	int i;
> > +
> > +	for (i = 0; i < modeset->num_connectors; i++) {
> > +		drm_connector_unreference(modeset->connectors[i]);
> > +		modeset->connectors[i] = NULL;
> > +	}
> > +	modeset->num_connectors = 0;
> > +
> > +	drm_mode_destroy(helper->dev, modeset->mode);
> > +	modeset->mode = NULL;
> > +
> > +	/* FIXME should hold a ref? */
> > +	modeset->fb = NULL;
> > +}
> > +
> >  static void drm_fb_helper_crtc_free(struct drm_fb_helper *helper)
> >  {
> >  	int i;
> > @@ -614,11 +632,10 @@ static void drm_fb_helper_crtc_free(struct drm_fb_helper *helper)
> >  		kfree(helper->connector_info[i]);
> >  	}
> >  	kfree(helper->connector_info);
> > -	for (i = 0; i < helper->crtc_count; i++) {
> > -		kfree(helper->crtc_info[i].mode_set.connectors);
> > -		if (helper->crtc_info[i].mode_set.mode)
> > -			drm_mode_destroy(helper->dev, helper->crtc_info[i].mode_set.mode);
> > -	}
> > +
> > +	for (i = 0; i < helper->crtc_count; i++)
> > +		drm_fb_helper_modeset_free(helper,
> > +					   &helper->crtc_info[i].mode_set);
> 
> We lose the kfree(mode_set.connectors) here.

Doh.

> 
> So 
> 	for (i = 0; i < helper->crtc_count; i++)
> 		struct drm_mode_set *modeset = &helper->crtc_info[i].mode_set);
> 
> 		drm_fb_helper_modeset_release(helper, modeset);

Hmm. Yeah _release() does seem better than _free() if we don't actually
free all of it.

> 		kfree(modeset->connectors);
> 	}
> ?
> 
> Couldn't spot any other missing calls to release the new ref, so with
> the tiny leak fixed,
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Thanks. I'll respin it once more.

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

WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>,
	dri-devel@lists.freedesktop.org, stable@vger.kernel.org,
	Carlos Santa <carlos.santa@intel.com>,
	"Kirill A . Shutemov" <kirill@shutemov.name>
Subject: Re: [PATCH v2 2/4] drm/fb-helper: Keep references for the current set of used connectors
Date: Wed, 26 Oct 2016 17:11:00 +0300	[thread overview]
Message-ID: <20161026141100.GH4617@intel.com> (raw)
In-Reply-To: <20161026135445.GR10167@nuc-i3427.alporthouse.com>

On Wed, Oct 26, 2016 at 02:54:45PM +0100, Chris Wilson wrote:
> On Wed, Oct 26, 2016 at 04:31:20PM +0300, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrj�l� <ville.syrjala@linux.intel.com>
> > 
> > The fbdev helper code keeps around two lists of connectors. One is the
> > list of all connectors it could use, and that list already holds
> > references for all the connectors. However the other list, or rather
> > lists, is the one actively being used. That list is tracked per-crtc
> > and currently doesn't hold any extra references. Let's grab those
> > extra references to avoid oopsing when the connector vanishes. The
> > list of all possible connectors should get updated when the hpd happens,
> > but the list of actively used connectors would not get updated until
> > the next time the fb-helper picks through the set of possible connectors.
> > And so we need to hang on to the connectors until that time.
> > 
> > Since we need to clean up in drm_fb_helper_crtc_free() as well,
> > let's pull the code to a common place. And while at it let's
> > pull in up the modeset->mode cleanup in there as well. The case
> > of modeset->fb is a bit less clear. I'm thinking we should probably
> > hold a reference to it, but for now I just slapped on a FIXME.
> > 
> > v2: Cleanup things drm_fb_helper_crtc_free() too (Chris)
> > 
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: stable@vger.kernel.org
> > Cc: Carlos Santa <carlos.santa@intel.com>
> > Cc: Kirill A. Shutemov <kirill@shutemov.name>
> > Tested-by: Carlos Santa <carlos.santa@intel.com> (v1)
> > Tested-by: Kirill A. Shutemov <kirill@shutemov.name> (v1)
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97666
> > Signed-off-by: Ville Syrj�l� <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_fb_helper.c | 58 +++++++++++++++++++++++------------------
> >  1 file changed, 32 insertions(+), 26 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> > index db469d12d195..83961f1a97d2 100644
> > --- a/drivers/gpu/drm/drm_fb_helper.c
> > +++ b/drivers/gpu/drm/drm_fb_helper.c
> > @@ -605,6 +605,24 @@ int drm_fb_helper_blank(int blank, struct fb_info *info)
> >  }
> >  EXPORT_SYMBOL(drm_fb_helper_blank);
> >  
> > +static void drm_fb_helper_modeset_free(struct drm_fb_helper *helper,
> > +				       struct drm_mode_set *modeset)
> > +{
> > +	int i;
> > +
> > +	for (i = 0; i < modeset->num_connectors; i++) {
> > +		drm_connector_unreference(modeset->connectors[i]);
> > +		modeset->connectors[i] = NULL;
> > +	}
> > +	modeset->num_connectors = 0;
> > +
> > +	drm_mode_destroy(helper->dev, modeset->mode);
> > +	modeset->mode = NULL;
> > +
> > +	/* FIXME should hold a ref? */
> > +	modeset->fb = NULL;
> > +}
> > +
> >  static void drm_fb_helper_crtc_free(struct drm_fb_helper *helper)
> >  {
> >  	int i;
> > @@ -614,11 +632,10 @@ static void drm_fb_helper_crtc_free(struct drm_fb_helper *helper)
> >  		kfree(helper->connector_info[i]);
> >  	}
> >  	kfree(helper->connector_info);
> > -	for (i = 0; i < helper->crtc_count; i++) {
> > -		kfree(helper->crtc_info[i].mode_set.connectors);
> > -		if (helper->crtc_info[i].mode_set.mode)
> > -			drm_mode_destroy(helper->dev, helper->crtc_info[i].mode_set.mode);
> > -	}
> > +
> > +	for (i = 0; i < helper->crtc_count; i++)
> > +		drm_fb_helper_modeset_free(helper,
> > +					   &helper->crtc_info[i].mode_set);
> 
> We lose the kfree(mode_set.connectors) here.

Doh.

> 
> So 
> 	for (i = 0; i < helper->crtc_count; i++)
> 		struct drm_mode_set *modeset = &helper->crtc_info[i].mode_set);
> 
> 		drm_fb_helper_modeset_release(helper, modeset);

Hmm. Yeah _release() does seem better than _free() if we don't actually
free all of it.

> 		kfree(modeset->connectors);
> 	}
> ?
> 
> Couldn't spot any other missing calls to release the new ref, so with
> the tiny leak fixed,
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Thanks. I'll respin it once more.

-- 
Ville Syrj�l�
Intel OTC

  reply	other threads:[~2016-10-26 14:11 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-26  9:05 [PATCH 0/4] drm: Fix MST oopses in fbdev restore ville.syrjala
2016-10-26  9:05 ` [PATCH 1/4] drm/fb-helper: Fix connector ref leak on error ville.syrjala
2016-10-26  9:48   ` Chris Wilson
2016-10-26  9:48     ` Chris Wilson
2016-10-26  9:05 ` [PATCH 2/4] drm/fb-helper: Keep references for the current set of used connectors ville.syrjala
2016-10-26  9:05   ` ville.syrjala
2016-10-26  9:52   ` Chris Wilson
2016-10-26  9:52     ` Chris Wilson
2016-10-26 12:34     ` Ville Syrjälä
2016-10-26 12:34       ` Ville Syrjälä
2016-10-26 13:31   ` [PATCH v2 " ville.syrjala
2016-10-26 13:54     ` Chris Wilson
2016-10-26 13:54       ` Chris Wilson
2016-10-26 14:11       ` Ville Syrjälä [this message]
2016-10-26 14:11         ` Ville Syrjälä
2016-10-26 14:41   ` [PATCH v3 " ville.syrjala
2016-10-26 14:41     ` ville.syrjala
2016-10-26  9:05 ` [PATCH 3/4] drm/dp/mst: Clear port->pdt when tearing down the i2c adapter ville.syrjala
2016-10-26  9:05   ` ville.syrjala
2016-10-26 12:53   ` Daniel Vetter
2016-10-26 12:53     ` Daniel Vetter
2016-10-26 13:02     ` Ville Syrjälä
2016-10-26 13:02       ` Ville Syrjälä
2016-10-26 13:30   ` [PATCH v2 " ville.syrjala
2016-10-26 13:30     ` ville.syrjala
2016-10-26 13:35     ` Ville Syrjälä
2016-10-26 13:35       ` Ville Syrjälä
2016-10-26 14:02       ` Daniel Vetter
2016-10-26 14:02         ` Daniel Vetter
2016-10-26 16:54         ` Daniel Vetter
2016-10-26 16:54           ` Daniel Vetter
2016-10-26 14:46   ` [PATCH v3 " ville.syrjala
2016-10-26 14:46     ` ville.syrjala
2016-10-26  9:05 ` [PATCH 4/4] drm/dp/mst: Check peer device type before attempting EDID read ville.syrjala
2016-10-26 12:55   ` Daniel Vetter
2016-10-26 12:55     ` Daniel Vetter
2016-10-26 13:05     ` Ville Syrjälä
2016-10-26 13:05       ` Ville Syrjälä
2016-10-26 18:31   ` Carlos Santa
2016-10-26 18:31     ` Carlos Santa
2016-10-26 18:45     ` Ville Syrjälä
2016-10-26 18:45       ` Ville Syrjälä
2016-10-26 13:38 ` [PATCH 0/4] drm: Fix MST oopses in fbdev restore Ville Syrjälä

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=20161026141100.GH4617@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=carlos.santa@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kirill@shutemov.name \
    --cc=stable@vger.kernel.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 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.