lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Fri, 23 Jan 2015 09:58:16 +0100 From: Krzysztof Kozlowski <k.kozlowski@...sung.com> To: Paul Osmialowski <p.osmialowsk@...sung.com> Cc: Kukjin Kim <kgene@...nel.org>, Wolfram Sang <wsa@...-dreams.de>, Mark Brown <broonie@...nel.org>, Tomasz Figa <tomasz.figa@...il.com>, Peter De Schrijver <pdeschrijver@...dia.com>, linux-samsung-soc@...r.kernel.org, linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org, Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com> Subject: Re: [PATCH] i2c: s3c2410: fix ABBA deadlock by keeping clock prepared 2015-01-19 17:03 GMT+01:00 Paul Osmialowski <p.osmialowsk@...sung.com>: > This patch solves deadlock between clock prepare mutex and regmap mutex reported > by Tomasz Figa in [1] by implementing solution from [2]: "always leave the clock > of the i2c controller in a prepared state". > > [1] https://lkml.org/lkml/2014/7/2/171 > [2] https://lkml.org/lkml/2014/7/2/207 > > On each i2c transfer handled by s3c24xx_i2c_xfer(), clk_prepare_enable() was > called, which calls clk_prepare() then clk_enable(). clk_prepare() takes > prepare_lock mutex before proceeding. Note that i2c transfer functions are > invoked from many places in kernel, typically with some other additional lock > held. > > It may happen that function on CPU1 (e.g. regmap_update_bits()) has taken a > mutex (i.e. regmap lock mutex) then it attempts i2c communication in order to > proceed (so it needs to obtain clock related prepare_lock mutex during transfer > preparation stage due to clk_prepare() call). At the same time other task on > CPU0 wants to operate on clock (e.g. to (un)prepare clock for some other reason) > so it has taken prepare_lock mutex. > > CPU0: CPU1: > clk_disable_unused() regulator_disable() > clk_prepare_lock() map->lock(map->lock_arg) > regmap_read() s3c24xx_i2c_xfer() > map->lock(map->lock_arg) clk_prepare_lock() > > Implemented solution from [2] leaves i2c clock prepared. Preparation is done in > s3c24xx_i2c_probe() function. Without this patch, it is immediately unprepared > by clk_disable_unprepare() call. I've replaced this call with clk_disable() and > I've added clk_unprepare() call in s3c24xx_i2c_remove(). > > The s3c24xx_i2c_xfer() function now uses clk_enable() instead of > clk_prepare_enable() (and clk_disable() instead of clk_unprepare_disable()). > > Signed-off-by: Paul Osmialowski <p.osmialowsk@...sung.com> > --- > drivers/i2c/busses/i2c-s3c2410.c | 23 +++++++++++++++++------ > 1 file changed, 17 insertions(+), 6 deletions(-) Looks good to me. Reviewed-by: Krzysztof Kozlowski <k.kozlowski@...sung.com> Best regards, Krzysztof -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists