aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSumit.Saxena@avagotech.com <Sumit.Saxena@avagotech.com>2015-01-05 09:35:58 -0500
committerChristoph Hellwig <hch@lst.de>2015-01-09 09:44:33 -0500
commit200aed582d6170a2687cd69095469b663f69f16f (patch)
tree77d99d82baccd1556702df6d4612d03099fc6f97
parent470613b462a767aa8cca1e590928fcbc55bf39e5 (diff)
megaraid_sas: endianness related bug fixes and code optimization
This patch addresses below issues: 1) Few endianness bug fixes. 2) Break the iteration after (MAX_LOGICAL_DRIVES_EXT - 1)), instead of MAX_LOGICAL_DRIVES_EXT. 3) Optimization in MFI INIT frame before firing. 4) MFI IO frame should be 256bytes aligned. Code is optimized to reduce the size of frame for fusion adapters and make the MFI frame size calculation a bit transparent and readable. Cc: <stable@vger.kernel.org> Signed-off-by: Kashyap Desai <kashyap.desai@avagotech.com> Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com> Signed-off-by: Chaitra Basappa <chaitra.basappa@avagotech.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_base.c24
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_fp.c14
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_fusion.c7
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_fusion.h9
4 files changed, 24 insertions, 30 deletions
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index ff283d23788a..401ed67cf4c1 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -3547,7 +3547,6 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
3547 int i; 3547 int i;
3548 u32 max_cmd; 3548 u32 max_cmd;
3549 u32 sge_sz; 3549 u32 sge_sz;
3550 u32 sgl_sz;
3551 u32 total_sz; 3550 u32 total_sz;
3552 u32 frame_count; 3551 u32 frame_count;
3553 struct megasas_cmd *cmd; 3552 struct megasas_cmd *cmd;
@@ -3566,24 +3565,23 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
3566 } 3565 }
3567 3566
3568 /* 3567 /*
3569 * Calculated the number of 64byte frames required for SGL 3568 * For MFI controllers.
3570 */ 3569 * max_num_sge = 60
3571 sgl_sz = sge_sz * instance->max_num_sge; 3570 * max_sge_sz = 16 byte (sizeof megasas_sge_skinny)
3572 frame_count = (sgl_sz + MEGAMFI_FRAME_SIZE - 1) / MEGAMFI_FRAME_SIZE; 3571 * Total 960 byte (15 MFI frame of 64 byte)
3573 frame_count = 15; 3572 *
3574 3573 * Fusion adapter require only 3 extra frame.
3575 /* 3574 * max_num_sge = 16 (defined as MAX_IOCTL_SGE)
3576 * We need one extra frame for the MFI command 3575 * max_sge_sz = 12 byte (sizeof megasas_sge64)
3576 * Total 192 byte (3 MFI frame of 64 byte)
3577 */ 3577 */
3578 frame_count++; 3578 frame_count = instance->ctrl_context ? (3 + 1) : (15 + 1);
3579
3580 total_sz = MEGAMFI_FRAME_SIZE * frame_count; 3579 total_sz = MEGAMFI_FRAME_SIZE * frame_count;
3581 /* 3580 /*
3582 * Use DMA pool facility provided by PCI layer 3581 * Use DMA pool facility provided by PCI layer
3583 */ 3582 */
3584 instance->frame_dma_pool = pci_pool_create("megasas frame pool", 3583 instance->frame_dma_pool = pci_pool_create("megasas frame pool",
3585 instance->pdev, total_sz, 64, 3584 instance->pdev, total_sz, 256, 0);
3586 0);
3587 3585
3588 if (!instance->frame_dma_pool) { 3586 if (!instance->frame_dma_pool) {
3589 printk(KERN_DEBUG "megasas: failed to setup frame pool\n"); 3587 printk(KERN_DEBUG "megasas: failed to setup frame pool\n");
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c
index 460c6a3d4ade..7cae1c25c9a9 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -172,6 +172,7 @@ void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
172 struct MR_FW_RAID_MAP_ALL *fw_map_old = NULL; 172 struct MR_FW_RAID_MAP_ALL *fw_map_old = NULL;
173 struct MR_FW_RAID_MAP *pFwRaidMap = NULL; 173 struct MR_FW_RAID_MAP *pFwRaidMap = NULL;
174 int i; 174 int i;
175 u16 ld_count;
175 176
176 177
177 struct MR_DRV_RAID_MAP_ALL *drv_map = 178 struct MR_DRV_RAID_MAP_ALL *drv_map =
@@ -191,9 +192,10 @@ void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
191 fw_map_old = (struct MR_FW_RAID_MAP_ALL *) 192 fw_map_old = (struct MR_FW_RAID_MAP_ALL *)
192 fusion->ld_map[(instance->map_id & 1)]; 193 fusion->ld_map[(instance->map_id & 1)];
193 pFwRaidMap = &fw_map_old->raidMap; 194 pFwRaidMap = &fw_map_old->raidMap;
195 ld_count = (u16)le32_to_cpu(pFwRaidMap->ldCount);
194 196
195#if VD_EXT_DEBUG 197#if VD_EXT_DEBUG
196 for (i = 0; i < le16_to_cpu(pFwRaidMap->ldCount); i++) { 198 for (i = 0; i < ld_count; i++) {
197 dev_dbg(&instance->pdev->dev, "(%d) :Index 0x%x " 199 dev_dbg(&instance->pdev->dev, "(%d) :Index 0x%x "
198 "Target Id 0x%x Seq Num 0x%x Size 0/%llx\n", 200 "Target Id 0x%x Seq Num 0x%x Size 0/%llx\n",
199 instance->unique_id, i, 201 instance->unique_id, i,
@@ -205,12 +207,12 @@ void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
205 207
206 memset(drv_map, 0, fusion->drv_map_sz); 208 memset(drv_map, 0, fusion->drv_map_sz);
207 pDrvRaidMap->totalSize = pFwRaidMap->totalSize; 209 pDrvRaidMap->totalSize = pFwRaidMap->totalSize;
208 pDrvRaidMap->ldCount = (__le16)pFwRaidMap->ldCount; 210 pDrvRaidMap->ldCount = (__le16)cpu_to_le16(ld_count);
209 pDrvRaidMap->fpPdIoTimeoutSec = pFwRaidMap->fpPdIoTimeoutSec; 211 pDrvRaidMap->fpPdIoTimeoutSec = pFwRaidMap->fpPdIoTimeoutSec;
210 for (i = 0; i < MAX_RAIDMAP_LOGICAL_DRIVES + MAX_RAIDMAP_VIEWS; i++) 212 for (i = 0; i < MAX_RAIDMAP_LOGICAL_DRIVES + MAX_RAIDMAP_VIEWS; i++)
211 pDrvRaidMap->ldTgtIdToLd[i] = 213 pDrvRaidMap->ldTgtIdToLd[i] =
212 (u8)pFwRaidMap->ldTgtIdToLd[i]; 214 (u8)pFwRaidMap->ldTgtIdToLd[i];
213 for (i = 0; i < le16_to_cpu(pDrvRaidMap->ldCount); i++) { 215 for (i = 0; i < ld_count; i++) {
214 pDrvRaidMap->ldSpanMap[i] = pFwRaidMap->ldSpanMap[i]; 216 pDrvRaidMap->ldSpanMap[i] = pFwRaidMap->ldSpanMap[i];
215#if VD_EXT_DEBUG 217#if VD_EXT_DEBUG
216 dev_dbg(&instance->pdev->dev, 218 dev_dbg(&instance->pdev->dev,
@@ -252,7 +254,7 @@ u8 MR_ValidateMapInfo(struct megasas_instance *instance)
252 struct LD_LOAD_BALANCE_INFO *lbInfo; 254 struct LD_LOAD_BALANCE_INFO *lbInfo;
253 PLD_SPAN_INFO ldSpanInfo; 255 PLD_SPAN_INFO ldSpanInfo;
254 struct MR_LD_RAID *raid; 256 struct MR_LD_RAID *raid;
255 int ldCount, num_lds; 257 u16 ldCount, num_lds;
256 u16 ld; 258 u16 ld;
257 u32 expected_size; 259 u32 expected_size;
258 260
@@ -356,7 +358,7 @@ static int getSpanInfo(struct MR_DRV_RAID_MAP_ALL *map,
356 358
357 for (ldCount = 0; ldCount < MAX_LOGICAL_DRIVES_EXT; ldCount++) { 359 for (ldCount = 0; ldCount < MAX_LOGICAL_DRIVES_EXT; ldCount++) {
358 ld = MR_TargetIdToLdGet(ldCount, map); 360 ld = MR_TargetIdToLdGet(ldCount, map);
359 if (ld >= MAX_LOGICAL_DRIVES_EXT) 361 if (ld >= (MAX_LOGICAL_DRIVES_EXT - 1))
360 continue; 362 continue;
361 raid = MR_LdRaidGet(ld, map); 363 raid = MR_LdRaidGet(ld, map);
362 dev_dbg(&instance->pdev->dev, "LD %x: span_depth=%x\n", 364 dev_dbg(&instance->pdev->dev, "LD %x: span_depth=%x\n",
@@ -1157,7 +1159,7 @@ void mr_update_span_set(struct MR_DRV_RAID_MAP_ALL *map,
1157 1159
1158 for (ldCount = 0; ldCount < MAX_LOGICAL_DRIVES_EXT; ldCount++) { 1160 for (ldCount = 0; ldCount < MAX_LOGICAL_DRIVES_EXT; ldCount++) {
1159 ld = MR_TargetIdToLdGet(ldCount, map); 1161 ld = MR_TargetIdToLdGet(ldCount, map);
1160 if (ld >= MAX_LOGICAL_DRIVES_EXT) 1162 if (ld >= (MAX_LOGICAL_DRIVES_EXT - 1))
1161 continue; 1163 continue;
1162 raid = MR_LdRaidGet(ld, map); 1164 raid = MR_LdRaidGet(ld, map);
1163 for (element = 0; element < MAX_QUAD_DEPTH; element++) { 1165 for (element = 0; element < MAX_QUAD_DEPTH; element++) {
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 71557f64bb5e..b5362c196000 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -698,12 +698,11 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
698 cpu_to_le32(lower_32_bits(ioc_init_handle)); 698 cpu_to_le32(lower_32_bits(ioc_init_handle));
699 init_frame->data_xfer_len = cpu_to_le32(sizeof(struct MPI2_IOC_INIT_REQUEST)); 699 init_frame->data_xfer_len = cpu_to_le32(sizeof(struct MPI2_IOC_INIT_REQUEST));
700 700
701 req_desc.Words = 0; 701 req_desc.u.low = cpu_to_le32(lower_32_bits(cmd->frame_phys_addr));
702 req_desc.u.high = cpu_to_le32(upper_32_bits(cmd->frame_phys_addr));
702 req_desc.MFAIo.RequestFlags = 703 req_desc.MFAIo.RequestFlags =
703 (MEGASAS_REQ_DESCRIPT_FLAGS_MFA << 704 (MEGASAS_REQ_DESCRIPT_FLAGS_MFA <<
704 MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); 705 MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
705 cpu_to_le32s((u32 *)&req_desc.MFAIo);
706 req_desc.Words |= cpu_to_le64(cmd->frame_phys_addr);
707 706
708 /* 707 /*
709 * disable the intr before firing the init frame 708 * disable the intr before firing the init frame
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h b/drivers/scsi/megaraid/megaraid_sas_fusion.h
index 5ab7daee11be..56e6db2d5874 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.h
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h
@@ -306,14 +306,9 @@ struct MPI2_RAID_SCSI_IO_REQUEST {
306 * MPT RAID MFA IO Descriptor. 306 * MPT RAID MFA IO Descriptor.
307 */ 307 */
308struct MEGASAS_RAID_MFA_IO_REQUEST_DESCRIPTOR { 308struct MEGASAS_RAID_MFA_IO_REQUEST_DESCRIPTOR {
309#if defined(__BIG_ENDIAN_BITFIELD)
310 u32 MessageAddress1:24; /* bits 31:8*/
311 u32 RequestFlags:8;
312#else
313 u32 RequestFlags:8; 309 u32 RequestFlags:8;
314 u32 MessageAddress1:24; /* bits 31:8*/ 310 u32 MessageAddress1:24;
315#endif 311 u32 MessageAddress2;
316 u32 MessageAddress2; /* bits 61:32 */
317}; 312};
318 313
319/* Default Request Descriptor */ 314/* Default Request Descriptor */