Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

jack_wang and committed by
James Bottomley
97ee2088 72d0baa0

+36 -35
+7 -4
drivers/scsi/pm8001/pm8001_init.c
··· 203 203 for (i = 0; i < pm8001_ha->chip->n_phy; i++) 204 204 pm8001_phy_init(pm8001_ha, i); 205 205 206 - pm8001_ha->tags = kmalloc(sizeof(*pm8001_ha->tags)*PM8001_MAX_DEVICES, 207 - GFP_KERNEL); 208 - 206 + pm8001_ha->tags = kzalloc(PM8001_MAX_CCB, GFP_KERNEL); 207 + if (!pm8001_ha->tags) 208 + goto err_out; 209 209 /* MPI Memory region 1 for AAP Event Log for fw */ 210 210 pm8001_ha->memoryMap.region[AAP1].num_elements = 1; 211 211 pm8001_ha->memoryMap.region[AAP1].element_size = PM8001_EVENT_LOG_SIZE; ··· 287 287 pm8001_ha->ccb_info[i].ccb_dma_handle = 288 288 pm8001_ha->memoryMap.region[CCB_MEM].phys_addr + 289 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 293 ++pm8001_ha->tags_num; 291 294 } 292 295 pm8001_ha->flags = PM8001F_INIT_TIME; ··· 581 578 { 582 579 struct pci_dev *pdev; 583 580 irq_handler_t irq_handler = pm8001_interrupt; 584 - u32 rc; 581 + int rc; 585 582 586 583 pdev = pm8001_ha->pdev; 587 584
+29 -31
drivers/scsi/pm8001/pm8001_sas.c
··· 330 330 return 0; 331 331 } 332 332 /** 333 - * pm8001_task_exec -execute the task which come from upper level, send the 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. 333 + * pm8001_task_exec - queue the task(ssp, smp && ata) to the hardware. 337 334 * @task: the task to be execute. 338 335 * @num: if can_queue great than 1, the task can be queued up. for SMP task, 339 336 * we always execute one one time. 340 337 * @gfp_flags: gfp_flags. 341 - * @is tmf: if it is task management task. 338 + * @is_tmf: if it is task management task. 342 339 * @tmf: the task management IU 343 340 */ 344 341 #define DEV_IS_GONE(pm8001_dev) \ ··· 376 379 pm8001_printk("device %016llx not " 377 380 "ready.\n", SAS_ADDR(dev->sas_addr))); 378 381 } 379 - rc = SAS_PHY_DOWN; 382 + rc = SAS_PHY_DOWN; 380 383 goto out_done; 381 384 } 382 385 rc = pm8001_tag_alloc(pm8001_ha, &tag); ··· 392 395 t->data_dir); 393 396 if (!n_elem) { 394 397 rc = -ENOMEM; 395 - goto err_out; 398 + goto err_out_tag; 396 399 } 397 400 } 398 401 } else { 399 402 n_elem = t->num_scatter; 400 403 } 401 404 402 - t->lldd_task = NULL; 405 + t->lldd_task = ccb; 403 406 ccb->n_elem = n_elem; 404 407 ccb->ccb_tag = tag; 405 408 ccb->task = t; ··· 432 435 pm8001_printk("rc is %x\n", rc)); 433 436 goto err_out_tag; 434 437 } 435 - t->lldd_task = ccb; 436 438 /* TODO: select normal or high priority */ 437 439 spin_lock(&t->task_state_lock); 438 440 t->task_state_flags |= SAS_TASK_AT_INITIATOR; ··· 514 518 } 515 519 516 520 /** 517 - * pm8001_alloc_dev - find the empty pm8001_device structure, allocate and 518 - * return it for use. 521 + * pm8001_alloc_dev - find a empty pm8001_device 519 522 * @pm8001_ha: our hba card information 520 523 */ 521 524 struct pm8001_device *pm8001_alloc_dev(struct pm8001_hba_info *pm8001_ha) ··· 545 550 } 546 551 547 552 /** 548 - * pm8001_dev_found_notify - when libsas find a sas domain device, it should 549 - * tell the LLDD that device is found, and then LLDD register this device to 550 - * HBA FW by the command "OPC_INB_REG_DEV", after that the HBA will assign 551 - * a device ID(according to device's sas address) and returned it to LLDD.from 553 + * pm8001_dev_found_notify - libsas notify a device is found. 554 + * @dev: the device structure which sas layer used. 555 + * 556 + * when libsas find a sas domain device, it should tell the LLDD that 557 + * device is found, and then LLDD register this device to HBA firmware 558 + * by the command "OPC_INB_REG_DEV", after that the HBA will assign a 559 + * device ID(according to device's sas address) and returned it to LLDD. From 552 560 * now on, we communicate with HBA FW with the device ID which HBA assigned 553 561 * rather than sas address. it is the neccessary step for our HBA but it is 554 562 * the optional for other HBA driver. 555 - * @dev: the device structure which sas layer used. 556 563 */ 557 564 static int pm8001_dev_found_notify(struct domain_device *dev) 558 565 { ··· 662 665 663 666 #define PM8001_TASK_TIMEOUT 20 664 667 /** 665 - * pm8001_exec_internal_tmf_task - when errors or exception happened, we may 666 - * want to do something, for example abort issued task which result in this 667 - * execption, this is by calling this function, note it is also with the task 668 - * execute interface. 668 + * pm8001_exec_internal_tmf_task - execute some task management commands. 669 669 * @dev: the wanted device. 670 670 * @tmf: which task management wanted to be take. 671 671 * @para_len: para_len. 672 672 * @parameter: ssp task parameter. 673 + * 674 + * when errors or exception happened, we may want to do something, for example 675 + * abort the issued task which result in this execption, it is done by calling 676 + * this function, note it is also with the task execute interface. 673 677 */ 674 678 static int pm8001_exec_internal_tmf_task(struct domain_device *dev, 675 679 void *parameter, u32 para_len, struct pm8001_tmf_task *tmf) ··· 735 737 res = -EMSGSIZE; 736 738 break; 737 739 } else { 738 - PM8001_IO_DBG(pm8001_ha, 739 - pm8001_printk(" Task to dev %016llx response: 0x%x" 740 - "status 0x%x\n", 740 + PM8001_EH_DBG(pm8001_ha, 741 + pm8001_printk(" Task to dev %016llx response:" 742 + "0x%x status 0x%x\n", 741 743 SAS_ADDR(dev->sas_addr), 742 744 task->task_status.resp, 743 745 task->task_status.stat)); ··· 758 760 u32 task_tag) 759 761 { 760 762 int res, retry; 761 - u32 rc, ccb_tag; 763 + u32 ccb_tag; 762 764 struct pm8001_ccb_info *ccb; 763 765 struct sas_task *task = NULL; 764 766 ··· 775 777 task->timer.expires = jiffies + PM8001_TASK_TIMEOUT*HZ; 776 778 add_timer(&task->timer); 777 779 778 - rc = pm8001_tag_alloc(pm8001_ha, &ccb_tag); 779 - if (rc) 780 - return rc; 780 + res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); 781 + if (res) 782 + return res; 781 783 ccb = &pm8001_ha->ccb_info[ccb_tag]; 782 784 ccb->device = pm8001_dev; 783 785 ccb->ccb_tag = ccb_tag; ··· 810 812 break; 811 813 812 814 } else { 813 - PM8001_IO_DBG(pm8001_ha, 815 + PM8001_EH_DBG(pm8001_ha, 814 816 pm8001_printk(" Task to dev %016llx response: " 815 817 "0x%x status 0x%x\n", 816 818 SAS_ADDR(dev->sas_addr), ··· 1025 1027 } 1026 1028 device_id = pm8001_dev->device_id; 1027 1029 PM8001_EH_DBG(pm8001_ha, 1028 - pm8001_printk("abort io to device_id = %d\n", device_id)); 1029 - tmf_task.tmf = TMF_ABORT_TASK; 1030 + pm8001_printk("abort io to deviceid= %d\n", device_id)); 1031 + tmf_task.tmf = TMF_ABORT_TASK; 1030 1032 tmf_task.tag_of_task_to_be_managed = tag; 1031 1033 rc = pm8001_issue_ssp_tmf(dev, lun.scsi_lun, &tmf_task); 1032 - rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev, 1034 + pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev, 1033 1035 pm8001_dev->sas_device, 0, tag); 1034 1036 } else if (task->task_proto & SAS_PROTOCOL_SATA || 1035 1037 task->task_proto & SAS_PROTOCOL_STP) {