Message ID | 1415366876-30811-4-git-send-email-tomasz.nowicki@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | Bjorn Helgaas |
Headers | show |
On Friday 07 November 2014 14:27:55 Tomasz Nowicki wrote: > These calls allow to map/unmap PCI config space ranges (which are specified in > MMCFG ACPI table). > > Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org> > Nothing in this patch looks arm64 specific, and most of it looks like a copy of the x86 code. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 07.11.2014 15:12, Arnd Bergmann wrote: > On Friday 07 November 2014 14:27:55 Tomasz Nowicki wrote: >> These calls allow to map/unmap PCI config space ranges (which are specified in >> MMCFG ACPI table). >> >> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org> >> > > Nothing in this patch looks arm64 specific, and most of it looks like a > copy of the x86 code. Yes, most of the logic was borrowed from mmconfig_64.c file, mmconfig_32.c looks differently, though. It is not simple to merge them both. IMO, we have two choices: 1. Refactor and move mmconfig_64.c out of x86 to e.g. drivers/acpi/ and let it be default. 2. Stay with solution presented in this patch. 3. Thoughts ? Regards, Tomasz -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Friday 07 November 2014 15:39:32 Tomasz Nowicki wrote: > On 07.11.2014 15:12, Arnd Bergmann wrote: > > On Friday 07 November 2014 14:27:55 Tomasz Nowicki wrote: > >> These calls allow to map/unmap PCI config space ranges (which are specified in > >> MMCFG ACPI table). > >> > >> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org> > >> > > > > Nothing in this patch looks arm64 specific, and most of it looks like a > > copy of the x86 code. > > Yes, most of the logic was borrowed from mmconfig_64.c file, > mmconfig_32.c looks differently, though. It is not simple to merge them > both. IMO, we have two choices: > 1. Refactor and move mmconfig_64.c out of x86 to e.g. drivers/acpi/ and > let it be default. > 2. Stay with solution presented in this patch. > 3. Thoughts ? If the code is generic, it should be shared with as many architectures as possible. Moving the x86-64 implementation to drivers/acpi/ would immediately let you share it with two out of the four architectures (x86-64 and arm64, but not x86-32 and ia64) as well as any potential other architectures that might implement ACPI in the future. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index aee6a60..f2bcb58 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -186,6 +186,9 @@ config PCI_DOMAINS_GENERIC config PCI_SYSCALL def_bool PCI +config PCI_MMCONFIG + def_bool PCI && ACPI + source "drivers/pci/Kconfig" source "drivers/pci/pcie/Kconfig" source "drivers/pci/hotplug/Kconfig" diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index f48e3f7..ec576e6 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -32,6 +32,7 @@ arm64-obj-$(CONFIG_KGDB) += kgdb.o arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o arm64-obj-$(CONFIG_PCI) += pci.o arm64-obj-$(CONFIG_ACPI) += acpi.o +arm64-obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o obj-y += $(arm64-obj-y) vdso/ obj-m += $(arm64-obj-m) diff --git a/arch/arm64/kernel/mmconfig.c b/arch/arm64/kernel/mmconfig.c new file mode 100644 index 0000000..b0ca0ec --- /dev/null +++ b/arch/arm64/kernel/mmconfig.c @@ -0,0 +1,69 @@ +/* + * mmconfig.c - Low-level direct PCI config space access via MMCONFIG + * + * This is an ARM64 version that allows the mmconfig space to be mapped. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + */ + +#include <linux/mmconfig.h> + +#define PREFIX "PCI: " + +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; +} + +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; + } + + return 1; +} + +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); +} + +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; +} + +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; + } +}
These calls allow to map/unmap PCI config space ranges (which are specified in MMCFG ACPI table). Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org> --- arch/arm64/Kconfig | 3 ++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/mmconfig.c | 69 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 arch/arm64/kernel/mmconfig.c