• Nicolin Chen's avatar
    ASoC: fsl_asrc: Add reg_defaults for regmap to fix kernel dump · 86a570c5
    Nicolin Chen authored
    Kernel dump (WARN_ON) ocurred during system boot-up inside regmap_write():
    
    ------------[ cut here ]------------
    WARNING: CPU: 0 PID: 47 at kernel/locking/lockdep.c:2744 lockdep_trace_alloc+0xe8/0x108()
    DEBUG_LOCKS_WARN_ON(irqs_disabled_flags(flags))
    Modules linked in:
    CPU: 0 PID: 47 Comm: kworker/u2:2 Not tainted 3.18.0-rc1-10245-gb75d289-dirty #56
    Workqueue: deferwq deferred_probe_work_func
    Backtrace:
    [<80012294>] (dump_backtrace) from [<80012578>] (show_stack+0x18/0x1c)
     r6:8097c73c r5:8097c73c r4:00000000 r3:be33ba80
    [<80012560>] (show_stack) from [<806aac48>] (dump_stack+0x8c/0xa4)
    [<806aabbc>] (dump_stack) from [<8002a694>] (warn_slowpath_common+0x70/0x94)
     r6:80062838 r5:00000009 r4:bd827b30 r3:be33ba80
    [<8002a624>] (warn_slowpath_common) from [<8002a6f0>] (warn_slowpath_fmt+0x38/0x40)
     r8:00000004 r7:00000001 r6:000080d0 r5:60000193 r4:bd826010
    [<8002a6bc>] (warn_slowpath_fmt) from [<80062838>] (lockdep_trace_alloc+0xe8/0x108)
     r3:80831590 r2:8082e160
    [<80062750>] (lockdep_trace_alloc) from [<800ea5dc>] (kmem_cache_alloc+0x28/0x134)
     r5:000080d0 r4:be001f00
    [<800ea5b4>] (kmem_cache_alloc) from [<8038d72c>] (regcache_rbtree_write+0x15c/0x648)
     r10:00000000 r9:0000001c r8:00000004 r7:00000001 r6:00000000 r5:bd819a00
     r4:00000000 r3:811aea88
    [<8038d5d0>] (regcache_rbtree_write) from [<8038c4d8>] (regcache_write+0x5c/0x64)
     r10:be3f9f88 r9:00000000 r8:00000004 r7:00000001 r6:00000000 r5:00000001
     r4:bd819a00
    [<8038c47c>] (regcache_write) from [<8038b0dc>] (_regmap_raw_write+0x134/0x5f4)
     r6:be3f9f84 r5:00000001 r4:bd819a00 r3:00000001
    [<8038afa8>] (_regmap_raw_write) from [<8038b610>] (_regmap_bus_raw_write+0x74/0x94)
     r10:00000000 r9:00000001 r8:be3fb080 r7:bd819a00 r6:00000001 r5:00000000
     r4:bd819a00
    [<8038b59c>] (_regmap_bus_raw_write) from [<8038a8b4>] (_regmap_write+0x60/0x9c)
     r6:00000001 r5:00000000 r4:bd819a00 r3:8038b59c
    [<8038a854>] (_regmap_write) from [<8038ba24>] (regmap_write+0x48/0x68)
     r7:bd81ad80 r6:00000001 r5:00000000 r4:bd819a00
    [<8038b9dc>] (regmap_write) from [<80528f30>] (fsl_asrc_dai_probe+0x34/0x104)
     r6:bd888628 r5:be3fb080 r4:be3b4410 r3:be3b442c
    ------------[ dump end ]------------
    
    =============================================================================
    2741         /*
    2742          * Oi! Can't be having __GFP_FS allocations with IRQs disabled.
    2743          */
    2744         if (DEBUG_LOCKS_WARN_ON(irqs_disabled_flags(flags)))
    2745                 return;
    =============================================================================
    
    By looking at 2744 line, we can get that it's because regcache_rbtree_write()
    would call kmalloc() with GFP flag if it couldn't find an existing block to
    insert nodes while this kmalloc() call is inside a spin_lock_irq_save pair,
    i.e. IRQs disabled.
    
    Even though this may be a bug that should be fixed, I still try to send this
    patch as a quick fix (work around) since it does no harm to assign default
    values of every registers when using regcache.
    Signed-off-by: default avatarNicolin Chen <nicoleotsuka@gmail.com>
    Signed-off-by: default avatarMark Brown <broonie@kernel.org>
    86a570c5
fsl_asrc.c 27.7 KB