Sfoglia il codice sorgente

bnxt_re: Free up devices in module_exit path

Clean up all devices added to the bnxt_re_dev_list in the
module_exit entry point.

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Somnath Kotur 8 anni fa
parent
commit
027c892924
1 ha cambiato i file con 16 aggiunte e 0 eliminazioni
  1. 16 0
      drivers/infiniband/hw/bnxt_re/main.c

+ 16 - 0
drivers/infiniband/hw/bnxt_re/main.c

@@ -1375,6 +1375,22 @@ err_netdev:
 
 
 static void __exit bnxt_re_mod_exit(void)
 static void __exit bnxt_re_mod_exit(void)
 {
 {
+	struct bnxt_re_dev *rdev;
+	LIST_HEAD(to_be_deleted);
+
+	mutex_lock(&bnxt_re_dev_lock);
+	/* Free all adapter allocated resources */
+	if (!list_empty(&bnxt_re_dev_list))
+		list_splice_init(&bnxt_re_dev_list, &to_be_deleted);
+	mutex_unlock(&bnxt_re_dev_lock);
+
+	list_for_each_entry(rdev, &to_be_deleted, list) {
+		dev_info(rdev_to_dev(rdev), "Unregistering Device");
+		bnxt_re_dev_stop(rdev);
+		bnxt_re_ib_unreg(rdev, true);
+		bnxt_re_remove_one(rdev);
+		bnxt_re_dev_unreg(rdev);
+	}
 	unregister_netdevice_notifier(&bnxt_re_netdev_notifier);
 	unregister_netdevice_notifier(&bnxt_re_netdev_notifier);
 	if (bnxt_re_wq)
 	if (bnxt_re_wq)
 		destroy_workqueue(bnxt_re_wq);
 		destroy_workqueue(bnxt_re_wq);