linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: robin.murphy@arm.com (Robin Murphy)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: dma-mapping: fix dma_to_phys API for IOMMU attached devices
Date: Thu, 17 Mar 2016 15:57:22 +0000	[thread overview]
Message-ID: <56EAD3E2.5070109@arm.com> (raw)
In-Reply-To: <1458229833-4886-1-git-send-email-okaya@codeaurora.org>

On 17/03/16 15:50, Sinan Kaya wrote:
> This patch modifies dma_to_phys to call iommu_iova_to_phys to perform dma
> to phys conversions for IOMMU attached devices where dma and physical
> addresses often have distinct values.

What's this for? dma_to_phys() is only used by SWIOTLB, and that's 
mutually exclusive with IOMMU ops.

Also, what about phys_to_dma()?

Robin.

> Signed-off-by: Nate Watterson <nwatters@codeaurora.org>
> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> ---
>   arch/arm64/include/asm/dma-mapping.h |  5 +----
>   arch/arm64/mm/dma-mapping.c          | 16 ++++++++++++++++
>   2 files changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
> index ba437f0..a0a486c 100644
> --- a/arch/arm64/include/asm/dma-mapping.h
> +++ b/arch/arm64/include/asm/dma-mapping.h
> @@ -69,10 +69,7 @@ static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
>   	return (dma_addr_t)paddr;
>   }
>
> -static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr)
> -{
> -	return (phys_addr_t)dev_addr;
> -}
> +phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr);
>
>   static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
>   {
> diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
> index 331c4ca..8252a92 100644
> --- a/arch/arm64/mm/dma-mapping.c
> +++ b/arch/arm64/mm/dma-mapping.c
> @@ -989,3 +989,19 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
>   	dev->archdata.dma_coherent = coherent;
>   	__iommu_setup_dma_ops(dev, dma_base, size, iommu);
>   }
> +
> +phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr)
> +{
> +	phys_addr_t phys = (phys_addr_t)dev_addr;
> +
> +#ifdef CONFIG_IOMMU_DMA
> +	struct iommu_domain *domain;
> +
> +	domain = iommu_get_domain_for_dev(dev);
> +	if (domain)
> +		phys = iommu_iova_to_phys(domain, dev_addr);
> +#endif
> +
> +	return phys;
> +}
> +EXPORT_SYMBOL(dma_to_phys);
>

  reply	other threads:[~2016-03-17 15:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-17 15:50 [PATCH] arm64: dma-mapping: fix dma_to_phys API for IOMMU attached devices Sinan Kaya
2016-03-17 15:57 ` Robin Murphy [this message]
2016-03-17 16:07   ` Sinan Kaya
2016-03-17 16:14     ` Arnd Bergmann
2016-03-17 16:36       ` Sinan Kaya
2016-03-17 17:01         ` Arnd Bergmann

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=56EAD3E2.5070109@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;
as well as URLs for NNTP newsgroup(s).