aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2008-12-08 06:02:41 -0500
committerJoerg Roedel <joerg.roedel@amd.com>2009-01-03 08:11:55 -0500
commit355bf553edb7fe21ada51f62c849180bec6da877 (patch)
tree64c0c55bd838aa70b5395ea566b23e6b744d9780 /arch
parentf1179dc005ee2b0e55c3f74f3552c3e9ef852265 (diff)
AMD IOMMU: add device detach helper functions
Impact: add helper functions to detach a device from a domain Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/amd_iommu.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 12e8b67e5881..15456a3a18c8 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -844,6 +844,45 @@ static void attach_device(struct amd_iommu *iommu,
844 iommu_queue_inv_dev_entry(iommu, devid); 844 iommu_queue_inv_dev_entry(iommu, devid);
845} 845}
846 846
847#ifdef CONFIG_IOMMU_API
848/*
849 * Removes a device from a protection domain (unlocked)
850 */
851static void __detach_device(struct protection_domain *domain, u16 devid)
852{
853
854 /* lock domain */
855 spin_lock(&domain->lock);
856
857 /* remove domain from the lookup table */
858 amd_iommu_pd_table[devid] = NULL;
859
860 /* remove entry from the device table seen by the hardware */
861 amd_iommu_dev_table[devid].data[0] = IOMMU_PTE_P | IOMMU_PTE_TV;
862 amd_iommu_dev_table[devid].data[1] = 0;
863 amd_iommu_dev_table[devid].data[2] = 0;
864
865 /* decrease reference counter */
866 domain->dev_cnt -= 1;
867
868 /* ready */
869 spin_unlock(&domain->lock);
870}
871
872/*
873 * Removes a device from a protection domain (with devtable_lock held)
874 */
875static void detach_device(struct protection_domain *domain, u16 devid)
876{
877 unsigned long flags;
878
879 /* lock device table */
880 write_lock_irqsave(&amd_iommu_devtable_lock, flags);
881 __detach_device(domain, devid);
882 write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
883}
884#endif
885
847/***************************************************************************** 886/*****************************************************************************
848 * 887 *
849 * The next functions belong to the dma_ops mapping/unmapping code. 888 * The next functions belong to the dma_ops mapping/unmapping code.