scsi: mpt3sas: Suppress a warning in debug kernel
authorTomas Henzl <thenzl@redhat.com>
Thu, 19 Oct 2023 15:37:06 +0000 (17:37 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 15 Nov 2023 15:50:31 +0000 (10:50 -0500)
The mpt3sas_ctl_exit() should be called after communication with the
controller stops but currently it may cause false warnings about not
released memory. Fix this by letting mpt3sas_ctl_exit() handle misc driver
release per driver and release DMA in mpt3sas_ctl_release() per ioc.

Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Link: https://lore.kernel.org/r/20231019153706.7967-1-thenzl@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/mpt3sas/mpt3sas_base.h
drivers/scsi/mpt3sas/mpt3sas_ctl.c
drivers/scsi/mpt3sas/mpt3sas_scsih.c

index c672f3a1c67d3235aa1855c6aa4900a2f640c787..6d0bc8c6670028d621271190ac6e38a7a79a4fe6 100644 (file)
@@ -1981,6 +1981,7 @@ extern const struct attribute_group *mpt3sas_host_groups[];
 extern const struct attribute_group *mpt3sas_dev_groups[];
 void mpt3sas_ctl_init(ushort hbas_to_enumerate);
 void mpt3sas_ctl_exit(ushort hbas_to_enumerate);
+void mpt3sas_ctl_release(struct MPT3SAS_ADAPTER *ioc);
 u8 mpt3sas_ctl_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
        u32 reply);
 void mpt3sas_ctl_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc);
index efdb8178db3248684385ce83bd2e27e7d745f43e..147cb7088d55f4aaa4eb823b894a8a67dd22bf84 100644 (file)
@@ -4157,31 +4157,37 @@ mpt3sas_ctl_init(ushort hbas_to_enumerate)
 }
 
 /**
- * mpt3sas_ctl_exit - exit point for ctl
- * @hbas_to_enumerate: ?
+ * mpt3sas_ctl_release - release dma for ctl
+ * @ioc: per adapter object
  */
 void
-mpt3sas_ctl_exit(ushort hbas_to_enumerate)
+mpt3sas_ctl_release(struct MPT3SAS_ADAPTER *ioc)
 {
-       struct MPT3SAS_ADAPTER *ioc;
        int i;
 
-       list_for_each_entry(ioc, &mpt3sas_ioc_list, list) {
+       /* free memory associated to diag buffers */
+       for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) {
+               if (!ioc->diag_buffer[i])
+                       continue;
+               dma_free_coherent(&ioc->pdev->dev,
+                                 ioc->diag_buffer_sz[i],
+                                 ioc->diag_buffer[i],
+                                 ioc->diag_buffer_dma[i]);
+               ioc->diag_buffer[i] = NULL;
+               ioc->diag_buffer_status[i] = 0;
+       }
 
-               /* free memory associated to diag buffers */
-               for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) {
-                       if (!ioc->diag_buffer[i])
-                               continue;
-                       dma_free_coherent(&ioc->pdev->dev,
-                                         ioc->diag_buffer_sz[i],
-                                         ioc->diag_buffer[i],
-                                         ioc->diag_buffer_dma[i]);
-                       ioc->diag_buffer[i] = NULL;
-                       ioc->diag_buffer_status[i] = 0;
-               }
+       kfree(ioc->event_log);
+}
+
+/**
+ * mpt3sas_ctl_exit - exit point for ctl
+ * @hbas_to_enumerate: ?
+ */
+void
+mpt3sas_ctl_exit(ushort hbas_to_enumerate)
+{
 
-               kfree(ioc->event_log);
-       }
        if (hbas_to_enumerate != 1)
                misc_deregister(&ctl_dev);
        if (hbas_to_enumerate != 2)
index 5037e24596d8d4669875b51cc18adacf59f6f47e..51b5788da040ac79125eaf027048b85dca8e7e2a 100644 (file)
@@ -11331,6 +11331,7 @@ static void scsih_remove(struct pci_dev *pdev)
        }
 
        mpt3sas_base_detach(ioc);
+       mpt3sas_ctl_release(ioc);
        spin_lock(&gioc_lock);
        list_del(&ioc->list);
        spin_unlock(&gioc_lock);