Yinghai Lu
2007-06-22T19:18:15Z

[PATCH] x86-64: disable the GART before allocate aperture

For K8 system: 4G RAM with memory hole remapping enabled, or more than 4G RAM
installed. when mem is allocated for GART, it will do the memset for clear.
and for kexec case, the first kernel already enable that, the memset in second
kernel will cause the system restart. So disable that at first before we try to
allocate mem for it.

Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>

diff --git a/arch/x86_64/kernel/aperture.c b/arch/x86_64/kernel/aperture.c
index a3d450d..7a1b072 100644
--- a/arch/x86_64/kernel/aperture.c
+++ b/arch/x86_64/kernel/aperture.c
@@ -270,6 +270,19 @@ void __init iommu_hole_init(void)
printk("This costs you %d MB of RAM\n",
32 << fallback_aper_order);

+ /*
+ * disable it in case it is enabled before, esp for kexec/kdump,
+ * previous kernel already enable that. otherwise memset called
+ * by allocate_aperture/__alloc_bootmem_nopanic cause restart.
+ */
+ for (num = 24; num < 32; num++) {
+ if (!early_is_k8_nb(read_pci_config(0, num, 3, 0x00)))
+ continue;
+
+ write_pci_config(0, num, 3, 0x90, 0);
+ write_pci_config(0, num, 3, 0x94, 0);
+ }
+
aper_order = fallback_aper_order;
aper_alloc = allocate_aperture();
if (!aper_alloc) {