* [bug report] habanalabs: add debugfs support
@ 2023-01-17 14:05 Dan Carpenter
2023-01-19 12:49 ` Oded Gabbay
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-01-17 14:05 UTC (permalink / raw)
To: oded.gabbay; +Cc: dri-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] habanalabs: add debugfs support
2023-01-17 14:05 [bug report] habanalabs: add debugfs support Dan Carpenter
@ 2023-01-19 12:49 ` Oded Gabbay
0 siblings, 0 replies; 2+ messages in thread
From: Oded Gabbay @ 2023-01-19 12:49 UTC (permalink / raw)
To: Dan Carpenter; +Cc: dri-devel
On Tue, Jan 17, 2023 at 4:05 PM Dan Carpenter <error27@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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-19 12:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-17 14:05 [bug report] habanalabs: add debugfs support Dan Carpenter
2023-01-19 12:49 ` Oded Gabbay
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.