···1487 struct protection_domain *domain)1488{1489 struct iommu_dev_data *dev_data, *alias_data;014901491 dev_data = get_dev_data(dev);1492 alias_data = get_dev_data(dev_data->alias);···1499 spin_lock(&domain->lock);15001501 /* Some sanity checks */01502 if (alias_data->domain != NULL &&1503 alias_data->domain != domain)1504- return -EBUSY;15051506 if (dev_data->domain != NULL &&1507 dev_data->domain != domain)1508- return -EBUSY;15091510 /* Do real assignment */1511 if (dev_data->alias != dev) {···15221523 atomic_inc(&dev_data->bind);152400001525 /* ready */1526 spin_unlock(&domain->lock);15271528- return 0;1529}15301531/*···23302331 iommu_detected = 1;2332 swiotlb = 0;2333-#ifdef CONFIG_GART_IOMMU2334- gart_iommu_aperture_disabled = 1;2335- gart_iommu_aperture = 0;2336-#endif23372338 /* Make the driver finally visible to the drivers */2339 dma_ops = &amd_iommu_dma_ops;
···1487 struct protection_domain *domain)1488{1489 struct iommu_dev_data *dev_data, *alias_data;1490+ int ret;14911492 dev_data = get_dev_data(dev);1493 alias_data = get_dev_data(dev_data->alias);···1498 spin_lock(&domain->lock);14991500 /* Some sanity checks */1501+ ret = -EBUSY;1502 if (alias_data->domain != NULL &&1503 alias_data->domain != domain)1504+ goto out_unlock;15051506 if (dev_data->domain != NULL &&1507 dev_data->domain != domain)1508+ goto out_unlock;15091510 /* Do real assignment */1511 if (dev_data->alias != dev) {···15201521 atomic_inc(&dev_data->bind);15221523+ ret = 0;1524+1525+out_unlock:1526+1527 /* ready */1528 spin_unlock(&domain->lock);15291530+ return ret;1531}15321533/*···23242325 iommu_detected = 1;2326 swiotlb = 0;000023272328 /* Make the driver finally visible to the drivers */2329 dma_ops = &amd_iommu_dma_ops;
+17-3
arch/x86/kernel/amd_iommu_init.c
···287{288 u8 *ret;289290- if (!request_mem_region(address, MMIO_REGION_LENGTH, "amd_iommu"))000291 return NULL;0292293 ret = ioremap_nocache(address, MMIO_REGION_LENGTH);294 if (ret != NULL)···1318 ret = amd_iommu_init_dma_ops();13191320 if (ret)1321- goto free;13221323 amd_iommu_init_api();1324···1336out:1337 return ret;13381339-free:1340 disable_iommus();134101342 amd_iommu_uninit_devices();13431344 free_pages((unsigned long)amd_iommu_pd_alloc_bitmap,···1357 free_iommu_all();13581359 free_unity_maps();00000000013601361 goto out;1362}
···287{288 u8 *ret;289290+ if (!request_mem_region(address, MMIO_REGION_LENGTH, "amd_iommu")) {291+ pr_err("AMD-Vi: Can not reserve memory region %llx for mmio\n",292+ address);293+ pr_err("AMD-Vi: This is a BIOS bug. Please contact your hardware vendor\n");294 return NULL;295+ }296297 ret = ioremap_nocache(address, MMIO_REGION_LENGTH);298 if (ret != NULL)···1314 ret = amd_iommu_init_dma_ops();13151316 if (ret)1317+ goto free_disable;13181319 amd_iommu_init_api();1320···1332out:1333 return ret;13341335+free_disable:1336 disable_iommus();13371338+free:1339 amd_iommu_uninit_devices();13401341 free_pages((unsigned long)amd_iommu_pd_alloc_bitmap,···1352 free_iommu_all();13531354 free_unity_maps();1355+1356+#ifdef CONFIG_GART_IOMMU1357+ /*1358+ * We failed to initialize the AMD IOMMU - try fallback to GART1359+ * if possible.1360+ */1361+ gart_iommu_init();1362+1363+#endif13641365 goto out;1366}