aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnus Damm <magnus.damm@gmail.com>2008-02-19 07:35:22 -0500
committerPaul Mundt <lethal@linux-sh.org>2009-04-16 03:00:14 -0400
commitef339f241b08a16af58897e6288ba200e0c7a8c7 (patch)
tree6e9984ccbccc87017c3beb97567002926b5ae549
parentef53fdeb7e0cb139aff33665635b886700137abb (diff)
sh: pci memory range checking code
This patch changes the code to use __is_pci_memory() instead of is_pci_memaddr(). __is_pci_memory() loops through all the pci channels on the system to match memory windows. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--arch/sh/boards/mach-titan/io.c2
-rw-r--r--arch/sh/drivers/pci/pci.c5
-rw-r--r--arch/sh/include/asm/pci.h23
-rw-r--r--arch/sh/mm/ioremap_32.c4
4 files changed, 24 insertions, 10 deletions
diff --git a/arch/sh/boards/mach-titan/io.c b/arch/sh/boards/mach-titan/io.c
index 4badad4c6f30..053b3ed2ed8d 100644
--- a/arch/sh/boards/mach-titan/io.c
+++ b/arch/sh/boards/mach-titan/io.c
@@ -117,7 +117,7 @@ void titan_outsl(unsigned long port, const void *src, unsigned long count)
117 117
118void __iomem *titan_ioport_map(unsigned long port, unsigned int size) 118void __iomem *titan_ioport_map(unsigned long port, unsigned int size)
119{ 119{
120 if (PXSEG(port) || is_pci_memaddr(port)) 120 if (PXSEG(port))
121 return (void __iomem *)port; 121 return (void __iomem *)port;
122 else if (is_pci_ioaddr(port)) 122 else if (is_pci_ioaddr(port))
123 return (void __iomem *)pci_ioaddr(port); 123 return (void __iomem *)pci_ioaddr(port);
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 29ec16e69afa..b9aca5478048 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -167,9 +167,8 @@ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
167 /* 167 /*
168 * Presently the IORESOURCE_MEM case is a bit special, most 168 * Presently the IORESOURCE_MEM case is a bit special, most
169 * SH7751 style PCI controllers have PCI memory at a fixed 169 * SH7751 style PCI controllers have PCI memory at a fixed
170 * location in the address space where no remapping is desired 170 * location in the address space where no remapping is desired.
171 * (typically at 0xfd000000, but is_pci_memaddr() will know 171 * With the IORESOURCE_MEM case more care has to be taken
172 * best). With the IORESOURCE_MEM case more care has to be taken
173 * to inhibit page table mapping for legacy cores, but this is 172 * to inhibit page table mapping for legacy cores, but this is
174 * punted off to __ioremap(). 173 * punted off to __ioremap().
175 * -- PFM. 174 * -- PFM.
diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h
index 84d12ebef084..ccf5c5ff62ff 100644
--- a/arch/sh/include/asm/pci.h
+++ b/arch/sh/include/asm/pci.h
@@ -61,12 +61,8 @@ extern unsigned long PCI_IO_AREA;
61#define is_pci_ioaddr(port) \ 61#define is_pci_ioaddr(port) \
62 (((port) >= PCIBIOS_MIN_IO) && \ 62 (((port) >= PCIBIOS_MIN_IO) && \
63 ((port) < (PCIBIOS_MIN_IO + PCI_IO_SIZE))) 63 ((port) < (PCIBIOS_MIN_IO + PCI_IO_SIZE)))
64#define is_pci_memaddr(port) \
65 (((port) >= PCIBIOS_MIN_MEM) && \
66 ((port) < (PCIBIOS_MIN_MEM + PCI_MEM_SIZE)))
67#else 64#else
68#define is_pci_ioaddr(port) (0) 65#define is_pci_ioaddr(port) (0)
69#define is_pci_memaddr(port) (0)
70#endif 66#endif
71 67
72struct pci_dev; 68struct pci_dev;
@@ -127,6 +123,25 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
127 *strat = PCI_DMA_BURST_INFINITY; 123 *strat = PCI_DMA_BURST_INFINITY;
128 *strategy_parameter = ~0UL; 124 *strategy_parameter = ~0UL;
129} 125}
126
127static inline int __is_pci_memory(unsigned long phys_addr, unsigned long size)
128{
129 struct pci_channel *p;
130 struct resource *res;
131
132 for (p = board_pci_channels; p->init; p++) {
133 res = p->mem_resource;
134 if (p->enabled && (phys_addr >= res->start) &&
135 (phys_addr + size) <= (res->end + 1))
136 return 1;
137 }
138 return 0;
139}
140#else
141static inline int __is_pci_memory(unsigned long phys_addr, unsigned long size)
142{
143 return 0;
144}
130#endif 145#endif
131 146
132/* Board-specific fixup routines. */ 147/* Board-specific fixup routines. */
diff --git a/arch/sh/mm/ioremap_32.c b/arch/sh/mm/ioremap_32.c
index 60cc486d2c2c..7e04cc8f3b9b 100644
--- a/arch/sh/mm/ioremap_32.c
+++ b/arch/sh/mm/ioremap_32.c
@@ -56,7 +56,7 @@ void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
56 * P1/P2 space, ioremap() will already do the right thing, 56 * P1/P2 space, ioremap() will already do the right thing,
57 * and we'll never get this far. 57 * and we'll never get this far.
58 */ 58 */
59 if (is_pci_memaddr(phys_addr) && is_pci_memaddr(last_addr)) 59 if (__is_pci_memory(phys_addr, size))
60 return (void __iomem *)phys_addr; 60 return (void __iomem *)phys_addr;
61 61
62#if !defined(CONFIG_PMB_FIXED) 62#if !defined(CONFIG_PMB_FIXED)
@@ -121,7 +121,7 @@ void __iounmap(void __iomem *addr)
121 unsigned long seg = PXSEG(vaddr); 121 unsigned long seg = PXSEG(vaddr);
122 struct vm_struct *p; 122 struct vm_struct *p;
123 123
124 if (seg < P3SEG || vaddr >= P3_ADDR_MAX || is_pci_memaddr(vaddr)) 124 if (seg < P3SEG || vaddr >= P3_ADDR_MAX || __is_pci_memory(vaddr, 0))
125 return; 125 return;
126 126
127#ifdef CONFIG_PMB 127#ifdef CONFIG_PMB