Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 480125ba authored by Konrad Rzeszutek Wilk's avatar Konrad Rzeszutek Wilk Committed by H. Peter Anvin
Browse files

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: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
LKML-Reference: <1282845485-8991-3-git-send-email-konrad.wilk@oracle.com>
Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 0444ad93
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -24,11 +24,11 @@

#ifdef CONFIG_AMD_IOMMU

extern void amd_iommu_detect(void);
extern int amd_iommu_detect(void);

#else

static inline void amd_iommu_detect(void) { }
static inline int amd_iommu_detect(void) { return -ENODEV; }

#endif

+2 −2
Original line number Diff line number Diff line
@@ -62,9 +62,9 @@ struct cal_chipset_ops {
extern int use_calgary;

#ifdef CONFIG_CALGARY_IOMMU
extern void detect_calgary(void);
extern int detect_calgary(void);
#else
static inline void detect_calgary(void) { return; }
static inline int detect_calgary(void) { return -ENODEV; }
#endif

#endif /* _ASM_X86_CALGARY_H */
+3 −2
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ extern int gart_iommu_aperture_disabled;
extern void early_gart_iommu_check(void);
extern int gart_iommu_init(void);
extern void __init gart_parse_options(char *);
extern void gart_iommu_hole_init(void);
extern int gart_iommu_hole_init(void);

#else
#define gart_iommu_aperture            0
@@ -50,8 +50,9 @@ static inline void early_gart_iommu_check(void)
static inline void gart_parse_options(char *options)
{
}
static inline void gart_iommu_hole_init(void)
static inline int gart_iommu_hole_init(void)
{
	return -ENODEV;
}
#endif

+5 −3
Original line number Diff line number Diff line
@@ -1382,13 +1382,13 @@ static int __init early_amd_iommu_detect(struct acpi_table_header *table)
	return 0;
}

void __init amd_iommu_detect(void)
int __init amd_iommu_detect(void)
{
	if (no_iommu || (iommu_detected && !gart_iommu_aperture))
		return;
		return -ENODEV;

	if (amd_iommu_disabled)
		return;
		return -ENODEV;

	if (acpi_table_parse("IVRS", early_amd_iommu_detect) == 0) {
		iommu_detected = 1;
@@ -1397,7 +1397,9 @@ void __init amd_iommu_detect(void)

		/* Make sure ACS will be enabled */
		pci_request_acs();
		return 1;
	}
	return -ENODEV;
}

/****************************************************************************
+7 −4
Original line number Diff line number Diff line
@@ -371,7 +371,7 @@ void __init early_gart_iommu_check(void)

static int __initdata printed_gart_size_msg;

void __init gart_iommu_hole_init(void)
int __init gart_iommu_hole_init(void)
{
	u32 agp_aper_base = 0, agp_aper_order = 0;
	u32 aper_size, aper_alloc = 0, aper_order = 0, last_aper_order = 0;
@@ -381,7 +381,7 @@ void __init gart_iommu_hole_init(void)

	if (gart_iommu_aperture_disabled || !fix_aperture ||
	    !early_pci_allowed())
		return;
		return -ENODEV;

	printk(KERN_INFO  "Checking aperture...\n");

@@ -463,8 +463,9 @@ void __init gart_iommu_hole_init(void)
			unsigned long n = (32 * 1024 * 1024) << last_aper_order;

			insert_aperture_resource((u32)last_aper_base, n);
			return 1;
		}
		return;
		return 0;
	}

	if (!fallback_aper_force) {
@@ -500,7 +501,7 @@ void __init gart_iommu_hole_init(void)
			panic("Not enough memory for aperture");
		}
	} else {
		return;
		return 0;
	}

	/* Fix up the north bridges */
@@ -524,4 +525,6 @@ void __init gart_iommu_hole_init(void)
	}

	set_up_gart_resume(aper_order, aper_alloc);

	return 1;
}
Loading