Release 4.14 arch/x86/pci/mmconfig_64.c
// SPDX-License-Identifier: GPL-2.0
/*
* mmconfig.c - Low-level direct PCI config space access via MMCONFIG
*
* This is an 64bit optimized version that always keeps the full mmconfig
* space mapped. This allows lockless config space operation.
*/
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/acpi.h>
#include <linux/bitmap.h>
#include <linux/rcupdate.h>
#include <asm/e820/api.h>
#include <asm/pci_x86.h>
#define PREFIX "PCI: "
static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn)
{
struct pci_mmcfg_region *cfg = pci_mmconfig_lookup(seg, bus);
if (cfg && cfg->virt)
return cfg->virt + (PCI_MMCFG_BUS_OFFSET(bus) | (devfn << 12));
return NULL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Björn Helgaas | 24 | 39.34% | 5 | 55.56% |
Greg Kroah-Hartman | 23 | 37.70% | 1 | 11.11% |
Andi Kleen | 13 | 21.31% | 2 | 22.22% |
Al Viro | 1 | 1.64% | 1 | 11.11% |
Total | 61 | 100.00% | 9 | 100.00% |
static int pci_mmcfg_read(unsigned int seg, unsigned int bus,
unsigned int devfn, int reg, int len, u32 *value)
{
char __iomem *addr;
/* Why do we have this when nobody checks it. How about a BUG()!? -AK */
if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095))) {
err: *value = -1;
return -EINVAL;
}
rcu_read_lock();
addr = pci_dev_base(seg, bus, devfn);
if (!addr) {
rcu_read_unlock();
goto err;
}
switch (len) {
case 1:
*value = mmio_config_readb(addr + reg);
break;
case 2:
*value = mmio_config_readw(addr + reg);
break;
case 4:
*value = mmio_config_readl(addr + reg);
break;
}
rcu_read_unlock();
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 113 | 74.34% | 3 | 37.50% |
Ivan Kokshaysky | 21 | 13.82% | 1 | 12.50% |
Jiang Liu | 11 | 7.24% | 1 | 12.50% |
Dean Gaudet | 3 | 1.97% | 1 | 12.50% |
Björn Helgaas | 3 | 1.97% | 1 | 12.50% |
Al Viro | 1 | 0.66% | 1 | 12.50% |
Total | 152 | 100.00% | 8 | 100.00% |
static int pci_mmcfg_write(unsigned int seg, unsigned int bus,
unsigned int devfn, int reg, int len, u32 value)
{
char __iomem *addr;
/* Why do we have this when nobody checks it. How about a BUG()!? -AK */
if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095)))
return -EINVAL;
rcu_read_lock();
addr = pci_dev_base(seg, bus, devfn);
if (!addr) {
rcu_read_unlock();
return -EINVAL;
}
switch (len) {
case 1:
mmio_config_writeb(addr + reg, value);
break;
case 2:
mmio_config_writew(addr + reg, value);
break;
case 4:
mmio_config_writel(addr + reg, value);
break;
}
rcu_read_unlock();
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 95 | 68.35% | 2 | 28.57% |
Ivan Kokshaysky | 20 | 14.39% | 1 | 14.29% |
Jiang Liu | 11 | 7.91% | 1 | 14.29% |
Dean Gaudet | 9 | 6.47% | 1 | 14.29% |
Björn Helgaas | 3 | 2.16% | 1 | 14.29% |
Al Viro | 1 | 0.72% | 1 | 14.29% |
Total | 139 | 100.00% | 7 | 100.00% |
const struct pci_raw_ops pci_mmcfg = {
.read = pci_mmcfg_read,
.write = pci_mmcfg_write,
};
static void __iomem *mcfg_ioremap(struct pci_mmcfg_region *cfg)
{
void __iomem *addr;
u64 start, size;
int num_buses;
start = cfg->address + PCI_MMCFG_BUS_OFFSET(cfg->start_bus);
num_buses = cfg->end_bus - cfg->start_bus + 1;
size = PCI_MMCFG_BUS_OFFSET(num_buses);
addr = ioremap_nocache(start, size);
if (addr)
addr -= PCI_MMCFG_BUS_OFFSET(cfg->start_bus);
return addr;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hirofumi Ogawa | 38 | 45.78% | 1 | 20.00% |
Björn Helgaas | 24 | 28.92% | 3 | 60.00% |
Yinghai Lu | 21 | 25.30% | 1 | 20.00% |
Total | 83 | 100.00% | 5 | 100.00% |
int __init pci_mmcfg_arch_init(void)
{
struct pci_mmcfg_region *cfg;
list_for_each_entry(cfg, &pci_mmcfg_list, list)
if (pci_mmcfg_arch_map(cfg)) {
pci_mmcfg_arch_free();
return 0;
}
raw_pci_ext_ops = &pci_mmcfg;
return 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 15 | 34.09% | 2 | 25.00% |
Björn Helgaas | 14 | 31.82% | 2 | 25.00% |
Olivier Galibert | 8 | 18.18% | 1 | 12.50% |
Jiang Liu | 3 | 6.82% | 1 | 12.50% |
Yinghai Lu | 3 | 6.82% | 1 | 12.50% |
Matthew Wilcox | 1 | 2.27% | 1 | 12.50% |
Total | 44 | 100.00% | 8 | 100.00% |
void __init pci_mmcfg_arch_free(void)
{
struct pci_mmcfg_region *cfg;
list_for_each_entry(cfg, &pci_mmcfg_list, list)
pci_mmcfg_arch_unmap(cfg);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Björn Helgaas | 13 | 50.00% | 2 | 50.00% |
Yinghai Lu | 7 | 26.92% | 1 | 25.00% |
Jiang Liu | 6 | 23.08% | 1 | 25.00% |
Total | 26 | 100.00% | 4 | 100.00% |
int pci_mmcfg_arch_map(struct pci_mmcfg_region *cfg)
{
cfg->virt = mcfg_ioremap(cfg);
if (!cfg->virt) {
pr_err(PREFIX "can't map MMCONFIG at %pR\n", &cfg->res);
return -ENOMEM;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jiang Liu | 43 | 93.48% | 2 | 50.00% |
Björn Helgaas | 2 | 4.35% | 1 | 25.00% |
Yinghai Lu | 1 | 2.17% | 1 | 25.00% |
Total | 46 | 100.00% | 4 | 100.00% |
void pci_mmcfg_arch_unmap(struct pci_mmcfg_region *cfg)
{
if (cfg && cfg->virt) {
iounmap(cfg->virt + PCI_MMCFG_BUS_OFFSET(cfg->start_bus));
cfg->virt = NULL;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yinghai Lu | 17 | 42.50% | 2 | 33.33% |
Jiang Liu | 13 | 32.50% | 1 | 16.67% |
Björn Helgaas | 10 | 25.00% | 3 | 50.00% |
Total | 40 | 100.00% | 6 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 263 | 41.42% | 4 | 12.90% |
Björn Helgaas | 97 | 15.28% | 8 | 25.81% |
Jiang Liu | 90 | 14.17% | 3 | 9.68% |
Yinghai Lu | 49 | 7.72% | 2 | 6.45% |
Ivan Kokshaysky | 41 | 6.46% | 1 | 3.23% |
Hirofumi Ogawa | 38 | 5.98% | 1 | 3.23% |
Greg Kroah-Hartman | 27 | 4.25% | 3 | 9.68% |
Dean Gaudet | 12 | 1.89% | 1 | 3.23% |
Olivier Galibert | 8 | 1.26% | 1 | 3.23% |
Al Viro | 3 | 0.47% | 1 | 3.23% |
Arjan van de Ven | 2 | 0.31% | 1 | 3.23% |
Jan Beulich | 1 | 0.16% | 1 | 3.23% |
Ingo Molnar | 1 | 0.16% | 1 | 3.23% |
Jaswinder Singh Rajput | 1 | 0.16% | 1 | 3.23% |
Alexey Y. Starikovskiy | 1 | 0.16% | 1 | 3.23% |
Matthew Wilcox | 1 | 0.16% | 1 | 3.23% |
Total | 635 | 100.00% | 31 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.