Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 174814
b: refs/heads/master
c: 3f0f550
h: refs/heads/master
v: v3
  • Loading branch information
Bjorn Helgaas authored and Jesse Barnes committed Nov 24, 2009
1 parent 39c5d79 commit dea912c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 32 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2f2a8b9c90279e75f87aaf322a948bdced27e89f
refs/heads/master: 3f0f5503926f7447615f083c2d57545a83b6357c
1 change: 1 addition & 0 deletions trunk/arch/x86/include/asm/pci_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ extern int __init pcibios_init(void);
struct pci_mmcfg_region {
struct resource res;
u64 address;
char __iomem *virt;
u16 segment;
u8 start_bus;
u8 end_bus;
Expand Down
45 changes: 14 additions & 31 deletions trunk/arch/x86/pci/mmconfig_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,17 @@
#include <asm/e820.h>
#include <asm/pci_x86.h>

/* Static virtual mapping of the MMCONFIG aperture */
struct mmcfg_virt {
struct pci_mmcfg_region *cfg;
char __iomem *virt;
};
static struct mmcfg_virt *pci_mmcfg_virt;

static char __iomem *get_virt(unsigned int seg, unsigned bus)
{
int i;
struct pci_mmcfg_region *cfg;
int cfg_num;

for (cfg_num = 0; cfg_num < pci_mmcfg_config_num; cfg_num++) {
cfg = pci_mmcfg_virt[cfg_num].cfg;
for (i = 0; i < pci_mmcfg_config_num; ++i) {
cfg = &pci_mmcfg_config[i];
if (cfg->segment == seg &&
(cfg->start_bus <= bus) &&
(cfg->end_bus >= bus))
return pci_mmcfg_virt[cfg_num].virt;
return cfg->virt;
}

/* Fall back to type 0 */
Expand Down Expand Up @@ -130,20 +123,15 @@ static void __iomem * __init mcfg_ioremap(struct pci_mmcfg_region *cfg)
int __init pci_mmcfg_arch_init(void)
{
int i;
pci_mmcfg_virt = kzalloc(sizeof(*pci_mmcfg_virt) *
pci_mmcfg_config_num, GFP_KERNEL);
if (pci_mmcfg_virt == NULL) {
printk(KERN_ERR "PCI: Can not allocate memory for mmconfig structures\n");
return 0;
}
struct pci_mmcfg_region *cfg;

for (i = 0; i < pci_mmcfg_config_num; ++i) {
pci_mmcfg_virt[i].cfg = &pci_mmcfg_config[i];
pci_mmcfg_virt[i].virt = mcfg_ioremap(&pci_mmcfg_config[i]);
if (!pci_mmcfg_virt[i].virt) {
cfg = &pci_mmcfg_config[i];
cfg->virt = mcfg_ioremap(cfg);
if (!cfg->virt) {
printk(KERN_ERR "PCI: Cannot map mmconfig aperture for "
"segment %d\n",
pci_mmcfg_config[i].segment);
cfg->segment);
pci_mmcfg_arch_free();
return 0;
}
Expand All @@ -155,18 +143,13 @@ int __init pci_mmcfg_arch_init(void)
void __init pci_mmcfg_arch_free(void)
{
int i;

if (pci_mmcfg_virt == NULL)
return;
struct pci_mmcfg_region *cfg;

for (i = 0; i < pci_mmcfg_config_num; ++i) {
if (pci_mmcfg_virt[i].virt) {
iounmap(pci_mmcfg_virt[i].virt + PCI_MMCFG_BUS_OFFSET(pci_mmcfg_virt[i].cfg->start_bus));
pci_mmcfg_virt[i].virt = NULL;
pci_mmcfg_virt[i].cfg = NULL;
cfg = &pci_mmcfg_config[i];
if (cfg->virt) {
iounmap(cfg->virt + PCI_MMCFG_BUS_OFFSET(cfg->start_bus));
cfg->virt = NULL;
}
}

kfree(pci_mmcfg_virt);
pci_mmcfg_virt = NULL;
}

0 comments on commit dea912c

Please sign in to comment.