Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
172ca926 | 2 | /* |
1da177e4 | 3 | * Copyright (C) 2001 Dave Engebretsen & Todd Inglett IBM Corporation. |
cb3bc9d0 | 4 | * Copyright 2001-2012 IBM Corporation. |
1da177e4 LT |
5 | */ |
6 | ||
8b8da358 BH |
7 | #ifndef _POWERPC_EEH_H |
8 | #define _POWERPC_EEH_H | |
88ced031 | 9 | #ifdef __KERNEL__ |
1da177e4 | 10 | |
1da177e4 LT |
11 | #include <linux/init.h> |
12 | #include <linux/list.h> | |
13 | #include <linux/string.h> | |
5a71978e | 14 | #include <linux/time.h> |
05ec424e | 15 | #include <linux/atomic.h> |
1da177e4 | 16 | |
ed3e81ff GS |
17 | #include <uapi/asm/eeh.h> |
18 | ||
1da177e4 | 19 | struct pci_dev; |
827c1a6c | 20 | struct pci_bus; |
e8e9b34c | 21 | struct pci_dn; |
1da177e4 LT |
22 | |
23 | #ifdef CONFIG_EEH | |
24 | ||
8a5ad356 | 25 | /* EEH subsystem flags */ |
ee8c446f MR |
26 | #define EEH_ENABLED 0x01 /* EEH enabled */ |
27 | #define EEH_FORCE_DISABLED 0x02 /* EEH disabled */ | |
28 | #define EEH_PROBE_MODE_DEV 0x04 /* From PCI device */ | |
29 | #define EEH_PROBE_MODE_DEVTREE 0x08 /* From device tree */ | |
ee8c446f MR |
30 | #define EEH_ENABLE_IO_FOR_LOG 0x20 /* Enable IO for log */ |
31 | #define EEH_EARLY_DUMP_LOG 0x40 /* Dump log immediately */ | |
8a5ad356 | 32 | |
26833a50 GS |
33 | /* |
34 | * Delay for PE reset, all in ms | |
35 | * | |
36 | * PCI specification has reset hold time of 100 milliseconds. | |
37 | * We have 250 milliseconds here. The PCI bus settlement time | |
38 | * is specified as 1.5 seconds and we have 1.8 seconds. | |
39 | */ | |
40 | #define EEH_PE_RST_HOLD_TIME 250 | |
41 | #define EEH_PE_RST_SETTLE_TIME 1800 | |
42 | ||
968f968f GS |
43 | /* |
44 | * The struct is used to trace PE related EEH functionality. | |
45 | * In theory, there will have one instance of the struct to | |
027dfac6 | 46 | * be created against particular PE. In nature, PEs correlate |
968f968f GS |
47 | * to each other. the struct has to reflect that hierarchy in |
48 | * order to easily pick up those affected PEs when one particular | |
49 | * PE has EEH errors. | |
50 | * | |
51 | * Also, one particular PE might be composed of PCI device, PCI | |
52 | * bus and its subordinate components. The struct also need ship | |
53 | * the information. Further more, one particular PE is only meaingful | |
54 | * in the corresponding PHB. Therefore, the root PEs should be created | |
55 | * against existing PHBs in on-to-one fashion. | |
56 | */ | |
5efc3ad7 GS |
57 | #define EEH_PE_INVALID (1 << 0) /* Invalid */ |
58 | #define EEH_PE_PHB (1 << 1) /* PHB PE */ | |
59 | #define EEH_PE_DEVICE (1 << 2) /* Device PE */ | |
60 | #define EEH_PE_BUS (1 << 3) /* Bus PE */ | |
c29fa27d | 61 | #define EEH_PE_VF (1 << 4) /* VF PE */ |
968f968f GS |
62 | |
63 | #define EEH_PE_ISOLATED (1 << 0) /* Isolated PE */ | |
64 | #define EEH_PE_RECOVERING (1 << 1) /* Recovering PE */ | |
8a6b3710 | 65 | #define EEH_PE_CFG_BLOCKED (1 << 2) /* Block config access */ |
28bf36f9 | 66 | #define EEH_PE_RESET (1 << 3) /* PE reset in progress */ |
968f968f | 67 | |
807a827d | 68 | #define EEH_PE_KEEP (1 << 8) /* Keep PE on hotplug */ |
b6541db1 | 69 | #define EEH_PE_CFG_RESTRICTED (1 << 9) /* Block config on error */ |
432227e9 | 70 | #define EEH_PE_REMOVED (1 << 10) /* Removed permanently */ |
05ba75f8 | 71 | #define EEH_PE_PRI_BUS (1 << 11) /* Cached primary bus */ |
807a827d | 72 | |
968f968f GS |
73 | struct eeh_pe { |
74 | int type; /* PE type: PHB/Bus/Device */ | |
75 | int state; /* PE EEH dependent mode */ | |
968f968f GS |
76 | int addr; /* PE configuration address */ |
77 | struct pci_controller *phb; /* Associated PHB */ | |
8cdb2833 | 78 | struct pci_bus *bus; /* Top PCI bus for bus PE */ |
968f968f GS |
79 | int check_count; /* Times of ignored error */ |
80 | int freeze_count; /* Times of froze up */ | |
edfd17ff | 81 | time64_t tstamp; /* Time on first-time freeze */ |
968f968f | 82 | int false_positives; /* Times of reported #ff's */ |
05ec424e | 83 | atomic_t pass_dev_cnt; /* Count of passed through devs */ |
968f968f | 84 | struct eeh_pe *parent; /* Parent PE */ |
39434af1 | 85 | void *data; /* PE auxiliary data */ |
80e65b00 SB |
86 | struct list_head child_list; /* List of PEs below this PE */ |
87 | struct list_head child; /* Memb. child_list/eeh_phb_pe */ | |
88 | struct list_head edevs; /* List of eeh_dev in this PE */ | |
25baf3d8 | 89 | |
1b7f3b6c | 90 | #ifdef CONFIG_STACKTRACE |
25baf3d8 OH |
91 | /* |
92 | * Saved stack trace. When we find a PE freeze in eeh_dev_check_failure | |
93 | * the stack trace is saved here so we can print it in the recovery | |
94 | * thread if it turns out to due to a real problem rather than | |
95 | * a hot-remove. | |
96 | * | |
97 | * A max of 64 entries might be overkill, but it also might not be. | |
98 | */ | |
99 | unsigned long stack_trace[64]; | |
100 | int trace_entries; | |
1b7f3b6c | 101 | #endif /* CONFIG_STACKTRACE */ |
968f968f GS |
102 | }; |
103 | ||
9feed42e | 104 | #define eeh_pe_for_each_dev(pe, edev, tmp) \ |
80e65b00 | 105 | list_for_each_entry_safe(edev, tmp, &pe->edevs, entry) |
5b663529 | 106 | |
309ed3a7 SB |
107 | #define eeh_for_each_pe(root, pe) \ |
108 | for (pe = root; pe; pe = eeh_pe_next(pe, root)) | |
109 | ||
05ec424e GS |
110 | static inline bool eeh_pe_passed(struct eeh_pe *pe) |
111 | { | |
112 | return pe ? !!atomic_read(&pe->pass_dev_cnt) : false; | |
113 | } | |
114 | ||
eb740b5f GS |
115 | /* |
116 | * The struct is used to trace EEH state for the associated | |
117 | * PCI device node or PCI device. In future, it might | |
118 | * represent PE as well so that the EEH device to form | |
119 | * another tree except the currently existing tree of PCI | |
120 | * buses and PCI devices | |
121 | */ | |
4b83bd45 GS |
122 | #define EEH_DEV_BRIDGE (1 << 0) /* PCI bridge */ |
123 | #define EEH_DEV_ROOT_PORT (1 << 1) /* PCIe root port */ | |
124 | #define EEH_DEV_DS_PORT (1 << 2) /* Downstream port */ | |
125 | #define EEH_DEV_IRQ_DISABLED (1 << 3) /* Interrupt disabled */ | |
126 | #define EEH_DEV_DISCONNECTED (1 << 4) /* Removing from PE */ | |
eb740b5f | 127 | |
f26c7a03 GS |
128 | #define EEH_DEV_NO_HANDLER (1 << 8) /* No error handler */ |
129 | #define EEH_DEV_SYSFS (1 << 9) /* Sysfs created */ | |
d2b0f6f7 | 130 | #define EEH_DEV_REMOVED (1 << 10) /* Removed permanently */ |
ab55d218 | 131 | |
eb740b5f GS |
132 | struct eeh_dev { |
133 | int mode; /* EEH mode */ | |
7c33a994 OH |
134 | int bdfn; /* bdfn of device (for cfg ops) */ |
135 | struct pci_controller *controller; | |
eb740b5f | 136 | int pe_config_addr; /* PE config address */ |
eb740b5f | 137 | u32 config_space[16]; /* Saved PCI config space */ |
2a18dfc6 GS |
138 | int pcix_cap; /* Saved PCIx capability */ |
139 | int pcie_cap; /* Saved PCIe capability */ | |
140 | int aer_cap; /* Saved AER capability */ | |
9312bc5b | 141 | int af_cap; /* Saved AF capability */ |
968f968f | 142 | struct eeh_pe *pe; /* Associated PE */ |
80e65b00 SB |
143 | struct list_head entry; /* Membership in eeh_pe.edevs */ |
144 | struct list_head rmv_entry; /* Membership in rmv_list */ | |
e8e9b34c | 145 | struct pci_dn *pdn; /* Associated PCI device node */ |
eb740b5f | 146 | struct pci_dev *pdev; /* Associated PCI device */ |
67086e32 | 147 | bool in_error; /* Error flag for edev */ |
dffa9153 OH |
148 | |
149 | /* VF specific properties */ | |
39218cd0 | 150 | struct pci_dev *physfn; /* Associated SRIOV PF */ |
dffa9153 | 151 | int vf_index; /* Index of this VF */ |
eb740b5f GS |
152 | }; |
153 | ||
b093f2cb SB |
154 | /* "fmt" must be a simple literal string */ |
155 | #define EEH_EDEV_PRINT(level, edev, fmt, ...) \ | |
156 | pr_##level("PCI %04x:%02x:%02x.%x#%04x: EEH: " fmt, \ | |
157 | (edev)->controller->global_number, PCI_BUSNO((edev)->bdfn), \ | |
158 | PCI_SLOT((edev)->bdfn), PCI_FUNC((edev)->bdfn), \ | |
159 | ((edev)->pe ? (edev)->pe_config_addr : 0xffff), ##__VA_ARGS__) | |
160 | #define eeh_edev_dbg(edev, fmt, ...) EEH_EDEV_PRINT(debug, (edev), fmt, ##__VA_ARGS__) | |
161 | #define eeh_edev_info(edev, fmt, ...) EEH_EDEV_PRINT(info, (edev), fmt, ##__VA_ARGS__) | |
162 | #define eeh_edev_warn(edev, fmt, ...) EEH_EDEV_PRINT(warn, (edev), fmt, ##__VA_ARGS__) | |
163 | #define eeh_edev_err(edev, fmt, ...) EEH_EDEV_PRINT(err, (edev), fmt, ##__VA_ARGS__) | |
164 | ||
e8e9b34c GS |
165 | static inline struct pci_dn *eeh_dev_to_pdn(struct eeh_dev *edev) |
166 | { | |
167 | return edev ? edev->pdn : NULL; | |
168 | } | |
169 | ||
eb740b5f GS |
170 | static inline struct pci_dev *eeh_dev_to_pci_dev(struct eeh_dev *edev) |
171 | { | |
2d5c1216 | 172 | return edev ? edev->pdev : NULL; |
eb740b5f GS |
173 | } |
174 | ||
2a58222f WY |
175 | static inline struct eeh_pe *eeh_dev_to_pe(struct eeh_dev* edev) |
176 | { | |
177 | return edev ? edev->pe : NULL; | |
178 | } | |
179 | ||
7e4e7867 GS |
180 | /* Return values from eeh_ops::next_error */ |
181 | enum { | |
182 | EEH_NEXT_ERR_NONE = 0, | |
183 | EEH_NEXT_ERR_INF, | |
184 | EEH_NEXT_ERR_FROZEN_PE, | |
185 | EEH_NEXT_ERR_FENCED_PHB, | |
186 | EEH_NEXT_ERR_DEAD_PHB, | |
187 | EEH_NEXT_ERR_DEAD_IOC | |
188 | }; | |
189 | ||
aa1e6374 GS |
190 | /* |
191 | * The struct is used to trace the registered EEH operation | |
192 | * callback functions. Actually, those operation callback | |
193 | * functions are heavily platform dependent. That means the | |
194 | * platform should register its own EEH operation callback | |
195 | * functions before any EEH further operations. | |
196 | */ | |
8fb8f709 GS |
197 | #define EEH_OPT_DISABLE 0 /* EEH disable */ |
198 | #define EEH_OPT_ENABLE 1 /* EEH enable */ | |
199 | #define EEH_OPT_THAW_MMIO 2 /* MMIO enable */ | |
200 | #define EEH_OPT_THAW_DMA 3 /* DMA enable */ | |
0d5ee520 | 201 | #define EEH_OPT_FREEZE_PE 4 /* Freeze PE */ |
eb594a47 GS |
202 | #define EEH_STATE_UNAVAILABLE (1 << 0) /* State unavailable */ |
203 | #define EEH_STATE_NOT_SUPPORT (1 << 1) /* EEH not supported */ | |
204 | #define EEH_STATE_RESET_ACTIVE (1 << 2) /* Active reset */ | |
205 | #define EEH_STATE_MMIO_ACTIVE (1 << 3) /* Active MMIO */ | |
206 | #define EEH_STATE_DMA_ACTIVE (1 << 4) /* Active DMA */ | |
207 | #define EEH_STATE_MMIO_ENABLED (1 << 5) /* MMIO enabled */ | |
208 | #define EEH_STATE_DMA_ENABLED (1 << 6) /* DMA enabled */ | |
2652481f GS |
209 | #define EEH_RESET_DEACTIVATE 0 /* Deactivate the PE reset */ |
210 | #define EEH_RESET_HOT 1 /* Hot reset */ | |
211 | #define EEH_RESET_FUNDAMENTAL 3 /* Fundamental reset */ | |
8d633291 GS |
212 | #define EEH_LOG_TEMP 1 /* EEH temporary error log */ |
213 | #define EEH_LOG_PERM 2 /* EEH permanent error log */ | |
eb594a47 | 214 | |
aa1e6374 GS |
215 | struct eeh_ops { |
216 | char *name; | |
e86350f7 | 217 | struct eeh_dev *(*probe)(struct pci_dev *pdev); |
371a395d | 218 | int (*set_option)(struct eeh_pe *pe, int option); |
fef7f905 | 219 | int (*get_state)(struct eeh_pe *pe, int *delay); |
371a395d | 220 | int (*reset)(struct eeh_pe *pe, int option); |
371a395d GS |
221 | int (*get_log)(struct eeh_pe *pe, int severity, char *drv_log, unsigned long len); |
222 | int (*configure_bridge)(struct eeh_pe *pe); | |
131c123a GS |
223 | int (*err_inject)(struct eeh_pe *pe, int type, int func, |
224 | unsigned long addr, unsigned long mask); | |
17d2a487 OH |
225 | int (*read_config)(struct eeh_dev *edev, int where, int size, u32 *val); |
226 | int (*write_config)(struct eeh_dev *edev, int where, int size, u32 val); | |
8a6b1bc7 | 227 | int (*next_error)(struct eeh_pe **pe); |
0c2c7652 | 228 | int (*restore_config)(struct eeh_dev *edev); |
8225d543 | 229 | int (*notify_resume)(struct eeh_dev *edev); |
aa1e6374 GS |
230 | }; |
231 | ||
8a5ad356 | 232 | extern int eeh_subsystem_flags; |
46ee7c3c | 233 | extern u32 eeh_max_freezes; |
6b493f60 | 234 | extern bool eeh_debugfs_no_recover; |
aa1e6374 | 235 | extern struct eeh_ops *eeh_ops; |
4907581d | 236 | extern raw_spinlock_t confirm_error_lock; |
d7bb8862 | 237 | |
05b1721d | 238 | static inline void eeh_add_flag(int flag) |
2ec5a0ad | 239 | { |
05b1721d | 240 | eeh_subsystem_flags |= flag; |
2ec5a0ad GS |
241 | } |
242 | ||
05b1721d | 243 | static inline void eeh_clear_flag(int flag) |
2ec5a0ad | 244 | { |
05b1721d | 245 | eeh_subsystem_flags &= ~flag; |
2ec5a0ad GS |
246 | } |
247 | ||
05b1721d | 248 | static inline bool eeh_has_flag(int flag) |
d7bb8862 | 249 | { |
05b1721d | 250 | return !!(eeh_subsystem_flags & flag); |
d7bb8862 GS |
251 | } |
252 | ||
05b1721d | 253 | static inline bool eeh_enabled(void) |
d7bb8862 | 254 | { |
54644927 | 255 | return eeh_has_flag(EEH_ENABLED) && !eeh_has_flag(EEH_FORCE_DISABLED); |
d7bb8862 | 256 | } |
646a8499 | 257 | |
4907581d GS |
258 | static inline void eeh_serialize_lock(unsigned long *flags) |
259 | { | |
260 | raw_spin_lock_irqsave(&confirm_error_lock, *flags); | |
261 | } | |
262 | ||
263 | static inline void eeh_serialize_unlock(unsigned long flags) | |
264 | { | |
265 | raw_spin_unlock_irqrestore(&confirm_error_lock, flags); | |
266 | } | |
267 | ||
34a286a4 SB |
268 | static inline bool eeh_state_active(int state) |
269 | { | |
270 | return (state & (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE)) | |
271 | == (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE); | |
272 | } | |
273 | ||
cef50c67 | 274 | typedef void (*eeh_edev_traverse_func)(struct eeh_dev *edev, void *flag); |
d6c4932f | 275 | typedef void *(*eeh_pe_traverse_func)(struct eeh_pe *pe, void *flag); |
bb593c00 | 276 | void eeh_set_pe_aux_size(int size); |
cad5cef6 | 277 | int eeh_phb_pe_create(struct pci_controller *phb); |
fef7f905 | 278 | int eeh_wait_state(struct eeh_pe *pe, int max_wait); |
9ff67433 | 279 | struct eeh_pe *eeh_phb_pe_get(struct pci_controller *phb); |
309ed3a7 | 280 | struct eeh_pe *eeh_pe_next(struct eeh_pe *pe, struct eeh_pe *root); |
35d64734 | 281 | struct eeh_pe *eeh_pe_get(struct pci_controller *phb, int pe_no); |
a131bfc6 | 282 | int eeh_pe_tree_insert(struct eeh_dev *edev, struct eeh_pe *new_pe_parent); |
d923ab7a | 283 | int eeh_pe_tree_remove(struct eeh_dev *edev); |
5a71978e | 284 | void eeh_pe_update_time_stamp(struct eeh_pe *pe); |
f5c57710 | 285 | void *eeh_pe_traverse(struct eeh_pe *root, |
d6c4932f | 286 | eeh_pe_traverse_func fn, void *flag); |
cef50c67 SB |
287 | void eeh_pe_dev_traverse(struct eeh_pe *root, |
288 | eeh_edev_traverse_func fn, void *flag); | |
9e6d2cf6 | 289 | void eeh_pe_restore_bars(struct eeh_pe *pe); |
357b2f3d | 290 | const char *eeh_pe_loc_get(struct eeh_pe *pe); |
9b3c76f0 | 291 | struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe); |
55037d17 | 292 | |
c44e4cca | 293 | void eeh_show_enabled(void); |
d125aedb | 294 | int __init eeh_init(struct eeh_ops *ops); |
3e938052 | 295 | int eeh_check_failure(const volatile void __iomem *token); |
f8f7d63f | 296 | int eeh_dev_check_failure(struct eeh_dev *edev); |
685a0bc0 | 297 | void eeh_addr_cache_init(void); |
e86350f7 | 298 | void eeh_probe_device(struct pci_dev *pdev); |
807a827d | 299 | void eeh_remove_device(struct pci_dev *); |
188fdea6 | 300 | int eeh_unfreeze_pe(struct eeh_pe *pe); |
5cfb20b9 | 301 | int eeh_pe_reset_and_recover(struct eeh_pe *pe); |
212d16cd GS |
302 | int eeh_dev_open(struct pci_dev *pdev); |
303 | void eeh_dev_release(struct pci_dev *pdev); | |
304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group); | |
305 | int eeh_pe_set_option(struct eeh_pe *pe, int option); | |
306 | int eeh_pe_get_state(struct eeh_pe *pe); | |
1ef52073 | 307 | int eeh_pe_reset(struct eeh_pe *pe, int option, bool include_passed); |
212d16cd | 308 | int eeh_pe_configure(struct eeh_pe *pe); |
ec33d36e GS |
309 | int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func, |
310 | unsigned long addr, unsigned long mask); | |
b0e2b828 | 311 | int eeh_pe_inject_mmio_error(struct pci_dev *pdev); |
e2a296ee | 312 | |
1da177e4 LT |
313 | /** |
314 | * EEH_POSSIBLE_ERROR() -- test for possible MMIO failure. | |
315 | * | |
316 | * If this macro yields TRUE, the caller relays to eeh_check_failure() | |
317 | * which does further tests out of line. | |
318 | */ | |
2ec5a0ad | 319 | #define EEH_POSSIBLE_ERROR(val, type) ((val) == (type)~0 && eeh_enabled()) |
1da177e4 LT |
320 | |
321 | /* | |
322 | * Reads from a device which has been isolated by EEH will return | |
323 | * all 1s. This macro gives an all-1s value of the given size (in | |
324 | * bytes: 1, 2, or 4) for comparing with the result of a read. | |
325 | */ | |
326 | #define EEH_IO_ERROR_VALUE(size) (~0U >> ((4 - (size)) * 8)) | |
327 | ||
328 | #else /* !CONFIG_EEH */ | |
eb740b5f | 329 | |
2ec5a0ad GS |
330 | static inline bool eeh_enabled(void) |
331 | { | |
332 | return false; | |
333 | } | |
334 | ||
c44e4cca | 335 | static inline void eeh_show_enabled(void) { } |
51fb5f56 | 336 | |
3e938052 | 337 | static inline int eeh_check_failure(const volatile void __iomem *token) |
1da177e4 | 338 | { |
3e938052 | 339 | return 0; |
1da177e4 LT |
340 | } |
341 | ||
f8f7d63f | 342 | #define eeh_dev_check_failure(x) (0) |
1da177e4 | 343 | |
685a0bc0 SB |
344 | static inline void eeh_addr_cache_init(void) { } |
345 | ||
e86350f7 | 346 | static inline void eeh_probe_device(struct pci_dev *dev) { } |
f2856491 | 347 | |
807a827d | 348 | static inline void eeh_remove_device(struct pci_dev *dev) { } |
646a8499 | 349 | |
1da177e4 LT |
350 | #define EEH_POSSIBLE_ERROR(val, type) (0) |
351 | #define EEH_IO_ERROR_VALUE(size) (-1UL) | |
475028ef | 352 | static inline int eeh_phb_pe_create(struct pci_controller *phb) { return 0; } |
1da177e4 LT |
353 | #endif /* CONFIG_EEH */ |
354 | ||
b6eebb09 | 355 | #if defined(CONFIG_PPC_PSERIES) && defined(CONFIG_EEH) |
b6eebb09 | 356 | void pseries_eeh_init_edev_recursive(struct pci_dn *pdn); |
b6eebb09 OH |
357 | #endif |
358 | ||
8b8da358 | 359 | #ifdef CONFIG_PPC64 |
172ca926 | 360 | /* |
1da177e4 LT |
361 | * MMIO read/write operations with EEH support. |
362 | */ | |
363 | static inline u8 eeh_readb(const volatile void __iomem *addr) | |
364 | { | |
365 | u8 val = in_8(addr); | |
366 | if (EEH_POSSIBLE_ERROR(val, u8)) | |
3e938052 | 367 | eeh_check_failure(addr); |
1da177e4 LT |
368 | return val; |
369 | } | |
1da177e4 LT |
370 | |
371 | static inline u16 eeh_readw(const volatile void __iomem *addr) | |
372 | { | |
373 | u16 val = in_le16(addr); | |
374 | if (EEH_POSSIBLE_ERROR(val, u16)) | |
3e938052 | 375 | eeh_check_failure(addr); |
1da177e4 LT |
376 | return val; |
377 | } | |
1da177e4 LT |
378 | |
379 | static inline u32 eeh_readl(const volatile void __iomem *addr) | |
380 | { | |
381 | u32 val = in_le32(addr); | |
382 | if (EEH_POSSIBLE_ERROR(val, u32)) | |
3e938052 | 383 | eeh_check_failure(addr); |
1da177e4 LT |
384 | return val; |
385 | } | |
4cb3cee0 BH |
386 | |
387 | static inline u64 eeh_readq(const volatile void __iomem *addr) | |
1da177e4 | 388 | { |
4cb3cee0 BH |
389 | u64 val = in_le64(addr); |
390 | if (EEH_POSSIBLE_ERROR(val, u64)) | |
3e938052 | 391 | eeh_check_failure(addr); |
1da177e4 LT |
392 | return val; |
393 | } | |
1da177e4 | 394 | |
4cb3cee0 | 395 | static inline u16 eeh_readw_be(const volatile void __iomem *addr) |
1da177e4 | 396 | { |
4cb3cee0 BH |
397 | u16 val = in_be16(addr); |
398 | if (EEH_POSSIBLE_ERROR(val, u16)) | |
3e938052 | 399 | eeh_check_failure(addr); |
1da177e4 LT |
400 | return val; |
401 | } | |
4cb3cee0 BH |
402 | |
403 | static inline u32 eeh_readl_be(const volatile void __iomem *addr) | |
1da177e4 | 404 | { |
4cb3cee0 BH |
405 | u32 val = in_be32(addr); |
406 | if (EEH_POSSIBLE_ERROR(val, u32)) | |
3e938052 | 407 | eeh_check_failure(addr); |
4cb3cee0 | 408 | return val; |
1da177e4 | 409 | } |
4cb3cee0 BH |
410 | |
411 | static inline u64 eeh_readq_be(const volatile void __iomem *addr) | |
1da177e4 LT |
412 | { |
413 | u64 val = in_be64(addr); | |
414 | if (EEH_POSSIBLE_ERROR(val, u64)) | |
3e938052 | 415 | eeh_check_failure(addr); |
1da177e4 LT |
416 | return val; |
417 | } | |
1da177e4 | 418 | |
68a64357 BH |
419 | static inline void eeh_memcpy_fromio(void *dest, const |
420 | volatile void __iomem *src, | |
1da177e4 LT |
421 | unsigned long n) |
422 | { | |
68a64357 | 423 | _memcpy_fromio(dest, src, n); |
1da177e4 LT |
424 | |
425 | /* Look for ffff's here at dest[n]. Assume that at least 4 bytes | |
426 | * were copied. Check all four bytes. | |
427 | */ | |
68a64357 | 428 | if (n >= 4 && EEH_POSSIBLE_ERROR(*((u32 *)(dest + n - 4)), u32)) |
3e938052 | 429 | eeh_check_failure(src); |
1da177e4 LT |
430 | } |
431 | ||
1da177e4 | 432 | /* in-string eeh macros */ |
4cb3cee0 BH |
433 | static inline void eeh_readsb(const volatile void __iomem *addr, void * buf, |
434 | int ns) | |
1da177e4 | 435 | { |
4cb3cee0 | 436 | _insb(addr, buf, ns); |
1da177e4 | 437 | if (EEH_POSSIBLE_ERROR((*(((u8*)buf)+ns-1)), u8)) |
3e938052 | 438 | eeh_check_failure(addr); |
1da177e4 LT |
439 | } |
440 | ||
4cb3cee0 BH |
441 | static inline void eeh_readsw(const volatile void __iomem *addr, void * buf, |
442 | int ns) | |
1da177e4 | 443 | { |
4cb3cee0 | 444 | _insw(addr, buf, ns); |
1da177e4 | 445 | if (EEH_POSSIBLE_ERROR((*(((u16*)buf)+ns-1)), u16)) |
3e938052 | 446 | eeh_check_failure(addr); |
1da177e4 LT |
447 | } |
448 | ||
4cb3cee0 BH |
449 | static inline void eeh_readsl(const volatile void __iomem *addr, void * buf, |
450 | int nl) | |
1da177e4 | 451 | { |
4cb3cee0 | 452 | _insl(addr, buf, nl); |
1da177e4 | 453 | if (EEH_POSSIBLE_ERROR((*(((u32*)buf)+nl-1)), u32)) |
3e938052 | 454 | eeh_check_failure(addr); |
1da177e4 LT |
455 | } |
456 | ||
5ca85ae6 | 457 | |
d276960d | 458 | void __init eeh_cache_debugfs_init(void); |
5ca85ae6 | 459 | |
8b8da358 | 460 | #endif /* CONFIG_PPC64 */ |
88ced031 | 461 | #endif /* __KERNEL__ */ |
8b8da358 | 462 | #endif /* _POWERPC_EEH_H */ |