aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorKashyap, Desai <kashyap.desai@lsi.com>2010-03-17 06:54:52 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-04-11 10:23:59 -0400
commite94f67472106e5a0e97c79090211c551e69e889b (patch)
tree653fdf5d1733a902c04517f0941ccbb69db9f428 /drivers
parentb4344276f75827f609ebef886b292653bec38f92 (diff)
[SCSI] mpt2sas: Fix for little endian
1. Fixes for little endian issues. 2. Now Debug info for Discovery event is more readable. Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.c22
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_config.c6
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_ctl.c26
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_scsih.c15
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_transport.c3
5 files changed, 46 insertions, 26 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
index b7b6285a3061..6f786349679f 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -285,6 +285,9 @@ _base_sas_ioc_info(struct MPT2SAS_ADAPTER *ioc, MPI2DefaultReply_t *mpi_reply,
285 request_hdr->Function == MPI2_FUNCTION_EVENT_NOTIFICATION) 285 request_hdr->Function == MPI2_FUNCTION_EVENT_NOTIFICATION)
286 return; 286 return;
287 287
288 if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE)
289 return;
290
288 switch (ioc_status) { 291 switch (ioc_status) {
289 292
290/**************************************************************************** 293/****************************************************************************
@@ -517,8 +520,18 @@ _base_display_event_data(struct MPT2SAS_ADAPTER *ioc,
517 desc = "IR Operation Status"; 520 desc = "IR Operation Status";
518 break; 521 break;
519 case MPI2_EVENT_SAS_DISCOVERY: 522 case MPI2_EVENT_SAS_DISCOVERY:
520 desc = "Discovery"; 523 {
521 break; 524 Mpi2EventDataSasDiscovery_t *event_data =
525 (Mpi2EventDataSasDiscovery_t *)mpi_reply->EventData;
526 printk(MPT2SAS_INFO_FMT "Discovery: (%s)", ioc->name,
527 (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED) ?
528 "start" : "stop");
529 if (event_data->DiscoveryStatus)
530 printk("discovery_status(0x%08x)",
531 le32_to_cpu(event_data->DiscoveryStatus));
532 printk("\n");
533 return;
534 }
522 case MPI2_EVENT_SAS_BROADCAST_PRIMITIVE: 535 case MPI2_EVENT_SAS_BROADCAST_PRIMITIVE:
523 desc = "SAS Broadcast Primitive"; 536 desc = "SAS Broadcast Primitive";
524 break; 537 break;
@@ -3184,7 +3197,7 @@ _base_event_notification(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3184 mpi_request->VP_ID = 0; 3197 mpi_request->VP_ID = 0;
3185 for (i = 0; i < MPI2_EVENT_NOTIFY_EVENTMASK_WORDS; i++) 3198 for (i = 0; i < MPI2_EVENT_NOTIFY_EVENTMASK_WORDS; i++)
3186 mpi_request->EventMasks[i] = 3199 mpi_request->EventMasks[i] =
3187 le32_to_cpu(ioc->event_masks[i]); 3200 cpu_to_le32(ioc->event_masks[i]);
3188 mpt2sas_base_put_smid_default(ioc, smid); 3201 mpt2sas_base_put_smid_default(ioc, smid);
3189 init_completion(&ioc->base_cmds.done); 3202 init_completion(&ioc->base_cmds.done);
3190 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, 30*HZ); 3203 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, 30*HZ);
@@ -3648,6 +3661,7 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
3648 pci_set_drvdata(ioc->pdev, NULL); 3661 pci_set_drvdata(ioc->pdev, NULL);
3649 kfree(ioc->tm_cmds.reply); 3662 kfree(ioc->tm_cmds.reply);
3650 kfree(ioc->transport_cmds.reply); 3663 kfree(ioc->transport_cmds.reply);
3664 kfree(ioc->scsih_cmds.reply);
3651 kfree(ioc->config_cmds.reply); 3665 kfree(ioc->config_cmds.reply);
3652 kfree(ioc->base_cmds.reply); 3666 kfree(ioc->base_cmds.reply);
3653 kfree(ioc->ctl_cmds.reply); 3667 kfree(ioc->ctl_cmds.reply);
@@ -3655,6 +3669,7 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
3655 ioc->ctl_cmds.reply = NULL; 3669 ioc->ctl_cmds.reply = NULL;
3656 ioc->base_cmds.reply = NULL; 3670 ioc->base_cmds.reply = NULL;
3657 ioc->tm_cmds.reply = NULL; 3671 ioc->tm_cmds.reply = NULL;
3672 ioc->scsih_cmds.reply = NULL;
3658 ioc->transport_cmds.reply = NULL; 3673 ioc->transport_cmds.reply = NULL;
3659 ioc->config_cmds.reply = NULL; 3674 ioc->config_cmds.reply = NULL;
3660 ioc->pfacts = NULL; 3675 ioc->pfacts = NULL;
@@ -3684,6 +3699,7 @@ mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc)
3684 kfree(ioc->base_cmds.reply); 3699 kfree(ioc->base_cmds.reply);
3685 kfree(ioc->tm_cmds.reply); 3700 kfree(ioc->tm_cmds.reply);
3686 kfree(ioc->transport_cmds.reply); 3701 kfree(ioc->transport_cmds.reply);
3702 kfree(ioc->scsih_cmds.reply);
3687 kfree(ioc->config_cmds.reply); 3703 kfree(ioc->config_cmds.reply);
3688} 3704}
3689 3705
diff --git a/drivers/scsi/mpt2sas/mpt2sas_config.c b/drivers/scsi/mpt2sas/mpt2sas_config.c
index cf44b355bc97..6f713fd57089 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_config.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_config.c
@@ -1390,12 +1390,12 @@ mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
1390 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) 1390 if (ioc_status != MPI2_IOCSTATUS_SUCCESS)
1391 goto out; 1391 goto out;
1392 for (i = 0; i < config_page->NumElements; i++) { 1392 for (i = 0; i < config_page->NumElements; i++) {
1393 if ((config_page->ConfigElement[i].ElementFlags & 1393 if ((le16_to_cpu(config_page->ConfigElement[i].ElementFlags) &
1394 MPI2_RAIDCONFIG0_EFLAGS_MASK_ELEMENT_TYPE) != 1394 MPI2_RAIDCONFIG0_EFLAGS_MASK_ELEMENT_TYPE) !=
1395 MPI2_RAIDCONFIG0_EFLAGS_VOL_PHYS_DISK_ELEMENT) 1395 MPI2_RAIDCONFIG0_EFLAGS_VOL_PHYS_DISK_ELEMENT)
1396 continue; 1396 continue;
1397 if (config_page->ConfigElement[i].PhysDiskDevHandle == 1397 if (le16_to_cpu(config_page->ConfigElement[i].
1398 pd_handle) { 1398 PhysDiskDevHandle) == pd_handle) {
1399 *volume_handle = le16_to_cpu(config_page-> 1399 *volume_handle = le16_to_cpu(config_page->
1400 ConfigElement[i].VolDevHandle); 1400 ConfigElement[i].VolDevHandle);
1401 r = 0; 1401 r = 0;
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
index fa9bf83819d5..ae55a912baf4 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
@@ -533,7 +533,7 @@ _ctl_set_task_mid(struct MPT2SAS_ADAPTER *ioc, struct mpt2_ioctl_command *karg,
533 if (!found) { 533 if (!found) {
534 dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: " 534 dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: "
535 "handle(0x%04x), lun(%d), no active mid!!\n", ioc->name, 535 "handle(0x%04x), lun(%d), no active mid!!\n", ioc->name,
536 desc, tm_request->DevHandle, lun)); 536 desc, le16_to_cpu(tm_request->DevHandle), lun));
537 tm_reply = ioc->ctl_cmds.reply; 537 tm_reply = ioc->ctl_cmds.reply;
538 tm_reply->DevHandle = tm_request->DevHandle; 538 tm_reply->DevHandle = tm_request->DevHandle;
539 tm_reply->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; 539 tm_reply->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
@@ -551,7 +551,8 @@ _ctl_set_task_mid(struct MPT2SAS_ADAPTER *ioc, struct mpt2_ioctl_command *karg,
551 551
552 dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: " 552 dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: "
553 "handle(0x%04x), lun(%d), task_mid(%d)\n", ioc->name, 553 "handle(0x%04x), lun(%d), task_mid(%d)\n", ioc->name,
554 desc, tm_request->DevHandle, lun, tm_request->TaskMID)); 554 desc, le16_to_cpu(tm_request->DevHandle), lun,
555 le16_to_cpu(tm_request->TaskMID)));
555 return 0; 556 return 0;
556} 557}
557 558
@@ -647,9 +648,9 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
647 648
648 if (mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST || 649 if (mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST ||
649 mpi_request->Function == MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH) { 650 mpi_request->Function == MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH) {
650 if (!mpi_request->FunctionDependent1 || 651 if (!le16_to_cpu(mpi_request->FunctionDependent1) ||
651 mpi_request->FunctionDependent1 > 652 le16_to_cpu(mpi_request->FunctionDependent1) >
652 cpu_to_le16(ioc->facts.MaxDevHandle)) { 653 ioc->facts.MaxDevHandle) {
653 ret = -EINVAL; 654 ret = -EINVAL;
654 mpt2sas_base_free_smid(ioc, smid); 655 mpt2sas_base_free_smid(ioc, smid);
655 goto out; 656 goto out;
@@ -897,11 +898,11 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
897 MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH)) { 898 MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH)) {
898 printk(MPT2SAS_INFO_FMT "issue target reset: handle " 899 printk(MPT2SAS_INFO_FMT "issue target reset: handle "
899 "= (0x%04x)\n", ioc->name, 900 "= (0x%04x)\n", ioc->name,
900 mpi_request->FunctionDependent1); 901 le16_to_cpu(mpi_request->FunctionDependent1));
901 mpt2sas_halt_firmware(ioc); 902 mpt2sas_halt_firmware(ioc);
902 mutex_lock(&ioc->tm_cmds.mutex); 903 mutex_lock(&ioc->tm_cmds.mutex);
903 mpt2sas_scsih_issue_tm(ioc, 904 mpt2sas_scsih_issue_tm(ioc,
904 mpi_request->FunctionDependent1, 0, 905 le16_to_cpu(mpi_request->FunctionDependent1), 0,
905 MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0, 10); 906 MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0, 10);
906 ioc->tm_cmds.status = MPT2_CMD_NOT_USED; 907 ioc->tm_cmds.status = MPT2_CMD_NOT_USED;
907 mutex_unlock(&ioc->tm_cmds.mutex); 908 mutex_unlock(&ioc->tm_cmds.mutex);
@@ -1373,7 +1374,8 @@ _ctl_diag_register_2(struct MPT2SAS_ADAPTER *ioc,
1373 1374
1374 dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: diag_buffer(0x%p), " 1375 dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: diag_buffer(0x%p), "
1375 "dma(0x%llx), sz(%d)\n", ioc->name, __func__, request_data, 1376 "dma(0x%llx), sz(%d)\n", ioc->name, __func__, request_data,
1376 (unsigned long long)request_data_dma, mpi_request->BufferLength)); 1377 (unsigned long long)request_data_dma,
1378 le32_to_cpu(mpi_request->BufferLength)));
1377 1379
1378 for (i = 0; i < MPT2_PRODUCT_SPECIFIC_DWORDS; i++) 1380 for (i = 0; i < MPT2_PRODUCT_SPECIFIC_DWORDS; i++)
1379 mpi_request->ProductSpecific[i] = 1381 mpi_request->ProductSpecific[i] =
@@ -2334,8 +2336,8 @@ _ctl_version_nvdata_persistent_show(struct device *cdev,
2334 struct Scsi_Host *shost = class_to_shost(cdev); 2336 struct Scsi_Host *shost = class_to_shost(cdev);
2335 struct MPT2SAS_ADAPTER *ioc = shost_priv(shost); 2337 struct MPT2SAS_ADAPTER *ioc = shost_priv(shost);
2336 2338
2337 return snprintf(buf, PAGE_SIZE, "%02xh\n", 2339 return snprintf(buf, PAGE_SIZE, "%08xh\n",
2338 le16_to_cpu(ioc->iounit_pg0.NvdataVersionPersistent.Word)); 2340 le32_to_cpu(ioc->iounit_pg0.NvdataVersionPersistent.Word));
2339} 2341}
2340static DEVICE_ATTR(version_nvdata_persistent, S_IRUGO, 2342static DEVICE_ATTR(version_nvdata_persistent, S_IRUGO,
2341 _ctl_version_nvdata_persistent_show, NULL); 2343 _ctl_version_nvdata_persistent_show, NULL);
@@ -2354,8 +2356,8 @@ _ctl_version_nvdata_default_show(struct device *cdev,
2354 struct Scsi_Host *shost = class_to_shost(cdev); 2356 struct Scsi_Host *shost = class_to_shost(cdev);
2355 struct MPT2SAS_ADAPTER *ioc = shost_priv(shost); 2357 struct MPT2SAS_ADAPTER *ioc = shost_priv(shost);
2356 2358
2357 return snprintf(buf, PAGE_SIZE, "%02xh\n", 2359 return snprintf(buf, PAGE_SIZE, "%08xh\n",
2358 le16_to_cpu(ioc->iounit_pg0.NvdataVersionDefault.Word)); 2360 le32_to_cpu(ioc->iounit_pg0.NvdataVersionDefault.Word));
2359} 2361}
2360static DEVICE_ATTR(version_nvdata_default, S_IRUGO, 2362static DEVICE_ATTR(version_nvdata_default, S_IRUGO,
2361 _ctl_version_nvdata_default_show, NULL); 2363 _ctl_version_nvdata_default_show, NULL);
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index afd3b82f7cd6..3d1be440ed7b 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -1376,7 +1376,7 @@ _scsih_display_sata_capabilities(struct MPT2SAS_ADAPTER *ioc,
1376 } 1376 }
1377 1377
1378 flags = le16_to_cpu(sas_device_pg0.Flags); 1378 flags = le16_to_cpu(sas_device_pg0.Flags);
1379 device_info = le16_to_cpu(sas_device_pg0.DeviceInfo); 1379 device_info = le32_to_cpu(sas_device_pg0.DeviceInfo);
1380 1380
1381 sdev_printk(KERN_INFO, sdev, 1381 sdev_printk(KERN_INFO, sdev,
1382 "atapi(%s), ncq(%s), asyn_notify(%s), smart(%s), fua(%s), " 1382 "atapi(%s), ncq(%s), asyn_notify(%s), smart(%s), fua(%s), "
@@ -3210,8 +3210,8 @@ _scsih_scsi_ioc_info(struct MPT2SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,
3210 struct sense_info data; 3210 struct sense_info data;
3211 _scsih_normalize_sense(scmd->sense_buffer, &data); 3211 _scsih_normalize_sense(scmd->sense_buffer, &data);
3212 printk(MPT2SAS_WARN_FMT "\t[sense_key,asc,ascq]: " 3212 printk(MPT2SAS_WARN_FMT "\t[sense_key,asc,ascq]: "
3213 "[0x%02x,0x%02x,0x%02x]\n", ioc->name, data.skey, 3213 "[0x%02x,0x%02x,0x%02x], count(%d)\n", ioc->name, data.skey,
3214 data.asc, data.ascq); 3214 data.asc, data.ascq, le32_to_cpu(mpi_reply->SenseCount));
3215 } 3215 }
3216 3216
3217 if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID) { 3217 if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID) {
@@ -3265,7 +3265,7 @@ _scsih_smart_predicted_fault(struct MPT2SAS_ADAPTER *ioc, u16 handle)
3265 mpi_request.Function = MPI2_FUNCTION_SCSI_ENCLOSURE_PROCESSOR; 3265 mpi_request.Function = MPI2_FUNCTION_SCSI_ENCLOSURE_PROCESSOR;
3266 mpi_request.Action = MPI2_SEP_REQ_ACTION_WRITE_STATUS; 3266 mpi_request.Action = MPI2_SEP_REQ_ACTION_WRITE_STATUS;
3267 mpi_request.SlotStatus = 3267 mpi_request.SlotStatus =
3268 MPI2_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT; 3268 cpu_to_le32(MPI2_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT);
3269 mpi_request.DevHandle = cpu_to_le16(handle); 3269 mpi_request.DevHandle = cpu_to_le16(handle);
3270 mpi_request.Flags = MPI2_SEP_REQ_FLAGS_DEVHANDLE_ADDRESS; 3270 mpi_request.Flags = MPI2_SEP_REQ_FLAGS_DEVHANDLE_ADDRESS;
3271 if ((mpt2sas_base_scsi_enclosure_processor(ioc, &mpi_reply, 3271 if ((mpt2sas_base_scsi_enclosure_processor(ioc, &mpi_reply,
@@ -5934,6 +5934,7 @@ mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
5934 struct fw_event_work *fw_event; 5934 struct fw_event_work *fw_event;
5935 Mpi2EventNotificationReply_t *mpi_reply; 5935 Mpi2EventNotificationReply_t *mpi_reply;
5936 u16 event; 5936 u16 event;
5937 u16 sz;
5937 5938
5938 /* events turned off due to host reset or driver unloading */ 5939 /* events turned off due to host reset or driver unloading */
5939 if (ioc->remove_host) 5940 if (ioc->remove_host)
@@ -5984,8 +5985,8 @@ mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
5984 ioc->name, __FILE__, __LINE__, __func__); 5985 ioc->name, __FILE__, __LINE__, __func__);
5985 return 1; 5986 return 1;
5986 } 5987 }
5987 fw_event->event_data = 5988 sz = le16_to_cpu(mpi_reply->EventDataLength) * 4;
5988 kzalloc(mpi_reply->EventDataLength*4, GFP_ATOMIC); 5989 fw_event->event_data = kzalloc(sz, GFP_ATOMIC);
5989 if (!fw_event->event_data) { 5990 if (!fw_event->event_data) {
5990 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", 5991 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n",
5991 ioc->name, __FILE__, __LINE__, __func__); 5992 ioc->name, __FILE__, __LINE__, __func__);
@@ -5994,7 +5995,7 @@ mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
5994 } 5995 }
5995 5996
5996 memcpy(fw_event->event_data, mpi_reply->EventData, 5997 memcpy(fw_event->event_data, mpi_reply->EventData,
5997 mpi_reply->EventDataLength*4); 5998 sz);
5998 fw_event->ioc = ioc; 5999 fw_event->ioc = ioc;
5999 fw_event->VF_ID = mpi_reply->VF_ID; 6000 fw_event->VF_ID = mpi_reply->VF_ID;
6000 fw_event->VP_ID = mpi_reply->VP_ID; 6001 fw_event->VP_ID = mpi_reply->VP_ID;
diff --git a/drivers/scsi/mpt2sas/mpt2sas_transport.c b/drivers/scsi/mpt2sas/mpt2sas_transport.c
index bd7ca2b49f81..9b585f02e804 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_transport.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_transport.c
@@ -1341,7 +1341,8 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1341 memcpy(req->sense, mpi_reply, sizeof(*mpi_reply)); 1341 memcpy(req->sense, mpi_reply, sizeof(*mpi_reply));
1342 req->sense_len = sizeof(*mpi_reply); 1342 req->sense_len = sizeof(*mpi_reply);
1343 req->resid_len = 0; 1343 req->resid_len = 0;
1344 rsp->resid_len -= mpi_reply->ResponseDataLength; 1344 rsp->resid_len -=
1345 le16_to_cpu(mpi_reply->ResponseDataLength);
1345 } else { 1346 } else {
1346 dtransportprintk(ioc, printk(MPT2SAS_DEBUG_FMT 1347 dtransportprintk(ioc, printk(MPT2SAS_DEBUG_FMT
1347 "%s - no reply\n", ioc->name, __func__)); 1348 "%s - no reply\n", ioc->name, __func__));