aboutsummaryrefslogtreecommitdiff
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2009-11-20 14:57:32 +0100
committerJoerg Roedel <joerg.roedel@amd.com>2009-11-27 11:45:50 +0100
commitc459611424d8b8396060eb766e23bd0c70c993bc (patch)
tree2c15dda4d4eda490b8593aba5f29b3e1df7d2878 /arch/x86/kernel
parentbb52777ec4d736c2d7c4f037b32d4eeeb172ed89 (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')
-rw-r--r--arch/x86/kernel/amd_iommu.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 7fe28be3b54..8c38f008540 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,
/* update DTE entry */
set_dte_entry(devid, domain);
- domain->dev_cnt += 1;
+ /* Do reference counting */
+ domain->dev_iommu[iommu->index] += 1;
+ domain->dev_cnt += 1;
/* ready */
spin_unlock(&domain->lock);
@@ -1209,6 +1211,9 @@ static void attach_device(struct amd_iommu *iommu,
*/
static void __detach_device(struct protection_domain *domain, u16 devid)
{
+ struct amd_iommu *iommu = amd_iommu_rlookup_table[devid];
+
+ BUG_ON(!iommu);
/* lock domain */
spin_lock(&domain->lock);
@@ -1223,8 +1228,9 @@ static void __detach_device(struct protection_domain *domain, u16 devid)
amd_iommu_apply_erratum_63(devid);
- /* decrease reference counter */
- domain->dev_cnt -= 1;
+ /* decrease reference counters */
+ domain->dev_iommu[iommu->index] -= 1;
+ domain->dev_cnt -= 1;
/* ready */
spin_unlock(&domain->lock);