From: David Woodhouse Date: Mon, 10 Apr 2017 20:02:09 +0000 (+0100) Subject: pci: Kill ARCH_GENERIC_PCI_MMAP_RESOURCE X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fpcimmap;p=users%2Fdwmw2%2Flinux.git pci: Kill ARCH_GENERIC_PCI_MMAP_RESOURCE Now that every architecture does it, we can kill the #define. This does have the side-effect that other architectures which previously didn't support mmap on sysfs resource files now get it. We have an exemption for !MMU (obviously) and for Alpha (with its bizarre setup for pre-BWX CPUs). Signed-off-by: David Woodhouse --- diff --git a/Documentation/filesystems/sysfs-pci.txt b/Documentation/filesystems/sysfs-pci.txt index 06f1d64c6f702..0aff2fee00949 100644 --- a/Documentation/filesystems/sysfs-pci.txt +++ b/Documentation/filesystems/sysfs-pci.txt @@ -112,14 +112,9 @@ to access legacy memory space. Supporting PCI access on new platforms -------------------------------------- -In order to support PCI resource mapping as described above, Linux platform -code should ideally define ARCH_GENERIC_PCI_MMAP_RESOURCE and use the generic -implementation of that functionality. To support the historical interface of -mmap() through files in /proc/bus/pci, platforms may also set HAVE_PCI_MMAP. - -Alternatively, platforms which set HAVE_PCI_MMAP may provide their own -implementation of pci_mmap_page_range() instead of defining -ARCH_GENERIC_PCI_MMAP_RESOURCE. +To support the historical interface of mmap() through files in /proc/bus/pci, +platforms may also set HAVE_PCI_MMAP. The mapping through sysfs is supported +through generic code. Platforms which support write-combining maps of PCI resources must define arch_can_pci_mmap_wc() which shall evaluate to non-zero at runtime when diff --git a/arch/arm/include/asm/pci.h b/arch/arm/include/asm/pci.h index 1f0de808d111e..f79ebe8b50191 100644 --- a/arch/arm/include/asm/pci.h +++ b/arch/arm/include/asm/pci.h @@ -27,7 +27,6 @@ static inline int pci_proc_domain(struct pci_bus *bus) #define PCI_DMA_BUS_IS_PHYS (1) #define HAVE_PCI_MMAP -#define ARCH_GENERIC_PCI_MMAP_RESOURCE static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) { diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h index 8747f7c5e0e75..1d351939d9ec6 100644 --- a/arch/arm64/include/asm/pci.h +++ b/arch/arm64/include/asm/pci.h @@ -23,8 +23,6 @@ */ #define PCI_DMA_BUS_IS_PHYS (0) -#define ARCH_GENERIC_PCI_MMAP_RESOURCE 1 - extern int isa_dma_bridge_buggy; #ifdef CONFIG_PCI diff --git a/arch/cris/include/asm/pci.h b/arch/cris/include/asm/pci.h index dcfef6407ae64..ae763c9fc4a66 100644 --- a/arch/cris/include/asm/pci.h +++ b/arch/cris/include/asm/pci.h @@ -34,7 +34,6 @@ #define PCI_DMA_BUS_IS_PHYS (1) #define HAVE_PCI_MMAP -#define ARCH_GENERIC_PCI_MMAP_RESOURCE #endif /* __KERNEL__ */ diff --git a/arch/ia64/include/asm/pci.h b/arch/ia64/include/asm/pci.h index b1d04e8bafc86..2557a2537908d 100644 --- a/arch/ia64/include/asm/pci.h +++ b/arch/ia64/include/asm/pci.h @@ -48,7 +48,6 @@ extern unsigned long ia64_max_iommu_merge_mask; #define PCI_DMA_BUS_IS_PHYS (ia64_max_iommu_merge_mask == ~0UL) #define HAVE_PCI_MMAP -#define ARCH_GENERIC_PCI_MMAP_RESOURCE #define arch_can_pci_mmap_wc() 1 #define HAVE_PCI_LEGACY diff --git a/arch/microblaze/include/asm/pci.h b/arch/microblaze/include/asm/pci.h index 5de871eb4a591..c2687004642f9 100644 --- a/arch/microblaze/include/asm/pci.h +++ b/arch/microblaze/include/asm/pci.h @@ -49,7 +49,6 @@ struct vm_area_struct; /* Tell PCI code what kind of PCI resource mappings we support */ #define HAVE_PCI_MMAP 1 -#define ARCH_GENERIC_PCI_MMAP_RESOURCE 1 #define arch_can_pci_mmap_io() 1 extern int pci_legacy_read(struct pci_bus *bus, loff_t port, u32 *val, diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h index 2339f42f047ac..aa7b8ca5d9cc4 100644 --- a/arch/mips/include/asm/pci.h +++ b/arch/mips/include/asm/pci.h @@ -107,7 +107,6 @@ extern unsigned long PCIBIOS_MIN_MEM; #define PCIBIOS_MIN_CARDBUS_IO 0x4000 #define HAVE_PCI_MMAP -#define ARCH_GENERIC_PCI_MMAP_RESOURCE #define HAVE_ARCH_PCI_RESOURCE_TO_USER /* diff --git a/arch/mn10300/include/asm/pci.h b/arch/mn10300/include/asm/pci.h index 5b75a1b2c4f62..99116d4bbba49 100644 --- a/arch/mn10300/include/asm/pci.h +++ b/arch/mn10300/include/asm/pci.h @@ -70,7 +70,6 @@ static inline int pci_controller_num(struct pci_dev *dev) } #define HAVE_PCI_MMAP -#define ARCH_GENERIC_PCI_MMAP_RESOURCE #endif /* __KERNEL__ */ diff --git a/arch/parisc/include/asm/pci.h b/arch/parisc/include/asm/pci.h index 96b7deec512d3..20965718f2b0c 100644 --- a/arch/parisc/include/asm/pci.h +++ b/arch/parisc/include/asm/pci.h @@ -193,6 +193,5 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) } #define HAVE_PCI_MMAP -#define ARCH_GENERIC_PCI_MMAP_RESOURCE #endif /* __ASM_PARISC_PCI_H */ diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index 401c62aad5e4e..1ecfb24e17b91 100644 --- a/arch/powerpc/include/asm/pci.h +++ b/arch/powerpc/include/asm/pci.h @@ -78,7 +78,6 @@ struct vm_area_struct; /* Tell PCI code what kind of PCI resource mappings we support */ #define HAVE_PCI_MMAP 1 -#define ARCH_GENERIC_PCI_MMAP_RESOURCE 1 #define arch_can_pci_mmap_io() 1 #define arch_can_pci_mmap_wc() 1 diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h index 0033f0df2b3b2..5802cd7e523f2 100644 --- a/arch/sh/include/asm/pci.h +++ b/arch/sh/include/asm/pci.h @@ -65,7 +65,6 @@ extern int pci_is_66mhz_capable(struct pci_channel *hose, extern unsigned long PCIBIOS_MIN_IO, PCIBIOS_MIN_MEM; #define HAVE_PCI_MMAP -#define ARCH_GENERIC_PCI_MMAP_RESOURCE /* Dynamic DMA mapping stuff. * SuperH has everything mapped statically like x86. diff --git a/arch/sparc/include/asm/pci_64.h b/arch/sparc/include/asm/pci_64.h index 95d41c827391f..671274e36cfad 100644 --- a/arch/sparc/include/asm/pci_64.h +++ b/arch/sparc/include/asm/pci_64.h @@ -43,7 +43,6 @@ static inline int pci_proc_domain(struct pci_bus *bus) /* Platform support for /proc/bus/pci/X/Y mmap()s. */ #define HAVE_PCI_MMAP -#define ARCH_GENERIC_PCI_MMAP_RESOURCE #define arch_can_pci_mmap_io() 1 #define HAVE_ARCH_PCI_GET_UNMAPPED_AREA #define get_pci_unmapped_area get_fb_unmapped_area diff --git a/arch/unicore32/include/asm/pci.h b/arch/unicore32/include/asm/pci.h index ac5acdf4c4d01..a51290862acdd 100644 --- a/arch/unicore32/include/asm/pci.h +++ b/arch/unicore32/include/asm/pci.h @@ -17,7 +17,6 @@ #include /* for PCIBIOS_MIN_* */ #define HAVE_PCI_MMAP -#define ARCH_GENERIC_PCI_MMAP_RESOURCE #endif /* __KERNEL__ */ #endif diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h index d32175e302593..f71c0d119756a 100644 --- a/arch/x86/include/asm/pci.h +++ b/arch/x86/include/asm/pci.h @@ -97,7 +97,6 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq); #define HAVE_PCI_MMAP #define arch_can_pci_mmap_wc() pat_enabled() -#define ARCH_GENERIC_PCI_MMAP_RESOURCE #ifdef CONFIG_PCI extern void early_quirks(void); diff --git a/arch/xtensa/include/asm/pci.h b/arch/xtensa/include/asm/pci.h index d5a82153a7c5d..c312ee3929b3b 100644 --- a/arch/xtensa/include/asm/pci.h +++ b/arch/xtensa/include/asm/pci.h @@ -46,7 +46,6 @@ extern struct pci_controller* pcibios_alloc_controller(void); /* Tell PCI code what kind of PCI resource mappings we support */ #define HAVE_PCI_MMAP 1 -#define ARCH_GENERIC_PCI_MMAP_RESOURCE 1 #define arch_can_pci_mmap_io() 1 #endif /* __KERNEL__ */ diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 941970936840e..915acda945baf 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -5,9 +5,10 @@ obj-$(CONFIG_PCI) += access.o bus.o probe.o host-bridge.o remove.o pci.o \ pci-driver.o search.o pci-sysfs.o rom.o setup-res.o \ - irq.o vpd.o setup-bus.o vc.o mmap.o setup-irq.o + irq.o vpd.o setup-bus.o vc.o setup-irq.o ifdef CONFIG_PCI +obj-$(CONFIG_MMU) += mmap.o obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_SYSFS) += slot.o obj-$(CONFIG_OF) += of.o diff --git a/drivers/pci/mmap.c b/drivers/pci/mmap.c index 814a3ce341fcd..c4dc4eaf739c5 100644 --- a/drivers/pci/mmap.c +++ b/drivers/pci/mmap.c @@ -11,8 +11,6 @@ #include #include -#ifdef ARCH_GENERIC_PCI_MMAP_RESOURCE - /* * Modern setup: generic pci_mmap_resource_range(), and implement the legacy * pci_mmap_page_range() (if needed) as a wrapper round it. @@ -69,28 +67,3 @@ int pci_mmap_resource_range(struct pci_dev *pdev, int bar, vma->vm_end - vma->vm_start, vma->vm_page_prot); } - -#elif defined(HAVE_PCI_MMAP) /* && !ARCH_GENERIC_PCI_MMAP_RESOURCE */ - -/* - * Legacy setup: Impement pci_mmap_resource_range() as a wrapper around - * the architecture's pci_mmap_page_range(), converting to "user visible" - * addresses as necessary. - */ - -int pci_mmap_resource_range(struct pci_dev *pdev, int bar, - struct vm_area_struct *vma, - enum pci_mmap_state mmap_state, int write_combine) -{ - resource_size_t start, end; - - /* - * pci_mmap_page_range() expects the same kind of entry as coming - * from /proc/bus/pci/ which is a "user visible" value. If this is - * different from the resource itself, arch will do necessary fixup. - */ - pci_resource_to_user(pdev, bar, &pdev->resource[bar], &start, &end); - vma->vm_pgoff += start >> PAGE_SHIFT; - return pci_mmap_page_range(pdev, bar, vma, mmap_state, write_combine); -} -#endif diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index eb6bee8724cc1..1a8cb40902d8a 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1183,7 +1183,7 @@ void pci_remove_legacy_files(struct pci_bus *b) } #endif /* HAVE_PCI_LEGACY */ -#if defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE) +#if defined(CONFIG_MMU) && !defined(__alpha__) int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma, enum pci_mmap_api mmap_api) diff --git a/include/linux/pci.h b/include/linux/pci.h index 024a1beda008c..09d9dcf1f2ea8 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1689,17 +1689,14 @@ static inline int pci_irqd_intx_xlate(struct irq_domain *d, #include -/* These two functions provide almost identical functionality. Depennding - * on the architecture, one will be implemented as a wrapper around the - * other (in drivers/pci/mmap.c). +/* These two functions provide almost identical functionality. * * pci_mmap_resource_range() maps a specific BAR, and vm->vm_pgoff * is expected to be an offset within that region. * - * pci_mmap_page_range() is the legacy architecture-specific interface, - * which accepts a "user visible" resource address converted by - * pci_resource_to_user(), as used in the legacy mmap() interface in - * /proc/bus/pci/. + * pci_mmap_page_range() is the legacy interface which accepts a "user + * visible" resource address converted by pci_resource_to_user(), as + * used in the legacy mmap() interface in /proc/bus/pci/. */ int pci_mmap_resource_range(struct pci_dev *dev, int bar, struct vm_area_struct *vma,