From: catalin.marinas@arm.com (Catalin Marinas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/5] ARM: Implement read/write for ownership in theARMv6 DMA cache ops
Date: Fri, 26 Mar 2010 14:08:42 +0000 [thread overview]
Message-ID: <1269612522.807.71.camel@e102109-lin.cambridge.arm.com> (raw)
In-Reply-To: <20100323213825.GI19572@n2100.arm.linux.org.uk>
On Tue, 2010-03-23 at 21:38 +0000, Russell King - ARM Linux wrote:
> On Mon, Mar 22, 2010 at 03:19:45PM +0000, Catalin Marinas wrote:
> > diff --git a/arch/arm/mm/cache-v6.S b/arch/arm/mm/cache-v6.S
> > index 9d89c67..b9f2cbd 100644
> > --- a/arch/arm/mm/cache-v6.S
> > +++ b/arch/arm/mm/cache-v6.S
> > @@ -211,6 +211,9 @@ v6_dma_inv_range:
> > mcrne p15, 0, r1, c7, c15, 1 @ clean & invalidate unified line
> > #endif
> > 1:
> > +#ifdef CONFIG_SMP
> > + str r0, [r0] @ write for ownership
> > +#endif
> > #ifdef HARVARD_CACHE
> > mcr p15, 0, r0, c7, c6, 1 @ invalidate D line
> > #else
> > @@ -231,6 +234,9 @@ v6_dma_inv_range:
> > v6_dma_clean_range:
> > bic r0, r0, #D_CACHE_LINE_SIZE - 1
> > 1:
> > +#ifdef CONFIG_SMP
> > + ldr r2, [r0] @ read for ownership
> > +#endif
> > #ifdef HARVARD_CACHE
> > mcr p15, 0, r0, c7, c10, 1 @ clean D line
> > #else
> > @@ -251,6 +257,10 @@ v6_dma_clean_range:
> > ENTRY(v6_dma_flush_range)
> > bic r0, r0, #D_CACHE_LINE_SIZE - 1
> > 1:
> > +#ifdef CONFIG_SMP
> > + ldr r2, [r0] @ read for ownership
> > + str r2, [r0] @ write for ownership
>
> What is the effect of using the register just loaded on ARMv6? Does it
> stall like previous architectures? If so, this str should use a different
> register.
Using the same register here is on purpose so that we do not override
the data already in the buffer (it's a flush operation). Yes, we have
interlocking, but the STR has to be executed before we issue the cache
cleaning operation.
The invalidate case uses a dummy STR but we just found that with the
latest DMA API, invalidating in the unmap functions would override the
transferred data. I need to revisit this.
> In any case, does reading then writing actually achieve anything over just
> a plain write? read surely brings the cache line into shared mode, and
> a write to exclusive mode - so won't just a write do?
Yes, we need to preserve the data already in the buffer in some
situations.
> The converse argument is that with read allocate caches, this technique
> can result in faster code, so why don't we use it in dma_inv_range?
Only reading the data may put the cache line in shared mode and a local
cache invalidation only affects the current CPU, leaving the data in
cache on the other CPUs. It's true that we won't have dirty cache lines
that may be evicted during the DMA transfer but if a different CPU uses
the data at a later time, it may get the stale cache entries.
Issuing a write would invalidate the cache lines on the other CPUs so
they'll need to be read from L2 again when accessed.
--
Catalin
next prev parent reply other threads:[~2010-03-26 14:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-22 15:19 [PATCH 0/5] Various patches for 2.6.35-rc1 Catalin Marinas
2010-03-22 15:19 ` [PATCH 1/5] ARM: Use lazy cache flushing on ARMv7 SMP systems Catalin Marinas
2010-03-23 21:33 ` Russell King - ARM Linux
2010-03-24 9:51 ` Catalin Marinas
2010-03-26 14:49 ` Catalin Marinas
2010-03-26 17:36 ` Catalin Marinas
2010-03-22 15:19 ` [PATCH 2/5] ARM: Implement read/write for ownership in the ARMv6 DMA cache ops Catalin Marinas
2010-03-23 21:38 ` Russell King - ARM Linux
2010-03-26 14:08 ` Catalin Marinas [this message]
2010-03-22 15:19 ` [PATCH 3/5] ARM: Correct the VFPv3 detection Catalin Marinas
2010-03-23 21:38 ` Russell King - ARM Linux
2010-03-22 15:19 ` [PATCH 4/5] ARM: Align machine_desc.phys_io to a 1MB section Catalin Marinas
2010-03-23 21:39 ` Russell King - ARM Linux
2010-03-22 15:20 ` [PATCH 5/5] ARM: Remove the domain switching on ARMv6k/v7 CPUs Catalin Marinas
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=1269612522.807.71.camel@e102109-lin.cambridge.arm.com \
--to=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.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).