aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/aacraid/aachba.c64
1 files changed, 31 insertions, 33 deletions
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 2dbfbe3cf453..ef11c18d9ba4 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -312,11 +312,10 @@ int aac_get_containers(struct aac_dev *dev)
312 312
313 if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS) 313 if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS)
314 maximum_num_containers = MAXIMUM_NUM_CONTAINERS; 314 maximum_num_containers = MAXIMUM_NUM_CONTAINERS;
315 fsa_dev_ptr = kmalloc(sizeof(*fsa_dev_ptr) * maximum_num_containers, 315 fsa_dev_ptr = kzalloc(sizeof(*fsa_dev_ptr) * maximum_num_containers,
316 GFP_KERNEL); 316 GFP_KERNEL);
317 if (!fsa_dev_ptr) 317 if (!fsa_dev_ptr)
318 return -ENOMEM; 318 return -ENOMEM;
319 memset(fsa_dev_ptr, 0, sizeof(*fsa_dev_ptr) * maximum_num_containers);
320 319
321 dev->fsa_dev = fsa_dev_ptr; 320 dev->fsa_dev = fsa_dev_ptr;
322 dev->maximum_num_containers = maximum_num_containers; 321 dev->maximum_num_containers = maximum_num_containers;
@@ -446,7 +445,7 @@ static int aac_probe_container_callback2(struct scsi_cmnd * scsicmd)
446{ 445{
447 struct fsa_dev_info *fsa_dev_ptr = ((struct aac_dev *)(scsicmd->device->host->hostdata))->fsa_dev; 446 struct fsa_dev_info *fsa_dev_ptr = ((struct aac_dev *)(scsicmd->device->host->hostdata))->fsa_dev;
448 447
449 if (fsa_dev_ptr[scmd_id(scsicmd)].valid) 448 if ((fsa_dev_ptr[scmd_id(scsicmd)].valid & 1))
450 return aac_scsi_cmd(scsicmd); 449 return aac_scsi_cmd(scsicmd);
451 450
452 scsicmd->result = DID_NO_CONNECT << 16; 451 scsicmd->result = DID_NO_CONNECT << 16;
@@ -454,18 +453,18 @@ static int aac_probe_container_callback2(struct scsi_cmnd * scsicmd)
454 return 0; 453 return 0;
455} 454}
456 455
457static int _aac_probe_container2(void * context, struct fib * fibptr) 456static void _aac_probe_container2(void * context, struct fib * fibptr)
458{ 457{
459 struct fsa_dev_info *fsa_dev_ptr; 458 struct fsa_dev_info *fsa_dev_ptr;
460 int (*callback)(struct scsi_cmnd *); 459 int (*callback)(struct scsi_cmnd *);
461 struct scsi_cmnd * scsicmd = (struct scsi_cmnd *)context; 460 struct scsi_cmnd * scsicmd = (struct scsi_cmnd *)context;
462 461
463 if (!aac_valid_context(scsicmd, fibptr))
464 return 0;
465 462
466 fsa_dev_ptr = ((struct aac_dev *)(scsicmd->device->host->hostdata))->fsa_dev; 463 if (!aac_valid_context(scsicmd, fibptr))
464 return;
467 465
468 scsicmd->SCp.Status = 0; 466 scsicmd->SCp.Status = 0;
467 fsa_dev_ptr = fibptr->dev->fsa_dev;
469 if (fsa_dev_ptr) { 468 if (fsa_dev_ptr) {
470 struct aac_mount * dresp = (struct aac_mount *) fib_data(fibptr); 469 struct aac_mount * dresp = (struct aac_mount *) fib_data(fibptr);
471 fsa_dev_ptr += scmd_id(scsicmd); 470 fsa_dev_ptr += scmd_id(scsicmd);
@@ -488,10 +487,11 @@ static int _aac_probe_container2(void * context, struct fib * fibptr)
488 aac_fib_free(fibptr); 487 aac_fib_free(fibptr);
489 callback = (int (*)(struct scsi_cmnd *))(scsicmd->SCp.ptr); 488 callback = (int (*)(struct scsi_cmnd *))(scsicmd->SCp.ptr);
490 scsicmd->SCp.ptr = NULL; 489 scsicmd->SCp.ptr = NULL;
491 return (*callback)(scsicmd); 490 (*callback)(scsicmd);
491 return;
492} 492}
493 493
494static int _aac_probe_container1(void * context, struct fib * fibptr) 494static void _aac_probe_container1(void * context, struct fib * fibptr)
495{ 495{
496 struct scsi_cmnd * scsicmd; 496 struct scsi_cmnd * scsicmd;
497 struct aac_mount * dresp; 497 struct aac_mount * dresp;
@@ -501,13 +501,14 @@ static int _aac_probe_container1(void * context, struct fib * fibptr)
501 dresp = (struct aac_mount *) fib_data(fibptr); 501 dresp = (struct aac_mount *) fib_data(fibptr);
502 dresp->mnt[0].capacityhigh = 0; 502 dresp->mnt[0].capacityhigh = 0;
503 if ((le32_to_cpu(dresp->status) != ST_OK) || 503 if ((le32_to_cpu(dresp->status) != ST_OK) ||
504 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE)) 504 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE)) {
505 return _aac_probe_container2(context, fibptr); 505 _aac_probe_container2(context, fibptr);
506 return;
507 }
506 scsicmd = (struct scsi_cmnd *) context; 508 scsicmd = (struct scsi_cmnd *) context;
507 scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL;
508 509
509 if (!aac_valid_context(scsicmd, fibptr)) 510 if (!aac_valid_context(scsicmd, fibptr))
510 return 0; 511 return;
511 512
512 aac_fib_init(fibptr); 513 aac_fib_init(fibptr);
513 514
@@ -522,21 +523,18 @@ static int _aac_probe_container1(void * context, struct fib * fibptr)
522 sizeof(struct aac_query_mount), 523 sizeof(struct aac_query_mount),
523 FsaNormal, 524 FsaNormal,
524 0, 1, 525 0, 1,
525 (fib_callback) _aac_probe_container2, 526 _aac_probe_container2,
526 (void *) scsicmd); 527 (void *) scsicmd);
527 /* 528 /*
528 * Check that the command queued to the controller 529 * Check that the command queued to the controller
529 */ 530 */
530 if (status == -EINPROGRESS) { 531 if (status == -EINPROGRESS)
531 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; 532 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
532 return 0; 533 else if (status < 0) {
533 }
534 if (status < 0) {
535 /* Inherit results from VM_NameServe, if any */ 534 /* Inherit results from VM_NameServe, if any */
536 dresp->status = cpu_to_le32(ST_OK); 535 dresp->status = cpu_to_le32(ST_OK);
537 return _aac_probe_container2(context, fibptr); 536 _aac_probe_container2(context, fibptr);
538 } 537 }
539 return 0;
540} 538}
541 539
542static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(struct scsi_cmnd *)) 540static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(struct scsi_cmnd *))
@@ -561,7 +559,7 @@ static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(stru
561 sizeof(struct aac_query_mount), 559 sizeof(struct aac_query_mount),
562 FsaNormal, 560 FsaNormal,
563 0, 1, 561 0, 1,
564 (fib_callback) _aac_probe_container1, 562 _aac_probe_container1,
565 (void *) scsicmd); 563 (void *) scsicmd);
566 /* 564 /*
567 * Check that the command queued to the controller 565 * Check that the command queued to the controller
@@ -615,7 +613,7 @@ int aac_probe_container(struct aac_dev *dev, int cid)
615 return -ENOMEM; 613 return -ENOMEM;
616 } 614 }
617 scsicmd->list.next = NULL; 615 scsicmd->list.next = NULL;
618 scsicmd->scsi_done = (void (*)(struct scsi_cmnd*))_aac_probe_container1; 616 scsicmd->scsi_done = (void (*)(struct scsi_cmnd*))aac_probe_container_callback1;
619 617
620 scsicmd->device = scsidev; 618 scsicmd->device = scsidev;
621 scsidev->sdev_state = 0; 619 scsidev->sdev_state = 0;
@@ -1329,7 +1327,7 @@ static void io_callback(void *context, struct fib * fibptr)
1329 if (!aac_valid_context(scsicmd, fibptr)) 1327 if (!aac_valid_context(scsicmd, fibptr))
1330 return; 1328 return;
1331 1329
1332 dev = (struct aac_dev *)scsicmd->device->host->hostdata; 1330 dev = fibptr->dev;
1333 cid = scmd_id(scsicmd); 1331 cid = scmd_id(scsicmd);
1334 1332
1335 if (nblank(dprintk(x))) { 1333 if (nblank(dprintk(x))) {
@@ -1587,7 +1585,7 @@ static void synchronize_callback(void *context, struct fib *fibptr)
1587 COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; 1585 COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1588 else { 1586 else {
1589 struct scsi_device *sdev = cmd->device; 1587 struct scsi_device *sdev = cmd->device;
1590 struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata; 1588 struct aac_dev *dev = fibptr->dev;
1591 u32 cid = sdev_id(sdev); 1589 u32 cid = sdev_id(sdev);
1592 printk(KERN_WARNING 1590 printk(KERN_WARNING
1593 "synchronize_callback: synchronize failed, status = %d\n", 1591 "synchronize_callback: synchronize failed, status = %d\n",
@@ -1694,7 +1692,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
1694 1692
1695int aac_scsi_cmd(struct scsi_cmnd * scsicmd) 1693int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1696{ 1694{
1697 u32 cid = 0; 1695 u32 cid;
1698 struct Scsi_Host *host = scsicmd->device->host; 1696 struct Scsi_Host *host = scsicmd->device->host;
1699 struct aac_dev *dev = (struct aac_dev *)host->hostdata; 1697 struct aac_dev *dev = (struct aac_dev *)host->hostdata;
1700 struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev; 1698 struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev;
@@ -1706,15 +1704,15 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1706 * Test does not apply to ID 16, the pseudo id for the controller 1704 * Test does not apply to ID 16, the pseudo id for the controller
1707 * itself. 1705 * itself.
1708 */ 1706 */
1709 if (scmd_id(scsicmd) != host->this_id) { 1707 cid = scmd_id(scsicmd);
1710 if ((scmd_channel(scsicmd) == CONTAINER_CHANNEL)) { 1708 if (cid != host->this_id) {
1711 if((scmd_id(scsicmd) >= dev->maximum_num_containers) || 1709 if (scmd_channel(scsicmd) == CONTAINER_CHANNEL) {
1710 if((cid >= dev->maximum_num_containers) ||
1712 (scsicmd->device->lun != 0)) { 1711 (scsicmd->device->lun != 0)) {
1713 scsicmd->result = DID_NO_CONNECT << 16; 1712 scsicmd->result = DID_NO_CONNECT << 16;
1714 scsicmd->scsi_done(scsicmd); 1713 scsicmd->scsi_done(scsicmd);
1715 return 0; 1714 return 0;
1716 } 1715 }
1717 cid = scmd_id(scsicmd);
1718 1716
1719 /* 1717 /*
1720 * If the target container doesn't exist, it may have 1718 * If the target container doesn't exist, it may have
@@ -1777,7 +1775,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1777 { 1775 {
1778 struct inquiry_data inq_data; 1776 struct inquiry_data inq_data;
1779 1777
1780 dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", scmd_id(scsicmd))); 1778 dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", cid));
1781 memset(&inq_data, 0, sizeof (struct inquiry_data)); 1779 memset(&inq_data, 0, sizeof (struct inquiry_data));
1782 1780
1783 inq_data.inqd_ver = 2; /* claim compliance to SCSI-2 */ 1781 inq_data.inqd_ver = 2; /* claim compliance to SCSI-2 */
@@ -1789,7 +1787,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1789 * Set the Vendor, Product, and Revision Level 1787 * Set the Vendor, Product, and Revision Level
1790 * see: <vendor>.c i.e. aac.c 1788 * see: <vendor>.c i.e. aac.c
1791 */ 1789 */
1792 if (scmd_id(scsicmd) == host->this_id) { 1790 if (cid == host->this_id) {
1793 setinqstr(dev, (void *) (inq_data.inqd_vid), ARRAY_SIZE(container_types)); 1791 setinqstr(dev, (void *) (inq_data.inqd_vid), ARRAY_SIZE(container_types));
1794 inq_data.inqd_pdt = INQD_PDT_PROC; /* Processor device */ 1792 inq_data.inqd_pdt = INQD_PDT_PROC; /* Processor device */
1795 aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data)); 1793 aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data));
@@ -2160,10 +2158,10 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
2160 if (!aac_valid_context(scsicmd, fibptr)) 2158 if (!aac_valid_context(scsicmd, fibptr))
2161 return; 2159 return;
2162 2160
2163 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
2164
2165 BUG_ON(fibptr == NULL); 2161 BUG_ON(fibptr == NULL);
2166 2162
2163 dev = fibptr->dev;
2164
2167 srbreply = (struct aac_srb_reply *) fib_data(fibptr); 2165 srbreply = (struct aac_srb_reply *) fib_data(fibptr);
2168 2166
2169 scsicmd->sense_buffer[0] = '\0'; /* Initialize sense valid flag to false */ 2167 scsicmd->sense_buffer[0] = '\0'; /* Initialize sense valid flag to false */