Skip to content

Commit 0e152cd

Browse files
Borislav PetkovIngo Molnar
authored andcommitted
x86, k8 nb: Fix boot crash: enable k8_northbridges unconditionally on AMD systems
de95762 changed setting of the x86_init.iommu.iommu_init function ptr only when GART IOMMU is found. One side effect of it is that num_k8_northbridges is not initialized anymore if not explicitly called. This resulted in uninitialized pointers in <arch/x86/kernel/cpu/intel_cacheinfo.c:amd_calc_l3_indices()>, for example, which uses the num_k8_northbridges thing through node_to_k8_nb_misc(). Fix that through an initcall that runs right after the PCI subsystem and does all the scanning. Then, remove initialization in gart_iommu_init() which is a rootfs_initcall and we're running before that. What is more, since num_k8_northbridges is being used in other places beside GART IOMMU, include it whenever we add AMD CPU support. The previous dependency chain in kconfig contained K8_NB depends on AGP_AMD64|GART_IOMMU which was clearly incorrect. The more natural way in terms of hardware dependency should be AGP_AMD64|GART_IOMMU depends on K8_NB depends on CPU_SUP_AMD && PCI. Make it so Number One! Signed-off-by: Borislav Petkov <borislav.petkov@amd.com> Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: Joerg Roedel <joerg.roedel@amd.com> LKML-Reference: <20100312144303.GA29262@aftab> Signed-off-by: Ingo Molnar <mingo@elte.hu> Tested-by: Joerg Roedel <joerg.roedel@amd.com>
1 parent 8447b36 commit 0e152cd

4 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎arch/x86/Kconfig‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ config GART_IOMMU
627627
bool "GART IOMMU support" if EMBEDDED
628628
default y
629629
select SWIOTLB
630-
depends on X86_64 && PCI
630+
depends on X86_64 && PCI && K8_NB
631631
---help---
632632
Support for full DMA access of devices with 32bit memory access only
633633
on systems with more than 3GB. This is usually needed for USB,
@@ -2026,7 +2026,7 @@ endif # X86_32
20262026

20272027
config K8_NB
20282028
def_bool y
2029-
depends on AGP_AMD64 || (X86_64 && (GART_IOMMU || (PCI && NUMA)))
2029+
depends on CPU_SUP_AMD && PCI
20302030

20312031
source "drivers/pcmcia/Kconfig"
20322032

‎arch/x86/kernel/k8.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,17 @@ void k8_flush_garts(void)
121121
}
122122
EXPORT_SYMBOL_GPL(k8_flush_garts);
123123

124+
static __init int init_k8_nbs(void)
125+
{
126+
int err = 0;
127+
128+
err = cache_k8_northbridges();
129+
130+
if (err < 0)
131+
printk(KERN_NOTICE "K8 NB: Cannot enumerate AMD northbridges.\n");
132+
133+
return err;
134+
}
135+
136+
/* This has to go after the PCI subsystem */
137+
fs_initcall(init_k8_nbs);

‎arch/x86/kernel/pci-gart_64.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ int __init gart_iommu_init(void)
735735
unsigned long scratch;
736736
long i;
737737

738-
if (cache_k8_northbridges() < 0 || num_k8_northbridges == 0)
738+
if (num_k8_northbridges == 0)
739739
return 0;
740740

741741
#ifndef CONFIG_AGP_AMD64

‎drivers/char/agp/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ config AGP_AMD
5757

5858
config AGP_AMD64
5959
tristate "AMD Opteron/Athlon64 on-CPU GART support"
60-
depends on AGP && X86
60+
depends on AGP && X86 && K8_NB
6161
help
6262
This option gives you AGP support for the GLX component of
6363
X using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs.

0 commit comments

Comments
 (0)