linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dma-buf: fix locking in sync_print_obj()
@ 2020-01-24 10:13 Dan Carpenter
  2020-01-24 10:20 ` Chris Wilson
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2020-01-24 10:13 UTC (permalink / raw)
  To: Sumit Semwal, Chris Wilson
  Cc: Gustavo Padovan, Sean Paul, linux-media, dri-devel,
	linaro-mm-sig, kernel-janitors

This is always called with IRQs disabled and we don't actually want to
enable IRQs at the end.

Fixes: a6aa8fca4d79 ("dma-buf/sw-sync: Reduce irqsave/irqrestore from known context")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/dma-buf/sync_debug.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/dma-buf/sync_debug.c b/drivers/dma-buf/sync_debug.c
index 101394f16930..952331344b1c 100644
--- a/drivers/dma-buf/sync_debug.c
+++ b/drivers/dma-buf/sync_debug.c
@@ -107,15 +107,16 @@ static void sync_print_fence(struct seq_file *s,
 static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)
 {
 	struct list_head *pos;
+	unsigned long flags;
 
 	seq_printf(s, "%s: %d\n", obj->name, obj->value);
 
-	spin_lock_irq(&obj->lock);
+	spin_lock_irqsave(&obj->lock, flags);
 	list_for_each(pos, &obj->pt_list) {
 		struct sync_pt *pt = container_of(pos, struct sync_pt, link);
 		sync_print_fence(s, &pt->base, false);
 	}
-	spin_unlock_irq(&obj->lock);
+	spin_unlock_irqrestore(&obj->lock, flags);
 }
 
 static void sync_print_sync_file(struct seq_file *s,
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] dma-buf: fix locking in sync_print_obj()
  2020-01-24 10:13 [PATCH] dma-buf: fix locking in sync_print_obj() Dan Carpenter
@ 2020-01-24 10:20 ` Chris Wilson
  2020-01-24 10:31   ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Wilson @ 2020-01-24 10:20 UTC (permalink / raw)
  To: Dan Carpenter, Sumit Semwal
  Cc: Gustavo Padovan, Sean Paul, linux-media, dri-devel,
	linaro-mm-sig, kernel-janitors

Quoting Dan Carpenter (2020-01-24 10:13:12)
> This is always called with IRQs disabled and we don't actually want to
> enable IRQs at the end.
> 
> Fixes: a6aa8fca4d79 ("dma-buf/sw-sync: Reduce irqsave/irqrestore from known context")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/dma-buf/sync_debug.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma-buf/sync_debug.c b/drivers/dma-buf/sync_debug.c
> index 101394f16930..952331344b1c 100644
> --- a/drivers/dma-buf/sync_debug.c
> +++ b/drivers/dma-buf/sync_debug.c
> @@ -107,15 +107,16 @@ static void sync_print_fence(struct seq_file *s,
>  static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)
>  {
>         struct list_head *pos;
> +       unsigned long flags;
>  
>         seq_printf(s, "%s: %d\n", obj->name, obj->value);
>  
> -       spin_lock_irq(&obj->lock);
> +       spin_lock_irqsave(&obj->lock, flags);

Exactly, it can be just spin_lock() as the irq state is known.

Once again I question why this [sync_debug.c] code even exists.
-Chris

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dma-buf: fix locking in sync_print_obj()
  2020-01-24 10:20 ` Chris Wilson
@ 2020-01-24 10:31   ` Dan Carpenter
  2020-01-24 11:15     ` Chris Wilson
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2020-01-24 10:31 UTC (permalink / raw)
  To: Chris Wilson
  Cc: Sumit Semwal, Gustavo Padovan, Sean Paul, linux-media, dri-devel,
	linaro-mm-sig, kernel-janitors

On Fri, Jan 24, 2020 at 10:20:56AM +0000, Chris Wilson wrote:
> Quoting Dan Carpenter (2020-01-24 10:13:12)
> > This is always called with IRQs disabled and we don't actually want to
> > enable IRQs at the end.
> > 
> > Fixes: a6aa8fca4d79 ("dma-buf/sw-sync: Reduce irqsave/irqrestore from known context")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> >  drivers/dma-buf/sync_debug.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/dma-buf/sync_debug.c b/drivers/dma-buf/sync_debug.c
> > index 101394f16930..952331344b1c 100644
> > --- a/drivers/dma-buf/sync_debug.c
> > +++ b/drivers/dma-buf/sync_debug.c
> > @@ -107,15 +107,16 @@ static void sync_print_fence(struct seq_file *s,
> >  static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)
> >  {
> >         struct list_head *pos;
> > +       unsigned long flags;
> >  
> >         seq_printf(s, "%s: %d\n", obj->name, obj->value);
> >  
> > -       spin_lock_irq(&obj->lock);
> > +       spin_lock_irqsave(&obj->lock, flags);
> 
> Exactly, it can be just spin_lock() as the irq state is known.
> 

I did consider that but I wasn't sure how this is going to be used in
the future so I took a conservative approach.

> Once again I question why this [sync_debug.c] code even exists.

No idea.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dma-buf: fix locking in sync_print_obj()
  2020-01-24 10:31   ` Dan Carpenter
@ 2020-01-24 11:15     ` Chris Wilson
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2020-01-24 11:15 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Sumit Semwal, Gustavo Padovan, Sean Paul, linux-media, dri-devel,
	linaro-mm-sig, kernel-janitors

Quoting Dan Carpenter (2020-01-24 10:31:23)
> On Fri, Jan 24, 2020 at 10:20:56AM +0000, Chris Wilson wrote:
> > Quoting Dan Carpenter (2020-01-24 10:13:12)
> > > This is always called with IRQs disabled and we don't actually want to
> > > enable IRQs at the end.
> > > 
> > > Fixes: a6aa8fca4d79 ("dma-buf/sw-sync: Reduce irqsave/irqrestore from known context")
> > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > ---
> > >  drivers/dma-buf/sync_debug.c | 5 +++--
> > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/dma-buf/sync_debug.c b/drivers/dma-buf/sync_debug.c
> > > index 101394f16930..952331344b1c 100644
> > > --- a/drivers/dma-buf/sync_debug.c
> > > +++ b/drivers/dma-buf/sync_debug.c
> > > @@ -107,15 +107,16 @@ static void sync_print_fence(struct seq_file *s,
> > >  static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)
> > >  {
> > >         struct list_head *pos;
> > > +       unsigned long flags;
> > >  
> > >         seq_printf(s, "%s: %d\n", obj->name, obj->value);
> > >  
> > > -       spin_lock_irq(&obj->lock);
> > > +       spin_lock_irqsave(&obj->lock, flags);
> > 
> > Exactly, it can be just spin_lock() as the irq state is known.
> > 
> 
> I did consider that but I wasn't sure how this is going to be used in
> the future so I took a conservative approach.

Sure, it's debug so not critical (lists within lists to a seqfile, ouch)

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-24 11:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-24 10:13 [PATCH] dma-buf: fix locking in sync_print_obj() Dan Carpenter
2020-01-24 10:20 ` Chris Wilson
2020-01-24 10:31   ` Dan Carpenter
2020-01-24 11:15     ` Chris Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).