]> git.ipfire.org Git - people/ms/linux.git/commitdiff
megaraid_sas: endianness related bug fixes and code optimization
authorSumit.Saxena@avagotech.com <Sumit.Saxena@avagotech.com>
Mon, 5 Jan 2015 14:35:58 +0000 (20:05 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Mar 2015 22:52:50 +0000 (14:52 -0800)
commit 200aed582d6170a2687cd69095469b663f69f16f upstream.

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.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/scsi/megaraid/megaraid_sas_base.c
drivers/scsi/megaraid/megaraid_sas_fp.c
drivers/scsi/megaraid/megaraid_sas_fusion.c
drivers/scsi/megaraid/megaraid_sas_fusion.h

index 5e881e5e67b6c464b2cd99f1ee2464c7f2393c04..6e503802947ac682dc05b8eb5c64cb95028f75cf 100644 (file)
@@ -3556,7 +3556,6 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
        int i;
        u32 max_cmd;
        u32 sge_sz;
-       u32 sgl_sz;
        u32 total_sz;
        u32 frame_count;
        struct megasas_cmd *cmd;
@@ -3575,24 +3574,23 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
        }
 
        /*
-        * Calculated the number of 64byte frames required for SGL
-        */
-       sgl_sz = sge_sz * instance->max_num_sge;
-       frame_count = (sgl_sz + MEGAMFI_FRAME_SIZE - 1) / MEGAMFI_FRAME_SIZE;
-       frame_count = 15;
-
-       /*
-        * We need one extra frame for the MFI command
+        * For MFI controllers.
+        * max_num_sge = 60
+        * max_sge_sz  = 16 byte (sizeof megasas_sge_skinny)
+        * Total 960 byte (15 MFI frame of 64 byte)
+        *
+        * Fusion adapter require only 3 extra frame.
+        * max_num_sge = 16 (defined as MAX_IOCTL_SGE)
+        * max_sge_sz  = 12 byte (sizeof  megasas_sge64)
+        * Total 192 byte (3 MFI frame of 64 byte)
         */
-       frame_count++;
-
+       frame_count = instance->ctrl_context ? (3 + 1) : (15 + 1);
        total_sz = MEGAMFI_FRAME_SIZE * frame_count;
        /*
         * Use DMA pool facility provided by PCI layer
         */
        instance->frame_dma_pool = pci_pool_create("megasas frame pool",
-                                                  instance->pdev, total_sz, 64,
-                                                  0);
+                                       instance->pdev, total_sz, 256, 0);
 
        if (!instance->frame_dma_pool) {
                printk(KERN_DEBUG "megasas: failed to setup frame pool\n");
index 0f66d0ef0b26523a513919b87aa8d8722827af3f..a8e410bc53f11ccbc171457465c701a67c654f8f 100644 (file)
@@ -170,6 +170,7 @@ void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
        struct MR_FW_RAID_MAP_ALL     *fw_map_old    = NULL;
        struct MR_FW_RAID_MAP         *pFwRaidMap    = NULL;
        int i;
+       u16 ld_count;
 
 
        struct MR_DRV_RAID_MAP_ALL *drv_map =
@@ -189,9 +190,10 @@ void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
                fw_map_old = (struct MR_FW_RAID_MAP_ALL *)
                        fusion->ld_map[(instance->map_id & 1)];
                pFwRaidMap = &fw_map_old->raidMap;
+               ld_count = (u16)le32_to_cpu(pFwRaidMap->ldCount);
 
 #if VD_EXT_DEBUG
-               for (i = 0; i < le16_to_cpu(pFwRaidMap->ldCount); i++) {
+               for (i = 0; i < ld_count; i++) {
                        dev_dbg(&instance->pdev->dev, "(%d) :Index 0x%x "
                                "Target Id 0x%x Seq Num 0x%x Size 0/%llx\n",
                                instance->unique_id, i,
@@ -203,12 +205,12 @@ void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
 
                memset(drv_map, 0, fusion->drv_map_sz);
                pDrvRaidMap->totalSize = pFwRaidMap->totalSize;
-               pDrvRaidMap->ldCount = (__le16)pFwRaidMap->ldCount;
+               pDrvRaidMap->ldCount = (__le16)cpu_to_le16(ld_count);
                pDrvRaidMap->fpPdIoTimeoutSec = pFwRaidMap->fpPdIoTimeoutSec;
                for (i = 0; i < MAX_RAIDMAP_LOGICAL_DRIVES + MAX_RAIDMAP_VIEWS; i++)
                        pDrvRaidMap->ldTgtIdToLd[i] =
                                (u8)pFwRaidMap->ldTgtIdToLd[i];
-               for (i = 0; i < le16_to_cpu(pDrvRaidMap->ldCount); i++) {
+               for (i = 0; i < ld_count; i++) {
                        pDrvRaidMap->ldSpanMap[i] = pFwRaidMap->ldSpanMap[i];
 #if VD_EXT_DEBUG
                        dev_dbg(&instance->pdev->dev,
@@ -250,7 +252,7 @@ u8 MR_ValidateMapInfo(struct megasas_instance *instance)
        struct LD_LOAD_BALANCE_INFO *lbInfo;
        PLD_SPAN_INFO ldSpanInfo;
        struct MR_LD_RAID         *raid;
-       int ldCount, num_lds;
+       u16 ldCount, num_lds;
        u16 ld;
        u32 expected_size;
 
@@ -354,7 +356,7 @@ static int getSpanInfo(struct MR_DRV_RAID_MAP_ALL *map,
 
        for (ldCount = 0; ldCount < MAX_LOGICAL_DRIVES_EXT; ldCount++) {
                ld = MR_TargetIdToLdGet(ldCount, map);
-                       if (ld >= MAX_LOGICAL_DRIVES_EXT)
+                       if (ld >= (MAX_LOGICAL_DRIVES_EXT - 1))
                                continue;
                raid = MR_LdRaidGet(ld, map);
                dev_dbg(&instance->pdev->dev, "LD %x: span_depth=%x\n",
@@ -1155,7 +1157,7 @@ void mr_update_span_set(struct MR_DRV_RAID_MAP_ALL *map,
 
        for (ldCount = 0; ldCount < MAX_LOGICAL_DRIVES_EXT; ldCount++) {
                ld = MR_TargetIdToLdGet(ldCount, map);
-               if (ld >= MAX_LOGICAL_DRIVES_EXT)
+               if (ld >= (MAX_LOGICAL_DRIVES_EXT - 1))
                        continue;
                raid = MR_LdRaidGet(ld, map);
                for (element = 0; element < MAX_QUAD_DEPTH; element++) {
index 9d9c27cd4687322a02b6c5957d0999f79e1112a4..21987aca0eea0403ae8d51aaa9565b8268b0c8b6 100644 (file)
@@ -696,12 +696,11 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
                cpu_to_le32(lower_32_bits(ioc_init_handle));
        init_frame->data_xfer_len = cpu_to_le32(sizeof(struct MPI2_IOC_INIT_REQUEST));
 
-       req_desc.Words = 0;
+       req_desc.u.low = cpu_to_le32(lower_32_bits(cmd->frame_phys_addr));
+       req_desc.u.high = cpu_to_le32(upper_32_bits(cmd->frame_phys_addr));
        req_desc.MFAIo.RequestFlags =
                (MEGASAS_REQ_DESCRIPT_FLAGS_MFA <<
-                MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
-       cpu_to_le32s((u32 *)&req_desc.MFAIo);
-       req_desc.Words |= cpu_to_le64(cmd->frame_phys_addr);
+               MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
 
        /*
         * disable the intr before firing the init frame
index 0d183d521bdd9bf83b6590fc6555af2dbc434094..a7f216f27ae3103382f12f9f406b210a8165a581 100644 (file)
@@ -304,14 +304,9 @@ struct MPI2_RAID_SCSI_IO_REQUEST {
  * MPT RAID MFA IO Descriptor.
  */
 struct MEGASAS_RAID_MFA_IO_REQUEST_DESCRIPTOR {
-#if   defined(__BIG_ENDIAN_BITFIELD)
-       u32     MessageAddress1:24; /* bits 31:8*/
-       u32     RequestFlags:8;
-#else
        u32     RequestFlags:8;
-       u32     MessageAddress1:24; /* bits 31:8*/
-#endif
-       u32     MessageAddress2;      /* bits 61:32 */
+       u32     MessageAddress1:24;
+       u32     MessageAddress2;
 };
 
 /* Default Request Descriptor */