drivers/scsi/mpt3sas/mpt3sas_base.c:5025:16-34: WARNING: dma_alloc_coherent use in ioc -> request already zeroes out memory, so memset is not needed (fwd)

From: Julia Lawall
Date: Tue Jul 07 2020 - 06:44:36 EST


Hello,

Please lines 5025 and 5038.

julia

---------- Forwarded message ----------
Date: Tue, 7 Jul 2020 04:54:19 +0800
From: kernel test robot <lkp@xxxxxxxxx>
To: kbuild@xxxxxxxxxxxx
Cc: lkp@xxxxxxxxx, Julia Lawall <julia.lawall@xxxxxxx>
Subject: drivers/scsi/mpt3sas/mpt3sas_base.c:5025:16-34: WARNING:
dma_alloc_coherent use in ioc -> request already zeroes out memory,
so memset is not needed

CC: kbuild-all@xxxxxxxxxxxx
CC: linux-kernel@xxxxxxxxxxxxxxx
TO: Suganath Prabu <suganath-prabu.subramani@xxxxxxxxxxxx>
CC: "Martin K. Petersen" <martin.petersen@xxxxxxxxxx>

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 5c82ec00dd00c7a2b02d4b42cf59ae87592cb75f
commit: e224e03b0c6a2381ed1ea5325c846582d87d6fae scsi: mpt3sas: memset request frame before reusing
date: 11 months ago
:::::: branch date: 4 hours ago
:::::: commit date: 11 months ago
config: ia64-randconfig-c024-20200706 (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Julia Lawall <julia.lawall@xxxxxxx>


coccinelle warnings: (new ones prefixed by >>)

>> drivers/scsi/mpt3sas/mpt3sas_base.c:5025:16-34: WARNING: dma_alloc_coherent use in ioc -> request already zeroes out memory, so memset is not needed

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e224e03b0c6a2381ed1ea5325c846582d87d6fae
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git remote update linus
git checkout e224e03b0c6a2381ed1ea5325c846582d87d6fae
vim +5025 drivers/scsi/mpt3sas/mpt3sas_base.c

e21fef6f331b39 Chaitra P B 2018-04-24 4781
f92363d1235949 Sreekanth Reddy 2012-11-30 4782 /**
f92363d1235949 Sreekanth Reddy 2012-11-30 4783 * _base_allocate_memory_pools - allocate start of day memory pools
f92363d1235949 Sreekanth Reddy 2012-11-30 4784 * @ioc: per adapter object
f92363d1235949 Sreekanth Reddy 2012-11-30 4785 *
4beb4867f049ae Bart Van Assche 2018-06-15 4786 * Return: 0 success, anything else error.
f92363d1235949 Sreekanth Reddy 2012-11-30 4787 */
f92363d1235949 Sreekanth Reddy 2012-11-30 4788 static int
98c56ad32c33f0 Calvin Owens 2016-07-28 4789 _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc)
f92363d1235949 Sreekanth Reddy 2012-11-30 4790 {
f92363d1235949 Sreekanth Reddy 2012-11-30 4791 struct mpt3sas_facts *facts;
f92363d1235949 Sreekanth Reddy 2012-11-30 4792 u16 max_sge_elements;
f92363d1235949 Sreekanth Reddy 2012-11-30 4793 u16 chains_needed_per_io;
cd33223b59a493 Chaitra P B 2018-04-24 4794 u32 sz, total_sz, reply_post_free_sz, reply_post_free_array_sz;
f92363d1235949 Sreekanth Reddy 2012-11-30 4795 u32 retry_sz;
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 4796 u16 max_request_credit, nvme_blocks_needed;
f92363d1235949 Sreekanth Reddy 2012-11-30 4797 unsigned short sg_tablesize;
f92363d1235949 Sreekanth Reddy 2012-11-30 4798 u16 sge_size;
93204b782a88f2 Chaitra P B 2018-04-24 4799 int i, j;
93204b782a88f2 Chaitra P B 2018-04-24 4800 struct chain_tracker *ct;
f92363d1235949 Sreekanth Reddy 2012-11-30 4801
919d8a3f3fef99 Joe Perches 2018-09-17 4802 dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
f92363d1235949 Sreekanth Reddy 2012-11-30 4803
f92363d1235949 Sreekanth Reddy 2012-11-30 4804
f92363d1235949 Sreekanth Reddy 2012-11-30 4805 retry_sz = 0;
f92363d1235949 Sreekanth Reddy 2012-11-30 4806 facts = &ioc->facts;
f92363d1235949 Sreekanth Reddy 2012-11-30 4807
f92363d1235949 Sreekanth Reddy 2012-11-30 4808 /* command line tunables for max sgl entries */
f92363d1235949 Sreekanth Reddy 2012-11-30 4809 if (max_sgl_entries != -1)
f92363d1235949 Sreekanth Reddy 2012-11-30 4810 sg_tablesize = max_sgl_entries;
471ef9d4e49825 Sreekanth Reddy 2015-11-11 4811 else {
471ef9d4e49825 Sreekanth Reddy 2015-11-11 4812 if (ioc->hba_mpi_version_belonged == MPI2_VERSION)
471ef9d4e49825 Sreekanth Reddy 2015-11-11 4813 sg_tablesize = MPT2SAS_SG_DEPTH;
f92363d1235949 Sreekanth Reddy 2012-11-30 4814 else
f92363d1235949 Sreekanth Reddy 2012-11-30 4815 sg_tablesize = MPT3SAS_SG_DEPTH;
471ef9d4e49825 Sreekanth Reddy 2015-11-11 4816 }
f92363d1235949 Sreekanth Reddy 2012-11-30 4817
06f5f976a6ee0f Sreekanth Reddy 2017-10-10 4818 /* max sgl entries <= MPT_KDUMP_MIN_PHYS_SEGMENTS in KDUMP mode */
06f5f976a6ee0f Sreekanth Reddy 2017-10-10 4819 if (reset_devices)
06f5f976a6ee0f Sreekanth Reddy 2017-10-10 4820 sg_tablesize = min_t(unsigned short, sg_tablesize,
06f5f976a6ee0f Sreekanth Reddy 2017-10-10 4821 MPT_KDUMP_MIN_PHYS_SEGMENTS);
06f5f976a6ee0f Sreekanth Reddy 2017-10-10 4822
0448f0195124e3 Suganath Prabu Subramani 2018-02-07 4823 if (ioc->is_mcpu_endpoint)
0448f0195124e3 Suganath Prabu Subramani 2018-02-07 4824 ioc->shost->sg_tablesize = MPT_MIN_PHYS_SEGMENTS;
0448f0195124e3 Suganath Prabu Subramani 2018-02-07 4825 else {
8a7e4c24e08fce Sreekanth Reddy 2015-11-11 4826 if (sg_tablesize < MPT_MIN_PHYS_SEGMENTS)
8a7e4c24e08fce Sreekanth Reddy 2015-11-11 4827 sg_tablesize = MPT_MIN_PHYS_SEGMENTS;
8a7e4c24e08fce Sreekanth Reddy 2015-11-11 4828 else if (sg_tablesize > MPT_MAX_PHYS_SEGMENTS) {
ad666a0f41d98e Sreekanth Reddy 2015-01-12 4829 sg_tablesize = min_t(unsigned short, sg_tablesize,
65e8617fba1773 Ming Lin 2016-04-04 4830 SG_MAX_SEGMENTS);
919d8a3f3fef99 Joe Perches 2018-09-17 4831 ioc_warn(ioc, "sg_tablesize(%u) is bigger than kernel defined SG_CHUNK_SIZE(%u)\n",
8a7e4c24e08fce Sreekanth Reddy 2015-11-11 4832 sg_tablesize, MPT_MAX_PHYS_SEGMENTS);
ad666a0f41d98e Sreekanth Reddy 2015-01-12 4833 }
f92363d1235949 Sreekanth Reddy 2012-11-30 4834 ioc->shost->sg_tablesize = sg_tablesize;
0448f0195124e3 Suganath Prabu Subramani 2018-02-07 4835 }
f92363d1235949 Sreekanth Reddy 2012-11-30 4836
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4837 ioc->internal_depth = min_t(int, (facts->HighPriorityCredit + (5)),
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4838 (facts->RequestCredit / 4));
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4839 if (ioc->internal_depth < INTERNAL_CMDS_COUNT) {
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4840 if (facts->RequestCredit <= (INTERNAL_CMDS_COUNT +
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4841 INTERNAL_SCSIIO_CMDS_COUNT)) {
919d8a3f3fef99 Joe Perches 2018-09-17 4842 ioc_err(ioc, "IOC doesn't have enough Request Credits, it has just %d number of credits\n",
919d8a3f3fef99 Joe Perches 2018-09-17 4843 facts->RequestCredit);
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4844 return -ENOMEM;
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4845 }
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4846 ioc->internal_depth = 10;
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4847 }
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4848
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4849 ioc->hi_priority_depth = ioc->internal_depth - (5);
f92363d1235949 Sreekanth Reddy 2012-11-30 4850 /* command line tunables for max controller queue depth */
f92363d1235949 Sreekanth Reddy 2012-11-30 4851 if (max_queue_depth != -1 && max_queue_depth != 0) {
f92363d1235949 Sreekanth Reddy 2012-11-30 4852 max_request_credit = min_t(u16, max_queue_depth +
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4853 ioc->internal_depth, facts->RequestCredit);
f92363d1235949 Sreekanth Reddy 2012-11-30 4854 if (max_request_credit > MAX_HBA_QUEUE_DEPTH)
f92363d1235949 Sreekanth Reddy 2012-11-30 4855 max_request_credit = MAX_HBA_QUEUE_DEPTH;
06f5f976a6ee0f Sreekanth Reddy 2017-10-10 4856 } else if (reset_devices)
06f5f976a6ee0f Sreekanth Reddy 2017-10-10 4857 max_request_credit = min_t(u16, facts->RequestCredit,
06f5f976a6ee0f Sreekanth Reddy 2017-10-10 4858 (MPT3SAS_KDUMP_SCSI_IO_DEPTH + ioc->internal_depth));
06f5f976a6ee0f Sreekanth Reddy 2017-10-10 4859 else
f92363d1235949 Sreekanth Reddy 2012-11-30 4860 max_request_credit = min_t(u16, facts->RequestCredit,
f92363d1235949 Sreekanth Reddy 2012-11-30 4861 MAX_HBA_QUEUE_DEPTH);
f92363d1235949 Sreekanth Reddy 2012-11-30 4862
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4863 /* Firmware maintains additional facts->HighPriorityCredit number of
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4864 * credits for HiPriprity Request messages, so hba queue depth will be
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4865 * sum of max_request_credit and high priority queue depth.
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4866 */
fd0331b32826dd Suganath prabu Subramani 2016-01-28 4867 ioc->hba_queue_depth = max_request_credit + ioc->hi_priority_depth;
f92363d1235949 Sreekanth Reddy 2012-11-30 4868
f92363d1235949 Sreekanth Reddy 2012-11-30 4869 /* request frame size */
f92363d1235949 Sreekanth Reddy 2012-11-30 4870 ioc->request_sz = facts->IOCRequestFrameSize * 4;
f92363d1235949 Sreekanth Reddy 2012-11-30 4871
f92363d1235949 Sreekanth Reddy 2012-11-30 4872 /* reply frame size */
f92363d1235949 Sreekanth Reddy 2012-11-30 4873 ioc->reply_sz = facts->ReplyFrameSize * 4;
f92363d1235949 Sreekanth Reddy 2012-11-30 4874
ebb3024e2fd557 Suganath prabu Subramani 2016-01-28 4875 /* chain segment size */
ebb3024e2fd557 Suganath prabu Subramani 2016-01-28 4876 if (ioc->hba_mpi_version_belonged != MPI2_VERSION) {
ebb3024e2fd557 Suganath prabu Subramani 2016-01-28 4877 if (facts->IOCMaxChainSegmentSize)
ebb3024e2fd557 Suganath prabu Subramani 2016-01-28 4878 ioc->chain_segment_sz =
ebb3024e2fd557 Suganath prabu Subramani 2016-01-28 4879 facts->IOCMaxChainSegmentSize *
ebb3024e2fd557 Suganath prabu Subramani 2016-01-28 4880 MAX_CHAIN_ELEMT_SZ;
ebb3024e2fd557 Suganath prabu Subramani 2016-01-28 4881 else
ebb3024e2fd557 Suganath prabu Subramani 2016-01-28 4882 /* set to 128 bytes size if IOCMaxChainSegmentSize is zero */
ebb3024e2fd557 Suganath prabu Subramani 2016-01-28 4883 ioc->chain_segment_sz = DEFAULT_NUM_FWCHAIN_ELEMTS *
ebb3024e2fd557 Suganath prabu Subramani 2016-01-28 4884 MAX_CHAIN_ELEMT_SZ;
ebb3024e2fd557 Suganath prabu Subramani 2016-01-28 4885 } else
ebb3024e2fd557 Suganath prabu Subramani 2016-01-28 4886 ioc->chain_segment_sz = ioc->request_sz;
ebb3024e2fd557 Suganath prabu Subramani 2016-01-28 4887
f92363d1235949 Sreekanth Reddy 2012-11-30 4888 /* calculate the max scatter element size */
f92363d1235949 Sreekanth Reddy 2012-11-30 4889 sge_size = max_t(u16, ioc->sge_size, ioc->sge_size_ieee);
f92363d1235949 Sreekanth Reddy 2012-11-30 4890
f92363d1235949 Sreekanth Reddy 2012-11-30 4891 retry_allocation:
f92363d1235949 Sreekanth Reddy 2012-11-30 4892 total_sz = 0;
f92363d1235949 Sreekanth Reddy 2012-11-30 4893 /* calculate number of sg elements left over in the 1st frame */
f92363d1235949 Sreekanth Reddy 2012-11-30 4894 max_sge_elements = ioc->request_sz - ((sizeof(Mpi2SCSIIORequest_t) -
f92363d1235949 Sreekanth Reddy 2012-11-30 4895 sizeof(Mpi2SGEIOUnion_t)) + sge_size);
f92363d1235949 Sreekanth Reddy 2012-11-30 4896 ioc->max_sges_in_main_message = max_sge_elements/sge_size;
f92363d1235949 Sreekanth Reddy 2012-11-30 4897
f92363d1235949 Sreekanth Reddy 2012-11-30 4898 /* now do the same for a chain buffer */
ebb3024e2fd557 Suganath prabu Subramani 2016-01-28 4899 max_sge_elements = ioc->chain_segment_sz - sge_size;
f92363d1235949 Sreekanth Reddy 2012-11-30 4900 ioc->max_sges_in_chain_message = max_sge_elements/sge_size;
f92363d1235949 Sreekanth Reddy 2012-11-30 4901
f92363d1235949 Sreekanth Reddy 2012-11-30 4902 /*
f92363d1235949 Sreekanth Reddy 2012-11-30 4903 * MPT3SAS_SG_DEPTH = CONFIG_FUSION_MAX_SGE
f92363d1235949 Sreekanth Reddy 2012-11-30 4904 */
f92363d1235949 Sreekanth Reddy 2012-11-30 4905 chains_needed_per_io = ((ioc->shost->sg_tablesize -
f92363d1235949 Sreekanth Reddy 2012-11-30 4906 ioc->max_sges_in_main_message)/ioc->max_sges_in_chain_message)
f92363d1235949 Sreekanth Reddy 2012-11-30 4907 + 1;
f92363d1235949 Sreekanth Reddy 2012-11-30 4908 if (chains_needed_per_io > facts->MaxChainDepth) {
f92363d1235949 Sreekanth Reddy 2012-11-30 4909 chains_needed_per_io = facts->MaxChainDepth;
f92363d1235949 Sreekanth Reddy 2012-11-30 4910 ioc->shost->sg_tablesize = min_t(u16,
f92363d1235949 Sreekanth Reddy 2012-11-30 4911 ioc->max_sges_in_main_message + (ioc->max_sges_in_chain_message
f92363d1235949 Sreekanth Reddy 2012-11-30 4912 * chains_needed_per_io), ioc->shost->sg_tablesize);
f92363d1235949 Sreekanth Reddy 2012-11-30 4913 }
f92363d1235949 Sreekanth Reddy 2012-11-30 4914 ioc->chains_needed_per_io = chains_needed_per_io;
f92363d1235949 Sreekanth Reddy 2012-11-30 4915
f92363d1235949 Sreekanth Reddy 2012-11-30 4916 /* reply free queue sizing - taking into account for 64 FW events */
f92363d1235949 Sreekanth Reddy 2012-11-30 4917 ioc->reply_free_queue_depth = ioc->hba_queue_depth + 64;
f92363d1235949 Sreekanth Reddy 2012-11-30 4918
0448f0195124e3 Suganath Prabu Subramani 2018-02-07 4919 /* mCPU manage single counters for simplicity */
0448f0195124e3 Suganath Prabu Subramani 2018-02-07 4920 if (ioc->is_mcpu_endpoint)
0448f0195124e3 Suganath Prabu Subramani 2018-02-07 4921 ioc->reply_post_queue_depth = ioc->reply_free_queue_depth;
0448f0195124e3 Suganath Prabu Subramani 2018-02-07 4922 else {
f92363d1235949 Sreekanth Reddy 2012-11-30 4923 /* calculate reply descriptor post queue depth */
f92363d1235949 Sreekanth Reddy 2012-11-30 4924 ioc->reply_post_queue_depth = ioc->hba_queue_depth +
f92363d1235949 Sreekanth Reddy 2012-11-30 4925 ioc->reply_free_queue_depth + 1;
f92363d1235949 Sreekanth Reddy 2012-11-30 4926 /* align the reply post queue on the next 16 count boundary */
f92363d1235949 Sreekanth Reddy 2012-11-30 4927 if (ioc->reply_post_queue_depth % 16)
f92363d1235949 Sreekanth Reddy 2012-11-30 4928 ioc->reply_post_queue_depth += 16 -
f92363d1235949 Sreekanth Reddy 2012-11-30 4929 (ioc->reply_post_queue_depth % 16);
0448f0195124e3 Suganath Prabu Subramani 2018-02-07 4930 }
f92363d1235949 Sreekanth Reddy 2012-11-30 4931
f92363d1235949 Sreekanth Reddy 2012-11-30 4932 if (ioc->reply_post_queue_depth >
f92363d1235949 Sreekanth Reddy 2012-11-30 4933 facts->MaxReplyDescriptorPostQueueDepth) {
f92363d1235949 Sreekanth Reddy 2012-11-30 4934 ioc->reply_post_queue_depth =
f92363d1235949 Sreekanth Reddy 2012-11-30 4935 facts->MaxReplyDescriptorPostQueueDepth -
f92363d1235949 Sreekanth Reddy 2012-11-30 4936 (facts->MaxReplyDescriptorPostQueueDepth % 16);
f92363d1235949 Sreekanth Reddy 2012-11-30 4937 ioc->hba_queue_depth =
f92363d1235949 Sreekanth Reddy 2012-11-30 4938 ((ioc->reply_post_queue_depth - 64) / 2) - 1;
f92363d1235949 Sreekanth Reddy 2012-11-30 4939 ioc->reply_free_queue_depth = ioc->hba_queue_depth + 64;
f92363d1235949 Sreekanth Reddy 2012-11-30 4940 }
f92363d1235949 Sreekanth Reddy 2012-11-30 4941
919d8a3f3fef99 Joe Perches 2018-09-17 4942 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 4943 ioc_info(ioc, "scatter gather: sge_in_main_msg(%d), sge_per_chain(%d), sge_per_io(%d), chains_per_io(%d)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 4944 ioc->max_sges_in_main_message,
919d8a3f3fef99 Joe Perches 2018-09-17 4945 ioc->max_sges_in_chain_message,
919d8a3f3fef99 Joe Perches 2018-09-17 4946 ioc->shost->sg_tablesize,
f92363d1235949 Sreekanth Reddy 2012-11-30 4947 ioc->chains_needed_per_io));
f92363d1235949 Sreekanth Reddy 2012-11-30 4948
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4949 /* reply post queue, 16 byte align */
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4950 reply_post_free_sz = ioc->reply_post_queue_depth *
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4951 sizeof(Mpi2DefaultReplyDescriptor_t);
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4952
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4953 sz = reply_post_free_sz;
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4954 if (_base_is_controller_msix_enabled(ioc) && !ioc->rdpq_array_enable)
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4955 sz *= ioc->reply_queue_count;
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4956
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4957 ioc->reply_post = kcalloc((ioc->rdpq_array_enable) ?
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4958 (ioc->reply_queue_count):1,
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4959 sizeof(struct reply_post_struct), GFP_KERNEL);
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4960
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4961 if (!ioc->reply_post) {
919d8a3f3fef99 Joe Perches 2018-09-17 4962 ioc_err(ioc, "reply_post_free pool: kcalloc failed\n");
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4963 goto out;
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4964 }
e9d984182ab8e4 Romain Perier 2017-07-06 4965 ioc->reply_post_free_dma_pool = dma_pool_create("reply_post_free pool",
e9d984182ab8e4 Romain Perier 2017-07-06 4966 &ioc->pdev->dev, sz, 16, 0);
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4967 if (!ioc->reply_post_free_dma_pool) {
919d8a3f3fef99 Joe Perches 2018-09-17 4968 ioc_err(ioc, "reply_post_free pool: dma_pool_create failed\n");
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4969 goto out;
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4970 }
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4971 i = 0;
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4972 do {
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4973 ioc->reply_post[i].reply_post_free =
c39a4d75539393 Souptick Joarder 2018-10-02 4974 dma_pool_zalloc(ioc->reply_post_free_dma_pool,
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4975 GFP_KERNEL,
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4976 &ioc->reply_post[i].reply_post_free_dma);
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4977 if (!ioc->reply_post[i].reply_post_free) {
919d8a3f3fef99 Joe Perches 2018-09-17 4978 ioc_err(ioc, "reply_post_free pool: dma_pool_alloc failed\n");
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4979 goto out;
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4980 }
919d8a3f3fef99 Joe Perches 2018-09-17 4981 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 4982 ioc_info(ioc, "reply post free pool (0x%p): depth(%d), element_size(%d), pool_size(%d kB)\n",
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4983 ioc->reply_post[i].reply_post_free,
919d8a3f3fef99 Joe Perches 2018-09-17 4984 ioc->reply_post_queue_depth,
919d8a3f3fef99 Joe Perches 2018-09-17 4985 8, sz / 1024));
919d8a3f3fef99 Joe Perches 2018-09-17 4986 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 4987 ioc_info(ioc, "reply_post_free_dma = (0x%llx)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 4988 (u64)ioc->reply_post[i].reply_post_free_dma));
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4989 total_sz += sz;
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4990 } while (ioc->rdpq_array_enable && (++i < ioc->reply_queue_count));
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4991
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4992 if (ioc->dma_mask == 64) {
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4993 if (_base_change_consistent_dma_mask(ioc, ioc->pdev) != 0) {
919d8a3f3fef99 Joe Perches 2018-09-17 4994 ioc_warn(ioc, "no suitable consistent DMA mask for %s\n",
919d8a3f3fef99 Joe Perches 2018-09-17 4995 pci_name(ioc->pdev));
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4996 goto out;
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4997 }
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4998 }
9b05c91ae7fbff Sreekanth Reddy 2014-09-12 4999
f92363d1235949 Sreekanth Reddy 2012-11-30 5000 ioc->scsiio_depth = ioc->hba_queue_depth -
f92363d1235949 Sreekanth Reddy 2012-11-30 5001 ioc->hi_priority_depth - ioc->internal_depth;
f92363d1235949 Sreekanth Reddy 2012-11-30 5002
f92363d1235949 Sreekanth Reddy 2012-11-30 5003 /* set the scsi host can_queue depth
f92363d1235949 Sreekanth Reddy 2012-11-30 5004 * with some internal commands that could be outstanding
f92363d1235949 Sreekanth Reddy 2012-11-30 5005 */
fd0331b32826dd Suganath prabu Subramani 2016-01-28 5006 ioc->shost->can_queue = ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT;
919d8a3f3fef99 Joe Perches 2018-09-17 5007 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5008 ioc_info(ioc, "scsi host: can_queue depth (%d)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5009 ioc->shost->can_queue));
f92363d1235949 Sreekanth Reddy 2012-11-30 5010
f92363d1235949 Sreekanth Reddy 2012-11-30 5011
f92363d1235949 Sreekanth Reddy 2012-11-30 5012 /* contiguous pool for request and chains, 16 byte align, one extra "
f92363d1235949 Sreekanth Reddy 2012-11-30 5013 * "frame for smid=0
f92363d1235949 Sreekanth Reddy 2012-11-30 5014 */
f92363d1235949 Sreekanth Reddy 2012-11-30 5015 ioc->chain_depth = ioc->chains_needed_per_io * ioc->scsiio_depth;
f92363d1235949 Sreekanth Reddy 2012-11-30 5016 sz = ((ioc->scsiio_depth + 1) * ioc->request_sz);
f92363d1235949 Sreekanth Reddy 2012-11-30 5017
f92363d1235949 Sreekanth Reddy 2012-11-30 5018 /* hi-priority queue */
f92363d1235949 Sreekanth Reddy 2012-11-30 5019 sz += (ioc->hi_priority_depth * ioc->request_sz);
f92363d1235949 Sreekanth Reddy 2012-11-30 5020
f92363d1235949 Sreekanth Reddy 2012-11-30 5021 /* internal queue */
f92363d1235949 Sreekanth Reddy 2012-11-30 5022 sz += (ioc->internal_depth * ioc->request_sz);
f92363d1235949 Sreekanth Reddy 2012-11-30 5023
f92363d1235949 Sreekanth Reddy 2012-11-30 5024 ioc->request_dma_sz = sz;
1c2048bdc3f4ff Christoph Hellwig 2018-10-11 @5025 ioc->request = dma_alloc_coherent(&ioc->pdev->dev, sz,
1c2048bdc3f4ff Christoph Hellwig 2018-10-11 5026 &ioc->request_dma, GFP_KERNEL);
f92363d1235949 Sreekanth Reddy 2012-11-30 5027 if (!ioc->request) {
1c2048bdc3f4ff Christoph Hellwig 2018-10-11 5028 ioc_err(ioc, "request pool: dma_alloc_coherent failed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), total(%d kB)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5029 ioc->hba_queue_depth, ioc->chains_needed_per_io,
919d8a3f3fef99 Joe Perches 2018-09-17 5030 ioc->request_sz, sz / 1024);
f92363d1235949 Sreekanth Reddy 2012-11-30 5031 if (ioc->scsiio_depth < MPT3SAS_SAS_QUEUE_DEPTH)
f92363d1235949 Sreekanth Reddy 2012-11-30 5032 goto out;
fd0331b32826dd Suganath prabu Subramani 2016-01-28 5033 retry_sz = 64;
fd0331b32826dd Suganath prabu Subramani 2016-01-28 5034 ioc->hba_queue_depth -= retry_sz;
8ff045c92708a5 Suganath prabu Subramani 2016-02-18 5035 _base_release_memory_pools(ioc);
f92363d1235949 Sreekanth Reddy 2012-11-30 5036 goto retry_allocation;
f92363d1235949 Sreekanth Reddy 2012-11-30 5037 }
e224e03b0c6a23 Suganath Prabu 2019-08-03 5038 memset(ioc->request, 0, sz);
f92363d1235949 Sreekanth Reddy 2012-11-30 5039
f92363d1235949 Sreekanth Reddy 2012-11-30 5040 if (retry_sz)
1c2048bdc3f4ff Christoph Hellwig 2018-10-11 5041 ioc_err(ioc, "request pool: dma_alloc_coherent succeed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), total(%d kb)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5042 ioc->hba_queue_depth, ioc->chains_needed_per_io,
919d8a3f3fef99 Joe Perches 2018-09-17 5043 ioc->request_sz, sz / 1024);
f92363d1235949 Sreekanth Reddy 2012-11-30 5044
f92363d1235949 Sreekanth Reddy 2012-11-30 5045 /* hi-priority queue */
f92363d1235949 Sreekanth Reddy 2012-11-30 5046 ioc->hi_priority = ioc->request + ((ioc->scsiio_depth + 1) *
f92363d1235949 Sreekanth Reddy 2012-11-30 5047 ioc->request_sz);
f92363d1235949 Sreekanth Reddy 2012-11-30 5048 ioc->hi_priority_dma = ioc->request_dma + ((ioc->scsiio_depth + 1) *
f92363d1235949 Sreekanth Reddy 2012-11-30 5049 ioc->request_sz);
f92363d1235949 Sreekanth Reddy 2012-11-30 5050
f92363d1235949 Sreekanth Reddy 2012-11-30 5051 /* internal queue */
f92363d1235949 Sreekanth Reddy 2012-11-30 5052 ioc->internal = ioc->hi_priority + (ioc->hi_priority_depth *
f92363d1235949 Sreekanth Reddy 2012-11-30 5053 ioc->request_sz);
f92363d1235949 Sreekanth Reddy 2012-11-30 5054 ioc->internal_dma = ioc->hi_priority_dma + (ioc->hi_priority_depth *
f92363d1235949 Sreekanth Reddy 2012-11-30 5055 ioc->request_sz);
f92363d1235949 Sreekanth Reddy 2012-11-30 5056
919d8a3f3fef99 Joe Perches 2018-09-17 5057 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5058 ioc_info(ioc, "request pool(0x%p): depth(%d), frame_size(%d), pool_size(%d kB)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5059 ioc->request, ioc->hba_queue_depth,
919d8a3f3fef99 Joe Perches 2018-09-17 5060 ioc->request_sz,
f92363d1235949 Sreekanth Reddy 2012-11-30 5061 (ioc->hba_queue_depth * ioc->request_sz) / 1024));
f92363d1235949 Sreekanth Reddy 2012-11-30 5062
919d8a3f3fef99 Joe Perches 2018-09-17 5063 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5064 ioc_info(ioc, "request pool: dma(0x%llx)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5065 (unsigned long long)ioc->request_dma));
f92363d1235949 Sreekanth Reddy 2012-11-30 5066 total_sz += sz;
f92363d1235949 Sreekanth Reddy 2012-11-30 5067
919d8a3f3fef99 Joe Perches 2018-09-17 5068 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5069 ioc_info(ioc, "scsiio(0x%p): depth(%d)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5070 ioc->request, ioc->scsiio_depth));
f92363d1235949 Sreekanth Reddy 2012-11-30 5071
f92363d1235949 Sreekanth Reddy 2012-11-30 5072 ioc->chain_depth = min_t(u32, ioc->chain_depth, MAX_CHAIN_DEPTH);
93204b782a88f2 Chaitra P B 2018-04-24 5073 sz = ioc->scsiio_depth * sizeof(struct chain_lookup);
93204b782a88f2 Chaitra P B 2018-04-24 5074 ioc->chain_lookup = kzalloc(sz, GFP_KERNEL);
f92363d1235949 Sreekanth Reddy 2012-11-30 5075 if (!ioc->chain_lookup) {
919d8a3f3fef99 Joe Perches 2018-09-17 5076 ioc_err(ioc, "chain_lookup: __get_free_pages failed\n");
93204b782a88f2 Chaitra P B 2018-04-24 5077 goto out;
93204b782a88f2 Chaitra P B 2018-04-24 5078 }
93204b782a88f2 Chaitra P B 2018-04-24 5079
93204b782a88f2 Chaitra P B 2018-04-24 5080 sz = ioc->chains_needed_per_io * sizeof(struct chain_tracker);
93204b782a88f2 Chaitra P B 2018-04-24 5081 for (i = 0; i < ioc->scsiio_depth; i++) {
93204b782a88f2 Chaitra P B 2018-04-24 5082 ioc->chain_lookup[i].chains_per_smid = kzalloc(sz, GFP_KERNEL);
93204b782a88f2 Chaitra P B 2018-04-24 5083 if (!ioc->chain_lookup[i].chains_per_smid) {
919d8a3f3fef99 Joe Perches 2018-09-17 5084 ioc_err(ioc, "chain_lookup: kzalloc failed\n");
f92363d1235949 Sreekanth Reddy 2012-11-30 5085 goto out;
f92363d1235949 Sreekanth Reddy 2012-11-30 5086 }
93204b782a88f2 Chaitra P B 2018-04-24 5087 }
93204b782a88f2 Chaitra P B 2018-04-24 5088
f92363d1235949 Sreekanth Reddy 2012-11-30 5089 /* initialize hi-priority queue smid's */
f92363d1235949 Sreekanth Reddy 2012-11-30 5090 ioc->hpr_lookup = kcalloc(ioc->hi_priority_depth,
f92363d1235949 Sreekanth Reddy 2012-11-30 5091 sizeof(struct request_tracker), GFP_KERNEL);
f92363d1235949 Sreekanth Reddy 2012-11-30 5092 if (!ioc->hpr_lookup) {
919d8a3f3fef99 Joe Perches 2018-09-17 5093 ioc_err(ioc, "hpr_lookup: kcalloc failed\n");
f92363d1235949 Sreekanth Reddy 2012-11-30 5094 goto out;
f92363d1235949 Sreekanth Reddy 2012-11-30 5095 }
f92363d1235949 Sreekanth Reddy 2012-11-30 5096 ioc->hi_priority_smid = ioc->scsiio_depth + 1;
919d8a3f3fef99 Joe Perches 2018-09-17 5097 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5098 ioc_info(ioc, "hi_priority(0x%p): depth(%d), start smid(%d)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5099 ioc->hi_priority,
f92363d1235949 Sreekanth Reddy 2012-11-30 5100 ioc->hi_priority_depth, ioc->hi_priority_smid));
f92363d1235949 Sreekanth Reddy 2012-11-30 5101
f92363d1235949 Sreekanth Reddy 2012-11-30 5102 /* initialize internal queue smid's */
f92363d1235949 Sreekanth Reddy 2012-11-30 5103 ioc->internal_lookup = kcalloc(ioc->internal_depth,
f92363d1235949 Sreekanth Reddy 2012-11-30 5104 sizeof(struct request_tracker), GFP_KERNEL);
f92363d1235949 Sreekanth Reddy 2012-11-30 5105 if (!ioc->internal_lookup) {
919d8a3f3fef99 Joe Perches 2018-09-17 5106 ioc_err(ioc, "internal_lookup: kcalloc failed\n");
f92363d1235949 Sreekanth Reddy 2012-11-30 5107 goto out;
f92363d1235949 Sreekanth Reddy 2012-11-30 5108 }
f92363d1235949 Sreekanth Reddy 2012-11-30 5109 ioc->internal_smid = ioc->hi_priority_smid + ioc->hi_priority_depth;
919d8a3f3fef99 Joe Perches 2018-09-17 5110 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5111 ioc_info(ioc, "internal(0x%p): depth(%d), start smid(%d)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5112 ioc->internal,
f92363d1235949 Sreekanth Reddy 2012-11-30 5113 ioc->internal_depth, ioc->internal_smid));
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5114 /*
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5115 * The number of NVMe page sized blocks needed is:
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5116 * (((sg_tablesize * 8) - 1) / (page_size - 8)) + 1
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5117 * ((sg_tablesize * 8) - 1) is the max PRP's minus the first PRP entry
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5118 * that is placed in the main message frame. 8 is the size of each PRP
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5119 * entry or PRP list pointer entry. 8 is subtracted from page_size
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5120 * because of the PRP list pointer entry at the end of a page, so this
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5121 * is not counted as a PRP entry. The 1 added page is a round up.
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5122 *
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5123 * To avoid allocation failures due to the amount of memory that could
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5124 * be required for NVMe PRP's, only each set of NVMe blocks will be
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5125 * contiguous, so a new set is allocated for each possible I/O.
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5126 */
74522a92bbf003 Chaitra P B 2018-04-24 5127 ioc->chains_per_prp_buffer = 0;
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5128 if (ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_NVME_DEVICES) {
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5129 nvme_blocks_needed =
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5130 (ioc->shost->sg_tablesize * NVME_PRP_SIZE) - 1;
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5131 nvme_blocks_needed /= (ioc->page_size - NVME_PRP_SIZE);
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5132 nvme_blocks_needed++;
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5133
dbec4c9040edc1 Suganath Prabu Subramani 2018-01-04 5134 sz = sizeof(struct pcie_sg_list) * ioc->scsiio_depth;
dbec4c9040edc1 Suganath Prabu Subramani 2018-01-04 5135 ioc->pcie_sg_lookup = kzalloc(sz, GFP_KERNEL);
dbec4c9040edc1 Suganath Prabu Subramani 2018-01-04 5136 if (!ioc->pcie_sg_lookup) {
919d8a3f3fef99 Joe Perches 2018-09-17 5137 ioc_info(ioc, "PCIe SGL lookup: kzalloc failed\n");
dbec4c9040edc1 Suganath Prabu Subramani 2018-01-04 5138 goto out;
dbec4c9040edc1 Suganath Prabu Subramani 2018-01-04 5139 }
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5140 sz = nvme_blocks_needed * ioc->page_size;
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5141 ioc->pcie_sgl_dma_pool =
13a0640525367c Romain Perier 2017-11-20 5142 dma_pool_create("PCIe SGL pool", &ioc->pdev->dev, sz, 16, 0);
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5143 if (!ioc->pcie_sgl_dma_pool) {
919d8a3f3fef99 Joe Perches 2018-09-17 5144 ioc_info(ioc, "PCIe SGL pool: dma_pool_create failed\n");
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5145 goto out;
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5146 }
74522a92bbf003 Chaitra P B 2018-04-24 5147
74522a92bbf003 Chaitra P B 2018-04-24 5148 ioc->chains_per_prp_buffer = sz/ioc->chain_segment_sz;
74522a92bbf003 Chaitra P B 2018-04-24 5149 ioc->chains_per_prp_buffer = min(ioc->chains_per_prp_buffer,
74522a92bbf003 Chaitra P B 2018-04-24 5150 ioc->chains_needed_per_io);
74522a92bbf003 Chaitra P B 2018-04-24 5151
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5152 for (i = 0; i < ioc->scsiio_depth; i++) {
dbec4c9040edc1 Suganath Prabu Subramani 2018-01-04 5153 ioc->pcie_sg_lookup[i].pcie_sgl = dma_pool_alloc(
dbec4c9040edc1 Suganath Prabu Subramani 2018-01-04 5154 ioc->pcie_sgl_dma_pool, GFP_KERNEL,
dbec4c9040edc1 Suganath Prabu Subramani 2018-01-04 5155 &ioc->pcie_sg_lookup[i].pcie_sgl_dma);
dbec4c9040edc1 Suganath Prabu Subramani 2018-01-04 5156 if (!ioc->pcie_sg_lookup[i].pcie_sgl) {
919d8a3f3fef99 Joe Perches 2018-09-17 5157 ioc_info(ioc, "PCIe SGL pool: dma_pool_alloc failed\n");
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5158 goto out;
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5159 }
74522a92bbf003 Chaitra P B 2018-04-24 5160 for (j = 0; j < ioc->chains_per_prp_buffer; j++) {
74522a92bbf003 Chaitra P B 2018-04-24 5161 ct = &ioc->chain_lookup[i].chains_per_smid[j];
74522a92bbf003 Chaitra P B 2018-04-24 5162 ct->chain_buffer =
74522a92bbf003 Chaitra P B 2018-04-24 5163 ioc->pcie_sg_lookup[i].pcie_sgl +
74522a92bbf003 Chaitra P B 2018-04-24 5164 (j * ioc->chain_segment_sz);
74522a92bbf003 Chaitra P B 2018-04-24 5165 ct->chain_buffer_dma =
74522a92bbf003 Chaitra P B 2018-04-24 5166 ioc->pcie_sg_lookup[i].pcie_sgl_dma +
74522a92bbf003 Chaitra P B 2018-04-24 5167 (j * ioc->chain_segment_sz);
74522a92bbf003 Chaitra P B 2018-04-24 5168 }
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5169 }
f92363d1235949 Sreekanth Reddy 2012-11-30 5170
919d8a3f3fef99 Joe Perches 2018-09-17 5171 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5172 ioc_info(ioc, "PCIe sgl pool depth(%d), element_size(%d), pool_size(%d kB)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5173 ioc->scsiio_depth, sz,
919d8a3f3fef99 Joe Perches 2018-09-17 5174 (sz * ioc->scsiio_depth) / 1024));
919d8a3f3fef99 Joe Perches 2018-09-17 5175 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5176 ioc_info(ioc, "Number of chains can fit in a PRP page(%d)\n",
74522a92bbf003 Chaitra P B 2018-04-24 5177 ioc->chains_per_prp_buffer));
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5178 total_sz += sz * ioc->scsiio_depth;
016d5c35e27824 Suganath Prabu Subramani 2017-10-31 5179 }
74522a92bbf003 Chaitra P B 2018-04-24 5180
74522a92bbf003 Chaitra P B 2018-04-24 5181 ioc->chain_dma_pool = dma_pool_create("chain pool", &ioc->pdev->dev,
74522a92bbf003 Chaitra P B 2018-04-24 5182 ioc->chain_segment_sz, 16, 0);
74522a92bbf003 Chaitra P B 2018-04-24 5183 if (!ioc->chain_dma_pool) {
919d8a3f3fef99 Joe Perches 2018-09-17 5184 ioc_err(ioc, "chain_dma_pool: dma_pool_create failed\n");
74522a92bbf003 Chaitra P B 2018-04-24 5185 goto out;
74522a92bbf003 Chaitra P B 2018-04-24 5186 }
74522a92bbf003 Chaitra P B 2018-04-24 5187 for (i = 0; i < ioc->scsiio_depth; i++) {
74522a92bbf003 Chaitra P B 2018-04-24 5188 for (j = ioc->chains_per_prp_buffer;
74522a92bbf003 Chaitra P B 2018-04-24 5189 j < ioc->chains_needed_per_io; j++) {
74522a92bbf003 Chaitra P B 2018-04-24 5190 ct = &ioc->chain_lookup[i].chains_per_smid[j];
74522a92bbf003 Chaitra P B 2018-04-24 5191 ct->chain_buffer = dma_pool_alloc(
74522a92bbf003 Chaitra P B 2018-04-24 5192 ioc->chain_dma_pool, GFP_KERNEL,
74522a92bbf003 Chaitra P B 2018-04-24 5193 &ct->chain_buffer_dma);
74522a92bbf003 Chaitra P B 2018-04-24 5194 if (!ct->chain_buffer) {
919d8a3f3fef99 Joe Perches 2018-09-17 5195 ioc_err(ioc, "chain_lookup: pci_pool_alloc failed\n");
74522a92bbf003 Chaitra P B 2018-04-24 5196 _base_release_memory_pools(ioc);
74522a92bbf003 Chaitra P B 2018-04-24 5197 goto out;
74522a92bbf003 Chaitra P B 2018-04-24 5198 }
74522a92bbf003 Chaitra P B 2018-04-24 5199 }
74522a92bbf003 Chaitra P B 2018-04-24 5200 total_sz += ioc->chain_segment_sz;
74522a92bbf003 Chaitra P B 2018-04-24 5201 }
74522a92bbf003 Chaitra P B 2018-04-24 5202
919d8a3f3fef99 Joe Perches 2018-09-17 5203 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5204 ioc_info(ioc, "chain pool depth(%d), frame_size(%d), pool_size(%d kB)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5205 ioc->chain_depth, ioc->chain_segment_sz,
919d8a3f3fef99 Joe Perches 2018-09-17 5206 (ioc->chain_depth * ioc->chain_segment_sz) / 1024));
74522a92bbf003 Chaitra P B 2018-04-24 5207
f92363d1235949 Sreekanth Reddy 2012-11-30 5208 /* sense buffers, 4 byte align */
f92363d1235949 Sreekanth Reddy 2012-11-30 5209 sz = ioc->scsiio_depth * SCSI_SENSE_BUFFERSIZE;
e9d984182ab8e4 Romain Perier 2017-07-06 5210 ioc->sense_dma_pool = dma_pool_create("sense pool", &ioc->pdev->dev, sz,
e9d984182ab8e4 Romain Perier 2017-07-06 5211 4, 0);
f92363d1235949 Sreekanth Reddy 2012-11-30 5212 if (!ioc->sense_dma_pool) {
919d8a3f3fef99 Joe Perches 2018-09-17 5213 ioc_err(ioc, "sense pool: dma_pool_create failed\n");
f92363d1235949 Sreekanth Reddy 2012-11-30 5214 goto out;
f92363d1235949 Sreekanth Reddy 2012-11-30 5215 }
e9d984182ab8e4 Romain Perier 2017-07-06 5216 ioc->sense = dma_pool_alloc(ioc->sense_dma_pool, GFP_KERNEL,
f92363d1235949 Sreekanth Reddy 2012-11-30 5217 &ioc->sense_dma);
f92363d1235949 Sreekanth Reddy 2012-11-30 5218 if (!ioc->sense) {
919d8a3f3fef99 Joe Perches 2018-09-17 5219 ioc_err(ioc, "sense pool: dma_pool_alloc failed\n");
f92363d1235949 Sreekanth Reddy 2012-11-30 5220 goto out;
f92363d1235949 Sreekanth Reddy 2012-11-30 5221 }
e21fef6f331b39 Chaitra P B 2018-04-24 5222 /* sense buffer requires to be in same 4 gb region.
e21fef6f331b39 Chaitra P B 2018-04-24 5223 * Below function will check the same.
e21fef6f331b39 Chaitra P B 2018-04-24 5224 * In case of failure, new pci pool will be created with updated
e21fef6f331b39 Chaitra P B 2018-04-24 5225 * alignment. Older allocation and pool will be destroyed.
e21fef6f331b39 Chaitra P B 2018-04-24 5226 * Alignment will be used such a way that next allocation if
e21fef6f331b39 Chaitra P B 2018-04-24 5227 * success, will always meet same 4gb region requirement.
e21fef6f331b39 Chaitra P B 2018-04-24 5228 * Actual requirement is not alignment, but we need start and end of
e21fef6f331b39 Chaitra P B 2018-04-24 5229 * DMA address must have same upper 32 bit address.
e21fef6f331b39 Chaitra P B 2018-04-24 5230 */
e21fef6f331b39 Chaitra P B 2018-04-24 5231 if (!is_MSB_are_same((long)ioc->sense, sz)) {
e21fef6f331b39 Chaitra P B 2018-04-24 5232 //Release Sense pool & Reallocate
e21fef6f331b39 Chaitra P B 2018-04-24 5233 dma_pool_free(ioc->sense_dma_pool, ioc->sense, ioc->sense_dma);
e21fef6f331b39 Chaitra P B 2018-04-24 5234 dma_pool_destroy(ioc->sense_dma_pool);
e21fef6f331b39 Chaitra P B 2018-04-24 5235 ioc->sense = NULL;
e21fef6f331b39 Chaitra P B 2018-04-24 5236
e21fef6f331b39 Chaitra P B 2018-04-24 5237 ioc->sense_dma_pool =
e21fef6f331b39 Chaitra P B 2018-04-24 5238 dma_pool_create("sense pool", &ioc->pdev->dev, sz,
e21fef6f331b39 Chaitra P B 2018-04-24 5239 roundup_pow_of_two(sz), 0);
e21fef6f331b39 Chaitra P B 2018-04-24 5240 if (!ioc->sense_dma_pool) {
919d8a3f3fef99 Joe Perches 2018-09-17 5241 ioc_err(ioc, "sense pool: pci_pool_create failed\n");
e21fef6f331b39 Chaitra P B 2018-04-24 5242 goto out;
e21fef6f331b39 Chaitra P B 2018-04-24 5243 }
e21fef6f331b39 Chaitra P B 2018-04-24 5244 ioc->sense = dma_pool_alloc(ioc->sense_dma_pool, GFP_KERNEL,
e21fef6f331b39 Chaitra P B 2018-04-24 5245 &ioc->sense_dma);
e21fef6f331b39 Chaitra P B 2018-04-24 5246 if (!ioc->sense) {
919d8a3f3fef99 Joe Perches 2018-09-17 5247 ioc_err(ioc, "sense pool: pci_pool_alloc failed\n");
e21fef6f331b39 Chaitra P B 2018-04-24 5248 goto out;
e21fef6f331b39 Chaitra P B 2018-04-24 5249 }
e21fef6f331b39 Chaitra P B 2018-04-24 5250 }
919d8a3f3fef99 Joe Perches 2018-09-17 5251 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5252 ioc_info(ioc, "sense pool(0x%p): depth(%d), element_size(%d), pool_size(%d kB)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5253 ioc->sense, ioc->scsiio_depth,
f92363d1235949 Sreekanth Reddy 2012-11-30 5254 SCSI_SENSE_BUFFERSIZE, sz / 1024));
919d8a3f3fef99 Joe Perches 2018-09-17 5255 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5256 ioc_info(ioc, "sense_dma(0x%llx)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5257 (unsigned long long)ioc->sense_dma));
f92363d1235949 Sreekanth Reddy 2012-11-30 5258 total_sz += sz;
f92363d1235949 Sreekanth Reddy 2012-11-30 5259
f92363d1235949 Sreekanth Reddy 2012-11-30 5260 /* reply pool, 4 byte align */
f92363d1235949 Sreekanth Reddy 2012-11-30 5261 sz = ioc->reply_free_queue_depth * ioc->reply_sz;
e9d984182ab8e4 Romain Perier 2017-07-06 5262 ioc->reply_dma_pool = dma_pool_create("reply pool", &ioc->pdev->dev, sz,
e9d984182ab8e4 Romain Perier 2017-07-06 5263 4, 0);
f92363d1235949 Sreekanth Reddy 2012-11-30 5264 if (!ioc->reply_dma_pool) {
919d8a3f3fef99 Joe Perches 2018-09-17 5265 ioc_err(ioc, "reply pool: dma_pool_create failed\n");
f92363d1235949 Sreekanth Reddy 2012-11-30 5266 goto out;
f92363d1235949 Sreekanth Reddy 2012-11-30 5267 }
e9d984182ab8e4 Romain Perier 2017-07-06 5268 ioc->reply = dma_pool_alloc(ioc->reply_dma_pool, GFP_KERNEL,
f92363d1235949 Sreekanth Reddy 2012-11-30 5269 &ioc->reply_dma);
f92363d1235949 Sreekanth Reddy 2012-11-30 5270 if (!ioc->reply) {
919d8a3f3fef99 Joe Perches 2018-09-17 5271 ioc_err(ioc, "reply pool: dma_pool_alloc failed\n");
f92363d1235949 Sreekanth Reddy 2012-11-30 5272 goto out;
f92363d1235949 Sreekanth Reddy 2012-11-30 5273 }
f92363d1235949 Sreekanth Reddy 2012-11-30 5274 ioc->reply_dma_min_address = (u32)(ioc->reply_dma);
f92363d1235949 Sreekanth Reddy 2012-11-30 5275 ioc->reply_dma_max_address = (u32)(ioc->reply_dma) + sz;
919d8a3f3fef99 Joe Perches 2018-09-17 5276 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5277 ioc_info(ioc, "reply pool(0x%p): depth(%d), frame_size(%d), pool_size(%d kB)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5278 ioc->reply, ioc->reply_free_queue_depth,
919d8a3f3fef99 Joe Perches 2018-09-17 5279 ioc->reply_sz, sz / 1024));
919d8a3f3fef99 Joe Perches 2018-09-17 5280 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5281 ioc_info(ioc, "reply_dma(0x%llx)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5282 (unsigned long long)ioc->reply_dma));
f92363d1235949 Sreekanth Reddy 2012-11-30 5283 total_sz += sz;
f92363d1235949 Sreekanth Reddy 2012-11-30 5284
f92363d1235949 Sreekanth Reddy 2012-11-30 5285 /* reply free queue, 16 byte align */
f92363d1235949 Sreekanth Reddy 2012-11-30 5286 sz = ioc->reply_free_queue_depth * 4;
e9d984182ab8e4 Romain Perier 2017-07-06 5287 ioc->reply_free_dma_pool = dma_pool_create("reply_free pool",
e9d984182ab8e4 Romain Perier 2017-07-06 5288 &ioc->pdev->dev, sz, 16, 0);
f92363d1235949 Sreekanth Reddy 2012-11-30 5289 if (!ioc->reply_free_dma_pool) {
919d8a3f3fef99 Joe Perches 2018-09-17 5290 ioc_err(ioc, "reply_free pool: dma_pool_create failed\n");
f92363d1235949 Sreekanth Reddy 2012-11-30 5291 goto out;
f92363d1235949 Sreekanth Reddy 2012-11-30 5292 }
c39a4d75539393 Souptick Joarder 2018-10-02 5293 ioc->reply_free = dma_pool_zalloc(ioc->reply_free_dma_pool, GFP_KERNEL,
f92363d1235949 Sreekanth Reddy 2012-11-30 5294 &ioc->reply_free_dma);
f92363d1235949 Sreekanth Reddy 2012-11-30 5295 if (!ioc->reply_free) {
919d8a3f3fef99 Joe Perches 2018-09-17 5296 ioc_err(ioc, "reply_free pool: dma_pool_alloc failed\n");
f92363d1235949 Sreekanth Reddy 2012-11-30 5297 goto out;
f92363d1235949 Sreekanth Reddy 2012-11-30 5298 }
919d8a3f3fef99 Joe Perches 2018-09-17 5299 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5300 ioc_info(ioc, "reply_free pool(0x%p): depth(%d), element_size(%d), pool_size(%d kB)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5301 ioc->reply_free, ioc->reply_free_queue_depth,
919d8a3f3fef99 Joe Perches 2018-09-17 5302 4, sz / 1024));
919d8a3f3fef99 Joe Perches 2018-09-17 5303 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5304 ioc_info(ioc, "reply_free_dma (0x%llx)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5305 (unsigned long long)ioc->reply_free_dma));
f92363d1235949 Sreekanth Reddy 2012-11-30 5306 total_sz += sz;
f92363d1235949 Sreekanth Reddy 2012-11-30 5307
cd33223b59a493 Chaitra P B 2018-04-24 5308 if (ioc->rdpq_array_enable) {
cd33223b59a493 Chaitra P B 2018-04-24 5309 reply_post_free_array_sz = ioc->reply_queue_count *
cd33223b59a493 Chaitra P B 2018-04-24 5310 sizeof(Mpi2IOCInitRDPQArrayEntry);
cd33223b59a493 Chaitra P B 2018-04-24 5311 ioc->reply_post_free_array_dma_pool =
cd33223b59a493 Chaitra P B 2018-04-24 5312 dma_pool_create("reply_post_free_array pool",
cd33223b59a493 Chaitra P B 2018-04-24 5313 &ioc->pdev->dev, reply_post_free_array_sz, 16, 0);
cd33223b59a493 Chaitra P B 2018-04-24 5314 if (!ioc->reply_post_free_array_dma_pool) {
cd33223b59a493 Chaitra P B 2018-04-24 5315 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5316 ioc_info(ioc, "reply_post_free_array pool: dma_pool_create failed\n"));
cd33223b59a493 Chaitra P B 2018-04-24 5317 goto out;
cd33223b59a493 Chaitra P B 2018-04-24 5318 }
cd33223b59a493 Chaitra P B 2018-04-24 5319 ioc->reply_post_free_array =
cd33223b59a493 Chaitra P B 2018-04-24 5320 dma_pool_alloc(ioc->reply_post_free_array_dma_pool,
cd33223b59a493 Chaitra P B 2018-04-24 5321 GFP_KERNEL, &ioc->reply_post_free_array_dma);
cd33223b59a493 Chaitra P B 2018-04-24 5322 if (!ioc->reply_post_free_array) {
cd33223b59a493 Chaitra P B 2018-04-24 5323 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5324 ioc_info(ioc, "reply_post_free_array pool: dma_pool_alloc failed\n"));
cd33223b59a493 Chaitra P B 2018-04-24 5325 goto out;
cd33223b59a493 Chaitra P B 2018-04-24 5326 }
cd33223b59a493 Chaitra P B 2018-04-24 5327 }
f92363d1235949 Sreekanth Reddy 2012-11-30 5328 ioc->config_page_sz = 512;
1c2048bdc3f4ff Christoph Hellwig 2018-10-11 5329 ioc->config_page = dma_alloc_coherent(&ioc->pdev->dev,
1c2048bdc3f4ff Christoph Hellwig 2018-10-11 5330 ioc->config_page_sz, &ioc->config_page_dma, GFP_KERNEL);
f92363d1235949 Sreekanth Reddy 2012-11-30 5331 if (!ioc->config_page) {
919d8a3f3fef99 Joe Perches 2018-09-17 5332 ioc_err(ioc, "config page: dma_pool_alloc failed\n");
f92363d1235949 Sreekanth Reddy 2012-11-30 5333 goto out;
f92363d1235949 Sreekanth Reddy 2012-11-30 5334 }
919d8a3f3fef99 Joe Perches 2018-09-17 5335 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5336 ioc_info(ioc, "config page(0x%p): size(%d)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5337 ioc->config_page, ioc->config_page_sz));
919d8a3f3fef99 Joe Perches 2018-09-17 5338 dinitprintk(ioc,
919d8a3f3fef99 Joe Perches 2018-09-17 5339 ioc_info(ioc, "config_page_dma(0x%llx)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5340 (unsigned long long)ioc->config_page_dma));
f92363d1235949 Sreekanth Reddy 2012-11-30 5341 total_sz += ioc->config_page_sz;
f92363d1235949 Sreekanth Reddy 2012-11-30 5342
919d8a3f3fef99 Joe Perches 2018-09-17 5343 ioc_info(ioc, "Allocated physical memory: size(%d kB)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5344 total_sz / 1024);
919d8a3f3fef99 Joe Perches 2018-09-17 5345 ioc_info(ioc, "Current Controller Queue Depth(%d),Max Controller Queue Depth(%d)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5346 ioc->shost->can_queue, facts->RequestCredit);
919d8a3f3fef99 Joe Perches 2018-09-17 5347 ioc_info(ioc, "Scatter Gather Elements per IO(%d)\n",
919d8a3f3fef99 Joe Perches 2018-09-17 5348 ioc->shost->sg_tablesize);
f92363d1235949 Sreekanth Reddy 2012-11-30 5349 return 0;
f92363d1235949 Sreekanth Reddy 2012-11-30 5350
f92363d1235949 Sreekanth Reddy 2012-11-30 5351 out:
f92363d1235949 Sreekanth Reddy 2012-11-30 5352 return -ENOMEM;
f92363d1235949 Sreekanth Reddy 2012-11-30 5353 }
f92363d1235949 Sreekanth Reddy 2012-11-30 5354

:::::: The code at line 5025 was first introduced by commit
:::::: 1c2048bdc3f4ff3337613c27519cf608916e95a9 scsi: mpt3sas: switch to generic DMA API

:::::: TO: Christoph Hellwig <hch@xxxxxx>
:::::: CC: Martin K. Petersen <martin.petersen@xxxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip