Commit e343a895a9f342f239c5e3c5ffc6c0b1707e6244

Authored by Linus Torvalds

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost

lib: use generic pci_iomap on all architectures

Many architectures don't want to pull in iomap.c,
so they ended up duplicating pci_iomap from that file.
That function isn't trivial, and we are going to modify it
https://lkml.org/lkml/2011/11/14/183
so the duplication hurts.

This reduces the scope of the problem significantly,
by moving pci_iomap to a separate file and
referencing that from all architectures.

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
  alpha: drop pci_iomap/pci_iounmap from pci-noop.c
  mn10300: switch to GENERIC_PCI_IOMAP
  mn10300: add missing __iomap markers
  frv: switch to GENERIC_PCI_IOMAP
  tile: switch to GENERIC_PCI_IOMAP
  tile: don't panic on iomap
  sparc: switch to GENERIC_PCI_IOMAP
  sh: switch to GENERIC_PCI_IOMAP
  powerpc: switch to GENERIC_PCI_IOMAP
  parisc: switch to GENERIC_PCI_IOMAP
  mips: switch to GENERIC_PCI_IOMAP
  microblaze: switch to GENERIC_PCI_IOMAP
  arm: switch to GENERIC_PCI_IOMAP
  alpha: switch to GENERIC_PCI_IOMAP
  lib: add GENERIC_PCI_IOMAP
  lib: move GENERIC_IOMAP to lib/Kconfig

Fix up trivial conflicts due to changes nearby in arch/{m68k,score}/Kconfig

Showing 48 changed files Side-by-side Diff

... ... @@ -70,10 +70,6 @@
70 70 bool
71 71 default y
72 72  
73   -config GENERIC_IOMAP
74   - bool
75   - default n
76   -
77 73 source "init/Kconfig"
78 74 source "kernel/Kconfig.freezer"
79 75  
... ... @@ -319,6 +315,7 @@
319 315 config PCI
320 316 bool
321 317 depends on !ALPHA_JENSEN
  318 + select GENERIC_PCI_IOMAP
322 319 default y
323 320 help
324 321 Find out whether you have a PCI motherboard. PCI is the name of a
arch/alpha/kernel/pci-noop.c
... ... @@ -185,16 +185,4 @@
185 185  
186 186 struct dma_map_ops *dma_ops = &alpha_noop_ops;
187 187 EXPORT_SYMBOL(dma_ops);
188   -
189   -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
190   -{
191   - return NULL;
192   -}
193   -
194   -void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
195   -{
196   -}
197   -
198   -EXPORT_SYMBOL(pci_iomap);
199   -EXPORT_SYMBOL(pci_iounmap);
arch/alpha/kernel/pci.c
... ... @@ -508,38 +508,14 @@
508 508 return -EOPNOTSUPP;
509 509 }
510 510  
511   -/* Create an __iomem token from a PCI BAR. Copied from lib/iomap.c with
512   - no changes, since we don't want the other things in that object file. */
  511 +/* Destroy an __iomem token. Not copied from lib/iomap.c. */
513 512  
514   -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
515   -{
516   - resource_size_t start = pci_resource_start(dev, bar);
517   - resource_size_t len = pci_resource_len(dev, bar);
518   - unsigned long flags = pci_resource_flags(dev, bar);
519   -
520   - if (!len || !start)
521   - return NULL;
522   - if (maxlen && len > maxlen)
523   - len = maxlen;
524   - if (flags & IORESOURCE_IO)
525   - return ioport_map(start, len);
526   - if (flags & IORESOURCE_MEM) {
527   - /* Not checking IORESOURCE_CACHEABLE because alpha does
528   - not distinguish between ioremap and ioremap_nocache. */
529   - return ioremap(start, len);
530   - }
531   - return NULL;
532   -}
533   -
534   -/* Destroy that token. Not copied from lib/iomap.c. */
535   -
536 513 void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
537 514 {
538 515 if (__is_mmio(addr))
539 516 iounmap(addr);
540 517 }
541 518  
542   -EXPORT_SYMBOL(pci_iomap);
543 519 EXPORT_SYMBOL(pci_iounmap);
544 520  
545 521 /* FIXME: Some boxes have multiple ISA bridges! */
... ... @@ -31,6 +31,7 @@
31 31 select HAVE_SPARSE_IRQ
32 32 select GENERIC_IRQ_SHOW
33 33 select CPU_PM if (SUSPEND || CPU_IDLE)
  34 + select GENERIC_PCI_IOMAP
34 35 help
35 36 The ARM series is a line of low-power-consumption RISC chip designs
36 37 licensed by ARM Ltd and targeted at embedded applications and
arch/arm/include/asm/io.h
... ... @@ -27,6 +27,7 @@
27 27 #include <asm/byteorder.h>
28 28 #include <asm/memory.h>
29 29 #include <asm/system.h>
  30 +#include <asm-generic/pci_iomap.h>
