The method struct pci_error_handlers.error_detected() is defined and documented as taking an 'enum pci_channel_state' for the second argument, but most drivers use 'pci_channel_state_t' instead. This 'pci_channel_state_t' is not a typedef for the enum but a typedef for a bitwise type in order to have better/stricter typechecking. Consolidate everything by using 'pci_channel_state_t' in the method's definition, in the related helpers and in the drivers. Enforce use of 'pci_channel_state_t' by replacing 'enum pci_channel_state' with an anonymous 'enum'. Note: Currently, from a typechecking point of view this patch changes nothing because only the constants defined by the enum are bitwise, not the enum itself (sparse doesn't have the notion of 'bitwise enum'). This may change in some not too far future, hence the patch. [bhelgaas: squash in https://lore.kernel.org/r/20200702162651.49526-3-luc.vanoostenryck@gmail.com https://lore.kernel.org/r/20200702162651.49526-4-luc.vanoostenryck@gmail.com] Link: https://lore.kernel.org/r/20200702162651.49526-2-luc.vanoostenryck@gmail.com Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Unified · Split
| @@ -79,7 +79,7 @@ This structure has the form:: · 78 unmodified lines | ||
| 79 | 79 | |
| 80 | 80 | struct pci_error_handlers |
| 81 | 81 | { |
| 82 | − int (*error_detected)(struct pci_dev *dev, enum pci_channel_state); | |
| 82 | + int (*error_detected)(struct pci_dev *dev, pci_channel_state_t); | |
| 83 | 83 | int (*mmio_enabled)(struct pci_dev *dev); |
| 84 | 84 | int (*slot_reset)(struct pci_dev *dev); |
| 85 | 85 | void (*resume)(struct pci_dev *dev); |
| @@ -87,11 +87,11 @@ This structure has the form:: · 1 unmodified line | ||
| 87 | 87 | |
| 88 | 88 | The possible channel states are:: |
| 89 | 89 | |
| 90 | − enum pci_channel_state { | |
| 90 | + typedef enum { | |
| 91 | 91 | pci_channel_io_normal, /* I/O channel is in normal state */ |
| 92 | 92 | pci_channel_io_frozen, /* I/O to channel is blocked */ |
| 93 | 93 | pci_channel_io_perm_failure, /* PCI card is dead */ |
| 94 | − }; | |
| 94 | + } pci_channel_state_t; | |
| 95 | 95 | |
| 96 | 96 | Possible return values are:: |
| 97 | 97 | |
| @@ -348,7 +348,7 @@ STEP 6: Permanent Failure · 250 unmodified lines | ||
| 348 | 348 | ------------------------- |
| 349 | 349 | A "permanent failure" has occurred, and the platform cannot recover |
| 350 | 350 | the device. The platform will call error_detected() with a |
| 351 | −pci_channel_state value of pci_channel_io_perm_failure. | |
| 351 | +pci_channel_state_t value of pci_channel_io_perm_failure. | |
| 352 | 352 | |
| 353 | 353 | The device driver should, at this point, assume the worst. It should |
| 354 | 354 | cancel all pending I/O, refuse all new I/O, returning -EIO to |
| @@ -214,7 +214,7 @@ static void eeh_dev_save_state(struct eeh_dev *edev, void *userdata) · 213 unmodified lines | ||
| 214 | 214 | pci_save_state(pdev); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | −static void eeh_set_channel_state(struct eeh_pe *root, enum pci_channel_state s) | |
| 217 | +static void eeh_set_channel_state(struct eeh_pe *root, pci_channel_state_t s) | |
| 218 | 218 | { |
| 219 | 219 | struct eeh_pe *pe; |
| 220 | 220 | struct eeh_dev *edev, *tmp; |
| @@ -625,7 +625,7 @@ static int rsxx_eeh_fifo_flush_poll(struct rsxx_cardinfo *card) · 624 unmodified lines | ||
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | static pci_ers_result_t rsxx_error_detected(struct pci_dev *dev, |
| 628 | − enum pci_channel_state error) | |
| 628 | + pci_channel_state_t error) | |
| 629 | 629 | { |
| 630 | 630 | int st; |
| 631 | 631 | |
| @@ -1267,7 +1267,7 @@ static void ioat_resume(struct ioatdma_device *ioat_dma) · 1266 unmodified lines | ||
| 1267 | 1267 | #define DRV_NAME "ioatdma" |
| 1268 | 1268 | |
| 1269 | 1269 | static pci_ers_result_t ioat_pcie_error_detected(struct pci_dev *pdev, |
| 1270 | − enum pci_channel_state error) | |
| 1270 | + pci_channel_state_t error) | |
| 1271 | 1271 | { |
| 1272 | 1272 | dev_dbg(&pdev->dev, "%s: PCIe AER error %d\n", DRV_NAME, error); |
| 1273 | 1273 | |
| @@ -1186,7 +1186,7 @@ MODULE_DEVICE_TABLE(pci, ngene_id_tbl); · 1185 unmodified lines | ||
| 1186 | 1186 | /****************************************************************************/ |
| 1187 | 1187 | |
| 1188 | 1188 | static pci_ers_result_t ngene_error_detected(struct pci_dev *dev, |
| 1189 | − enum pci_channel_state state) | |
| 1189 | + pci_channel_state_t state) | |
| 1190 | 1190 | { |
| 1191 | 1191 | dev_err(&dev->dev, "PCI error\n"); |
| 1192 | 1192 | if (state == pci_channel_io_perm_failure) |
| @@ -1240,7 +1240,7 @@ static void genwqe_remove(struct pci_dev *pci_dev) · 1239 unmodified lines | ||
| 1240 | 1240 | * error is detected. |
| 1241 | 1241 | */ |
| 1242 | 1242 | static pci_ers_result_t genwqe_err_error_detected(struct pci_dev *pci_dev, |
| 1243 | − enum pci_channel_state state) | |
| 1243 | + pci_channel_state_t state) | |
| 1244 | 1244 | { |
| 1245 | 1245 | struct genwqe_dev *cd; |
| 1246 | 1246 | |
| @@ -15465,7 +15465,7 @@ unmap: · 15464 unmodified lines | ||
| 15465 | 15465 | * remediation. |
| 15466 | 15466 | **/ |
| 15467 | 15467 | static pci_ers_result_t i40e_pci_error_detected(struct pci_dev *pdev, |
| 15468 | − enum pci_channel_state error) | |
| 15468 | + pci_channel_state_t error) | |
| 15469 | 15469 | { |
| 15470 | 15470 | struct i40e_pf *pf = pci_get_drvdata(pdev); |
| 15471 | 15471 | |
| @@ -3586,7 +3586,7 @@ static void ice_remove(struct pci_dev *pdev) · 3585 unmodified lines | ||
| 3586 | 3586 | * is in progress. Allows the driver to gracefully prepare/handle PCI errors. |
| 3587 | 3587 | */ |
| 3588 | 3588 | static pci_ers_result_t |
| 3589 | −ice_pci_err_detected(struct pci_dev *pdev, enum pci_channel_state err) | |
| 3589 | +ice_pci_err_detected(struct pci_dev *pdev, pci_channel_state_t err) | |
| 3590 | 3590 | { |
| 3591 | 3591 | struct ice_pf *pf = pci_get_drvdata(pdev); |
| 3592 | 3592 | |
| @@ -82,7 +82,7 @@ static int ixgb_vlan_rx_kill_vid(struct net_device *netdev, · 81 unmodified lines | ||
| 82 | 82 | static void ixgb_restore_vlan(struct ixgb_adapter *adapter); |
| 83 | 83 | |
| 84 | 84 | static pci_ers_result_t ixgb_io_error_detected (struct pci_dev *pdev, |
| 85 | − enum pci_channel_state state); | |
| 85 | + pci_channel_state_t state); | |
| 86 | 86 | static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev); |
| 87 | 87 | static void ixgb_io_resume (struct pci_dev *pdev); |
| 88 | 88 | |
| @@ -2194,7 +2194,7 @@ ixgb_restore_vlan(struct ixgb_adapter *adapter) · 2105 unmodified lines | ||
| 2194 | 2194 | * a PCI bus error is detected. |
| 2195 | 2195 | */ |
| 2196 | 2196 | static pci_ers_result_t ixgb_io_error_detected(struct pci_dev *pdev, |
| 2197 | − enum pci_channel_state state) | |
| 2197 | + pci_channel_state_t state) | |
| 2198 | 2198 | { |
| 2199 | 2199 | struct net_device *netdev = pci_get_drvdata(pdev); |
| 2200 | 2200 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
| @@ -1519,7 +1519,7 @@ static const struct dev_pm_ops efx_pm_ops = { · 1518 unmodified lines | ||
| 1519 | 1519 | * Stop the software path and request a slot reset. |
| 1520 | 1520 | */ |
| 1521 | 1521 | static pci_ers_result_t efx_io_error_detected(struct pci_dev *pdev, |
| 1522 | − enum pci_channel_state state) | |
| 1522 | + pci_channel_state_t state) | |
| 1523 | 1523 | { |
| 1524 | 1524 | pci_ers_result_t status = PCI_ERS_RESULT_RECOVERED; |
| 1525 | 1525 | struct efx_nic *efx = pci_get_drvdata(pdev); |
| @@ -3118,7 +3118,7 @@ static const struct dev_pm_ops ef4_pm_ops = { · 3117 unmodified lines | ||
| 3118 | 3118 | * Stop the software path and request a slot reset. |
| 3119 | 3119 | */ |
| 3120 | 3120 | static pci_ers_result_t ef4_io_error_detected(struct pci_dev *pdev, |
| 3121 | − enum pci_channel_state state) | |
| 3121 | + pci_channel_state_t state) | |
| 3122 | 3122 | { |
| 3123 | 3123 | pci_ers_result_t status = PCI_ERS_RESULT_RECOVERED; |
| 3124 | 3124 | struct ef4_nic *efx = pci_get_drvdata(pdev); |
| @@ -555,7 +555,7 @@ static inline int pci_dev_specific_disable_acs_redir(struct pci_dev *dev) · 554 unmodified lines | ||
| 555 | 555 | |
| 556 | 556 | /* PCI error reporting and recovery */ |
| 557 | 557 | pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, |
| 558 | − enum pci_channel_state state, | |
| 558 | + pci_channel_state_t state, | |
| 559 | 559 | pci_ers_result_t (*reset_link)(struct pci_dev *pdev)); |
| 560 | 560 | |
| 561 | 561 | bool pcie_wait_for_link(struct pci_dev *pdev, bool active); |
| @@ -46,7 +46,7 @@ static pci_ers_result_t merge_result(enum pci_ers_result orig, · 45 unmodified lines | ||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | static int report_error_detected(struct pci_dev *dev, |
| 49 | − enum pci_channel_state state, | |
| 49 | + pci_channel_state_t state, | |
| 50 | 50 | enum pci_ers_result *result) |
| 51 | 51 | { |
| 52 | 52 | pci_ers_result_t vote; |
| @@ -147,7 +147,7 @@ out: · 94 unmodified lines | ||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, |
| 150 | − enum pci_channel_state state, | |
| 150 | + pci_channel_state_t state, | |
| 151 | 151 | pci_ers_result_t (*reset_link)(struct pci_dev *pdev)) |
| 152 | 152 | { |
| 153 | 153 | pci_ers_result_t status = PCI_ERS_RESULT_CAN_RECOVER; |
| @@ -146,7 +146,7 @@ static void pcie_portdrv_remove(struct pci_dev *dev) · 145 unmodified lines | ||
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | static pci_ers_result_t pcie_portdrv_error_detected(struct pci_dev *dev, |
| 149 | − enum pci_channel_state error) | |
| 149 | + pci_channel_state_t error) | |
| 150 | 150 | { |
| 151 | 151 | /* Root Port has no impact. Always recovers. */ |
| 152 | 152 | return PCI_ERS_RESULT_CAN_RECOVER; |
| @@ -2002,7 +2002,7 @@ static void aac_remove_one(struct pci_dev *pdev) · 2001 unmodified lines | ||
| 2002 | 2002 | } |
| 2003 | 2003 | |
| 2004 | 2004 | static pci_ers_result_t aac_pci_error_detected(struct pci_dev *pdev, |
| 2005 | − enum pci_channel_state error) | |
| 2005 | + pci_channel_state_t error) | |
| 2006 | 2006 | { |
| 2007 | 2007 | struct Scsi_Host *shost = pci_get_drvdata(pdev); |
| 2008 | 2008 | struct aac_dev *aac = shost_priv(shost); |
| @@ -1743,7 +1743,7 @@ static void sym2_remove(struct pci_dev *pdev) · 1742 unmodified lines | ||
| 1743 | 1743 | * @state: current state of the PCI slot |
| 1744 | 1744 | */ |
| 1745 | 1745 | static pci_ers_result_t sym2_io_error_detected(struct pci_dev *pdev, |
| 1746 | − enum pci_channel_state state) | |
| 1746 | + pci_channel_state_t state) | |
| 1747 | 1747 | { |
| 1748 | 1748 | /* If slot is permanently frozen, turn everything off */ |
| 1749 | 1749 | if (state == pci_channel_io_perm_failure) { |
| @@ -4678,7 +4678,7 @@ static void ql_eeh_close(struct net_device *ndev) · 4677 unmodified lines | ||
| 4678 | 4678 | * a PCI bus error is detected. |
| 4679 | 4679 | */ |
| 4680 | 4680 | static pci_ers_result_t qlge_io_error_detected(struct pci_dev *pdev, |
| 4681 | − enum pci_channel_state state) | |
| 4681 | + pci_channel_state_t state) | |
| 4682 | 4682 | { |
| 4683 | 4683 | struct net_device *ndev = pci_get_drvdata(pdev); |
| 4684 | 4684 | struct ql_adapter *qdev = netdev_priv(ndev); |
| @@ -179,7 +179,7 @@ static inline const char *pci_power_name(pci_power_t state) · 178 unmodified lines | ||
| 179 | 179 | */ |
| 180 | 180 | typedef unsigned int __bitwise pci_channel_state_t; |
| 181 | 181 | |
| 182 | −enum pci_channel_state { | |
| 182 | +enum { | |
| 183 | 183 | /* I/O channel is in normal state */ |
| 184 | 184 | pci_channel_io_normal = (__force pci_channel_state_t) 1, |
| 185 | 185 | |
| @@ -785,7 +785,7 @@ enum pci_ers_result { · 599 unmodified lines | ||
| 785 | 785 | struct pci_error_handlers { |
| 786 | 786 | /* PCI bus error detected on this device */ |
| 787 | 787 | pci_ers_result_t (*error_detected)(struct pci_dev *dev, |
| 788 | − enum pci_channel_state error); | |
| 788 | + pci_channel_state_t error); | |
| 789 | 789 | |
| 790 | 790 | /* MMIO has been re-enabled, but not DMA */ |
| 791 | 791 | pci_ers_result_t (*mmio_enabled)(struct pci_dev *dev); |