From: Chaitra P B <chaitra.basappa@broadcom.com>
To: linux-scsi@vger.kernel.org, stable@vger.kernel.org
Cc: suganath-prabu.subramani@broadcom.com,
Sathya.Prakash@broadcom.com, sreekanth.reddy@broadcom.com,
Chaitra P B <chaitra.basappa@broadcom.com>
Subject: [PATCH 06/15] mpt3sas: Enhanced handling of Sense Buffer.
Date: Fri, 30 Mar 2018 15:07:15 +0530 [thread overview]
Message-ID: <1522402644-3016-7-git-send-email-chaitra.basappa@broadcom.com> (raw)
In-Reply-To: <1522402644-3016-1-git-send-email-chaitra.basappa@broadcom.com>
Enhanced DMA allocation for Sense Buffer, if the allocation does not fit
within same 4GB.Introduced is_MSB_are_same function to check if allocted
buffer within 4GB range or not.
Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
---
drivers/scsi/mpt3sas/mpt3sas_base.c | 57 +++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 701e1e7..7f3b684 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -4205,6 +4205,32 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)
}
/**
+ * is_MSB_are_same - checks whether all reply queues in a set are
+ * having same upper 32bits in their base memory address.
+ * @reply_pool_start_address: Base address of a reply queue set
+ * @pool_sz: Size of single Reply Descriptor Post Queues pool size
+ *
+ * Returns 1 if reply queues in a set have a same upper 32bits
+ * in their base memory address,
+ * else 0
+ */
+
+static int
+is_MSB_are_same(long reply_pool_start_address, u32 pool_sz)
+{
+ long reply_pool_end_address;
+ unsigned long bit_divisor_16 = 0x10000;
+
+ reply_pool_end_address = reply_pool_start_address + pool_sz;
+
+ if (((reply_pool_start_address / bit_divisor_16) / (bit_divisor_16)) ==
+ ((reply_pool_end_address / bit_divisor_16) / bit_divisor_16))
+ return 1;
+ else
+ return 0;
+}
+
+/**
* _base_allocate_memory_pools - allocate start of day memory pools
* @ioc: per adapter object
*
@@ -4664,6 +4690,37 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc)
ioc->name);
goto out;
}
+ /* sense buffer requires to be in same 4 gb region.
+ * Below function will check the same.
+ * In case of failure, new pci pool will be created with updated
+ * alignment. Older allocation and pool will be destroyed.
+ * Alignment will be used such a way that next allocation if
+ * success, will always meet same 4gb region requirement.
+ * Actual requirement is not alignment, but we need start and end of
+ * DMA address must have same upper 32 bit address.
+ */
+ if (!is_MSB_are_same((long)ioc->sense, sz)) {
+ //Release Sense pool & Reallocate
+ dma_pool_free(ioc->sense_dma_pool, ioc->sense, ioc->sense_dma);
+ dma_pool_destroy(ioc->sense_dma_pool);
+ ioc->sense = NULL;
+
+ ioc->sense_dma_pool =
+ dma_pool_create("sense pool", &ioc->pdev->dev, sz,
+ roundup_pow_of_two(sz), 0);
+ if (!ioc->sense_dma_pool) {
+ pr_err(MPT3SAS_FMT "sense pool: pci_pool_create failed\n",
+ ioc->name);
+ goto out;
+ }
+ ioc->sense = dma_pool_alloc(ioc->sense_dma_pool, GFP_KERNEL,
+ &ioc->sense_dma);
+ if (!ioc->sense) {
+ pr_err(MPT3SAS_FMT "sense pool: pci_pool_alloc failed\n",
+ ioc->name);
+ goto out;
+ }
+ }
dinitprintk(ioc, pr_info(MPT3SAS_FMT
"sense pool(0x%p): depth(%d), element_size(%d), pool_size"
"(%d kB)\n", ioc->name, ioc->sense, ioc->scsiio_depth,
--
1.8.3.1
next prev parent reply other threads:[~2018-03-30 9:39 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-30 9:37 [PATCH 00/15] mpt3sas: Enhancements and Defect fixes Chaitra P B
2018-03-30 9:37 ` [PATCH 01/15] mpt3sas: Fixed warnings Chaitra P B
2018-03-30 9:37 ` [PATCH 02/15] mpt3sas: Pre-allocate RDPQ Array at driver boot time Chaitra P B
2018-03-30 9:37 ` [PATCH 03/15] mpt3sas: Add sanity checks for scsi tracker before accessing it Chaitra P B
2018-03-30 11:59 ` Christoph Hellwig
2018-04-02 6:23 ` Sreekanth Reddy
2018-04-02 15:25 ` Bart Van Assche
2018-04-03 4:41 ` Sreekanth Reddy
2018-04-03 15:56 ` Bart Van Assche
2018-04-04 12:28 ` Sreekanth Reddy
2018-03-30 15:54 ` Bart Van Assche
2018-03-30 9:37 ` [PATCH 04/15] mpt3sas: Lockless access for chain buffers Chaitra P B
2018-03-30 9:37 ` [PATCH 05/15] mpt3sas: Optimize I/O memory consumption in driver Chaitra P B
2018-03-30 9:37 ` Chaitra P B [this message]
2018-03-30 9:37 ` [PATCH 07/15] mpt3sas: Added support for SAS Device Discovery Error Event Chaitra P B
2018-03-30 9:37 ` [PATCH 08/15] mpt3sas: Increase event log buffer to support 24 port HBA's Chaitra P B
2018-03-30 9:37 ` [PATCH 09/15] mpt3sas: Allow processing of events during driver unload Chaitra P B
2018-03-30 9:37 ` [PATCH 10/15] mpt3sas: Cache enclosure pages during enclosure add Chaitra P B
2018-03-30 9:37 ` [PATCH 11/15] mpt3sas: Report Firmware Package Version from HBA Driver Chaitra P B
2018-03-31 8:44 ` kbuild test robot
2018-03-30 9:37 ` [PATCH 12/15] mpt3sas: Update MPI Headers Chaitra P B
2018-03-30 9:37 ` [PATCH 13/15] mpt3sas: For NVME device, issue a protocol level reset instead of hot reset and use TM timeout value exposed in PCIe Device Page 2 Chaitra P B
2018-03-30 9:37 ` [PATCH 14/15] mpt3sas: fix possible memory leak Chaitra P B
2018-03-30 9:37 ` [PATCH 15/15] mpt3sas: Update driver version "25.100.00.00" Chaitra P B
2018-03-30 9:58 ` [PATCH 00/15] mpt3sas: Enhancements and Defect fixes Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1522402644-3016-7-git-send-email-chaitra.basappa@broadcom.com \
--to=chaitra.basappa@broadcom.com \
--cc=Sathya.Prakash@broadcom.com \
--cc=linux-scsi@vger.kernel.org \
--cc=sreekanth.reddy@broadcom.com \
--cc=stable@vger.kernel.org \
--cc=suganath-prabu.subramani@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox