aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/amd_iommu.c
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2009-11-24 10:43:06 -0500
committerJoerg Roedel <joerg.roedel@amd.com>2009-11-27 08:20:28 -0500
commit71c70984e5afc20d304fbb523f1c8bb42c4ceb36 (patch)
tree37a5d835a81bb7d3a264ebcd3168094cfff3c702 /arch/x86/kernel/amd_iommu.c
parent94f6d190eeed91cb2bb901aa7816edd1e2405347 (diff)
x86/amd-iommu: Move find_protection_domain to helper functions
This is a helper function and when its placed in the helper function section we can remove its forward declaration. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'arch/x86/kernel/amd_iommu.c')
-rw-r--r--arch/x86/kernel/amd_iommu.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index e5bbe9a0c192..405f8dad7c77 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -59,7 +59,6 @@ struct iommu_cmd {
59 59
60static int dma_ops_unity_map(struct dma_ops_domain *dma_dom, 60static int dma_ops_unity_map(struct dma_ops_domain *dma_dom,
61 struct unity_map_entry *e); 61 struct unity_map_entry *e);
62static struct dma_ops_domain *find_protection_domain(u16 devid);
63static u64 *alloc_pte(struct protection_domain *domain, 62static u64 *alloc_pte(struct protection_domain *domain,
64 unsigned long address, int end_lvl, 63 unsigned long address, int end_lvl,
65 u64 **pte_page, gfp_t gfp); 64 u64 **pte_page, gfp_t gfp);
@@ -84,6 +83,34 @@ static inline u16 get_device_id(struct device *dev)
84 return calc_devid(pdev->bus->number, pdev->devfn); 83 return calc_devid(pdev->bus->number, pdev->devfn);
85} 84}
86 85
86/*
87 * In this function the list of preallocated protection domains is traversed to
88 * find the domain for a specific device
89 */
90static struct dma_ops_domain *find_protection_domain(u16 devid)
91{
92 struct dma_ops_domain *entry, *ret = NULL;
93 unsigned long flags;
94 u16 alias = amd_iommu_alias_table[devid];
95
96 if (list_empty(&iommu_pd_list))
97 return NULL;
98
99 spin_lock_irqsave(&iommu_pd_list_lock, flags);
100
101 list_for_each_entry(entry, &iommu_pd_list, list) {
102 if (entry->target_dev == devid ||
103 entry->target_dev == alias) {
104 ret = entry;
105 break;
106 }
107 }
108
109 spin_unlock_irqrestore(&iommu_pd_list_lock, flags);
110
111 return ret;
112}
113
87#ifdef CONFIG_AMD_IOMMU_STATS 114#ifdef CONFIG_AMD_IOMMU_STATS
88 115
89/* 116/*
@@ -1456,34 +1483,6 @@ static bool check_device(struct device *dev)
1456} 1483}
1457 1484
1458/* 1485/*
1459 * In this function the list of preallocated protection domains is traversed to
1460 * find the domain for a specific device
1461 */
1462static struct dma_ops_domain *find_protection_domain(u16 devid)
1463{
1464 struct dma_ops_domain *entry, *ret = NULL;
1465 unsigned long flags;
1466 u16 alias = amd_iommu_alias_table[devid];
1467
1468 if (list_empty(&iommu_pd_list))
1469 return NULL;
1470
1471 spin_lock_irqsave(&iommu_pd_list_lock, flags);
1472
1473 list_for_each_entry(entry, &iommu_pd_list, list) {
1474 if (entry->target_dev == devid ||
1475 entry->target_dev == alias) {
1476 ret = entry;
1477 break;
1478 }
1479 }
1480
1481 spin_unlock_irqrestore(&iommu_pd_list_lock, flags);
1482
1483 return ret;
1484}
1485
1486/*
1487 * In the dma_ops path we only have the struct device. This function 1486 * In the dma_ops path we only have the struct device. This function
1488 * finds the corresponding IOMMU, the protection domain and the 1487 * finds the corresponding IOMMU, the protection domain and the
1489 * requestor id for a given device. 1488 * requestor id for a given device.