* Regmap commit 815806e3 from 4.8-rc6 introduces a deadlock @ 2016-09-22 8:32 Nikita Yushchenko 2016-09-22 9:02 ` [PATCH] regmap: fix deadlock on _regmap_raw_write() error path Nikita Yushchenko 2016-09-22 9:54 ` Regmap commit 815806e3 from 4.8-rc6 introduces a deadlock Mark Brown 0 siblings, 2 replies; 5+ messages in thread From: Nikita Yushchenko @ 2016-09-22 8:32 UTC (permalink / raw) To: Elaine Zhang, Mark Brown; +Cc: linux-kernel, Chris Healy Hi. Here is a trace: amixer D 8068ae98 0 197 183 0x00000000 Backtrace: [<8068ab7c>] (__schedule) from [<8068b1c4>] (schedule+0xb8/0xd0) [<8068b10c>] (schedule) from [<8068b61c>] (schedule_preempt_disabled+0x20/0x2c) [<8068b5fc>] (schedule_preempt_disabled) from [<8068cd18>] (__mutex_lock_slowpath+0xf8/0x180) [<8068cc20>] (__mutex_lock_slowpath) from [<8068cde0>] (mutex_lock+0x40/0x58) [<8068cda0>] (mutex_lock) from [<8047c440>] (regmap_lock_mutex+0x18/0x1c) [<8047c428>] (regmap_lock_mutex) from [<8047fedc>] (regcache_drop_region+0x44/0x144) [<8047fe98>] (regcache_drop_region) from [<8047f0a4>] (_regmap_raw_write+0x65c/0x7f0) [<8047ea48>] (_regmap_raw_write) from [<8047f2b8>] (_regmap_bus_raw_write+0x80/0x98) [<8047f238>] (_regmap_bus_raw_write) from [<8047dea4>] (_regmap_write+0x11c/0x16c) [<8047dd88>] (_regmap_write) from [<8047dfa4>] (_regmap_update_bits+0xb0/0xd4) [<8047def4>] (_regmap_update_bits) from [<8047f460>] (regmap_update_bits_base+0x60/0x84) [<8047f400>] (regmap_update_bits_base) from [<805acecc>] (snd_soc_component_update_bits+0x40/0x5c) [<805ace8c>] (snd_soc_component_update_bits) from [<805adec0>] (snd_soc_put_volsw+0x9c/0xf8) [<805ade24>] (snd_soc_put_volsw) from [<8058b070>] (snd_ctl_ioctl+0x75c/0xbe8) [<8058a914>] (snd_ctl_ioctl) from [<80209d04>] (vfs_ioctl+0x30/0x44) [<80209cd4>] (vfs_ioctl) from [<8020a5ec>] (do_vfs_ioctl+0x7b0/0x884) [<80209e3c>] (do_vfs_ioctl) from [<8020a704>] (SyS_ioctl+0x44/0x6c) [<8020a6c0>] (SyS_ioctl) from [<80107900>] (ret_fast_syscall+0x0/0x3c) Regmap lock is taken in regmap_update_bits_base() and then regcache_drop_region() added in commit 815806e3 tries to take it again. WBR, Nikita ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] regmap: fix deadlock on _regmap_raw_write() error path 2016-09-22 8:32 Regmap commit 815806e3 from 4.8-rc6 introduces a deadlock Nikita Yushchenko @ 2016-09-22 9:02 ` Nikita Yushchenko 2016-09-22 10:24 ` Applied "regmap: fix deadlock on _regmap_raw_write() error path" to the regmap tree Mark Brown 2016-09-22 9:54 ` Regmap commit 815806e3 from 4.8-rc6 introduces a deadlock Mark Brown 1 sibling, 1 reply; 5+ messages in thread From: Nikita Yushchenko @ 2016-09-22 9:02 UTC (permalink / raw) To: Mark Brown, Greg Kroah-Hartman, Kuninori Morimoto, Xiubo Li, Dan Carpenter, Jon Ringle, Chen-Yu Tsai, David S. Miller, linux-kernel, Chris Healy Cc: Nikita Yushchenko Commit 815806e39bf6 ("regmap: drop cache if the bus transfer error") added a call to regcache_drop_region() to error path in _regmap_raw_write(). However that path runs with regmap lock taken, and regcache_drop_region() tries to re-take it, causing deadlock: amixer D 8068ae98 0 197 183 0x00000000 Backtrace: [<8068ab7c>] (__schedule) from [<8068b1c4>] (schedule+0xb8/0xd0) [<8068b10c>] (schedule) from [<8068b61c>] (schedule_preempt_disabled+0x20/0x2c) [<8068b5fc>] (schedule_preempt_disabled) from [<8068cd18>] (__mutex_lock_slowpath+0xf8/0x180) [<8068cc20>] (__mutex_lock_slowpath) from [<8068cde0>] (mutex_lock+0x40/0x58) [<8068cda0>] (mutex_lock) from [<8047c440>] (regmap_lock_mutex+0x18/0x1c) [<8047c428>] (regmap_lock_mutex) from [<8047fedc>] (regcache_drop_region+0x44/0x144) [<8047fe98>] (regcache_drop_region) from [<8047f0a4>] (_regmap_raw_write+0x65c/0x7f0) [<8047ea48>] (_regmap_raw_write) from [<8047f2b8>] (_regmap_bus_raw_write+0x80/0x98) [<8047f238>] (_regmap_bus_raw_write) from [<8047dea4>] (_regmap_write+0x11c/0x16c) [<8047dd88>] (_regmap_write) from [<8047dfa4>] (_regmap_update_bits+0xb0/0xd4) [<8047def4>] (_regmap_update_bits) from [<8047f460>] (regmap_update_bits_base+0x60/0x84) [<8047f400>] (regmap_update_bits_base) from [<805acecc>] (snd_soc_component_update_bits+0x40/0x5c) [<805ace8c>] (snd_soc_component_update_bits) from [<805adec0>] (snd_soc_put_volsw+0x9c/0xf8) [<805ade24>] (snd_soc_put_volsw) from [<8058b070>] (snd_ctl_ioctl+0x75c/0xbe8) [<8058a914>] (snd_ctl_ioctl) from [<80209d04>] (vfs_ioctl+0x30/0x44) [<80209cd4>] (vfs_ioctl) from [<8020a5ec>] (do_vfs_ioctl+0x7b0/0x884) [<80209e3c>] (do_vfs_ioctl) from [<8020a704>] (SyS_ioctl+0x44/0x6c) [<8020a6c0>] (SyS_ioctl) from [<80107900>] (ret_fast_syscall+0x0/0x3c) Fix that by calling map->cache_ops->drop() directly. Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com> --- drivers/base/regmap/regmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 25d26bb..e964d06 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1475,7 +1475,11 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg, kfree(buf); } else if (ret != 0 && !map->cache_bypass && map->format.parse_val) { - regcache_drop_region(map, reg, reg + 1); + /* regcache_drop_region() takes lock that we already have, + * thus call map->cache_ops->drop() directly + */ + if (map->cache_ops && map->cache_ops->drop) + map->cache_ops->drop(map, reg, reg + 1); } trace_regmap_hw_write_done(map, reg, val_len / map->format.val_bytes); -- 2.1.4 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Applied "regmap: fix deadlock on _regmap_raw_write() error path" to the regmap tree 2016-09-22 9:02 ` [PATCH] regmap: fix deadlock on _regmap_raw_write() error path Nikita Yushchenko @ 2016-09-22 10:24 ` Mark Brown 0 siblings, 0 replies; 5+ messages in thread From: Mark Brown @ 2016-09-22 10:24 UTC (permalink / raw) To: Nikita Yushchenko Cc: Mark Brown, Mark Brown, Greg Kroah-Hartman, Kuninori Morimoto, Xiubo Li, Dan Carpenter, Jon Ringle, Chen-Yu Tsai, David S. Miller, linux-kernel, Chris Healy The patch regmap: fix deadlock on _regmap_raw_write() error path has been applied to the regmap tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From f0aa1ce6259eb65f53f969b3250c1d0aac84f30b Mon Sep 17 00:00:00 2001 From: Nikita Yushchenko <nikita.yoush@cogentembedded.com> Date: Thu, 22 Sep 2016 12:02:25 +0300 Subject: [PATCH] regmap: fix deadlock on _regmap_raw_write() error path Commit 815806e39bf6 ("regmap: drop cache if the bus transfer error") added a call to regcache_drop_region() to error path in _regmap_raw_write(). However that path runs with regmap lock taken, and regcache_drop_region() tries to re-take it, causing a deadlock. Fix that by calling map->cache_ops->drop() directly. Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com> Signed-off-by: Mark Brown <broonie@kernel.org> --- drivers/base/regmap/regmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 25d26bb18970..e964d068874d 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1475,7 +1475,11 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg, kfree(buf); } else if (ret != 0 && !map->cache_bypass && map->format.parse_val) { - regcache_drop_region(map, reg, reg + 1); + /* regcache_drop_region() takes lock that we already have, + * thus call map->cache_ops->drop() directly + */ + if (map->cache_ops && map->cache_ops->drop) + map->cache_ops->drop(map, reg, reg + 1); } trace_regmap_hw_write_done(map, reg, val_len / map->format.val_bytes); -- 2.8.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Regmap commit 815806e3 from 4.8-rc6 introduces a deadlock 2016-09-22 8:32 Regmap commit 815806e3 from 4.8-rc6 introduces a deadlock Nikita Yushchenko 2016-09-22 9:02 ` [PATCH] regmap: fix deadlock on _regmap_raw_write() error path Nikita Yushchenko @ 2016-09-22 9:54 ` Mark Brown 2016-09-22 9:58 ` Nikita Yushchenko 1 sibling, 1 reply; 5+ messages in thread From: Mark Brown @ 2016-09-22 9:54 UTC (permalink / raw) To: Nikita Yushchenko; +Cc: Elaine Zhang, linux-kernel, Chris Healy [-- Attachment #1: Type: text/plain, Size: 405 bytes --] On Thu, Sep 22, 2016 at 11:32:33AM +0300, Nikita Yushchenko wrote: > Hi. > > Here is a trace: Please don't send cover letters for single patches, if there is anything that needs saying put it in the changelog of the patch or after the --- if it's administrative stuff. This reduces mail volume and ensures that any important information is recorded in the changelog rather than being lost. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Regmap commit 815806e3 from 4.8-rc6 introduces a deadlock 2016-09-22 9:54 ` Regmap commit 815806e3 from 4.8-rc6 introduces a deadlock Mark Brown @ 2016-09-22 9:58 ` Nikita Yushchenko 0 siblings, 0 replies; 5+ messages in thread From: Nikita Yushchenko @ 2016-09-22 9:58 UTC (permalink / raw) To: Mark Brown; +Cc: Elaine Zhang, linux-kernel, Chris Healy >> Hi. >> >> Here is a trace: > > Please don't send cover letters for single patches, if there is anything > that needs saying put it in the changelog of the patch or after the --- > if it's administrative stuff. This reduces mail volume and ensures that > any important information is recorded in the changelog rather than being > lost. Ok. Actually I first wrote the bug report and only then decided to send fix as well :) Nikita ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-09-22 10:25 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-09-22 8:32 Regmap commit 815806e3 from 4.8-rc6 introduces a deadlock Nikita Yushchenko 2016-09-22 9:02 ` [PATCH] regmap: fix deadlock on _regmap_raw_write() error path Nikita Yushchenko 2016-09-22 10:24 ` Applied "regmap: fix deadlock on _regmap_raw_write() error path" to the regmap tree Mark Brown 2016-09-22 9:54 ` Regmap commit 815806e3 from 4.8-rc6 introduces a deadlock Mark Brown 2016-09-22 9:58 ` Nikita Yushchenko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®