Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 154783
b: refs/heads/master
c: 6f6a00e
h: refs/heads/master
i:
  154781: 5ec2a3d
  154779: 2dbfa97
  154775: 93e197f
  154767: 491d4c7
  154751: 5d4bc1d
v: v3
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Jun 29, 2009
1 parent f327672 commit 3e86c75
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 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: 310a5ab93cb4ce29367238f682affd9ac352f4d0
refs/heads/master: 6f6a00e40aa3fdd3b29c30e3ef1fc9690506bc03
26 changes: 17 additions & 9 deletions trunk/drivers/pci/intel-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1639,27 +1639,35 @@ static int domain_pfn_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
unsigned long phys_pfn, unsigned long nr_pages,
int prot)
{
struct dma_pte *pte;
struct dma_pte *first_pte = NULL, *pte = NULL;
int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT;

BUG_ON(addr_width < BITS_PER_LONG && (iov_pfn + nr_pages - 1) >> addr_width);

if ((prot & (DMA_PTE_READ|DMA_PTE_WRITE)) == 0)
return -EINVAL;

prot &= DMA_PTE_READ | DMA_PTE_WRITE | DMA_PTE_SNP;

while (nr_pages--) {
pte = pfn_to_dma_pte(domain, iov_pfn);
if (!pte)
return -ENOMEM;
if (!pte) {
first_pte = pte = pfn_to_dma_pte(domain, iov_pfn);
if (!pte)
return -ENOMEM;
}
/* We don't need lock here, nobody else
* touches the iova range
*/
BUG_ON(dma_pte_addr(pte));
dma_set_pte_pfn(pte, phys_pfn);
dma_set_pte_prot(pte, prot);
if (prot & DMA_PTE_SNP)
dma_set_pte_snp(pte);
domain_flush_cache(domain, pte, sizeof(*pte));
pte->val = (phys_pfn << VTD_PAGE_SHIFT) | prot;
pte++;
if (!nr_pages ||
(unsigned long)pte >> VTD_PAGE_SHIFT !=
(unsigned long)first_pte >> VTD_PAGE_SHIFT) {
domain_flush_cache(domain, first_pte,
(void *)pte - (void *)first_pte);
pte = NULL;
}
iov_pfn++;
phys_pfn++;
}
Expand Down

0 comments on commit 3e86c75

Please sign in to comment.