From: robin.murphy@arm.com (Robin Murphy)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] ARM: dma-mapping: Support cache sync after arm_dma_get_sgtable
Date: Wed, 26 Oct 2016 18:24:03 +0100 [thread overview]
Message-ID: <3c46b9df-7024-82bf-6360-01663a5edf43@arm.com> (raw)
In-Reply-To: <1477501448-30915-2-git-send-email-thierry.escande@collabora.com>
On 26/10/16 18:04, Thierry Escande wrote:
> From: Heng-Ruey Hsu <henryhsu@chromium.org>
>
> Currently arm_dma_sync_sg_* require dma_address to do cache sync. But
> dma address is set by map_sg(). We can't do cache sync after
> arm_dma_get_sgtable. The behavior is different from iommu_ops.
>
> We don't have to get dma address in arm_dma_sync_sg_* and convert the
> address to physical address in arm_dma_sync_single_*. With this change
> sg_page() is used to get physical address and do sync directly.
>
> Signed-off-by: Heng-Ruey Hsu <henryhsu@chromium.org>
> Tested-by: Heng-ruey Hsu <henryhsu@chromium.org>
> Reviewed-by: Tomasz Figa <tfiga@chromium.org>
> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
> ---
> arch/arm/mm/dma-mapping.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index ab4f745..dc42ca6 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -1120,13 +1120,11 @@ void arm_dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
> void arm_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
> int nents, enum dma_data_direction dir)
> {
> - struct dma_map_ops *ops = get_dma_ops(dev);
> struct scatterlist *s;
> int i;
>
> for_each_sg(sg, s, nents, i)
> - ops->sync_single_for_cpu(dev, sg_dma_address(s), s->length,
> - dir);
> + __dma_page_dev_to_cpu(sg_page(s), s->offset, s->length, dir);
This breaks dmabounce. The .sync_single_for_cpu implementation there is
non-trivial.
Robin.
> }
>
> /**
> @@ -1139,13 +1137,11 @@ void arm_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
> void arm_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
> int nents, enum dma_data_direction dir)
> {
> - struct dma_map_ops *ops = get_dma_ops(dev);
> struct scatterlist *s;
> int i;
>
> for_each_sg(sg, s, nents, i)
> - ops->sync_single_for_device(dev, sg_dma_address(s), s->length,
> - dir);
> + __dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir);
> }
>
> /*
>
next prev parent reply other threads:[~2016-10-26 17:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-26 17:04 [PATCH 0/2] ARM DMA mapping Thierry Escande
2016-10-26 17:04 ` [PATCH 1/2] ARM: dma-mapping: Support cache sync after arm_dma_get_sgtable Thierry Escande
2016-10-26 17:24 ` Robin Murphy [this message]
2016-10-26 17:04 ` [PATCH 2/2] ARM: dma-mapping: Handle prot with non-consistent dma attribute Thierry Escande
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=3c46b9df-7024-82bf-6360-01663a5edf43@arm.com \
--to=robin.murphy@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