Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158094
b: refs/heads/master
c: 8bc3e12
h: refs/heads/master
v: v3
  • Loading branch information
Joerg Roedel committed Sep 3, 2009
1 parent a1c23e7 commit 0e2ef32
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 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: 50020fb6324465e478d6c8cdbf3c695f0a60358d
refs/heads/master: 8bc3e127421bf3b735edbde05135892c12c5f615
44 changes: 20 additions & 24 deletions trunk/arch/x86/kernel/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct iommu_cmd {
static int dma_ops_unity_map(struct dma_ops_domain *dma_dom,
struct unity_map_entry *e);
static struct dma_ops_domain *find_protection_domain(u16 devid);
static u64* alloc_pte(struct protection_domain *dom,
static u64 *alloc_pte(struct protection_domain *domain,
unsigned long address, u64
**pte_page, gfp_t gfp);
static void dma_ops_reserve_addresses(struct dma_ops_domain *dom,
Expand Down Expand Up @@ -1351,39 +1351,35 @@ static bool increase_address_space(struct protection_domain *domain,
return true;
}

/*
* If the pte_page is not yet allocated this function is called
*/
static u64* alloc_pte(struct protection_domain *dom,
static u64 *alloc_pte(struct protection_domain *domain,
unsigned long address, u64 **pte_page, gfp_t gfp)
{
u64 *pte, *page;
int level;

pte = &dom->pt_root[IOMMU_PTE_L2_INDEX(address)];
while (address > PM_LEVEL_SIZE(domain->mode))
increase_address_space(domain, gfp);

if (!IOMMU_PTE_PRESENT(*pte)) {
page = (u64 *)get_zeroed_page(gfp);
if (!page)
return NULL;
*pte = IOMMU_L2_PDE(virt_to_phys(page));
}
level = domain->mode - 1;
pte = &domain->pt_root[PM_LEVEL_INDEX(level, address)];

pte = IOMMU_PTE_PAGE(*pte);
pte = &pte[IOMMU_PTE_L1_INDEX(address)];
while (level > 0) {
if (!IOMMU_PTE_PRESENT(*pte)) {
page = (u64 *)get_zeroed_page(gfp);
if (!page)
return NULL;
*pte = PM_LEVEL_PDE(level, virt_to_phys(page));
}

if (!IOMMU_PTE_PRESENT(*pte)) {
page = (u64 *)get_zeroed_page(gfp);
if (!page)
return NULL;
*pte = IOMMU_L1_PDE(virt_to_phys(page));
}
level -= 1;

pte = IOMMU_PTE_PAGE(*pte);
pte = IOMMU_PTE_PAGE(*pte);

if (pte_page)
*pte_page = pte;
if (pte_page && level == 0)
*pte_page = pte;

pte = &pte[IOMMU_PTE_L0_INDEX(address)];
pte = &pte[PM_LEVEL_INDEX(level, address)];
}

return pte;
}
Expand Down

0 comments on commit 0e2ef32

Please sign in to comment.