hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/arch/powerpc/include/asm/eeh.h
....@@ -1,20 +1,7 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * Copyright (C) 2001 Dave Engebretsen & Todd Inglett IBM Corporation.
34 * Copyright 2001-2012 IBM Corporation.
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation; either version 2 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
185 */
196
207 #ifndef _POWERPC_EEH_H
....@@ -40,10 +27,8 @@
4027 #define EEH_FORCE_DISABLED 0x02 /* EEH disabled */
4128 #define EEH_PROBE_MODE_DEV 0x04 /* From PCI device */
4229 #define EEH_PROBE_MODE_DEVTREE 0x08 /* From device tree */
43
-#define EEH_VALID_PE_ZERO 0x10 /* PE#0 is valid */
4430 #define EEH_ENABLE_IO_FOR_LOG 0x20 /* Enable IO for log */
4531 #define EEH_EARLY_DUMP_LOG 0x40 /* Dump log immediately */
46
-#define EEH_POSTPONED_PROBE 0x80 /* Powernv may postpone device probe */
4732
4833 /*
4934 * Delay for PE reset, all in ms
....@@ -88,7 +73,6 @@
8873 struct eeh_pe {
8974 int type; /* PE type: PHB/Bus/Device */
9075 int state; /* PE EEH dependent mode */
91
- int config_addr; /* Traditional PCI address */
9276 int addr; /* PE configuration address */
9377 struct pci_controller *phb; /* Associated PHB */
9478 struct pci_bus *bus; /* Top PCI bus for bus PE */
....@@ -99,13 +83,26 @@
9983 atomic_t pass_dev_cnt; /* Count of passed through devs */
10084 struct eeh_pe *parent; /* Parent PE */
10185 void *data; /* PE auxillary data */
102
- struct list_head child_list; /* Link PE to the child list */
103
- struct list_head edevs; /* Link list of EEH devices */
104
- struct list_head child; /* Child PEs */
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 */
89
+
90
+#ifdef CONFIG_STACKTRACE
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;
101
+#endif /* CONFIG_STACKTRACE */
105102 };
106103
107104 #define eeh_pe_for_each_dev(pe, edev, tmp) \
108
- list_for_each_entry_safe(edev, tmp, &pe->edevs, list)
105
+ list_for_each_entry_safe(edev, tmp, &pe->edevs, entry)
109106
110107 #define eeh_for_each_pe(root, pe) \
111108 for (pe = root; pe; pe = eeh_pe_next(pe, root))
....@@ -134,7 +131,8 @@
134131
135132 struct eeh_dev {
136133 int mode; /* EEH mode */
137
- int class_code; /* Class code of the device */
134
+ int bdfn; /* bdfn of device (for cfg ops) */
135
+ struct pci_controller *controller;
138136 int pe_config_addr; /* PE config address */
139137 u32 config_space[16]; /* Saved PCI config space */
140138 int pcix_cap; /* Saved PCIx capability */
....@@ -142,14 +140,27 @@
142140 int aer_cap; /* Saved AER capability */
143141 int af_cap; /* Saved AF capability */
144142 struct eeh_pe *pe; /* Associated PE */
145
- struct list_head list; /* Form link list in the PE */
146
- struct list_head rmv_list; /* Record the removed edevs */
143
+ struct list_head entry; /* Membership in eeh_pe.edevs */
144
+ struct list_head rmv_entry; /* Membership in rmv_list */
147145 struct pci_dn *pdn; /* Associated PCI device node */
148146 struct pci_dev *pdev; /* Associated PCI device */
149147 bool in_error; /* Error flag for edev */
148
+
149
+ /* VF specific properties */
150150 struct pci_dev *physfn; /* Associated SRIOV PF */
151
- struct pci_bus *bus; /* PCI bus for partial hotplug */
151
+ int vf_index; /* Index of this VF */
152152 };
153
+
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__)
153164
154165 static inline struct pci_dn *eeh_dev_to_pdn(struct eeh_dev *edev)
155166 {
....@@ -203,26 +214,24 @@
203214
204215 struct eeh_ops {
205216 char *name;
206
- int (*init)(void);
207
- void* (*probe)(struct pci_dn *pdn, void *data);
217
+ struct eeh_dev *(*probe)(struct pci_dev *pdev);
208218 int (*set_option)(struct eeh_pe *pe, int option);
209
- int (*get_pe_addr)(struct eeh_pe *pe);
210
- int (*get_state)(struct eeh_pe *pe, int *state);
219
+ int (*get_state)(struct eeh_pe *pe, int *delay);
211220 int (*reset)(struct eeh_pe *pe, int option);
212
- int (*wait_state)(struct eeh_pe *pe, int max_wait);
213221 int (*get_log)(struct eeh_pe *pe, int severity, char *drv_log, unsigned long len);
214222 int (*configure_bridge)(struct eeh_pe *pe);
215223 int (*err_inject)(struct eeh_pe *pe, int type, int func,
216224 unsigned long addr, unsigned long mask);
217
- int (*read_config)(struct pci_dn *pdn, int where, int size, u32 *val);
218
- int (*write_config)(struct pci_dn *pdn, int where, int size, u32 val);
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);
219227 int (*next_error)(struct eeh_pe **pe);
220
- int (*restore_config)(struct pci_dn *pdn);
221
- int (*notify_resume)(struct pci_dn *pdn);
228
+ int (*restore_config)(struct eeh_dev *edev);
229
+ int (*notify_resume)(struct eeh_dev *edev);
222230 };
223231
224232 extern int eeh_subsystem_flags;
225
-extern int eeh_max_freezes;
233
+extern u32 eeh_max_freezes;
234
+extern bool eeh_debugfs_no_recover;
226235 extern struct eeh_ops *eeh_ops;
227236 extern raw_spinlock_t confirm_error_lock;
228237
....@@ -243,11 +252,7 @@
243252
244253 static inline bool eeh_enabled(void)
245254 {
246
- if (eeh_has_flag(EEH_FORCE_DISABLED) ||
247
- !eeh_has_flag(EEH_ENABLED))
248
- return false;
249
-
250
- return true;
255
+ return eeh_has_flag(EEH_ENABLED) && !eeh_has_flag(EEH_FORCE_DISABLED);
251256 }
252257
253258 static inline void eeh_serialize_lock(unsigned long *flags)
....@@ -266,51 +271,43 @@
266271 == (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE);
267272 }
268273
269
-typedef void *(*eeh_edev_traverse_func)(struct eeh_dev *edev, void *flag);
274
+typedef void (*eeh_edev_traverse_func)(struct eeh_dev *edev, void *flag);
270275 typedef void *(*eeh_pe_traverse_func)(struct eeh_pe *pe, void *flag);
271276 void eeh_set_pe_aux_size(int size);
272277 int eeh_phb_pe_create(struct pci_controller *phb);
278
+int eeh_wait_state(struct eeh_pe *pe, int max_wait);
273279 struct eeh_pe *eeh_phb_pe_get(struct pci_controller *phb);
274280 struct eeh_pe *eeh_pe_next(struct eeh_pe *pe, struct eeh_pe *root);
275
-struct eeh_pe *eeh_pe_get(struct pci_controller *phb,
276
- int pe_no, int config_addr);
277
-int eeh_add_to_parent_pe(struct eeh_dev *edev);
278
-int eeh_rmv_from_parent_pe(struct eeh_dev *edev);
281
+struct eeh_pe *eeh_pe_get(struct pci_controller *phb, int pe_no);
282
+int eeh_pe_tree_insert(struct eeh_dev *edev, struct eeh_pe *new_pe_parent);
283
+int eeh_pe_tree_remove(struct eeh_dev *edev);
279284 void eeh_pe_update_time_stamp(struct eeh_pe *pe);
280285 void *eeh_pe_traverse(struct eeh_pe *root,
281286 eeh_pe_traverse_func fn, void *flag);
282
-void *eeh_pe_dev_traverse(struct eeh_pe *root,
283
- eeh_edev_traverse_func fn, void *flag);
287
+void eeh_pe_dev_traverse(struct eeh_pe *root,
288
+ eeh_edev_traverse_func fn, void *flag);
284289 void eeh_pe_restore_bars(struct eeh_pe *pe);
285290 const char *eeh_pe_loc_get(struct eeh_pe *pe);
286291 struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe);
287292
288
-struct eeh_dev *eeh_dev_init(struct pci_dn *pdn);
289
-void eeh_dev_phb_init_dynamic(struct pci_controller *phb);
290
-void eeh_probe_devices(void);
291
-int __init eeh_ops_register(struct eeh_ops *ops);
292
-int __exit eeh_ops_unregister(const char *name);
293
+void eeh_show_enabled(void);
294
+int __init eeh_init(struct eeh_ops *ops);
293295 int eeh_check_failure(const volatile void __iomem *token);
294296 int eeh_dev_check_failure(struct eeh_dev *edev);
295
-void eeh_addr_cache_build(void);
296
-void eeh_add_device_early(struct pci_dn *);
297
-void eeh_add_device_tree_early(struct pci_dn *);
298
-void eeh_add_device_late(struct pci_dev *);
299
-void eeh_add_device_tree_late(struct pci_bus *);
300
-void eeh_add_sysfs_files(struct pci_bus *);
297
+void eeh_addr_cache_init(void);
298
+void eeh_probe_device(struct pci_dev *pdev);
301299 void eeh_remove_device(struct pci_dev *);
302
-int eeh_unfreeze_pe(struct eeh_pe *pe, bool sw_state);
300
+int eeh_unfreeze_pe(struct eeh_pe *pe);
303301 int eeh_pe_reset_and_recover(struct eeh_pe *pe);
304302 int eeh_dev_open(struct pci_dev *pdev);
305303 void eeh_dev_release(struct pci_dev *pdev);
306304 struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
307305 int eeh_pe_set_option(struct eeh_pe *pe, int option);
308306 int eeh_pe_get_state(struct eeh_pe *pe);
309
-int eeh_pe_reset(struct eeh_pe *pe, int option);
307
+int eeh_pe_reset(struct eeh_pe *pe, int option, bool include_passed);
310308 int eeh_pe_configure(struct eeh_pe *pe);
311309 int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func,
312310 unsigned long addr, unsigned long mask);
313
-int eeh_restore_vf_config(struct pci_dn *pdn);
314311
315312 /**
316313 * EEH_POSSIBLE_ERROR() -- test for possible MMIO failure.
....@@ -334,12 +331,7 @@
334331 return false;
335332 }
336333
337
-static inline void eeh_probe_devices(void) { }
338
-
339
-static inline void *eeh_dev_init(struct pci_dn *pdn, void *data)
340
-{
341
- return NULL;
342
-}
334
+static inline void eeh_show_enabled(void) { }
343335
344336 static inline void eeh_dev_phb_init_dynamic(struct pci_controller *phb) { }
345337
....@@ -350,23 +342,24 @@
350342
351343 #define eeh_dev_check_failure(x) (0)
352344
353
-static inline void eeh_addr_cache_build(void) { }
345
+static inline void eeh_addr_cache_init(void) { }
354346
355
-static inline void eeh_add_device_early(struct pci_dn *pdn) { }
356
-
357
-static inline void eeh_add_device_tree_early(struct pci_dn *pdn) { }
358
-
359
-static inline void eeh_add_device_late(struct pci_dev *dev) { }
360
-
361
-static inline void eeh_add_device_tree_late(struct pci_bus *bus) { }
362
-
363
-static inline void eeh_add_sysfs_files(struct pci_bus *bus) { }
347
+static inline void eeh_probe_device(struct pci_dev *dev) { }
364348
365349 static inline void eeh_remove_device(struct pci_dev *dev) { }
366350
367351 #define EEH_POSSIBLE_ERROR(val, type) (0)
368352 #define EEH_IO_ERROR_VALUE(size) (-1UL)
353
+static inline int eeh_phb_pe_create(struct pci_controller *phb) { return 0; }
369354 #endif /* CONFIG_EEH */
355
+
356
+#if defined(CONFIG_PPC_PSERIES) && defined(CONFIG_EEH)
357
+void pseries_eeh_init_edev(struct pci_dn *pdn);
358
+void pseries_eeh_init_edev_recursive(struct pci_dn *pdn);
359
+#else
360
+static inline void pseries_eeh_add_device_early(struct pci_dn *pdn) { }
361
+static inline void pseries_eeh_add_device_tree_early(struct pci_dn *pdn) { }
362
+#endif
370363
371364 #ifdef CONFIG_PPC64
372365 /*
....@@ -466,6 +459,9 @@
466459 eeh_check_failure(addr);
467460 }
468461
462
+
463
+void eeh_cache_debugfs_init(void);
464
+
469465 #endif /* CONFIG_PPC64 */
470466 #endif /* __KERNEL__ */
471467 #endif /* _POWERPC_EEH_H */