Commit c4bf2f372db09ef8d16a25a60d523bfa1c50f7b5

Authored by Len Brown
1 parent 24c5c4c2f5

ACPI, PCI, x86: move MCFG parsing routine from ACPI to PCI file

Move
arch/x86/kernel/acpi/boot.c: acpi_parse_mcfg()
to
arch/x86/pci/mmconfig-shared.c: pci_parse_mcfg()
where it is used, and make it static.

Move associated globals and helper routine with it.

No functional change.

This code move is in preparation for SFI support,
which will allow the PCI code to find the MCFG table
on systems which do not support ACPI.

Signed-off-by: Len Brown <len.brown@intel.com>
Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>

Showing 4 changed files with 67 additions and 70 deletions Side-by-side Diff

arch/x86/include/asm/pci_x86.h
... ... @@ -121,6 +121,9 @@
121 121 extern int __init pci_mmcfg_arch_init(void);
122 122 extern void __init pci_mmcfg_arch_free(void);
123 123  
  124 +extern struct acpi_mcfg_allocation *pci_mmcfg_config;
  125 +extern int pci_mmcfg_config_num;
  126 +
124 127 /*
125 128 * AMD Fam10h CPUs are buggy, and cannot access MMIO config space
126 129 * on their northbrige except through the * %eax register. As such, you MUST
arch/x86/kernel/acpi/boot.c
... ... @@ -117,72 +117,6 @@
117 117 early_iounmap(map, size);
118 118 }
119 119  
120   -#ifdef CONFIG_PCI_MMCONFIG
121   -
122   -static int acpi_mcfg_64bit_base_addr __initdata = FALSE;
123   -
124   -/* The physical address of the MMCONFIG aperture. Set from ACPI tables. */
125   -struct acpi_mcfg_allocation *pci_mmcfg_config;
126   -int pci_mmcfg_config_num;
127   -
128   -static int __init acpi_mcfg_oem_check(struct acpi_table_mcfg *mcfg)
129   -{
130   - if (!strcmp(mcfg->header.oem_id, "SGI"))
131   - acpi_mcfg_64bit_base_addr = TRUE;
132   -
133   - return 0;
134   -}
135   -
136   -int __init acpi_parse_mcfg(struct acpi_table_header *header)
137   -{
138   - struct acpi_table_mcfg *mcfg;
139   - unsigned long i;
140   - int config_size;
141   -
142   - if (!header)
143   - return -EINVAL;
144   -
145   - mcfg = (struct acpi_table_mcfg *)header;
146   -
147   - /* how many config structures do we have */
148   - pci_mmcfg_config_num = 0;
149   - i = header->length - sizeof(struct acpi_table_mcfg);
150   - while (i >= sizeof(struct acpi_mcfg_allocation)) {
151   - ++pci_mmcfg_config_num;
152   - i -= sizeof(struct acpi_mcfg_allocation);
153   - };
154   - if (pci_mmcfg_config_num == 0) {
155   - printk(KERN_ERR PREFIX "MMCONFIG has no entries\n");
156   - return -ENODEV;
157   - }
158   -
159   - config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config);
160   - pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL);
161   - if (!pci_mmcfg_config) {
162   - printk(KERN_WARNING PREFIX
163   - "No memory for MCFG config tables\n");
164   - return -ENOMEM;
165   - }
166   -
167   - memcpy(pci_mmcfg_config, &mcfg[1], config_size);
168   -
169   - acpi_mcfg_oem_check(mcfg);
170   -
171   - for (i = 0; i < pci_mmcfg_config_num; ++i) {
172   - if ((pci_mmcfg_config[i].address > 0xFFFFFFFF) &&
173   - !acpi_mcfg_64bit_base_addr) {
174   - printk(KERN_ERR PREFIX
175   - "MMCONFIG not in low 4GB of memory\n");
176   - kfree(pci_mmcfg_config);
177   - pci_mmcfg_config_num = 0;
178   - return -ENODEV;
179   - }
180   - }
181   -
182   - return 0;
183   -}
184   -#endif /* CONFIG_PCI_MMCONFIG */
185   -
186 120 #ifdef CONFIG_X86_LOCAL_APIC
187 121 static int __init acpi_parse_madt(struct acpi_table_header *table)
188 122 {
arch/x86/pci/mmconfig-shared.c
... ... @@ -523,6 +523,69 @@
523 523  
524 524 static int __initdata known_bridge;
525 525  
  526 +static int acpi_mcfg_64bit_base_addr __initdata = FALSE;
  527 +
  528 +/* The physical address of the MMCONFIG aperture. Set from ACPI tables. */
  529 +struct acpi_mcfg_allocation *pci_mmcfg_config;
  530 +int pci_mmcfg_config_num;
  531 +
  532 +static int __init acpi_mcfg_oem_check(struct acpi_table_mcfg *mcfg)
  533 +{
  534 + if (!strcmp(mcfg->header.oem_id, "SGI"))
  535 + acpi_mcfg_64bit_base_addr = TRUE;
  536 +
  537 + return 0;
  538 +}
  539 +
  540 +static int __init pci_parse_mcfg(struct acpi_table_header *header)
  541 +{
  542 + struct acpi_table_mcfg *mcfg;
  543 + unsigned long i;
  544 + int config_size;
  545 +
  546 + if (!header)
  547 + return -EINVAL;
  548 +
  549 + mcfg = (struct acpi_table_mcfg *)header;
  550 +
  551 + /* how many config structures do we have */
  552 + pci_mmcfg_config_num = 0;
  553 + i = header->length - sizeof(struct acpi_table_mcfg);
  554 + while (i >= sizeof(struct acpi_mcfg_allocation)) {
  555 + ++pci_mmcfg_config_num;
  556 + i -= sizeof(struct acpi_mcfg_allocation);
  557 + };
  558 + if (pci_mmcfg_config_num == 0) {
  559 + printk(KERN_ERR PREFIX "MMCONFIG has no entries\n");
  560 + return -ENODEV;
  561 + }
  562 +
  563 + config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config);
  564 + pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL);
  565 + if (!pci_mmcfg_config) {
  566 + printk(KERN_WARNING PREFIX
  567 + "No memory for MCFG config tables\n");
  568 + return -ENOMEM;
  569 + }
  570 +
  571 + memcpy(pci_mmcfg_config, &mcfg[1], config_size);
  572 +
  573 + acpi_mcfg_oem_check(mcfg);
  574 +
  575 + for (i = 0; i < pci_mmcfg_config_num; ++i) {
  576 + if ((pci_mmcfg_config[i].address > 0xFFFFFFFF) &&
  577 + !acpi_mcfg_64bit_base_addr) {
  578 + printk(KERN_ERR PREFIX
  579 + "MMCONFIG not in low 4GB of memory\n");
  580 + kfree(pci_mmcfg_config);
  581 + pci_mmcfg_config_num = 0;
  582 + return -ENODEV;
  583 + }
  584 + }
  585 +
  586 + return 0;
  587 +}
  588 +
526 589 static void __init __pci_mmcfg_init(int early)
527 590 {
528 591 /* MMCONFIG disabled */
... ... @@ -543,7 +606,7 @@
543 606 }
544 607  
545 608 if (!known_bridge)
546   - acpi_table_parse(ACPI_SIG_MCFG, acpi_parse_mcfg);
  609 + acpi_table_parse(ACPI_SIG_MCFG, pci_parse_mcfg);
547 610  
548 611 pci_mmcfg_reject_broken(early);
549 612  
include/linux/acpi.h
... ... @@ -113,9 +113,6 @@
113 113 extern u32 acpi_irq_handled;
114 114 extern u32 acpi_irq_not_handled;
115 115  
116   -extern struct acpi_mcfg_allocation *pci_mmcfg_config;
117   -extern int pci_mmcfg_config_num;
118   -
119 116 extern int sbf_port;
120 117 extern unsigned long acpi_realmode_flags;
121 118