30 31  
31 32 /*
32 33 * ISA I/O bus memory addresses are 1:1 with the physical address.
... ... @@ -306,7 +307,6 @@
306 307  
307 308 struct pci_dev;
308 309  
309   -extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen);
310 310 extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
311 311  
312 312 /*
... ... @@ -35,27 +35,6 @@
35 35 unsigned int pci_flags = PCI_REASSIGN_ALL_RSRC;
36 36 EXPORT_SYMBOL(pci_flags);
37 37  
38   -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
39   -{
40   - resource_size_t start = pci_resource_start(dev, bar);
41   - resource_size_t len = pci_resource_len(dev, bar);
42   - unsigned long flags = pci_resource_flags(dev, bar);
43   -
44   - if (!len || !start)
45   - return NULL;
46   - if (maxlen && len > maxlen)
47   - len = maxlen;
48   - if (flags & IORESOURCE_IO)
49   - return ioport_map(start, len);
50   - if (flags & IORESOURCE_MEM) {
51   - if (flags & IORESOURCE_CACHEABLE)
52   - return ioremap(start, len);
53   - return ioremap_nocache(start, len);
54   - }
55   - return NULL;
56   -}
57   -EXPORT_SYMBOL(pci_iomap);
58   -
59 38 void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
60 39 {
61 40 if ((unsigned long)addr >= VMALLOC_START &&
... ... @@ -19,10 +19,6 @@
19 19 config ARCH_USES_GETTIMEOFFSET
20 20 def_bool n
21 21  
22   -config GENERIC_IOMAP
23   - bool
24   - default y
25   -
26 22 config ARCH_HAS_ILOG2_U32
27 23 bool
28 24 default n
... ... @@ -52,6 +48,7 @@
52 48 select HAVE_IDE
53 49 select HAVE_GENERIC_HARDIRQS
54 50 select GENERIC_IRQ_SHOW
  51 + select GENERIC_IOMAP
55 52  
56 53 config HZ
57 54 int
... ... @@ -317,6 +317,7 @@
317 317 bool "Use PCI"
318 318 depends on MB93090_MB00
319 319 default y
  320 + select GENERIC_PCI_IOMAP
320 321 help
321 322 Some FR-V systems (such as the MB93090-MB00 VDK) have PCI
322 323 onboard. If you have one of these boards and you wish to use the PCI
arch/frv/include/asm/io.h
... ... @@ -21,6 +21,7 @@
21 21 #include <asm/virtconvert.h>
22 22 #include <asm/string.h>
23 23 #include <asm/mb-regs.h>
  24 +#include <asm-generic/pci_iomap.h>
24 25 #include <linux/delay.h>
25 26  
26 27 /*
... ... @@ -370,7 +371,6 @@
370 371  
371 372 /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
372 373 struct pci_dev;
373   -extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
374 374 static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p)
375 375 {
376 376 }
arch/frv/mb93090-mb00/Makefile
... ... @@ -3,7 +3,7 @@
3 3 #
4 4  
5 5 ifeq "$(CONFIG_PCI)" "y"
6   -obj-y := pci-frv.o pci-irq.o pci-vdk.o pci-iomap.o
  6 +obj-y := pci-frv.o pci-irq.o pci-vdk.o
7 7  
8 8 ifeq "$(CONFIG_MMU)" "y"
9 9 obj-y += pci-dma.o
arch/frv/mb93090-mb00/pci-iomap.c
1   -/* pci-iomap.c: description
2   - *
3   - * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
4   - * Written by David Howells (dhowells@redhat.com)
5   - *
6   - * This program is free software; you can redistribute it and/or
7   - * modify it under the terms of the GNU General Public License
8   - * as published by the Free Software Foundation; either version
9   - * 2 of the License, or (at your option) any later version.
10   - */
11   -#include <linux/pci.h>
12   -#include <linux/module.h>
13   -
14   -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
15   -{
16   - resource_size_t start = pci_resource_start(dev, bar);
17   - resource_size_t len = pci_resource_len(dev, bar);
18   - unsigned long flags = pci_resource_flags(dev, bar);
19   -
20   - if (!len || !start)
21   - return NULL;
22   -
23   - if ((flags & IORESOURCE_IO) || (flags & IORESOURCE_MEM))
24   - return (void __iomem *) start;
25   -
26   - return NULL;
27   -}
28   -
29   -EXPORT_SYMBOL(pci_iomap);
arch/hexagon/Kconfig
... ... @@ -26,6 +26,7 @@
26 26 select HAVE_ARCH_KGDB
27 27 select HAVE_ARCH_TRACEHOOK
28 28 select NO_IOPORT
  29 + select GENERIC_IOMAP
