diff mbox series

[v2] mpt3sas: suppress a warning in debug kernel

Message ID 20231019153706.7967-1-thenzl@redhat.com (mailing list archive)
State Accepted
Headers show
Series [v2] mpt3sas: suppress a warning in debug kernel | expand

Commit Message

Tomas Henzl Oct. 19, 2023, 3:37 p.m. UTC
The mpt3sas_ctl_exit should be called after communication
with the controller stops but in currently  it may cause
false warnings about not released memory.
Fix it by leaving 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>
---
V2: separate handling of DMA release and misc driver deregistration


 drivers/scsi/mpt3sas/mpt3sas_base.h  |  1 +
 drivers/scsi/mpt3sas/mpt3sas_ctl.c   | 42 ++++++++++++++++------------
 drivers/scsi/mpt3sas/mpt3sas_scsih.c |  1 +
 3 files changed, 26 insertions(+), 18 deletions(-)

Comments

Martin K. Petersen Nov. 15, 2023, 3:51 p.m. UTC | #1
Tomas,

> The mpt3sas_ctl_exit should be called after communication with the
> controller stops but in currently it may cause false warnings about
> not released memory. Fix it by leaving mpt3sas_ctl_exit handle misc
> driver release per driver and release DMA in mpt3sas_ctl_release per
> ioc.

Applied to 6.8/scsi-staging, thanks!
Martin K. Petersen Nov. 25, 2023, 2:54 a.m. UTC | #2
On Thu, 19 Oct 2023 17:37:06 +0200, Tomas Henzl wrote:

> The mpt3sas_ctl_exit should be called after communication
> with the controller stops but in currently  it may cause
> false warnings about not released memory.
> Fix it by leaving mpt3sas_ctl_exit handle misc driver release
> per driver and release DMA in mpt3sas_ctl_release per ioc.
> 
> 
> [...]

Applied to 6.8/scsi-queue, thanks!

[1/1] mpt3sas: suppress a warning in debug kernel
      https://git.kernel.org/mkp/scsi/c/6a965ee1892a
Christophe JAILLET Dec. 7, 2023, 8:57 p.m. UTC | #3
> The mpt3sas_ctl_exit should be called after communication
> with the controller stops but in currently  it may cause
> false warnings about not released memory.
> Fix it by leaving 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>
> ---
> V2: separate handling of DMA release and misc driver deregistration

...

> diff 
<https://lore.kernel.org/all/20231019153706.7967-1-thenzl@redhat.com/#iZ31drivers:scsi:mpt3sas:mpt3sas_scsih.c> 
--git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c > index 
605013d3ee83..96dd2af5cd7d 100644 > --- 
a/drivers/scsi/mpt3sas/mpt3sas_scsih.c > +++ 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c > @@ -11350,6 +11350,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);
> 

Hi,

does a similarmpt3sas_ctl_release() should also be called in the error handling path of |

_scsih_probe()? CJ |
diff mbox series

Patch

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h
index 1be0850ca17a..48ad17bd811d 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -1983,6 +1983,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);
diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
index efdb8178db32..147cb7088d55 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
@@ -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)
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 605013d3ee83..96dd2af5cd7d 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -11350,6 +11350,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);