aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen M. Cameron <stephenmcameron@gmail.com>2014-11-14 18:26:59 -0500
committerChristoph Hellwig <hch@lst.de>2014-11-20 03:11:24 -0500
commit50a0decf75b66480aa5b076d4e1bca11bc202efe (patch)
tree6e562079679e9310ebfd174cdbe84128e5a4b74c
parent92084715f4d296c99ac120b3b77cf72d5c194c86 (diff)
hpsa: fix endianness issue with scatter gather elements
The hardware needs little endian scatter gather addresses and lengths but we were not bothering to convert from cpu byte order as we should have been. On Intel, this is all just a bunch of no-ops macros, but it makes the code endian-clean(er). Signed-off-by: Don Brace <don.brace@pmcs.com> Signed-off-by: Robert Elliott <elliott@hp.com> Reviewed-by: Webb Scales <webbnh@hp.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/scsi/hpsa.c223
-rw-r--r--drivers/scsi/hpsa_cmd.h14
2 files changed, 107 insertions, 130 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index e788e6822b1b..b082594e7c69 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1502,22 +1502,22 @@ static int hpsa_map_sg_chain_block(struct ctlr_info *h,
1502{ 1502{
1503 struct SGDescriptor *chain_sg, *chain_block; 1503 struct SGDescriptor *chain_sg, *chain_block;
1504 u64 temp64; 1504 u64 temp64;
1505 u32 chain_len;
1505 1506
1506 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; 1507 chain_sg = &c->SG[h->max_cmd_sg_entries - 1];
1507 chain_block = h->cmd_sg_list[c->cmdindex]; 1508 chain_block = h->cmd_sg_list[c->cmdindex];
1508 chain_sg->Ext = HPSA_SG_CHAIN; 1509 chain_sg->Ext = cpu_to_le32(HPSA_SG_CHAIN);
1509 chain_sg->Len = sizeof(*chain_sg) * 1510 chain_len = sizeof(*chain_sg) *
1510 (c->Header.SGTotal - h->max_cmd_sg_entries); 1511 (c->Header.SGTotal - h->max_cmd_sg_entries);
1511 temp64 = pci_map_single(h->pdev, chain_block, chain_sg->Len, 1512 chain_sg->Len = cpu_to_le32(chain_len);
1513 temp64 = pci_map_single(h->pdev, chain_block, chain_len,
1512 PCI_DMA_TODEVICE); 1514 PCI_DMA_TODEVICE);
1513 if (dma_mapping_error(&h->pdev->dev, temp64)) { 1515 if (dma_mapping_error(&h->pdev->dev, temp64)) {
1514 /* prevent subsequent unmapping */ 1516 /* prevent subsequent unmapping */
1515 chain_sg->Addr.lower = 0; 1517 chain_sg->Addr = cpu_to_le64(0);
1516 chain_sg->Addr.upper = 0;
1517 return -1; 1518 return -1;
1518 } 1519 }
1519 chain_sg->Addr.lower = (u32) (temp64 & 0x0FFFFFFFFULL); 1520 chain_sg->Addr = cpu_to_le64(temp64);
1520 chain_sg->Addr.upper = (u32) ((temp64 >> 32) & 0x0FFFFFFFFULL);
1521 return 0; 1521 return 0;
1522} 1522}
1523 1523
@@ -1525,15 +1525,13 @@ static void hpsa_unmap_sg_chain_block(struct ctlr_info *h,
1525 struct CommandList *c) 1525 struct CommandList *c)
1526{ 1526{
1527 struct SGDescriptor *chain_sg; 1527 struct SGDescriptor *chain_sg;
1528 union u64bit temp64;
1529 1528
1530 if (c->Header.SGTotal <= h->max_cmd_sg_entries) 1529 if (le16_to_cpu(c->Header.SGTotal) <= h->max_cmd_sg_entries)
1531 return; 1530 return;
1532 1531
1533 chain_sg = &c->SG[h->max_cmd_sg_entries - 1]; 1532 chain_sg = &c->SG[h->max_cmd_sg_entries - 1];
1534 temp64.val32.lower = chain_sg->Addr.lower; 1533 pci_unmap_single(h->pdev, le64_to_cpu(chain_sg->Addr),
1535 temp64.val32.upper = chain_sg->Addr.upper; 1534 le32_to_cpu(chain_sg->Len), PCI_DMA_TODEVICE);
1536 pci_unmap_single(h->pdev, temp64.val, chain_sg->Len, PCI_DMA_TODEVICE);
1537} 1535}
1538 1536
1539 1537
@@ -1734,8 +1732,7 @@ static void complete_scsi_command(struct CommandList *cp)
1734 struct io_accel1_cmd *c = &h->ioaccel_cmd_pool[cp->cmdindex]; 1732 struct io_accel1_cmd *c = &h->ioaccel_cmd_pool[cp->cmdindex];
1735 cp->Header.SGList = cp->Header.SGTotal = scsi_sg_count(cmd); 1733 cp->Header.SGList = cp->Header.SGTotal = scsi_sg_count(cmd);
1736 cp->Request.CDBLen = c->io_flags & IOACCEL1_IOFLAGS_CDBLEN_MASK; 1734 cp->Request.CDBLen = c->io_flags & IOACCEL1_IOFLAGS_CDBLEN_MASK;
1737 cp->Header.Tag.lower = c->Tag.lower; 1735 cp->Header.tag = c->tag;
1738 cp->Header.Tag.upper = c->Tag.upper;
1739 memcpy(cp->Header.LUN.LunAddrBytes, c->CISS_LUN, 8); 1736 memcpy(cp->Header.LUN.LunAddrBytes, c->CISS_LUN, 8);
1740 memcpy(cp->Request.CDB, c->CDB, cp->Request.CDBLen); 1737 memcpy(cp->Request.CDB, c->CDB, cp->Request.CDBLen);
1741 1738
@@ -1936,14 +1933,11 @@ static void hpsa_pci_unmap(struct pci_dev *pdev,
1936 struct CommandList *c, int sg_used, int data_direction) 1933 struct CommandList *c, int sg_used, int data_direction)
1937{ 1934{
1938 int i; 1935 int i;
1939 union u64bit addr64;
1940 1936
1941 for (i = 0; i < sg_used; i++) { 1937 for (i = 0; i < sg_used; i++)
1942 addr64.val32.lower = c->SG[i].Addr.lower; 1938 pci_unmap_single(pdev, (dma_addr_t) le64_to_cpu(c->SG[i].Addr),
1943 addr64.val32.upper = c->SG[i].Addr.upper; 1939 le32_to_cpu(c->SG[i].Len),
1944 pci_unmap_single(pdev, (dma_addr_t) addr64.val, c->SG[i].Len, 1940 data_direction);
1945 data_direction);
1946 }
1947} 1941}
1948 1942
1949static int hpsa_map_one(struct pci_dev *pdev, 1943static int hpsa_map_one(struct pci_dev *pdev,
@@ -1956,25 +1950,22 @@ static int hpsa_map_one(struct pci_dev *pdev,
1956 1950
1957 if (buflen == 0 || data_direction == PCI_DMA_NONE) { 1951 if (buflen == 0 || data_direction == PCI_DMA_NONE) {
1958 cp->Header.SGList = 0; 1952 cp->Header.SGList = 0;
1959 cp->Header.SGTotal = 0; 1953 cp->Header.SGTotal = cpu_to_le16(0);
1960 return 0; 1954 return 0;
1961 } 1955 }
1962 1956
1963 addr64 = (u64) pci_map_single(pdev, buf, buflen, data_direction); 1957 addr64 = pci_map_single(pdev, buf, buflen, data_direction);
1964 if (dma_mapping_error(&pdev->dev, addr64)) { 1958 if (dma_mapping_error(&pdev->dev, addr64)) {
1965 /* Prevent subsequent unmap of something never mapped */ 1959 /* Prevent subsequent unmap of something never mapped */
1966 cp->Header.SGList = 0; 1960 cp->Header.SGList = 0;
1967 cp->Header.SGTotal = 0; 1961 cp->Header.SGTotal = cpu_to_le16(0);
1968 return -1; 1962 return -1;
1969 } 1963 }
1970 cp->SG[0].Addr.lower = 1964 cp->SG[0].Addr = cpu_to_le64(addr64);
1971 (u32) (addr64 & (u64) 0x00000000FFFFFFFF); 1965 cp->SG[0].Len = cpu_to_le32(buflen);
1972 cp->SG[0].Addr.upper = 1966 cp->SG[0].Ext = cpu_to_le32(HPSA_SG_LAST); /* we are not chaining */
1973 (u32) ((addr64 >> 32) & (u64) 0x00000000FFFFFFFF); 1967 cp->Header.SGList = 1; /* no. SGs contig in this cmd */
1974 cp->SG[0].Len = buflen; 1968 cp->Header.SGTotal = cpu_to_le16(1); /* total sgs in cmd list */
1975 cp->SG[0].Ext = HPSA_SG_LAST; /* we are not chaining */
1976 cp->Header.SGList = (u8) 1; /* no. SGs contig in this cmd */
1977 cp->Header.SGTotal = (u16) 1; /* total sgs in this cmd list */
1978 return 0; 1969 return 0;
1979} 1970}
1980 1971
@@ -2832,8 +2823,8 @@ static int hpsa_get_pdisk_of_ioaccel2(struct ctlr_info *h,
2832 if (d == NULL) 2823 if (d == NULL)
2833 return 0; /* no match */ 2824 return 0; /* no match */
2834 2825
2835 it_nexus = cpu_to_le32((u32) d->ioaccel_handle); 2826 it_nexus = cpu_to_le32(d->ioaccel_handle);
2836 scsi_nexus = cpu_to_le32((u32) c2a->scsi_nexus); 2827 scsi_nexus = cpu_to_le32(c2a->scsi_nexus);
2837 find = c2a->scsi_nexus; 2828 find = c2a->scsi_nexus;
2838 2829
2839 if (h->raid_offload_debug > 0) 2830 if (h->raid_offload_debug > 0)
@@ -3212,19 +3203,19 @@ static int hpsa_scatter_gather(struct ctlr_info *h,
3212 } 3203 }
3213 addr64 = (u64) sg_dma_address(sg); 3204 addr64 = (u64) sg_dma_address(sg);
3214 len = sg_dma_len(sg); 3205 len = sg_dma_len(sg);
3215 curr_sg->Addr.lower = (u32) (addr64 & 0x0FFFFFFFFULL); 3206 curr_sg->Addr = cpu_to_le64(addr64);
3216 curr_sg->Addr.upper = (u32) ((addr64 >> 32) & 0x0FFFFFFFFULL); 3207 curr_sg->Len = cpu_to_le32(len);
3217 curr_sg->Len = len; 3208 curr_sg->Ext = cpu_to_le32(0);
3218 curr_sg->Ext = (i < scsi_sg_count(cmd) - 1) ? 0 : HPSA_SG_LAST;
3219 curr_sg++; 3209 curr_sg++;
3220 } 3210 }
3211 (--curr_sg)->Ext = cpu_to_le32(HPSA_SG_LAST);
3221 3212
3222 if (use_sg + chained > h->maxSG) 3213 if (use_sg + chained > h->maxSG)
3223 h->maxSG = use_sg + chained; 3214 h->maxSG = use_sg + chained;
3224 3215
3225 if (chained) { 3216 if (chained) {
3226 cp->Header.SGList = h->max_cmd_sg_entries; 3217 cp->Header.SGList = h->max_cmd_sg_entries;
3227 cp->Header.SGTotal = (u16) (use_sg + 1); 3218 cp->Header.SGTotal = cpu_to_le16(use_sg + 1);
3228 if (hpsa_map_sg_chain_block(h, cp)) { 3219 if (hpsa_map_sg_chain_block(h, cp)) {
3229 scsi_dma_unmap(cmd); 3220 scsi_dma_unmap(cmd);
3230 return -1; 3221 return -1;
@@ -3235,7 +3226,7 @@ static int hpsa_scatter_gather(struct ctlr_info *h,
3235sglist_finished: 3226sglist_finished:
3236 3227
3237 cp->Header.SGList = (u8) use_sg; /* no. SGs contig in this cmd */ 3228 cp->Header.SGList = (u8) use_sg; /* no. SGs contig in this cmd */
3238 cp->Header.SGTotal = (u16) use_sg; /* total sgs in this cmd list */ 3229 cp->Header.SGTotal = cpu_to_le16(use_sg); /* total sgs in this cmd list */
3239 return 0; 3230 return 0;
3240} 3231}
3241 3232
@@ -3327,17 +3318,12 @@ static int hpsa_scsi_ioaccel1_queue_command(struct ctlr_info *h,
3327 addr64 = (u64) sg_dma_address(sg); 3318 addr64 = (u64) sg_dma_address(sg);
3328 len = sg_dma_len(sg); 3319 len = sg_dma_len(sg);
3329 total_len += len; 3320 total_len += len;
3330 curr_sg->Addr.lower = (u32) (addr64 & 0x0FFFFFFFFULL); 3321 curr_sg->Addr = cpu_to_le64(addr64);
3331 curr_sg->Addr.upper = 3322 curr_sg->Len = cpu_to_le32(len);
3332 (u32) ((addr64 >> 32) & 0x0FFFFFFFFULL); 3323 curr_sg->Ext = cpu_to_le32(0);
3333 curr_sg->Len = len;
3334
3335 if (i == (scsi_sg_count(cmd) - 1))
3336 curr_sg->Ext = HPSA_SG_LAST;
3337 else
3338 curr_sg->Ext = 0; /* we are not chaining */
3339 curr_sg++; 3324 curr_sg++;
3340 } 3325 }
3326 (--curr_sg)->Ext = cpu_to_le32(HPSA_SG_LAST);
3341 3327
3342 switch (cmd->sc_data_direction) { 3328 switch (cmd->sc_data_direction) {
3343 case DMA_TO_DEVICE: 3329 case DMA_TO_DEVICE:
@@ -3594,7 +3580,7 @@ static int hpsa_scsi_ioaccel2_queue_command(struct ctlr_info *h,
3594 cp->data_len = cpu_to_le32(total_len); 3580 cp->data_len = cpu_to_le32(total_len);
3595 cp->err_ptr = cpu_to_le64(c->busaddr + 3581 cp->err_ptr = cpu_to_le64(c->busaddr +
3596 offsetof(struct io_accel2_cmd, error_data)); 3582 offsetof(struct io_accel2_cmd, error_data));
3597 cp->err_len = cpu_to_le32((u32) sizeof(cp->error_data)); 3583 cp->err_len = cpu_to_le32(sizeof(cp->error_data));
3598 3584
3599 enqueue_cmd_and_start_io(h, c); 3585 enqueue_cmd_and_start_io(h, c);
3600 return 0; 3586 return 0;
@@ -4023,8 +4009,8 @@ static int hpsa_scsi_queue_command_lck(struct scsi_cmnd *cmd,
4023 4009
4024 c->Header.ReplyQueue = 0; /* unused in simple mode */ 4010 c->Header.ReplyQueue = 0; /* unused in simple mode */
4025 memcpy(&c->Header.LUN.LunAddrBytes[0], &scsi3addr[0], 8); 4011 memcpy(&c->Header.LUN.LunAddrBytes[0], &scsi3addr[0], 8);
4026 c->Header.Tag.lower = (c->cmdindex << DIRECT_LOOKUP_SHIFT); 4012 c->Header.tag = cpu_to_le64((c->cmdindex << DIRECT_LOOKUP_SHIFT) |
4027 c->Header.Tag.lower |= DIRECT_LOOKUP_BIT; 4013 DIRECT_LOOKUP_BIT);
4028 4014
4029 /* Fill in the request block... */ 4015 /* Fill in the request block... */
4030 4016
@@ -4326,8 +4312,8 @@ static void hpsa_get_tag(struct ctlr_info *h,
4326 if (c->cmd_type == CMD_IOACCEL1) { 4312 if (c->cmd_type == CMD_IOACCEL1) {
4327 struct io_accel1_cmd *cm1 = (struct io_accel1_cmd *) 4313 struct io_accel1_cmd *cm1 = (struct io_accel1_cmd *)
4328 &h->ioaccel_cmd_pool[c->cmdindex]; 4314 &h->ioaccel_cmd_pool[c->cmdindex];
4329 *tagupper = cm1->Tag.upper; 4315 *tagupper = (u32) (cm1->tag >> 32);
4330 *taglower = cm1->Tag.lower; 4316 *taglower = (u32) (cm1->tag & 0x0ffffffffULL);
4331 return; 4317 return;
4332 } 4318 }
4333 if (c->cmd_type == CMD_IOACCEL2) { 4319 if (c->cmd_type == CMD_IOACCEL2) {
@@ -4338,11 +4324,10 @@ static void hpsa_get_tag(struct ctlr_info *h,
4338 *taglower = cm2->Tag; 4324 *taglower = cm2->Tag;
4339 return; 4325 return;
4340 } 4326 }
4341 *tagupper = c->Header.Tag.upper; 4327 *tagupper = (u32) (c->Header.tag >> 32);
4342 *taglower = c->Header.Tag.lower; 4328 *taglower = (u32) (c->Header.tag & 0x0ffffffffULL);
4343} 4329}
4344 4330
4345
4346static int hpsa_send_abort(struct ctlr_info *h, unsigned char *scsi3addr, 4331static int hpsa_send_abort(struct ctlr_info *h, unsigned char *scsi3addr,
4347 struct CommandList *abort, int swizzle) 4332 struct CommandList *abort, int swizzle)
4348{ 4333{
@@ -4429,7 +4414,7 @@ static struct CommandList *hpsa_find_cmd_in_queue_by_tag(struct ctlr_info *h,
4429 4414
4430 spin_lock_irqsave(&h->lock, flags); 4415 spin_lock_irqsave(&h->lock, flags);
4431 list_for_each_entry(c, queue_head, list) { 4416 list_for_each_entry(c, queue_head, list) {
4432 if (memcmp(&c->Header.Tag, tag, 8) != 0) 4417 if (memcmp(&c->Header.tag, tag, 8) != 0)
4433 continue; 4418 continue;
4434 spin_unlock_irqrestore(&h->lock, flags); 4419 spin_unlock_irqrestore(&h->lock, flags);
4435 return c; 4420 return c;
@@ -4711,9 +4696,8 @@ static struct CommandList *cmd_alloc(struct ctlr_info *h)
4711 INIT_LIST_HEAD(&c->list); 4696 INIT_LIST_HEAD(&c->list);
4712 c->busaddr = (u32) cmd_dma_handle; 4697 c->busaddr = (u32) cmd_dma_handle;
4713 temp64.val = (u64) err_dma_handle; 4698 temp64.val = (u64) err_dma_handle;
4714 c->ErrDesc.Addr.lower = temp64.val32.lower; 4699 c->ErrDesc.Addr = cpu_to_le64(err_dma_handle);
4715 c->ErrDesc.Addr.upper = temp64.val32.upper; 4700 c->ErrDesc.Len = cpu_to_le32(sizeof(*c->err_info));
4716 c->ErrDesc.Len = sizeof(*c->err_info);
4717 4701
4718 c->h = h; 4702 c->h = h;
4719 return c; 4703 return c;
@@ -4726,7 +4710,6 @@ static struct CommandList *cmd_alloc(struct ctlr_info *h)
4726static struct CommandList *cmd_special_alloc(struct ctlr_info *h) 4710static struct CommandList *cmd_special_alloc(struct ctlr_info *h)
4727{ 4711{
4728 struct CommandList *c; 4712 struct CommandList *c;
4729 union u64bit temp64;
4730 dma_addr_t cmd_dma_handle, err_dma_handle; 4713 dma_addr_t cmd_dma_handle, err_dma_handle;
4731 4714
4732 c = pci_zalloc_consistent(h->pdev, sizeof(*c), &cmd_dma_handle); 4715 c = pci_zalloc_consistent(h->pdev, sizeof(*c), &cmd_dma_handle);
@@ -4747,10 +4730,8 @@ static struct CommandList *cmd_special_alloc(struct ctlr_info *h)
4747 4730
4748 INIT_LIST_HEAD(&c->list); 4731 INIT_LIST_HEAD(&c->list);
4749 c->busaddr = (u32) cmd_dma_handle; 4732 c->busaddr = (u32) cmd_dma_handle;
4750 temp64.val = (u64) err_dma_handle; 4733 c->ErrDesc.Addr = cpu_to_le64(err_dma_handle);
4751 c->ErrDesc.Addr.lower = temp64.val32.lower; 4734 c->ErrDesc.Len = cpu_to_le32(sizeof(*c->err_info));
4752 c->ErrDesc.Addr.upper = temp64.val32.upper;
4753 c->ErrDesc.Len = sizeof(*c->err_info);
4754 4735
4755 c->h = h; 4736 c->h = h;
4756 return c; 4737 return c;
@@ -4770,12 +4751,9 @@ static void cmd_free(struct ctlr_info *h, struct CommandList *c)
4770 4751
4771static void cmd_special_free(struct ctlr_info *h, struct CommandList *c) 4752static void cmd_special_free(struct ctlr_info *h, struct CommandList *c)
4772{ 4753{
4773 union u64bit temp64;
4774
4775 temp64.val32.lower = c->ErrDesc.Addr.lower;
4776 temp64.val32.upper = c->ErrDesc.Addr.upper;
4777 pci_free_consistent(h->pdev, sizeof(*c->err_info), 4754 pci_free_consistent(h->pdev, sizeof(*c->err_info),
4778 c->err_info, (dma_addr_t) temp64.val); 4755 c->err_info,
4756 (dma_addr_t) le64_to_cpu(c->ErrDesc.Addr));
4779 pci_free_consistent(h->pdev, sizeof(*c), 4757 pci_free_consistent(h->pdev, sizeof(*c),
4780 c, (dma_addr_t) (c->busaddr & DIRECT_LOOKUP_MASK)); 4758 c, (dma_addr_t) (c->busaddr & DIRECT_LOOKUP_MASK));
4781} 4759}
@@ -4930,7 +4908,7 @@ static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp)
4930 IOCTL_Command_struct iocommand; 4908 IOCTL_Command_struct iocommand;
4931 struct CommandList *c; 4909 struct CommandList *c;
4932 char *buff = NULL; 4910 char *buff = NULL;
4933 union u64bit temp64; 4911 u64 temp64;
4934 int rc = 0; 4912 int rc = 0;
4935 4913
4936 if (!argp) 4914 if (!argp)
@@ -4969,14 +4947,14 @@ static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp)
4969 c->Header.ReplyQueue = 0; /* unused in simple mode */ 4947 c->Header.ReplyQueue = 0; /* unused in simple mode */
4970 if (iocommand.buf_size > 0) { /* buffer to fill */ 4948 if (iocommand.buf_size > 0) { /* buffer to fill */
4971 c->Header.SGList = 1; 4949 c->Header.SGList = 1;
4972 c->Header.SGTotal = 1; 4950 c->Header.SGTotal = cpu_to_le16(1);
4973 } else { /* no buffers to fill */ 4951 } else { /* no buffers to fill */
4974 c->Header.SGList = 0; 4952 c->Header.SGList = 0;
4975 c->Header.SGTotal = 0; 4953 c->Header.SGTotal = cpu_to_le16(0);
4976 } 4954 }
4977 memcpy(&c->Header.LUN, &iocommand.LUN_info, sizeof(c->Header.LUN)); 4955 memcpy(&c->Header.LUN, &iocommand.LUN_info, sizeof(c->Header.LUN));
4978 /* use the kernel address the cmd block for tag */ 4956 /* use the kernel address the cmd block for tag */
4979 c->Header.Tag.lower = c->busaddr; 4957 c->Header.tag = c->busaddr;
4980 4958
4981 /* Fill in Request block */ 4959 /* Fill in Request block */
4982 memcpy(&c->Request, &iocommand.Request, 4960 memcpy(&c->Request, &iocommand.Request,
@@ -4984,19 +4962,17 @@ static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp)
4984 4962
4985 /* Fill in the scatter gather information */ 4963 /* Fill in the scatter gather information */
4986 if (iocommand.buf_size > 0) { 4964 if (iocommand.buf_size > 0) {
4987 temp64.val = pci_map_single(h->pdev, buff, 4965 temp64 = pci_map_single(h->pdev, buff,
4988 iocommand.buf_size, PCI_DMA_BIDIRECTIONAL); 4966 iocommand.buf_size, PCI_DMA_BIDIRECTIONAL);
4989 if (dma_mapping_error(&h->pdev->dev, temp64.val)) { 4967 if (dma_mapping_error(&h->pdev->dev, (dma_addr_t) temp64)) {
4990 c->SG[0].Addr.lower = 0; 4968 c->SG[0].Addr = cpu_to_le64(0);
4991 c->SG[0].Addr.upper = 0; 4969 c->SG[0].Len = cpu_to_le32(0);
4992 c->SG[0].Len = 0;
4993 rc = -ENOMEM; 4970 rc = -ENOMEM;
4994 goto out; 4971 goto out;
4995 } 4972 }
4996 c->SG[0].Addr.lower = temp64.val32.lower; 4973 c->SG[0].Addr = cpu_to_le64(temp64);
4997 c->SG[0].Addr.upper = temp64.val32.upper; 4974 c->SG[0].Len = cpu_to_le32(iocommand.buf_size);
4998 c->SG[0].Len = iocommand.buf_size; 4975 c->SG[0].Ext = cpu_to_le32(HPSA_SG_LAST); /* not chaining */
4999 c->SG[0].Ext = HPSA_SG_LAST; /* we are not chaining*/
5000 } 4976 }
5001 hpsa_scsi_do_simple_cmd_core_if_no_lockup(h, c); 4977 hpsa_scsi_do_simple_cmd_core_if_no_lockup(h, c);
5002 if (iocommand.buf_size > 0) 4978 if (iocommand.buf_size > 0)
@@ -5031,7 +5007,7 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp)
5031 struct CommandList *c; 5007 struct CommandList *c;
5032 unsigned char **buff = NULL; 5008 unsigned char **buff = NULL;
5033 int *buff_size = NULL; 5009 int *buff_size = NULL;
5034 union u64bit temp64; 5010 u64 temp64;
5035 BYTE sg_used = 0; 5011 BYTE sg_used = 0;
5036 int status = 0; 5012 int status = 0;
5037 int i; 5013 int i;
@@ -5105,29 +5081,30 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp)
5105 } 5081 }
5106 c->cmd_type = CMD_IOCTL_PEND; 5082 c->cmd_type = CMD_IOCTL_PEND;
5107 c->Header.ReplyQueue = 0; 5083 c->Header.ReplyQueue = 0;
5108 c->Header.SGList = c->Header.SGTotal = sg_used; 5084 c->Header.SGList = (u8) sg_used;
5085 c->Header.SGTotal = cpu_to_le16(sg_used);
5109 memcpy(&c->Header.LUN, &ioc->LUN_info, sizeof(c->Header.LUN)); 5086 memcpy(&c->Header.LUN, &ioc->LUN_info, sizeof(c->Header.LUN));
5110 c->Header.Tag.lower = c->busaddr; 5087 c->Header.tag = c->busaddr;
5111 memcpy(&c->Request, &ioc->Request, sizeof(c->Request)); 5088 memcpy(&c->Request, &ioc->Request, sizeof(c->Request));
5112 if (ioc->buf_size > 0) { 5089 if (ioc->buf_size > 0) {
5113 int i; 5090 int i;
5114 for (i = 0; i < sg_used; i++) { 5091 for (i = 0; i < sg_used; i++) {
5115 temp64.val = pci_map_single(h->pdev, buff[i], 5092 temp64 = pci_map_single(h->pdev, buff[i],
5116 buff_size[i], PCI_DMA_BIDIRECTIONAL); 5093 buff_size[i], PCI_DMA_BIDIRECTIONAL);
5117 if (dma_mapping_error(&h->pdev->dev, temp64.val)) { 5094 if (dma_mapping_error(&h->pdev->dev,
5118 c->SG[i].Addr.lower = 0; 5095 (dma_addr_t) temp64)) {
5119 c->SG[i].Addr.upper = 0; 5096 c->SG[i].Addr = cpu_to_le64(0);
5120 c->SG[i].Len = 0; 5097 c->SG[i].Len = cpu_to_le32(0);
5121 hpsa_pci_unmap(h->pdev, c, i, 5098 hpsa_pci_unmap(h->pdev, c, i,
5122 PCI_DMA_BIDIRECTIONAL); 5099 PCI_DMA_BIDIRECTIONAL);
5123 status = -ENOMEM; 5100 status = -ENOMEM;
5124 goto cleanup0; 5101 goto cleanup0;
5125 } 5102 }
5126 c->SG[i].Addr.lower = temp64.val32.lower; 5103 c->SG[i].Addr = cpu_to_le64(temp64);
5127 c->SG[i].Addr.upper = temp64.val32.upper; 5104 c->SG[i].Len = cpu_to_le32(buff_size[i]);
5128 c->SG[i].Len = buff_size[i]; 5105 c->SG[i].Ext = cpu_to_le32(0);
5129 c->SG[i].Ext = i < sg_used - 1 ? 0 : HPSA_SG_LAST;
5130 } 5106 }
5107 c->SG[--i].Ext = cpu_to_le32(HPSA_SG_LAST);
5131 } 5108 }
5132 hpsa_scsi_do_simple_cmd_core_if_no_lockup(h, c); 5109 hpsa_scsi_do_simple_cmd_core_if_no_lockup(h, c);
5133 if (sg_used) 5110 if (sg_used)
@@ -5266,17 +5243,18 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
5266{ 5243{
5267 int pci_dir = XFER_NONE; 5244 int pci_dir = XFER_NONE;
5268 struct CommandList *a; /* for commands to be aborted */ 5245 struct CommandList *a; /* for commands to be aborted */
5246 u32 tupper, tlower;
5269 5247
5270 c->cmd_type = CMD_IOCTL_PEND; 5248 c->cmd_type = CMD_IOCTL_PEND;
5271 c->Header.ReplyQueue = 0; 5249 c->Header.ReplyQueue = 0;
5272 if (buff != NULL && size > 0) { 5250 if (buff != NULL && size > 0) {
5273 c->Header.SGList = 1; 5251 c->Header.SGList = 1;
5274 c->Header.SGTotal = 1; 5252 c->Header.SGTotal = cpu_to_le16(1);
5275 } else { 5253 } else {
5276 c->Header.SGList = 0; 5254 c->Header.SGList = 0;
5277 c->Header.SGTotal = 0; 5255 c->Header.SGTotal = cpu_to_le16(0);
5278 } 5256 }
5279 c->Header.Tag.lower = c->busaddr; 5257 c->Header.tag = c->busaddr;
5280 memcpy(c->Header.LUN.LunAddrBytes, scsi3addr, 8); 5258 memcpy(c->Header.LUN.LunAddrBytes, scsi3addr, 8);
5281 5259
5282 c->Request.Type.Type = cmd_type; 5260 c->Request.Type.Type = cmd_type;
@@ -5374,9 +5352,10 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
5374 break; 5352 break;
5375 case HPSA_ABORT_MSG: 5353 case HPSA_ABORT_MSG:
5376 a = buff; /* point to command to be aborted */ 5354 a = buff; /* point to command to be aborted */
5377 dev_dbg(&h->pdev->dev, "Abort Tag:0x%08x:%08x using request Tag:0x%08x:%08x\n", 5355 dev_dbg(&h->pdev->dev, "Abort Tag:0x%016llx using request Tag:0x%016llx",
5378 a->Header.Tag.upper, a->Header.Tag.lower, 5356 a->Header.tag, c->Header.tag);
5379 c->Header.Tag.upper, c->Header.Tag.lower); 5357 tlower = (u32) (a->Header.tag >> 32);
5358 tupper = (u32) (a->Header.tag & 0x0ffffffffULL);
5380 c->Request.CDBLen = 16; 5359 c->Request.CDBLen = 16;
5381 c->Request.Type.Type = TYPE_MSG; 5360 c->Request.Type.Type = TYPE_MSG;
5382 c->Request.Type.Attribute = ATTR_SIMPLE; 5361 c->Request.Type.Attribute = ATTR_SIMPLE;
@@ -5387,14 +5366,14 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
5387 c->Request.CDB[2] = 0x00; /* reserved */ 5366 c->Request.CDB[2] = 0x00; /* reserved */
5388 c->Request.CDB[3] = 0x00; /* reserved */ 5367 c->Request.CDB[3] = 0x00; /* reserved */
5389 /* Tag to abort goes in CDB[4]-CDB[11] */ 5368 /* Tag to abort goes in CDB[4]-CDB[11] */
5390 c->Request.CDB[4] = a->Header.Tag.lower & 0xFF; 5369 c->Request.CDB[4] = tlower & 0xFF;
5391 c->Request.CDB[5] = (a->Header.Tag.lower >> 8) & 0xFF; 5370 c->Request.CDB[5] = (tlower >> 8) & 0xFF;
5392 c->Request.CDB[6] = (a->Header.Tag.lower >> 16) & 0xFF; 5371 c->Request.CDB[6] = (tlower >> 16) & 0xFF;
5393 c->Request.CDB[7] = (a->Header.Tag.lower >> 24) & 0xFF; 5372 c->Request.CDB[7] = (tlower >> 24) & 0xFF;
5394 c->Request.CDB[8] = a->Header.Tag.upper & 0xFF; 5373 c->Request.CDB[8] = tupper & 0xFF;
5395 c->Request.CDB[9] = (a->Header.Tag.upper >> 8) & 0xFF; 5374 c->Request.CDB[9] = (tupper >> 8) & 0xFF;
5396 c->Request.CDB[10] = (a->Header.Tag.upper >> 16) & 0xFF; 5375 c->Request.CDB[10] = (tupper >> 16) & 0xFF;
5397 c->Request.CDB[11] = (a->Header.Tag.upper >> 24) & 0xFF; 5376 c->Request.CDB[11] = (tupper >> 24) & 0xFF;
5398 c->Request.CDB[12] = 0x00; /* reserved */ 5377 c->Request.CDB[12] = 0x00; /* reserved */
5399 c->Request.CDB[13] = 0x00; /* reserved */ 5378 c->Request.CDB[13] = 0x00; /* reserved */
5400 c->Request.CDB[14] = 0x00; /* reserved */ 5379 c->Request.CDB[14] = 0x00; /* reserved */
@@ -5763,9 +5742,8 @@ static int hpsa_message(struct pci_dev *pdev, unsigned char opcode,
5763 5742
5764 cmd->CommandHeader.ReplyQueue = 0; 5743 cmd->CommandHeader.ReplyQueue = 0;
5765 cmd->CommandHeader.SGList = 0; 5744 cmd->CommandHeader.SGList = 0;
5766 cmd->CommandHeader.SGTotal = 0; 5745 cmd->CommandHeader.SGTotal = cpu_to_le16(0);
5767 cmd->CommandHeader.Tag.lower = paddr32; 5746 cmd->CommandHeader.tag = paddr32;
5768 cmd->CommandHeader.Tag.upper = 0;
5769 memset(&cmd->CommandHeader.LUN.LunAddrBytes, 0, 8); 5747 memset(&cmd->CommandHeader.LUN.LunAddrBytes, 0, 8);
5770 5748
5771 cmd->Request.CDBLen = 16; 5749 cmd->Request.CDBLen = 16;
@@ -5776,9 +5754,9 @@ static int hpsa_message(struct pci_dev *pdev, unsigned char opcode,
5776 cmd->Request.CDB[0] = opcode; 5754 cmd->Request.CDB[0] = opcode;
5777 cmd->Request.CDB[1] = type; 5755 cmd->Request.CDB[1] = type;
5778 memset(&cmd->Request.CDB[2], 0, 14); /* rest of the CDB is reserved */ 5756 memset(&cmd->Request.CDB[2], 0, 14); /* rest of the CDB is reserved */
5779 cmd->ErrorDescriptor.Addr.lower = paddr32 + sizeof(*cmd); 5757 cmd->ErrorDescriptor.Addr =
5780 cmd->ErrorDescriptor.Addr.upper = 0; 5758 cpu_to_le64((paddr32 + sizeof(*cmd)));
5781 cmd->ErrorDescriptor.Len = sizeof(struct ErrorInfo); 5759 cmd->ErrorDescriptor.Len = cpu_to_le32(sizeof(struct ErrorInfo));
5782 5760
5783 writel(paddr32, vaddr + SA5_REQUEST_PORT_OFFSET); 5761 writel(paddr32, vaddr + SA5_REQUEST_PORT_OFFSET);
5784 5762
@@ -7429,13 +7407,12 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
7429 cp->host_context_flags = IOACCEL1_HCFLAGS_CISS_FORMAT; 7407 cp->host_context_flags = IOACCEL1_HCFLAGS_CISS_FORMAT;
7430 cp->timeout_sec = 0; 7408 cp->timeout_sec = 0;
7431 cp->ReplyQueue = 0; 7409 cp->ReplyQueue = 0;
7432 cp->Tag.lower = (i << DIRECT_LOOKUP_SHIFT) | 7410 cp->tag =
7433 DIRECT_LOOKUP_BIT; 7411 cpu_to_le64((i << DIRECT_LOOKUP_SHIFT) |
7434 cp->Tag.upper = 0; 7412 DIRECT_LOOKUP_BIT);
7435 cp->host_addr.lower = 7413 cp->host_addr =
7436 (u32) (h->ioaccel_cmd_pool_dhandle + 7414 cpu_to_le64(h->ioaccel_cmd_pool_dhandle +
7437 (i * sizeof(struct io_accel1_cmd))); 7415 (i * sizeof(struct io_accel1_cmd)));
7438 cp->host_addr.upper = 0;
7439 } 7416 }
7440 } else if (trans_support & CFGTBL_Trans_io_accel2) { 7417 } else if (trans_support & CFGTBL_Trans_io_accel2) {
7441 u64 cfg_offset, cfg_base_addr_index; 7418 u64 cfg_offset, cfg_base_addr_index;
@@ -7709,7 +7686,7 @@ static void __attribute__((unused)) verify_offsets(void)
7709 VERIFY_OFFSET(timeout_sec, 0x62); 7686 VERIFY_OFFSET(timeout_sec, 0x62);
7710 VERIFY_OFFSET(ReplyQueue, 0x64); 7687 VERIFY_OFFSET(ReplyQueue, 0x64);
7711 VERIFY_OFFSET(reserved9, 0x65); 7688 VERIFY_OFFSET(reserved9, 0x65);
7712 VERIFY_OFFSET(Tag, 0x68); 7689 VERIFY_OFFSET(tag, 0x68);
7713 VERIFY_OFFSET(host_addr, 0x70); 7690 VERIFY_OFFSET(host_addr, 0x70);
7714 VERIFY_OFFSET(CISS_LUN, 0x78); 7691 VERIFY_OFFSET(CISS_LUN, 0x78);
7715 VERIFY_OFFSET(SG, 0x78 + 8); 7692 VERIFY_OFFSET(SG, 0x78 + 8);
diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
index 9b19042ff330..575eda8a8c5e 100644
--- a/drivers/scsi/hpsa_cmd.h
+++ b/drivers/scsi/hpsa_cmd.h
@@ -314,7 +314,7 @@ struct CommandListHeader {
314 u8 ReplyQueue; 314 u8 ReplyQueue;
315 u8 SGList; 315 u8 SGList;
316 u16 SGTotal; 316 u16 SGTotal;
317 struct vals32 Tag; 317 u64 tag;
318 union LUNAddr LUN; 318 union LUNAddr LUN;
319}; 319};
320 320
@@ -330,12 +330,12 @@ struct RequestBlock {
330}; 330};
331 331
332struct ErrDescriptor { 332struct ErrDescriptor {
333 struct vals32 Addr; 333 u64 Addr;
334 u32 Len; 334 u32 Len;
335}; 335};
336 336
337struct SGDescriptor { 337struct SGDescriptor {
338 struct vals32 Addr; 338 u64 Addr;
339 u32 Len; 339 u32 Len;
340 u32 Ext; 340 u32 Ext;
341}; 341};
@@ -434,8 +434,8 @@ struct io_accel1_cmd {
434 u16 timeout_sec; /* 0x62 - 0x63 */ 434 u16 timeout_sec; /* 0x62 - 0x63 */
435 u8 ReplyQueue; /* 0x64 */ 435 u8 ReplyQueue; /* 0x64 */
436 u8 reserved9[3]; /* 0x65 - 0x67 */ 436 u8 reserved9[3]; /* 0x65 - 0x67 */
437 struct vals32 Tag; /* 0x68 - 0x6F */ 437 u64 tag; /* 0x68 - 0x6F */
438 struct vals32 host_addr; /* 0x70 - 0x77 */ 438 u64 host_addr; /* 0x70 - 0x77 */
439 u8 CISS_LUN[8]; /* 0x78 - 0x7F */ 439 u8 CISS_LUN[8]; /* 0x78 - 0x7F */
440 struct SGDescriptor SG[IOACCEL1_MAXSGENTRIES]; 440 struct SGDescriptor SG[IOACCEL1_MAXSGENTRIES];
441} __aligned(IOACCEL1_COMMANDLIST_ALIGNMENT); 441} __aligned(IOACCEL1_COMMANDLIST_ALIGNMENT);
@@ -555,8 +555,8 @@ struct hpsa_tmf_struct {
555 u8 reserved1; /* byte 3 Reserved */ 555 u8 reserved1; /* byte 3 Reserved */
556 u32 it_nexus; /* SCSI I-T Nexus */ 556 u32 it_nexus; /* SCSI I-T Nexus */
557 u8 lun_id[8]; /* LUN ID for TMF request */ 557 u8 lun_id[8]; /* LUN ID for TMF request */
558 struct vals32 Tag; /* cciss tag associated w/ request */ 558 u64 tag; /* cciss tag associated w/ request */
559 struct vals32 abort_tag;/* cciss tag of SCSI cmd or task to abort */ 559 u64 abort_tag; /* cciss tag of SCSI cmd or task to abort */
560 u64 error_ptr; /* Error Pointer */ 560 u64 error_ptr; /* Error Pointer */
561 u32 error_len; /* Error Length */ 561 u32 error_len; /* Error Length */
562}; 562};