29 30 # mostly generic routines, with some accelerated ones
30 31 ---help---
31 32 Qualcomm Hexagon is a processor architecture designed for high
... ... @@ -71,9 +72,6 @@
71 72 # Use the generic interrupt handling code in kernel/irq/:
72 73 #
73 74 config GENERIC_IRQ_PROBE
74   - def_bool y
75   -
76   -config GENERIC_IOMAP
77 75 def_bool y
78 76  
79 77 #config ZONE_DMA
... ... @@ -32,6 +32,7 @@
32 32 select GENERIC_IRQ_SHOW
33 33 select ARCH_WANT_OPTIONAL_GPIOLIB
34 34 select ARCH_HAVE_NMI_SAFE_CMPXCHG
  35 + select GENERIC_IOMAP
35 36 default y
36 37 help
37 38 The Itanium Processor Family is Intel's 64-bit successor to
... ... @@ -102,10 +103,6 @@
102 103 default y
103 104  
104 105 config EFI
105   - bool
106   - default y
107   -
108   -config GENERIC_IOMAP
109 106 bool
110 107 default y
111 108  
... ... @@ -37,9 +37,6 @@
37 37 bool
38 38 default y
39 39  
40   -config GENERIC_IOMAP
41   - def_bool MMU
42   -
43 40 config GENERIC_CSUM
44 41 bool
45 42  
... ... @@ -81,6 +78,7 @@
81 78 config MMU
82 79 bool "MMU-based Paged Memory Management Support"
83 80 default y
  81 + select GENERIC_IOMAP
84 82 help
85 83 Select if you want MMU-based virtualised addressing space
86 84 support by paged memory management. If unsure, say 'Y'.
arch/microblaze/Kconfig
... ... @@ -17,6 +17,7 @@
17 17 select HAVE_GENERIC_HARDIRQS
18 18 select GENERIC_IRQ_PROBE
19 19 select GENERIC_IRQ_SHOW
  20 + select GENERIC_PCI_IOMAP
20 21  
21 22 config SWAP
22 23 def_bool n
arch/microblaze/pci/iomap.c
... ... @@ -10,25 +10,6 @@
10 10 #include <asm/io.h>
11 11 #include <asm/pci-bridge.h>
12 12  
13   -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
14   -{
15   - resource_size_t start = pci_resource_start(dev, bar);
16   - resource_size_t len = pci_resource_len(dev, bar);
17   - unsigned long flags = pci_resource_flags(dev, bar);
18   -
19   - if (!len)
20   - return NULL;
21   - if (max && len > max)
22   - len = max;
23   - if (flags & IORESOURCE_IO)
24   - return ioport_map(start, len);
25   - if (flags & IORESOURCE_MEM)
26   - return ioremap(start, len);
27   - /* What? */
28   - return NULL;
29   -}
30   -EXPORT_SYMBOL(pci_iomap);
31   -
32 13 void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
33 14 {
34 15 if (isa_vaddr_is_ioport(addr))
... ... @@ -2317,6 +2317,7 @@
2317 2317 bool "Support for PCI controller"
2318 2318 depends on HW_HAS_PCI
2319 2319 select PCI_DOMAINS
  2320 + select GENERIC_PCI_IOMAP
2320 2321 help
2321 2322 Find out whether you have a PCI motherboard. PCI is the name of a
2322 2323 bus system, i.e. the way the CPU talks to the other stuff inside
arch/mips/lib/iomap-pci.c
... ... @@ -40,32 +40,6 @@
40 40 return (void __iomem *) (ctrl->io_map_base + port);
41 41 }
42 42  
43   -/*
44   - * Create a virtual mapping cookie for a PCI BAR (memory or IO)
45   - */
46   -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
47   -{
48   - resource_size_t start = pci_resource_start(dev, bar);
49   - resource_size_t len = pci_resource_len(dev, bar);
50   - unsigned long flags = pci_resource_flags(dev, bar);
51   -
52   - if (!len || !start)
53   - return NULL;
54   - if (maxlen && len > maxlen)
55   - len = maxlen;
56   - if (flags & IORESOURCE_IO)
57   - return ioport_map_pci(dev, start, len);
58   - if (flags & IORESOURCE_MEM) {
59   - if (flags & IORESOURCE_CACHEABLE)
60   - return ioremap(start, len);
61   - return ioremap_nocache(start, len);
62   - }
63   - /* What? */
64   - return NULL;
65   -}
66   -
67   -EXPORT_SYMBOL(pci_iomap);
68   -
69 43 void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
70 44 {
71 45 iounmap(addr);
arch/mn10300/Kconfig
... ... @@ -252,6 +252,7 @@
252 252 bool "Use PCI"
253 253 depends on MN10300_UNIT_ASB2305
254 254 default y
  255 + select GENERIC_PCI_IOMAP
255 256 help
256 257 Some systems (such as the ASB2305) have PCI onboard. If you have one
257 258 of these boards and you wish to use the PCI facilities, say Y here.
arch/mn10300/include/asm/io.h
... ... @@ -229,7 +229,6 @@
229 229  
230 230 /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
231 231 struct pci_dev;
232   -extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
233 232 static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p)
234 233 {
235 234 }
236 235  
237 236  
238 237  
... ... @@ -251,15 +250,15 @@
251 250 /*
252 251 * Change "struct page" to physical address.
253 252 */
254   -static inline void *__ioremap(unsigned long offset, unsigned long size,
255   - unsigned long flags)
  253 +static inline void __iomem *__ioremap(unsigned long offset, unsigned long size,
  254 + unsigned long flags)
