aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2012-07-02 10:02:20 -0400
committerJoerg Roedel <joerg.roedel@amd.com>2012-09-28 11:43:53 -0400
commitd04e0ba3432e3fa68bd779330e0f79a9d979bc5f (patch)
treebf79193c07648d6567a60f1d96e9686bc378d726 /drivers/iommu
parent6b474b8224cdb473f19e8c925171e608499cc45d (diff)
iommu/amd: Make sure irq remapping still works on dma init failure
Do not deinitialize the AMD IOMMU driver completly when interrupt remapping is already in use but the initialization of the DMA layer fails for some reason. Make sure the IOMMU can still be used to remap interrupts. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/amd_iommu_init.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index d536d24b6f34..fee872f666f5 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -1399,6 +1399,16 @@ static void init_device_table_dma(void)
1399 } 1399 }
1400} 1400}
1401 1401
1402static void __init uninit_device_table_dma(void)
1403{
1404 u32 devid;
1405
1406 for (devid = 0; devid <= amd_iommu_last_bdf; ++devid) {
1407 amd_iommu_dev_table[devid].data[0] = 0ULL;
1408 amd_iommu_dev_table[devid].data[1] = 0ULL;
1409 }
1410}
1411
1402static void init_device_table(void) 1412static void init_device_table(void)
1403{ 1413{
1404 u32 devid; 1414 u32 devid;
@@ -1567,11 +1577,6 @@ static void __init free_on_init_error(void)
1567 1577
1568 } 1578 }
1569 1579
1570 amd_iommu_uninit_devices();
1571
1572 free_pages((unsigned long)amd_iommu_pd_alloc_bitmap,
1573 get_order(MAX_DOMAIN_ID/8));
1574
1575 free_pages((unsigned long)amd_iommu_rlookup_table, 1580 free_pages((unsigned long)amd_iommu_rlookup_table,
1576 get_order(rlookup_table_size)); 1581 get_order(rlookup_table_size));
1577 1582
@@ -1583,8 +1588,6 @@ static void __init free_on_init_error(void)
1583 1588
1584 free_iommu_all(); 1589 free_iommu_all();
1585 1590
1586 free_unity_maps();
1587
1588#ifdef CONFIG_GART_IOMMU 1591#ifdef CONFIG_GART_IOMMU
1589 /* 1592 /*
1590 * We failed to initialize the AMD IOMMU - try fallback to GART 1593 * We failed to initialize the AMD IOMMU - try fallback to GART
@@ -1612,6 +1615,16 @@ static bool __init check_ioapic_information(void)
1612 return true; 1615 return true;
1613} 1616}
1614 1617
1618static void __init free_dma_resources(void)
1619{
1620 amd_iommu_uninit_devices();
1621
1622 free_pages((unsigned long)amd_iommu_pd_alloc_bitmap,
1623 get_order(MAX_DOMAIN_ID/8));
1624
1625 free_unity_maps();
1626}
1627
1615/* 1628/*
1616 * This is the hardware init function for AMD IOMMU in the system. 1629 * This is the hardware init function for AMD IOMMU in the system.
1617 * This function is called either from amd_iommu_init or from the interrupt 1630 * This function is called either from amd_iommu_init or from the interrupt
@@ -1952,8 +1965,17 @@ static int __init amd_iommu_init(void)
1952 1965
1953 ret = iommu_go_to_state(IOMMU_INITIALIZED); 1966 ret = iommu_go_to_state(IOMMU_INITIALIZED);
1954 if (ret) { 1967 if (ret) {
1955 disable_iommus(); 1968 free_dma_resources();
1956 free_on_init_error(); 1969 if (!irq_remapping_enabled) {
1970 disable_iommus();
1971 free_on_init_error();
1972 } else {
1973 struct amd_iommu *iommu;
1974
1975 uninit_device_table_dma();
1976 for_each_iommu(iommu)
1977 iommu_flush_all_caches(iommu);
1978 }
1957 } 1979 }
1958 1980
1959 return ret; 1981 return ret;