Skip to content

Commit a987ba9

Browse files
Jijie ShaoNipaLocal
authored andcommitted
net: hibmcge: fix the inappropriate netif_device_detach()
current, driver will call netif_device_detach() in pci_error_handlers.error_detected() and do reset in pci_error_handlers.slot_reset(). However, if pci_error_handlers.slot_reset() is not called after pci_error_handlers.error_detected(), driver will be detached and unable to recover. drivers/pci/pcie/err.c/report_error_detected() says: If any device in the subtree does not have an error_detected callback, PCI_ERS_RESULT_NO_AER_DRIVER prevents subsequent error callbacks of any device in the subtree, and will exit in the disconnected error state. Therefore, when the hibmcge device and other devices that do not support the error_detected callback are under the same subtree, hibmcge will be unable to do slot_reset even for non-fatal errors. This path move netif_device_detach() from error_detected() to slot_reset(), ensuring that detach and reset are always executed together. Fixes: fd394a3 ("net: hibmcge: Add support for abnormal irq handling feature") Signed-off-by: Jijie Shao <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 62ca87b commit a987ba9

File tree

1 file changed

+6
-4
lines changed
  • drivers/net/ethernet/hisilicon/hibmcge

1 file changed

+6
-4
lines changed

drivers/net/ethernet/hisilicon/hibmcge/hbg_err.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,11 @@ static pci_ers_result_t hbg_pci_err_detected(struct pci_dev *pdev,
136136
{
137137
struct net_device *netdev = pci_get_drvdata(pdev);
138138

139-
netif_device_detach(netdev);
140-
141-
if (state == pci_channel_io_perm_failure)
139+
if (state == pci_channel_io_perm_failure) {
140+
netif_device_detach(netdev);
142141
return PCI_ERS_RESULT_DISCONNECT;
142+
}
143143

144-
pci_disable_device(pdev);
145144
return PCI_ERS_RESULT_NEED_RESET;
146145
}
147146

@@ -150,6 +149,9 @@ static pci_ers_result_t hbg_pci_err_slot_reset(struct pci_dev *pdev)
150149
struct net_device *netdev = pci_get_drvdata(pdev);
151150
struct hbg_priv *priv = netdev_priv(netdev);
152151

152+
netif_device_detach(netdev);
153+
pci_disable_device(pdev);
154+
153155
if (pci_enable_device(pdev)) {
154156
dev_err(&pdev->dev,
155157
"failed to re-enable PCI device after reset\n");

0 commit comments

Comments
 (0)