diff mbox series

mpt3sas: fix ReplyPostFree pool allocation

Message ID 20210201141522.25363-1-sreekanth.reddy@broadcom.com
State New
Headers show
Series mpt3sas: fix ReplyPostFree pool allocation | expand

Commit Message

Sreekanth Reddy Feb. 1, 2021, 2:15 p.m. UTC
Currently driver allocate memory for ReplyPostFree queues in
chunks of 16 ReplyPostFree queue count.
On less resource environment such as VM with 1GB and two CPUs,
memory allocation for ReplyPostFree pools may fail, since
driver tries to allocate a memory for 16 ReplyPostFree queue count
even though the actual number of ReplyPostFree queue used is two.
Now, the driver will allocate memory for only the actual number of
ReplyPostFree queues instead for 16 queues if the ReplyPostFree
queue count is less than 16.

Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Martin K. Petersen Feb. 9, 2021, 2:20 a.m. UTC | #1
Sreekanth,

> Currently driver allocate memory for ReplyPostFree queues in chunks of

> 16 ReplyPostFree queue count.  On less resource environment such as VM

> with 1GB and two CPUs, memory allocation for ReplyPostFree pools may

> fail, since driver tries to allocate a memory for 16 ReplyPostFree

> queue count even though the actual number of ReplyPostFree queue used

> is two.  Now, the driver will allocate memory for only the actual

> number of ReplyPostFree queues instead for 16 queues if the

> ReplyPostFree queue count is less than 16.


Applied to 5.12/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering
diff mbox series

Patch

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index f5582c8..e2455b9 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -5641,7 +5641,8 @@  _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc)
 	reply_post_free_sz = ioc->reply_post_queue_depth *
 	    sizeof(Mpi2DefaultReplyDescriptor_t);
 	rdpq_sz = reply_post_free_sz * RDPQ_MAX_INDEX_IN_ONE_CHUNK;
-	if (_base_is_controller_msix_enabled(ioc) && !ioc->rdpq_array_enable)
+	if ((_base_is_controller_msix_enabled(ioc) && !ioc->rdpq_array_enable)
+	    || (ioc->reply_queue_count < RDPQ_MAX_INDEX_IN_ONE_CHUNK))
 		rdpq_sz = reply_post_free_sz * ioc->reply_queue_count;
 	ret = base_alloc_rdpq_dma_pool(ioc, rdpq_sz);
 	if (ret == -EAGAIN) {