All of lore.kernel.org
 help / color / mirror / Atom feed
From: okaya@codeaurora.org (Sinan Kaya)
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 12:07:26 -0400	[thread overview]
Message-ID: <56EAD63E.2010103@codeaurora.org> (raw)
In-Reply-To: <56EAD3E2.5070109@arm.com>

On 3/17/2016 11:57 AM, Robin Murphy 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.

If it is SWIOTLB only, then it needs to disappear from common header file as 
it is doing the wrong thing when IOMMU is enabled for a device. 

I have some device driver (HIDMA) that used dma_to_phys during DMA self test.
I needed this patch to get it working properly. I removed the self test from
my code but I still don't feel right about this dma_to_phys API returning physical
addresses.

> 
> Also, what about phys_to_dma()?

Agreed, need to fix phys_to_dma too.

> 
> Robin.

Let me know which direction I should go. 

1. Fix phys_to_dma and keep dma_to_phys as in the patch.
2. Remove both of the API from header file, move it to where it is needed. Rename them as swio_phys_to_dma etc.

-- 
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

WARNING: multiple messages have this Message-ID (diff)
From: Sinan Kaya <okaya@codeaurora.org>
To: Robin Murphy <robin.murphy@arm.com>,
	linux-arm-kernel@lists.infradead.org, timur@codeaurora.org,
	cov@codeaurora.org, nwatters@codeaurora.org
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Max Filippov <jcmvbkbc@gmail.com>, Joe Perches <joe@perches.com>,
	"Suthikulpanit, Suravee" <Suravee.Suthikulpanit@amd.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Jisheng Zhang <jszhang@marvell.com>,
	Dean Nelson <dnelson@redhat.com>,
	"Suzuki K. Poulose" <suzuki.poulose@arm.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm64: dma-mapping: fix dma_to_phys API for IOMMU attached devices
Date: Thu, 17 Mar 2016 12:07:26 -0400	[thread overview]
Message-ID: <56EAD63E.2010103@codeaurora.org> (raw)
In-Reply-To: <56EAD3E2.5070109@arm.com>

On 3/17/2016 11:57 AM, Robin Murphy 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.

If it is SWIOTLB only, then it needs to disappear from common header file as 
it is doing the wrong thing when IOMMU is enabled for a device. 

I have some device driver (HIDMA) that used dma_to_phys during DMA self test.
I needed this patch to get it working properly. I removed the self test from
my code but I still don't feel right about this dma_to_phys API returning physical
addresses.

> 
> Also, what about phys_to_dma()?

Agreed, need to fix phys_to_dma too.

> 
> Robin.

Let me know which direction I should go. 

1. Fix phys_to_dma and keep dma_to_phys as in the patch.
2. Remove both of the API from header file, move it to where it is needed. Rename them as swio_phys_to_dma etc.

-- 
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

  reply	other threads:[~2016-03-17 16:07 UTC|newest]

Thread overview: 12+ 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:50 ` Sinan Kaya
2016-03-17 15:57 ` Robin Murphy
2016-03-17 15:57   ` Robin Murphy
2016-03-17 16:07   ` Sinan Kaya [this message]
2016-03-17 16:07     ` Sinan Kaya
2016-03-17 16:14     ` Arnd Bergmann
2016-03-17 16:14       ` Arnd Bergmann
2016-03-17 16:36       ` Sinan Kaya
2016-03-17 16:36         ` Sinan Kaya
2016-03-17 17:01         ` Arnd Bergmann
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=56EAD63E.2010103@codeaurora.org \
    --to=okaya@codeaurora.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.