* [PATCH v2 1/6] scsi: mpi3mr: fix a memory leak
2023-03-02 23:43 [PATCH v2 0/6] scsi: mpi3mr: fix few resource leaks Tomas Henzl
@ 2023-03-02 23:43 ` Tomas Henzl
2023-03-02 23:43 ` [PATCH v2 2/6] scsi: mpi3mr: fix a dma " Tomas Henzl
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Tomas Henzl @ 2023-03-02 23:43 UTC (permalink / raw)
To: linux-scsi; +Cc: sreekanth.reddy, sathya.prakash, ranjan.kumar
Add a missing kfree.
Fixes: f10af057325c ("scsi: mpi3mr: Resource Based Metering")
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
---
drivers/scsi/mpi3mr/mpi3mr_fw.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c
index ab8326b532e7..b632e1bb1007 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_fw.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c
@@ -4403,6 +4403,9 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc)
mrioc->pel_seqnum_virt = NULL;
}
+ kfree(mrioc->throttle_groups);
+ mrioc->throttle_groups = NULL;
+
kfree(mrioc->logdata_buf);
mrioc->logdata_buf = NULL;
--
2.39.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v2 2/6] scsi: mpi3mr: fix a dma memory leak
2023-03-02 23:43 [PATCH v2 0/6] scsi: mpi3mr: fix few resource leaks Tomas Henzl
2023-03-02 23:43 ` [PATCH v2 1/6] scsi: mpi3mr: fix a memory leak Tomas Henzl
@ 2023-03-02 23:43 ` Tomas Henzl
2023-03-02 23:43 ` [PATCH v2 3/6] scsi: mpi3mr: fix a " Tomas Henzl
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Tomas Henzl @ 2023-03-02 23:43 UTC (permalink / raw)
To: linux-scsi; +Cc: sreekanth.reddy, sathya.prakash, ranjan.kumar
A fix for:
DMA-API: pci 0000:83:00.0: device driver has pending DMA allocations while released from device [count=1]
Fixes: 32d457d5a2af ("scsi: mpi3mr: Add framework to issue config requests")
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
---
drivers/scsi/mpi3mr/mpi3mr_fw.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c
index b632e1bb1007..fa62991f5aee 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_fw.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c
@@ -4396,7 +4396,11 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc)
mrioc->admin_req_base, mrioc->admin_req_dma);
mrioc->admin_req_base = NULL;
}
-
+ if (mrioc->cfg_page) {
+ dma_free_coherent(&mrioc->pdev->dev, mrioc->cfg_page_sz,
+ mrioc->cfg_page, mrioc->cfg_page_dma);
+ mrioc->cfg_page = NULL;
+ }
if (mrioc->pel_seqnum_virt) {
dma_free_coherent(&mrioc->pdev->dev, mrioc->pel_seqnum_sz,
mrioc->pel_seqnum_virt, mrioc->pel_seqnum_dma);
--
2.39.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v2 3/6] scsi: mpi3mr: fix a memory leak
2023-03-02 23:43 [PATCH v2 0/6] scsi: mpi3mr: fix few resource leaks Tomas Henzl
2023-03-02 23:43 ` [PATCH v2 1/6] scsi: mpi3mr: fix a memory leak Tomas Henzl
2023-03-02 23:43 ` [PATCH v2 2/6] scsi: mpi3mr: fix a dma " Tomas Henzl
@ 2023-03-02 23:43 ` Tomas Henzl
2023-03-02 23:43 ` [PATCH v2 4/6] " Tomas Henzl
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Tomas Henzl @ 2023-03-02 23:43 UTC (permalink / raw)
To: linux-scsi; +Cc: sreekanth.reddy, sathya.prakash, ranjan.kumar
Free mpi3mr_hba_port at .remove.
Fixes: 42fc9fee116f ("scsi: mpi3mr: Add helper functions to manage device's port")
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
---
drivers/scsi/mpi3mr/mpi3mr_os.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index 6f9230a079c3..85bd45563686 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -5112,6 +5112,7 @@ static void mpi3mr_remove(struct pci_dev *pdev)
struct workqueue_struct *wq;
unsigned long flags;
struct mpi3mr_tgt_dev *tgtdev, *tgtdev_next;
+ struct mpi3mr_hba_port *port, *hba_port_next;
if (!shost)
return;
@@ -5151,6 +5152,16 @@ static void mpi3mr_remove(struct pci_dev *pdev)
mpi3mr_free_mem(mrioc);
mpi3mr_cleanup_resources(mrioc);
+ spin_lock_irqsave(&mrioc->sas_node_lock, flags);
+ list_for_each_entry_safe(port, hba_port_next, &mrioc->hba_port_table_list, list) {
+ ioc_info(mrioc,
+ "removing hba_port entry: %p port: %d from hba_port list\n",
+ port, port->port_id);
+ list_del(&port->list);
+ kfree(port);
+ }
+ spin_unlock_irqrestore(&mrioc->sas_node_lock, flags);
+
spin_lock(&mrioc_list_lock);
list_del(&mrioc->list);
spin_unlock(&mrioc_list_lock);
--
2.39.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v2 4/6] scsi: mpi3mr: fix a memory leak
2023-03-02 23:43 [PATCH v2 0/6] scsi: mpi3mr: fix few resource leaks Tomas Henzl
` (2 preceding siblings ...)
2023-03-02 23:43 ` [PATCH v2 3/6] scsi: mpi3mr: fix a " Tomas Henzl
@ 2023-03-02 23:43 ` Tomas Henzl
2023-03-02 23:43 ` [PATCH v2 5/6] " Tomas Henzl
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Tomas Henzl @ 2023-03-02 23:43 UTC (permalink / raw)
To: linux-scsi; +Cc: sreekanth.reddy, sathya.prakash, ranjan.kumar
Free mrioc->sas_hba.phy at .remove.
Fixes: 42fc9fee116f ("scsi: mpi3mr: Add helper functions to manage device's port")
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
---
drivers/scsi/mpi3mr/mpi3mr_os.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index 85bd45563686..8f17a7953eb4 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -5162,6 +5162,12 @@ static void mpi3mr_remove(struct pci_dev *pdev)
}
spin_unlock_irqrestore(&mrioc->sas_node_lock, flags);
+ if (mrioc->sas_hba.num_phys) {
+ kfree(mrioc->sas_hba.phy);
+ mrioc->sas_hba.phy = NULL;
+ mrioc->sas_hba.num_phys = 0;
+ }
+
spin_lock(&mrioc_list_lock);
list_del(&mrioc->list);
spin_unlock(&mrioc_list_lock);
--
2.39.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v2 5/6] scsi: mpi3mr: fix a memory leak
2023-03-02 23:43 [PATCH v2 0/6] scsi: mpi3mr: fix few resource leaks Tomas Henzl
` (3 preceding siblings ...)
2023-03-02 23:43 ` [PATCH v2 4/6] " Tomas Henzl
@ 2023-03-02 23:43 ` Tomas Henzl
2023-03-02 23:43 ` [PATCH v2 6/6] " Tomas Henzl
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Tomas Henzl @ 2023-03-02 23:43 UTC (permalink / raw)
To: linux-scsi; +Cc: sreekanth.reddy, sathya.prakash, ranjan.kumar
Don't allocate memory again in next loop(s).
Fixes: fe6db6151565 ("scsi: mpi3mr: Handle offline FW activation in graceful manner")
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
---
V2 - mpi3mr_create_op_queues may be called repeatedly
and without it it interferes with mpi3mr_memset_buffers
So let drop the changes around it.
drivers/scsi/mpi3mr/mpi3mr_fw.c | 41 ++++++++++++++++++---------------
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c
index fa62991f5aee..081512b46538 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_fw.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c
@@ -3852,29 +3852,34 @@ int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc)
mpi3mr_print_ioc_info(mrioc);
- dprint_init(mrioc, "allocating config page buffers\n");
- mrioc->cfg_page = dma_alloc_coherent(&mrioc->pdev->dev,
- MPI3MR_DEFAULT_CFG_PAGE_SZ, &mrioc->cfg_page_dma, GFP_KERNEL);
if (!mrioc->cfg_page) {
- retval = -1;
- goto out_failed_noretry;
+ dprint_init(mrioc, "allocating config page buffers\n");
+ mrioc->cfg_page_sz = MPI3MR_DEFAULT_CFG_PAGE_SZ;
+ mrioc->cfg_page = dma_alloc_coherent(&mrioc->pdev->dev,
+ mrioc->cfg_page_sz, &mrioc->cfg_page_dma, GFP_KERNEL);
+ if (!mrioc->cfg_page) {
+ retval = -1;
+ goto out_failed_noretry;
+ }
}
- mrioc->cfg_page_sz = MPI3MR_DEFAULT_CFG_PAGE_SZ;
-
- retval = mpi3mr_alloc_reply_sense_bufs(mrioc);
- if (retval) {
- ioc_err(mrioc,
- "%s :Failed to allocated reply sense buffers %d\n",
- __func__, retval);
- goto out_failed_noretry;
+ if (!mrioc->init_cmds.reply) {
+ retval = mpi3mr_alloc_reply_sense_bufs(mrioc);
+ if (retval) {
+ ioc_err(mrioc,
+ "%s :Failed to allocated reply sense buffers %d\n",
+ __func__, retval);
+ goto out_failed_noretry;
+ }
}
- retval = mpi3mr_alloc_chain_bufs(mrioc);
- if (retval) {
- ioc_err(mrioc, "Failed to allocated chain buffers %d\n",
- retval);
- goto out_failed_noretry;
+ if (!mrioc->chain_sgl_list) {
+ retval = mpi3mr_alloc_chain_bufs(mrioc);
+ if (retval) {
+ ioc_err(mrioc, "Failed to allocated chain buffers %d\n",
+ retval);
+ goto out_failed_noretry;
+ }
}
retval = mpi3mr_issue_iocinit(mrioc);
--
2.39.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v2 6/6] scsi: mpi3mr: fix a memory leak
2023-03-02 23:43 [PATCH v2 0/6] scsi: mpi3mr: fix few resource leaks Tomas Henzl
` (4 preceding siblings ...)
2023-03-02 23:43 ` [PATCH v2 5/6] " Tomas Henzl
@ 2023-03-02 23:43 ` Tomas Henzl
2023-03-07 1:43 ` [PATCH v2 0/6] scsi: mpi3mr: fix few resource leaks Martin K. Petersen
2023-03-10 3:13 ` Martin K. Petersen
7 siblings, 0 replies; 10+ messages in thread
From: Tomas Henzl @ 2023-03-02 23:43 UTC (permalink / raw)
To: linux-scsi; +Cc: sreekanth.reddy, sathya.prakash, ranjan.kumar
Add a missing resource clean up in .remove.
Fixes: e22bae30667a ("scsi: mpi3mr: Add expander devices to STL")
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
---
drivers/scsi/mpi3mr/mpi3mr.h | 2 ++
drivers/scsi/mpi3mr/mpi3mr_os.c | 7 +++++++
drivers/scsi/mpi3mr/mpi3mr_transport.c | 5 +----
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h
index e6a9c81bba33..c5347a004cd5 100644
--- a/drivers/scsi/mpi3mr/mpi3mr.h
+++ b/drivers/scsi/mpi3mr/mpi3mr.h
@@ -1407,4 +1407,6 @@ void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc);
void mpi3mr_flush_cmds_for_unrecovered_controller(struct mpi3mr_ioc *mrioc);
void mpi3mr_free_enclosure_list(struct mpi3mr_ioc *mrioc);
int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc);
+void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
+ struct mpi3mr_sas_node *sas_expander);
#endif /*MPI3MR_H_INCLUDED*/
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index 8f17a7953eb4..b329e1ee46dc 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -5113,6 +5113,7 @@ static void mpi3mr_remove(struct pci_dev *pdev)
unsigned long flags;
struct mpi3mr_tgt_dev *tgtdev, *tgtdev_next;
struct mpi3mr_hba_port *port, *hba_port_next;
+ struct mpi3mr_sas_node *sas_expander, *sas_expander_next;
if (!shost)
return;
@@ -5153,6 +5154,12 @@ static void mpi3mr_remove(struct pci_dev *pdev)
mpi3mr_cleanup_resources(mrioc);
spin_lock_irqsave(&mrioc->sas_node_lock, flags);
+ list_for_each_entry_safe_reverse(sas_expander, sas_expander_next,
+ &mrioc->sas_expander_list, list) {
+ spin_unlock_irqrestore(&mrioc->sas_node_lock, flags);
+ mpi3mr_expander_node_remove(mrioc, sas_expander);
+ spin_lock_irqsave(&mrioc->sas_node_lock, flags);
+ }
list_for_each_entry_safe(port, hba_port_next, &mrioc->hba_port_table_list, list) {
ioc_info(mrioc,
"removing hba_port entry: %p port: %d from hba_port list\n",
diff --git a/drivers/scsi/mpi3mr/mpi3mr_transport.c b/drivers/scsi/mpi3mr/mpi3mr_transport.c
index 121fae310692..4d84d5bd173f 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_transport.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_transport.c
@@ -9,9 +9,6 @@
#include "mpi3mr.h"
-static void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
- struct mpi3mr_sas_node *sas_expander);
-
/**
* mpi3mr_post_transport_req - Issue transport requests and wait
* @mrioc: Adapter instance reference
@@ -2164,7 +2161,7 @@ int mpi3mr_expander_add(struct mpi3mr_ioc *mrioc, u16 handle)
*
* Return nothing.
*/
-static void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
+void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
struct mpi3mr_sas_node *sas_expander)
{
struct mpi3mr_sas_port *mr_sas_port, *next;
--
2.39.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v2 0/6] scsi: mpi3mr: fix few resource leaks
2023-03-02 23:43 [PATCH v2 0/6] scsi: mpi3mr: fix few resource leaks Tomas Henzl
` (5 preceding siblings ...)
2023-03-02 23:43 ` [PATCH v2 6/6] " Tomas Henzl
@ 2023-03-07 1:43 ` Martin K. Petersen
2023-03-07 20:14 ` Sathya Prakash Veerichetty
2023-03-10 3:13 ` Martin K. Petersen
7 siblings, 1 reply; 10+ messages in thread
From: Martin K. Petersen @ 2023-03-07 1:43 UTC (permalink / raw)
To: Ranjan Kumar, Sreekanth Reddy; +Cc: Tomas Henzl, linux-scsi, sathya.prakash
Ranjan/Sreekanth,
> The series applies on
> [PATCH 00/15] mpi3mr: Few Enhancements and minor fixes
> from 2/24 posted by Ranjan.
>
> V2 - fixed a bug in [PATCH 5/6]
>
>
> drivers/scsi/mpi3mr/mpi3mr.h | 2 ++
> drivers/scsi/mpi3mr/mpi3mr_fw.c | 50 ++++++++++++++++----------
> drivers/scsi/mpi3mr/mpi3mr_os.c | 24 +++++++++++++
> drivers/scsi/mpi3mr/mpi3mr_transport.c | 5 +--
> 4 files changed, 58 insertions(+), 23 deletions(-)
Please review!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v2 0/6] scsi: mpi3mr: fix few resource leaks
2023-03-07 1:43 ` [PATCH v2 0/6] scsi: mpi3mr: fix few resource leaks Martin K. Petersen
@ 2023-03-07 20:14 ` Sathya Prakash Veerichetty
0 siblings, 0 replies; 10+ messages in thread
From: Sathya Prakash Veerichetty @ 2023-03-07 20:14 UTC (permalink / raw)
To: Martin K. Petersen; +Cc: Ranjan Kumar, Sreekanth Reddy, Tomas Henzl, linux-scsi
[-- Attachment #1: Type: text/plain, Size: 1537 bytes --]
V2 looks good, please add this set into 6.3 scsi-fixes.
On Mon, Mar 6, 2023 at 6:43 PM Martin K. Petersen
<martin.petersen@oracle.com> wrote:
>
>
> Ranjan/Sreekanth,
>
> > The series applies on
> > [PATCH 00/15] mpi3mr: Few Enhancements and minor fixes
> > from 2/24 posted by Ranjan.
> >
> > V2 - fixed a bug in [PATCH 5/6]
> >
> >
> > drivers/scsi/mpi3mr/mpi3mr.h | 2 ++
> > drivers/scsi/mpi3mr/mpi3mr_fw.c | 50 ++++++++++++++++----------
> > drivers/scsi/mpi3mr/mpi3mr_os.c | 24 +++++++++++++
> > drivers/scsi/mpi3mr/mpi3mr_transport.c | 5 +--
> > 4 files changed, 58 insertions(+), 23 deletions(-)
>
> Please review!
>
> --
> Martin K. Petersen Oracle Linux Engineering
--
This electronic communication and the information and any files transmitted
with it, or attached to it, are confidential and are intended solely for
the use of the individual or entity to whom it is addressed and may contain
information that is confidential, legally privileged, protected by privacy
laws, or otherwise restricted from disclosure to anyone else. If you are
not the intended recipient or the person responsible for delivering the
e-mail to the intended recipient, you are hereby notified that any use,
copying, distributing, dissemination, forwarding, printing, or copying of
this e-mail is strictly prohibited. If you received this e-mail in error,
please return the e-mail to the sender, delete it from your computer, and
destroy any printed copy of it.
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4227 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/6] scsi: mpi3mr: fix few resource leaks
2023-03-02 23:43 [PATCH v2 0/6] scsi: mpi3mr: fix few resource leaks Tomas Henzl
` (6 preceding siblings ...)
2023-03-07 1:43 ` [PATCH v2 0/6] scsi: mpi3mr: fix few resource leaks Martin K. Petersen
@ 2023-03-10 3:13 ` Martin K. Petersen
7 siblings, 0 replies; 10+ messages in thread
From: Martin K. Petersen @ 2023-03-10 3:13 UTC (permalink / raw)
To: Tomas Henzl; +Cc: linux-scsi, sreekanth.reddy, sathya.prakash, ranjan.kumar
Tomas,
> The series applies on
> [PATCH 00/15] mpi3mr: Few Enhancements and minor fixes
> from 2/24 posted by Ranjan.
Applied to 6.3/scsi-fixes, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 10+ messages in thread