Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 154760
b: refs/heads/master
c: b213203
h: refs/heads/master
v: v3
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Jun 29, 2009
1 parent 998da21 commit 0ef7290
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bf92df30df909710c498d05620e2df1be1ef779b
refs/heads/master: b213203e475212a69ad6fedfb73464087e317148
62 changes: 36 additions & 26 deletions trunk/drivers/pci/intel-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1849,25 +1849,12 @@ static struct dmar_domain *get_domain_for_dev(struct pci_dev *pdev, int gaw)

static int iommu_identity_mapping;

static int iommu_prepare_identity_map(struct pci_dev *pdev,
unsigned long long start,
unsigned long long end)
static int iommu_domain_identity_map(struct dmar_domain *domain,
unsigned long long start,
unsigned long long end)
{
struct dmar_domain *domain;
unsigned long size;
unsigned long long base;
int ret;

printk(KERN_INFO
"IOMMU: Setting identity map for device %s [0x%Lx - 0x%Lx]\n",
pci_name(pdev), start, end);
if (iommu_identity_mapping)
domain = si_domain;
else
/* page table init */
domain = get_domain_for_dev(pdev, DEFAULT_DOMAIN_ADDRESS_WIDTH);
if (!domain)
return -ENOMEM;

/* The address might not be aligned */
base = start & PAGE_MASK;
Expand All @@ -1876,31 +1863,54 @@ static int iommu_prepare_identity_map(struct pci_dev *pdev,
if (!reserve_iova(&domain->iovad, IOVA_PFN(base),
IOVA_PFN(base + size) - 1)) {
printk(KERN_ERR "IOMMU: reserve iova failed\n");
ret = -ENOMEM;
goto error;
return -ENOMEM;
}

pr_debug("Mapping reserved region %lx@%llx for %s\n",
size, base, pci_name(pdev));
pr_debug("Mapping reserved region %lx@%llx for domain %d\n",
size, base, domain->id);
/*
* RMRR range might have overlap with physical memory range,
* clear it first
*/
dma_pte_clear_range(domain, base, base + size);

ret = domain_page_mapping(domain, base, base, size,
DMA_PTE_READ|DMA_PTE_WRITE);
return domain_page_mapping(domain, base, base, size,
DMA_PTE_READ|DMA_PTE_WRITE);
}

static int iommu_prepare_identity_map(struct pci_dev *pdev,
unsigned long long start,
unsigned long long end)
{
struct dmar_domain *domain;
int ret;

printk(KERN_INFO
"IOMMU: Setting identity map for device %s [0x%Lx - 0x%Lx]\n",
pci_name(pdev), start, end);

if (iommu_identity_mapping)
domain = si_domain;
else
/* page table init */
domain = get_domain_for_dev(pdev, DEFAULT_DOMAIN_ADDRESS_WIDTH);
if (!domain)
return -ENOMEM;

ret = iommu_domain_identity_map(domain, start, end);
if (ret)
goto error;

/* context entry init */
ret = domain_context_mapping(domain, pdev, CONTEXT_TT_MULTI_LEVEL);
if (!ret)
return 0;
error:
if (ret)
goto error;

return 0;

error:
domain_exit(domain);
return ret;

}

static inline int iommu_prepare_rmrr_dev(struct dmar_rmrr_unit *rmrr,
Expand Down

0 comments on commit 0ef7290

Please sign in to comment.