From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Wolfram Sang <wsa@the-dreams.de>, linux-i2c@vger.kernel.org
Cc: linux-sh@vger.kernel.org, Magnus Damm <magnus.damm@gmail.com>,
Simon Horman <horms@verge.net.au>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Subject: Re: [PATCH 08/11] i2c: rcar: remove spinlock
Date: Sat, 23 Aug 2014 03:54:34 +0400 [thread overview]
Message-ID: <53F7D83A.5030903@cogentembedded.com> (raw)
In-Reply-To: <1401263086-13720-9-git-send-email-wsa@the-dreams.de>
Hello.
On 05/28/2014 11:44 AM, Wolfram Sang wrote:
> From: Wolfram Sang <wsa+renesas@sang-engineering.com>
> The i2c core has per-adapter locks, so no need to protect again.
The core's lock is unable to protect from the IRQs. So I'm proposing to
revert this patch. It's a pity I hadn't noticed this issue when the patch was
posted.
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> drivers/i2c/busses/i2c-rcar.c | 22 ----------------------
> 1 file changed, 22 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
> index e82d64b5acef..4b088e67f2fd 100644
> --- a/drivers/i2c/busses/i2c-rcar.c
> +++ b/drivers/i2c/busses/i2c-rcar.c
[...]
> @@ -110,7 +109,6 @@ struct rcar_i2c_priv {
> struct i2c_msg *msg;
> struct clk *clk;
>
> - spinlock_t lock;
Needed a comment (that it protects the I2C registers).
[...]
> @@ -462,21 +454,14 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
> {
> struct rcar_i2c_priv *priv = i2c_get_adapdata(adap);
> struct device *dev = rcar_i2c_priv_to_dev(priv);
> - unsigned long flags;
> int i, ret, timeout;
>
> pm_runtime_get_sync(dev);
>
> - /*-------------- spin lock -----------------*/
> - spin_lock_irqsave(&priv->lock, flags);
> -
> rcar_i2c_init(priv);
> /* start clock */
> rcar_i2c_write(priv, ICCCR, priv->icccr);
>
> - spin_unlock_irqrestore(&priv->lock, flags);
> - /*-------------- spin unlock -----------------*/
> -
I'm afraid this unlock is misplaced, the code continues to access the
registers.
> ret = rcar_i2c_bus_barrier(priv);
Should probably unlock here instead?
> if (ret < 0)
> goto out;
WBR, Sergei
WARNING: multiple messages have this Message-ID (diff)
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Wolfram Sang <wsa@the-dreams.de>, linux-i2c@vger.kernel.org
Cc: linux-sh@vger.kernel.org, Magnus Damm <magnus.damm@gmail.com>,
Simon Horman <horms@verge.net.au>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Subject: Re: [PATCH 08/11] i2c: rcar: remove spinlock
Date: Fri, 22 Aug 2014 23:54:34 +0000 [thread overview]
Message-ID: <53F7D83A.5030903@cogentembedded.com> (raw)
In-Reply-To: <1401263086-13720-9-git-send-email-wsa@the-dreams.de>
Hello.
On 05/28/2014 11:44 AM, Wolfram Sang wrote:
> From: Wolfram Sang <wsa+renesas@sang-engineering.com>
> The i2c core has per-adapter locks, so no need to protect again.
The core's lock is unable to protect from the IRQs. So I'm proposing to
revert this patch. It's a pity I hadn't noticed this issue when the patch was
posted.
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> drivers/i2c/busses/i2c-rcar.c | 22 ----------------------
> 1 file changed, 22 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
> index e82d64b5acef..4b088e67f2fd 100644
> --- a/drivers/i2c/busses/i2c-rcar.c
> +++ b/drivers/i2c/busses/i2c-rcar.c
[...]
> @@ -110,7 +109,6 @@ struct rcar_i2c_priv {
> struct i2c_msg *msg;
> struct clk *clk;
>
> - spinlock_t lock;
Needed a comment (that it protects the I2C registers).
[...]
> @@ -462,21 +454,14 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
> {
> struct rcar_i2c_priv *priv = i2c_get_adapdata(adap);
> struct device *dev = rcar_i2c_priv_to_dev(priv);
> - unsigned long flags;
> int i, ret, timeout;
>
> pm_runtime_get_sync(dev);
>
> - /*-------------- spin lock -----------------*/
> - spin_lock_irqsave(&priv->lock, flags);
> -
> rcar_i2c_init(priv);
> /* start clock */
> rcar_i2c_write(priv, ICCCR, priv->icccr);
>
> - spin_unlock_irqrestore(&priv->lock, flags);
> - /*-------------- spin unlock -----------------*/
> -
I'm afraid this unlock is misplaced, the code continues to access the
registers.
> ret = rcar_i2c_bus_barrier(priv);
Should probably unlock here instead?
> if (ret < 0)
> goto out;
WBR, Sergei
next prev parent reply other threads:[~2014-08-22 23:54 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-28 7:44 [PATCH 00/11] i2c: rcar: cleanup series Wolfram Sang
2014-05-28 7:44 ` Wolfram Sang
2014-05-28 7:44 ` [PATCH 01/11] i2c: rcar: not everything needs to be a function Wolfram Sang
2014-05-28 7:44 ` Wolfram Sang
2014-05-28 7:44 ` [PATCH 02/11] i2c: rcar: no need to store irq number Wolfram Sang
2014-05-28 7:44 ` Wolfram Sang
2014-05-28 7:44 ` [PATCH 04/11] i2c: rcar: refactor irq state machine Wolfram Sang
2014-05-28 7:44 ` Wolfram Sang
2014-05-28 7:44 ` [PATCH 05/11] i2c: rcar: check bus free before first message Wolfram Sang
2014-05-28 7:44 ` Wolfram Sang
2014-05-28 7:44 ` [PATCH 07/11] i2c: rcar: refactor status bit handling Wolfram Sang
2014-05-28 7:44 ` Wolfram Sang
2014-05-28 7:44 ` [PATCH 08/11] i2c: rcar: remove spinlock Wolfram Sang
2014-05-28 7:44 ` Wolfram Sang
2014-08-22 23:54 ` Sergei Shtylyov [this message]
2014-08-22 23:54 ` Sergei Shtylyov
2014-08-23 3:08 ` Wolfram Sang
2014-08-23 3:08 ` Wolfram Sang
2014-09-02 22:10 ` Sergei Shtylyov
2014-09-02 22:10 ` Sergei Shtylyov
[not found] ` <5406404A.7090509-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2014-09-02 22:18 ` Wolfram Sang
2014-09-02 22:18 ` Wolfram Sang
2014-05-28 7:44 ` [PATCH 09/11] i2c: rcar: reuse status bits as enable bits Wolfram Sang
2014-05-28 7:44 ` Wolfram Sang
2014-05-28 7:44 ` [PATCH 10/11] i2c: rcar: janitorial cleanup after refactoring Wolfram Sang
2014-05-28 7:44 ` Wolfram Sang
2014-05-28 7:44 ` [PATCH 11/11] i2c: rcar: update copyright and license information Wolfram Sang
2014-05-28 7:44 ` Wolfram Sang
2014-05-28 8:11 ` [PATCH 00/11] i2c: rcar: cleanup series Kuninori Morimoto
2014-05-28 8:11 ` Kuninori Morimoto
[not found] ` <1401263086-13720-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2014-05-28 7:44 ` [PATCH 03/11] i2c: rcar: refactor bus state machine Wolfram Sang
2014-05-28 7:44 ` Wolfram Sang
2014-05-28 7:44 ` [PATCH 06/11] i2c: rcar: refactor setting up msg Wolfram Sang
2014-05-28 7:44 ` Wolfram Sang
2014-05-28 8:26 ` [PATCH 00/11] i2c: rcar: cleanup series Geert Uytterhoeven
2014-05-28 8:26 ` Geert Uytterhoeven
2014-06-01 20:24 ` Wolfram Sang
2014-06-01 20:24 ` Wolfram Sang
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=53F7D83A.5030903@cogentembedded.com \
--to=sergei.shtylyov@cogentembedded.com \
--cc=geert@linux-m68k.org \
--cc=horms@verge.net.au \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=wsa@the-dreams.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.