diff mbox series

dma-buf/sw-sync: don't enable IRQ from sync_print_obj()

Message ID c2e46020-aaa6-4e06-bf73-f05823f913f0@I-love.SAKURA.ne.jp (mailing list archive)
State New, archived
Headers show
Series dma-buf/sw-sync: don't enable IRQ from sync_print_obj() | expand

Commit Message

Tetsuo Handa May 5, 2024, 2:08 p.m. UTC
Since commit a6aa8fca4d79 ("dma-buf/sw-sync: Reduce irqsave/irqrestore from
known context") by error replaced spin_unlock_irqrestore() with
spin_unlock_irq() for both sync_debugfs_show() and sync_print_obj() despite
sync_print_obj() is called from sync_debugfs_show(), lockdep complains
inconsistent lock state warning.

Use plain spin_{lock,unlock}() for sync_print_obj(), for
sync_debugfs_show() is already using spin_{lock,unlock}_irq().

Reported-by: syzbot <syzbot+a225ee3df7e7f9372dbe@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=a225ee3df7e7f9372dbe
Fixes: a6aa8fca4d79 ("dma-buf/sw-sync: Reduce irqsave/irqrestore from known context")
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 drivers/dma-buf/sync_debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Christian König May 7, 2024, 1:09 p.m. UTC | #1
Am 05.05.24 um 16:08 schrieb Tetsuo Handa:
> Since commit a6aa8fca4d79 ("dma-buf/sw-sync: Reduce irqsave/irqrestore from
> known context") by error replaced spin_unlock_irqrestore() with
> spin_unlock_irq() for both sync_debugfs_show() and sync_print_obj() despite
> sync_print_obj() is called from sync_debugfs_show(), lockdep complains
> inconsistent lock state warning.
>
> Use plain spin_{lock,unlock}() for sync_print_obj(), for
> sync_debugfs_show() is already using spin_{lock,unlock}_irq().
>
> Reported-by: syzbot <syzbot+a225ee3df7e7f9372dbe@syzkaller.appspotmail.com>
> Closes: https://syzkaller.appspot.com/bug?extid=a225ee3df7e7f9372dbe
> Fixes: a6aa8fca4d79 ("dma-buf/sw-sync: Reduce irqsave/irqrestore from known context")
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/dma-buf/sync_debug.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma-buf/sync_debug.c b/drivers/dma-buf/sync_debug.c
> index 101394f16930..237bce21d1e7 100644
> --- a/drivers/dma-buf/sync_debug.c
> +++ b/drivers/dma-buf/sync_debug.c
> @@ -110,12 +110,12 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)
>   
>   	seq_printf(s, "%s: %d\n", obj->name, obj->value);
>   
> -	spin_lock_irq(&obj->lock);
> +	spin_lock(&obj->lock); /* Caller already disabled IRQ. */
>   	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(&obj->lock);
>   }
>   
>   static void sync_print_sync_file(struct seq_file *s,
Tetsuo Handa May 24, 2024, 1:26 p.m. UTC | #2
On 2024/05/07 22:09, Christian König wrote:
> Am 05.05.24 um 16:08 schrieb Tetsuo Handa:
>> Since commit a6aa8fca4d79 ("dma-buf/sw-sync: Reduce irqsave/irqrestore from
>> known context") by error replaced spin_unlock_irqrestore() with
>> spin_unlock_irq() for both sync_debugfs_show() and sync_print_obj() despite
>> sync_print_obj() is called from sync_debugfs_show(), lockdep complains
>> inconsistent lock state warning.
>>
>> Use plain spin_{lock,unlock}() for sync_print_obj(), for
>> sync_debugfs_show() is already using spin_{lock,unlock}_irq().
>>
>> Reported-by: syzbot <syzbot+a225ee3df7e7f9372dbe@syzkaller.appspotmail.com>
>> Closes: https://syzkaller.appspot.com/bug?extid=a225ee3df7e7f9372dbe
>> Fixes: a6aa8fca4d79 ("dma-buf/sw-sync: Reduce irqsave/irqrestore from known context")
>> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> 
> Reviewed-by: Christian König <christian.koenig@amd.com>

Thank you. Who can take this patch?

> 
>> ---
>>   drivers/dma-buf/sync_debug.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/dma-buf/sync_debug.c b/drivers/dma-buf/sync_debug.c
>> index 101394f16930..237bce21d1e7 100644
>> --- a/drivers/dma-buf/sync_debug.c
>> +++ b/drivers/dma-buf/sync_debug.c
>> @@ -110,12 +110,12 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)
>>         seq_printf(s, "%s: %d\n", obj->name, obj->value);
>>   -    spin_lock_irq(&obj->lock);
>> +    spin_lock(&obj->lock); /* Caller already disabled IRQ. */
>>       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(&obj->lock);
>>   }
>>     static void sync_print_sync_file(struct seq_file *s,
>
Christian König May 27, 2024, 7:02 a.m. UTC | #3
Am 24.05.24 um 15:26 schrieb Tetsuo Handa:
> On 2024/05/07 22:09, Christian König wrote:
>> Am 05.05.24 um 16:08 schrieb Tetsuo Handa:
>>> Since commit a6aa8fca4d79 ("dma-buf/sw-sync: Reduce irqsave/irqrestore from
>>> known context") by error replaced spin_unlock_irqrestore() with
>>> spin_unlock_irq() for both sync_debugfs_show() and sync_print_obj() despite
>>> sync_print_obj() is called from sync_debugfs_show(), lockdep complains
>>> inconsistent lock state warning.
>>>
>>> Use plain spin_{lock,unlock}() for sync_print_obj(), for
>>> sync_debugfs_show() is already using spin_{lock,unlock}_irq().
>>>
>>> Reported-by: syzbot <syzbot+a225ee3df7e7f9372dbe@syzkaller.appspotmail.com>
>>> Closes: https://syzkaller.appspot.com/bug?extid=a225ee3df7e7f9372dbe
>>> Fixes: a6aa8fca4d79 ("dma-buf/sw-sync: Reduce irqsave/irqrestore from known context")
>>> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
>> Reviewed-by: Christian König <christian.koenig@amd.com>
> Thank you. Who can take this patch?

I pushed it to drm-misc-fixes.

Thanks,
Christian.

>
>>> ---
>>>    drivers/dma-buf/sync_debug.c | 4 ++--
>>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/dma-buf/sync_debug.c b/drivers/dma-buf/sync_debug.c
>>> index 101394f16930..237bce21d1e7 100644
>>> --- a/drivers/dma-buf/sync_debug.c
>>> +++ b/drivers/dma-buf/sync_debug.c
>>> @@ -110,12 +110,12 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)
>>>          seq_printf(s, "%s: %d\n", obj->name, obj->value);
>>>    -    spin_lock_irq(&obj->lock);
>>> +    spin_lock(&obj->lock); /* Caller already disabled IRQ. */
>>>        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(&obj->lock);
>>>    }
>>>      static void sync_print_sync_file(struct seq_file *s,
diff mbox series

Patch

diff --git a/drivers/dma-buf/sync_debug.c b/drivers/dma-buf/sync_debug.c
index 101394f16930..237bce21d1e7 100644
--- a/drivers/dma-buf/sync_debug.c
+++ b/drivers/dma-buf/sync_debug.c
@@ -110,12 +110,12 @@  static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)
 
 	seq_printf(s, "%s: %d\n", obj->name, obj->value);
 
-	spin_lock_irq(&obj->lock);
+	spin_lock(&obj->lock); /* Caller already disabled IRQ. */
 	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(&obj->lock);
 }
 
 static void sync_print_sync_file(struct seq_file *s,