linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* megaraid_sas: sparse annotations and endianess fixes
@ 2015-01-10 17:11 Christoph Hellwig
  2015-01-10 17:11 ` [PATCH 01/10] megaraid_sas: megasas_complete_outstanding_ioctls() can be static Christoph Hellwig
                   ` (9 more replies)
  0 siblings, 10 replies; 21+ messages in thread
From: Christoph Hellwig @ 2015-01-10 17:11 UTC (permalink / raw)
  To: Sumit.Saxena, kashyap.desai; +Cc: martin.petersen, linux-scsi

The first 8 are fairly mechanical, but the last two will need close
inspection.  There's also a huge mess around the fw ioctls left, which
I haven't really made much progress on as they are way too convoluted.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 01/10] megaraid_sas: megasas_complete_outstanding_ioctls() can be static
  2015-01-10 17:11 megaraid_sas: sparse annotations and endianess fixes Christoph Hellwig
@ 2015-01-10 17:11 ` Christoph Hellwig
  2015-01-13  5:38   ` Sumit Saxena
  2015-01-10 17:11 ` [PATCH 02/10] megaraid_sas: add missing __iomem annotations Christoph Hellwig
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2015-01-10 17:11 UTC (permalink / raw)
  To: Sumit.Saxena, kashyap.desai
  Cc: martin.petersen, linux-scsi, kbuild test robot

From: kbuild test robot <fengguang.wu@intel.com>

drivers/scsi/megaraid/megaraid_sas_base.c:1701:6: sparse: symbol 'megasas_complete_outstanding_ioctls' was not declared. Should it be static?

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 890637f..2eb5233 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1698,7 +1698,7 @@ static int megasas_slave_alloc(struct scsi_device *sdev)
 * @instance:				Adapter soft state
 *
 */
-void megasas_complete_outstanding_ioctls(struct megasas_instance *instance)
+static void megasas_complete_outstanding_ioctls(struct megasas_instance *instance)
 {
 	int i;
 	struct megasas_cmd *cmd_mfi;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 02/10] megaraid_sas: add missing __iomem annotations
  2015-01-10 17:11 megaraid_sas: sparse annotations and endianess fixes Christoph Hellwig
  2015-01-10 17:11 ` [PATCH 01/10] megaraid_sas: megasas_complete_outstanding_ioctls() can be static Christoph Hellwig
@ 2015-01-10 17:11 ` Christoph Hellwig
  2015-01-13  7:05   ` Sumit Saxena
  2015-01-10 17:11 ` [PATCH 03/10] megaraid_sas: add endianess annotations Christoph Hellwig
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2015-01-10 17:11 UTC (permalink / raw)
  To: Sumit.Saxena, kashyap.desai; +Cc: martin.petersen, linux-scsi

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/megaraid/megaraid_sas.h      | 2 +-
 drivers/scsi/megaraid/megaraid_sas_base.c | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
index 14e5c7c..ecc4321 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1681,7 +1681,7 @@ struct megasas_instance {
 	spinlock_t crashdump_lock;
 
 	struct megasas_register_set __iomem *reg_set;
-	u32 *reply_post_host_index_addr[MR_MAX_MSIX_REG_ARRAY];
+	u32 __iomem *reply_post_host_index_addr[MR_MAX_MSIX_REG_ARRAY];
 	struct megasas_pd_list          pd_list[MEGASAS_MAX_PD];
 	struct megasas_pd_list          local_pd_list[MEGASAS_MAX_PD];
 	u8 ld_ids[MEGASAS_MAX_LD_IDS];
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 2eb5233..875db92 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -814,8 +814,8 @@ megasas_adp_reset_gen2(struct megasas_instance *instance,
 {
 	u32			retry = 0 ;
 	u32			HostDiag;
-	u32			*seq_offset = &reg_set->seq_offset;
-	u32			*hostdiag_offset = &reg_set->host_diag;
+	u32 __iomem		*seq_offset = &reg_set->seq_offset;
+	u32 __iomem		*hostdiag_offset = &reg_set->host_diag;
 
 	if (instance->instancet == &megasas_instance_template_skinny) {
 		seq_offset = &reg_set->fusion_seq_offset;
@@ -4499,7 +4499,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
 	 * It is used for all MPT based Adapters.
 	 */
 	instance->reply_post_host_index_addr[0] =
-		(u32 *)((u8 *)instance->reg_set +
+		(u32 __iomem *)((u8 __iomem *)instance->reg_set +
 		MPI2_REPLY_POST_HOST_INDEX_OFFSET);
 
 	/* Check if MSI-X is supported while in ready state */
@@ -4531,7 +4531,8 @@ static int megasas_init_fw(struct megasas_instance *instance)
 			 */
 			for (loop = 1; loop < MR_MAX_MSIX_REG_ARRAY; loop++) {
 				instance->reply_post_host_index_addr[loop] =
-					(u32 *)((u8 *)instance->reg_set +
+					(u32 __iomem *)
+					((u8 __iomem*)instance->reg_set +
 					MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET
 					+ (loop * 0x10));
 			}
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 03/10] megaraid_sas: add endianess annotations
  2015-01-10 17:11 megaraid_sas: sparse annotations and endianess fixes Christoph Hellwig
  2015-01-10 17:11 ` [PATCH 01/10] megaraid_sas: megasas_complete_outstanding_ioctls() can be static Christoph Hellwig
  2015-01-10 17:11 ` [PATCH 02/10] megaraid_sas: add missing __iomem annotations Christoph Hellwig
@ 2015-01-10 17:11 ` Christoph Hellwig
  2015-01-13  7:17   ` Sumit Saxena
  2015-01-10 17:11 ` [PATCH 04/10] megaraid_sas: add endianess conversions for all ones Christoph Hellwig
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2015-01-10 17:11 UTC (permalink / raw)
  To: Sumit.Saxena, kashyap.desai; +Cc: martin.petersen, linux-scsi

This adds endianess annotations to all data structures, and a few
variables directly referencing them.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/megaraid/megaraid_sas.h        | 296 ++++++++++++++--------------
 drivers/scsi/megaraid/megaraid_sas_base.c   |   2 +-
 drivers/scsi/megaraid/megaraid_sas_fp.c     |  10 +-
 drivers/scsi/megaraid/megaraid_sas_fusion.c |   2 +-
 drivers/scsi/megaraid/megaraid_sas_fusion.h | 276 +++++++++++++-------------
 5 files changed, 293 insertions(+), 293 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
