linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Daniel Walker <dwalker@codeaurora.org>
Cc: linux-arm-msm@vger.kernel.org, davidb@codeaurora.org,
	bdegraaf@codeaurora.org,
	Sahitya Tummala <stummala@codeaurora.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] mmc: msm: fix dma usage not to use internal APIs
Date: Thu, 20 Jan 2011 13:12:39 +0000	[thread overview]
Message-ID: <20110120131239.GB23941@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20110120130246.GA23941@n2100.arm.linux.org.uk>

On Thu, Jan 20, 2011 at 01:02:46PM +0000, Russell King - ARM Linux wrote:
> Strongly ordered requires no additional maintainence to ensure that writes
> to it are immediately visible to hardware.  However, ARMv6 and later
> requires a data synchronization barrier to ensure that writes to 'normal
> non-cachable' memory are visible before writes to 'device' memory complete.
> 
> >From what I can see, the driver does use writel() as does the DMA driver
> in arch/arm/mach-msm/dma.c, so there should be no problem with ARMv6 CPUs.

BTW, it looks like the work-around was added at the time when writel() did
not have the necessary barriers:

commit 56a8b5b8ae81bd766e527a0e5274a087c3c1109d
Author: San Mehat <san@google.com>
Date:   Sat Nov 21 12:29:46 2009 -0800

    mmc: msm_sdcc: Reduce command timeouts and improve reliability.

+       n = dma_map_sg(mmc_dev(host->mmc), host->dma.sg,
+                       host->dma.num_ents, host->dma.dir);
+/* dsb inside dma_map_sg will write nc out to mem as well */
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    so we are talking about ARMv6 or later as previous versions did not
    have dsb.

vs

commit e936771a76a7b61ca55a5142a3de835c2e196871
Author: Catalin Marinas <catalin.marinas@arm.com>
Date:   Wed Jul 28 22:00:54 2010 +0100

    ARM: 6271/1: Introduce *_relaxed() I/O accessors

commit 79f64dbf68c8a9779a7e9a25e0a9f0217a25b57a
Author: Catalin Marinas <catalin.marinas@arm.com>
Date:   Wed Jul 28 22:01:55 2010 +0100

    ARM: 6273/1: Add barriers to the I/O accessors if ARM_DMA_MEM_BUFFERABLE

    When the coherent DMA buffers are mapped as Normal Non-cacheable
    (ARM_DMA_MEM_BUFFERABLE enabled), buffer accesses are no longer ordered
    with Device memory accesses causing failures in device drivers that do
    not use the mandatory memory barriers before starting a DMA transfer.
    LKML discussions led to the conclusion that such barriers have to be
    added to the I/O accessors:

    http://thread.gmane.org/gmane.linux.kernel/683509/focus=686153
    http://thread.gmane.org/gmane.linux.ide/46414
    http://thread.gmane.org/gmane.linux.kernel.cross-arch/5250

    This patch introduces a wmb() barrier to the write*() I/O accessors to
    handle the situations where Normal Non-cacheable writes are still in the
    processor (or L2 cache controller) write buffer before a DMA transfer
    command is issued. For the read*() accessors, a rmb() is introduced
    after the I/O to avoid speculative loads where the driver polls for a
    DMA transfer ready bit.

So the necessary barriers were found to be necessary way after MSM
discovered the problem.  It _is_ related to the ARMv6 weakly ordered
memory model, and it _was_ a bug in the ARM IO accessor implementation.

It would've been nice to have had the problem discussed at architecture
level so maybe the problem could've been found sooner and fixed earlier.

  reply	other threads:[~2011-01-20 13:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-18 23:03 [PATCH] mmc: msm: fix dma usage not to use internal APIs Daniel Walker
2011-01-18 23:05 ` Russell King - ARM Linux
2011-01-20 11:20 ` Daniel Walker
2011-01-20 13:02   ` Russell King - ARM Linux
2011-01-20 13:12     ` Russell King - ARM Linux [this message]
2011-01-20 15:08       ` Daniel Walker
2011-01-21 16:13         ` Brent DeGraaf
2011-01-21 16:57           ` Brent DeGraaf
2011-01-21 18:13             ` Russell King - ARM Linux
2011-01-21 19:28           ` Russell King - ARM Linux
2011-01-21 20:45             ` Daniel Walker
2011-01-21 21:17             ` David Brown
2011-01-21 21:37               ` Brent DeGraaf
2011-01-21 21:42                 ` Russell King - ARM Linux
  -- strict thread matches above, loose matches on Subject: below --
2011-01-18 22:25 Daniel Walker
2011-01-18 22:41 ` Russell King - ARM Linux
2011-01-18 22:48   ` Daniel Walker

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=20110120131239.GB23941@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=bdegraaf@codeaurora.org \
    --cc=davidb@codeaurora.org \
    --cc=dwalker@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=stummala@codeaurora.org \
    /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).