aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2010-08-26 13:57:57 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2010-08-26 18:13:13 -0400
commit480125ba49ba62be93beea37770f266846e077ab (patch)
tree6e4437d77e352f5b03d1e00171bd77086378b01a
parent0444ad93ea2449963132d68753020a6a24d69895 (diff)
x86, iommu: Make all IOMMU's detection routines return a value.
We return 1 if the IOMMU has been detected. Zero or an error number if we failed to find it. This is in preperation of using the IOMMU_INIT so that we can detect whether an IOMMU is present. I have not tested this for regression on Calgary, nor on AMD Vi chipsets as I don't have that hardware. CC: Muli Ben-Yehuda <muli@il.ibm.com> CC: "Jon D. Mason" <jdmason@kudzu.us> CC: "Darrick J. Wong" <djwong@us.ibm.com> CC: Jesse Barnes <jbarnes@virtuousgeek.org> CC: David Woodhouse <David.Woodhouse@intel.com> CC: Chris Wright <chrisw@sous-sol.org> CC: Yinghai Lu <yinghai@kernel.org> CC: Joerg Roedel <joerg.roedel@amd.com> CC: H. Peter Anvin <hpa@zytor.com> CC: Fujita Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> LKML-Reference: <1282845485-8991-3-git-send-email-konrad.wilk@oracle.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--arch/x86/include/asm/amd_iommu.h4
-rw-r--r--arch/x86/include/asm/calgary.h4
-rw-r--r--arch/x86/include/asm/gart.h5
-rw-r--r--arch/x86/kernel/amd_iommu_init.c8
-rw-r--r--arch/x86/kernel/aperture_64.c11
-rw-r--r--arch/x86/kernel/pci-calgary_64.c15
-rw-r--r--drivers/pci/dmar.c4
-rw-r--r--include/linux/dmar.h6
8 files changed, 33 insertions, 24 deletions
diff --git a/arch/x86/include/asm/amd_iommu.h b/arch/x86/include/asm/amd_iommu.h
index 5af2982133b..2798142cdb4 100644
--- a/arch/x86/include/asm/amd_iommu.h
+++ b/arch/x86/include/asm/amd_iommu.h
@@ -24,11 +24,11 @@
24 24
25#ifdef CONFIG_AMD_IOMMU 25#ifdef CONFIG_AMD_IOMMU
26 26
27extern void amd_iommu_detect(void); 27extern int amd_iommu_detect(void);
28 28
29#else 29#else
30 30
31static inline void amd_iommu_detect(void) { } 31static inline int amd_iommu_detect(void) { return -ENODEV; }
32 32
33#endif 33#endif
34 34
diff --git a/arch/x86/include/asm/calgary.h b/arch/x86/include/asm/calgary.h
index 0918654305a..0d467b33883 100644
--- a/arch/x86/include/asm/calgary.h
+++ b/arch/x86/include/asm/calgary.h
@@ -62,9 +62,9 @@ struct cal_chipset_ops {
62extern int use_calgary; 62extern int use_calgary;
63 63
64#ifdef CONFIG_CALGARY_IOMMU 64#ifdef CONFIG_CALGARY_IOMMU
65extern void detect_calgary(void); 65extern int detect_calgary(void);
66#else 66#else
67static inline void detect_calgary(void) { return; } 67static inline int detect_calgary(void) { return -ENODEV; }
68#endif 68#endif
69 69
70#endif /* _ASM_X86_CALGARY_H */ 70#endif /* _ASM_X86_CALGARY_H */
diff --git a/arch/x86/include/asm/gart.h b/arch/x86/include/asm/gart.h
index 4ac5b0f33fc..d7d1d4c438a 100644
--- a/arch/x86/include/asm/gart.h
+++ b/arch/x86/include/asm/gart.h
@@ -37,7 +37,7 @@ extern int gart_iommu_aperture_disabled;
37extern void early_gart_iommu_check(void); 37extern void early_gart_iommu_check(void);
38extern int gart_iommu_init(void); 38extern int gart_iommu_init(void);
39extern void __init gart_parse_options(char *); 39extern void __init gart_parse_options(char *);
40extern void gart_iommu_hole_init(void); 40extern int gart_iommu_hole_init(void);
41 41
42#else 42#else
43#define gart_iommu_aperture 0 43#define gart_iommu_aperture 0
@@ -50,8 +50,9 @@ static inline void early_gart_iommu_check(void)
50static inline void gart_parse_options(char *options) 50static inline void gart_parse_options(char *options)
51{ 51{
52} 52}
53static inline void gart_iommu_hole_init(void) 53static inline int gart_iommu_hole_init(void)
54{ 54{
55 return -ENODEV;
55} 56}
56#endif 57#endif
57 58
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index 3cc63e2b8dd..0b9e2dc4fc9 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -1382,13 +1382,13 @@ static int __init early_amd_iommu_detect(struct acpi_table_header *table)
1382 return 0; 1382 return 0;
1383} 1383}
1384 1384
1385void __init amd_iommu_detect(void) 1385int __init amd_iommu_detect(void)
1386{ 1386{
1387 if (no_iommu || (iommu_detected && !gart_iommu_aperture)) 1387 if (no_iommu || (iommu_detected && !gart_iommu_aperture))
1388 return; 1388 return -ENODEV;
1389 1389
1390 if (amd_iommu_disabled) 1390 if (amd_iommu_disabled)
1391 return; 1391 return -ENODEV;
1392 1392
1393 if (acpi_table_parse("IVRS", early_amd_iommu_detect) == 0) { 1393 if (acpi_table_parse("IVRS", early_amd_iommu_detect) == 0) {
1394 iommu_detected = 1; 1394 iommu_detected = 1;
@@ -1397,7 +1397,9 @@ void __init amd_iommu_detect(void)
1397 1397
1398 /* Make sure ACS will be enabled */ 1398 /* Make sure ACS will be enabled */
1399 pci_request_acs(); 1399 pci_request_acs();
1400 return 1;
1400 } 1401 }
1402 return -ENODEV;
1401} 1403}
1402 1404
1403/**************************************************************************** 1405/****************************************************************************
diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c
index a2e0caf26e1..afa0dab3302 100644
--- a/arch/x86/kernel/aperture_64.c
+++ b/arch/x86/kernel/aperture_64.c
@@ -371,7 +371,7 @@ void __init early_gart_iommu_check(void)
371 371
372static int __initdata printed_gart_size_msg; 372static int __initdata printed_gart_size_msg;
373 373
374void __init gart_iommu_hole_init(void) 374int __init gart_iommu_hole_init(void)
375{ 375{
376 u32 agp_aper_base = 0, agp_aper_order = 0; 376 u32 agp_aper_base = 0, agp_aper_order = 0;
377 u32 aper_size, aper_alloc = 0, aper_order = 0, last_aper_order = 0; 377 u32 aper_size, aper_alloc = 0, aper_order = 0, last_aper_order = 0;
@@ -381,7 +381,7 @@ void __init gart_iommu_hole_init(void)
381 381
382 if (gart_iommu_aperture_disabled || !fix_aperture || 382 if (gart_iommu_aperture_disabled || !fix_aperture ||
383 !early_pci_allowed()) 383 !early_pci_allowed())
384 return; 384 return -ENODEV;
385 385
386 printk(KERN_INFO "Checking aperture...\n"); 386 printk(KERN_INFO "Checking aperture...\n");
387 387
@@ -463,8 +463,9 @@ out:
463 unsigned long n = (32 * 1024 * 1024) << last_aper_order; 463 unsigned long n = (32 * 1024 * 1024) << last_aper_order;
464 464
465 insert_aperture_resource((u32)last_aper_base, n); 465 insert_aperture_resource((u32)last_aper_base, n);
466 return 1;
466 } 467 }
467 return; 468 return 0;
468 } 469 }
469 470
470 if (!fallback_aper_force) { 471 if (!fallback_aper_force) {
@@ -500,7 +501,7 @@ out:
500 panic("Not enough memory for aperture"); 501 panic("Not enough memory for aperture");
501 } 502 }
502 } else { 503 } else {
503 return; 504 return 0;
504 } 505 }
505 506
506 /* Fix up the north bridges */ 507 /* Fix up the north bridges */
@@ -524,4 +525,6 @@ out:
524 } 525 }
525 526
526 set_up_gart_resume(aper_order, aper_alloc); 527 set_up_gart_resume(aper_order, aper_alloc);
528
529 return 1;
527} 530}
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 078d4ec1a9d..28c6b389fee 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -1364,7 +1364,7 @@ static int __init calgary_iommu_init(void)
1364 return 0; 1364 return 0;
1365} 1365}
1366 1366
1367void __init detect_calgary(void) 1367int __init detect_calgary(void)
1368{ 1368{
1369 int bus; 1369 int bus;
1370 void *tbl; 1370 void *tbl;
@@ -1378,13 +1378,13 @@ void __init detect_calgary(void)
1378 * another HW IOMMU already, bail out. 1378 * another HW IOMMU already, bail out.
1379 */ 1379 */
1380 if (no_iommu || iommu_detected) 1380 if (no_iommu || iommu_detected)
1381 return; 1381 return -ENODEV;
1382 1382
1383 if (!use_calgary) 1383 if (!use_calgary)
1384 return; 1384 return -ENODEV;
1385 1385
1386 if (!early_pci_allowed()) 1386 if (!early_pci_allowed())
1387 return; 1387 return -ENODEV;
1388 1388
1389 printk(KERN_DEBUG "Calgary: detecting Calgary via BIOS EBDA area\n"); 1389 printk(KERN_DEBUG "Calgary: detecting Calgary via BIOS EBDA area\n");
1390 1390
@@ -1410,13 +1410,13 @@ void __init detect_calgary(void)
1410 if (!rio_table_hdr) { 1410 if (!rio_table_hdr) {
1411 printk(KERN_DEBUG "Calgary: Unable to locate Rio Grande table " 1411 printk(KERN_DEBUG "Calgary: Unable to locate Rio Grande table "
1412 "in EBDA - bailing!\n"); 1412 "in EBDA - bailing!\n");
1413 return; 1413 return -ENODEV;
1414 } 1414 }
1415 1415
1416 ret = build_detail_arrays(); 1416 ret = build_detail_arrays();
1417 if (ret) { 1417 if (ret) {
1418 printk(KERN_DEBUG "Calgary: build_detail_arrays ret %d\n", ret); 1418 printk(KERN_DEBUG "Calgary: build_detail_arrays ret %d\n", ret);
1419 return; 1419 return -ENOMEM;
1420 } 1420 }
1421 1421
1422 specified_table_size = determine_tce_table_size((is_kdump_kernel() ? 1422 specified_table_size = determine_tce_table_size((is_kdump_kernel() ?
@@ -1464,7 +1464,7 @@ void __init detect_calgary(void)
1464 1464
1465 x86_init.iommu.iommu_init = calgary_iommu_init; 1465 x86_init.iommu.iommu_init = calgary_iommu_init;
1466 } 1466 }
1467 return; 1467 return calgary_found;
1468 1468
1469cleanup: 1469cleanup:
1470 for (--bus; bus >= 0; --bus) { 1470 for (--bus; bus >= 0; --bus) {
@@ -1473,6 +1473,7 @@ cleanup:
1473 if (info->tce_space) 1473 if (info->tce_space)
1474 free_tce_table(info->tce_space); 1474 free_tce_table(info->tce_space);
1475 } 1475 }
1476 return -ENOMEM;
1476} 1477}
1477 1478
1478static int __init calgary_parse_options(char *p) 1479static int __init calgary_parse_options(char *p)
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index 0a19708074c..5fa64ea5416 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -687,7 +687,7 @@ failed:
687 return 0; 687 return 0;
688} 688}
689 689
690void __init detect_intel_iommu(void) 690int __init detect_intel_iommu(void)
691{ 691{
692 int ret; 692 int ret;
693 693
@@ -723,6 +723,8 @@ void __init detect_intel_iommu(void)
723 } 723 }
724 early_acpi_os_unmap_memory(dmar_tbl, dmar_tbl_size); 724 early_acpi_os_unmap_memory(dmar_tbl, dmar_tbl_size);
725 dmar_tbl = NULL; 725 dmar_tbl = NULL;
726
727 return (ret ? 1 : -ENODEV);
726} 728}
727 729
728 730
diff --git a/include/linux/dmar.h b/include/linux/dmar.h
index d7cecc90ed3..a2060204151 100644
--- a/include/linux/dmar.h
+++ b/include/linux/dmar.h
@@ -57,15 +57,15 @@ extern int dmar_table_init(void);
57extern int dmar_dev_scope_init(void); 57extern int dmar_dev_scope_init(void);
58 58
59/* Intel IOMMU detection */ 59/* Intel IOMMU detection */
60extern void detect_intel_iommu(void); 60extern int detect_intel_iommu(void);
61extern int enable_drhd_fault_handling(void); 61extern int enable_drhd_fault_handling(void);
62 62
63extern int parse_ioapics_under_ir(void); 63extern int parse_ioapics_under_ir(void);
64extern int alloc_iommu(struct dmar_drhd_unit *); 64extern int alloc_iommu(struct dmar_drhd_unit *);
65#else 65#else
66static inline void detect_intel_iommu(void) 66static inline int detect_intel_iommu(void)
67{ 67{
68 return; 68 return -ENODEV;
69} 69}
70 70
71static inline int dmar_table_init(void) 71static inline int dmar_table_init(void)