index ecc4321..81484f1 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -408,7 +408,7 @@ enum MR_PD_STATE {
  * defines the physical drive address structure
  */
 struct MR_PD_ADDRESS {
-	u16     deviceId;
+	__le16	deviceId;
 	u16     enclDeviceId;
 
 	union {
@@ -433,8 +433,8 @@ struct MR_PD_ADDRESS {
  * defines the physical drive list structure
  */
 struct MR_PD_LIST {
-	u32             size;
-	u32             count;
+	__le32		size;
+	__le32		count;
 	struct MR_PD_ADDRESS   addr[1];
 } __packed;
 
@@ -451,28 +451,28 @@ union  MR_LD_REF {
 	struct {
 		u8      targetId;
 		u8      reserved;
-		u16     seqNum;
+		__le16     seqNum;
 	};
-	u32     ref;
+	__le32     ref;
 } __packed;
 
 /*
  * defines the logical drive list structure
  */
 struct MR_LD_LIST {
-	u32     ldCount;
-	u32     reserved;
+	__le32     ldCount;
+	__le32     reserved;
 	struct {
 		union MR_LD_REF   ref;
 		u8          state;
 		u8          reserved[3];
-		u64         size;
+		__le64		size;
 	} ldList[MAX_LOGICAL_DRIVES_EXT];
 } __packed;
 
 struct MR_LD_TARGETID_LIST {
-	u32	size;
-	u32	count;
+	__le32	size;
+	__le32	count;
 	u8	pad[3];
 	u8	targetId[MAX_LOGICAL_DRIVES_EXT];
 };
@@ -553,7 +553,7 @@ struct megasas_ctrl_prop {
 	} OnOffProperties;
 	u8 autoSnapVDSpace;
 	u8 viewSpace;
-	u16 spinDownTime;
+	__le16 spinDownTime;
 	u8  reserved[24];
 } __packed;
 
@@ -567,10 +567,10 @@ struct megasas_ctrl_info {
 	 */
 	struct {
 
-		u16 vendor_id;
-		u16 device_id;
-		u16 sub_vendor_id;
-		u16 sub_device_id;
+		__le16 vendor_id;
+		__le16 device_id;
+		__le16 sub_vendor_id;
+		__le16 sub_device_id;
 		u8 reserved[24];
 
 	} __attribute__ ((packed)) pci;
@@ -611,8 +611,8 @@ struct megasas_ctrl_info {
 	/*
 	 * List of components residing in flash. All str are null terminated
 	 */
-	u32 image_check_word;
-	u32 image_component_count;
+	__le32 image_check_word;
+	__le32 image_component_count;
 
 	struct {
 
@@ -629,7 +629,7 @@ struct megasas_ctrl_info {
 	 * empty if a flash operation has not occurred. All stings are null
 	 * terminated
 	 */
-	u32 pending_image_component_count;
+	__le32 pending_image_component_count;
 
 	struct {
 
@@ -662,39 +662,39 @@ struct megasas_ctrl_info {
 
 	} __attribute__ ((packed)) hw_present;
 
-	u32 current_fw_time;
+	__le32 current_fw_time;
 
 	/*
 	 * Maximum data transfer sizes
 	 */
-	u16 max_concurrent_cmds;
-	u16 max_sge_count;
-	u32 max_request_size;
+	__le16 max_concurrent_cmds;
+	__le16 max_sge_count;
+	__le32 max_request_size;
 
 	/*
 	 * Logical and physical device counts
 	 */
-	u16 ld_present_count;
-	u16 ld_degraded_count;
-	u16 ld_offline_count;
+	__le16 ld_present_count;
+	__le16 ld_degraded_count;
+	__le16 ld_offline_count;
 
-	u16 pd_present_count;
-	u16 pd_disk_present_count;
-	u16 pd_disk_pred_failure_count;
-	u16 pd_disk_failed_count;
+	__le16 pd_present_count;
+	__le16 pd_disk_present_count;
+	__le16 pd_disk_pred_failure_count;
+	__le16 pd_disk_failed_count;
 
 	/*
 	 * Memory size information
 	 */
-	u16 nvram_size;
-	u16 memory_size;
-	u16 flash_size;
+	__le16 nvram_size;
+	__le16 memory_size;
+	__le16 flash_size;
 
 	/*
 	 * Error counters
 	 */
-	u16 mem_correctable_error_count;
-	u16 mem_uncorrectable_error_count;
+	__le16 mem_correctable_error_count;
+	__le16 mem_uncorrectable_error_count;
 
 	/*
 	 * Cluster information
@@ -705,7 +705,7 @@ struct megasas_ctrl_info {
 	/*
 	 * Additional max data transfer sizes
 	 */
-	u16 max_strips_per_io;
+	__le16 max_strips_per_io;
 
 	/*
 	 * Controller capabilities structures
@@ -805,7 +805,7 @@ struct megasas_ctrl_info {
 	* deviceInterface.portAddr, and the rest shall be
 	* populated in deviceInterfacePortAddr2.
 	*/
-	u64         deviceInterfacePortAddr2[8]; /*6a0h */
+	__le64	    deviceInterfacePortAddr2[8]; /*6a0h */
 	u8          reserved3[128];              /*6e0h */
 
 	struct {                                /*760h */
@@ -842,26 +842,26 @@ struct megasas_ctrl_info {
 		u16 reserved[6];
 	} pdsForRaidLevels;
 
-	u16 maxPds;                             /*780h */
-	u16 maxDedHSPs;                         /*782h */
-	u16 maxGlobalHSPs;                      /*784h */
-	u16 ddfSize;                            /*786h */
+	__le16 maxPds;                          /*780h */
+	__le16 maxDedHSPs;                      /*782h */
+	__le16 maxGlobalHSP;                    /*784h */
+	__le16 ddfSize;                         /*786h */
 	u8  maxLdsPerArray;                     /*788h */
 	u8  partitionsInDDF;                    /*789h */
 	u8  lockKeyBinding;                     /*78ah */
 	u8  maxPITsPerLd;                       /*78bh */
 	u8  maxViewsPerLd;                      /*78ch */
 	u8  maxTargetId;                        /*78dh */
-	u16 maxBvlVdSize;                       /*78eh */
+	__le16 maxBvlVdSize;                    /*78eh */
 
-	u16 maxConfigurableSSCSize;             /*790h */
-	u16 currentSSCsize;                     /*792h */
+	__le16 maxConfigurableSSCSize;          /*790h */
+	__le16 currentSSCsize;                  /*792h */
 
 	char    expanderFwVersion[12];          /*794h */
 
-	u16 PFKTrialTimeRemaining;              /*7A0h */
+	__le16 PFKTrialTimeRemaining;           /*7A0h */
 
-	u16 cacheMemorySize;                    /*7A2h */
+	__le16 cacheMemorySize;                 /*7A2h */
 
 	struct {                                /*7A4h */
 #if   defined(__BIG_ENDIAN_BITFIELD)
@@ -931,7 +931,7 @@ struct megasas_ctrl_info {
 	u8  temperatureROC;                     /*7C9h */
 	u8  temperatureCtrl;                    /*7CAh */
 	u8  reserved4;                          /*7CBh */
-	u16 maxConfigurablePds;                 /*7CCh */
+	__le16 maxConfigurablePds;              /*7CCh */
 
 
 	u8  reserved5[2];                       /*0x7CDh */
@@ -1172,22 +1172,22 @@ struct megasas_register_set {
 
 struct megasas_sge32 {
 
-	u32 phys_addr;
-	u32 length;
+	__le32 phys_addr;
+	__le32 length;
 
 } __attribute__ ((packed));
 
 struct megasas_sge64 {
 
-	u64 phys_addr;
-	u32 length;
+	__le64 phys_addr;
+	__le32 length;
 
 } __attribute__ ((packed));
 
 struct megasas_sge_skinny {
-	u64 phys_addr;
-	u32 length;
-	u32 flag;
+	__le64 phys_addr;
+	__le32 length;
+	__le32 flag;
 } __packed;
 
 union megasas_sgl {
@@ -1210,12 +1210,12 @@ struct megasas_header {
 	u8 cdb_len;		/*06h */
 	u8 sge_count;		/*07h */
 
-	u32 context;		/*08h */
-	u32 pad_0;		/*0Ch */
+	__le32 context;		/*08h */
+	__le32 pad_0;		/*0Ch */
 
-	u16 flags;		/*10h */
-	u16 timeout;		/*12h */
-	u32 data_xferlen;	/*14h */
+	__le16 flags;		/*10h */
+	__le16 timeout;		/*12h */
+	__le32 data_xferlen;	/*14h */
 
 } __attribute__ ((packed));
 
@@ -1248,7 +1248,7 @@ typedef union _MFI_CAPABILITIES {
 		u32     reserved:25;
 #endif
 	} mfi_capabilities;
-	u32     reg;
+	__le32		reg;
 } MFI_CAPABILITIES;
 
 struct megasas_init_frame {
@@ -1260,33 +1260,33 @@ struct megasas_init_frame {
 	u8 reserved_1;		/*03h */
 	MFI_CAPABILITIES driver_operations; /*04h*/
 
-	u32 context;		/*08h */
-	u32 pad_0;		/*0Ch */
+	__le32 context;		/*08h */
+	__le32 pad_0;		/*0Ch */
 
-	u16 flags;		/*10h */
-	u16 reserved_3;		/*12h */
-	u32 data_xfer_len;	/*14h */
+	__le16 flags;		/*10h */
+	__le16 reserved_3;	/*12h */
+	__le32 data_xfer_len;	/*14h */
 
-	u32 queue_info_new_phys_addr_lo;	/*18h */
-	u32 queue_info_new_phys_addr_hi;	/*1Ch */
-	u32 queue_info_old_phys_addr_lo;	/*20h */
-	u32 queue_info_old_phys_addr_hi;	/*24h */
+	__le32 queue_info_new_phys_addr_lo;	/*18h */
+	__le32 queue_info_new_phys_addr_hi;	/*1Ch */
+	__le32 queue_info_old_phys_addr_lo;	/*20h */
+	__le32 queue_info_old_phys_addr_hi;	/*24h */
 
-	u32 reserved_4[6];	/*28h */
+	__le32 reserved_4[6];	/*28h */
 
 } __attribute__ ((packed));
 
 struct megasas_init_queue_info {
 
-	u32 init_flags;		/*00h */
-	u32 reply_queue_entries;	/*04h */
+	__le32 init_flags;		/*00h */
+	__le32 reply_queue_entries;	/*04h */
 
-	u32 reply_queue_start_phys_addr_lo;	/*08h */
-	u32 reply_queue_start_phys_addr_hi;	/*0Ch */
-	u32 producer_index_phys_addr_lo;	/*10h */
-	u32 producer_index_phys_addr_hi;	/*14h */
-	u32 consumer_index_phys_addr_lo;	/*18h */
-	u32 consumer_index_phys_addr_hi;	/*1Ch */
+	__le32 reply_queue_start_phys_addr_lo;	/*08h */
+	__le32 reply_queue_start_phys_addr_hi;	/*0Ch */
+	__le32 producer_index_phys_addr_lo;	/*10h */
+	__le32 producer_index_phys_addr_hi;	/*14h */
+	__le32 consumer_index_phys_addr_lo;	/*18h */
+	__le32 consumer_index_phys_addr_hi;	/*1Ch */
 
 } __attribute__ ((packed));
 
@@ -1302,18 +1302,18 @@ struct megasas_io_frame {
 	u8 reserved_0;		/*06h */
 	u8 sge_count;		/*07h */
 
-	u32 context;		/*08h */
-	u32 pad_0;		/*0Ch */
+	__le32 context;		/*08h */
+	__le32 pad_0;		/*0Ch */
 
-	u16 flags;		/*10h */
-	u16 timeout;		/*12h */
-	u32 lba_count;		/*14h */
+	__le16 flags;		/*10h */
+	__le16 timeout;		/*12h */
+	__le32 lba_count;	/*14h */
 
-	u32 sense_buf_phys_addr_lo;	/*18h */
-	u32 sense_buf_phys_addr_hi;	/*1Ch */
+	__le32 sense_buf_phys_addr_lo;	/*18h */
+	__le32 sense_buf_phys_addr_hi;	/*1Ch */
 
-	u32 start_lba_lo;	/*20h */
-	u32 start_lba_hi;	/*24h */
+	__le32 start_lba_lo;	/*20h */
+	__le32 start_lba_hi;	/*24h */
 
 	union megasas_sgl sgl;	/*28h */
 
@@ -1331,15 +1331,15 @@ struct megasas_pthru_frame {
 	u8 cdb_len;		/*06h */
 	u8 sge_count;		/*07h */
 
-	u32 context;		/*08h */
-	u32 pad_0;		/*0Ch */
+	__le32 context;		/*08h */
+	__le32 pad_0;		/*0Ch */
 
-	u16 flags;		/*10h */
-	u16 timeout;		/*12h */
-	u32 data_xfer_len;	/*14h */
+	__le16 flags;		/*10h */
+	__le16 timeout;		/*12h */
+	__le32 data_xfer_len;	/*14h */
 
-	u32 sense_buf_phys_addr_lo;	/*18h */
-	u32 sense_buf_phys_addr_hi;	/*1Ch */
+	__le32 sense_buf_phys_addr_lo;	/*18h */
+	__le32 sense_buf_phys_addr_hi;	/*1Ch */
 
 	u8 cdb[16];		/*20h */
 	union megasas_sgl sgl;	/*30h */
@@ -1354,19 +1354,19 @@ struct megasas_dcmd_frame {
 	u8 reserved_1[4];	/*03h */
 	u8 sge_count;		/*07h */
 
-	u32 context;		/*08h */
-	u32 pad_0;		/*0Ch */
+	__le32 context;		/*08h */
+	__le32 pad_0;		/*0Ch */
 
-	u16 flags;		/*10h */
-	u16 timeout;		/*12h */
+	__le16 flags;		/*10h */
+	__le16 timeout;		/*12h */
 
-	u32 data_xfer_len;	/*14h */
-	u32 opcode;		/*18h */
+	__le32 data_xfer_len;	/*14h */
+	__le32 opcode;		/*18h */
 
 	union {			/*1Ch */
 		u8 b[12];
-		u16 s[6];
-		u32 w[3];
+		__le16 s[6];
+		__le32 w[3];
 	} mbox;
 
 	union megasas_sgl sgl;	/*28h */
@@ -1380,22 +1380,22 @@ struct megasas_abort_frame {
 	u8 cmd_status;		/*02h */
 
 	u8 reserved_1;		/*03h */
-	u32 reserved_2;		/*04h */
+	__le32 reserved_2;	/*04h */
 
-	u32 context;		/*08h */
-	u32 pad_0;		/*0Ch */
+	__le32 context;		/*08h */
+	__le32 pad_0;		/*0Ch */
 
-	u16 flags;		/*10h */
-	u16 reserved_3;		/*12h */
-	u32 reserved_4;		/*14h */
+	__le16 flags;		/*10h */
+	__le16 reserved_3;	/*12h */
+	__le32 reserved_4;	/*14h */
 
-	u32 abort_context;	/*18h */
-	u32 pad_1;		/*1Ch */
+	__le32 abort_context;	/*18h */
+	__le32 pad_1;		/*1Ch */
 
-	u32 abort_mfi_phys_addr_lo;	/*20h */
-	u32 abort_mfi_phys_addr_hi;	/*24h */
+	__le32 abort_mfi_phys_addr_lo;	/*20h */
+	__le32 abort_mfi_phys_addr_hi;	/*24h */
 
-	u32 reserved_5[6];	/*28h */
+	__le32 reserved_5[6];	/*28h */
 
 } __attribute__ ((packed));
 
@@ -1409,14 +1409,14 @@ struct megasas_smp_frame {
 	u8 reserved_2[3];	/*04h */
 	u8 sge_count;		/*07h */
 
-	u32 context;		/*08h */
-	u32 pad_0;		/*0Ch */
+	__le32 context;		/*08h */
+	__le32 pad_0;		/*0Ch */
 
-	u16 flags;		/*10h */
-	u16 timeout;		/*12h */
+	__le16 flags;		/*10h */
+	__le16 timeout;		/*12h */
 
-	u32 data_xfer_len;	/*14h */
-	u64 sas_addr;		/*18h */
+	__le32 data_xfer_len;	/*14h */
+	__le64 sas_addr;	/*18h */
 
 	union {
 		struct megasas_sge32 sge32[2];	/* [0]: resp [1]: req */
@@ -1436,16 +1436,16 @@ struct megasas_stp_frame {
 	u8 reserved_3[2];	/*05h */
 	u8 sge_count;		/*07h */
 
-	u32 context;		/*08h */
-	u32 pad_0;		/*0Ch */
+	__le32 context;		/*08h */
+	__le32 pad_0;		/*0Ch */
 
-	u16 flags;		/*10h */
-	u16 timeout;		/*12h */
+	__le16 flags;		/*10h */
+	__le16 timeout;		/*12h */
 
-	u32 data_xfer_len;	/*14h */
+	__le32 data_xfer_len;	/*14h */
 
-	u16 fis[10];		/*18h */
-	u32 stp_flags;
+	__le16 fis[10];		/*18h */
+	__le32 stp_flags;
 
 	union {
 		struct megasas_sge32 sge32[2];	/* [0]: resp [1]: data */
@@ -1489,18 +1489,18 @@ union megasas_evt_class_locale {
 } __attribute__ ((packed));
 
 struct megasas_evt_log_info {
-	u32 newest_seq_num;
-	u32 oldest_seq_num;
-	u32 clear_seq_num;
-	u32 shutdown_seq_num;
-	u32 boot_seq_num;
+	__le32 newest_seq_num;
+	__le32 oldest_seq_num;
+	__le32 clear_seq_num;
+	__le32 shutdown_seq_num;
+	__le32 boot_seq_num;
 
 } __attribute__ ((packed));
 
 struct megasas_progress {
 
-	u16 progress;
-	u16 elapsed_seconds;
+	__le16 progress;
+	__le16 elapsed_seconds;
 
 } __attribute__ ((packed));
 
@@ -1521,9 +1521,9 @@ struct megasas_evtarg_pd {
 
 struct megasas_evt_detail {
 
-	u32 seq_num;
-	u32 time_stamp;
-	u32 code;
+	__le32 seq_num;
+	__le32 time_stamp;
+	__le32 code;
 	union megasas_evt_class_locale cl;
 	u8 arg_type;
 	u8 reserved1[15];
@@ -1542,18 +1542,18 @@ struct megasas_evt_detail {
 
 		struct {
 			struct megasas_evtarg_ld ld;
-			u64 count;
+			__le64 count;
 		} __attribute__ ((packed)) ld_count;
 
 		struct {
-			u64 lba;
+			__le64 lba;
 			struct megasas_evtarg_ld ld;
 		} __attribute__ ((packed)) ld_lba;
 
 		struct {
 			struct megasas_evtarg_ld ld;
-			u32 prevOwner;
-			u32 newOwner;
+			__le32 prevOwner;
+			__le32 newOwner;
 		} __attribute__ ((packed)) ld_owner;
 
 		struct {
@@ -1610,7 +1610,7 @@ struct megasas_evt_detail {
 
 		struct {
 			u16 vendorId;
-			u16 deviceId;
+			__le16 deviceId;
 			u16 subVendorId;
 			u16 subDeviceId;
 		} __attribute__ ((packed)) pci;
@@ -1630,9 +1630,9 @@ struct megasas_evt_detail {
 		} __attribute__ ((packed)) ecc;
 
 		u8 b[96];
-		u16 s[48];
-		u32 w[24];
-		u64 d[12];
+		__le16 s[48];
+		__le32 w[24];
+		__le64 d[12];
 	} args;
 
 	char description[128];
@@ -1651,9 +1651,9 @@ struct megasas_irq_context {
 
 struct megasas_instance {
 
-	u32 *producer;
+	__le32 *producer;
 	dma_addr_t producer_h;
-	u32 *consumer;
+	__le32 *consumer;
 	dma_addr_t consumer_h;
 	struct MR_LD_VF_AFFILIATION *vf_affiliation;
 	dma_addr_t vf_affiliation_h;
@@ -1662,7 +1662,7 @@ struct megasas_instance {
 	struct MR_CTRL_HB_HOST_MEM *hb_host_mem;
 	dma_addr_t hb_host_mem_h;
 
-	u32 *reply_queue;
+	__le32 *reply_queue;
 	dma_addr_t reply_queue_h;
 
 	u32 *crash_dump_buf;
@@ -1963,10 +1963,10 @@ u8 MR_TargetIdToLdGet(u32 ldTgtId, struct MR_DRV_RAID_MAP_ALL *map);
 struct MR_LD_RAID *MR_LdRaidGet(u32 ld, struct MR_DRV_RAID_MAP_ALL *map);
 u16 MR_ArPdGet(u32 ar, u32 arm, struct MR_DRV_RAID_MAP_ALL *map);
 u16 MR_LdSpanArrayGet(u32 ld, u32 span, struct MR_DRV_RAID_MAP_ALL *map);
-u16 MR_PdDevHandleGet(u32 pd, struct MR_DRV_RAID_MAP_ALL *map);
+__le16 MR_PdDevHandleGet(u32 pd, struct MR_DRV_RAID_MAP_ALL *map);
 u16 MR_GetLDTgtId(u32 ld, struct MR_DRV_RAID_MAP_ALL *map);
 
-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 *in_info);
 void mr_update_load_balance_params(struct MR_DRV_RAID_MAP_ALL *map,
 	struct LD_LOAD_BALANCE_INFO *lbInfo);
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 875db92..cb7d0c4 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4262,7 +4262,7 @@ int megasas_set_crash_dump_params(struct megasas_instance *instance,
 static int
 megasas_issue_init_mfi(struct megasas_instance *instance)
 {
-	u32 context;
+	__le32 context;
 
 	struct megasas_cmd *cmd;
 
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c
index 4f72287..e9138a2 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -142,7 +142,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;
 }
@@ -735,7 +735,7 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance *instance, u32 ld,
 	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;
 
 	if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER ||
@@ -817,7 +817,7 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 ld, u64 stripRow,
 	u8	    retval = TRUE;
 	u8          do_invader = 0;
 	u64	    *pdBlock = &io_info->pdBlock;
-	u16	    *pDevHandle = &io_info->devHandle;
+	__le16	    *pDevHandle = &io_info->devHandle;
 
 	if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER ||
 		instance->pdev->device == PCI_DEVICE_ID_LSI_FURY))
@@ -1341,11 +1341,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;
 
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 675b5e7..983635f 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -1670,7 +1670,7 @@ megasas_build_dcdb_fusion(struct megasas_instance *instance,
 	struct MR_DRV_RAID_MAP_ALL *local_map_ptr;
 	struct fusion_context *fusion = instance->ctrl_context;
 	u8                          span, physArm;
-	u16                         devHandle;
+	__le16                      devHandle;
 	u32                         ld, arRef, pd;
 	struct MR_LD_RAID                  *raid;
 	struct RAID_CONTEXT                *pRAID_Context;
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h b/drivers/scsi/megaraid/megaraid_sas_fusion.h
index 56e6db2..d62285e 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.h
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h
@@ -104,18 +104,18 @@ struct RAID_CONTEXT {
 	u8	nseg:4;
 #endif
 	u8	resvd0;
-	u16     timeoutValue;
+	__le16	timeoutValue;
 	u8      regLockFlags;
 	u8      resvd1;
-	u16     VirtualDiskTgtId;
-	u64     regLockRowLBA;
-	u32     regLockLength;
-	u16     nextLMId;
+	__le16	VirtualDiskTgtId;
+	__le64	regLockRowLBA;
+	__le32	regLockLength;
+	__le16	nextLMId;
 	u8      exStatus;
 	u8      status;
 	u8      RAIDFlags;
 	u8      numSGE;
-	u16	configSeqNum;
+	__le16	configSeqNum;
 	u8      spanArm;
 	u8      resvd2[3];
 };
@@ -182,61 +182,61 @@ enum REGION_TYPE {
 #define MPI2_WRSEQ_6TH_KEY_VALUE                (0xD)
 
 struct MPI25_IEEE_SGE_CHAIN64 {
-	u64                     Address;
-	u32                     Length;
-	u16                     Reserved1;
+	__le64			Address;
+	__le32			Length;
+	__le16			Reserved1;
 	u8                      NextChainOffset;
 	u8                      Flags;
 };
 
 struct MPI2_SGE_SIMPLE_UNION {
-	u32                     FlagsLength;
+	__le32                     FlagsLength;
 	union {
-		u32                 Address32;
-		u64                 Address64;
+		__le32                 Address32;
+		__le64                 Address64;
 	} u;
 };
 
 struct MPI2_SCSI_IO_CDB_EEDP32 {
 	u8                      CDB[20];                    /* 0x00 */
-	u32                     PrimaryReferenceTag;        /* 0x14 */
-	u16                     PrimaryApplicationTag;      /* 0x18 */
-	u16                     PrimaryApplicationTagMask;  /* 0x1A */
-	u32                     TransferLength;             /* 0x1C */
+	__be32			PrimaryReferenceTag;        /* 0x14 */
+	__be16			PrimaryApplicationTag;      /* 0x18 */
+	__be16			PrimaryApplicationTagMask;  /* 0x1A */
+	__le32			TransferLength;             /* 0x1C */
 };
 
 struct MPI2_SGE_CHAIN_UNION {
-	u16                     Length;
+	__le16			Length;
 	u8                      NextChainOffset;
 	u8                      Flags;
 	union {
-		u32                 Address32;
-		u64                 Address64;
+		__le32		Address32;
+		__le64		Address64;
 	} u;
 };
 
 struct MPI2_IEEE_SGE_SIMPLE32 {
-	u32                     Address;
-	u32                     FlagsLength;
+	__le32			Address;
+	__le32			FlagsLength;
 };
 
 struct MPI2_IEEE_SGE_CHAIN32 {
-	u32                     Address;
-	u32                     FlagsLength;
+	__le32			Address;
+	__le32			FlagsLength;
 };
 
 struct MPI2_IEEE_SGE_SIMPLE64 {
-	u64                     Address;
-	u32                     Length;
-	u16                     Reserved1;
+	__le64			Address;
+	__le32			Length;
+	__le16			Reserved1;
 	u8                      Reserved2;
 	u8                      Flags;
 };
 
 struct MPI2_IEEE_SGE_CHAIN64 {
-	u64                     Address;
-	u32                     Length;
-	u16                     Reserved1;
+	__le64			Address;
+	__le32			Length;
+	__le16			Reserved1;
 	u8                      Reserved2;
 	u8                      Flags;
 };
@@ -269,34 +269,34 @@ union MPI2_SCSI_IO_CDB_UNION {
  * Total SGE count will be one less than  _MPI2_SCSI_IO_REQUEST
  */
 struct MPI2_RAID_SCSI_IO_REQUEST {
-	u16                     DevHandle;                      /* 0x00 */
+	__le16			DevHandle;                      /* 0x00 */
 	u8                      ChainOffset;                    /* 0x02 */
 	u8                      Function;                       /* 0x03 */
-	u16                     Reserved1;                      /* 0x04 */
+	__le16			Reserved1;                      /* 0x04 */
 	u8                      Reserved2;                      /* 0x06 */
 	u8                      MsgFlags;                       /* 0x07 */
 	u8                      VP_ID;                          /* 0x08 */
 	u8                      VF_ID;                          /* 0x09 */
-	u16                     Reserved3;                      /* 0x0A */
-	u32                     SenseBufferLowAddress;          /* 0x0C */
-	u16                     SGLFlags;                       /* 0x10 */
+	__le16			Reserved3;                      /* 0x0A */
+	__le32			SenseBufferLowAddress;          /* 0x0C */
+	__le16			SGLFlags;                       /* 0x10 */
 	u8                      SenseBufferLength;              /* 0x12 */
 	u8                      Reserved4;                      /* 0x13 */
 	u8                      SGLOffset0;                     /* 0x14 */
 	u8                      SGLOffset1;                     /* 0x15 */
 	u8                      SGLOffset2;                     /* 0x16 */
 	u8                      SGLOffset3;                     /* 0x17 */
-	u32                     SkipCount;                      /* 0x18 */
-	u32                     DataLength;                     /* 0x1C */
-	u32                     BidirectionalDataLength;        /* 0x20 */
-	u16                     IoFlags;                        /* 0x24 */
-	u16                     EEDPFlags;                      /* 0x26 */
-	u32                     EEDPBlockSize;                  /* 0x28 */
-	u32                     SecondaryReferenceTag;          /* 0x2C */
-	u16                     SecondaryApplicationTag;        /* 0x30 */
-	u16                     ApplicationTagTranslationMask;  /* 0x32 */
+	__le32			SkipCount;                      /* 0x18 */
+	__le32			DataLength;                     /* 0x1C */
+	__le32			BidirectionalDataLength;        /* 0x20 */
+	__le16			IoFlags;                        /* 0x24 */
+	__le16			EEDPFlags;                      /* 0x26 */
+	__le32			EEDPBlockSize;                  /* 0x28 */
+	__le32			SecondaryReferenceTag;          /* 0x2C */
+	__le16			SecondaryApplicationTag;        /* 0x30 */
+	__le16			ApplicationTagTranslationMask;  /* 0x32 */
 	u8                      LUN[8];                         /* 0x34 */
-	u32                     Control;                        /* 0x3C */
+	__le32			Control;                        /* 0x3C */
 	union MPI2_SCSI_IO_CDB_UNION  CDB;			/* 0x40 */
 	struct RAID_CONTEXT	RaidContext;                    /* 0x60 */
 	union MPI2_SGE_IO_UNION       SGL;			/* 0x80 */
@@ -315,45 +315,45 @@ struct MEGASAS_RAID_MFA_IO_REQUEST_DESCRIPTOR {
 struct MPI2_DEFAULT_REQUEST_DESCRIPTOR {
 	u8              RequestFlags;               /* 0x00 */
 	u8              MSIxIndex;                  /* 0x01 */
-	u16             SMID;                       /* 0x02 */
-	u16             LMID;                       /* 0x04 */
-	u16             DescriptorTypeDependent;    /* 0x06 */
+	__le16		SMID;                       /* 0x02 */
+	__le16		LMID;                       /* 0x04 */
+	__le16		DescriptorTypeDependent;    /* 0x06 */
 };
 
 /* High Priority Request Descriptor */
 struct MPI2_HIGH_PRIORITY_REQUEST_DESCRIPTOR {
 	u8              RequestFlags;               /* 0x00 */
 	u8              MSIxIndex;                  /* 0x01 */
-	u16             SMID;                       /* 0x02 */
-	u16             LMID;                       /* 0x04 */
-	u16             Reserved1;                  /* 0x06 */
+	__le16		SMID;                       /* 0x02 */
+	__le16		LMID;                       /* 0x04 */
+	__le16		Reserved1;                  /* 0x06 */
 };
 
 /* SCSI IO Request Descriptor */
 struct MPI2_SCSI_IO_REQUEST_DESCRIPTOR {
 	u8              RequestFlags;               /* 0x00 */
 	u8              MSIxIndex;                  /* 0x01 */
-	u16             SMID;                       /* 0x02 */
-	u16             LMID;                       /* 0x04 */
-	u16             DevHandle;                  /* 0x06 */
+	__le16		SMID;                       /* 0x02 */
+	__le16		LMID;                       /* 0x04 */
+	__le16		DevHandle;                  /* 0x06 */
 };
 
 /* SCSI Target Request Descriptor */
 struct MPI2_SCSI_TARGET_REQUEST_DESCRIPTOR {
 	u8              RequestFlags;               /* 0x00 */
 	u8              MSIxIndex;                  /* 0x01 */
-	u16             SMID;                       /* 0x02 */
-	u16             LMID;                       /* 0x04 */
-	u16             IoIndex;                    /* 0x06 */
+	__le16		SMID;                       /* 0x02 */
+	__le16		LMID;                       /* 0x04 */
+	__le16		IoIndex;                    /* 0x06 */
 };
 
 /* RAID Accelerator Request Descriptor */
 struct MPI2_RAID_ACCEL_REQUEST_DESCRIPTOR {
 	u8              RequestFlags;               /* 0x00 */
 	u8              MSIxIndex;                  /* 0x01 */
-	u16             SMID;                       /* 0x02 */
-	u16             LMID;                       /* 0x04 */
-	u16             Reserved;                   /* 0x06 */
+	__le16		SMID;                       /* 0x02 */
+	__le16		LMID;                       /* 0x04 */
+	__le16		Reserved;                   /* 0x06 */
 };
 
 /* union of Request Descriptors */
@@ -366,10 +366,10 @@ union MEGASAS_REQUEST_DESCRIPTOR_UNION {
 	struct MEGASAS_RAID_MFA_IO_REQUEST_DESCRIPTOR      MFAIo;
 	union {
 		struct {
-			u32 low;
-			u32 high;
+			__le32 low;
+			__le32 high;
 		} u;
-		u64 Words;
+		__le64 Words;
 	};
 };
 
@@ -377,35 +377,35 @@ union MEGASAS_REQUEST_DESCRIPTOR_UNION {
 struct MPI2_DEFAULT_REPLY_DESCRIPTOR {
 	u8              ReplyFlags;                 /* 0x00 */
 	u8              MSIxIndex;                  /* 0x01 */
-	u16             DescriptorTypeDependent1;   /* 0x02 */
-	u32             DescriptorTypeDependent2;   /* 0x04 */
+	__le16		DescriptorTypeDependent1;   /* 0x02 */
+	__le32		DescriptorTypeDependent2;   /* 0x04 */
 };
 
 /* Address Reply Descriptor */
 struct MPI2_ADDRESS_REPLY_DESCRIPTOR {
 	u8              ReplyFlags;                 /* 0x00 */
 	u8              MSIxIndex;                  /* 0x01 */
-	u16             SMID;                       /* 0x02 */
-	u32             ReplyFrameAddress;          /* 0x04 */
+	__le16		SMID;                       /* 0x02 */
+	__le32		ReplyFrameAddress;          /* 0x04 */
 };
 
 /* SCSI IO Success Reply Descriptor */
 struct MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR {
 	u8              ReplyFlags;                 /* 0x00 */
 	u8              MSIxIndex;                  /* 0x01 */
-	u16             SMID;                       /* 0x02 */
-	u16             TaskTag;                    /* 0x04 */
-	u16             Reserved1;                  /* 0x06 */
+	__le16		SMID;                       /* 0x02 */
+	__le16		TaskTag;                    /* 0x04 */
+	__le16		Reserved1;                  /* 0x06 */
 };
 
 /* TargetAssist Success Reply Descriptor */
 struct MPI2_TARGETASSIST_SUCCESS_REPLY_DESCRIPTOR {
 	u8              ReplyFlags;                 /* 0x00 */
 	u8              MSIxIndex;                  /* 0x01 */
-	u16             SMID;                       /* 0x02 */
+	__le16		SMID;                       /* 0x02 */
 	u8              SequenceNumber;             /* 0x04 */
 	u8              Reserved1;                  /* 0x05 */
-	u16             IoIndex;                    /* 0x06 */
+	__le16		IoIndex;                    /* 0x06 */
 };
 
 /* Target Command Buffer Reply Descriptor */
@@ -414,16 +414,16 @@ struct MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR {
 	u8              MSIxIndex;                  /* 0x01 */
 	u8              VP_ID;                      /* 0x02 */
 	u8              Flags;                      /* 0x03 */
-	u16             InitiatorDevHandle;         /* 0x04 */
-	u16             IoIndex;                    /* 0x06 */
+	__le16		InitiatorDevHandle;         /* 0x04 */
+	__le16		IoIndex;                    /* 0x06 */
 };
 
 /* RAID Accelerator Success Reply Descriptor */
 struct MPI2_RAID_ACCELERATOR_SUCCESS_REPLY_DESCRIPTOR {
 	u8              ReplyFlags;                 /* 0x00 */
 	u8              MSIxIndex;                  /* 0x01 */
-	u16             SMID;                       /* 0x02 */
-	u32             Reserved;                   /* 0x04 */
+	__le16		SMID;                       /* 0x02 */
+	__le32		Reserved;                   /* 0x04 */
 };
 
 /* union of Reply Descriptors */
@@ -435,7 +435,7 @@ union MPI2_REPLY_DESCRIPTORS_UNION {
 	struct MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR TargetCommandBuffer;
 	struct MPI2_RAID_ACCELERATOR_SUCCESS_REPLY_DESCRIPTOR
 	RAIDAcceleratorSuccess;
-	u64                                             Words;
+	__le64                                             Words;
 };
 
 /* IOCInit Request message */
@@ -444,28 +444,28 @@ struct MPI2_IOC_INIT_REQUEST {
 	u8                      Reserved1;                      /* 0x01 */
 	u8                      ChainOffset;                    /* 0x02 */
 	u8                      Function;                       /* 0x03 */
-	u16                     Reserved2;                      /* 0x04 */
+	__le16			Reserved2;                      /* 0x04 */
 	u8                      Reserved3;                      /* 0x06 */
 	u8                      MsgFlags;                       /* 0x07 */
 	u8                      VP_ID;                          /* 0x08 */
 	u8                      VF_ID;                          /* 0x09 */
-	u16                     Reserved4;                      /* 0x0A */
-	u16                     MsgVersion;                     /* 0x0C */
-	u16                     HeaderVersion;                  /* 0x0E */
+	__le16			Reserved4;                      /* 0x0A */
+	__le16			MsgVersion;                     /* 0x0C */
+	__le16			HeaderVersion;                  /* 0x0E */
 	u32                     Reserved5;                      /* 0x10 */
-	u16                     Reserved6;                      /* 0x14 */
+	__le16			Reserved6;                      /* 0x14 */
 	u8                      Reserved7;                      /* 0x16 */
 	u8                      HostMSIxVectors;                /* 0x17 */
-	u16                     Reserved8;                      /* 0x18 */
-	u16                     SystemRequestFrameSize;         /* 0x1A */
-	u16                     ReplyDescriptorPostQueueDepth;  /* 0x1C */
-	u16                     ReplyFreeQueueDepth;            /* 0x1E */
-	u32                     SenseBufferAddressHigh;         /* 0x20 */
-	u32                     SystemReplyAddressHigh;         /* 0x24 */
-	u64                     SystemRequestFrameBaseAddress;  /* 0x28 */
-	u64                     ReplyDescriptorPostQueueAddress;/* 0x30 */
-	u64                     ReplyFreeQueueAddress;          /* 0x38 */
-	u64                     TimeStamp;                      /* 0x40 */
+	__le16			Reserved8;                      /* 0x18 */
+	__le16			SystemRequestFrameSize;         /* 0x1A */
+	__le16			ReplyDescriptorPostQueueDepth;  /* 0x1C */
+	__le16			ReplyFreeQueueDepth;            /* 0x1E */
+	__le32			SenseBufferAddressHigh;         /* 0x20 */
+	__le32			SystemReplyAddressHigh;         /* 0x24 */
+	__le64			SystemRequestFrameBaseAddress;  /* 0x28 */
+	__le64			ReplyDescriptorPostQueueAddress;/* 0x30 */
+	__le64			ReplyFreeQueueAddress;          /* 0x38 */
+	__le64			TimeStamp;                      /* 0x40 */
 };
 
 /* mrpriv defines */
@@ -491,41 +491,41 @@ struct MPI2_IOC_INIT_REQUEST {
 #define MR_DCMD_LD_VF_MAP_GET_ALL_LDS       0x03150200
 
 struct MR_DEV_HANDLE_INFO {
-	u16     curDevHdl;
+	__le16	curDevHdl;
 	u8      validHandles;
 	u8      reserved;
-	u16     devHandle[2];
+	__le16	devHandle[2];
 };
 
 struct MR_ARRAY_INFO {
-	u16      pd[MAX_RAIDMAP_ROW_SIZE];
+	__le16	pd[MAX_RAIDMAP_ROW_SIZE];
 };
 
 struct MR_QUAD_ELEMENT {
-	u64     logStart;
-	u64     logEnd;
-	u64     offsetInSpan;
-	u32     diff;
-	u32     reserved1;
+	__le64     logStart;
+	__le64     logEnd;
+	__le64     offsetInSpan;
+	__le32     diff;
+	__le32     reserved1;
 };
 
 struct MR_SPAN_INFO {
-	u32             noElements;
-	u32             reserved1;
+	__le32             noElements;
+	__le32             reserved1;
 	struct MR_QUAD_ELEMENT quad[MAX_RAIDMAP_SPAN_DEPTH];
 };
 
 struct MR_LD_SPAN {
-	u64      startBlk;
-	u64      numBlks;
-	u16      arrayRef;
+	__le64	 startBlk;
+	__le64	 numBlks;
+	__le16	 arrayRef;
 	u8       spanRowSize;
 	u8       spanRowDataSize;
 	u8       reserved[4];
 };
 
 struct MR_SPAN_BLOCK_INFO {
-	u64          num_rows;
+	__le64          num_rows;
 	struct MR_LD_SPAN   span;
 	struct MR_SPAN_INFO block_span_info;
 };
@@ -558,8 +558,8 @@ struct MR_LD_RAID {
 		u32     reserved4:7;
 #endif
 	} capability;
-	u32     reserved6;
-	u64     size;
+	__le32     reserved6;
+	__le64     size;
 	u8      spanDepth;
 	u8      level;
 	u8      stripeShift;
@@ -568,12 +568,12 @@ struct MR_LD_RAID {
 	u8      writeMode;
 	u8      PRL;
 	u8      SRL;
-	u16     targetId;
+	__le16     targetId;
 	u8      ldState;
 	u8      regTypeReqOnWrite;
 	u8      modFactor;
 	u8	regTypeReqOnRead;
-	u16     seqNum;
+	__le16     seqNum;
 
 	struct {
 		u32 ldSyncRequired:1;
@@ -592,20 +592,20 @@ struct MR_LD_SPAN_MAP {
 };
 
 struct MR_FW_RAID_MAP {
-	u32                 totalSize;
+	__le32                 totalSize;
 	union {
 		struct {
-			u32         maxLd;
-			u32         maxSpanDepth;
-			u32         maxRowSize;
-			u32         maxPdCount;
-			u32         maxArrays;
+			__le32         maxLd;
+			__le32         maxSpanDepth;
+			__le32         maxRowSize;
+			__le32         maxPdCount;
+			__le32         maxArrays;
 		} validationInfo;
-		u32             version[5];
+		__le32             version[5];
 	};
 
-	u32                 ldCount;
-	u32                 Reserved1;
+	__le32                 ldCount;
+	__le32                 Reserved1;
 	u8                  ldTgtIdToLd[MAX_RAIDMAP_LOGICAL_DRIVES+
 					MAX_RAIDMAP_VIEWS];
 	u8                  fpPdIoTimeoutSec;
@@ -620,7 +620,7 @@ struct IO_REQUEST_INFO {
 	u32 numBlocks;
 	u16 ldTgtId;
 	u8 isRead;
-	u16 devHandle;
+	__le16 devHandle;
 	u64 pdBlock;
 	u8 fpOkForIo;
 	u8 IoforUnevenSpan;
@@ -634,7 +634,7 @@ struct IO_REQUEST_INFO {
 struct MR_LD_TARGET_SYNC {
 	u8  targetId;
 	u8  reserved;
-	u16 seqNum;
+	__le16 seqNum;
 };
 
 #define IEEE_SGE_FLAGS_ADDR_MASK            (0x03)
@@ -720,27 +720,27 @@ struct MR_DRV_RAID_MAP {
 	 * This feild will be manupulated by driver for ext raid map,
 	 * else pick the value from firmware raid map.
 	 */
-	u32                 totalSize;
+	__le32                 totalSize;
 
 	union {
 	struct {
-		u32         maxLd;
-		u32         maxSpanDepth;
-		u32         maxRowSize;
-		u32         maxPdCount;
-		u32         maxArrays;
+		__le32         maxLd;
+		__le32         maxSpanDepth;
+		__le32         maxRowSize;
+		__le32         maxPdCount;
+		__le32         maxArrays;
 	} validationInfo;
-	u32             version[5];
+	__le32             version[5];
 	};
 
 	/* timeout value used by driver in FP IOs*/
 	u8                  fpPdIoTimeoutSec;
 	u8                  reserved2[7];
 
-	u16                 ldCount;
-	u16                 arCount;
-	u16                 spanCount;
-	u16                 reserve3;
+	__le16                 ldCount;
+	__le16                 arCount;
+	__le16                 spanCount;
+	__le16                 reserve3;
 
 	struct MR_DEV_HANDLE_INFO  devHndlInfo[MAX_RAIDMAP_PHYSICAL_DEVICES];
 	u8                  ldTgtIdToLd[MAX_LOGICAL_DRIVES_EXT];
@@ -779,10 +779,10 @@ struct MR_FW_RAID_MAP_EXT {
 	u8                  fpPdIoTimeoutSec;
 	u8                  reserved2[7];
 
-	u16                 ldCount;
-	u16                 arCount;
-	u16                 spanCount;
-	u16                 reserve3;
+	__le16                 ldCount;
+	__le16                 arCount;
+	__le16                 spanCount;
+	__le16                 reserve3;
 
 	struct MR_DEV_HANDLE_INFO  devHndlInfo[MAX_RAIDMAP_PHYSICAL_DEVICES];
 	u8                  ldTgtIdToLd[MAX_LOGICAL_DRIVES_EXT];
@@ -839,10 +839,10 @@ struct fusion_context {
 };
 
 union desc_value {
-	u64 word;
+	__le64 word;
 	struct {
-		u32 low;
-		u32 high;
+		__le32 low;
+		__le32 high;
 	} u;
 };
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 04/10] megaraid_sas: add endianess conversions for all ones
  2015-01-10 17:11 megaraid_sas: sparse annotations and endianess fixes Christoph Hellwig
                   ` (2 preceding siblings ...)
  2015-01-10 17:11 ` [PATCH 03/10] megaraid_sas: add endianess annotations Christoph Hellwig
@ 2015-01-10 17:11 ` Christoph Hellwig
  2015-01-13  7:21   ` Sumit Saxena
  2015-01-10 17:11 ` [PATCH 05/10] megaraid_sas: move endianess conversion into caller of megasas_get_seq_num Christoph Hellwig
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2015-01-10 17:11 UTC (permalink / raw)
  To: Sumit.Saxena, kashyap.desai; +Cc: martin.petersen, linux-scsi

Add noop conversions for all ones to make sparse happy.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/megaraid/megaraid_sas_base.c   | 2 +-
 drivers/scsi/megaraid/megaraid_sas_fp.c     | 7 ++++---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 9 +++++----
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index cb7d0c4..a6556ea 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1232,7 +1232,7 @@ megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp,
 	*/
 	if (scp->device->type == TYPE_TAPE) {
 		if ((scp->request->timeout / HZ) > 0xFFFF)
-			pthru->timeout = 0xFFFF;
+			pthru->timeout = cpu_to_le16(0xFFFF);
 		else
 			pthru->timeout = cpu_to_le16(scp->request->timeout / HZ);
 	}
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c
index e9138a2..2001ffb 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -769,7 +769,7 @@ 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 &&
 			(raid->regTypeReqOnRead != REGION_TYPE_UNUSED))))
@@ -864,7 +864,8 @@ 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 &&
 			(raid->regTypeReqOnRead != REGION_TYPE_UNUSED))))
@@ -1109,7 +1110,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) {
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 983635f..82439f9 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -464,7 +464,7 @@ megasas_alloc_cmds_fusion(struct megasas_instance *instance)
 
 	reply_desc = fusion->reply_frames_desc;
 	for (i = 0; i < fusion->reply_q_depth * count; i++, reply_desc++)
-		reply_desc->Words = ULLONG_MAX;
+		reply_desc->Words = cpu_to_le64(ULLONG_MAX);
 
 	io_frames_sz = fusion->io_frames_alloc_sz;
 
@@ -1995,7 +1995,8 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex)
 
 	num_completed = 0;
 
-	while ((d_val.u.low != UINT_MAX) && (d_val.u.high != UINT_MAX)) {
+	while (d_val.u.low != cpu_to_le32(UINT_MAX) &&
+	       d_val.u.high != cpu_to_le32(UINT_MAX)) {
 		smid = le16_to_cpu(reply_desc->SMID);
 
 		cmd_fusion = fusion->cmd_list[smid - 1];
@@ -2063,7 +2064,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex)
 		    fusion->reply_q_depth)
 			fusion->last_reply_idx[MSIxIndex] = 0;
 
-		desc->Words = ULLONG_MAX;
+		desc->Words = cpu_to_le64(ULLONG_MAX);
 		num_completed++;
 		threshold_reply_count++;
 
@@ -2505,7 +2506,7 @@ void  megasas_reset_reply_desc(struct megasas_instance *instance)
 		fusion->last_reply_idx[i] = 0;
 	reply_desc = fusion->reply_frames_desc;
 	for (i = 0 ; i < fusion->reply_q_depth * count; i++, reply_desc++)
-		reply_desc->Words = ULLONG_MAX;
+		reply_desc->Words = cpu_to_le64(ULLONG_MAX);
 }
 
 /* Check for a second path that is currently UP */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 05/10] megaraid_sas: move endianess conversion into caller of megasas_get_seq_num
  2015-01-10 17:11 megaraid_sas: sparse annotations and endianess fixes Christoph Hellwig
                   ` (3 preceding siblings ...)
  2015-01-10 17:11 ` [PATCH 04/10] megaraid_sas: add endianess conversions for all ones Christoph Hellwig
@ 2015-01-10 17:11 ` Christoph Hellwig
  2015-01-13  7:23   ` Sumit Saxena
  2015-01-10 17:11 ` [PATCH 06/10] megaraid_sas: bytewise or should be done on native endian variables Christoph Hellwig
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2015-01-10 17:11 UTC (permalink / raw)
  To: Sumit.Saxena, kashyap.desai; +Cc: martin.petersen, linux-scsi

Converting structure fields in place is always a bad idea, and in this case
by moving it into the only caller we also only have to do a single byte
swap as most fields of this structure are never used.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index a6556ea..548d033 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4823,11 +4823,11 @@ megasas_get_seq_num(struct megasas_instance *instance,
 		/*
 		 * Copy the data back into callers buffer
 		 */
-		eli->newest_seq_num = le32_to_cpu(el_info->newest_seq_num);
-		eli->oldest_seq_num = le32_to_cpu(el_info->oldest_seq_num);
-		eli->clear_seq_num = le32_to_cpu(el_info->clear_seq_num);
-		eli->shutdown_seq_num = le32_to_cpu(el_info->shutdown_seq_num);
-		eli->boot_seq_num = le32_to_cpu(el_info->boot_seq_num);
+		eli->newest_seq_num = el_info->newest_seq_num;
+		eli->oldest_seq_num = el_info->oldest_seq_num;
+		eli->clear_seq_num = el_info->clear_seq_num;
+		eli->shutdown_seq_num = el_info->shutdown_seq_num;
+		eli->boot_seq_num = el_info->boot_seq_num;
 	}
 
 	pci_free_consistent(instance->pdev, sizeof(struct megasas_evt_log_info),
@@ -4991,7 +4991,7 @@ static int megasas_start_aen(struct megasas_instance *instance)
 	class_locale.members.class = MR_EVT_CLASS_DEBUG;
 
 	return megasas_register_aen(instance,
-			eli.newest_seq_num + 1,
+			le32_to_cpu(eli.newest_seq_num) + 1,
 			class_locale.word);
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 06/10] megaraid_sas: bytewise or should be done on native endian variables
  2015-01-10 17:11 megaraid_sas: sparse annotations and endianess fixes Christoph Hellwig
                   ` (4 preceding siblings ...)
  2015-01-10 17:11 ` [PATCH 05/10] megaraid_sas: move endianess conversion into caller of megasas_get_seq_num Christoph Hellwig
@ 2015-01-10 17:11 ` Christoph Hellwig
  2015-01-14 11:01   ` Sumit Saxena
  2015-01-10 17:11 ` [PATCH 07/10] megaraid_sas: add missing byte swaps to the sriov code Christoph Hellwig
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2015-01-10 17:11 UTC (permalink / raw)
  To: Sumit.Saxena, kashyap.desai; +Cc: martin.petersen, linux-scsi

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 82439f9..b1e053b 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -673,7 +673,9 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
 
 	frame_hdr = &cmd->frame->hdr;
 	frame_hdr->cmd_status = 0xFF;
-	frame_hdr->flags |= cpu_to_le16(MFI_FRAME_DONT_POST_IN_REPLY_QUEUE);
+	frame_hdr->flags = cpu_to_le16(
+		le16_to_cpu(frame_hdr->flags) |
+		MFI_FRAME_DONT_POST_IN_REPLY_QUEUE);
 
 	init_frame->cmd	= MFI_CMD_INIT;
 	init_frame->cmd_status = 0xFF;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 07/10] megaraid_sas: add missing byte swaps to the sriov code
  2015-01-10 17:11 megaraid_sas: sparse annotations and endianess fixes Christoph Hellwig
                   ` (5 preceding siblings ...)
  2015-01-10 17:11 ` [PATCH 06/10] megaraid_sas: bytewise or should be done on native endian variables Christoph Hellwig
@ 2015-01-10 17:11 ` Christoph Hellwig
  2015-01-14 11:02   ` Sumit Saxena
  2015-01-10 17:11 ` [PATCH 08/10] megaraid_sas: fix megasas_fire_cmd_fusion calling convention Christoph Hellwig
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2015-01-10 17:11 UTC (permalink / raw)
  To: Sumit.Saxena, kashyap.desai; +Cc: martin.petersen, linux-scsi

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 46 +++++++++++++++++--------------
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 548d033..5350e18 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1924,20 +1924,22 @@ static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance,
 	dcmd->cmd = MFI_CMD_DCMD;
 	dcmd->cmd_status = 0xFF;
 	dcmd->sge_count = 1;
-	dcmd->flags = MFI_FRAME_DIR_BOTH;
+	dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH);
 	dcmd->timeout = 0;
 	dcmd->pad_0 = 0;
-	dcmd->data_xfer_len = sizeof(struct MR_LD_VF_AFFILIATION_111);
-	dcmd->opcode = MR_DCMD_LD_VF_MAP_GET_ALL_LDS_111;
+	dcmd->data_xfer_len =
+		cpu_to_le32(sizeof(struct MR_LD_VF_AFFILIATION_111));
+	dcmd->opcode = cpu_to_le32(MR_DCMD_LD_VF_MAP_GET_ALL_LDS_111);
 
 	if (initial)
 		dcmd->sgl.sge32[0].phys_addr =
-			instance->vf_affiliation_111_h;
+			cpu_to_le32(instance->vf_affiliation_111_h);
 	else
-		dcmd->sgl.sge32[0].phys_addr = new_affiliation_111_h;
+		dcmd->sgl.sge32[0].phys_addr = 
+			cpu_to_le32(new_affiliation_111_h);
 
-	dcmd->sgl.sge32[0].length =
-		sizeof(struct MR_LD_VF_AFFILIATION_111);
+	dcmd->sgl.sge32[0].length = cpu_to_le32(
+		sizeof(struct MR_LD_VF_AFFILIATION_111));
 
 	printk(KERN_WARNING "megasas: SR-IOV: Getting LD/VF affiliation for "
 	       "scsi%d\n", instance->host->host_no);
@@ -2039,20 +2041,22 @@ static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance,
 	dcmd->cmd = MFI_CMD_DCMD;
 	dcmd->cmd_status = 0xFF;
 	dcmd->sge_count = 1;
-	dcmd->flags = MFI_FRAME_DIR_BOTH;
+	dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH);
 	dcmd->timeout = 0;
 	dcmd->pad_0 = 0;
-	dcmd->data_xfer_len = (MAX_LOGICAL_DRIVES + 1) *
-		sizeof(struct MR_LD_VF_AFFILIATION);
-	dcmd->opcode = MR_DCMD_LD_VF_MAP_GET_ALL_LDS;
+	dcmd->data_xfer_len = cpu_to_le32((MAX_LOGICAL_DRIVES + 1) *
+		sizeof(struct MR_LD_VF_AFFILIATION));
+	dcmd->opcode = cpu_to_le32(MR_DCMD_LD_VF_MAP_GET_ALL_LDS);
 
 	if (initial)
-		dcmd->sgl.sge32[0].phys_addr = instance->vf_affiliation_h;
+		dcmd->sgl.sge32[0].phys_addr =
+			cpu_to_le32(instance->vf_affiliation_h);
 	else
-		dcmd->sgl.sge32[0].phys_addr = new_affiliation_h;
+		dcmd->sgl.sge32[0].phys_addr =
+			cpu_to_le32(new_affiliation_h);;
 
-	dcmd->sgl.sge32[0].length = (MAX_LOGICAL_DRIVES + 1) *
-		sizeof(struct MR_LD_VF_AFFILIATION);
+	dcmd->sgl.sge32[0].length = cpu_to_le32((MAX_LOGICAL_DRIVES + 1) *
+		sizeof(struct MR_LD_VF_AFFILIATION));
 
 	printk(KERN_WARNING "megasas: SR-IOV: Getting LD/VF affiliation for "
 	       "scsi%d\n", instance->host->host_no);
@@ -2204,17 +2208,17 @@ int megasas_sriov_start_heartbeat(struct megasas_instance *instance,
 
 	memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
 
-	dcmd->mbox.s[0] = sizeof(struct MR_CTRL_HB_HOST_MEM);
+	dcmd->mbox.s[0] = cpu_to_le16(sizeof(struct MR_CTRL_HB_HOST_MEM));
 	dcmd->cmd = MFI_CMD_DCMD;
 	dcmd->cmd_status = 0xFF;
 	dcmd->sge_count = 1;
-	dcmd->flags = MFI_FRAME_DIR_BOTH;
+	dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH);
 	dcmd->timeout = 0;
 	dcmd->pad_0 = 0;
-	dcmd->data_xfer_len = sizeof(struct MR_CTRL_HB_HOST_MEM);
-	dcmd->opcode = MR_DCMD_CTRL_SHARED_HOST_MEM_ALLOC;
-	dcmd->sgl.sge32[0].phys_addr = instance->hb_host_mem_h;
-	dcmd->sgl.sge32[0].length = sizeof(struct MR_CTRL_HB_HOST_MEM);
+	dcmd->data_xfer_len = cpu_to_le32(sizeof(struct MR_CTRL_HB_HOST_MEM));
+	dcmd->opcode = cpu_to_le32(MR_DCMD_CTRL_SHARED_HOST_MEM_ALLOC);
+	dcmd->sgl.sge32[0].phys_addr = cpu_to_le32(instance->hb_host_mem_h);
+	dcmd->sgl.sge32[0].length = cpu_to_le32(sizeof(struct MR_CTRL_HB_HOST_MEM));
 
 	printk(KERN_WARNING "megasas: SR-IOV: Starting heartbeat for scsi%d\n",
 	       instance->host->host_no);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 08/10] megaraid_sas: fix megasas_fire_cmd_fusion calling convention
  2015-01-10 17:11 megaraid_sas: sparse annotations and endianess fixes Christoph Hellwig
                   ` (6 preceding siblings ...)
  2015-01-10 17:11 ` [PATCH 07/10] megaraid_sas: add missing byte swaps to the sriov code Christoph Hellwig
@ 2015-01-10 17:11 ` Christoph Hellwig
  2015-01-14 11:05   ` Sumit Saxena
  2015-01-10 17:11 ` [PATCH 09/10] megaraid_sas: swap whole register in megasas_register_aen Christoph Hellwig
  2015-01-10 17:11 ` [PATCH 10/10] megaraid_sas: fix endianess for the crash dump state support Christoph Hellwig
  9 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2015-01-10 17:11 UTC (permalink / raw)
  To: Sumit.Saxena, kashyap.desai; +Cc: martin.petersen, linux-scsi

The fusion HBAs don't really use the instance template like the other
variants, as it branches off at a much higher level.  So instead of
trying to squeeze megasas_fire_cmd_fusion into the wrong calling
convention call it locally with argument data types that match what
is passed.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 73 ++++++++++++-----------------
 1 file changed, 29 insertions(+), 44 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index b1e053b..5a45764 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -230,6 +230,31 @@ inline void megasas_return_mfi_mpt_pthr(struct megasas_instance *instance,
 }
 
 /**
+ * megasas_fire_cmd_fusion -	Sends command to the FW
+ */
+static void
+megasas_fire_cmd_fusion(struct megasas_instance *instance,
+		union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc)
+{
+#if defined(writeq) && defined(CONFIG_64BIT)
+	u64 req_data = (((u64)le32_to_cpu(req_desc->u.low) << 32) |
+			le32_to_cpu(req_desc->u.high));
+
+	writeq(req_data, &instance->reg_set->inbound_low_queue_port);
+#else
+	unsigned long flags;
+
+	spin_lock_irqsave(&instance->hba_lock, flags);
+	writel(le32_to_cpu(req_desc->u.low),
+		&instance->reg_set->inbound_low_queue_port);
+	writel(le32_to_cpu(req_desc.u.high),
+		&instance->reg_set->inbound_high_queue_port);
+	spin_unlock_irqrestore(&instance->hba_lock, flags);
+#endif
+}
+
+
+/**
  * megasas_teardown_frame_pool_fusion -	Destroy the cmd frame DMA pool
  * @instance:				Adapter soft state
  */
@@ -721,8 +746,7 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
 			break;
 	}
 
-	instance->instancet->fire_cmd(instance, req_desc.u.low,
-				      req_desc.u.high, instance->reg_set);
+	megasas_fire_cmd_fusion(instance, &req_desc);
 
 	wait_and_poll(instance, cmd, MFI_POLL_TIMEOUT_SECS);
 
@@ -1133,34 +1157,6 @@ fail_alloc_mfi_cmds:
 }
 
 /**
- * megasas_fire_cmd_fusion -	Sends command to the FW
- * @frame_phys_addr :		Physical address of cmd
- * @frame_count :		Number of frames for the command
- * @regs :			MFI register set
- */
-void
-megasas_fire_cmd_fusion(struct megasas_instance *instance,
-			dma_addr_t req_desc_lo,
-			u32 req_desc_hi,
-			struct megasas_register_set __iomem *regs)
-{
-#if defined(writeq) && defined(CONFIG_64BIT)
-	u64 req_data = (((u64)le32_to_cpu(req_desc_hi) << 32) |
-			le32_to_cpu(req_desc_lo));
-
-	writeq(req_data, &(regs)->inbound_low_queue_port);
-#else
-	unsigned long flags;
-
-	spin_lock_irqsave(&instance->hba_lock, flags);
-
-	writel(le32_to_cpu(req_desc_lo), &(regs)->inbound_low_queue_port);
-	writel(le32_to_cpu(req_desc_hi), &(regs)->inbound_high_queue_port);
-	spin_unlock_irqrestore(&instance->hba_lock, flags);
-#endif
-}
-
-/**
  * map_cmd_status -	Maps FW cmd status to OS cmd status
  * @cmd :		Pointer to cmd
  * @status :		status of cmd returned by FW
@@ -1947,9 +1943,7 @@ megasas_build_and_issue_cmd_fusion(struct megasas_instance *instance,
 	 */
 	atomic_inc(&instance->fw_outstanding);
 
-	instance->instancet->fire_cmd(instance,
-				      req_desc->u.low, req_desc->u.high,
-				      instance->reg_set);
+	megasas_fire_cmd_fusion(instance, req_desc);
 
 	return 0;
 }
@@ -2328,8 +2322,7 @@ megasas_issue_dcmd_fusion(struct megasas_instance *instance,
 		return;
 	}
 	atomic_set(&cmd->mfi_mpt_pthr, MFI_MPT_ATTACHED);
-	instance->instancet->fire_cmd(instance, req_desc->u.low,
-				      req_desc->u.high, instance->reg_set);
+	megasas_fire_cmd_fusion(instance, req_desc);
 }
 
 /**
@@ -2816,14 +2809,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int iotimeout)
 							   frame */
 							megasas_return_cmd_fusion(instance, cmd_fusion);
 						} else {
-							instance->instancet->
-							fire_cmd(instance,
-								 req_desc->
-								 u.low,
-								 req_desc->
-								 u.high,
-								 instance->
-								 reg_set);
+							megasas_fire_cmd_fusion(instance, req_desc);
 						}
 					}
 				}
@@ -2978,7 +2964,6 @@ void megasas_fusion_ocr_wq(struct work_struct *work)
 }
 
 struct megasas_instance_template megasas_instance_template_fusion = {
-	.fire_cmd = megasas_fire_cmd_fusion,
 	.enable_intr = megasas_enable_intr_fusion,
 	.disable_intr = megasas_disable_intr_fusion,
 	.clear_intr = megasas_clear_intr_fusion,
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 09/10] megaraid_sas: swap whole register in megasas_register_aen
  2015-01-10 17:11 megaraid_sas: sparse annotations and endianess fixes Christoph Hellwig
                   ` (7 preceding siblings ...)
  2015-01-10 17:11 ` [PATCH 08/10] megaraid_sas: fix megasas_fire_cmd_fusion calling convention Christoph Hellwig
@ 2015-01-10 17:11 ` Christoph Hellwig
  2015-01-14 11:07   ` Sumit Saxena
  2015-01-10 17:11 ` [PATCH 10/10] megaraid_sas: fix endianess for the crash dump state support Christoph Hellwig
  9 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2015-01-10 17:11 UTC (permalink / raw)
  To: Sumit.Saxena, kashyap.desai; +Cc: martin.petersen, linux-scsi

Swap the whole 32 bits we read from the hardware instead of swapping
just the 16bits we care about in place later.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 5350e18..3d4a080 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4882,8 +4882,9 @@ megasas_register_aen(struct megasas_instance *instance, u32 seq_num,
 
 	if (instance->aen_cmd) {
 
-		prev_aen.word = instance->aen_cmd->frame->dcmd.mbox.w[1];
-		prev_aen.members.locale = le16_to_cpu(prev_aen.members.locale);
+		prev_aen.word =
+			le32_to_cpu(instance->aen_cmd->frame->dcmd.mbox.w[1]);
+		prev_aen.members.locale = prev_aen.members.locale;
 
 		/*
 		 * A class whose enum value is smaller is inclusive of all
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 10/10] megaraid_sas: fix endianess for the crash dump state support
  2015-01-10 17:11 megaraid_sas: sparse annotations and endianess fixes Christoph Hellwig
                   ` (8 preceding siblings ...)
  2015-01-10 17:11 ` [PATCH 09/10] megaraid_sas: swap whole register in megasas_register_aen Christoph Hellwig
@ 2015-01-10 17:11 ` Christoph Hellwig
  2015-01-14 12:01   ` Sumit Saxena
  9 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2015-01-10 17:11 UTC (permalink / raw)
  To: Sumit.Saxena, kashyap.desai; +Cc: martin.petersen, linux-scsi

Note that this one is a bit fishy: it seems like it should always be read
and written using either words or bytes, but never using a mixture.

Please verify against the hardware documentation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/megaraid/megaraid_sas.h      | 2 +-
 drivers/scsi/megaraid/megaraid_sas_base.c | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
index 81484f1..465dd45 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1676,7 +1676,7 @@ struct megasas_instance {
 	u32 drv_buf_alloc;
 	u32 crash_dump_fw_support;
 	u32 crash_dump_drv_support;
-	u32 crash_dump_app_support;
+	__le32 crash_dump_app_support;
 	u32 secure_jbod_support;
 	spinlock_t crashdump_lock;
 
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 3d4a080..29a1b20 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -6010,7 +6010,7 @@ static int megasas_set_crash_dump_params_ioctl(
 {
 	struct megasas_instance *local_instance;
 	int i, error = 0;
-	int crash_support;
+	__le32 crash_support;
 
 	crash_support = cmd->frame->dcmd.mbox.w[0];
 
@@ -6020,7 +6020,7 @@ static int megasas_set_crash_dump_params_ioctl(
 			if ((local_instance->adprecovery ==
 				MEGASAS_HBA_OPERATIONAL) &&
 				!megasas_set_crash_dump_params(local_instance,
-					crash_support)) {
+					le32_to_cpu(crash_support))) {
 				local_instance->crash_dump_app_support =
 					crash_support;
 				dev_info(&local_instance->pdev->dev,
@@ -6084,7 +6084,8 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
 					       MFI_FRAME_SGL64 |
 					       MFI_FRAME_SENSE64));
 
-	if (cmd->frame->dcmd.opcode == MR_DRIVER_SET_APP_CRASHDUMP_MODE) {
+	if (cmd->frame->dcmd.opcode ==
+			cpu_to_le32(MR_DRIVER_SET_APP_CRASHDUMP_MODE)) {
 		error = megasas_set_crash_dump_params_ioctl(cmd);
 		megasas_return_cmd(instance, cmd);
 		return error;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* RE: [PATCH 01/10] megaraid_sas: megasas_complete_outstanding_ioctls() can be static
  2015-01-10 17:11 ` [PATCH 01/10] megaraid_sas: megasas_complete_outstanding_ioctls() can be static Christoph Hellwig
@ 2015-01-13  5:38   ` Sumit Saxena
  0 siblings, 0 replies; 21+ messages in thread
From: Sumit Saxena @ 2015-01-13  5:38 UTC (permalink / raw)
  To: Christoph Hellwig, Kashyap Desai
  Cc: martin.petersen, linux-scsi, kbuild test robot

>-----Original Message-----
>From: Christoph Hellwig [mailto:hch@lst.de]
>Sent: Saturday, January 10, 2015 10:41 PM
>To: Sumit.Saxena@avagotech.com; kashyap.desai@avagotech.com
>Cc: martin.petersen@oracle.com; linux-scsi@vger.kernel.org; kbuild test
>robot
>Subject: [PATCH 01/10] megaraid_sas:
>megasas_complete_outstanding_ioctls() can be static
>
>From: kbuild test robot <fengguang.wu@intel.com>
>
>drivers/scsi/megaraid/megaraid_sas_base.c:1701:6: sparse: symbol
>'megasas_complete_outstanding_ioctls' was not declared. Should it be
static?
>
>Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
>---
> drivers/scsi/megaraid/megaraid_sas_base.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c
>b/drivers/scsi/megaraid/megaraid_sas_base.c
>index 890637f..2eb5233 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_base.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
>@@ -1698,7 +1698,7 @@ static int megasas_slave_alloc(struct scsi_device
>*sdev)
> * @instance:				Adapter soft state
> *
> */
>-void megasas_complete_outstanding_ioctls(struct megasas_instance
>*instance)
>+static void megasas_complete_outstanding_ioctls(struct megasas_instance
>*instance)
> {
> 	int i;
> 	struct megasas_cmd *cmd_mfi;

Acked-by: Sumit Saxena <sumit.saxena@avagotech.com>

>--
>1.9.1

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH 02/10] megaraid_sas: add missing __iomem annotations
  2015-01-10 17:11 ` [PATCH 02/10] megaraid_sas: add missing __iomem annotations Christoph Hellwig
@ 2015-01-13  7:05   ` Sumit Saxena
  0 siblings, 0 replies; 21+ messages in thread
From: Sumit Saxena @ 2015-01-13  7:05 UTC (permalink / raw)
  To: Christoph Hellwig, Kashyap Desai; +Cc: martin.petersen, linux-scsi

>-----Original Message-----
>From: Christoph Hellwig [mailto:hch@lst.de]
>Sent: Saturday, January 10, 2015 10:41 PM
>To: Sumit.Saxena@avagotech.com; kashyap.desai@avagotech.com
>Cc: martin.petersen@oracle.com; linux-scsi@vger.kernel.org
>Subject: [PATCH 02/10] megaraid_sas: add missing __iomem annotations
>
>Signed-off-by: Christoph Hellwig <hch@lst.de>
>---
> drivers/scsi/megaraid/megaraid_sas.h      | 2 +-
> drivers/scsi/megaraid/megaraid_sas_base.c | 9 +++++----
> 2 files changed, 6 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas.h
>b/drivers/scsi/megaraid/megaraid_sas.h
>index 14e5c7c..ecc4321 100644
>--- a/drivers/scsi/megaraid/megaraid_sas.h
>+++ b/drivers/scsi/megaraid/megaraid_sas.h
>@@ -1681,7 +1681,7 @@ struct megasas_instance {
> 	spinlock_t crashdump_lock;
>
> 	struct megasas_register_set __iomem *reg_set;
>-	u32 *reply_post_host_index_addr[MR_MAX_MSIX_REG_ARRAY];
>+	u32 __iomem
>*reply_post_host_index_addr[MR_MAX_MSIX_REG_ARRAY];
> 	struct megasas_pd_list          pd_list[MEGASAS_MAX_PD];
> 	struct megasas_pd_list          local_pd_list[MEGASAS_MAX_PD];
> 	u8 ld_ids[MEGASAS_MAX_LD_IDS];
>diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c
>b/drivers/scsi/megaraid/megaraid_sas_base.c
>index 2eb5233..875db92 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_base.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
>@@ -814,8 +814,8 @@ megasas_adp_reset_gen2(struct megasas_instance
>*instance,  {
> 	u32			retry = 0 ;
> 	u32			HostDiag;
>-	u32			*seq_offset = &reg_set->seq_offset;
>-	u32			*hostdiag_offset = &reg_set->host_diag;
>+	u32 __iomem		*seq_offset = &reg_set->seq_offset;
>+	u32 __iomem		*hostdiag_offset = &reg_set->host_diag;
>
> 	if (instance->instancet == &megasas_instance_template_skinny) {
> 		seq_offset = &reg_set->fusion_seq_offset; @@ -4499,7
>+4499,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
> 	 * It is used for all MPT based Adapters.
> 	 */
> 	instance->reply_post_host_index_addr[0] =
>-		(u32 *)((u8 *)instance->reg_set +
>+		(u32 __iomem *)((u8 __iomem *)instance->reg_set +
> 		MPI2_REPLY_POST_HOST_INDEX_OFFSET);
>
> 	/* Check if MSI-X is supported while in ready state */ @@ -4531,7
>+4531,8 @@ static int megasas_init_fw(struct megasas_instance *instance)
> 			 */
> 			for (loop = 1; loop < MR_MAX_MSIX_REG_ARRAY;
>loop++) {
> 				instance->reply_post_host_index_addr[loop]
>=
>-					(u32 *)((u8 *)instance->reg_set +
>+					(u32 __iomem *)
>+					((u8 __iomem*)instance->reg_set +
>
>	MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET
> 					+ (loop * 0x10));
> 			}
Acked-by: Sumit Saxena <sumit.saxena@avagotech.com>

>--
>1.9.1

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH 03/10] megaraid_sas: add endianess annotations
  2015-01-10 17:11 ` [PATCH 03/10] megaraid_sas: add endianess annotations Christoph Hellwig
@ 2015-01-13  7:17   ` Sumit Saxena
  0 siblings, 0 replies; 21+ messages in thread
From: Sumit Saxena @ 2015-01-13  7:17 UTC (permalink / raw)
  To: Christoph Hellwig, Kashyap Desai; +Cc: martin.petersen, linux-scsi

>-----Original Message-----
>From: Christoph Hellwig [mailto:hch@lst.de]
>Sent: Saturday, January 10, 2015 10:41 PM
>To: Sumit.Saxena@avagotech.com; kashyap.desai@avagotech.com
>Cc: martin.petersen@oracle.com; linux-scsi@vger.kernel.org
>Subject: [PATCH 03/10] megaraid_sas: add endianess annotations
>
>This adds endianess annotations to all data structures, and a few
variables
>directly referencing them.
>
>Signed-off-by: Christoph Hellwig <hch@lst.de>
>---
> drivers/scsi/megaraid/megaraid_sas.h        | 296
++++++++++++++-------------
>-
> drivers/scsi/megaraid/megaraid_sas_base.c   |   2 +-
> drivers/scsi/megaraid/megaraid_sas_fp.c     |  10 +-
> drivers/scsi/megaraid/megaraid_sas_fusion.c |   2 +-
> drivers/scsi/megaraid/megaraid_sas_fusion.h | 276
+++++++++++++----------
>---
> 5 files changed, 293 insertions(+), 293 deletions(-)
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas.h
>b/drivers/scsi/megaraid/megaraid_sas.h
>index ecc4321..81484f1 100644
>--- a/drivers/scsi/megaraid/megaraid_sas.h
>+++ b/drivers/scsi/megaraid/megaraid_sas.h
>@@ -408,7 +408,7 @@ enum MR_PD_STATE {
>  * defines the physical drive address structure
>  */
> struct MR_PD_ADDRESS {
>-	u16     deviceId;
>+	__le16	deviceId;
> 	u16     enclDeviceId;
>
> 	union {
>@@ -433,8 +433,8 @@ struct MR_PD_ADDRESS {
>  * defines the physical drive list structure
>  */
> struct MR_PD_LIST {
>-	u32             size;
>-	u32             count;
>+	__le32		size;
>+	__le32		count;
> 	struct MR_PD_ADDRESS   addr[1];
> } __packed;
>
>@@ -451,28 +451,28 @@ union  MR_LD_REF {
> 	struct {
> 		u8      targetId;
> 		u8      reserved;
>-		u16     seqNum;
>+		__le16     seqNum;
> 	};
>-	u32     ref;
>+	__le32     ref;
> } __packed;
>
> /*
>  * defines the logical drive list structure
>  */
> struct MR_LD_LIST {
>-	u32     ldCount;
>-	u32     reserved;
>+	__le32     ldCount;
>+	__le32     reserved;
> 	struct {
> 		union MR_LD_REF   ref;
> 		u8          state;
> 		u8          reserved[3];
>-		u64         size;
>+		__le64		size;
> 	} ldList[MAX_LOGICAL_DRIVES_EXT];
> } __packed;
>
> struct MR_LD_TARGETID_LIST {
>-	u32	size;
>-	u32	count;
>+	__le32	size;
>+	__le32	count;
> 	u8	pad[3];
> 	u8	targetId[MAX_LOGICAL_DRIVES_EXT];
> };
>@@ -553,7 +553,7 @@ struct megasas_ctrl_prop {
> 	} OnOffProperties;
> 	u8 autoSnapVDSpace;
> 	u8 viewSpace;
>-	u16 spinDownTime;
>+	__le16 spinDownTime;
> 	u8  reserved[24];
> } __packed;
>
>@@ -567,10 +567,10 @@ struct megasas_ctrl_info {
> 	 */
> 	struct {
>
>-		u16 vendor_id;
>-		u16 device_id;
>-		u16 sub_vendor_id;
>-		u16 sub_device_id;
>+		__le16 vendor_id;
>+		__le16 device_id;
>+		__le16 sub_vendor_id;
>+		__le16 sub_device_id;
> 		u8 reserved[24];
>
> 	} __attribute__ ((packed)) pci;
>@@ -611,8 +611,8 @@ struct megasas_ctrl_info {
> 	/*
> 	 * List of components residing in flash. All str are null
terminated
> 	 */
>-	u32 image_check_word;
>-	u32 image_component_count;
>+	__le32 image_check_word;
>+	__le32 image_component_count;
>
> 	struct {
>
>@@ -629,7 +629,7 @@ struct megasas_ctrl_info {
> 	 * empty if a flash operation has not occurred. All stings are
null
> 	 * terminated
> 	 */
>-	u32 pending_image_component_count;
>+	__le32 pending_image_component_count;
>
> 	struct {
>
>@@ -662,39 +662,39 @@ struct megasas_ctrl_info {
>
> 	} __attribute__ ((packed)) hw_present;
>
>-	u32 current_fw_time;
>+	__le32 current_fw_time;
>
> 	/*
> 	 * Maximum data transfer sizes
> 	 */
>-	u16 max_concurrent_cmds;
>-	u16 max_sge_count;
>-	u32 max_request_size;
>+	__le16 max_concurrent_cmds;
>+	__le16 max_sge_count;
>+	__le32 max_request_size;
>
> 	/*
> 	 * Logical and physical device counts
> 	 */
>-	u16 ld_present_count;
>-	u16 ld_degraded_count;
>-	u16 ld_offline_count;
>+	__le16 ld_present_count;
>+	__le16 ld_degraded_count;
>+	__le16 ld_offline_count;
>
>-	u16 pd_present_count;
>-	u16 pd_disk_present_count;
>-	u16 pd_disk_pred_failure_count;
>-	u16 pd_disk_failed_count;
>+	__le16 pd_present_count;
>+	__le16 pd_disk_present_count;
>+	__le16 pd_disk_pred_failure_count;
>+	__le16 pd_disk_failed_count;
>
> 	/*
> 	 * Memory size information
> 	 */
>-	u16 nvram_size;
>-	u16 memory_size;
>-	u16 flash_size;
>+	__le16 nvram_size;
>+	__le16 memory_size;
>+	__le16 flash_size;
>
> 	/*
> 	 * Error counters
> 	 */
>-	u16 mem_correctable_error_count;
>-	u16 mem_uncorrectable_error_count;
>+	__le16 mem_correctable_error_count;
>+	__le16 mem_uncorrectable_error_count;
>
> 	/*
> 	 * Cluster information
>@@ -705,7 +705,7 @@ struct megasas_ctrl_info {
> 	/*
> 	 * Additional max data transfer sizes
> 	 */
>-	u16 max_strips_per_io;
>+	__le16 max_strips_per_io;
>
> 	/*
> 	 * Controller capabilities structures
>@@ -805,7 +805,7 @@ struct megasas_ctrl_info {
> 	* deviceInterface.portAddr, and the rest shall be
> 	* populated in deviceInterfacePortAddr2.
> 	*/
>-	u64         deviceInterfacePortAddr2[8]; /*6a0h */
>+	__le64	    deviceInterfacePortAddr2[8]; /*6a0h */
> 	u8          reserved3[128];              /*6e0h */
>
> 	struct {                                /*760h */
>@@ -842,26 +842,26 @@ struct megasas_ctrl_info {
> 		u16 reserved[6];
> 	} pdsForRaidLevels;
>
>-	u16 maxPds;                             /*780h */
>-	u16 maxDedHSPs;                         /*782h */
>-	u16 maxGlobalHSPs;                      /*784h */
>-	u16 ddfSize;                            /*786h */
>+	__le16 maxPds;                          /*780h */
>+	__le16 maxDedHSPs;                      /*782h */
>+	__le16 maxGlobalHSP;                    /*784h */
>+	__le16 ddfSize;                         /*786h */
> 	u8  maxLdsPerArray;                     /*788h */
> 	u8  partitionsInDDF;                    /*789h */
> 	u8  lockKeyBinding;                     /*78ah */
> 	u8  maxPITsPerLd;                       /*78bh */
> 	u8  maxViewsPerLd;                      /*78ch */
> 	u8  maxTargetId;                        /*78dh */
>-	u16 maxBvlVdSize;                       /*78eh */
>+	__le16 maxBvlVdSize;                    /*78eh */
>
>-	u16 maxConfigurableSSCSize;             /*790h */
>-	u16 currentSSCsize;                     /*792h */
>+	__le16 maxConfigurableSSCSize;          /*790h */
>+	__le16 currentSSCsize;                  /*792h */
>
> 	char    expanderFwVersion[12];          /*794h */
>
>-	u16 PFKTrialTimeRemaining;              /*7A0h */
>+	__le16 PFKTrialTimeRemaining;           /*7A0h */
>
>-	u16 cacheMemorySize;                    /*7A2h */
>+	__le16 cacheMemorySize;                 /*7A2h */
>
> 	struct {                                /*7A4h */
> #if   defined(__BIG_ENDIAN_BITFIELD)
>@@ -931,7 +931,7 @@ struct megasas_ctrl_info {
> 	u8  temperatureROC;                     /*7C9h */
> 	u8  temperatureCtrl;                    /*7CAh */
> 	u8  reserved4;                          /*7CBh */
>-	u16 maxConfigurablePds;                 /*7CCh */
>+	__le16 maxConfigurablePds;              /*7CCh */
>
>
> 	u8  reserved5[2];                       /*0x7CDh */
>@@ -1172,22 +1172,22 @@ struct megasas_register_set {
>
> struct megasas_sge32 {
>
>-	u32 phys_addr;
>-	u32 length;
>+	__le32 phys_addr;
>+	__le32 length;
>
> } __attribute__ ((packed));
>
> struct megasas_sge64 {
>
>-	u64 phys_addr;
>-	u32 length;
>+	__le64 phys_addr;
>+	__le32 length;
>
> } __attribute__ ((packed));
>
> struct megasas_sge_skinny {
>-	u64 phys_addr;
>-	u32 length;
>-	u32 flag;
>+	__le64 phys_addr;
>+	__le32 length;
>+	__le32 flag;
> } __packed;
>
> union megasas_sgl {
>@@ -1210,12 +1210,12 @@ struct megasas_header {
> 	u8 cdb_len;		/*06h */
> 	u8 sge_count;		/*07h */
>
>-	u32 context;		/*08h */
>-	u32 pad_0;		/*0Ch */
>+	__le32 context;		/*08h */
>+	__le32 pad_0;		/*0Ch */
>
>-	u16 flags;		/*10h */
>-	u16 timeout;		/*12h */
>-	u32 data_xferlen;	/*14h */
>+	__le16 flags;		/*10h */
>+	__le16 timeout;		/*12h */
>+	__le32 data_xferlen;	/*14h */
>
> } __attribute__ ((packed));
>
>@@ -1248,7 +1248,7 @@ typedef union _MFI_CAPABILITIES {
> 		u32     reserved:25;
> #endif
> 	} mfi_capabilities;
>-	u32     reg;
>+	__le32		reg;
> } MFI_CAPABILITIES;
>
> struct megasas_init_frame {
>@@ -1260,33 +1260,33 @@ struct megasas_init_frame {
> 	u8 reserved_1;		/*03h */
> 	MFI_CAPABILITIES driver_operations; /*04h*/
>
>-	u32 context;		/*08h */
>-	u32 pad_0;		/*0Ch */
>+	__le32 context;		/*08h */
>+	__le32 pad_0;		/*0Ch */
>
>-	u16 flags;		/*10h */
>-	u16 reserved_3;		/*12h */
>-	u32 data_xfer_len;	/*14h */
>+	__le16 flags;		/*10h */
>+	__le16 reserved_3;	/*12h */
>+	__le32 data_xfer_len;	/*14h */
>
>-	u32 queue_info_new_phys_addr_lo;	/*18h */
>-	u32 queue_info_new_phys_addr_hi;	/*1Ch */
>-	u32 queue_info_old_phys_addr_lo;	/*20h */
>-	u32 queue_info_old_phys_addr_hi;	/*24h */
>+	__le32 queue_info_new_phys_addr_lo;	/*18h */
>+	__le32 queue_info_new_phys_addr_hi;	/*1Ch */
>+	__le32 queue_info_old_phys_addr_lo;	/*20h */
>+	__le32 queue_info_old_phys_addr_hi;	/*24h */
>
>-	u32 reserved_4[6];	/*28h */
>+	__le32 reserved_4[6];	/*28h */
>
> } __attribute__ ((packed));
>
> struct megasas_init_queue_info {
>
>-	u32 init_flags;		/*00h */
>-	u32 reply_queue_entries;	/*04h */
>+	__le32 init_flags;		/*00h */
>+	__le32 reply_queue_entries;	/*04h */
>
>-	u32 reply_queue_start_phys_addr_lo;	/*08h */
>-	u32 reply_queue_start_phys_addr_hi;	/*0Ch */
>-	u32 producer_index_phys_addr_lo;	/*10h */
>-	u32 producer_index_phys_addr_hi;	/*14h */
>-	u32 consumer_index_phys_addr_lo;	/*18h */
>-	u32 consumer_index_phys_addr_hi;	/*1Ch */
>+	__le32 reply_queue_start_phys_addr_lo;	/*08h */
>+	__le32 reply_queue_start_phys_addr_hi;	/*0Ch */
>+	__le32 producer_index_phys_addr_lo;	/*10h */
>+	__le32 producer_index_phys_addr_hi;	/*14h */
>+	__le32 consumer_index_phys_addr_lo;	/*18h */
>+	__le32 consumer_index_phys_addr_hi;	/*1Ch */
>
> } __attribute__ ((packed));
>
>@@ -1302,18 +1302,18 @@ struct megasas_io_frame {
> 	u8 reserved_0;		/*06h */
> 	u8 sge_count;		/*07h */
>
>-	u32 context;		/*08h */
>-	u32 pad_0;		/*0Ch */
>+	__le32 context;		/*08h */
>+	__le32 pad_0;		/*0Ch */
>
>-	u16 flags;		/*10h */
>-	u16 timeout;		/*12h */
>-	u32 lba_count;		/*14h */
>+	__le16 flags;		/*10h */
>+	__le16 timeout;		/*12h */
>+	__le32 lba_count;	/*14h */
>
>-	u32 sense_buf_phys_addr_lo;	/*18h */
>-	u32 sense_buf_phys_addr_hi;	/*1Ch */
>+	__le32 sense_buf_phys_addr_lo;	/*18h */
>+	__le32 sense_buf_phys_addr_hi;	/*1Ch */
>
>-	u32 start_lba_lo;	/*20h */
>-	u32 start_lba_hi;	/*24h */
>+	__le32 start_lba_lo;	/*20h */
>+	__le32 start_lba_hi;	/*24h */
>
> 	union megasas_sgl sgl;	/*28h */
>
>@@ -1331,15 +1331,15 @@ struct megasas_pthru_frame {
> 	u8 cdb_len;		/*06h */
> 	u8 sge_count;		/*07h */
>
>-	u32 context;		/*08h */
>-	u32 pad_0;		/*0Ch */
>+	__le32 context;		/*08h */
>+	__le32 pad_0;		/*0Ch */
>
>-	u16 flags;		/*10h */
>-	u16 timeout;		/*12h */
>-	u32 data_xfer_len;	/*14h */
>+	__le16 flags;		/*10h */
>+	__le16 timeout;		/*12h */
>+	__le32 data_xfer_len;	/*14h */
>
>-	u32 sense_buf_phys_addr_lo;	/*18h */
>-	u32 sense_buf_phys_addr_hi;	/*1Ch */
>+	__le32 sense_buf_phys_addr_lo;	/*18h */
>+	__le32 sense_buf_phys_addr_hi;	/*1Ch */
>
> 	u8 cdb[16];		/*20h */
> 	union megasas_sgl sgl;	/*30h */
>@@ -1354,19 +1354,19 @@ struct megasas_dcmd_frame {
> 	u8 reserved_1[4];	/*03h */
> 	u8 sge_count;		/*07h */
>
>-	u32 context;		/*08h */
>-	u32 pad_0;		/*0Ch */
>+	__le32 context;		/*08h */
>+	__le32 pad_0;		/*0Ch */
>
>-	u16 flags;		/*10h */
>-	u16 timeout;		/*12h */
>+	__le16 flags;		/*10h */
>+	__le16 timeout;		/*12h */
>
>-	u32 data_xfer_len;	/*14h */
>-	u32 opcode;		/*18h */
>+	__le32 data_xfer_len;	/*14h */
>+	__le32 opcode;		/*18h */
>
> 	union {			/*1Ch */
> 		u8 b[12];
>-		u16 s[6];
>-		u32 w[3];
>+		__le16 s[6];
>+		__le32 w[3];
> 	} mbox;
>
> 	union megasas_sgl sgl;	/*28h */
>@@ -1380,22 +1380,22 @@ struct megasas_abort_frame {
> 	u8 cmd_status;		/*02h */
>
> 	u8 reserved_1;		/*03h */
>-	u32 reserved_2;		/*04h */
>+	__le32 reserved_2;	/*04h */
>
>-	u32 context;		/*08h */
>-	u32 pad_0;		/*0Ch */
>+	__le32 context;		/*08h */
>+	__le32 pad_0;		/*0Ch */
>
>-	u16 flags;		/*10h */
>-	u16 reserved_3;		/*12h */
>-	u32 reserved_4;		/*14h */
>+	__le16 flags;		/*10h */
>+	__le16 reserved_3;	/*12h */
>+	__le32 reserved_4;	/*14h */
>
>-	u32 abort_context;	/*18h */
>-	u32 pad_1;		/*1Ch */
>+	__le32 abort_context;	/*18h */
>+	__le32 pad_1;		/*1Ch */
>
>-	u32 abort_mfi_phys_addr_lo;	/*20h */
>-	u32 abort_mfi_phys_addr_hi;	/*24h */
>+	__le32 abort_mfi_phys_addr_lo;	/*20h */
>+	__le32 abort_mfi_phys_addr_hi;	/*24h */
>
>-	u32 reserved_5[6];	/*28h */
>+	__le32 reserved_5[6];	/*28h */
>
> } __attribute__ ((packed));
>
>@@ -1409,14 +1409,14 @@ struct megasas_smp_frame {
> 	u8 reserved_2[3];	/*04h */
> 	u8 sge_count;		/*07h */
>
>-	u32 context;		/*08h */
>-	u32 pad_0;		/*0Ch */
>+	__le32 context;		/*08h */
>+	__le32 pad_0;		/*0Ch */
>
>-	u16 flags;		/*10h */
>-	u16 timeout;		/*12h */
>+	__le16 flags;		/*10h */
>+	__le16 timeout;		/*12h */
>
>-	u32 data_xfer_len;	/*14h */
>-	u64 sas_addr;		/*18h */
>+	__le32 data_xfer_len;	/*14h */
>+	__le64 sas_addr;	/*18h */
>
> 	union {
> 		struct megasas_sge32 sge32[2];	/* [0]: resp [1]: req */
>@@ -1436,16 +1436,16 @@ struct megasas_stp_frame {
> 	u8 reserved_3[2];	/*05h */
> 	u8 sge_count;		/*07h */
>
>-	u32 context;		/*08h */
>-	u32 pad_0;		/*0Ch */
>+	__le32 context;		/*08h */
>+	__le32 pad_0;		/*0Ch */
>
>-	u16 flags;		/*10h */
>-	u16 timeout;		/*12h */
>+	__le16 flags;		/*10h */
>+	__le16 timeout;		/*12h */
>
>-	u32 data_xfer_len;	/*14h */
>+	__le32 data_xfer_len;	/*14h */
>
>-	u16 fis[10];		/*18h */
>-	u32 stp_flags;
>+	__le16 fis[10];		/*18h */
>+	__le32 stp_flags;
>
> 	union {
> 		struct megasas_sge32 sge32[2];	/* [0]: resp [1]: data */
>@@ -1489,18 +1489,18 @@ union megasas_evt_class_locale {  } __attribute__
>((packed));
>
> struct megasas_evt_log_info {
>-	u32 newest_seq_num;
>-	u32 oldest_seq_num;
>-	u32 clear_seq_num;
>-	u32 shutdown_seq_num;
>-	u32 boot_seq_num;
>+	__le32 newest_seq_num;
>+	__le32 oldest_seq_num;
>+	__le32 clear_seq_num;
>+	__le32 shutdown_seq_num;
>+	__le32 boot_seq_num;
>
> } __attribute__ ((packed));
>
> struct megasas_progress {
>
>-	u16 progress;
>-	u16 elapsed_seconds;
>+	__le16 progress;
>+	__le16 elapsed_seconds;
>
> } __attribute__ ((packed));
>
>@@ -1521,9 +1521,9 @@ struct megasas_evtarg_pd {
>
> struct megasas_evt_detail {
>
>-	u32 seq_num;
>-	u32 time_stamp;
>-	u32 code;
>+	__le32 seq_num;
>+	__le32 time_stamp;
>+	__le32 code;
> 	union megasas_evt_class_locale cl;
> 	u8 arg_type;
> 	u8 reserved1[15];
>@@ -1542,18 +1542,18 @@ struct megasas_evt_detail {
>
> 		struct {
> 			struct megasas_evtarg_ld ld;
>-			u64 count;
>+			__le64 count;
> 		} __attribute__ ((packed)) ld_count;
>
> 		struct {
>-			u64 lba;
>+			__le64 lba;
> 			struct megasas_evtarg_ld ld;
> 		} __attribute__ ((packed)) ld_lba;
>
> 		struct {
> 			struct megasas_evtarg_ld ld;
>-			u32 prevOwner;
>-			u32 newOwner;
>+			__le32 prevOwner;
>+			__le32 newOwner;
> 		} __attribute__ ((packed)) ld_owner;
>
> 		struct {
>@@ -1610,7 +1610,7 @@ struct megasas_evt_detail {
>
> 		struct {
> 			u16 vendorId;
>-			u16 deviceId;
>+			__le16 deviceId;
> 			u16 subVendorId;
> 			u16 subDeviceId;
> 		} __attribute__ ((packed)) pci;
>@@ -1630,9 +1630,9 @@ struct megasas_evt_detail {
> 		} __attribute__ ((packed)) ecc;
>
> 		u8 b[96];
>-		u16 s[48];
>-		u32 w[24];
>-		u64 d[12];
>+		__le16 s[48];
>+		__le32 w[24];
>+		__le64 d[12];
> 	} args;
>
> 	char description[128];
>@@ -1651,9 +1651,9 @@ struct megasas_irq_context {
>
> struct megasas_instance {
>
>-	u32 *producer;
>+	__le32 *producer;
> 	dma_addr_t producer_h;
>-	u32 *consumer;
>+	__le32 *consumer;
> 	dma_addr_t consumer_h;
> 	struct MR_LD_VF_AFFILIATION *vf_affiliation;
> 	dma_addr_t vf_affiliation_h;
>@@ -1662,7 +1662,7 @@ struct megasas_instance {
> 	struct MR_CTRL_HB_HOST_MEM *hb_host_mem;
> 	dma_addr_t hb_host_mem_h;
>
>-	u32 *reply_queue;
>+	__le32 *reply_queue;
> 	dma_addr_t reply_queue_h;
>
> 	u32 *crash_dump_buf;
>@@ -1963,10 +1963,10 @@ u8 MR_TargetIdToLdGet(u32 ldTgtId, struct
>MR_DRV_RAID_MAP_ALL *map);  struct MR_LD_RAID *MR_LdRaidGet(u32
>ld, struct MR_DRV_RAID_MAP_ALL *map);
> u16 MR_ArPdGet(u32 ar, u32 arm, struct MR_DRV_RAID_MAP_ALL *map);
> u16 MR_LdSpanArrayGet(u32 ld, u32 span, struct MR_DRV_RAID_MAP_ALL
>*map);
>-u16 MR_PdDevHandleGet(u32 pd, struct MR_DRV_RAID_MAP_ALL *map);
>+__le16 MR_PdDevHandleGet(u32 pd, struct MR_DRV_RAID_MAP_ALL
>*map);
> u16 MR_GetLDTgtId(u32 ld, struct MR_DRV_RAID_MAP_ALL *map);
>
>-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
>*in_info);  void mr_update_load_balance_params(struct
>MR_DRV_RAID_MAP_ALL *map,
> 	struct LD_LOAD_BALANCE_INFO *lbInfo);
>diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c
>b/drivers/scsi/megaraid/megaraid_sas_base.c
>index 875db92..cb7d0c4 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_base.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
>@@ -4262,7 +4262,7 @@ int megasas_set_crash_dump_params(struct
>megasas_instance *instance,  static int  megasas_issue_init_mfi(struct
>megasas_instance *instance)  {
>-	u32 context;
>+	__le32 context;
>
> 	struct megasas_cmd *cmd;
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c
>b/drivers/scsi/megaraid/megaraid_sas_fp.c
>index 4f72287..e9138a2 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
>@@ -142,7 +142,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;
> }
>@@ -735,7 +735,7 @@ static u8 mr_spanset_get_phy_params(struct
>megasas_instance *instance, u32 ld,
> 	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;
>
> 	if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER || @@ -
>817,7 +817,7 @@ u8 MR_GetPhyParams(struct megasas_instance *instance,
>u32 ld, u64 stripRow,
> 	u8	    retval = TRUE;
> 	u8          do_invader = 0;
> 	u64	    *pdBlock = &io_info->pdBlock;
>-	u16	    *pDevHandle = &io_info->devHandle;
>+	__le16	    *pDevHandle = &io_info->devHandle;
>
> 	if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER ||
> 		instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) @@ -
>1341,11 +1341,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;
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c
>b/drivers/scsi/megaraid/megaraid_sas_fusion.c
>index 675b5e7..983635f 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
>@@ -1670,7 +1670,7 @@ megasas_build_dcdb_fusion(struct
>megasas_instance *instance,
> 	struct MR_DRV_RAID_MAP_ALL *local_map_ptr;
> 	struct fusion_context *fusion = instance->ctrl_context;
> 	u8                          span, physArm;
>-	u16                         devHandle;
>+	__le16                      devHandle;
> 	u32                         ld, arRef, pd;
> 	struct MR_LD_RAID                  *raid;
> 	struct RAID_CONTEXT                *pRAID_Context;
>diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h
>b/drivers/scsi/megaraid/megaraid_sas_fusion.h
>index 56e6db2..d62285e 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_fusion.h
>+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h
>@@ -104,18 +104,18 @@ struct RAID_CONTEXT {
> 	u8	nseg:4;
> #endif
> 	u8	resvd0;
>-	u16     timeoutValue;
>+	__le16	timeoutValue;
> 	u8      regLockFlags;
> 	u8      resvd1;
>-	u16     VirtualDiskTgtId;
>-	u64     regLockRowLBA;
>-	u32     regLockLength;
>-	u16     nextLMId;
>+	__le16	VirtualDiskTgtId;
>+	__le64	regLockRowLBA;
>+	__le32	regLockLength;
>+	__le16	nextLMId;
> 	u8      exStatus;
> 	u8      status;
> 	u8      RAIDFlags;
> 	u8      numSGE;
>-	u16	configSeqNum;
>+	__le16	configSeqNum;
> 	u8      spanArm;
> 	u8      resvd2[3];
> };
>@@ -182,61 +182,61 @@ enum REGION_TYPE {
> #define MPI2_WRSEQ_6TH_KEY_VALUE                (0xD)
>
> struct MPI25_IEEE_SGE_CHAIN64 {
>-	u64                     Address;
>-	u32                     Length;
>-	u16                     Reserved1;
>+	__le64			Address;
>+	__le32			Length;
>+	__le16			Reserved1;
> 	u8                      NextChainOffset;
> 	u8                      Flags;
> };
>
> struct MPI2_SGE_SIMPLE_UNION {
>-	u32                     FlagsLength;
>+	__le32                     FlagsLength;
> 	union {
>-		u32                 Address32;
>-		u64                 Address64;
>+		__le32                 Address32;
>+		__le64                 Address64;
> 	} u;
> };
>
> struct MPI2_SCSI_IO_CDB_EEDP32 {
> 	u8                      CDB[20];                    /* 0x00 */
>-	u32                     PrimaryReferenceTag;        /* 0x14 */
>-	u16                     PrimaryApplicationTag;      /* 0x18 */
>-	u16                     PrimaryApplicationTagMask;  /* 0x1A */
>-	u32                     TransferLength;             /* 0x1C */
>+	__be32			PrimaryReferenceTag;        /* 0x14 */
>+	__be16			PrimaryApplicationTag;      /* 0x18 */
>+	__be16			PrimaryApplicationTagMask;  /* 0x1A */
>+	__le32			TransferLength;             /* 0x1C */
> };
>
> struct MPI2_SGE_CHAIN_UNION {
>-	u16                     Length;
>+	__le16			Length;
> 	u8                      NextChainOffset;
> 	u8                      Flags;
> 	union {
>-		u32                 Address32;
>-		u64                 Address64;
>+		__le32		Address32;
>+		__le64		Address64;
> 	} u;
> };
>
> struct MPI2_IEEE_SGE_SIMPLE32 {
>-	u32                     Address;
>-	u32                     FlagsLength;
>+	__le32			Address;
>+	__le32			FlagsLength;
> };
>
> struct MPI2_IEEE_SGE_CHAIN32 {
>-	u32                     Address;
>-	u32                     FlagsLength;
>+	__le32			Address;
>+	__le32			FlagsLength;
> };
>
> struct MPI2_IEEE_SGE_SIMPLE64 {
>-	u64                     Address;
>-	u32                     Length;
>-	u16                     Reserved1;
>+	__le64			Address;
>+	__le32			Length;
>+	__le16			Reserved1;
> 	u8                      Reserved2;
> 	u8                      Flags;
> };
>
> struct MPI2_IEEE_SGE_CHAIN64 {
>-	u64                     Address;
>-	u32                     Length;
>-	u16                     Reserved1;
>+	__le64			Address;
>+	__le32			Length;
>+	__le16			Reserved1;
> 	u8                      Reserved2;
> 	u8                      Flags;
> };
>@@ -269,34 +269,34 @@ union MPI2_SCSI_IO_CDB_UNION {
>  * Total SGE count will be one less than  _MPI2_SCSI_IO_REQUEST
>  */
> struct MPI2_RAID_SCSI_IO_REQUEST {
>-	u16                     DevHandle;                      /* 0x00 */
>+	__le16			DevHandle;                      /* 0x00 */
> 	u8                      ChainOffset;                    /* 0x02 */
> 	u8                      Function;                       /* 0x03 */
>-	u16                     Reserved1;                      /* 0x04 */
>+	__le16			Reserved1;                      /* 0x04 */
> 	u8                      Reserved2;                      /* 0x06 */
> 	u8                      MsgFlags;                       /* 0x07 */
> 	u8                      VP_ID;                          /* 0x08 */
> 	u8                      VF_ID;                          /* 0x09 */
>-	u16                     Reserved3;                      /* 0x0A */
>-	u32                     SenseBufferLowAddress;          /* 0x0C */
>-	u16                     SGLFlags;                       /* 0x10 */
>+	__le16			Reserved3;                      /* 0x0A */
>+	__le32			SenseBufferLowAddress;          /* 0x0C */
>+	__le16			SGLFlags;                       /* 0x10 */
> 	u8                      SenseBufferLength;              /* 0x12 */
> 	u8                      Reserved4;                      /* 0x13 */
> 	u8                      SGLOffset0;                     /* 0x14 */
> 	u8                      SGLOffset1;                     /* 0x15 */
> 	u8                      SGLOffset2;                     /* 0x16 */
> 	u8                      SGLOffset3;                     /* 0x17 */
>-	u32                     SkipCount;                      /* 0x18 */
>-	u32                     DataLength;                     /* 0x1C */
>-	u32                     BidirectionalDataLength;        /* 0x20 */
>-	u16                     IoFlags;                        /* 0x24 */
>-	u16                     EEDPFlags;                      /* 0x26 */
>-	u32                     EEDPBlockSize;                  /* 0x28 */
>-	u32                     SecondaryReferenceTag;          /* 0x2C */
>-	u16                     SecondaryApplicationTag;        /* 0x30 */
>-	u16                     ApplicationTagTranslationMask;  /* 0x32 */
>+	__le32			SkipCount;                      /* 0x18 */
>+	__le32			DataLength;                     /* 0x1C */
>+	__le32			BidirectionalDataLength;        /* 0x20 */
>+	__le16			IoFlags;                        /* 0x24 */
>+	__le16			EEDPFlags;                      /* 0x26 */
>+	__le32			EEDPBlockSize;                  /* 0x28 */
>+	__le32			SecondaryReferenceTag;          /* 0x2C */
>+	__le16			SecondaryApplicationTag;        /* 0x30 */
>+	__le16			ApplicationTagTranslationMask;  /* 0x32 */
> 	u8                      LUN[8];                         /* 0x34 */
>-	u32                     Control;                        /* 0x3C */
>+	__le32			Control;                        /* 0x3C */
> 	union MPI2_SCSI_IO_CDB_UNION  CDB;			/*
>0x40 */
> 	struct RAID_CONTEXT	RaidContext;                    /* 0x60 */
> 	union MPI2_SGE_IO_UNION       SGL;			/* 0x80 */
>@@ -315,45 +315,45 @@ struct
>MEGASAS_RAID_MFA_IO_REQUEST_DESCRIPTOR {  struct
>MPI2_DEFAULT_REQUEST_DESCRIPTOR {
> 	u8              RequestFlags;               /* 0x00 */
> 	u8              MSIxIndex;                  /* 0x01 */
>-	u16             SMID;                       /* 0x02 */
>-	u16             LMID;                       /* 0x04 */
>-	u16             DescriptorTypeDependent;    /* 0x06 */
>+	__le16		SMID;                       /* 0x02 */
>+	__le16		LMID;                       /* 0x04 */
>+	__le16		DescriptorTypeDependent;    /* 0x06 */
> };
>
> /* High Priority Request Descriptor */
> struct MPI2_HIGH_PRIORITY_REQUEST_DESCRIPTOR {
> 	u8              RequestFlags;               /* 0x00 */
> 	u8              MSIxIndex;                  /* 0x01 */
>-	u16             SMID;                       /* 0x02 */
>-	u16             LMID;                       /* 0x04 */
>-	u16             Reserved1;                  /* 0x06 */
>+	__le16		SMID;                       /* 0x02 */
>+	__le16		LMID;                       /* 0x04 */
>+	__le16		Reserved1;                  /* 0x06 */
> };
>
> /* SCSI IO Request Descriptor */
> struct MPI2_SCSI_IO_REQUEST_DESCRIPTOR {
> 	u8              RequestFlags;               /* 0x00 */
> 	u8              MSIxIndex;                  /* 0x01 */
>-	u16             SMID;                       /* 0x02 */
>-	u16             LMID;                       /* 0x04 */
>-	u16             DevHandle;                  /* 0x06 */
>+	__le16		SMID;                       /* 0x02 */
>+	__le16		LMID;                       /* 0x04 */
>+	__le16		DevHandle;                  /* 0x06 */
> };
>
> /* SCSI Target Request Descriptor */
> struct MPI2_SCSI_TARGET_REQUEST_DESCRIPTOR {
> 	u8              RequestFlags;               /* 0x00 */
> 	u8              MSIxIndex;                  /* 0x01 */
>-	u16             SMID;                       /* 0x02 */
>-	u16             LMID;                       /* 0x04 */
>-	u16             IoIndex;                    /* 0x06 */
>+	__le16		SMID;                       /* 0x02 */
>+	__le16		LMID;                       /* 0x04 */
>+	__le16		IoIndex;                    /* 0x06 */
> };
>
> /* RAID Accelerator Request Descriptor */  struct
>MPI2_RAID_ACCEL_REQUEST_DESCRIPTOR {
> 	u8              RequestFlags;               /* 0x00 */
> 	u8              MSIxIndex;                  /* 0x01 */
>-	u16             SMID;                       /* 0x02 */
>-	u16             LMID;                       /* 0x04 */
>-	u16             Reserved;                   /* 0x06 */
>+	__le16		SMID;                       /* 0x02 */
>+	__le16		LMID;                       /* 0x04 */
>+	__le16		Reserved;                   /* 0x06 */
> };
>
> /* union of Request Descriptors */
>@@ -366,10 +366,10 @@ union MEGASAS_REQUEST_DESCRIPTOR_UNION {
> 	struct MEGASAS_RAID_MFA_IO_REQUEST_DESCRIPTOR      MFAIo;
> 	union {
> 		struct {
>-			u32 low;
>-			u32 high;
>+			__le32 low;
>+			__le32 high;
> 		} u;
>-		u64 Words;
>+		__le64 Words;
> 	};
> };
>
>@@ -377,35 +377,35 @@ union MEGASAS_REQUEST_DESCRIPTOR_UNION {
>struct MPI2_DEFAULT_REPLY_DESCRIPTOR {
> 	u8              ReplyFlags;                 /* 0x00 */
> 	u8              MSIxIndex;                  /* 0x01 */
>-	u16             DescriptorTypeDependent1;   /* 0x02 */
>-	u32             DescriptorTypeDependent2;   /* 0x04 */
>+	__le16		DescriptorTypeDependent1;   /* 0x02 */
>+	__le32		DescriptorTypeDependent2;   /* 0x04 */
> };
>
> /* Address Reply Descriptor */
> struct MPI2_ADDRESS_REPLY_DESCRIPTOR {
> 	u8              ReplyFlags;                 /* 0x00 */
> 	u8              MSIxIndex;                  /* 0x01 */
>-	u16             SMID;                       /* 0x02 */
>-	u32             ReplyFrameAddress;          /* 0x04 */
>+	__le16		SMID;                       /* 0x02 */
>+	__le32		ReplyFrameAddress;          /* 0x04 */
> };
>
> /* SCSI IO Success Reply Descriptor */
> struct MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR {
> 	u8              ReplyFlags;                 /* 0x00 */
> 	u8              MSIxIndex;                  /* 0x01 */
>-	u16             SMID;                       /* 0x02 */
>-	u16             TaskTag;                    /* 0x04 */
>-	u16             Reserved1;                  /* 0x06 */
>+	__le16		SMID;                       /* 0x02 */
>+	__le16		TaskTag;                    /* 0x04 */
>+	__le16		Reserved1;                  /* 0x06 */
> };
>
> /* TargetAssist Success Reply Descriptor */  struct
>MPI2_TARGETASSIST_SUCCESS_REPLY_DESCRIPTOR {
> 	u8              ReplyFlags;                 /* 0x00 */
> 	u8              MSIxIndex;                  /* 0x01 */
>-	u16             SMID;                       /* 0x02 */
>+	__le16		SMID;                       /* 0x02 */
> 	u8              SequenceNumber;             /* 0x04 */
> 	u8              Reserved1;                  /* 0x05 */
>-	u16             IoIndex;                    /* 0x06 */
>+	__le16		IoIndex;                    /* 0x06 */
> };
>
> /* Target Command Buffer Reply Descriptor */ @@ -414,16 +414,16 @@
>struct MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR {
> 	u8              MSIxIndex;                  /* 0x01 */
> 	u8              VP_ID;                      /* 0x02 */
> 	u8              Flags;                      /* 0x03 */
>-	u16             InitiatorDevHandle;         /* 0x04 */
>-	u16             IoIndex;                    /* 0x06 */
>+	__le16		InitiatorDevHandle;         /* 0x04 */
>+	__le16		IoIndex;                    /* 0x06 */
> };
>
> /* RAID Accelerator Success Reply Descriptor */  struct
>MPI2_RAID_ACCELERATOR_SUCCESS_REPLY_DESCRIPTOR {
> 	u8              ReplyFlags;                 /* 0x00 */
> 	u8              MSIxIndex;                  /* 0x01 */
>-	u16             SMID;                       /* 0x02 */
>-	u32             Reserved;                   /* 0x04 */
>+	__le16		SMID;                       /* 0x02 */
>+	__le32		Reserved;                   /* 0x04 */
> };
>
> /* union of Reply Descriptors */
>@@ -435,7 +435,7 @@ union MPI2_REPLY_DESCRIPTORS_UNION {
> 	struct MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR
>TargetCommandBuffer;
> 	struct MPI2_RAID_ACCELERATOR_SUCCESS_REPLY_DESCRIPTOR
> 	RAIDAcceleratorSuccess;
>-	u64                                             Words;
>+	__le64                                             Words;
> };
>
> /* IOCInit Request message */
>@@ -444,28 +444,28 @@ struct MPI2_IOC_INIT_REQUEST {
> 	u8                      Reserved1;                      /* 0x01 */
> 	u8                      ChainOffset;                    /* 0x02 */
> 	u8                      Function;                       /* 0x03 */
>-	u16                     Reserved2;                      /* 0x04 */
>+	__le16			Reserved2;                      /* 0x04 */
> 	u8                      Reserved3;                      /* 0x06 */
> 	u8                      MsgFlags;                       /* 0x07 */
> 	u8                      VP_ID;                          /* 0x08 */
> 	u8                      VF_ID;                          /* 0x09 */
>-	u16                     Reserved4;                      /* 0x0A */
>-	u16                     MsgVersion;                     /* 0x0C */
>-	u16                     HeaderVersion;                  /* 0x0E */
>+	__le16			Reserved4;                      /* 0x0A */
>+	__le16			MsgVersion;                     /* 0x0C */
>+	__le16			HeaderVersion;                  /* 0x0E */
> 	u32                     Reserved5;                      /* 0x10 */
>-	u16                     Reserved6;                      /* 0x14 */
>+	__le16			Reserved6;                      /* 0x14 */
> 	u8                      Reserved7;                      /* 0x16 */
> 	u8                      HostMSIxVectors;                /* 0x17 */
>-	u16                     Reserved8;                      /* 0x18 */
>-	u16                     SystemRequestFrameSize;         /* 0x1A */
>-	u16                     ReplyDescriptorPostQueueDepth;  /* 0x1C */
>-	u16                     ReplyFreeQueueDepth;            /* 0x1E */
>-	u32                     SenseBufferAddressHigh;         /* 0x20 */
>-	u32                     SystemReplyAddressHigh;         /* 0x24 */
>-	u64                     SystemRequestFrameBaseAddress;  /* 0x28 */
>-	u64                     ReplyDescriptorPostQueueAddress;/* 0x30 */
>-	u64                     ReplyFreeQueueAddress;          /* 0x38 */
>-	u64                     TimeStamp;                      /* 0x40 */
>+	__le16			Reserved8;                      /* 0x18 */
>+	__le16			SystemRequestFrameSize;         /* 0x1A */
>+	__le16			ReplyDescriptorPostQueueDepth;  /* 0x1C */
>+	__le16			ReplyFreeQueueDepth;            /* 0x1E */
>+	__le32			SenseBufferAddressHigh;         /* 0x20 */
>+	__le32			SystemReplyAddressHigh;         /* 0x24 */
>+	__le64			SystemRequestFrameBaseAddress;  /* 0x28
>*/
>+	__le64			ReplyDescriptorPostQueueAddress;/* 0x30 */
>+	__le64			ReplyFreeQueueAddress;          /* 0x38 */
>+	__le64			TimeStamp;                      /* 0x40 */
> };
>
> /* mrpriv defines */
>@@ -491,41 +491,41 @@ struct MPI2_IOC_INIT_REQUEST {
> #define MR_DCMD_LD_VF_MAP_GET_ALL_LDS       0x03150200
>
> struct MR_DEV_HANDLE_INFO {
>-	u16     curDevHdl;
>+	__le16	curDevHdl;
> 	u8      validHandles;
> 	u8      reserved;
>-	u16     devHandle[2];
>+	__le16	devHandle[2];
> };
>
> struct MR_ARRAY_INFO {
>-	u16      pd[MAX_RAIDMAP_ROW_SIZE];
>+	__le16	pd[MAX_RAIDMAP_ROW_SIZE];
> };
>
> struct MR_QUAD_ELEMENT {
>-	u64     logStart;
>-	u64     logEnd;
>-	u64     offsetInSpan;
>-	u32     diff;
>-	u32     reserved1;
>+	__le64     logStart;
>+	__le64     logEnd;
>+	__le64     offsetInSpan;
>+	__le32     diff;
>+	__le32     reserved1;
> };
>
> struct MR_SPAN_INFO {
>-	u32             noElements;
>-	u32             reserved1;
>+	__le32             noElements;
>+	__le32             reserved1;
> 	struct MR_QUAD_ELEMENT quad[MAX_RAIDMAP_SPAN_DEPTH];  };
>
> struct MR_LD_SPAN {
>-	u64      startBlk;
>-	u64      numBlks;
>-	u16      arrayRef;
>+	__le64	 startBlk;
>+	__le64	 numBlks;
>+	__le16	 arrayRef;
> 	u8       spanRowSize;
> 	u8       spanRowDataSize;
> 	u8       reserved[4];
> };
>
> struct MR_SPAN_BLOCK_INFO {
>-	u64          num_rows;
>+	__le64          num_rows;
> 	struct MR_LD_SPAN   span;
> 	struct MR_SPAN_INFO block_span_info;
> };
>@@ -558,8 +558,8 @@ struct MR_LD_RAID {
> 		u32     reserved4:7;
> #endif
> 	} capability;
>-	u32     reserved6;
>-	u64     size;
>+	__le32     reserved6;
>+	__le64     size;
> 	u8      spanDepth;
> 	u8      level;
> 	u8      stripeShift;
>@@ -568,12 +568,12 @@ struct MR_LD_RAID {
> 	u8      writeMode;
> 	u8      PRL;
> 	u8      SRL;
>-	u16     targetId;
>+	__le16     targetId;
> 	u8      ldState;
> 	u8      regTypeReqOnWrite;
> 	u8      modFactor;
> 	u8	regTypeReqOnRead;
>-	u16     seqNum;
>+	__le16     seqNum;
>
> 	struct {
> 		u32 ldSyncRequired:1;
>@@ -592,20 +592,20 @@ struct MR_LD_SPAN_MAP {  };
>
> struct MR_FW_RAID_MAP {
>-	u32                 totalSize;
>+	__le32                 totalSize;
> 	union {
> 		struct {
>-			u32         maxLd;
>-			u32         maxSpanDepth;
>-			u32         maxRowSize;
>-			u32         maxPdCount;
>-			u32         maxArrays;
>+			__le32         maxLd;
>+			__le32         maxSpanDepth;
>+			__le32         maxRowSize;
>+			__le32         maxPdCount;
>+			__le32         maxArrays;
> 		} validationInfo;
>-		u32             version[5];
>+		__le32             version[5];
> 	};
>
>-	u32                 ldCount;
>-	u32                 Reserved1;
>+	__le32                 ldCount;
>+	__le32                 Reserved1;
> 	u8                  ldTgtIdToLd[MAX_RAIDMAP_LOGICAL_DRIVES+
> 					MAX_RAIDMAP_VIEWS];
> 	u8                  fpPdIoTimeoutSec;
>@@ -620,7 +620,7 @@ struct IO_REQUEST_INFO {
> 	u32 numBlocks;
> 	u16 ldTgtId;
> 	u8 isRead;
>-	u16 devHandle;
>+	__le16 devHandle;
> 	u64 pdBlock;
> 	u8 fpOkForIo;
> 	u8 IoforUnevenSpan;
>@@ -634,7 +634,7 @@ struct IO_REQUEST_INFO {  struct
>MR_LD_TARGET_SYNC {
> 	u8  targetId;
> 	u8  reserved;
>-	u16 seqNum;
>+	__le16 seqNum;
> };
>
> #define IEEE_SGE_FLAGS_ADDR_MASK            (0x03)
>@@ -720,27 +720,27 @@ struct MR_DRV_RAID_MAP {
> 	 * This feild will be manupulated by driver for ext raid map,
> 	 * else pick the value from firmware raid map.
> 	 */
>-	u32                 totalSize;
>+	__le32                 totalSize;
>
> 	union {
> 	struct {
>-		u32         maxLd;
>-		u32         maxSpanDepth;
>-		u32         maxRowSize;
>-		u32         maxPdCount;
>-		u32         maxArrays;
>+		__le32         maxLd;
>+		__le32         maxSpanDepth;
>+		__le32         maxRowSize;
>+		__le32         maxPdCount;
>+		__le32         maxArrays;
> 	} validationInfo;
>-	u32             version[5];
>+	__le32             version[5];
> 	};
>
> 	/* timeout value used by driver in FP IOs*/
> 	u8                  fpPdIoTimeoutSec;
> 	u8                  reserved2[7];
>
>-	u16                 ldCount;
>-	u16                 arCount;
>-	u16                 spanCount;
>-	u16                 reserve3;
>+	__le16                 ldCount;
>+	__le16                 arCount;
>+	__le16                 spanCount;
>+	__le16                 reserve3;
>
> 	struct MR_DEV_HANDLE_INFO
>devHndlInfo[MAX_RAIDMAP_PHYSICAL_DEVICES];
> 	u8                  ldTgtIdToLd[MAX_LOGICAL_DRIVES_EXT];
>@@ -779,10 +779,10 @@ struct MR_FW_RAID_MAP_EXT {
> 	u8                  fpPdIoTimeoutSec;
> 	u8                  reserved2[7];
>
>-	u16                 ldCount;
>-	u16                 arCount;
>-	u16                 spanCount;
>-	u16                 reserve3;
>+	__le16                 ldCount;
>+	__le16                 arCount;
>+	__le16                 spanCount;
>+	__le16                 reserve3;
>
> 	struct MR_DEV_HANDLE_INFO
>devHndlInfo[MAX_RAIDMAP_PHYSICAL_DEVICES];
> 	u8                  ldTgtIdToLd[MAX_LOGICAL_DRIVES_EXT];
>@@ -839,10 +839,10 @@ struct fusion_context {  };
>
> union desc_value {
>-	u64 word;
>+	__le64 word;
> 	struct {
>-		u32 low;
>-		u32 high;
>+		__le32 low;
>+		__le32 high;
> 	} u;
> };
>
Acked-by: Sumit Saxena <sumit.saxena@avagotech.com>

>--
>1.9.1

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH 04/10] megaraid_sas: add endianess conversions for all ones
  2015-01-10 17:11 ` [PATCH 04/10] megaraid_sas: add endianess conversions for all ones Christoph Hellwig
@ 2015-01-13  7:21   ` Sumit Saxena
  0 siblings, 0 replies; 21+ messages in thread
From: Sumit Saxena @ 2015-01-13  7:21 UTC (permalink / raw)
  To: Christoph Hellwig, Kashyap Desai; +Cc: martin.petersen, linux-scsi

>-----Original Message-----
>From: Christoph Hellwig [mailto:hch@lst.de]
>Sent: Saturday, January 10, 2015 10:41 PM
>To: Sumit.Saxena@avagotech.com; kashyap.desai@avagotech.com
>Cc: martin.petersen@oracle.com; linux-scsi@vger.kernel.org
>Subject: [PATCH 04/10] megaraid_sas: add endianess conversions for all
ones
>
>Add noop conversions for all ones to make sparse happy.
>
>Signed-off-by: Christoph Hellwig <hch@lst.de>
>---
> drivers/scsi/megaraid/megaraid_sas_base.c   | 2 +-
> drivers/scsi/megaraid/megaraid_sas_fp.c     | 7 ++++---
> drivers/scsi/megaraid/megaraid_sas_fusion.c | 9 +++++----
> 3 files changed, 10 insertions(+), 8 deletions(-)
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c
>b/drivers/scsi/megaraid/megaraid_sas_base.c
>index cb7d0c4..a6556ea 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_base.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
>@@ -1232,7 +1232,7 @@ megasas_build_dcdb(struct megasas_instance
>*instance, struct scsi_cmnd *scp,
> 	*/
> 	if (scp->device->type == TYPE_TAPE) {
> 		if ((scp->request->timeout / HZ) > 0xFFFF)
>-			pthru->timeout = 0xFFFF;
>+			pthru->timeout = cpu_to_le16(0xFFFF);
> 		else
> 			pthru->timeout = cpu_to_le16(scp->request-
>>timeout / HZ);
> 	}
>diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c
>b/drivers/scsi/megaraid/megaraid_sas_fp.c
>index e9138a2..2001ffb 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
>@@ -769,7 +769,7 @@ 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 &&
> 			(raid->regTypeReqOnRead !=
>REGION_TYPE_UNUSED)))) @@ -864,7 +864,8 @@ 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 &&
> 			(raid->regTypeReqOnRead !=
>REGION_TYPE_UNUSED)))) @@ -1109,7 +1110,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) {
>diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c
>b/drivers/scsi/megaraid/megaraid_sas_fusion.c
>index 983635f..82439f9 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
>@@ -464,7 +464,7 @@ megasas_alloc_cmds_fusion(struct megasas_instance
>*instance)
>
> 	reply_desc = fusion->reply_frames_desc;
> 	for (i = 0; i < fusion->reply_q_depth * count; i++, reply_desc++)
>-		reply_desc->Words = ULLONG_MAX;
>+		reply_desc->Words = cpu_to_le64(ULLONG_MAX);
>
> 	io_frames_sz = fusion->io_frames_alloc_sz;
>
>@@ -1995,7 +1995,8 @@ complete_cmd_fusion(struct megasas_instance
>*instance, u32 MSIxIndex)
>
> 	num_completed = 0;
>
>-	while ((d_val.u.low != UINT_MAX) && (d_val.u.high != UINT_MAX)) {
>+	while (d_val.u.low != cpu_to_le32(UINT_MAX) &&
>+	       d_val.u.high != cpu_to_le32(UINT_MAX)) {
> 		smid = le16_to_cpu(reply_desc->SMID);
>
> 		cmd_fusion = fusion->cmd_list[smid - 1]; @@ -2063,7
+2064,7
>@@ complete_cmd_fusion(struct megasas_instance *instance, u32
>MSIxIndex)
> 		    fusion->reply_q_depth)
> 			fusion->last_reply_idx[MSIxIndex] = 0;
>
>-		desc->Words = ULLONG_MAX;
>+		desc->Words = cpu_to_le64(ULLONG_MAX);
> 		num_completed++;
> 		threshold_reply_count++;
>
>@@ -2505,7 +2506,7 @@ void  megasas_reset_reply_desc(struct
>megasas_instance *instance)
> 		fusion->last_reply_idx[i] = 0;
> 	reply_desc = fusion->reply_frames_desc;
> 	for (i = 0 ; i < fusion->reply_q_depth * count; i++, reply_desc++)
>-		reply_desc->Words = ULLONG_MAX;
>+		reply_desc->Words = cpu_to_le64(ULLONG_MAX);
> }
>
> /* Check for a second path that is currently UP */
Acked-by: Sumit Saxena <sumit.saxena@avagotech.com>

>--
>1.9.1

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH 05/10] megaraid_sas: move endianess conversion into caller of megasas_get_seq_num
  2015-01-10 17:11 ` [PATCH 05/10] megaraid_sas: move endianess conversion into caller of megasas_get_seq_num Christoph Hellwig
@ 2015-01-13  7:23   ` Sumit Saxena
  0 siblings, 0 replies; 21+ messages in thread
From: Sumit Saxena @ 2015-01-13  7:23 UTC (permalink / raw)
  To: Christoph Hellwig, Kashyap Desai; +Cc: martin.petersen, linux-scsi

>-----Original Message-----
>From: Christoph Hellwig [mailto:hch@lst.de]
>Sent: Saturday, January 10, 2015 10:41 PM
>To: Sumit.Saxena@avagotech.com; kashyap.desai@avagotech.com
>Cc: martin.petersen@oracle.com; linux-scsi@vger.kernel.org
>Subject: [PATCH 05/10] megaraid_sas: move endianess conversion into
caller
>of megasas_get_seq_num
>
>Converting structure fields in place is always a bad idea, and in this
case by
>moving it into the only caller we also only have to do a single byte swap
as
>most fields of this structure are never used.
>
>Signed-off-by: Christoph Hellwig <hch@lst.de>
>---
> drivers/scsi/megaraid/megaraid_sas_base.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c
>b/drivers/scsi/megaraid/megaraid_sas_base.c
>index a6556ea..548d033 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_base.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
>@@ -4823,11 +4823,11 @@ megasas_get_seq_num(struct megasas_instance
>*instance,
> 		/*
> 		 * Copy the data back into callers buffer
> 		 */
>-		eli->newest_seq_num = le32_to_cpu(el_info-
>>newest_seq_num);
>-		eli->oldest_seq_num = le32_to_cpu(el_info-
>>oldest_seq_num);
>-		eli->clear_seq_num = le32_to_cpu(el_info->clear_seq_num);
>-		eli->shutdown_seq_num = le32_to_cpu(el_info-
>>shutdown_seq_num);
>-		eli->boot_seq_num = le32_to_cpu(el_info->boot_seq_num);
>+		eli->newest_seq_num = el_info->newest_seq_num;
>+		eli->oldest_seq_num = el_info->oldest_seq_num;
>+		eli->clear_seq_num = el_info->clear_seq_num;
>+		eli->shutdown_seq_num = el_info->shutdown_seq_num;
>+		eli->boot_seq_num = el_info->boot_seq_num;
> 	}
>
> 	pci_free_consistent(instance->pdev, sizeof(struct
>megasas_evt_log_info), @@ -4991,7 +4991,7 @@ static int
>megasas_start_aen(struct megasas_instance *instance)
> 	class_locale.members.class = MR_EVT_CLASS_DEBUG;
>
> 	return megasas_register_aen(instance,
>-			eli.newest_seq_num + 1,
>+			le32_to_cpu(eli.newest_seq_num) + 1,
> 			class_locale.word);
> }
>
Acked-by: Sumit Saxena <sumit.saxena@avagotech.com>

>--
>1.9.1

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH 06/10] megaraid_sas: bytewise or should be done on native endian variables
  2015-01-10 17:11 ` [PATCH 06/10] megaraid_sas: bytewise or should be done on native endian variables Christoph Hellwig
@ 2015-01-14 11:01   ` Sumit Saxena
  0 siblings, 0 replies; 21+ messages in thread
From: Sumit Saxena @ 2015-01-14 11:01 UTC (permalink / raw)
  To: Christoph Hellwig, Kashyap Desai; +Cc: martin.petersen, linux-scsi

>-----Original Message-----
>From: Christoph Hellwig [mailto:hch@lst.de]
>Sent: Saturday, January 10, 2015 10:41 PM
>To: Sumit.Saxena@avagotech.com; kashyap.desai@avagotech.com
>Cc: martin.petersen@oracle.com; linux-scsi@vger.kernel.org
>Subject: [PATCH 06/10] megaraid_sas: bytewise or should be done on native
>endian variables
>
>Signed-off-by: Christoph Hellwig <hch@lst.de>
>---
> drivers/scsi/megaraid/megaraid_sas_fusion.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c
>b/drivers/scsi/megaraid/megaraid_sas_fusion.c
>index 82439f9..b1e053b 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
>@@ -673,7 +673,9 @@ megasas_ioc_init_fusion(struct megasas_instance
>*instance)
>
> 	frame_hdr = &cmd->frame->hdr;
> 	frame_hdr->cmd_status = 0xFF;
>-	frame_hdr->flags |=
>cpu_to_le16(MFI_FRAME_DONT_POST_IN_REPLY_QUEUE);
>+	frame_hdr->flags = cpu_to_le16(
>+		le16_to_cpu(frame_hdr->flags) |
>+		MFI_FRAME_DONT_POST_IN_REPLY_QUEUE);
>
> 	init_frame->cmd	= MFI_CMD_INIT;
> 	init_frame->cmd_status = 0xFF;

Acked-by: Sumit Saxena <sumit.saxena@avagotech.com>

>--
>1.9.1

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH 07/10] megaraid_sas: add missing byte swaps to the sriov code
  2015-01-10 17:11 ` [PATCH 07/10] megaraid_sas: add missing byte swaps to the sriov code Christoph Hellwig
@ 2015-01-14 11:02   ` Sumit Saxena
  0 siblings, 0 replies; 21+ messages in thread
From: Sumit Saxena @ 2015-01-14 11:02 UTC (permalink / raw)
  To: Christoph Hellwig, Kashyap Desai; +Cc: martin.petersen, linux-scsi

>-----Original Message-----
>From: Christoph Hellwig [mailto:hch@lst.de]
>Sent: Saturday, January 10, 2015 10:41 PM
>To: Sumit.Saxena@avagotech.com; kashyap.desai@avagotech.com
>Cc: martin.petersen@oracle.com; linux-scsi@vger.kernel.org
>Subject: [PATCH 07/10] megaraid_sas: add missing byte swaps to the sriov
>code
>
>Signed-off-by: Christoph Hellwig <hch@lst.de>
>---
> drivers/scsi/megaraid/megaraid_sas_base.c | 46 +++++++++++++++++-------
>-------
> 1 file changed, 25 insertions(+), 21 deletions(-)
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c
>b/drivers/scsi/megaraid/megaraid_sas_base.c
>index 548d033..5350e18 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_base.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
>@@ -1924,20 +1924,22 @@ static int
>megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance,
> 	dcmd->cmd = MFI_CMD_DCMD;
> 	dcmd->cmd_status = 0xFF;
> 	dcmd->sge_count = 1;
>-	dcmd->flags = MFI_FRAME_DIR_BOTH;
>+	dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH);
> 	dcmd->timeout = 0;
> 	dcmd->pad_0 = 0;
>-	dcmd->data_xfer_len = sizeof(struct MR_LD_VF_AFFILIATION_111);
>-	dcmd->opcode = MR_DCMD_LD_VF_MAP_GET_ALL_LDS_111;
>+	dcmd->data_xfer_len =
>+		cpu_to_le32(sizeof(struct MR_LD_VF_AFFILIATION_111));
>+	dcmd->opcode =
>cpu_to_le32(MR_DCMD_LD_VF_MAP_GET_ALL_LDS_111);
>
> 	if (initial)
> 		dcmd->sgl.sge32[0].phys_addr =
>-			instance->vf_affiliation_111_h;
>+			cpu_to_le32(instance->vf_affiliation_111_h);
> 	else
>-		dcmd->sgl.sge32[0].phys_addr = new_affiliation_111_h;
>+		dcmd->sgl.sge32[0].phys_addr =
>+			cpu_to_le32(new_affiliation_111_h);
>
>-	dcmd->sgl.sge32[0].length =
>-		sizeof(struct MR_LD_VF_AFFILIATION_111);
>+	dcmd->sgl.sge32[0].length = cpu_to_le32(
>+		sizeof(struct MR_LD_VF_AFFILIATION_111));
>
> 	printk(KERN_WARNING "megasas: SR-IOV: Getting LD/VF affiliation
>for "
> 	       "scsi%d\n", instance->host->host_no); @@ -2039,20 +2041,22
@@
>static int megasas_get_ld_vf_affiliation_12(struct megasas_instance
>*instance,
> 	dcmd->cmd = MFI_CMD_DCMD;
> 	dcmd->cmd_status = 0xFF;
> 	dcmd->sge_count = 1;
>-	dcmd->flags = MFI_FRAME_DIR_BOTH;
>+	dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH);
> 	dcmd->timeout = 0;
> 	dcmd->pad_0 = 0;
>-	dcmd->data_xfer_len = (MAX_LOGICAL_DRIVES + 1) *
>-		sizeof(struct MR_LD_VF_AFFILIATION);
>-	dcmd->opcode = MR_DCMD_LD_VF_MAP_GET_ALL_LDS;
>+	dcmd->data_xfer_len = cpu_to_le32((MAX_LOGICAL_DRIVES + 1) *
>+		sizeof(struct MR_LD_VF_AFFILIATION));
>+	dcmd->opcode =
>cpu_to_le32(MR_DCMD_LD_VF_MAP_GET_ALL_LDS);
>
> 	if (initial)
>-		dcmd->sgl.sge32[0].phys_addr = instance->vf_affiliation_h;
>+		dcmd->sgl.sge32[0].phys_addr =
>+			cpu_to_le32(instance->vf_affiliation_h);
> 	else
>-		dcmd->sgl.sge32[0].phys_addr = new_affiliation_h;
>+		dcmd->sgl.sge32[0].phys_addr =
>+			cpu_to_le32(new_affiliation_h);;
>
>-	dcmd->sgl.sge32[0].length = (MAX_LOGICAL_DRIVES + 1) *
>-		sizeof(struct MR_LD_VF_AFFILIATION);
>+	dcmd->sgl.sge32[0].length = cpu_to_le32((MAX_LOGICAL_DRIVES +
>1) *
>+		sizeof(struct MR_LD_VF_AFFILIATION));
>
> 	printk(KERN_WARNING "megasas: SR-IOV: Getting LD/VF affiliation
>for "
> 	       "scsi%d\n", instance->host->host_no); @@ -2204,17 +2208,17
@@
>int megasas_sriov_start_heartbeat(struct megasas_instance *instance,
>
> 	memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
>
>-	dcmd->mbox.s[0] = sizeof(struct MR_CTRL_HB_HOST_MEM);
>+	dcmd->mbox.s[0] = cpu_to_le16(sizeof(struct
>MR_CTRL_HB_HOST_MEM));
> 	dcmd->cmd = MFI_CMD_DCMD;
> 	dcmd->cmd_status = 0xFF;
> 	dcmd->sge_count = 1;
>-	dcmd->flags = MFI_FRAME_DIR_BOTH;
>+	dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_BOTH);
> 	dcmd->timeout = 0;
> 	dcmd->pad_0 = 0;
>-	dcmd->data_xfer_len = sizeof(struct MR_CTRL_HB_HOST_MEM);
>-	dcmd->opcode = MR_DCMD_CTRL_SHARED_HOST_MEM_ALLOC;
>-	dcmd->sgl.sge32[0].phys_addr = instance->hb_host_mem_h;
>-	dcmd->sgl.sge32[0].length = sizeof(struct
>MR_CTRL_HB_HOST_MEM);
>+	dcmd->data_xfer_len = cpu_to_le32(sizeof(struct
>MR_CTRL_HB_HOST_MEM));
>+	dcmd->opcode =
>cpu_to_le32(MR_DCMD_CTRL_SHARED_HOST_MEM_ALLOC);
>+	dcmd->sgl.sge32[0].phys_addr = cpu_to_le32(instance-
>>hb_host_mem_h);
>+	dcmd->sgl.sge32[0].length = cpu_to_le32(sizeof(struct
>+MR_CTRL_HB_HOST_MEM));
>
> 	printk(KERN_WARNING "megasas: SR-IOV: Starting heartbeat for
>scsi%d\n",
> 	       instance->host->host_no);
Acked-by: Sumit Saxena <sumit.saxena@avagotech.com>

>--
>1.9.1

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH 08/10] megaraid_sas: fix megasas_fire_cmd_fusion calling convention
  2015-01-10 17:11 ` [PATCH 08/10] megaraid_sas: fix megasas_fire_cmd_fusion calling convention Christoph Hellwig
@ 2015-01-14 11:05   ` Sumit Saxena
  0 siblings, 0 replies; 21+ messages in thread
From: Sumit Saxena @ 2015-01-14 11:05 UTC (permalink / raw)
  To: Christoph Hellwig, Kashyap Desai; +Cc: martin.petersen, linux-scsi

>-----Original Message-----
>From: Christoph Hellwig [mailto:hch@lst.de]
>Sent: Saturday, January 10, 2015 10:41 PM
>To: Sumit.Saxena@avagotech.com; kashyap.desai@avagotech.com
>Cc: martin.petersen@oracle.com; linux-scsi@vger.kernel.org
>Subject: [PATCH 08/10] megaraid_sas: fix megasas_fire_cmd_fusion calling
>convention
>
>The fusion HBAs don't really use the instance template like the other
variants,
>as it branches off at a much higher level.  So instead of trying to
squeeze
>megasas_fire_cmd_fusion into the wrong calling convention call it locally
with
>argument data types that match what is passed.
>
>Signed-off-by: Christoph Hellwig <hch@lst.de>
>---
> drivers/scsi/megaraid/megaraid_sas_fusion.c | 73
++++++++++++-------------
>----
> 1 file changed, 29 insertions(+), 44 deletions(-)
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c
>b/drivers/scsi/megaraid/megaraid_sas_fusion.c
>index b1e053b..5a45764 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
>@@ -230,6 +230,31 @@ inline void megasas_return_mfi_mpt_pthr(struct
>megasas_instance *instance,  }
>
> /**
>+ * megasas_fire_cmd_fusion -	Sends command to the FW
>+ */
>+static void
>+megasas_fire_cmd_fusion(struct megasas_instance *instance,
>+		union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc)
>{ #if
>+defined(writeq) && defined(CONFIG_64BIT)
>+	u64 req_data = (((u64)le32_to_cpu(req_desc->u.low) << 32) |
>+			le32_to_cpu(req_desc->u.high));

In req_data building, positions of "req_desc->u.low" and
"req_desc->u.high" are swapped.
req_data should be like below:
	u64 req_data = (((u64)le32_to_cpu(req_desc->u.high) << 32) |
			le32_to_cpu(req_desc->u.low));

I will post new patch with this change.

Thanks,
Sumit

>+
>+	writeq(req_data, &instance->reg_set->inbound_low_queue_port);
>+#else
>+	unsigned long flags;
>+
>+	spin_lock_irqsave(&instance->hba_lock, flags);
>+	writel(le32_to_cpu(req_desc->u.low),
>+		&instance->reg_set->inbound_low_queue_port);
>+	writel(le32_to_cpu(req_desc.u.high),
>+		&instance->reg_set->inbound_high_queue_port);
>+	spin_unlock_irqrestore(&instance->hba_lock, flags); #endif }
>+
>+
>+/**
>  * megasas_teardown_frame_pool_fusion -	Destroy the cmd frame DMA
>pool
>  * @instance:				Adapter soft state
>  */
>@@ -721,8 +746,7 @@ megasas_ioc_init_fusion(struct megasas_instance
>*instance)
> 			break;
> 	}
>
>-	instance->instancet->fire_cmd(instance, req_desc.u.low,
>-				      req_desc.u.high, instance->reg_set);
>+	megasas_fire_cmd_fusion(instance, &req_desc);
>
> 	wait_and_poll(instance, cmd, MFI_POLL_TIMEOUT_SECS);
>
>@@ -1133,34 +1157,6 @@ fail_alloc_mfi_cmds:
> }
>
> /**
>- * megasas_fire_cmd_fusion -	Sends command to the FW
>- * @frame_phys_addr :		Physical address of cmd
>- * @frame_count :		Number of frames for the command
>- * @regs :			MFI register set
>- */
>-void
>-megasas_fire_cmd_fusion(struct megasas_instance *instance,
>-			dma_addr_t req_desc_lo,
>-			u32 req_desc_hi,
>-			struct megasas_register_set __iomem *regs)
>-{
>-#if defined(writeq) && defined(CONFIG_64BIT)
>-	u64 req_data = (((u64)le32_to_cpu(req_desc_hi) << 32) |
>-			le32_to_cpu(req_desc_lo));
>-
>-	writeq(req_data, &(regs)->inbound_low_queue_port);
>-#else
>-	unsigned long flags;
>-
>-	spin_lock_irqsave(&instance->hba_lock, flags);
>-
>-	writel(le32_to_cpu(req_desc_lo), &(regs)-
>>inbound_low_queue_port);
>-	writel(le32_to_cpu(req_desc_hi), &(regs)-
>>inbound_high_queue_port);
>-	spin_unlock_irqrestore(&instance->hba_lock, flags);
>-#endif
>-}
>-
>-/**
>  * map_cmd_status -	Maps FW cmd status to OS cmd status
>  * @cmd :		Pointer to cmd
>  * @status :		status of cmd returned by FW
>@@ -1947,9 +1943,7 @@ megasas_build_and_issue_cmd_fusion(struct
>megasas_instance *instance,
> 	 */
> 	atomic_inc(&instance->fw_outstanding);
>
>-	instance->instancet->fire_cmd(instance,
>-				      req_desc->u.low, req_desc->u.high,
>-				      instance->reg_set);
>+	megasas_fire_cmd_fusion(instance, req_desc);
>
> 	return 0;
> }
>@@ -2328,8 +2322,7 @@ megasas_issue_dcmd_fusion(struct
>megasas_instance *instance,
> 		return;
> 	}
> 	atomic_set(&cmd->mfi_mpt_pthr, MFI_MPT_ATTACHED);
>-	instance->instancet->fire_cmd(instance, req_desc->u.low,
>-				      req_desc->u.high,
instance->reg_set);
>+	megasas_fire_cmd_fusion(instance, req_desc);
> }
>
> /**
>@@ -2816,14 +2809,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost,
>int iotimeout)
> 							   frame */
>
>	megasas_return_cmd_fusion(instance, cmd_fusion);
> 						} else {
>-
instance->instancet->
>-							fire_cmd(instance,
>-
req_desc->
>-								 u.low,
>-
req_desc->
>-								 u.high,
>-
instance->
>-								 reg_set);
>+
>	megasas_fire_cmd_fusion(instance, req_desc);
> 						}
> 					}
> 				}
>@@ -2978,7 +2964,6 @@ void megasas_fusion_ocr_wq(struct work_struct
>*work)
> }
>
> struct megasas_instance_template megasas_instance_template_fusion = {
>-	.fire_cmd = megasas_fire_cmd_fusion,
> 	.enable_intr = megasas_enable_intr_fusion,
> 	.disable_intr = megasas_disable_intr_fusion,
> 	.clear_intr = megasas_clear_intr_fusion,
>--
>1.9.1

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH 09/10] megaraid_sas: swap whole register in megasas_register_aen
  2015-01-10 17:11 ` [PATCH 09/10] megaraid_sas: swap whole register in megasas_register_aen Christoph Hellwig
@ 2015-01-14 11:07   ` Sumit Saxena
  0 siblings, 0 replies; 21+ messages in thread
From: Sumit Saxena @ 2015-01-14 11:07 UTC (permalink / raw)
  To: Christoph Hellwig, Kashyap Desai; +Cc: martin.petersen, linux-scsi

>-----Original Message-----
>From: Christoph Hellwig [mailto:hch@lst.de]
>Sent: Saturday, January 10, 2015 10:41 PM
>To: Sumit.Saxena@avagotech.com; kashyap.desai@avagotech.com
>Cc: martin.petersen@oracle.com; linux-scsi@vger.kernel.org
>Subject: [PATCH 09/10] megaraid_sas: swap whole register in
>megasas_register_aen
>
>Swap the whole 32 bits we read from the hardware instead of swapping just
>the 16bits we care about in place later.
>
>Signed-off-by: Christoph Hellwig <hch@lst.de>
>---
> drivers/scsi/megaraid/megaraid_sas_base.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c
>b/drivers/scsi/megaraid/megaraid_sas_base.c
>index 5350e18..3d4a080 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_base.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
>@@ -4882,8 +4882,9 @@ megasas_register_aen(struct megasas_instance
>*instance, u32 seq_num,
>
> 	if (instance->aen_cmd) {
>
>-		prev_aen.word = instance->aen_cmd->frame-
>>dcmd.mbox.w[1];
>-		prev_aen.members.locale =
>le16_to_cpu(prev_aen.members.locale);
>+		prev_aen.word =
>+			le32_to_cpu(instance->aen_cmd->frame-
>>dcmd.mbox.w[1]);
>+		prev_aen.members.locale = prev_aen.members.locale;
>
> 		/*
> 		 * A class whose enum value is smaller is inclusive of all

Looks good to me.
Acked-by: Sumit Saxena <sumit.saxena@avagotech.com>

>--
>1.9.1

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH 10/10] megaraid_sas: fix endianess for the crash dump state support
  2015-01-10 17:11 ` [PATCH 10/10] megaraid_sas: fix endianess for the crash dump state support Christoph Hellwig
@ 2015-01-14 12:01   ` Sumit Saxena
  0 siblings, 0 replies; 21+ messages in thread
From: Sumit Saxena @ 2015-01-14 12:01 UTC (permalink / raw)
  To: Christoph Hellwig, Kashyap Desai; +Cc: martin.petersen, linux-scsi

>-----Original Message-----
>From: Christoph Hellwig [mailto:hch@lst.de]
>Sent: Saturday, January 10, 2015 10:41 PM
>To: Sumit.Saxena@avagotech.com; kashyap.desai@avagotech.com
>Cc: martin.petersen@oracle.com; linux-scsi@vger.kernel.org
>Subject: [PATCH 10/10] megaraid_sas: fix endianess for the crash dump
state
>support
>
>Note that this one is a bit fishy: it seems like it should always be read
and
>written using either words or bytes, but never using a mixture.
>
>Please verify against the hardware documentation.
>
>Signed-off-by: Christoph Hellwig <hch@lst.de>
>---
> drivers/scsi/megaraid/megaraid_sas.h      | 2 +-
> drivers/scsi/megaraid/megaraid_sas_base.c | 7 ++++---
> 2 files changed, 5 insertions(+), 4 deletions(-)
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas.h
>b/drivers/scsi/megaraid/megaraid_sas.h
>index 81484f1..465dd45 100644
>--- a/drivers/scsi/megaraid/megaraid_sas.h
>+++ b/drivers/scsi/megaraid/megaraid_sas.h
>@@ -1676,7 +1676,7 @@ struct megasas_instance {
> 	u32 drv_buf_alloc;
> 	u32 crash_dump_fw_support;
> 	u32 crash_dump_drv_support;
>-	u32 crash_dump_app_support;
>+	__le32 crash_dump_app_support;
> 	u32 secure_jbod_support;
> 	spinlock_t crashdump_lock;
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c
>b/drivers/scsi/megaraid/megaraid_sas_base.c
>index 3d4a080..29a1b20 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_base.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
>@@ -6010,7 +6010,7 @@ static int megasas_set_crash_dump_params_ioctl(
> {
> 	struct megasas_instance *local_instance;
> 	int i, error = 0;
>-	int crash_support;
>+	__le32 crash_support;
>
> 	crash_support = cmd->frame->dcmd.mbox.w[0];
>
>@@ -6020,7 +6020,7 @@ static int megasas_set_crash_dump_params_ioctl(
> 			if ((local_instance->adprecovery ==
> 				MEGASAS_HBA_OPERATIONAL) &&
>
>	!megasas_set_crash_dump_params(local_instance,
>-					crash_support)) {
>+					le32_to_cpu(crash_support))) {
> 				local_instance->crash_dump_app_support =
> 					crash_support;
> 				dev_info(&local_instance->pdev->dev,
>@@ -6084,7 +6084,8 @@ megasas_mgmt_fw_ioctl(struct megasas_instance
>*instance,
> 					       MFI_FRAME_SGL64 |
> 					       MFI_FRAME_SENSE64));
>
>-	if (cmd->frame->dcmd.opcode ==
>MR_DRIVER_SET_APP_CRASHDUMP_MODE) {
>+	if (cmd->frame->dcmd.opcode ==
>+
>	cpu_to_le32(MR_DRIVER_SET_APP_CRASHDUMP_MODE)) {

Application will not do any byte swapping for this DCMD
frame(MR_DRIVER_SET_APP_CRASHDUMP_MODE) to convert it in LE format, since
this DCMD will not be sent to firmware, driver will only process this DCMD
and fire another DCMD- MR_DCMD_CTRL_SET_CRASH_DUMP_PARAMS to firmware.
DCMD frame will always be in CPU format only.
So this "if" condition does not need
cpu_to_le32(MR_DRIVER_SET_APP_CRASHDUMP_MODE).


> 		error = megasas_set_crash_dump_params_ioctl(cmd);
> 		megasas_return_cmd(instance, cmd);
> 		return error;
>--
>1.9.1

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2015-01-14 12:01 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-10 17:11 megaraid_sas: sparse annotations and endianess fixes Christoph Hellwig
2015-01-10 17:11 ` [PATCH 01/10] megaraid_sas: megasas_complete_outstanding_ioctls() can be static Christoph Hellwig
2015-01-13  5:38   ` Sumit Saxena
2015-01-10 17:11 ` [PATCH 02/10] megaraid_sas: add missing __iomem annotations Christoph Hellwig
2015-01-13  7:05   ` Sumit Saxena
2015-01-10 17:11 ` [PATCH 03/10] megaraid_sas: add endianess annotations Christoph Hellwig
2015-01-13  7:17   ` Sumit Saxena
2015-01-10 17:11 ` [PATCH 04/10] megaraid_sas: add endianess conversions for all ones Christoph Hellwig
2015-01-13  7:21   ` Sumit Saxena
2015-01-10 17:11 ` [PATCH 05/10] megaraid_sas: move endianess conversion into caller of megasas_get_seq_num Christoph Hellwig
2015-01-13  7:23   ` Sumit Saxena
2015-01-10 17:11 ` [PATCH 06/10] megaraid_sas: bytewise or should be done on native endian variables Christoph Hellwig
2015-01-14 11:01   ` Sumit Saxena
2015-01-10 17:11 ` [PATCH 07/10] megaraid_sas: add missing byte swaps to the sriov code Christoph Hellwig
2015-01-14 11:02   ` Sumit Saxena
2015-01-10 17:11 ` [PATCH 08/10] megaraid_sas: fix megasas_fire_cmd_fusion calling convention Christoph Hellwig
2015-01-14 11:05   ` Sumit Saxena
2015-01-10 17:11 ` [PATCH 09/10] megaraid_sas: swap whole register in megasas_register_aen Christoph Hellwig
2015-01-14 11:07   ` Sumit Saxena
2015-01-10 17:11 ` [PATCH 10/10] megaraid_sas: fix endianess for the crash dump state support Christoph Hellwig
2015-01-14 12:01   ` Sumit Saxena

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).