256 255 {
257   - return (void *) offset;
  256 + return (void __iomem *) offset;
258 257 }
259 258  
260   -static inline void *ioremap(unsigned long offset, unsigned long size)
  259 +static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
261 260 {
262   - return (void *) offset;
  261 + return (void __iomem *) offset;
263 262 }
264 263  
265 264 /*
266 265  
267 266  
... ... @@ -267,14 +266,14 @@
267 266 * area. it's useful if some control registers are in such an area and write
268 267 * combining or read caching is not desirable:
269 268 */
270   -static inline void *ioremap_nocache(unsigned long offset, unsigned long size)
  269 +static inline void __iomem *ioremap_nocache(unsigned long offset, unsigned long size)
271 270 {
272   - return (void *) (offset | 0x20000000);
  271 + return (void __iomem *) (offset | 0x20000000);
273 272 }
274 273  
275 274 #define ioremap_wc ioremap_nocache
276 275  
277   -static inline void iounmap(void *addr)
  276 +static inline void iounmap(void __iomem *addr)
278 277 {
279 278 }
280 279  
arch/mn10300/unit-asb2305/Makefile
... ... @@ -5,5 +5,5 @@
5 5 ###############################################################################
6 6 obj-y := unit-init.o leds.o
7 7  
8   -obj-$(CONFIG_PCI) += pci.o pci-asb2305.o pci-irq.o pci-iomap.o
  8 +obj-$(CONFIG_PCI) += pci.o pci-asb2305.o pci-irq.o
arch/mn10300/unit-asb2305/pci-iomap.c
1   -/* ASB2305 PCI I/O mapping handler
2   - *
3   - * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4   - * Written by David Howells (dhowells@redhat.com)
5   - *
6   - * This program is free software; you can redistribute it and/or
7   - * modify it under the terms of the GNU General Public Licence
8   - * as published by the Free Software Foundation; either version
9   - * 2 of the Licence, or (at your option) any later version.
10   - */
11   -#include <linux/pci.h>
12   -#include <linux/module.h>
13   -
14   -/*
15   - * Create a virtual mapping cookie for a PCI BAR (memory or IO)
16   - */
17   -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
18   -{
19   - resource_size_t start = pci_resource_start(dev, bar);
20   - resource_size_t len = pci_resource_len(dev, bar);
21   - unsigned long flags = pci_resource_flags(dev, bar);
22   -
23   - if (!len || !start)
24   - return NULL;
25   -
26   - if ((flags & IORESOURCE_IO) || (flags & IORESOURCE_MEM))
27   - return (void __iomem *) start;
28   -
29   - return NULL;
30   -}
31   -EXPORT_SYMBOL(pci_iomap);
arch/openrisc/Kconfig
... ... @@ -38,9 +38,6 @@
38 38 config GENERIC_HWEIGHT
39 39 def_bool y
40 40  
41   -config GENERIC_IOMAP
42   - def_bool y
43   -
44 41 config NO_IOPORT
45 42 def_bool y
46 43  
... ... @@ -14,6 +14,7 @@
14 14 select GENERIC_ATOMIC64 if !64BIT
15 15 select HAVE_GENERIC_HARDIRQS
16 16 select GENERIC_IRQ_PROBE
  17 + select GENERIC_PCI_IOMAP
