x86/PCI: MMCONFIG: add lookup function
This patch factors out the search for an MMCONFIG region, which was previously implemented in both mmconfig_32 and mmconfig_64. No functional change. Reviewed-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
This commit is contained in:
committed by
Jesse Barnes
parent
8c57786ad3
commit
f6e1d8cc38
@@ -134,6 +134,7 @@ struct pci_mmcfg_region {
|
|||||||
|
|
||||||
extern int __init pci_mmcfg_arch_init(void);
|
extern int __init pci_mmcfg_arch_init(void);
|
||||||
extern void __init pci_mmcfg_arch_free(void);
|
extern void __init pci_mmcfg_arch_free(void);
|
||||||
|
extern struct pci_mmcfg_region *pci_mmconfig_lookup(int segment, int bus);
|
||||||
|
|
||||||
extern struct list_head pci_mmcfg_list;
|
extern struct list_head pci_mmcfg_list;
|
||||||
|
|
||||||
|
@@ -97,6 +97,18 @@ static __init struct pci_mmcfg_region *pci_mmconfig_add(int segment, int start,
|
|||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct pci_mmcfg_region *pci_mmconfig_lookup(int segment, int bus)
|
||||||
|
{
|
||||||
|
struct pci_mmcfg_region *cfg;
|
||||||
|
|
||||||
|
list_for_each_entry(cfg, &pci_mmcfg_list, list)
|
||||||
|
if (cfg->segment == segment &&
|
||||||
|
cfg->start_bus <= bus && bus <= cfg->end_bus)
|
||||||
|
return cfg;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static const char __init *pci_mmcfg_e7520(void)
|
static const char __init *pci_mmcfg_e7520(void)
|
||||||
{
|
{
|
||||||
u32 win;
|
u32 win;
|
||||||
|
@@ -27,15 +27,10 @@ static int mmcfg_last_accessed_cpu;
|
|||||||
*/
|
*/
|
||||||
static u32 get_base_addr(unsigned int seg, int bus, unsigned devfn)
|
static u32 get_base_addr(unsigned int seg, int bus, unsigned devfn)
|
||||||
{
|
{
|
||||||
struct pci_mmcfg_region *cfg;
|
struct pci_mmcfg_region *cfg = pci_mmconfig_lookup(seg, bus);
|
||||||
|
|
||||||
list_for_each_entry(cfg, &pci_mmcfg_list, list)
|
if (cfg)
|
||||||
if (cfg->segment == seg &&
|
|
||||||
(cfg->start_bus <= bus) &&
|
|
||||||
(cfg->end_bus >= bus))
|
|
||||||
return cfg->address;
|
return cfg->address;
|
||||||
|
|
||||||
/* Fall back to type 0 */
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,28 +14,13 @@
|
|||||||
|
|
||||||
#define PREFIX "PCI: "
|
#define PREFIX "PCI: "
|
||||||
|
|
||||||
static char __iomem *get_virt(unsigned int seg, unsigned bus)
|
|
||||||
{
|
|
||||||
struct pci_mmcfg_region *cfg;
|
|
||||||
|
|
||||||
list_for_each_entry(cfg, &pci_mmcfg_list, list)
|
|
||||||
if (cfg->segment == seg &&
|
|
||||||
(cfg->start_bus <= bus) &&
|
|
||||||
(cfg->end_bus >= bus))
|
|
||||||
return cfg->virt;
|
|
||||||
|
|
||||||
/* Fall back to type 0 */
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn)
|
static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn)
|
||||||
{
|
{
|
||||||
char __iomem *addr;
|
struct pci_mmcfg_region *cfg = pci_mmconfig_lookup(seg, bus);
|
||||||
|
|
||||||
addr = get_virt(seg, bus);
|
if (cfg && cfg->virt)
|
||||||
if (!addr)
|
return cfg->virt + (PCI_MMCFG_BUS_OFFSET(bus) | (devfn << 12));
|
||||||
return NULL;
|
return NULL;
|
||||||
return addr + (PCI_MMCFG_BUS_OFFSET(bus) | (devfn << 12));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pci_mmcfg_read(unsigned int seg, unsigned int bus,
|
static int pci_mmcfg_read(unsigned int seg, unsigned int bus,
|
||||||
|
Reference in New Issue
Block a user