lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2fe2b72a28a7892797fed6d3db86b7c7912fe8c9.camel@bootlin.com>
Date:   Fri, 10 May 2019 17:48:39 +0200
From:   Paul Kocialkowski <paul.kocialkowski@...tlin.com>
To:     Eric Anholt <eric@...olt.net>, dri-devel@...ts.freedesktop.org,
        linux-kernel@...r.kernel.org
Cc:     David Airlie <airlied@...ux.ie>, Daniel Vetter <daniel@...ll.ch>,
        Maxime Ripard <maxime.ripard@...tlin.com>,
        Eben Upton <eben@...pberrypi.org>,
        Thomas Petazzoni <thomas.petazzoni@...tlin.com>
Subject: Re: [PATCH v8 4/4] drm/vc4: Allocate binner bo when starting to use
 the V3D

Hi,

On Thu, 2019-05-09 at 11:39 -0700, Eric Anholt wrote:
> Paul Kocialkowski <paul.kocialkowski@...tlin.com> writes:
> 
> > The binner BO is not required until the V3D is in use, so avoid
> > allocating it at probe and do it on the first non-dumb BO allocation.
> > 
> > Keep track of which clients are using the V3D and liberate the buffer
> > when there is none left, using a kref. Protect the logic with a
> > mutex to avoid race conditions.
> > 
> > The binner BO is created at the time of the first render ioctl and is
> > destroyed when there is no client and no exec job using it left.
> > 
> > The Out-Of-Memory (OOM) interrupt also gets some tweaking, to avoid
> > enabling it before having allocated a binner bo.
> > 
> > We also want to keep the BO alive during runtime suspend/resume to avoid
> > failing to allocate it at resume. This happens when the CMA pool is
> > full at that point and results in a hard crash.
> > 
> > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@...tlin.com>
> > @@ -313,6 +321,49 @@ static int bin_bo_alloc(struct vc4_dev *vc4)
> >  	return ret;
> >  }
> >  
> > +int vc4_v3d_bin_bo_get(struct vc4_dev *vc4, bool *used)
> > +{
> > +	int ret = 0;
> > +
> > +	mutex_lock(&vc4->bin_bo_lock);
> > +
> > +	if (used && *used)
> > +		goto complete;
> 
> 
> > +
> > +	if (used)
> > +		*used = true;
> > +
> > +	if (vc4->bin_bo) {
> > +		kref_get(&vc4->bin_bo_kref);
> > +		goto complete;
> > +	}
> > +
> > +	ret = bin_bo_alloc(vc4);
> 
> I think this block wants to be:
> 
> if (vc4->bin_bo)
> 	kref_get(&vc4->bin_bo_kref);
> else
> 	ret = bin_bo_alloc(vc4);
> 
> if (ret == 0 && used)
> 	*used = true;
> 
> (so we don't flag used if bin_bo_alloc fails)
> 
> If you agree, then the series is:

I totally agree, and had definitely lost sight of the return value.

Thanks for the thorough code review once more!

Cheers,

Paul

> Reviewed-by: Eric Anholt <eric@...olt.net>
> 
> > +
> > +complete:
> > +	mutex_unlock(&vc4->bin_bo_lock);
> > +
> > +	return ret;
> > +}
-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