17 18 select IRQ_PER_CPU
18 19 select ARCH_HAVE_NMI_SAFE_CMPXCHG
19 20  
arch/parisc/lib/iomap.c
... ... @@ -436,28 +436,6 @@
436 436 }
437 437 }
438 438  
439   -/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
440   -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
441   -{
442   - resource_size_t start = pci_resource_start(dev, bar);
443   - resource_size_t len = pci_resource_len(dev, bar);
444   - unsigned long flags = pci_resource_flags(dev, bar);
445   -
446   - if (!len || !start)
447   - return NULL;
448   - if (maxlen && len > maxlen)
449   - len = maxlen;
450   - if (flags & IORESOURCE_IO)
451   - return ioport_map(start, len);
452   - if (flags & IORESOURCE_MEM) {
453   - if (flags & IORESOURCE_CACHEABLE)
454   - return ioremap(start, len);
455   - return ioremap_nocache(start, len);
456   - }
457   - /* What? */
458   - return NULL;
459   -}
460   -
461 439 void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
462 440 {
463 441 if (!INDIRECT_ADDR(addr)) {
... ... @@ -483,6 +461,5 @@
483 461 EXPORT_SYMBOL(iowrite32_rep);
484 462 EXPORT_SYMBOL(ioport_map);
485 463 EXPORT_SYMBOL(ioport_unmap);
486   -EXPORT_SYMBOL(pci_iomap);
487 464 EXPORT_SYMBOL(pci_iounmap);
arch/powerpc/Kconfig
... ... @@ -718,6 +718,7 @@
718 718 default PCI_PERMEDIA if !4xx && !CPM2 && !8xx
719 719 default PCI_QSPAN if !4xx && !CPM2 && 8xx
720 720 select ARCH_SUPPORTS_MSI
  721 + select GENERIC_PCI_IOMAP
721 722 help
722 723 Find out whether your system includes a PCI bus. PCI is the name of
723 724 a bus system, i.e. the way the CPU talks to the other stuff inside
arch/powerpc/kernel/iomap.c
... ... @@ -119,24 +119,6 @@
119 119 EXPORT_SYMBOL(ioport_unmap);
120 120  
121 121 #ifdef CONFIG_PCI
122   -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
123   -{
124   - resource_size_t start = pci_resource_start(dev, bar);
125   - resource_size_t len = pci_resource_len(dev, bar);
126   - unsigned long flags = pci_resource_flags(dev, bar);
127   -
128   - if (!len)
129   - return NULL;
130   - if (max && len > max)
131   - len = max;
132   - if (flags & IORESOURCE_IO)
133   - return ioport_map(start, len);
134   - if (flags & IORESOURCE_MEM)
135   - return ioremap(start, len);
136   - /* What? */
137   - return NULL;
138   -}
139   -
140 122 void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
141 123 {
142 124 if (isa_vaddr_is_ioport(addr))
... ... @@ -146,7 +128,6 @@
146 128 iounmap(addr);
147 129 }
148 130  
149   -EXPORT_SYMBOL(pci_iomap);
150 131 EXPORT_SYMBOL(pci_iounmap);
151 132 #endif /* CONFIG_PCI */
arch/powerpc/platforms/Kconfig
... ... @@ -175,9 +175,6 @@
175 175 config PPC_IO_WORKAROUNDS
176 176 bool
177 177  
178   -config GENERIC_IOMAP
179   - bool
180   -
181 178 source "drivers/cpufreq/Kconfig"
182 179  
183 180 menu "CPU Frequency drivers"
... ... @@ -4,6 +4,7 @@
4 4 def_bool y
5 5 select HAVE_GENERIC_HARDIRQS
6 6 select GENERIC_IRQ_SHOW
  7 + select GENERIC_IOMAP
7 8 select HAVE_MEMBLOCK
8 9 select HAVE_MEMBLOCK_NODE_MAP
9 10 select ARCH_DISCARD_MEMBLOCK
... ... @@ -35,9 +36,6 @@
35 36  
36 37 config CPU_SCORE7
37 38 bool
38   -
39   -config GENERIC_IOMAP
40   - def_bool y
41 39  
42 40 config NO_DMA
43 41 bool
... ... @@ -85,9 +85,6 @@
85 85 config GENERIC_CALIBRATE_DELAY
86 86 bool
87 87  
88   -config GENERIC_IOMAP
89   - bool
90   -
91 88 config GENERIC_CLOCKEVENTS
92 89 def_bool y
93 90  
... ... @@ -861,6 +858,7 @@
861 858 bool "PCI support"
862 859 depends on SYS_SUPPORTS_PCI
863 860 select PCI_DOMAINS
  861 + select GENERIC_PCI_IOMAP
864 862 help
865 863 Find out whether you have a PCI motherboard. PCI is the name of a
866 864 bus system, i.e. the way the CPU talks to the other stuff inside
arch/sh/drivers/pci/pci.c
... ... @@ -393,29 +393,6 @@
393 393 return (void __iomem *)(chan->io_map_base + port);
394 394 }
395 395  
396   -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
397   -{
398   - resource_size_t start = pci_resource_start(dev, bar);
399   - resource_size_t len = pci_resource_len(dev, bar);
400   - unsigned long flags = pci_resource_flags(dev, bar);
401   -
402   - if (unlikely(!len || !start))
403   - return NULL;
404   - if (maxlen && len > maxlen)
405   - len = maxlen;
406   -
407   - if (flags & IORESOURCE_IO)
408   - return ioport_map_pci(dev, start, len);
409   - if (flags & IORESOURCE_MEM) {
410   - if (flags & IORESOURCE_CACHEABLE)
411   - return ioremap(start, len);
412   - return ioremap_nocache(start, len);
413   - }
414   -
415   - return NULL;
416   -}
417   -EXPORT_SYMBOL(pci_iomap);
418   -
419 396 void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
420 397 {
421 398 iounmap(addr);
... ... @@ -28,6 +28,7 @@
28 28 select HAVE_GENERIC_HARDIRQS
29 29 select GENERIC_IRQ_SHOW
30 30 select USE_GENERIC_SMP_HELPERS if SMP
  31 + select GENERIC_PCI_IOMAP
31 32  
32 33 config SPARC32
33 34 def_bool !64BIT
arch/sparc/include/asm/io_32.h
... ... @@ -7,6 +7,7 @@
7 7  
8 8 #include <asm/page.h> /* IO address mapping routines need this */
9 9 #include <asm/system.h>
  10 +#include <asm-generic/pci_iomap.h>
10 11  
11 12 #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
12 13  
... ... @@ -324,7 +325,6 @@
324 325  
325 326 /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
326 327 struct pci_dev;
327   -extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
328 328 extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
329 329  
330 330 /*
arch/sparc/include/asm/io_64.h
... ... @@ -8,6 +8,7 @@
8 8 #include <asm/page.h> /* IO address mapping routines need this */
9 9 #include <asm/system.h>
10 10 #include <asm/asi.h>
  11 +#include <asm-generic/pci_iomap.h>
11 12  
12 13 /* PC crapola... */
13 14 #define __SLOW_DOWN_IO do { } while (0)
... ... @@ -514,7 +515,6 @@
514 515  
515 516 /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
516 517 struct pci_dev;
517   -extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
518 518 extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
519 519  
520 520 static inline int sbus_can_dma_64bit(void)
arch/sparc/lib/iomap.c
... ... @@ -18,32 +18,9 @@
18 18 EXPORT_SYMBOL(ioport_map);
19 19 EXPORT_SYMBOL(ioport_unmap);
20 20  
21   -/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
22   -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
23   -{
24   - resource_size_t start = pci_resource_start(dev, bar);
25   - resource_size_t len = pci_resource_len(dev, bar);
26   - unsigned long flags = pci_resource_flags(dev, bar);
27   -
28   - if (!len || !start)
29   - return NULL;
30   - if (maxlen && len > maxlen)
31   - len = maxlen;
32   - if (flags & IORESOURCE_IO)
33   - return ioport_map(start, len);
34   - if (flags & IORESOURCE_MEM) {
35   - if (flags & IORESOURCE_CACHEABLE)
36   - return ioremap(start, len);
37   - return ioremap_nocache(start, len);
38   - }
39   - /* What? */
40   - return NULL;
41   -}
42   -
43 21 void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
44 22 {
45 23 /* nothing to do */
46 24 }
47   -EXPORT_SYMBOL(pci_iomap);
48 25 EXPORT_SYMBOL(pci_iounmap);
... ... @@ -321,6 +321,7 @@
321 321 bool "PCI support"
322 322 default y
323 323 select PCI_DOMAINS
  324 + select GENERIC_PCI_IOMAP
324 325 ---help---
325 326 Enable PCI root complex support, so PCIe endpoint devices can
326 327 be attached to the Tile chip. Many, but not all, PCI devices
arch/tile/include/asm/io.h
... ... @@ -204,7 +204,8 @@
204 204  
205 205 static inline void __iomem *ioport_map(unsigned long port, unsigned int len)
206 206 {
207   - return (void __iomem *) ioport_panic();
  207 + pr_info("ioport_map: mapping IO resources is unsupported on tile.\n");
  208 + return NULL;
208 209 }
209 210  
210 211 static inline void ioport_unmap(void __iomem *addr)
arch/tile/include/asm/pci.h
... ... @@ -16,6 +16,7 @@
16 16 #define _ASM_TILE_PCI_H
17 17  
18 18 #include <linux/pci.h>
  19 +#include <asm-generic/pci_iomap.h>
19 20  
20 21 /*
21 22 * Structure of a PCI controller (host bridge)
... ... @@ -49,7 +50,6 @@
49 50 int __devinit tile_pci_init(void);
50 51 int __devinit pcibios_init(void);
51 52  
52   -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
53 53 static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) {}
54 54  
55 55 void __devinit pcibios_fixup_bus(struct pci_bus *bus);
arch/tile/kernel/pci.c
... ... @@ -466,27 +466,6 @@
466 466 return 0;
467 467 }
468 468  
469   -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
470   -{
471   - unsigned long start = pci_resource_start(dev, bar);
472   - unsigned long len = pci_resource_len(dev, bar);
473   - unsigned long flags = pci_resource_flags(dev, bar);
474   -
475   - if (!len)
476   - return NULL;
477   - if (max && len > max)
478   - len = max;
479   -
480   - if (!(flags & IORESOURCE_MEM)) {
481   - pr_info("PCI: Trying to map invalid resource %#lx\n", flags);
482   - start = 0;
483   - }
484   -
485   - return (void __iomem *)start;
486   -}
487   -EXPORT_SYMBOL(pci_iomap);
488   -
489   -
490 469 /****************************************************************
491 470 *
492 471 * Tile PCI config space read/write routines
arch/unicore32/Kconfig
... ... @@ -12,6 +12,7 @@
12 12 select GENERIC_IRQ_PROBE
13 13 select GENERIC_IRQ_SHOW
14 14 select ARCH_WANT_FRAME_POINTERS
  15 + select GENERIC_IOMAP
15 16 help
16 17 UniCore-32 is 32-bit Instruction Set Architecture,
17 18 including a series of low-power-consumption RISC chip
... ... @@ -28,9 +29,6 @@
28 29 bool
29 30  
30 31 config GENERIC_CSUM
31   - def_bool y
32   -
33   -config GENERIC_IOMAP
34 32 def_bool y
35 33  
36 34 config NO_IOPORT
... ... @@ -78,6 +78,7 @@
78 78 select HAVE_BPF_JIT if (X86_64 && NET)
79 79 select CLKEVT_I8253
80 80 select ARCH_HAVE_NMI_SAFE_CMPXCHG
  81 + select GENERIC_IOMAP
81 82  
82 83 config INSTRUCTION_DECODER
83 84 def_bool (KPROBES || PERF_EVENTS)
... ... @@ -142,9 +143,6 @@
142 143  
143 144 config GENERIC_ISA_DMA
144 145 def_bool ISA_DMA_API
145   -
146   -config GENERIC_IOMAP
147   - def_bool y
148 146  
149 147 config GENERIC_BUG
150 148 def_bool y
include/asm-generic/io.h
... ... @@ -19,6 +19,8 @@
19 19 #include <asm-generic/iomap.h>
20 20 #endif
21 21  
  22 +#include <asm-generic/pci_iomap.h>
  23 +
22 24 #ifndef mmiowb
23 25 #define mmiowb() do {} while (0)
24 26 #endif
25 27  
... ... @@ -283,9 +285,7 @@
283 285 #define __io_virt(x) ((void __force *) (x))
284 286  
285 287 #ifndef CONFIG_GENERIC_IOMAP
286   -/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
287 288 struct pci_dev;
288   -extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
289 289 static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p)
290 290 {
291 291 }
include/asm-generic/iomap.h
... ... @@ -67,19 +67,16 @@
67 67 #endif
68 68  
69 69 #ifdef CONFIG_PCI
70   -/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
  70 +/* Destroy a virtual mapping cookie for a PCI BAR (memory or IO) */
71 71 struct pci_dev;
72   -extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
73 72 extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
74 73 #else
75 74 struct pci_dev;
76   -static inline void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
77   -{
78   - return NULL;
79   -}
80 75 static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
81 76 { }
82 77 #endif
  78 +
  79 +#include <asm-generic/pci_iomap.h>
83 80  
84 81 #endif
include/asm-generic/pci_iomap.h
  1 +/* Generic I/O port emulation, based on MN10300 code
  2 + *
  3 + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4 + * Written by David Howells (dhowells@redhat.com)
  5 + *
  6 + * This program is free software; you can redistribute it and/or
  7 + * modify it under the terms of the GNU General Public Licence
  8 + * as published by the Free Software Foundation; either version
  9 + * 2 of the Licence, or (at your option) any later version.
  10 + */
  11 +#ifndef __ASM_GENERIC_PCI_IOMAP_H
  12 +#define __ASM_GENERIC_PCI_IOMAP_H
  13 +
  14 +struct pci_dev;
  15 +#ifdef CONFIG_PCI
  16 +/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
  17 +extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
  18 +#else
  19 +static inline void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
  20 +{
  21 + return NULL;
  22 +}
  23 +#endif
  24 +
  25 +#endif /* __ASM_GENERIC_IO_H */
... ... @@ -19,6 +19,13 @@
19 19 config GENERIC_FIND_FIRST_BIT
20 20 bool
21 21  
  22 +config GENERIC_PCI_IOMAP
  23 + bool
  24 +
  25 +config GENERIC_IOMAP
  26 + bool
  27 + select GENERIC_PCI_IOMAP
  28 +
22 29 config CRC_CCITT
23 30 tristate "CRC-CCITT functions"
24 31 help
... ... @@ -33,6 +33,7 @@
33 33  
34 34 lib-$(CONFIG_HOTPLUG) += kobject_uevent.o
35 35 obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
  36 +obj-$(CONFIG_GENERIC_PCI_IOMAP) += pci_iomap.o
36 37 obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
37 38 obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o
38 39 obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
... ... @@ -242,46 +242,12 @@
242 242 #endif /* CONFIG_HAS_IOPORT */
243 243  
244 244 #ifdef CONFIG_PCI
245   -/**
246   - * pci_iomap - create a virtual mapping cookie for a PCI BAR
247   - * @dev: PCI device that owns the BAR
248   - * @bar: BAR number
249   - * @maxlen: length of the memory to map
250   - *
251   - * Using this function you will get a __iomem address to your device BAR.
252   - * You can access it using ioread*() and iowrite*(). These functions hide
253   - * the details if this is a MMIO or PIO address space and will just do what
254   - * you expect from them in the correct way.
255   - *
256   - * @maxlen specifies the maximum length to map. If you want to get access to
257   - * the complete BAR without checking for its length first, pass %0 here.
258   - * */
259   -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
260   -{
261   - resource_size_t start = pci_resource_start(dev, bar);
262   - resource_size_t len = pci_resource_len(dev, bar);
263   - unsigned long flags = pci_resource_flags(dev, bar);
264   -
265   - if (!len || !start)
266   - return NULL;
267   - if (maxlen && len > maxlen)
268   - len = maxlen;
269   - if (flags & IORESOURCE_IO)
270   - return ioport_map(start, len);
271   - if (flags & IORESOURCE_MEM) {
272   - if (flags & IORESOURCE_CACHEABLE)
273   - return ioremap(start, len);
274   - return ioremap_nocache(start, len);
275   - }
276   - /* What? */
277   - return NULL;
278   -}
279   -
  245 +/* Hide the details if this is a MMIO or PIO address space and just do what
  246 + * you expect in the correct way. */
280 247 void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
281 248 {
282 249 IO_COND(addr, /* nothing */, iounmap(addr));
283 250 }
284   -EXPORT_SYMBOL(pci_iomap);
285 251 EXPORT_SYMBOL(pci_iounmap);
286 252 #endif /* CONFIG_PCI */
  1 +/*
  2 + * Implement the default iomap interfaces
  3 + *
  4 + * (C) Copyright 2004 Linus Torvalds
  5 + */
  6 +#include <linux/pci.h>
  7 +#include <linux/io.h>
  8 +
  9 +#include <linux/export.h>
  10 +
  11 +#ifdef CONFIG_PCI
  12 +/**
  13 + * pci_iomap - create a virtual mapping cookie for a PCI BAR
  14 + * @dev: PCI device that owns the BAR
  15 + * @bar: BAR number
  16 + * @maxlen: length of the memory to map
  17 + *
  18 + * Using this function you will get a __iomem address to your device BAR.
  19 + * You can access it using ioread*() and iowrite*(). These functions hide
  20 + * the details if this is a MMIO or PIO address space and will just do what
  21 + * you expect from them in the correct way.
  22 + *
  23 + * @maxlen specifies the maximum length to map. If you want to get access to
  24 + * the complete BAR without checking for its length first, pass %0 here.
  25 + * */
  26 +void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
  27 +{
  28 + resource_size_t start = pci_resource_start(dev, bar);
  29 + resource_size_t len = pci_resource_len(dev, bar);
  30 + unsigned long flags = pci_resource_flags(dev, bar);
  31 +
  32 + if (!len || !start)
  33 + return NULL;
  34 + if (maxlen && len > maxlen)
  35 + len = maxlen;
  36 + if (flags & IORESOURCE_IO)
  37 + return ioport_map(start, len);
  38 + if (flags & IORESOURCE_MEM) {
  39 + if (flags & IORESOURCE_CACHEABLE)
  40 + return ioremap(start, len);
  41 + return ioremap_nocache(start, len);
  42 + }
  43 + /* What? */
  44 + return NULL;
  45 +}
  46 +
  47 +EXPORT_SYMBOL(pci_iomap);
  48 +#endif /* CONFIG_PCI */