forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 748e4f3d702def1a4bff191e0cf93b6a05340f01
kernel/arch/powerpc/kernel/eeh_sysfs.c
....@@ -1,24 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Sysfs entries for PCI Error Recovery for PAPR-compliant platform.
34 * Copyright IBM Corporation 2007
45 * Copyright Linas Vepstas <linas@austin.ibm.com> 2007
5
- *
6
- * All rights reserved.
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or (at
11
- * your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful, but
14
- * WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
16
- * NON INFRINGEMENT. See the GNU General Public License for more
17
- * details.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program; if not, write to the Free Software
21
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
226 *
237 * Send comments and feedback to Linas Vepstas <linas@austin.ibm.com>
248 */
....@@ -30,7 +14,7 @@
3014 /**
3115 * EEH_SHOW_ATTR -- Create sysfs entry for eeh statistic
3216 * @_name: name of file in sysfs directory
33
- * @_memb: name of member in struct pci_dn to access
17
+ * @_memb: name of member in struct eeh_dev to access
3418 * @_format: printf format for display
3519 *
3620 * All of the attributes look very similar, so just
....@@ -82,15 +66,16 @@
8266 if (!(edev->pe->state & EEH_PE_ISOLATED))
8367 return count;
8468
85
- if (eeh_unfreeze_pe(edev->pe, true))
69
+ if (eeh_unfreeze_pe(edev->pe))
8670 return -EIO;
71
+ eeh_pe_state_clear(edev->pe, EEH_PE_ISOLATED, true);
8772
8873 return count;
8974 }
9075
9176 static DEVICE_ATTR_RW(eeh_pe_state);
9277
93
-#ifdef CONFIG_PCI_IOV
78
+#if defined(CONFIG_PCI_IOV) && defined(CONFIG_PPC_PSERIES)
9479 static ssize_t eeh_notify_resume_show(struct device *dev,
9580 struct device_attribute *attr, char *buf)
9681 {
....@@ -101,7 +86,6 @@
10186 if (!edev || !edev->pe)
10287 return -ENODEV;
10388
104
- pdn = pci_get_pdn(pdev);
10589 return sprintf(buf, "%d\n", pdn->last_allow_rc);
10690 }
10791
....@@ -115,7 +99,7 @@
11599 if (!edev || !edev->pe || !eeh_ops->notify_resume)
116100 return -ENODEV;
117101
118
- if (eeh_ops->notify_resume(pci_get_pdn(pdev)))
102
+ if (eeh_ops->notify_resume(edev))
119103 return -EIO;
120104
121105 return count;
....@@ -147,7 +131,7 @@
147131 #else
148132 static inline int eeh_notify_resume_add(struct pci_dev *pdev) { return 0; }
149133 static inline void eeh_notify_resume_remove(struct pci_dev *pdev) { }
150
-#endif /* CONFIG_PCI_IOV */
134
+#endif /* CONFIG_PCI_IOV && CONFIG PPC_PSERIES*/
151135
152136 void eeh_sysfs_add_device(struct pci_dev *pdev)
153137 {
....@@ -175,22 +159,23 @@
175159 {
176160 struct eeh_dev *edev = pci_dev_to_eeh_dev(pdev);
177161
162
+ if (!edev) {
163
+ WARN_ON(eeh_enabled());
164
+ return;
165
+ }
166
+
167
+ edev->mode &= ~EEH_DEV_SYSFS;
168
+
178169 /*
179170 * The parent directory might have been removed. We needn't
180171 * continue for that case.
181172 */
182
- if (!pdev->dev.kobj.sd) {
183
- if (edev)
184
- edev->mode &= ~EEH_DEV_SYSFS;
173
+ if (!pdev->dev.kobj.sd)
185174 return;
186
- }
187175
188176 device_remove_file(&pdev->dev, &dev_attr_eeh_mode);
189177 device_remove_file(&pdev->dev, &dev_attr_eeh_pe_config_addr);
190178 device_remove_file(&pdev->dev, &dev_attr_eeh_pe_state);
191179
192180 eeh_notify_resume_remove(pdev);
193
-
194
- if (edev)
195
- edev->mode &= ~EEH_DEV_SYSFS;
196181 }