All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: oded.gabbay@gmail.com
Cc: dri-devel@lists.freedesktop.org
Subject: [bug report] habanalabs: add debugfs support
Date: Tue, 17 Jan 2023 17:05:26 +0300	[thread overview]
Message-ID: <Y8arJvmo7dLsAYlX@kili> (raw)

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

             reply	other threads:[~2023-01-17 14:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17 14:05 Dan Carpenter [this message]
2023-01-19 12:49 ` [bug report] habanalabs: add debugfs support Oded Gabbay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y8arJvmo7dLsAYlX@kili \
    --to=error27@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=oded.gabbay@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.