linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: Paul Osmialowski <p.osmialowsk@samsung.com>
Cc: Kukjin Kim <kgene@kernel.org>, Mark Brown <broonie@kernel.org>,
	Tomasz Figa <tomasz.figa@gmail.com>,
	Peter De Schrijver <pdeschrijver@nvidia.com>,
	linux-samsung-soc@vger.kernel.org, linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Subject: Re: [PATCH] i2c: s3c2410: fix ABBA deadlock by keeping clock prepared
Date: Fri, 23 Jan 2015 15:52:47 +0100	[thread overview]
Message-ID: <20150123145247.GD9592@katana> (raw)
In-Reply-To: <1421683413-27075-1-git-send-email-p.osmialowsk@samsung.com>

[-- Attachment #1: Type: text/plain, Size: 1976 bytes --]

On Mon, Jan 19, 2015 at 05:03:33PM +0100, Paul Osmialowski wrote:
> 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@samsung.com>

Applied to for-current, thanks!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

      parent reply	other threads:[~2015-01-23 14:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-19 16:03 [PATCH] i2c: s3c2410: fix ABBA deadlock by keeping clock prepared Paul Osmialowski
2015-01-23  8:58 ` Krzysztof Kozlowski
2015-01-23 14:52 ` Wolfram Sang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150123145247.GD9592@katana \
    --to=wsa@the-dreams.de \
    --cc=b.zolnierkie@samsung.com \
    --cc=broonie@kernel.org \
    --cc=kgene@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=p.osmialowsk@samsung.com \
    --cc=pdeschrijver@nvidia.com \
    --cc=tomasz.figa@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).