aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-powerpc/eeh.h
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2006-11-11 01:25:10 -0500
committerPaul Mackerras <paulus@samba.org>2006-12-04 04:38:52 -0500
commit4cb3cee03d558fd457cb58f56c80a2a09a66110c (patch)
treefe903107d098871a7babc1e3432448758c542cde /include/asm-powerpc/eeh.h
parentd03f387eb321189bc2ba278b6ca82f1a45cf19d6 (diff)
[POWERPC] Allow hooking of PCI MMIO & PIO accessors on 64 bits
This patch reworks the way iSeries hooks on PCI IO operations (both MMIO and PIO) and provides a generic way for other platforms to do so (we have need to do that for various other platforms). While reworking the IO ops, I ended up doing some spring cleaning in io.h and eeh.h which I might want to split into 2 or 3 patches (among others, eeh.h had a lot of useless stuff in it). A side effect is that EEH for PIO should work now (it used to pass IO ports down to the eeh address check functions which is bogus). Also, new are MMIO "repeat" ops, which other archs like ARM already had, and that we have too now: readsb, readsw, readsl, writesb, writesw, writesl. In the long run, I might also make EEH use the hooks instead of wrapping at the toplevel, which would make things even cleaner and relegate EEH completely in platforms/iseries, but we have to measure the performance impact there (though it's really only on MMIO reads) Since I also need to hook on ioremap, I shuffled the functions a bit there. I introduced ioremap_flags() to use by drivers who want to pass explicit flags to ioremap (and it can be hooked). The old __ioremap() is still there as a low level and cannot be hooked, thus drivers who use it should migrate unless they know they want the low level version. The patch "arch provides generic iomap missing accessors" (should be number 4 in this series) is a pre-requisite to provide full iomap API support with this patch. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'include/asm-powerpc/eeh.h')
-rw-r--r--include/asm-powerpc/eeh.h118
1 files changed, 27 insertions, 91 deletions
diff --git a/include/asm-powerpc/eeh.h b/include/asm-powerpc/eeh.h
index 6a784396660b..66481bbf270a 100644
--- a/include/asm-powerpc/eeh.h
+++ b/include/asm-powerpc/eeh.h
@@ -120,10 +120,6 @@ static inline u8 eeh_readb(const volatile void __iomem *addr)
120 return eeh_check_failure(addr, val); 120 return eeh_check_failure(addr, val);
121 return val; 121 return val;
122} 122}
123static inline void eeh_writeb(u8 val, volatile void __iomem *addr)
124{
125 out_8(addr, val);
126}
127 123
128static inline u16 eeh_readw(const volatile void __iomem *addr) 124static inline u16 eeh_readw(const volatile void __iomem *addr)
129{ 125{
@@ -132,21 +128,6 @@ static inline u16 eeh_readw(const volatile void __iomem *addr)
132 return eeh_check_failure(addr, val); 128 return eeh_check_failure(addr, val);
133 return val; 129 return val;
134} 130}
135static inline void eeh_writew(u16 val, volatile void __iomem *addr)
136{
137 out_le16(addr, val);
138}
139static inline u16 eeh_raw_readw(const volatile void __iomem *addr)
140{
141 u16 val = in_be16(addr);
142 if (EEH_POSSIBLE_ERROR(val, u16))
143 return eeh_check_failure(addr, val);
144 return val;
145}
146static inline void eeh_raw_writew(u16 val, volatile void __iomem *addr) {
147 volatile u16 __iomem *vaddr = (volatile u16 __iomem *) addr;
148 out_be16(vaddr, val);
149}
150 131
151static inline u32 eeh_readl(const volatile void __iomem *addr) 132static inline u32 eeh_readl(const volatile void __iomem *addr)
152{ 133{
@@ -155,44 +136,38 @@ static inline u32 eeh_readl(const volatile void __iomem *addr)
155 return eeh_check_failure(addr, val); 136 return eeh_check_failure(addr, val);
156 return val; 137 return val;
157} 138}
158static inline void eeh_writel(u32 val, volatile void __iomem *addr) 139
159{ 140static inline u64 eeh_readq(const volatile void __iomem *addr)
160 out_le32(addr, val);
161}
162static inline u32 eeh_raw_readl(const volatile void __iomem *addr)
163{ 141{
164 u32 val = in_be32(addr); 142 u64 val = in_le64(addr);
165 if (EEH_POSSIBLE_ERROR(val, u32)) 143 if (EEH_POSSIBLE_ERROR(val, u64))
166 return eeh_check_failure(addr, val); 144 return eeh_check_failure(addr, val);
167 return val; 145 return val;
168} 146}
169static inline void eeh_raw_writel(u32 val, volatile void __iomem *addr)
170{
171 out_be32(addr, val);
172}
173 147
174static inline u64 eeh_readq(const volatile void __iomem *addr) 148static inline u16 eeh_readw_be(const volatile void __iomem *addr)
175{ 149{
176 u64 val = in_le64(addr); 150 u16 val = in_be16(addr);
177 if (EEH_POSSIBLE_ERROR(val, u64)) 151 if (EEH_POSSIBLE_ERROR(val, u16))
178 return eeh_check_failure(addr, val); 152 return eeh_check_failure(addr, val);
179 return val; 153 return val;
180} 154}
181static inline void eeh_writeq(u64 val, volatile void __iomem *addr) 155
156static inline u32 eeh_readl_be(const volatile void __iomem *addr)
182{ 157{
183 out_le64(addr, val); 158 u32 val = in_be32(addr);
159 if (EEH_POSSIBLE_ERROR(val, u32))
160 return eeh_check_failure(addr, val);
161 return val;
184} 162}
185static inline u64 eeh_raw_readq(const volatile void __iomem *addr) 163
164static inline u64 eeh_readq_be(const volatile void __iomem *addr)
186{ 165{
187 u64 val = in_be64(addr); 166 u64 val = in_be64(addr);
188 if (EEH_POSSIBLE_ERROR(val, u64)) 167 if (EEH_POSSIBLE_ERROR(val, u64))
189 return eeh_check_failure(addr, val); 168 return eeh_check_failure(addr, val);
190 return val; 169 return val;
191} 170}
192static inline void eeh_raw_writeq(u64 val, volatile void __iomem *addr)
193{
194 out_be64(addr, val);
195}
196 171
197#define EEH_CHECK_ALIGN(v,a) \ 172#define EEH_CHECK_ALIGN(v,a) \
198 ((((unsigned long)(v)) & ((a) - 1)) == 0) 173 ((((unsigned long)(v)) & ((a) - 1)) == 0)
@@ -292,68 +267,29 @@ static inline void eeh_memcpy_toio(volatile void __iomem *dest, const void *src,
292 267
293#undef EEH_CHECK_ALIGN 268#undef EEH_CHECK_ALIGN
294 269
295static inline u8 eeh_inb(unsigned long port)
296{
297 u8 val;
298 val = in_8((u8 __iomem *)(port+pci_io_base));
299 if (EEH_POSSIBLE_ERROR(val, u8))
300 return eeh_check_failure((void __iomem *)(port), val);
301 return val;
302}
303
304static inline void eeh_outb(u8 val, unsigned long port)
305{
306 out_8((u8 __iomem *)(port+pci_io_base), val);
307}
308
309static inline u16 eeh_inw(unsigned long port)
310{
311 u16 val;
312 val = in_le16((u16 __iomem *)(port+pci_io_base));
313 if (EEH_POSSIBLE_ERROR(val, u16))
314 return eeh_check_failure((void __iomem *)(port), val);
315 return val;
316}
317
318static inline void eeh_outw(u16 val, unsigned long port)
319{
320 out_le16((u16 __iomem *)(port+pci_io_base), val);
321}
322
323static inline u32 eeh_inl(unsigned long port)
324{
325 u32 val;
326 val = in_le32((u32 __iomem *)(port+pci_io_base));
327 if (EEH_POSSIBLE_ERROR(val, u32))
328 return eeh_check_failure((void __iomem *)(port), val);
329 return val;
330}
331
332static inline void eeh_outl(u32 val, unsigned long port)
333{
334 out_le32((u32 __iomem *)(port+pci_io_base), val);
335}
336
337/* in-string eeh macros */ 270/* in-string eeh macros */
338static inline void eeh_insb(unsigned long port, void * buf, int ns) 271static inline void eeh_readsb(const volatile void __iomem *addr, void * buf,
272 int ns)
339{ 273{
340 _insb((u8 __iomem *)(port+pci_io_base), buf, ns); 274 _insb(addr, buf, ns);
341 if (EEH_POSSIBLE_ERROR((*(((u8*)buf)+ns-1)), u8)) 275 if (EEH_POSSIBLE_ERROR((*(((u8*)buf)+ns-1)), u8))
342 eeh_check_failure((void __iomem *)(port), *(u8*)buf); 276 eeh_check_failure(addr, *(u8*)buf);
343} 277}
344 278
345static inline void eeh_insw_ns(unsigned long port, void * buf, int ns) 279static inline void eeh_readsw(const volatile void __iomem *addr, void * buf,
280 int ns)
346{ 281{
347 _insw_ns((u16 __iomem *)(port+pci_io_base), buf, ns); 282 _insw(addr, buf, ns);
348 if (EEH_POSSIBLE_ERROR((*(((u16*)buf)+ns-1)), u16)) 283 if (EEH_POSSIBLE_ERROR((*(((u16*)buf)+ns-1)), u16))
349 eeh_check_failure((void __iomem *)(port), *(u16*)buf); 284 eeh_check_failure(addr, *(u16*)buf);
350} 285}
351 286
352static inline void eeh_insl_ns(unsigned long port, void * buf, int nl) 287static inline void eeh_readsl(const volatile void __iomem *addr, void * buf,
288 int nl)
353{ 289{
354 _insl_ns((u32 __iomem *)(port+pci_io_base), buf, nl); 290 _insl(addr, buf, nl);
355 if (EEH_POSSIBLE_ERROR((*(((u32*)buf)+nl-1)), u32)) 291 if (EEH_POSSIBLE_ERROR((*(((u32*)buf)+nl-1)), u32))
356 eeh_check_failure((void __iomem *)(port), *(u32*)buf); 292 eeh_check_failure(addr, *(u32*)buf);
357} 293}
358 294
359#endif /* __KERNEL__ */ 295#endif /* __KERNEL__ */