[bug report] habanalabs: add debugfs support

Oded Gabbay oded.gabbay at gmail.com
Thu Jan 19 12:49:57 UTC 2023


On Tue, Jan 17, 2023 at 4:05 PM Dan Carpenter <error27 at gmail.com> wrote:
>
> Hello Oded Gabbay,
>
> The patch c216477363a3: "habanalabs: add debugfs support" from Feb
> 16, 2019, leads to the following Smatch static checker warning:
>
>         drivers/accel/habanalabs/common/debugfs.c:272 vm_show()
>         warn: sleeping in atomic context
>
> drivers/accel/habanalabs/common/debugfs.c
>     241 static int vm_show(struct seq_file *s, void *data)
>     242 {
>     243         struct hl_debugfs_entry *entry = s->private;
>     244         struct hl_dbg_device_entry *dev_entry = entry->dev_entry;
>     245         struct hl_vm_hw_block_list_node *lnode;
>     246         struct hl_ctx *ctx;
>     247         struct hl_vm *vm;
>     248         struct hl_vm_hash_node *hnode;
>     249         struct hl_userptr *userptr;
>     250         struct hl_vm_phys_pg_pack *phys_pg_pack = NULL;
>     251         struct hl_va_range *va_range;
>     252         struct hl_vm_va_block *va_block;
>     253         enum vm_type *vm_type;
>     254         bool once = true;
>     255         u64 j;
>     256         int i;
>     257
>     258         if (!dev_entry->hdev->mmu_enable)
>     259                 return 0;
>     260
>     261         spin_lock(&dev_entry->ctx_mem_hash_spinlock);
>                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> This is holding a spinlock.
>
>     262
>     263         list_for_each_entry(ctx, &dev_entry->ctx_mem_hash_list, debugfs_list) {
>     264                 once = false;
>     265                 seq_puts(s, "\n\n----------------------------------------------------");
>     266                 seq_puts(s, "\n----------------------------------------------------\n\n");
>     267                 seq_printf(s, "ctx asid: %u\n", ctx->asid);
>     268
>     269                 seq_puts(s, "\nmappings:\n\n");
>     270                 seq_puts(s, "    virtual address        size          handle\n");
>     271                 seq_puts(s, "----------------------------------------------------\n");
> --> 272                 mutex_lock(&ctx->mem_hash_lock);
>                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> so it can't take a mutex or it leads to a sleeping in atomic bug.  These
> can be detected at runtime by enabling CONFIG_DEBUG_ATOMIC_SLEEP.
>
> regards,
> dan carpenter

Thanks Dan,
We will fix that.
Oded


More information about the dri-devel mailing list