Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158092
b: refs/heads/master
c: 04bfdd8
h: refs/heads/master
v: v3
  • Loading branch information
Joerg Roedel committed Sep 3, 2009
1 parent 688f8bb commit 8a28279
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 407d733e30a97daf5ea6f9eb5f9ebbd42a0a9ef2
refs/heads/master: 04bfdd8406099fca2e6b8844748c4d6c5eba8c8d
1 change: 1 addition & 0 deletions trunk/arch/x86/include/asm/amd_iommu_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ struct protection_domain {
int mode; /* paging mode (0-6 levels) */
u64 *pt_root; /* page table root pointer */
unsigned long flags; /* flags to find out type of domain */
bool updated; /* complete domain flush required */
unsigned dev_cnt; /* devices assigned to this domain */
void *priv; /* private data */
};
Expand Down
32 changes: 32 additions & 0 deletions trunk/arch/x86/kernel/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ static void dma_ops_reserve_addresses(struct dma_ops_domain *dom,
unsigned int pages);
static u64 *fetch_pte(struct protection_domain *domain,
unsigned long address);
static void update_domain(struct protection_domain *domain);

#ifndef BUS_NOTIFY_UNBOUND_DRIVER
#define BUS_NOTIFY_UNBOUND_DRIVER 0x0005
Expand Down Expand Up @@ -546,6 +547,8 @@ static int iommu_map_page(struct protection_domain *dom,

*pte = __pte;

update_domain(dom);

return 0;
}

Expand Down Expand Up @@ -762,9 +765,13 @@ static int alloc_new_range(struct amd_iommu *iommu,
dma_ops_reserve_addresses(dma_dom, i << PAGE_SHIFT, 1);
}

update_domain(&dma_dom->domain);

return 0;

out_free:
update_domain(&dma_dom->domain);

free_page((unsigned long)dma_dom->aperture[index]->bitmap);

kfree(dma_dom->aperture[index]);
Expand Down Expand Up @@ -1294,6 +1301,29 @@ static int get_device_resources(struct device *dev,
return 1;
}

static void update_device_table(struct protection_domain *domain)
{
int i;

for (i = 0; i <= amd_iommu_last_bdf; ++i) {
if (amd_iommu_pd_table[i] != domain)
continue;
set_dte_entry(i, domain);
}
}

static void update_domain(struct protection_domain *domain)
{
if (!domain->updated)
return;

update_device_table(domain);
flush_devices_by_domain(domain);
iommu_flush_domain(domain->id);

domain->updated = false;
}

/*
* If the pte_page is not yet allocated this function is called
*/
Expand Down Expand Up @@ -1351,6 +1381,8 @@ static u64* dma_ops_get_pte(struct dma_ops_domain *dom,
} else
pte += IOMMU_PTE_L0_INDEX(address);

update_domain(&dom->domain);

return pte;
}

Expand Down

0 comments on commit 8a28279

Please sign in to comment.