diff mbox series

[v5,3/4] drm/vc4: Check for the binner bo before handling OOM interrupt

Message ID 20190415123908.28986-4-paul.kocialkowski@bootlin.com (mailing list archive)
State New, archived
Headers show
Series drm/vc4: Binner BO management improvements | expand

Commit Message

Paul Kocialkowski April 15, 2019, 12:39 p.m. UTC
Since the OOM interrupt directly deals with the binner bo, it doesn't
make sense to try and handle it without a binner buffer registered.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 drivers/gpu/drm/vc4/vc4_irq.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Eric Anholt April 15, 2019, 8:48 p.m. UTC | #1
Paul Kocialkowski <paul.kocialkowski@bootlin.com> writes:

> Since the OOM interrupt directly deals with the binner bo, it doesn't
> make sense to try and handle it without a binner buffer registered.
>
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> ---
>  drivers/gpu/drm/vc4/vc4_irq.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_irq.c b/drivers/gpu/drm/vc4/vc4_irq.c
> index ffd0a4388752..723dc86b4511 100644
> --- a/drivers/gpu/drm/vc4/vc4_irq.c
> +++ b/drivers/gpu/drm/vc4/vc4_irq.c
> @@ -64,6 +64,9 @@ vc4_overflow_mem_work(struct work_struct *work)
>  	struct vc4_exec_info *exec;
>  	unsigned long irqflags;
>  
> +	if (!bo)
> +		return;
> +
>  	bin_bo_slot = vc4_v3d_get_bin_slot(vc4);
>  	if (bin_bo_slot < 0) {
>  		DRM_ERROR("Couldn't allocate binner overflow mem\n");
> -- 
> 2.21.0

I don't think this is going to be race-free.  You're checking outside of
a lock, then proceeding to use it even if (in patch 4) the bin BO was in
the process of being freed during the file close path.  Can we put all
of the overflow process here under the same lock as freeing?
Paul Kocialkowski April 23, 2019, 8:30 a.m. UTC | #2
Hi,

On Mon, 2019-04-15 at 13:48 -0700, Eric Anholt wrote:
> Paul Kocialkowski <paul.kocialkowski@bootlin.com> writes:
> 
> > Since the OOM interrupt directly deals with the binner bo, it doesn't
> > make sense to try and handle it without a binner buffer registered.
> > 
> > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > ---
> >  drivers/gpu/drm/vc4/vc4_irq.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/vc4/vc4_irq.c b/drivers/gpu/drm/vc4/vc4_irq.c
> > index ffd0a4388752..723dc86b4511 100644
> > --- a/drivers/gpu/drm/vc4/vc4_irq.c
> > +++ b/drivers/gpu/drm/vc4/vc4_irq.c
> > @@ -64,6 +64,9 @@ vc4_overflow_mem_work(struct work_struct *work)
> >  	struct vc4_exec_info *exec;
> >  	unsigned long irqflags;
> >  
> > +	if (!bo)
> > +		return;
> > +
> >  	bin_bo_slot = vc4_v3d_get_bin_slot(vc4);
> >  	if (bin_bo_slot < 0) {
> >  		DRM_ERROR("Couldn't allocate binner overflow mem\n");
> > -- 
> > 2.21.0
> 
> I don't think this is going to be race-free.  You're checking outside of
> a lock, then proceeding to use it even if (in patch 4) the bin BO was in
> the process of being freed during the file close path.  Can we put all
> of the overflow process here under the same lock as freeing?

Definitely, sorry I missed that.

Cheers,

Paul
Paul Kocialkowski April 23, 2019, 8:50 a.m. UTC | #3
On Tue, 2019-04-23 at 10:30 +0200, Paul Kocialkowski wrote:
> Hi,
> 
> On Mon, 2019-04-15 at 13:48 -0700, Eric Anholt wrote:
> > Paul Kocialkowski <paul.kocialkowski@bootlin.com> writes:
> > 
> > > Since the OOM interrupt directly deals with the binner bo, it doesn't
> > > make sense to try and handle it without a binner buffer registered.
> > > 
> > > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > > ---
> > >  drivers/gpu/drm/vc4/vc4_irq.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/vc4/vc4_irq.c b/drivers/gpu/drm/vc4/vc4_irq.c
> > > index ffd0a4388752..723dc86b4511 100644
> > > --- a/drivers/gpu/drm/vc4/vc4_irq.c
> > > +++ b/drivers/gpu/drm/vc4/vc4_irq.c
> > > @@ -64,6 +64,9 @@ vc4_overflow_mem_work(struct work_struct *work)
> > >  	struct vc4_exec_info *exec;
> > >  	unsigned long irqflags;
> > >  
> > > +	if (!bo)
> > > +		return;
> > > +
> > >  	bin_bo_slot = vc4_v3d_get_bin_slot(vc4);
> > >  	if (bin_bo_slot < 0) {
> > >  		DRM_ERROR("Couldn't allocate binner overflow mem\n");
> > > -- 
> > > 2.21.0
> > 
> > I don't think this is going to be race-free.  You're checking outside of
> > a lock, then proceeding to use it even if (in patch 4) the bin BO was in
> > the process of being freed during the file close path.  Can we put all
> > of the overflow process here under the same lock as freeing?
> 
> Definitely, sorry I missed that.

That being said, I think it should be fixed in 4/4 since this patch is
not problematic on its own (we haven't introduced the mutex/kref yet). 

Cheers,

Paul
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vc4/vc4_irq.c b/drivers/gpu/drm/vc4/vc4_irq.c
index ffd0a4388752..723dc86b4511 100644
--- a/drivers/gpu/drm/vc4/vc4_irq.c
+++ b/drivers/gpu/drm/vc4/vc4_irq.c
@@ -64,6 +64,9 @@  vc4_overflow_mem_work(struct work_struct *work)
 	struct vc4_exec_info *exec;
 	unsigned long irqflags;
 
+	if (!bo)
+		return;
+
 	bin_bo_slot = vc4_v3d_get_bin_slot(vc4);
 	if (bin_bo_slot < 0) {
 		DRM_ERROR("Couldn't allocate binner overflow mem\n");