aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorjack_wang <jack_wang@usish.com>2009-11-05 09:33:51 -0500
committerJames Bottomley <James.Bottomley@suse.de>2009-12-04 13:01:32 -0500
commit97ee20886cfd257a7818087c1638ca60b9ffd192 (patch)
tree32aaceb5a9bd6366620e0bf10acff06ac1a59931 /drivers/scsi
parent72d0baa089ebd058cdb8b87fde835e9157c4597a (diff)
[SCSI] pm8001: Fixes for tag alloc, error goto and code cleanup
Allocate right size for bitmap tag,fix error goto and cleanup print message and undocable commemts. patch attached. Signed-off-by: Lindar Liu <lindar_liu@usish.com> Signed-off-by: Jack Wang <jack_wang@usish.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/pm8001/pm8001_init.c11
-rw-r--r--drivers/scsi/pm8001/pm8001_sas.c60
2 files changed, 36 insertions, 35 deletions
diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index 811b5d36d5f0..42ebe725d5a5 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -203,9 +203,9 @@ static int __devinit pm8001_alloc(struct pm8001_hba_info *pm8001_ha)
203 for (i = 0; i < pm8001_ha->chip->n_phy; i++) 203 for (i = 0; i < pm8001_ha->chip->n_phy; i++)
204 pm8001_phy_init(pm8001_ha, i); 204 pm8001_phy_init(pm8001_ha, i);
205 205
206 pm8001_ha->tags = kmalloc(sizeof(*pm8001_ha->tags)*PM8001_MAX_DEVICES, 206 pm8001_ha->tags = kzalloc(PM8001_MAX_CCB, GFP_KERNEL);
207 GFP_KERNEL); 207 if (!pm8001_ha->tags)
208 208 goto err_out;
209 /* MPI Memory region 1 for AAP Event Log for fw */ 209 /* MPI Memory region 1 for AAP Event Log for fw */
210 pm8001_ha->memoryMap.region[AAP1].num_elements = 1; 210 pm8001_ha->memoryMap.region[AAP1].num_elements = 1;
211 pm8001_ha->memoryMap.region[AAP1].element_size = PM8001_EVENT_LOG_SIZE; 211 pm8001_ha->memoryMap.region[AAP1].element_size = PM8001_EVENT_LOG_SIZE;
@@ -287,6 +287,9 @@ static int __devinit pm8001_alloc(struct pm8001_hba_info *pm8001_ha)
287 pm8001_ha->ccb_info[i].ccb_dma_handle = 287 pm8001_ha->ccb_info[i].ccb_dma_handle =
288 pm8001_ha->memoryMap.region[CCB_MEM].phys_addr + 288 pm8001_ha->memoryMap.region[CCB_MEM].phys_addr +
289 i * sizeof(struct pm8001_ccb_info); 289 i * sizeof(struct pm8001_ccb_info);
290 pm8001_ha->ccb_info[i].task = NULL;
291 pm8001_ha->ccb_info[i].ccb_tag = 0xffffffff;
292 pm8001_ha->ccb_info[i].device = NULL;
290 ++pm8001_ha->tags_num; 293 ++pm8001_ha->tags_num;
291 } 294 }
292 pm8001_ha->flags = PM8001F_INIT_TIME; 295 pm8001_ha->flags = PM8001F_INIT_TIME;
@@ -578,7 +581,7 @@ static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha)
578{ 581{
579 struct pci_dev *pdev; 582 struct pci_dev *pdev;
580 irq_handler_t irq_handler = pm8001_interrupt; 583 irq_handler_t irq_handler = pm8001_interrupt;
581 u32 rc; 584 int rc;
582 585
583 pdev = pm8001_ha->pdev; 586 pdev = pm8001_ha->pdev;
584 587
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index 1e840fd15160..1f767a0e727a 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -330,15 +330,12 @@ int pm8001_slave_configure(struct scsi_device *sdev)
330 return 0; 330 return 0;
331} 331}
332/** 332/**
333 * pm8001_task_exec -execute the task which come from upper level, send the 333 * pm8001_task_exec - queue the task(ssp, smp && ata) to the hardware.
334 * command or data to DMA area and then increase CI,for queuecommand(ssp),
335 * it is from upper layer and for smp command,it is from libsas,
336 * for ata command it is from libata.
337 * @task: the task to be execute. 334 * @task: the task to be execute.
338 * @num: if can_queue great than 1, the task can be queued up. for SMP task, 335 * @num: if can_queue great than 1, the task can be queued up. for SMP task,
339 * we always execute one one time. 336 * we always execute one one time.
340 * @gfp_flags: gfp_flags. 337 * @gfp_flags: gfp_flags.
341 * @is tmf: if it is task management task. 338 * @is_tmf: if it is task management task.
342 * @tmf: the task management IU 339 * @tmf: the task management IU
343 */ 340 */
344#define DEV_IS_GONE(pm8001_dev) \ 341#define DEV_IS_GONE(pm8001_dev) \
@@ -379,7 +376,7 @@ static int pm8001_task_exec(struct sas_task *task, const int num,
379 pm8001_printk("device %016llx not " 376 pm8001_printk("device %016llx not "
380 "ready.\n", SAS_ADDR(dev->sas_addr))); 377 "ready.\n", SAS_ADDR(dev->sas_addr)));
381 } 378 }
382 rc = SAS_PHY_DOWN; 379 rc = SAS_PHY_DOWN;
383 goto out_done; 380 goto out_done;
384 } 381 }
385 rc = pm8001_tag_alloc(pm8001_ha, &tag); 382 rc = pm8001_tag_alloc(pm8001_ha, &tag);
@@ -395,14 +392,14 @@ static int pm8001_task_exec(struct sas_task *task, const int num,
395 t->data_dir); 392 t->data_dir);
396 if (!n_elem) { 393 if (!n_elem) {
397 rc = -ENOMEM; 394 rc = -ENOMEM;
398 goto err_out; 395 goto err_out_tag;
399 } 396 }
400 } 397 }
401 } else { 398 } else {
402 n_elem = t->num_scatter; 399 n_elem = t->num_scatter;
403 } 400 }
404 401
405 t->lldd_task = NULL; 402 t->lldd_task = ccb;
406 ccb->n_elem = n_elem; 403 ccb->n_elem = n_elem;
407 ccb->ccb_tag = tag; 404 ccb->ccb_tag = tag;
408 ccb->task = t; 405 ccb->task = t;
@@ -435,7 +432,6 @@ static int pm8001_task_exec(struct sas_task *task, const int num,
435 pm8001_printk("rc is %x\n", rc)); 432 pm8001_printk("rc is %x\n", rc));
436 goto err_out_tag; 433 goto err_out_tag;
437 } 434 }
438 t->lldd_task = ccb;
439 /* TODO: select normal or high priority */ 435 /* TODO: select normal or high priority */
440 spin_lock(&t->task_state_lock); 436 spin_lock(&t->task_state_lock);
441 t->task_state_flags |= SAS_TASK_AT_INITIATOR; 437 t->task_state_flags |= SAS_TASK_AT_INITIATOR;
@@ -518,8 +514,7 @@ void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha,
518} 514}
519 515
520 /** 516 /**
521 * pm8001_alloc_dev - find the empty pm8001_device structure, allocate and 517 * pm8001_alloc_dev - find a empty pm8001_device
522 * return it for use.
523 * @pm8001_ha: our hba card information 518 * @pm8001_ha: our hba card information
524 */ 519 */
525struct pm8001_device *pm8001_alloc_dev(struct pm8001_hba_info *pm8001_ha) 520struct pm8001_device *pm8001_alloc_dev(struct pm8001_hba_info *pm8001_ha)
@@ -550,14 +545,16 @@ static void pm8001_free_dev(struct pm8001_device *pm8001_dev)
550} 545}
551 546
552/** 547/**
553 * pm8001_dev_found_notify - when libsas find a sas domain device, it should 548 * pm8001_dev_found_notify - libsas notify a device is found.
554 * tell the LLDD that device is found, and then LLDD register this device to 549 * @dev: the device structure which sas layer used.
555 * HBA FW by the command "OPC_INB_REG_DEV", after that the HBA will assign 550 *
556 * a device ID(according to device's sas address) and returned it to LLDD.from 551 * when libsas find a sas domain device, it should tell the LLDD that
552 * device is found, and then LLDD register this device to HBA firmware
553 * by the command "OPC_INB_REG_DEV", after that the HBA will assign a
554 * device ID(according to device's sas address) and returned it to LLDD. From
557 * now on, we communicate with HBA FW with the device ID which HBA assigned 555 * now on, we communicate with HBA FW with the device ID which HBA assigned
558 * rather than sas address. it is the neccessary step for our HBA but it is 556 * rather than sas address. it is the neccessary step for our HBA but it is
559 * the optional for other HBA driver. 557 * the optional for other HBA driver.
560 * @dev: the device structure which sas layer used.
561 */ 558 */
562static int pm8001_dev_found_notify(struct domain_device *dev) 559static int pm8001_dev_found_notify(struct domain_device *dev)
563{ 560{
@@ -665,14 +662,15 @@ static void pm8001_tmf_timedout(unsigned long data)
665 662
666#define PM8001_TASK_TIMEOUT 20 663#define PM8001_TASK_TIMEOUT 20
667/** 664/**
668 * pm8001_exec_internal_tmf_task - when errors or exception happened, we may 665 * pm8001_exec_internal_tmf_task - execute some task management commands.
669 * want to do something, for example abort issued task which result in this
670 * execption, this is by calling this function, note it is also with the task
671 * execute interface.
672 * @dev: the wanted device. 666 * @dev: the wanted device.
673 * @tmf: which task management wanted to be take. 667 * @tmf: which task management wanted to be take.
674 * @para_len: para_len. 668 * @para_len: para_len.
675 * @parameter: ssp task parameter. 669 * @parameter: ssp task parameter.
670 *
671 * when errors or exception happened, we may want to do something, for example
672 * abort the issued task which result in this execption, it is done by calling
673 * this function, note it is also with the task execute interface.
676 */ 674 */
677static int pm8001_exec_internal_tmf_task(struct domain_device *dev, 675static int pm8001_exec_internal_tmf_task(struct domain_device *dev,
678 void *parameter, u32 para_len, struct pm8001_tmf_task *tmf) 676 void *parameter, u32 para_len, struct pm8001_tmf_task *tmf)
@@ -737,9 +735,9 @@ static int pm8001_exec_internal_tmf_task(struct domain_device *dev,
737 res = -EMSGSIZE; 735 res = -EMSGSIZE;
738 break; 736 break;
739 } else { 737 } else {
740 PM8001_IO_DBG(pm8001_ha, 738 PM8001_EH_DBG(pm8001_ha,
741 pm8001_printk(" Task to dev %016llx response: 0x%x" 739 pm8001_printk(" Task to dev %016llx response:"
742 "status 0x%x\n", 740 "0x%x status 0x%x\n",
743 SAS_ADDR(dev->sas_addr), 741 SAS_ADDR(dev->sas_addr),
744 task->task_status.resp, 742 task->task_status.resp,
745 task->task_status.stat)); 743 task->task_status.stat));
@@ -760,7 +758,7 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
760 u32 task_tag) 758 u32 task_tag)
761{ 759{
762 int res, retry; 760 int res, retry;
763 u32 rc, ccb_tag; 761 u32 ccb_tag;
764 struct pm8001_ccb_info *ccb; 762 struct pm8001_ccb_info *ccb;
765 struct sas_task *task = NULL; 763 struct sas_task *task = NULL;
766 764
@@ -777,9 +775,9 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
777 task->timer.expires = jiffies + PM8001_TASK_TIMEOUT*HZ; 775 task->timer.expires = jiffies + PM8001_TASK_TIMEOUT*HZ;
778 add_timer(&task->timer); 776 add_timer(&task->timer);
779 777
780 rc = pm8001_tag_alloc(pm8001_ha, &ccb_tag); 778 res = pm8001_tag_alloc(pm8001_ha, &ccb_tag);
781 if (rc) 779 if (res)
782 return rc; 780 return res;
783 ccb = &pm8001_ha->ccb_info[ccb_tag]; 781 ccb = &pm8001_ha->ccb_info[ccb_tag];
784 ccb->device = pm8001_dev; 782 ccb->device = pm8001_dev;
785 ccb->ccb_tag = ccb_tag; 783 ccb->ccb_tag = ccb_tag;
@@ -812,7 +810,7 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
812 break; 810 break;
813 811
814 } else { 812 } else {
815 PM8001_IO_DBG(pm8001_ha, 813 PM8001_EH_DBG(pm8001_ha,
816 pm8001_printk(" Task to dev %016llx response: " 814 pm8001_printk(" Task to dev %016llx response: "
817 "0x%x status 0x%x\n", 815 "0x%x status 0x%x\n",
818 SAS_ADDR(dev->sas_addr), 816 SAS_ADDR(dev->sas_addr),
@@ -1027,11 +1025,11 @@ int pm8001_abort_task(struct sas_task *task)
1027 } 1025 }
1028 device_id = pm8001_dev->device_id; 1026 device_id = pm8001_dev->device_id;
1029 PM8001_EH_DBG(pm8001_ha, 1027 PM8001_EH_DBG(pm8001_ha,
1030 pm8001_printk("abort io to device_id = %d\n", device_id)); 1028 pm8001_printk("abort io to deviceid= %d\n", device_id));
1031 tmf_task.tmf = TMF_ABORT_TASK; 1029 tmf_task.tmf = TMF_ABORT_TASK;
1032 tmf_task.tag_of_task_to_be_managed = tag; 1030 tmf_task.tag_of_task_to_be_managed = tag;
1033 rc = pm8001_issue_ssp_tmf(dev, lun.scsi_lun, &tmf_task); 1031 rc = pm8001_issue_ssp_tmf(dev, lun.scsi_lun, &tmf_task);
1034 rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev, 1032 pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
1035 pm8001_dev->sas_device, 0, tag); 1033 pm8001_dev->sas_device, 0, tag);
1036 } else if (task->task_proto & SAS_PROTOCOL_SATA || 1034 } else if (task->task_proto & SAS_PROTOCOL_SATA ||
1037 task->task_proto & SAS_PROTOCOL_STP) { 1035 task->task_proto & SAS_PROTOCOL_STP) {