From: tixy@linaro.org (Jon Medhurst (Tixy))
To: linux-arm-kernel@lists.infradead.org
Subject: Bug(?) in patch "arm64: Implement coherent DMA API based on swiotlb" (was Re: [GIT PULL] arm64 patches for 3.15)
Date: Tue, 01 Apr 2014 17:10:57 +0100 [thread overview]
Message-ID: <1396368657.3681.17.camel@linaro1.home> (raw)
In-Reply-To: <20140331175230.GA7480@arm.com>
On Mon, 2014-03-31 at 18:52 +0100, Catalin Marinas wrote:
> The following changes since commit cfbf8d4857c26a8a307fb7cd258074c9dcd8c691:
>
> Linux 3.14-rc4 (2014-02-23 17:40:03 -0800)
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux tags/arm64-upstream
>
> for you to fetch changes up to 196adf2f3015eacac0567278ba538e3ffdd16d0e:
>
> arm64: Remove pgprot_dmacoherent() (2014-03-24 10:35:35 +0000)
I may have spotted a bug in commit 7363590d2c46 (arm64: Implement
coherent DMA API based on swiotlb), see my inline comment below...
[...]
> diff --git a/arch/arm64/mm/cache.S b/arch/arm64/mm/cache.S
> index 1ea9f26..97fcef5 100644
> --- a/arch/arm64/mm/cache.S
> +++ b/arch/arm64/mm/cache.S
> @@ -166,3 +166,81 @@ ENTRY(__flush_dcache_area)
> dsb sy
> ret
> ENDPROC(__flush_dcache_area)
> +
> +/*
> + * __dma_inv_range(start, end)
> + * - start - virtual start address of region
> + * - end - virtual end address of region
> + */
> +__dma_inv_range:
> + dcache_line_size x2, x3
> + sub x3, x2, #1
> + bic x0, x0, x3
> + bic x1, x1, x3
Why is the 'end' value in x1 above rounded down to be cache aligned?
This means the cache invalidate won't include the cache line containing
the final bytes of the region, unless it happened to already be cache
line aligned. This looks especially suspect as the other two cache
operations added in the same patch (below) don't do that.
> +1: dc ivac, x0 // invalidate D / U line
> + add x0, x0, x2
> + cmp x0, x1
> + b.lo 1b
> + dsb sy
> + ret
> +ENDPROC(__dma_inv_range)
> +
> +/*
> + * __dma_clean_range(start, end)
> + * - start - virtual start address of region
> + * - end - virtual end address of region
> + */
> +__dma_clean_range:
> + dcache_line_size x2, x3
> + sub x3, x2, #1
> + bic x0, x0, x3
> +1: dc cvac, x0 // clean D / U line
> + add x0, x0, x2
> + cmp x0, x1
> + b.lo 1b
> + dsb sy
> + ret
> +ENDPROC(__dma_clean_range)
> +
> +/*
> + * __dma_flush_range(start, end)
> + * - start - virtual start address of region
> + * - end - virtual end address of region
> + */
> +ENTRY(__dma_flush_range)
> + dcache_line_size x2, x3
> + sub x3, x2, #1
> + bic x0, x0, x3
> +1: dc civac, x0 // clean & invalidate D / U line
> + add x0, x0, x2
> + cmp x0, x1
> + b.lo 1b
> + dsb sy
> + ret
> +ENDPROC(__dma_flush_range)
[...]
--
Tixy
next prev parent reply other threads:[~2014-04-01 16:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-31 17:52 [GIT PULL] arm64 patches for 3.15 Catalin Marinas
2014-04-01 16:10 ` Jon Medhurst (Tixy) [this message]
2014-04-01 17:29 ` Bug(?) in patch "arm64: Implement coherent DMA API based on swiotlb" (was Re: [GIT PULL] arm64 patches for 3.15) Catalin Marinas
2014-04-02 8:52 ` Jon Medhurst (Tixy)
2014-04-02 9:20 ` Catalin Marinas
2014-04-02 9:40 ` Russell King - ARM Linux
2014-04-02 11:13 ` Catalin Marinas
2014-04-02 10:41 ` Bug(?) in patch "arm64: Implement coherent DMA API based on swiotlb" Jon Medhurst (Tixy)
2014-04-02 11:37 ` Catalin Marinas
2014-04-02 10:54 ` Bug(?) in patch "arm64: Implement coherent DMA API based on swiotlb" (was Re: [GIT PULL] arm64 patches for 3.15) Jon Medhurst (Tixy)
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=1396368657.3681.17.camel@linaro1.home \
--to=tixy@linaro.org \
--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).