aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@google.com>2006-12-06 20:14:01 -0500
committerAndi Kleen <andi@basil.nowhere.org>2006-12-06 20:14:01 -0500
commit399287229c775a8962a852a761d65dc9475dec7c (patch)
treec8cbad038fa9891350d33c5e5f50bc31b6a15882 /arch
parentacc207616a91a413a50fdd8847a747c4a7324167 (diff)
[PATCH] x86-64: Insert Local and IO APIC(s) into resource map
Insert the Local APIC and IO APIC(s) into the resource tree. It allows the APIC resources to be visible within /proc/iomem. The patch also takes into account IO APIC(s) mapped in the PCI space by deferring the insertion until after PCI has allocated its necessary resources. Signed-off-by: Aaron Durbin <adurbin@google.com> Signed-off-by: Andi Kleen <ak@suse.de> Cc: Andi Kleen <ak@muc.de> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86_64/kernel/apic.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
index 4d9d5ed942b2..5c468971e645 100644
--- a/arch/x86_64/kernel/apic.c
+++ b/arch/x86_64/kernel/apic.c
@@ -25,6 +25,7 @@
25#include <linux/kernel_stat.h> 25#include <linux/kernel_stat.h>
26#include <linux/sysdev.h> 26#include <linux/sysdev.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/ioport.h>
28 29
29#include <asm/atomic.h> 30#include <asm/atomic.h>
30#include <asm/smp.h> 31#include <asm/smp.h>
@@ -45,6 +46,12 @@ int apic_calibrate_pmtmr __initdata;
45 46
46int disable_apic_timer __initdata; 47int disable_apic_timer __initdata;
47 48
49static struct resource *ioapic_resources;
50static struct resource lapic_resource = {
51 .name = "Local APIC",
52 .flags = IORESOURCE_MEM | IORESOURCE_BUSY,
53};
54
48/* 55/*
49 * cpu_mask that denotes the CPUs that needs timer interrupt coming in as 56 * cpu_mask that denotes the CPUs that needs timer interrupt coming in as
50 * IPIs in place of local APIC timers 57 * IPIs in place of local APIC timers
@@ -585,6 +592,64 @@ static int __init detect_init_APIC (void)
585 return 0; 592 return 0;
586} 593}
587 594
595#ifdef CONFIG_X86_IO_APIC
596static struct resource * __init ioapic_setup_resources(void)
597{
598#define IOAPIC_RESOURCE_NAME_SIZE 11
599 unsigned long n;
600 struct resource *res;
601 char *mem;
602 int i;
603
604 if (nr_ioapics <= 0)
605 return NULL;
606
607 n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource);
608 n *= nr_ioapics;
609
610 mem = alloc_bootmem(n);
611 res = (void *)mem;
612
613 if (mem != NULL) {
614 memset(mem, 0, n);
615 mem += sizeof(struct resource) * nr_ioapics;
616
617 for (i = 0; i < nr_ioapics; i++) {
618 res[i].name = mem;
619 res[i].flags = IORESOURCE_MEM | IORESOURCE_BUSY;
620 sprintf(mem, "IOAPIC %u", i);
621 mem += IOAPIC_RESOURCE_NAME_SIZE;
622 }
623 }
624
625 ioapic_resources = res;
626
627 return res;
628}
629
630static int __init ioapic_insert_resources(void)
631{
632 int i;
633 struct resource *r = ioapic_resources;
634
635 if (!r) {
636 printk("IO APIC resources could be not be allocated.\n");
637 return -1;
638 }
639
640 for (i = 0; i < nr_ioapics; i++) {
641 insert_resource(&iomem_resource, r);
642 r++;
643 }
644
645 return 0;
646}
647
648/* Insert the IO APIC resources after PCI initialization has occured to handle
649 * IO APICS that are mapped in on a BAR in PCI space. */
650late_initcall(ioapic_insert_resources);
651#endif
652
588void __init init_apic_mappings(void) 653void __init init_apic_mappings(void)
589{ 654{
590 unsigned long apic_phys; 655 unsigned long apic_phys;
@@ -604,6 +669,11 @@ void __init init_apic_mappings(void)
604 apic_mapped = 1; 669 apic_mapped = 1;
605 apic_printk(APIC_VERBOSE,"mapped APIC to %16lx (%16lx)\n", APIC_BASE, apic_phys); 670 apic_printk(APIC_VERBOSE,"mapped APIC to %16lx (%16lx)\n", APIC_BASE, apic_phys);
606 671
672 /* Put local APIC into the resource map. */
673 lapic_resource.start = apic_phys;
674 lapic_resource.end = lapic_resource.start + PAGE_SIZE - 1;
675 insert_resource(&iomem_resource, &lapic_resource);
676
607 /* 677 /*
608 * Fetch the APIC ID of the BSP in case we have a 678 * Fetch the APIC ID of the BSP in case we have a
609 * default configuration (or the MP table is broken). 679 * default configuration (or the MP table is broken).
@@ -613,7 +683,9 @@ void __init init_apic_mappings(void)
613 { 683 {
614 unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0; 684 unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0;
615 int i; 685 int i;
686 struct resource *ioapic_res;
616 687
688 ioapic_res = ioapic_setup_resources();
617 for (i = 0; i < nr_ioapics; i++) { 689 for (i = 0; i < nr_ioapics; i++) {
618 if (smp_found_config) { 690 if (smp_found_config) {
619 ioapic_phys = mp_ioapics[i].mpc_apicaddr; 691 ioapic_phys = mp_ioapics[i].mpc_apicaddr;
@@ -625,6 +697,12 @@ void __init init_apic_mappings(void)
625 apic_printk(APIC_VERBOSE,"mapped IOAPIC to %016lx (%016lx)\n", 697 apic_printk(APIC_VERBOSE,"mapped IOAPIC to %016lx (%016lx)\n",
626 __fix_to_virt(idx), ioapic_phys); 698 __fix_to_virt(idx), ioapic_phys);
627 idx++; 699 idx++;
700
701 if (ioapic_res != NULL) {
702 ioapic_res->start = ioapic_phys;
703 ioapic_res->end = ioapic_phys + (4 * 1024) - 1;
704 ioapic_res++;
705 }
628 } 706 }
629 } 707 }
630} 708}