x86: clean up arch/x86/kernel/aperture_64.c
whitespace cleanup. No code changed: text data bss dec hex filename 2080 76 4 2160 870 aperture_64.o.before 2080 76 4 2160 870 aperture_64.o.after errors lines of code errors/KLOC arch/x86/kernel/aperture_64.c 114 299 381.2 arch/x86/kernel/aperture_64.c 0 315 0 Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
@@ -59,10 +59,10 @@ static u32 __init allocate_aperture(void)
|
||||
aper_size = (32 * 1024 * 1024) << fallback_aper_order;
|
||||
|
||||
/*
|
||||
* Aperture has to be naturally aligned. This means an 2GB aperture won't
|
||||
* have much chance of finding a place in the lower 4GB of memory.
|
||||
* Unfortunately we cannot move it up because that would make the
|
||||
* IOMMU useless.
|
||||
* Aperture has to be naturally aligned. This means a 2GB aperture
|
||||
* won't have much chance of finding a place in the lower 4GB of
|
||||
* memory. Unfortunately we cannot move it up because that would
|
||||
* make the IOMMU useless.
|
||||
*/
|
||||
p = __alloc_bootmem_nopanic(aper_size, aper_size, 0);
|
||||
if (!p || __pa(p)+aper_size > 0xffffffff) {
|
||||
@@ -75,6 +75,7 @@ static u32 __init allocate_aperture(void)
|
||||
printk("Mapping aperture over %d KB of RAM @ %lx\n",
|
||||
aper_size >> 10, __pa(p));
|
||||
insert_aperture_resource((u32)__pa(p), aper_size);
|
||||
|
||||
return (u32)__pa(p);
|
||||
}
|
||||
|
||||
@@ -100,20 +101,25 @@ static int __init aperture_valid(u64 aper_base, u32 aper_size)
|
||||
/* Find a PCI capability */
|
||||
static __u32 __init find_cap(int num, int slot, int func, int cap)
|
||||
{
|
||||
u8 pos;
|
||||
int bytes;
|
||||
if (!(read_pci_config_16(num,slot,func,PCI_STATUS) & PCI_STATUS_CAP_LIST))
|
||||
u8 pos;
|
||||
|
||||
if (!(read_pci_config_16(num, slot, func, PCI_STATUS) &
|
||||
PCI_STATUS_CAP_LIST))
|
||||
return 0;
|
||||
pos = read_pci_config_byte(num,slot,func,PCI_CAPABILITY_LIST);
|
||||
|
||||
pos = read_pci_config_byte(num, slot, func, PCI_CAPABILITY_LIST);
|
||||
for (bytes = 0; bytes < 48 && pos >= 0x40; bytes++) {
|
||||
u8 id;
|
||||
|
||||
pos &= ~3;
|
||||
id = read_pci_config_byte(num,slot,func,pos+PCI_CAP_LIST_ID);
|
||||
id = read_pci_config_byte(num, slot, func, pos+PCI_CAP_LIST_ID);
|
||||
if (id == 0xff)
|
||||
break;
|
||||
if (id == cap)
|
||||
return pos;
|
||||
pos = read_pci_config_byte(num,slot,func,pos+PCI_CAP_LIST_NEXT);
|
||||
pos = read_pci_config_byte(num, slot, func,
|
||||
pos+PCI_CAP_LIST_NEXT);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -128,7 +134,7 @@ static __u32 __init read_agp(int num, int slot, int func, int cap, u32 *order)
|
||||
u64 aper;
|
||||
|
||||
printk("AGP bridge at %02x:%02x:%02x\n", num, slot, func);
|
||||
apsizereg = read_pci_config_16(num,slot,func, cap + 0x14);
|
||||
apsizereg = read_pci_config_16(num, slot, func, cap + 0x14);
|
||||
if (apsizereg == 0xffffffff) {
|
||||
printk("APSIZE in AGP bridge unreadable\n");
|
||||
return 0;
|
||||
@@ -143,8 +149,8 @@ static __u32 __init read_agp(int num, int slot, int func, int cap, u32 *order)
|
||||
if ((int)*order < 0) /* < 32MB */
|
||||
*order = 0;
|
||||
|
||||
aper_low = read_pci_config(num,slot,func, 0x10);
|
||||
aper_hi = read_pci_config(num,slot,func,0x14);
|
||||
aper_low = read_pci_config(num, slot, func, 0x10);
|
||||
aper_hi = read_pci_config(num, slot, func, 0x14);
|
||||
aper = (aper_low & ~((1<<22)-1)) | ((u64)aper_hi << 32);
|
||||
|
||||
printk("Aperture from AGP @ %Lx size %u MB (APSIZE %x)\n",
|
||||
@@ -155,17 +161,19 @@ static __u32 __init read_agp(int num, int slot, int func, int cap, u32 *order)
|
||||
return (u32)aper;
|
||||
}
|
||||
|
||||
/* Look for an AGP bridge. Windows only expects the aperture in the
|
||||
AGP bridge and some BIOS forget to initialize the Northbridge too.
|
||||
Work around this here.
|
||||
|
||||
Do an PCI bus scan by hand because we're running before the PCI
|
||||
subsystem.
|
||||
|
||||
All K8 AGP bridges are AGPv3 compliant, so we can do this scan
|
||||
generically. It's probably overkill to always scan all slots because
|
||||
the AGP bridges should be always an own bus on the HT hierarchy,
|
||||
but do it here for future safety. */
|
||||
/*
|
||||
* Look for an AGP bridge. Windows only expects the aperture in the
|
||||
* AGP bridge and some BIOS forget to initialize the Northbridge too.
|
||||
* Work around this here.
|
||||
*
|
||||
* Do an PCI bus scan by hand because we're running before the PCI
|
||||
* subsystem.
|
||||
*
|
||||
* All K8 AGP bridges are AGPv3 compliant, so we can do this scan
|
||||
* generically. It's probably overkill to always scan all slots because
|
||||
* the AGP bridges should be always an own bus on the HT hierarchy,
|
||||
* but do it here for future safety.
|
||||
*/
|
||||
static __u32 __init search_agp_bridge(u32 *order, int *valid_agp)
|
||||
{
|
||||
int num, slot, func;
|
||||
@@ -176,7 +184,7 @@ static __u32 __init search_agp_bridge(u32 *order, int *valid_agp)
|
||||
for (func = 0; func < 8; func++) {
|
||||
u32 class, cap;
|
||||
u8 type;
|
||||
class = read_pci_config(num,slot,func,
|
||||
class = read_pci_config(num, slot, func,
|
||||
PCI_CLASS_REVISION);
|
||||
if (class == 0xffffffff)
|
||||
break;
|
||||
@@ -185,15 +193,17 @@ static __u32 __init search_agp_bridge(u32 *order, int *valid_agp)
|
||||
case PCI_CLASS_BRIDGE_HOST:
|
||||
case PCI_CLASS_BRIDGE_OTHER: /* needed? */
|
||||
/* AGP bridge? */
|
||||
cap = find_cap(num,slot,func,PCI_CAP_ID_AGP);
|
||||
cap = find_cap(num, slot, func,
|
||||
PCI_CAP_ID_AGP);
|
||||
if (!cap)
|
||||
break;
|
||||
*valid_agp = 1;
|
||||
return read_agp(num,slot,func,cap,order);
|
||||
return read_agp(num, slot, func, cap,
|
||||
order);
|
||||
}
|
||||
|
||||
/* No multi-function device? */
|
||||
type = read_pci_config_byte(num,slot,func,
|
||||
type = read_pci_config_byte(num, slot, func,
|
||||
PCI_HEADER_TYPE);
|
||||
if (!(type & 0x80))
|
||||
break;
|
||||
@@ -201,15 +211,15 @@ static __u32 __init search_agp_bridge(u32 *order, int *valid_agp)
|
||||
}
|
||||
}
|
||||
printk("No AGP bridge found\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __init gart_iommu_hole_init(void)
|
||||
{
|
||||
int fix, num;
|
||||
u32 aper_size, aper_alloc = 0, aper_order = 0, last_aper_order = 0;
|
||||
u64 aper_base, last_aper_base = 0;
|
||||
int valid_agp = 0;
|
||||
int fix, num, valid_agp = 0;
|
||||
|
||||
if (gart_iommu_aperture_disabled || !fix_aperture ||
|
||||
!early_pci_allowed())
|
||||
@@ -250,6 +260,7 @@ void __init gart_iommu_hole_init(void)
|
||||
if (!fix && !fallback_aper_force) {
|
||||
if (last_aper_base) {
|
||||
unsigned long n = (32 * 1024 * 1024) << last_aper_order;
|
||||
|
||||
insert_aperture_resource((u32)last_aper_base, n);
|
||||
}
|
||||
return;
|
||||
@@ -274,11 +285,14 @@ void __init gart_iommu_hole_init(void)
|
||||
aper_order = fallback_aper_order;
|
||||
aper_alloc = allocate_aperture();
|
||||
if (!aper_alloc) {
|
||||
/* Could disable AGP and IOMMU here, but it's probably
|
||||
not worth it. But the later users cannot deal with
|
||||
bad apertures and turning on the aperture over memory
|
||||
causes very strange problems, so it's better to
|
||||
panic early. */
|
||||
/*
|
||||
* Could disable AGP and IOMMU here, but it's
|
||||
* probably not worth it. But the later users
|
||||
* cannot deal with bad apertures and turning
|
||||
* on the aperture over memory causes very
|
||||
* strange problems, so it's better to panic
|
||||
* early.
|
||||
*/
|
||||
panic("Not enough memory for aperture");
|
||||
}
|
||||
} else {
|
||||
@@ -290,9 +304,11 @@ void __init gart_iommu_hole_init(void)
|
||||
if (!early_is_k8_nb(read_pci_config(0, num, 3, 0x00)))
|
||||
continue;
|
||||
|
||||
/* Don't enable translation yet. That is done later.
|
||||
Assume this BIOS didn't initialise the GART so
|
||||
just overwrite all previous bits */
|
||||
/*
|
||||
* Don't enable translation yet. That is done later.
|
||||
* Assume this BIOS didn't initialise the GART so
|
||||
* just overwrite all previous bits
|
||||
*/
|
||||
write_pci_config(0, num, 3, 0x90, aper_order<<1);
|
||||
write_pci_config(0, num, 3, 0x94, aper_alloc>>25);
|
||||
}
|
||||
|
Reference in New Issue
Block a user