Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 189939
b: refs/heads/master
c: 5d214fe
h: refs/heads/master
i:
  189937: 0d7e81c
  189935: a75656c
v: v3
  • Loading branch information
Joerg Roedel committed Mar 1, 2010
1 parent 43a4385 commit fcc6d47
Show file tree
Hide file tree
Showing 3 changed files with 12 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: 339d3261aa3eb0e12f68ef868e042c1ca03628f7
refs/heads/master: 5d214fe6e808a8caa9cb6f610c0190d3f50ac570
2 changes: 2 additions & 0 deletions trunk/arch/x86/include/asm/amd_iommu_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define _ASM_X86_AMD_IOMMU_TYPES_H

#include <linux/types.h>
#include <linux/mutex.h>
#include <linux/list.h>
#include <linux/spinlock.h>

Expand Down Expand Up @@ -237,6 +238,7 @@ struct protection_domain {
struct list_head list; /* for list of all protection domains */
struct list_head dev_list; /* List of all devices in this domain */
spinlock_t lock; /* mostly used to lock the page table*/
struct mutex api_lock; /* protect page tables in the iommu-api path */
u16 id; /* the domain id written to the device table */
int mode; /* paging mode (0-6 levels) */
u64 *pt_root; /* page table root pointer */
Expand Down
9 changes: 9 additions & 0 deletions trunk/arch/x86/kernel/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2327,6 +2327,7 @@ static struct protection_domain *protection_domain_alloc(void)
return NULL;

spin_lock_init(&domain->lock);
mutex_init(&domain->api_lock);
domain->id = domain_id_alloc();
if (!domain->id)
goto out_err;
Expand Down Expand Up @@ -2456,6 +2457,8 @@ static int amd_iommu_map_range(struct iommu_domain *dom,
iova &= PAGE_MASK;
paddr &= PAGE_MASK;

mutex_lock(&domain->api_lock);

for (i = 0; i < npages; ++i) {
ret = iommu_map_page(domain, iova, paddr, prot, PM_MAP_4k);
if (ret)
Expand All @@ -2465,6 +2468,8 @@ static int amd_iommu_map_range(struct iommu_domain *dom,
paddr += PAGE_SIZE;
}

mutex_unlock(&domain->api_lock);

return 0;
}

Expand All @@ -2477,12 +2482,16 @@ static void amd_iommu_unmap_range(struct iommu_domain *dom,

iova &= PAGE_MASK;

mutex_lock(&domain->api_lock);

for (i = 0; i < npages; ++i) {
iommu_unmap_page(domain, iova, PM_MAP_4k);
iova += PAGE_SIZE;
}

iommu_flush_tlb_pde(domain);

mutex_unlock(&domain->api_lock);
}

static phys_addr_t amd_iommu_iova_to_phys(struct iommu_domain *dom,
Expand Down

0 comments on commit fcc6d47

Please sign in to comment.