From: Robin Murphy <robin.murphy@arm.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Tom Murphy <tmurphy@arista.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 07/24] iommu/dma: Move domain lookup into __iommu_dma_{map, unmap}
Date: Wed, 22 May 2019 14:34:49 +0100 [thread overview]
Message-ID: <b2ef2d14-ec58-a1d6-1741-7834840498ee@arm.com> (raw)
In-Reply-To: <20190520072948.11412-8-hch@lst.de>
On 20/05/2019 08:29, Christoph Hellwig wrote:
> From: Robin Murphy <robin.murphy@arm.com>
>
> Most of the callers don't care, and the couple that do already have the
> domain to hand for other reasons are in slow paths where the (trivial)
> overhead of a repeated lookup will be utterly immaterial.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> [hch: dropped the hunk touching iommu_dma_get_msi_page to avoid a
> conflict with another series]
Since the MSI changes made it into 5.2, do you want to resurrect that
hunk here, or shall I spin it up as a follow-on patch?
Robin.
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/iommu/dma-iommu.c | 29 ++++++++++++++---------------
> 1 file changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index c406abe3be01..6ece8f477fc8 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -448,9 +448,10 @@ static void iommu_dma_free_iova(struct iommu_dma_cookie *cookie,
> size >> iova_shift(iovad));
> }
>
> -static void __iommu_dma_unmap(struct iommu_domain *domain, dma_addr_t dma_addr,
> +static void __iommu_dma_unmap(struct device *dev, dma_addr_t dma_addr,
> size_t size)
> {
> + struct iommu_domain *domain = iommu_get_dma_domain(dev);
> struct iommu_dma_cookie *cookie = domain->iova_cookie;
> struct iova_domain *iovad = &cookie->iovad;
> size_t iova_off = iova_offset(iovad, dma_addr);
> @@ -465,8 +466,9 @@ static void __iommu_dma_unmap(struct iommu_domain *domain, dma_addr_t dma_addr,
> }
>
> static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys,
> - size_t size, int prot, struct iommu_domain *domain)
> + size_t size, int prot)
> {
> + struct iommu_domain *domain = iommu_get_dma_domain(dev);
> struct iommu_dma_cookie *cookie = domain->iova_cookie;
> size_t iova_off = 0;
> dma_addr_t iova;
> @@ -565,7 +567,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,
> static void __iommu_dma_free(struct device *dev, struct page **pages,
> size_t size, dma_addr_t *handle)
> {
> - __iommu_dma_unmap(iommu_get_dma_domain(dev), *handle, size);
> + __iommu_dma_unmap(dev, *handle, size);
> __iommu_dma_free_pages(pages, PAGE_ALIGN(size) >> PAGE_SHIFT);
> *handle = DMA_MAPPING_ERROR;
> }
> @@ -718,14 +720,13 @@ static void iommu_dma_sync_sg_for_device(struct device *dev,
> static dma_addr_t __iommu_dma_map_page(struct device *dev, struct page *page,
> unsigned long offset, size_t size, int prot)
> {
> - return __iommu_dma_map(dev, page_to_phys(page) + offset, size, prot,
> - iommu_get_dma_domain(dev));
> + return __iommu_dma_map(dev, page_to_phys(page) + offset, size, prot);
> }
>
> static void __iommu_dma_unmap_page(struct device *dev, dma_addr_t handle,
> size_t size, enum dma_data_direction dir, unsigned long attrs)
> {
> - __iommu_dma_unmap(iommu_get_dma_domain(dev), handle, size);
> + __iommu_dma_unmap(dev, handle, size);
> }
>
> static dma_addr_t iommu_dma_map_page(struct device *dev, struct page *page,
> @@ -734,11 +735,10 @@ static dma_addr_t iommu_dma_map_page(struct device *dev, struct page *page,
> {
> phys_addr_t phys = page_to_phys(page) + offset;
> bool coherent = dev_is_dma_coherent(dev);
> + int prot = dma_info_to_prot(dir, coherent, attrs);
> dma_addr_t dma_handle;
>
> - dma_handle =__iommu_dma_map(dev, phys, size,
> - dma_info_to_prot(dir, coherent, attrs),
> - iommu_get_dma_domain(dev));
> + dma_handle =__iommu_dma_map(dev, phys, size, prot);
> if (!coherent && !(attrs & DMA_ATTR_SKIP_CPU_SYNC) &&
> dma_handle != DMA_MAPPING_ERROR)
> arch_sync_dma_for_device(dev, phys, size, dir);
> @@ -750,7 +750,7 @@ static void iommu_dma_unmap_page(struct device *dev, dma_addr_t dma_handle,
> {
> if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
> iommu_dma_sync_single_for_cpu(dev, dma_handle, size, dir);
> - __iommu_dma_unmap(iommu_get_dma_domain(dev), dma_handle, size);
> + __iommu_dma_unmap(dev, dma_handle, size);
> }
>
> /*
> @@ -931,21 +931,20 @@ static void iommu_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
> sg = tmp;
> }
> end = sg_dma_address(sg) + sg_dma_len(sg);
> - __iommu_dma_unmap(iommu_get_dma_domain(dev), start, end - start);
> + __iommu_dma_unmap(dev, start, end - start);
> }
>
> static dma_addr_t iommu_dma_map_resource(struct device *dev, phys_addr_t phys,
> size_t size, enum dma_data_direction dir, unsigned long attrs)
> {
> return __iommu_dma_map(dev, phys, size,
> - dma_info_to_prot(dir, false, attrs) | IOMMU_MMIO,
> - iommu_get_dma_domain(dev));
> + dma_info_to_prot(dir, false, attrs) | IOMMU_MMIO);
> }
>
> static void iommu_dma_unmap_resource(struct device *dev, dma_addr_t handle,
> size_t size, enum dma_data_direction dir, unsigned long attrs)
> {
> - __iommu_dma_unmap(iommu_get_dma_domain(dev), handle, size);
> + __iommu_dma_unmap(dev, handle, size);
> }
>
> static void *iommu_dma_alloc(struct device *dev, size_t size,
> @@ -1222,7 +1221,7 @@ static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev,
> if (!msi_page)
> return NULL;
>
> - iova = __iommu_dma_map(dev, msi_addr, size, prot, domain);
> + iova = __iommu_dma_map(dev, msi_addr, size, prot);
> if (iova == DMA_MAPPING_ERROR)
> goto out_free_page;
>
>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2019-05-22 13:35 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-20 7:29 implement generic dma_map_ops for IOMMUs v5 Christoph Hellwig
2019-05-20 7:29 ` [PATCH 01/24] arm64/iommu: handle non-remapped addresses in ->mmap and ->get_sgtable Christoph Hellwig
2019-05-22 12:54 ` Will Deacon
2019-05-20 7:29 ` [PATCH 02/24] iommu/dma: Cleanup dma-iommu.h Christoph Hellwig
2019-05-20 7:29 ` [PATCH 03/24] iommu/dma: Remove the flush_page callback Christoph Hellwig
2019-05-20 7:29 ` [PATCH 04/24] iommu/dma: Use for_each_sg in iommu_dma_alloc Christoph Hellwig
2019-05-20 7:29 ` [PATCH 05/24] iommu/dma: move the arm64 wrappers to common code Christoph Hellwig
2019-05-20 7:29 ` [PATCH 06/24] iommu/dma: Move __iommu_dma_map Christoph Hellwig
2019-05-20 7:29 ` [PATCH 07/24] iommu/dma: Move domain lookup into __iommu_dma_{map, unmap} Christoph Hellwig
2019-05-22 13:34 ` Robin Murphy [this message]
2019-05-22 15:57 ` Christoph Hellwig
2019-07-29 12:12 ` Shameerali Kolothum Thodi
2019-07-29 13:13 ` Robin Murphy
2019-05-20 7:29 ` [PATCH 08/24] iommu/dma: Squash __iommu_dma_{map,unmap}_page helpers Christoph Hellwig
2019-05-20 7:29 ` [PATCH 09/24] iommu/dma: Factor out remapped pages lookup Christoph Hellwig
2019-05-20 7:29 ` [PATCH 10/24] iommu/dma: Refactor the page array remapping allocator Christoph Hellwig
2019-05-20 7:29 ` [PATCH 11/24] iommu/dma: Remove __iommu_dma_free Christoph Hellwig
2019-05-20 7:29 ` [PATCH 12/24] iommu/dma: Refactor iommu_dma_free Christoph Hellwig
2019-05-20 7:29 ` [PATCH 13/24] iommu/dma: Refactor iommu_dma_alloc Christoph Hellwig
2019-05-20 7:29 ` [PATCH 14/24] iommu/dma: Don't remap CMA unnecessarily Christoph Hellwig
2019-05-20 7:29 ` [PATCH 15/24] iommu/dma: Merge the CMA and alloc_pages allocation paths Christoph Hellwig
2019-05-20 7:29 ` [PATCH 16/24] iommu/dma: Split iommu_dma_free Christoph Hellwig
2019-05-20 7:29 ` [PATCH 17/24] iommu/dma: Cleanup variable naming in iommu_dma_alloc Christoph Hellwig
2019-05-20 7:29 ` [PATCH 18/24] iommu/dma: Refactor iommu_dma_alloc, part 2 Christoph Hellwig
2019-05-20 7:29 ` [PATCH 19/24] iommu/dma: Refactor iommu_dma_get_sgtable Christoph Hellwig
2019-05-20 7:29 ` [PATCH 20/24] iommu/dma: Refactor iommu_dma_mmap Christoph Hellwig
2019-05-22 17:11 ` Robin Murphy
2019-05-20 7:29 ` [PATCH 21/24] iommu/dma: Don't depend on CONFIG_DMA_DIRECT_REMAP Christoph Hellwig
2019-05-20 7:29 ` [PATCH 22/24] iommu/dma: Switch copyright boilerplace to SPDX Christoph Hellwig
2019-05-20 7:29 ` [PATCH 23/24] arm64: switch copyright boilerplace to SPDX in dma-mapping.c Christoph Hellwig
2019-05-20 7:29 ` [PATCH 24/24] arm64: trim includes " Christoph Hellwig
2019-05-27 15:37 ` implement generic dma_map_ops for IOMMUs v5 Joerg Roedel
2019-05-27 15:38 ` Christoph Hellwig
2019-05-27 15:45 ` Joerg Roedel
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=b2ef2d14-ec58-a1d6-1741-7834840498ee@arm.com \
--to=robin.murphy@arm.com \
--cc=catalin.marinas@arm.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tmurphy@arista.com \
--cc=will.deacon@arm.com \
/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