Part Number: 66AK2H12
Tool/software: Linux
The functions keystone_rio_maint_read and keystone_rio_maint_write
make two calls that could potentially sleep: kzalloc
tbuf = kzalloc(align_len, GFP_NOFS | GFP_DMA);
if (!tbuf)
return -ENOMEM;
and mutex_lock
mutex_lock(&krio_priv->lsu_lock_maint);
(the latter in the inline function keystone_rio_maint_request).
This means keystone_rio_maint_read and keystone_rio_maint_write must
not be called from interrupt context, nor when holding spinlocks.
The function rio_mport_read_config_32 (rio-access.c) locks
rio_config_lock, then calls keystone_rio_maint_read through the pointer
mport->ops->cread. This is not safe and could deadlock the kernel.
The RapidIO enumeration mechanism ends up calling
rio_mport_read_config_32, so we can't enumerate without generating
BUGs.
[ 29.486937] RIO: enumerate master port 0, RIO0 mport
[ 29.493231] BUG: sleeping function called from invalid context at /home/MITLL/CH22073/ojm/keystoneii/processor-sdk-linux/kernel/locking/mutex.c:620
[ 29.506499] in_atomic(): 1, irqs_disabled(): 128, pid: 612, name: modprobe
[ 29.513398] 2 locks held by modprobe/612:
[ 29.517417] #0: (rio_mport_list_lock){+.+.+.}, at: [<c0352b28>] rio_init_mports+0x34/0x2a4
[ 29.525923] #1: (rio_config_lock){......}, at: [<c0354944>] rio_mport_read_config_32+0x40/0xa0
[ 29.534770] irq event stamp: 18684
[ 29.538179] hardirqs last enabled at (18683): [<c06ec7ac>] _raw_spin_unlock_irqrestore+0x6c/0x74
[ 29.547093] hardirqs last disabled at (18684): [<c06ec5cc>] _raw_spin_lock_irqsave+0x1c/0x58
[ 29.555569] softirqs last enabled at (16960): [<c002a924>] __do_softirq+0x234/0x2b0
[ 29.563346] softirqs last disabled at (16937): [<c002ad00>] irq_exit+0xd8/0x114
[ 29.570687] Preemption disabled at:[< (null)>] (null)
[ 29.576019]
[ 29.577513] CPU: 0 PID: 612 Comm: modprobe Tainted: G W 4.4.32-W1CMC-g1c11a44-dirty #53
[ 29.586679] Hardware name: Keystone
[ 29.590183] [<c00180c8>] (unwind_backtrace) from [<c0013d18>] (show_stack+0x10/0x14)
[ 29.597957] [<c0013d18>] (show_stack) from [<c02e9888>] (dump_stack+0x98/0xc4)
[ 29.605208] [<c02e9888>] (dump_stack) from [<c06e7f9c>] (mutex_lock_nested+0x30/0x4b4)
[ 29.613157] [<c06e7f9c>] (mutex_lock_nested) from [<c035b3f8>] (keystone_rio_maint_read+0x12c/0x400)
[ 29.622326] [<c035b3f8>] (keystone_rio_maint_read) from [<c035b700>] (keystone_rio_config_read+0x34/0x3c)
[ 29.631931] [<c035b700>] (keystone_rio_config_read) from [<c0354978>] (rio_mport_read_config_32+0x74/0xa0)
[ 29.641623] [<c0354978>] (rio_mport_read_config_32) from [<c03526f8>] (rio_mport_chk_dev_access+0x44/0x74)
[ 29.651322] [<c03526f8>] (rio_mport_chk_dev_access) from [<bf21ab9c>] (rio_enum_peer+0x34/0x76c [rio_scan])
[ 29.661111] [<bf21ab9c>] (rio_enum_peer [rio_scan]) from [<bf21b524>] (rio_enum_mport+0x134/0x2b8 [rio_scan])
[ 29.671071] [<bf21b524>] (rio_enum_mport [rio_scan]) from [<c0352b90>] (rio_init_mports+0x9c/0x2a4)
[ 29.680157] [<c0352b90>] (rio_init_mports) from [<bf21e034>] (rio_basic_attach+0x34/0x40 [rio_scan])
[ 29.689332] [<bf21e034>] (rio_basic_attach [rio_scan]) from [<c0009840>] (do_one_initcall+0xbc/0x204)
[ 29.698590] [<c0009840>] (do_one_initcall) from [<c00dbe5c>] (do_init_module+0x60/0x3a4)
[ 29.706713] [<c00dbe5c>] (do_init_module) from [<c00affc4>] (load_module+0x1dc8/0x2370)
[ 29.714748] [<c00affc4>] (load_module) from [<c00b078c>] (SyS_finit_module+0x8c/0xc8)
[ 29.722609] [<c00b078c>] (SyS_finit_module) from [<c0010380>] (ret_fast_syscall+0x0/0x1c)