aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/amd_iommu.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kernel/amd_iommu.c')
-rw-r--r--arch/x86/kernel/amd_iommu.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index cd8cbeb5fa34..b2c309b07427 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -30,6 +30,7 @@
30#include <asm/proto.h> 30#include <asm/proto.h>
31#include <asm/iommu.h> 31#include <asm/iommu.h>
32#include <asm/gart.h> 32#include <asm/gart.h>
33#include <asm/dma.h>
33#include <asm/amd_iommu_proto.h> 34#include <asm/amd_iommu_proto.h>
34#include <asm/amd_iommu_types.h> 35#include <asm/amd_iommu_types.h>
35#include <asm/amd_iommu.h> 36#include <asm/amd_iommu.h>
@@ -2383,6 +2384,23 @@ static struct dma_map_ops amd_iommu_dma_ops = {
2383 .dma_supported = amd_iommu_dma_supported, 2384 .dma_supported = amd_iommu_dma_supported,
2384}; 2385};
2385 2386
2387static unsigned device_dma_ops_init(void)
2388{
2389 struct pci_dev *pdev = NULL;
2390 unsigned unhandled = 0;
2391
2392 for_each_pci_dev(pdev) {
2393 if (!check_device(&pdev->dev)) {
2394 unhandled += 1;
2395 continue;
2396 }
2397
2398 pdev->dev.archdata.dma_ops = &amd_iommu_dma_ops;
2399 }
2400
2401 return unhandled;
2402}
2403
2386/* 2404/*
2387 * The function which clues the AMD IOMMU driver into dma_ops. 2405 * The function which clues the AMD IOMMU driver into dma_ops.
2388 */ 2406 */
@@ -2395,7 +2413,7 @@ void __init amd_iommu_init_api(void)
2395int __init amd_iommu_init_dma_ops(void) 2413int __init amd_iommu_init_dma_ops(void)
2396{ 2414{
2397 struct amd_iommu *iommu; 2415 struct amd_iommu *iommu;
2398 int ret; 2416 int ret, unhandled;
2399 2417
2400 /* 2418 /*
2401 * first allocate a default protection domain for every IOMMU we 2419 * first allocate a default protection domain for every IOMMU we
@@ -2421,7 +2439,11 @@ int __init amd_iommu_init_dma_ops(void)
2421 swiotlb = 0; 2439 swiotlb = 0;
2422 2440
2423 /* Make the driver finally visible to the drivers */ 2441 /* Make the driver finally visible to the drivers */
2424 dma_ops = &amd_iommu_dma_ops; 2442 unhandled = device_dma_ops_init();
2443 if (unhandled && max_pfn > MAX_DMA32_PFN) {
2444 /* There are unhandled devices - initialize swiotlb for them */
2445 swiotlb = 1;
2446 }
2425 2447
2426 amd_iommu_stats_init(); 2448 amd_iommu_stats_init();
2427 2449