aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/amd_iommu.c
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2009-09-02 10:07:00 -0400
committerJoerg Roedel <joerg.roedel@amd.com>2009-09-03 10:03:44 -0400
commit407d733e30a97daf5ea6f9eb5f9ebbd42a0a9ef2 (patch)
tree5b99eb040f2a260feaf047d380d92dd214957d06 /arch/x86/kernel/amd_iommu.c
parent6a0dbcbe4e612fbc9d73cd4dde8ebef19295058a (diff)
x86/amd-iommu: Introduce set_dte_entry function
This function factors out some logic of attach_device to a seperate function. This new function will be used to update device table entries when necessary. 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.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 5265dd17eb5c..0fab1f1d135e 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -1058,18 +1058,10 @@ static struct protection_domain *domain_for_device(u16 devid)
1058 return dom; 1058 return dom;
1059} 1059}
1060 1060
1061/* 1061static void set_dte_entry(u16 devid, struct protection_domain *domain)
1062 * If a device is not yet associated with a domain, this function does
1063 * assigns it visible for the hardware
1064 */
1065static void attach_device(struct amd_iommu *iommu,
1066 struct protection_domain *domain,
1067 u16 devid)
1068{ 1062{
1069 unsigned long flags;
1070 u64 pte_root = virt_to_phys(domain->pt_root); 1063 u64 pte_root = virt_to_phys(domain->pt_root);
1071 1064 unsigned long flags;
1072 domain->dev_cnt += 1;
1073 1065
1074 pte_root |= (domain->mode & DEV_ENTRY_MODE_MASK) 1066 pte_root |= (domain->mode & DEV_ENTRY_MODE_MASK)
1075 << DEV_ENTRY_MODE_SHIFT; 1067 << DEV_ENTRY_MODE_SHIFT;
@@ -1082,6 +1074,21 @@ static void attach_device(struct amd_iommu *iommu,
1082 1074
1083 amd_iommu_pd_table[devid] = domain; 1075 amd_iommu_pd_table[devid] = domain;
1084 write_unlock_irqrestore(&amd_iommu_devtable_lock, flags); 1076 write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
1077}
1078
1079/*
1080 * If a device is not yet associated with a domain, this function does
1081 * assigns it visible for the hardware
1082 */
1083static void attach_device(struct amd_iommu *iommu,
1084 struct protection_domain *domain,
1085 u16 devid)
1086{
1087 /* set the DTE entry */
1088 set_dte_entry(devid, domain);
1089
1090 /* increase reference counter */
1091 domain->dev_cnt += 1;
1085 1092
1086 /* 1093 /*
1087 * We might boot into a crash-kernel here. The crashed kernel 1094 * We might boot into a crash-kernel here. The crashed kernel