diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2009-11-20 08:57:32 -0500 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2009-11-27 05:45:50 -0500 |
commit | c459611424d8b8396060eb766e23bd0c70c993bc (patch) | |
tree | 2c15dda4d4eda490b8593aba5f29b3e1df7d2878 /arch/x86/kernel/amd_iommu.c | |
parent | bb52777ec4d736c2d7c4f037b32d4eeeb172ed89 (diff) |
x86/amd-iommu: Add per IOMMU reference counting
This patch adds reference counting for protection domains
per IOMMU. This allows a smarter TLB flushing strategy.
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.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c index 7fe28be3b548..8c38f0085403 100644 --- a/arch/x86/kernel/amd_iommu.c +++ b/arch/x86/kernel/amd_iommu.c | |||
@@ -1175,7 +1175,9 @@ static void __attach_device(struct amd_iommu *iommu, | |||
1175 | /* update DTE entry */ | 1175 | /* update DTE entry */ |
1176 | set_dte_entry(devid, domain); | 1176 | set_dte_entry(devid, domain); |
1177 | 1177 | ||
1178 | domain->dev_cnt += 1; | 1178 | /* Do reference counting */ |
1179 | domain->dev_iommu[iommu->index] += 1; | ||
1180 | domain->dev_cnt += 1; | ||
1179 | 1181 | ||
1180 | /* ready */ | 1182 | /* ready */ |
1181 | spin_unlock(&domain->lock); | 1183 | spin_unlock(&domain->lock); |
@@ -1209,6 +1211,9 @@ static void attach_device(struct amd_iommu *iommu, | |||
1209 | */ | 1211 | */ |
1210 | static void __detach_device(struct protection_domain *domain, u16 devid) | 1212 | static void __detach_device(struct protection_domain *domain, u16 devid) |
1211 | { | 1213 | { |
1214 | struct amd_iommu *iommu = amd_iommu_rlookup_table[devid]; | ||
1215 | |||
1216 | BUG_ON(!iommu); | ||
1212 | 1217 | ||
1213 | /* lock domain */ | 1218 | /* lock domain */ |
1214 | spin_lock(&domain->lock); | 1219 | spin_lock(&domain->lock); |
@@ -1223,8 +1228,9 @@ static void __detach_device(struct protection_domain *domain, u16 devid) | |||
1223 | 1228 | ||
1224 | amd_iommu_apply_erratum_63(devid); | 1229 | amd_iommu_apply_erratum_63(devid); |
1225 | 1230 | ||
1226 | /* decrease reference counter */ | 1231 | /* decrease reference counters */ |
1227 | domain->dev_cnt -= 1; | 1232 | domain->dev_iommu[iommu->index] -= 1; |
1233 | domain->dev_cnt -= 1; | ||
1228 | 1234 | ||
1229 | /* ready */ | 1235 | /* ready */ |
1230 | spin_unlock(&domain->lock); | 1236 | spin_unlock(&domain->lock); |