aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-05-19 20:27:28 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-19 20:27:28 -0400
commitd4c6cd157a77645b9f8bff348b57aafa551f2d79 (patch)
tree81e0cfc1149820e979ed609d7c87f7de5671a6bb
parent4217fdde34a574f1bbdd5f34f64e499465a157ba (diff)
parent745b6e74704782488dd875292bc49e24d23e81fd (diff)
Merge tag 'iommu-fixes-v4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull IOMMU fixes from Joerg Roedel: - another compile-fix as a fallout of the recent header-file cleanup - add a missing IO/TLB flush to the Intel VT-d kdump code path - a fix for ARM64 dma code to only access initialized iova_domain members * tag 'iommu-fixes-v4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu/mediatek: Include linux/dma-mapping.h iommu/vt-d: Flush the IOTLB to get rid of the initial kdump mappings iommu/dma: Don't touch invalid iova_domain members
-rw-r--r--drivers/iommu/dma-iommu.c13
-rw-r--r--drivers/iommu/intel-iommu.c5
-rw-r--r--drivers/iommu/mtk_iommu_v1.c1
3 files changed, 13 insertions, 6 deletions
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 8348f366ddd1..62618e77bedc 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -396,13 +396,13 @@ static void iommu_dma_free_iova(struct iommu_dma_cookie *cookie,
396 dma_addr_t iova, size_t size) 396 dma_addr_t iova, size_t size)
397{ 397{
398 struct iova_domain *iovad = &cookie->iovad; 398 struct iova_domain *iovad = &cookie->iovad;
399 unsigned long shift = iova_shift(iovad);
400 399
401 /* The MSI case is only ever cleaning up its most recent allocation */ 400 /* The MSI case is only ever cleaning up its most recent allocation */
402 if (cookie->type == IOMMU_DMA_MSI_COOKIE) 401 if (cookie->type == IOMMU_DMA_MSI_COOKIE)
403 cookie->msi_iova -= size; 402 cookie->msi_iova -= size;
404 else 403 else
405 free_iova_fast(iovad, iova >> shift, size >> shift); 404 free_iova_fast(iovad, iova_pfn(iovad, iova),
405 size >> iova_shift(iovad));
406} 406}
407 407
408static void __iommu_dma_unmap(struct iommu_domain *domain, dma_addr_t dma_addr, 408static void __iommu_dma_unmap(struct iommu_domain *domain, dma_addr_t dma_addr,
@@ -617,11 +617,14 @@ static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys,
617{ 617{
618 struct iommu_domain *domain = iommu_get_domain_for_dev(dev); 618 struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
619 struct iommu_dma_cookie *cookie = domain->iova_cookie; 619 struct iommu_dma_cookie *cookie = domain->iova_cookie;
620 struct iova_domain *iovad = &cookie->iovad; 620 size_t iova_off = 0;
621 size_t iova_off = iova_offset(iovad, phys);
622 dma_addr_t iova; 621 dma_addr_t iova;
623 622
624 size = iova_align(iovad, size + iova_off); 623 if (cookie->type == IOMMU_DMA_IOVA_COOKIE) {
624 iova_off = iova_offset(&cookie->iovad, phys);
625 size = iova_align(&cookie->iovad, size + iova_off);
626 }
627
625 iova = iommu_dma_alloc_iova(domain, size, dma_get_mask(dev), dev); 628 iova = iommu_dma_alloc_iova(domain, size, dma_get_mask(dev), dev);
626 if (!iova) 629 if (!iova)
627 return DMA_ERROR_CODE; 630 return DMA_ERROR_CODE;
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 90ab0115d78e..fc2765ccdb57 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -2055,11 +2055,14 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
2055 if (context_copied(context)) { 2055 if (context_copied(context)) {
2056 u16 did_old = context_domain_id(context); 2056 u16 did_old = context_domain_id(context);
2057 2057
2058 if (did_old >= 0 && did_old < cap_ndoms(iommu->cap)) 2058 if (did_old >= 0 && did_old < cap_ndoms(iommu->cap)) {
2059 iommu->flush.flush_context(iommu, did_old, 2059 iommu->flush.flush_context(iommu, did_old,
2060 (((u16)bus) << 8) | devfn, 2060 (((u16)bus) << 8) | devfn,
2061 DMA_CCMD_MASK_NOBIT, 2061 DMA_CCMD_MASK_NOBIT,
2062 DMA_CCMD_DEVICE_INVL); 2062 DMA_CCMD_DEVICE_INVL);
2063 iommu->flush.flush_iotlb(iommu, did_old, 0, 0,
2064 DMA_TLB_DSI_FLUSH);
2065 }
2063 } 2066 }
2064 2067
2065 pgd = domain->pgd; 2068 pgd = domain->pgd;
diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c
index a27ef570c328..bc1efbfb9ddf 100644
--- a/drivers/iommu/mtk_iommu_v1.c
+++ b/drivers/iommu/mtk_iommu_v1.c
@@ -18,6 +18,7 @@
18#include <linux/clk.h> 18#include <linux/clk.h>
19#include <linux/component.h> 19#include <linux/component.h>
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/dma-mapping.h>
21#include <linux/dma-iommu.h> 22#include <linux/dma-iommu.h>
22#include <linux/err.h> 23#include <linux/err.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>