From: Wolfram Sang <wsa@the-dreams.de>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-i2c@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com>
Subject: Re: [PATCH 1/2] i2c: rcar: fix concurrency issue related to ICDMAER
Date: Sat, 9 Mar 2019 11:10:30 +0100 [thread overview]
Message-ID: <20190309101030.GF1340@kunai> (raw)
In-Reply-To: <20190303150314.6528-2-wsa+renesas@sang-engineering.com>
[-- Attachment #1: Type: text/plain, Size: 1790 bytes --]
On Sun, Mar 03, 2019 at 04:03:13PM +0100, Wolfram Sang wrote:
> From: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com>
>
> This patch fixes the problem that an interrupt may set up a new I2C
> message and the DMA callback overwrites this setup.
>
> By disabling the DMA Enable Register(ICDMAER), rcar_i2c_dma_unmap()
> enables interrupts for register settings (such as Master Control
> Register(ICMCR)) and advances the I2C transfer sequence.
>
> If an interrupt occurs immediately after ICDMAER is disabled, the
> callback handler later continues and overwrites the previous settings
> from the interrupt. So, disable ICDMAER at the end of the callback to
> ensure other interrupts are masked until then.
>
> Note that this driver needs to work lock-free because there are IP cores
> with a HW race condition which prevent us from using a spinlock in the
> interrupt handler.
>
> Reproduction test:
> 1. Add udelay(1) after disabling ICDMAER. (It is expected to
> generate an interrupt of rcar_i2c_irq())
>
> void rcar_i2c_dma_unmap(struct rcar_i2c_priv *priv)
> {
> ...
> rcar_i2c_write(priv, ICDMAER, 0);
> udelay(1); <-- Add this line
> ...
> priv->dma_direction = DMA_NONE;
> }
>
> 2. Execute DMA transfer.
> Performs DMA transfer of read or write. In the sample, write was used.
>
> $ i2cset -y -f 4 0x6a 0x01 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 i
>
> 3. A log message of BUG_ON() will be displayed.
>
> Signed-off-by: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Updated the test case, added a note about all this to the comment and
applied to for-current, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-03-09 10:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-03 15:03 [PATCH 0/2] i2c: rcar: improve concurrency Wolfram Sang
2019-03-03 15:03 ` [PATCH 1/2] i2c: rcar: fix concurrency issue related to ICDMAER Wolfram Sang
2019-03-04 22:27 ` Wolfram Sang
2019-03-06 12:59 ` Simon Horman
2019-03-09 10:10 ` Wolfram Sang [this message]
2019-03-03 15:03 ` [PATCH 2/2] i2c: rcar: explain the lockless design Wolfram Sang
2019-03-06 12:59 ` Simon Horman
2019-03-09 10:11 ` 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=20190309101030.GF1340@kunai \
--to=wsa@the-dreams.de \
--cc=hiromitsu.yamasaki.ym@renesas.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=wsa+renesas@sang-engineering.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