From a9e5f5eefd6b57f9fc6ac57a4bccc2be71aae4c8 Mon Sep 17 00:00:00 2001 From: Shuai Li Date: Tue, 5 Nov 2019 14:47:37 +0800 Subject: [PATCH] audio: fix might_sleep warning at bootup [1/1] PD#SWPL-16123 Problem: might_sleep() is triggered by regmap_read(). [ 3.106894@0] Workqueue: events tl1_acodec_release_fast_mode_work_func [ 3.106903@0] [bc059af4+ 16][] show_stack+0x20/0x24 [ 3.106910@0] [bc059b1c+ 40][] dump_stack+0xb8/0xf4 [ 3.106917@0] [bc059b44+ 40][] ___might_sleep+0x1c8/0x208 [ 3.106922@0] [bc059b6c+ 40][] __might_sleep+0x74/0xac [ 3.106928@0] [bc059bb4+ 72][] kmem_cache_alloc_trace+0x12c/0x2c0 [ 3.106935@0] [bc059bfc+ 72][] regcache_rbtree_write+0x2dc/0x4f0 [ 3.106941@0] [bc059c1c+ 32][] regcache_write+0x64/0x6c [ 3.106945@0] [bc059c44+ 40][] _regmap_write+0x144/0x16c [ 3.106948@0] [bc059c64+ 32][] regmap_write+0x4c/0x6c [ 3.106953@0] [bc059c74+ 16][] snd_soc_component_write+0x28/0x48 [ 3.106958@0] [bc059c84+ 16][] snd_soc_write+0x1c/0x20 [ 3.106962@0] [bc059c9c+ 24][] tl1_acodec_start_up+0x24/0x44 [ 3.106967@0] [bc059cbc+ 32][] tl1_acodec_release_fast_mode_work_func+0x54/0xe4 [ 3.106973@0] [bc059cfc+ 64][] process_one_work+0x200/0x624 [ 3.106977@0] [bc059d3c+ 64][] worker_thread+0x58/0x5c4 [ 3.106982@0] [bc059d94+ 88][] kthread+0x128/0x144 [ 3.106987@0] [00000000+ 0][] ret_from_fork+0x14/0x38 Solution: This is a mmio regmap constrain using spinlock_irq to protect the critical read and write. But if the default reg cache is not allocated, the read routine will malloc() buffer which is non-atomic. That is the root cause of this warning. So we add num_reg_defaults_raw to tell regmap to malloc the buffer at initializing stage. Verify: TL1. Change-Id: I42f87fa89bbe99762ada36337b5ed6565b06b891 Signed-off-by: Shuai Li --- sound/soc/codecs/amlogic/aml_codec_tl1_acodec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/amlogic/aml_codec_tl1_acodec.c b/sound/soc/codecs/amlogic/aml_codec_tl1_acodec.c index 604c62f9abf6..dc5bd8bd9419 100644 --- a/sound/soc/codecs/amlogic/aml_codec_tl1_acodec.c +++ b/sound/soc/codecs/amlogic/aml_codec_tl1_acodec.c @@ -699,6 +699,7 @@ static const struct regmap_config tl1_acodec_regmap_config = { .reg_stride = 4, .val_bits = 32, .max_register = 0x1c, + .num_reg_defaults_raw = ARRAY_SIZE(tl1_acodec_init_list), .cache_type = REGCACHE_RBTREE, };