| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Sysfs entries for PCI Error Recovery for PAPR-compliant platform. |
|---|
| 3 | 4 | * Copyright IBM Corporation 2007 |
|---|
| 4 | 5 | * 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. |
|---|
| 22 | 6 | * |
|---|
| 23 | 7 | * Send comments and feedback to Linas Vepstas <linas@austin.ibm.com> |
|---|
| 24 | 8 | */ |
|---|
| .. | .. |
|---|
| 30 | 14 | /** |
|---|
| 31 | 15 | * EEH_SHOW_ATTR -- Create sysfs entry for eeh statistic |
|---|
| 32 | 16 | * @_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 |
|---|
| 34 | 18 | * @_format: printf format for display |
|---|
| 35 | 19 | * |
|---|
| 36 | 20 | * All of the attributes look very similar, so just |
|---|
| .. | .. |
|---|
| 82 | 66 | if (!(edev->pe->state & EEH_PE_ISOLATED)) |
|---|
| 83 | 67 | return count; |
|---|
| 84 | 68 | |
|---|
| 85 | | - if (eeh_unfreeze_pe(edev->pe, true)) |
|---|
| 69 | + if (eeh_unfreeze_pe(edev->pe)) |
|---|
| 86 | 70 | return -EIO; |
|---|
| 71 | + eeh_pe_state_clear(edev->pe, EEH_PE_ISOLATED, true); |
|---|
| 87 | 72 | |
|---|
| 88 | 73 | return count; |
|---|
| 89 | 74 | } |
|---|
| 90 | 75 | |
|---|
| 91 | 76 | static DEVICE_ATTR_RW(eeh_pe_state); |
|---|
| 92 | 77 | |
|---|
| 93 | | -#ifdef CONFIG_PCI_IOV |
|---|
| 78 | +#if defined(CONFIG_PCI_IOV) && defined(CONFIG_PPC_PSERIES) |
|---|
| 94 | 79 | static ssize_t eeh_notify_resume_show(struct device *dev, |
|---|
| 95 | 80 | struct device_attribute *attr, char *buf) |
|---|
| 96 | 81 | { |
|---|
| .. | .. |
|---|
| 101 | 86 | if (!edev || !edev->pe) |
|---|
| 102 | 87 | return -ENODEV; |
|---|
| 103 | 88 | |
|---|
| 104 | | - pdn = pci_get_pdn(pdev); |
|---|
| 105 | 89 | return sprintf(buf, "%d\n", pdn->last_allow_rc); |
|---|
| 106 | 90 | } |
|---|
| 107 | 91 | |
|---|
| .. | .. |
|---|
| 115 | 99 | if (!edev || !edev->pe || !eeh_ops->notify_resume) |
|---|
| 116 | 100 | return -ENODEV; |
|---|
| 117 | 101 | |
|---|
| 118 | | - if (eeh_ops->notify_resume(pci_get_pdn(pdev))) |
|---|
| 102 | + if (eeh_ops->notify_resume(edev)) |
|---|
| 119 | 103 | return -EIO; |
|---|
| 120 | 104 | |
|---|
| 121 | 105 | return count; |
|---|
| .. | .. |
|---|
| 147 | 131 | #else |
|---|
| 148 | 132 | static inline int eeh_notify_resume_add(struct pci_dev *pdev) { return 0; } |
|---|
| 149 | 133 | static inline void eeh_notify_resume_remove(struct pci_dev *pdev) { } |
|---|
| 150 | | -#endif /* CONFIG_PCI_IOV */ |
|---|
| 134 | +#endif /* CONFIG_PCI_IOV && CONFIG PPC_PSERIES*/ |
|---|
| 151 | 135 | |
|---|
| 152 | 136 | void eeh_sysfs_add_device(struct pci_dev *pdev) |
|---|
| 153 | 137 | { |
|---|
| .. | .. |
|---|
| 175 | 159 | { |
|---|
| 176 | 160 | struct eeh_dev *edev = pci_dev_to_eeh_dev(pdev); |
|---|
| 177 | 161 | |
|---|
| 162 | + if (!edev) { |
|---|
| 163 | + WARN_ON(eeh_enabled()); |
|---|
| 164 | + return; |
|---|
| 165 | + } |
|---|
| 166 | + |
|---|
| 167 | + edev->mode &= ~EEH_DEV_SYSFS; |
|---|
| 168 | + |
|---|
| 178 | 169 | /* |
|---|
| 179 | 170 | * The parent directory might have been removed. We needn't |
|---|
| 180 | 171 | * continue for that case. |
|---|
| 181 | 172 | */ |
|---|
| 182 | | - if (!pdev->dev.kobj.sd) { |
|---|
| 183 | | - if (edev) |
|---|
| 184 | | - edev->mode &= ~EEH_DEV_SYSFS; |
|---|
| 173 | + if (!pdev->dev.kobj.sd) |
|---|
| 185 | 174 | return; |
|---|
| 186 | | - } |
|---|
| 187 | 175 | |
|---|
| 188 | 176 | device_remove_file(&pdev->dev, &dev_attr_eeh_mode); |
|---|
| 189 | 177 | device_remove_file(&pdev->dev, &dev_attr_eeh_pe_config_addr); |
|---|
| 190 | 178 | device_remove_file(&pdev->dev, &dev_attr_eeh_pe_state); |
|---|
| 191 | 179 | |
|---|
| 192 | 180 | eeh_notify_resume_remove(pdev); |
|---|
| 193 | | - |
|---|
| 194 | | - if (edev) |
|---|
| 195 | | - edev->mode &= ~EEH_DEV_SYSFS; |
|---|
| 196 | 181 | } |
|---|