ucb-bar/nvdla-workload

Sleeping Function From Invalid Context

Open

#2 opened on May 29, 2020

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Shell (5 forks)auto 404
buggood first issue

Repository metrics

Stars
 (5 stars)
PR merge metrics
 (PR metrics pending)

Description

Related Issue: https://github.com/ucb-bar/chipyard/issues/573

With the latest 5.7rc3 Linux bump, a bug was unmasked leading to the following warning given:

[    2.560709] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:255                                                                                                                                                                          
[    2.560972] in_atomic(): 1, irqs_disabled(): 1, pid: 240, name: nvdla_runtime                                                                                                                                                                                        
[    2.561196] CPU: 2 PID: 240 Comm: nvdla_runtime Tainted: G        W  O      5.3.0-00002-g6a95b016aba5-dirty #214                                                                                                                                                  
[    2.561512] Call Trace:                                                                                                                                                                                                                                             
[    2.561591] [<ffffffe00017c0fa>] walk_stackframe+0x0/0xa6                                                                                                                                                                                                            
[    2.561758] [<ffffffe00017c2e2>] show_stack+0x2a/0x34                                                                                                                                                                                                          
[    2.561915] [<ffffffe000783112>] dump_stack+0x66/0x82                                                                                                                                                                                                           
[    2.562074] [<ffffffe00019ca32>] ___might_sleep+0xbe/0xce                                                                                                                                                                                                         
[    2.562242] [<ffffffe00019ca7a>] __might_sleep+0x38/0x62                                                                                                                                                                                                          
[    2.562408] [<ffffffe0007983ec>] mutex_lock+0x22/0x4e                                                                                                                                                                                                            
[    2.562566] [<ffffffe00057fd82>] dma_buf_vmap+0x26/0x9e                                                                                                                                                                                                            
[    2.562855] [<ffffffd00400c74e>] dla_data_write+0x94/0x12a [opendla]                                                                                                                                                                                                  
[    2.563018] [<ffffffd00400bafc>] dla_put_op_desc+0x108/0x138 [opendla]                                                                                                                                                                                                
[    2.563218] [<ffffffd004007f2e>] dla_op_completion+0x1d0/0x2ea [opendla]                                                                                                                                                                                             
[    2.563427] [<ffffffd004008222>] dla_process_events+0x1da/0x218 [opendla]                                                                                                                                                                                            
[    2.563638] [<ffffffd00400c9d8>] nvdla_task_submit+0xca/0x14a [opendla]                                                                                                                                                                                               
[    2.563845] [<ffffffd00400ce68>] nvdla_submit+0x98/0xae [opendla]                                                                                                                                                                                                    
[    2.563948] [<ffffffe000458212>] drm_ioctl_kernel+0x74/0xa8                                                                                                                                                                                                           
[    2.564121] [<ffffffe0004583d0>] drm_ioctl+0x18a/0x290                                                                                                                                                                                                                
[    2.564281] [<ffffffe00027ae1a>] do_vfs_ioctl+0x3be/0x5f2                                                                                                                                                                                                             
[    2.564449] [<ffffffe00027b082>] ksys_ioctl+0x34/0x5a                                                                                                                                                                                                                 
[    2.564607] [<ffffffe00027b0b8>] sys_ioctl+0x10/0x18                                                                                                                                                                                                                 
[    2.564762] [<ffffffe00017ae66>] ret_from_syscall+0x0/0xe

This seems to be a problem with the KMD driver code and not with Chipyard's integration. Specifically, the dma_buf_vmap call is done within a critical section (which is unsafe: https://github.com/ucb-bar/chipyard/issues/573#issuecomment-635113793).

You can mask the warning by setting the following CONFIG_* flags to n in the nvdla-base/nvdla-kfrag file.

CONFIG_DEBUG_RT_MUTEXES=n
CONFIG_DEBUG_SPINLOCK=n
CONFIG_DEBUG_MUTEXES=n
CONFIG_DEBUG_RWSEMS=n
CONFIG_DEBUG_ATOMIC_SLEEP=n

Contributor guide