Skip to content

Commit b350f0a

Browse files
amd-anathjonmason
authored andcommitted
NTB: add pci shutdown handler for AMD NTB
The PCI shutdown handler is invoked in response to system reboot or shutdown. A data transfer might still be in flight when this happens. So the very first action we take here is to send a link down notification, so that any pending data transfer is terminated. Rest of the actions are same as that of PCI remove handler. Signed-off-by: Arindam Nath <[email protected]> Signed-off-by: Jon Mason <[email protected]>
1 parent ac10d4f commit b350f0a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/ntb/hw/amd/ntb_hw_amd.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,22 @@ static void amd_ntb_pci_remove(struct pci_dev *pdev)
12961296
kfree(ndev);
12971297
}
12981298

1299+
static void amd_ntb_pci_shutdown(struct pci_dev *pdev)
1300+
{
1301+
struct amd_ntb_dev *ndev = pci_get_drvdata(pdev);
1302+
1303+
/* Send link down notification */
1304+
ntb_link_event(&ndev->ntb);
1305+
1306+
amd_deinit_side_info(ndev);
1307+
ntb_peer_db_set(&ndev->ntb, BIT_ULL(ndev->db_last_bit));
1308+
ntb_unregister_device(&ndev->ntb);
1309+
ndev_deinit_debugfs(ndev);
1310+
amd_deinit_dev(ndev);
1311+
amd_ntb_deinit_pci(ndev);
1312+
kfree(ndev);
1313+
}
1314+
12991315
static const struct file_operations amd_ntb_debugfs_info = {
13001316
.owner = THIS_MODULE,
13011317
.open = simple_open,
@@ -1326,6 +1342,7 @@ static struct pci_driver amd_ntb_pci_driver = {
13261342
.id_table = amd_ntb_pci_tbl,
13271343
.probe = amd_ntb_pci_probe,
13281344
.remove = amd_ntb_pci_remove,
1345+
.shutdown = amd_ntb_pci_shutdown,
13291346
};
13301347

13311348
static int __init amd_ntb_pci_driver_init(void)

0 commit comments

Comments
 (0)