Commit d4c6cd15 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 4217fdde 745b6e74
...@@ -396,13 +396,13 @@ static void iommu_dma_free_iova(struct iommu_dma_cookie *cookie, ...@@ -396,13 +396,13 @@ static void iommu_dma_free_iova(struct iommu_dma_cookie *cookie,
dma_addr_t iova, size_t size) dma_addr_t iova, size_t size)
{ {
struct iova_domain *iovad = &cookie->iovad; struct iova_domain *iovad = &cookie->iovad;
unsigned long shift = iova_shift(iovad);
/* The MSI case is only ever cleaning up its most recent allocation */ /* The MSI case is only ever cleaning up its most recent allocation */
if (cookie->type == IOMMU_DMA_MSI_COOKIE) if (cookie->type == IOMMU_DMA_MSI_COOKIE)
cookie->msi_iova -= size; cookie->msi_iova -= size;
else else
free_iova_fast(iovad, iova >> shift, size >> shift); free_iova_fast(iovad, iova_pfn(iovad, iova),
size >> iova_shift(iovad));
} }
static void __iommu_dma_unmap(struct iommu_domain *domain, dma_addr_t dma_addr, static 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,11 +617,14 @@ static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys,
{ {
struct iommu_domain *domain = iommu_get_domain_for_dev(dev); struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
struct iommu_dma_cookie *cookie = domain->iova_cookie; struct iommu_dma_cookie *cookie = domain->iova_cookie;
struct iova_domain *iovad = &cookie->iovad; size_t iova_off = 0;
size_t iova_off = iova_offset(iovad, phys);
dma_addr_t iova; dma_addr_t iova;
size = iova_align(iovad, size + iova_off); if (cookie->type == IOMMU_DMA_IOVA_COOKIE) {
iova_off = iova_offset(&cookie->iovad, phys);
size = iova_align(&cookie->iovad, size + iova_off);
}
iova = iommu_dma_alloc_iova(domain, size, dma_get_mask(dev), dev); iova = iommu_dma_alloc_iova(domain, size, dma_get_mask(dev), dev);
if (!iova) if (!iova)
return DMA_ERROR_CODE; return DMA_ERROR_CODE;
......
...@@ -2055,11 +2055,14 @@ static int domain_context_mapping_one(struct dmar_domain *domain, ...@@ -2055,11 +2055,14 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
if (context_copied(context)) { if (context_copied(context)) {
u16 did_old = context_domain_id(context); u16 did_old = context_domain_id(context);
if (did_old >= 0 && did_old < cap_ndoms(iommu->cap)) if (did_old >= 0 && did_old < cap_ndoms(iommu->cap)) {
iommu->flush.flush_context(iommu, did_old, iommu->flush.flush_context(iommu, did_old,
(((u16)bus) << 8) | devfn, (((u16)bus) << 8) | devfn,
DMA_CCMD_MASK_NOBIT, DMA_CCMD_MASK_NOBIT,
DMA_CCMD_DEVICE_INVL); DMA_CCMD_DEVICE_INVL);
iommu->flush.flush_iotlb(iommu, did_old, 0, 0,
DMA_TLB_DSI_FLUSH);
}
} }
pgd = domain->pgd; pgd = domain->pgd;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/component.h> #include <linux/component.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/dma-iommu.h> #include <linux/dma-iommu.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment