These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / scsi / megaraid / megaraid_sas_fp.c
index 4f72287..741509b 100644 (file)
@@ -66,7 +66,15 @@ MODULE_PARM_DESC(lb_pending_cmds, "Change raid-1 load balancing outstanding "
 
 #define ABS_DIFF(a, b)   (((a) > (b)) ? ((a) - (b)) : ((b) - (a)))
 #define MR_LD_STATE_OPTIMAL 3
+
+#ifdef FALSE
+#undef FALSE
+#endif
 #define FALSE 0
+
+#ifdef TRUE
+#undef TRUE
+#endif
 #define TRUE 1
 
 #define SPAN_DEBUG 0
@@ -142,7 +150,7 @@ u16 MR_LdSpanArrayGet(u32 ld, u32 span, struct MR_DRV_RAID_MAP_ALL *map)
        return le16_to_cpu(map->raidMap.ldSpanMap[ld].spanBlock[span].span.arrayRef);
 }
 
-u16 MR_PdDevHandleGet(u32 pd, struct MR_DRV_RAID_MAP_ALL *map)
+__le16 MR_PdDevHandleGet(u32 pd, struct MR_DRV_RAID_MAP_ALL *map)
 {
        return map->raidMap.devHndlInfo[pd].curDevHdl;
 }
@@ -733,14 +741,12 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance *instance, u32 ld,
        u8      physArm, span;
        u64     row;
        u8      retval = TRUE;
-       u8      do_invader = 0;
        u64     *pdBlock = &io_info->pdBlock;
-       u16     *pDevHandle = &io_info->devHandle;
+       __le16  *pDevHandle = &io_info->devHandle;
        u32     logArm, rowMod, armQ, arm;
+       struct fusion_context *fusion;
 
-       if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER ||
-               instance->pdev->device == PCI_DEVICE_ID_LSI_FURY))
-               do_invader = 1;
+       fusion = instance->ctrl_context;
 
        /*Get row and span from io_info for Uneven Span IO.*/
        row         = io_info->start_row;
@@ -769,9 +775,10 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance *instance, u32 ld,
        if (pd != MR_PD_INVALID)
                *pDevHandle = MR_PdDevHandleGet(pd, map);
        else {
-               *pDevHandle = MR_PD_INVALID;
+               *pDevHandle = cpu_to_le16(MR_PD_INVALID);
                if ((raid->level >= 5) &&
-                       (!do_invader  || (do_invader &&
+                       ((fusion->adapter_type == THUNDERBOLT_SERIES)  ||
+                       ((fusion->adapter_type == INVADER_SERIES) &&
                        (raid->regTypeReqOnRead != REGION_TYPE_UNUSED))))
                        pRAID_Context->regLockFlags = REGION_TYPE_EXCLUSIVE;
                else if (raid->level == 1) {
@@ -815,13 +822,12 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 ld, u64 stripRow,
        u8          physArm, span;
        u64         row;
        u8          retval = TRUE;
-       u8          do_invader = 0;
        u64         *pdBlock = &io_info->pdBlock;
-       u16         *pDevHandle = &io_info->devHandle;
+       __le16      *pDevHandle = &io_info->devHandle;
+       struct fusion_context *fusion;
+
+       fusion = instance->ctrl_context;
 
-       if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER ||
-               instance->pdev->device == PCI_DEVICE_ID_LSI_FURY))
-               do_invader = 1;
 
        row =  mega_div64_32(stripRow, raid->rowDataSize);
 
@@ -864,9 +870,11 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 ld, u64 stripRow,
                /* Get dev handle from Pd. */
                *pDevHandle = MR_PdDevHandleGet(pd, map);
        else {
-               *pDevHandle = MR_PD_INVALID; /* set dev handle as invalid. */
+               /* set dev handle as invalid. */
+               *pDevHandle = cpu_to_le16(MR_PD_INVALID);
                if ((raid->level >= 5) &&
-                       (!do_invader  || (do_invader &&
+                       ((fusion->adapter_type == THUNDERBOLT_SERIES)  ||
+                       ((fusion->adapter_type == INVADER_SERIES) &&
                        (raid->regTypeReqOnRead != REGION_TYPE_UNUSED))))
                        pRAID_Context->regLockFlags = REGION_TYPE_EXCLUSIVE;
                else if (raid->level == 1) {
@@ -900,6 +908,7 @@ MR_BuildRaidContext(struct megasas_instance *instance,
                    struct RAID_CONTEXT *pRAID_Context,
                    struct MR_DRV_RAID_MAP_ALL *map, u8 **raidLUN)
 {
+       struct fusion_context *fusion;
        struct MR_LD_RAID  *raid;
        u32         ld, stripSize, stripe_mask;
        u64         endLba, endStrip, endRow, start_row, start_strip;
@@ -920,6 +929,7 @@ MR_BuildRaidContext(struct megasas_instance *instance,
        isRead = io_info->isRead;
        io_info->IoforUnevenSpan = 0;
        io_info->start_span     = SPAN_INVALID;
+       fusion = instance->ctrl_context;
 
        ld = MR_TargetIdToLdGet(ldTgtId, map);
        raid = MR_LdRaidGet(ld, map);
@@ -1083,8 +1093,7 @@ MR_BuildRaidContext(struct megasas_instance *instance,
                cpu_to_le16(raid->fpIoTimeoutForLd ?
                            raid->fpIoTimeoutForLd :
                            map->raidMap.fpPdIoTimeoutSec);
-       if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
-               (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY))
+       if (fusion->adapter_type == INVADER_SERIES)
                pRAID_Context->regLockFlags = (isRead) ?
                        raid->regTypeReqOnRead : raid->regTypeReqOnWrite;
        else
@@ -1109,7 +1118,7 @@ MR_BuildRaidContext(struct megasas_instance *instance,
                                        ref_in_start_stripe, io_info,
                                        pRAID_Context, map);
                /* If IO on an invalid Pd, then FP is not possible.*/
-               if (io_info->devHandle == MR_PD_INVALID)
+               if (io_info->devHandle == cpu_to_le16(MR_PD_INVALID))
                        io_info->fpOkForIo = FALSE;
                return retval;
        } else if (isRead) {
@@ -1189,10 +1198,6 @@ void mr_update_span_set(struct MR_DRV_RAID_MAP_ALL *map,
                                                span_row_width +=
                                                        MR_LdSpanPtrGet
                                                        (ld, count, map)->spanRowDataSize;
-                                               printk(KERN_INFO "megasas:"
-                                                       "span %x rowDataSize %x\n",
-                                                       count, MR_LdSpanPtrGet
-                                                       (ld, count, map)->spanRowDataSize);
                                        }
                                }
 
@@ -1341,11 +1346,11 @@ u8 megasas_get_best_arm_pd(struct megasas_instance *instance,
        return io_info->pd_after_lb;
 }
 
-u16 get_updated_dev_handle(struct megasas_instance *instance,
+__le16 get_updated_dev_handle(struct megasas_instance *instance,
        struct LD_LOAD_BALANCE_INFO *lbInfo, struct IO_REQUEST_INFO *io_info)
 {
        u8 arm_pd;
-       u16 devHandle;
+       __le16 devHandle;
        struct fusion_context *fusion;
        struct MR_DRV_RAID_MAP_ALL *drv_map;