diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_scsi.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_scsi.c | 86 |
1 files changed, 66 insertions, 20 deletions
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index f4a3b2e79eea..c818a7255962 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c | |||
@@ -623,6 +623,7 @@ lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba, | |||
623 | unsigned long iflag = 0; | 623 | unsigned long iflag = 0; |
624 | struct lpfc_iocbq *iocbq; | 624 | struct lpfc_iocbq *iocbq; |
625 | int i; | 625 | int i; |
626 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; | ||
626 | 627 | ||
627 | spin_lock_irqsave(&phba->hbalock, iflag); | 628 | spin_lock_irqsave(&phba->hbalock, iflag); |
628 | spin_lock(&phba->sli4_hba.abts_scsi_buf_list_lock); | 629 | spin_lock(&phba->sli4_hba.abts_scsi_buf_list_lock); |
@@ -651,6 +652,8 @@ lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba, | |||
651 | psb = container_of(iocbq, struct lpfc_scsi_buf, cur_iocbq); | 652 | psb = container_of(iocbq, struct lpfc_scsi_buf, cur_iocbq); |
652 | psb->exch_busy = 0; | 653 | psb->exch_busy = 0; |
653 | spin_unlock_irqrestore(&phba->hbalock, iflag); | 654 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
655 | if (pring->txq_cnt) | ||
656 | lpfc_worker_wake_up(phba); | ||
654 | return; | 657 | return; |
655 | 658 | ||
656 | } | 659 | } |
@@ -747,7 +750,6 @@ lpfc_new_scsi_buf_s4(struct lpfc_vport *vport, int num_to_alloc) | |||
747 | int status = 0, index; | 750 | int status = 0, index; |
748 | int bcnt; | 751 | int bcnt; |
749 | int non_sequential_xri = 0; | 752 | int non_sequential_xri = 0; |
750 | int rc = 0; | ||
751 | LIST_HEAD(sblist); | 753 | LIST_HEAD(sblist); |
752 | 754 | ||
753 | for (bcnt = 0; bcnt < num_to_alloc; bcnt++) { | 755 | for (bcnt = 0; bcnt < num_to_alloc; bcnt++) { |
@@ -774,6 +776,8 @@ lpfc_new_scsi_buf_s4(struct lpfc_vport *vport, int num_to_alloc) | |||
774 | /* Allocate iotag for psb->cur_iocbq. */ | 776 | /* Allocate iotag for psb->cur_iocbq. */ |
775 | iotag = lpfc_sli_next_iotag(phba, &psb->cur_iocbq); | 777 | iotag = lpfc_sli_next_iotag(phba, &psb->cur_iocbq); |
776 | if (iotag == 0) { | 778 | if (iotag == 0) { |
779 | pci_pool_free(phba->lpfc_scsi_dma_buf_pool, | ||
780 | psb->data, psb->dma_handle); | ||
777 | kfree(psb); | 781 | kfree(psb); |
778 | break; | 782 | break; |
779 | } | 783 | } |
@@ -858,7 +862,6 @@ lpfc_new_scsi_buf_s4(struct lpfc_vport *vport, int num_to_alloc) | |||
858 | if (status) { | 862 | if (status) { |
859 | /* Put this back on the abort scsi list */ | 863 | /* Put this back on the abort scsi list */ |
860 | psb->exch_busy = 1; | 864 | psb->exch_busy = 1; |
861 | rc++; | ||
862 | } else { | 865 | } else { |
863 | psb->exch_busy = 0; | 866 | psb->exch_busy = 0; |
864 | psb->status = IOSTAT_SUCCESS; | 867 | psb->status = IOSTAT_SUCCESS; |
@@ -877,7 +880,6 @@ lpfc_new_scsi_buf_s4(struct lpfc_vport *vport, int num_to_alloc) | |||
877 | if (status) { | 880 | if (status) { |
878 | /* Put this back on the abort scsi list */ | 881 | /* Put this back on the abort scsi list */ |
879 | psb->exch_busy = 1; | 882 | psb->exch_busy = 1; |
880 | rc++; | ||
881 | } else { | 883 | } else { |
882 | psb->exch_busy = 0; | 884 | psb->exch_busy = 0; |
883 | psb->status = IOSTAT_SUCCESS; | 885 | psb->status = IOSTAT_SUCCESS; |
@@ -887,7 +889,7 @@ lpfc_new_scsi_buf_s4(struct lpfc_vport *vport, int num_to_alloc) | |||
887 | } | 889 | } |
888 | } | 890 | } |
889 | 891 | ||
890 | return bcnt + non_sequential_xri - rc; | 892 | return bcnt + non_sequential_xri; |
891 | } | 893 | } |
892 | 894 | ||
893 | /** | 895 | /** |
@@ -1323,6 +1325,10 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
1323 | bf_set(pde5_type, pde5, LPFC_PDE5_DESCRIPTOR); | 1325 | bf_set(pde5_type, pde5, LPFC_PDE5_DESCRIPTOR); |
1324 | pde5->reftag = reftag; | 1326 | pde5->reftag = reftag; |
1325 | 1327 | ||
1328 | /* Endian convertion if necessary for PDE5 */ | ||
1329 | pde5->word0 = cpu_to_le32(pde5->word0); | ||
1330 | pde5->reftag = cpu_to_le32(pde5->reftag); | ||
1331 | |||
1326 | /* advance bpl and increment bde count */ | 1332 | /* advance bpl and increment bde count */ |
1327 | num_bde++; | 1333 | num_bde++; |
1328 | bpl++; | 1334 | bpl++; |
@@ -1341,6 +1347,11 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
1341 | bf_set(pde6_ai, pde6, 1); | 1347 | bf_set(pde6_ai, pde6, 1); |
1342 | bf_set(pde6_apptagval, pde6, apptagval); | 1348 | bf_set(pde6_apptagval, pde6, apptagval); |
1343 | 1349 | ||
1350 | /* Endian convertion if necessary for PDE6 */ | ||
1351 | pde6->word0 = cpu_to_le32(pde6->word0); | ||
1352 | pde6->word1 = cpu_to_le32(pde6->word1); | ||
1353 | pde6->word2 = cpu_to_le32(pde6->word2); | ||
1354 | |||
1344 | /* advance bpl and increment bde count */ | 1355 | /* advance bpl and increment bde count */ |
1345 | num_bde++; | 1356 | num_bde++; |
1346 | bpl++; | 1357 | bpl++; |
@@ -1448,6 +1459,10 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
1448 | bf_set(pde5_type, pde5, LPFC_PDE5_DESCRIPTOR); | 1459 | bf_set(pde5_type, pde5, LPFC_PDE5_DESCRIPTOR); |
1449 | pde5->reftag = reftag; | 1460 | pde5->reftag = reftag; |
1450 | 1461 | ||
1462 | /* Endian convertion if necessary for PDE5 */ | ||
1463 | pde5->word0 = cpu_to_le32(pde5->word0); | ||
1464 | pde5->reftag = cpu_to_le32(pde5->reftag); | ||
1465 | |||
1451 | /* advance bpl and increment bde count */ | 1466 | /* advance bpl and increment bde count */ |
1452 | num_bde++; | 1467 | num_bde++; |
1453 | bpl++; | 1468 | bpl++; |
@@ -1464,6 +1479,11 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
1464 | bf_set(pde6_ai, pde6, 1); | 1479 | bf_set(pde6_ai, pde6, 1); |
1465 | bf_set(pde6_apptagval, pde6, apptagval); | 1480 | bf_set(pde6_apptagval, pde6, apptagval); |
1466 | 1481 | ||
1482 | /* Endian convertion if necessary for PDE6 */ | ||
1483 | pde6->word0 = cpu_to_le32(pde6->word0); | ||
1484 | pde6->word1 = cpu_to_le32(pde6->word1); | ||
1485 | pde6->word2 = cpu_to_le32(pde6->word2); | ||
1486 | |||
1467 | /* advance bpl and increment bde count */ | 1487 | /* advance bpl and increment bde count */ |
1468 | num_bde++; | 1488 | num_bde++; |
1469 | bpl++; | 1489 | bpl++; |
@@ -1475,7 +1495,6 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
1475 | prot_bde->addrLow = le32_to_cpu(putPaddrHigh(protphysaddr)); | 1495 | prot_bde->addrLow = le32_to_cpu(putPaddrHigh(protphysaddr)); |
1476 | protgroup_len = sg_dma_len(sgpe); | 1496 | protgroup_len = sg_dma_len(sgpe); |
1477 | 1497 | ||
1478 | |||
1479 | /* must be integer multiple of the DIF block length */ | 1498 | /* must be integer multiple of the DIF block length */ |
1480 | BUG_ON(protgroup_len % 8); | 1499 | BUG_ON(protgroup_len % 8); |
1481 | 1500 | ||
@@ -2293,15 +2312,21 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
2293 | struct lpfc_vport *vport = pIocbIn->vport; | 2312 | struct lpfc_vport *vport = pIocbIn->vport; |
2294 | struct lpfc_rport_data *rdata = lpfc_cmd->rdata; | 2313 | struct lpfc_rport_data *rdata = lpfc_cmd->rdata; |
2295 | struct lpfc_nodelist *pnode = rdata->pnode; | 2314 | struct lpfc_nodelist *pnode = rdata->pnode; |
2296 | struct scsi_cmnd *cmd = lpfc_cmd->pCmd; | 2315 | struct scsi_cmnd *cmd; |
2297 | int result; | 2316 | int result; |
2298 | struct scsi_device *tmp_sdev; | 2317 | struct scsi_device *tmp_sdev; |
2299 | int depth; | 2318 | int depth; |
2300 | unsigned long flags; | 2319 | unsigned long flags; |
2301 | struct lpfc_fast_path_event *fast_path_evt; | 2320 | struct lpfc_fast_path_event *fast_path_evt; |
2302 | struct Scsi_Host *shost = cmd->device->host; | 2321 | struct Scsi_Host *shost; |
2303 | uint32_t queue_depth, scsi_id; | 2322 | uint32_t queue_depth, scsi_id; |
2304 | 2323 | ||
2324 | /* Sanity check on return of outstanding command */ | ||
2325 | if (!(lpfc_cmd->pCmd)) | ||
2326 | return; | ||
2327 | cmd = lpfc_cmd->pCmd; | ||
2328 | shost = cmd->device->host; | ||
2329 | |||
2305 | lpfc_cmd->result = pIocbOut->iocb.un.ulpWord[4]; | 2330 | lpfc_cmd->result = pIocbOut->iocb.un.ulpWord[4]; |
2306 | lpfc_cmd->status = pIocbOut->iocb.ulpStatus; | 2331 | lpfc_cmd->status = pIocbOut->iocb.ulpStatus; |
2307 | /* pick up SLI4 exhange busy status from HBA */ | 2332 | /* pick up SLI4 exhange busy status from HBA */ |
@@ -2363,7 +2388,8 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
2363 | case IOSTAT_LOCAL_REJECT: | 2388 | case IOSTAT_LOCAL_REJECT: |
2364 | if (lpfc_cmd->result == IOERR_INVALID_RPI || | 2389 | if (lpfc_cmd->result == IOERR_INVALID_RPI || |
2365 | lpfc_cmd->result == IOERR_NO_RESOURCES || | 2390 | lpfc_cmd->result == IOERR_NO_RESOURCES || |
2366 | lpfc_cmd->result == IOERR_ABORT_REQUESTED) { | 2391 | lpfc_cmd->result == IOERR_ABORT_REQUESTED || |
2392 | lpfc_cmd->result == IOERR_SLER_CMD_RCV_FAILURE) { | ||
2367 | cmd->result = ScsiResult(DID_REQUEUE, 0); | 2393 | cmd->result = ScsiResult(DID_REQUEUE, 0); |
2368 | break; | 2394 | break; |
2369 | } | 2395 | } |
@@ -2432,14 +2458,16 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
2432 | } | 2458 | } |
2433 | spin_unlock_irqrestore(shost->host_lock, flags); | 2459 | spin_unlock_irqrestore(shost->host_lock, flags); |
2434 | } else if (pnode && NLP_CHK_NODE_ACT(pnode)) { | 2460 | } else if (pnode && NLP_CHK_NODE_ACT(pnode)) { |
2435 | if ((pnode->cmd_qdepth < LPFC_MAX_TGT_QDEPTH) && | 2461 | if ((pnode->cmd_qdepth < vport->cfg_tgt_queue_depth) && |
2436 | time_after(jiffies, pnode->last_change_time + | 2462 | time_after(jiffies, pnode->last_change_time + |
2437 | msecs_to_jiffies(LPFC_TGTQ_INTERVAL))) { | 2463 | msecs_to_jiffies(LPFC_TGTQ_INTERVAL))) { |
2438 | spin_lock_irqsave(shost->host_lock, flags); | 2464 | spin_lock_irqsave(shost->host_lock, flags); |
2439 | pnode->cmd_qdepth += pnode->cmd_qdepth * | 2465 | depth = pnode->cmd_qdepth * LPFC_TGTQ_RAMPUP_PCENT |
2440 | LPFC_TGTQ_RAMPUP_PCENT / 100; | 2466 | / 100; |
2441 | if (pnode->cmd_qdepth > LPFC_MAX_TGT_QDEPTH) | 2467 | depth = depth ? depth : 1; |
2442 | pnode->cmd_qdepth = LPFC_MAX_TGT_QDEPTH; | 2468 | pnode->cmd_qdepth += depth; |
2469 | if (pnode->cmd_qdepth > vport->cfg_tgt_queue_depth) | ||
2470 | pnode->cmd_qdepth = vport->cfg_tgt_queue_depth; | ||
2443 | pnode->last_change_time = jiffies; | 2471 | pnode->last_change_time = jiffies; |
2444 | spin_unlock_irqrestore(shost->host_lock, flags); | 2472 | spin_unlock_irqrestore(shost->host_lock, flags); |
2445 | } | 2473 | } |
@@ -2894,8 +2922,7 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) | |||
2894 | cmnd->result = ScsiResult(DID_TRANSPORT_DISRUPTED, 0); | 2922 | cmnd->result = ScsiResult(DID_TRANSPORT_DISRUPTED, 0); |
2895 | goto out_fail_command; | 2923 | goto out_fail_command; |
2896 | } | 2924 | } |
2897 | if (vport->cfg_max_scsicmpl_time && | 2925 | if (atomic_read(&ndlp->cmd_pending) >= ndlp->cmd_qdepth) |
2898 | (atomic_read(&ndlp->cmd_pending) >= ndlp->cmd_qdepth)) | ||
2899 | goto out_host_busy; | 2926 | goto out_host_busy; |
2900 | 2927 | ||
2901 | lpfc_cmd = lpfc_get_scsi_buf(phba); | 2928 | lpfc_cmd = lpfc_get_scsi_buf(phba); |
@@ -3041,7 +3068,9 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) | |||
3041 | int ret = SUCCESS; | 3068 | int ret = SUCCESS; |
3042 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waitq); | 3069 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waitq); |
3043 | 3070 | ||
3044 | fc_block_scsi_eh(cmnd); | 3071 | ret = fc_block_scsi_eh(cmnd); |
3072 | if (ret) | ||
3073 | return ret; | ||
3045 | lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble; | 3074 | lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble; |
3046 | BUG_ON(!lpfc_cmd); | 3075 | BUG_ON(!lpfc_cmd); |
3047 | 3076 | ||
@@ -3225,7 +3254,9 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct lpfc_rport_data *rdata, | |||
3225 | lpfc_taskmgmt_name(task_mgmt_cmd), | 3254 | lpfc_taskmgmt_name(task_mgmt_cmd), |
3226 | tgt_id, lun_id, iocbqrsp->iocb.ulpStatus, | 3255 | tgt_id, lun_id, iocbqrsp->iocb.ulpStatus, |
3227 | iocbqrsp->iocb.un.ulpWord[4]); | 3256 | iocbqrsp->iocb.un.ulpWord[4]); |
3228 | } else | 3257 | } else if (status == IOCB_BUSY) |
3258 | ret = FAILED; | ||
3259 | else | ||
3229 | ret = SUCCESS; | 3260 | ret = SUCCESS; |
3230 | 3261 | ||
3231 | lpfc_sli_release_iocbq(phba, iocbqrsp); | 3262 | lpfc_sli_release_iocbq(phba, iocbqrsp); |
@@ -3357,7 +3388,9 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd) | |||
3357 | return FAILED; | 3388 | return FAILED; |
3358 | } | 3389 | } |
3359 | pnode = rdata->pnode; | 3390 | pnode = rdata->pnode; |
3360 | fc_block_scsi_eh(cmnd); | 3391 | status = fc_block_scsi_eh(cmnd); |
3392 | if (status) | ||
3393 | return status; | ||
3361 | 3394 | ||
3362 | status = lpfc_chk_tgt_mapped(vport, cmnd); | 3395 | status = lpfc_chk_tgt_mapped(vport, cmnd); |
3363 | if (status == FAILED) { | 3396 | if (status == FAILED) { |
@@ -3422,7 +3455,9 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd) | |||
3422 | return FAILED; | 3455 | return FAILED; |
3423 | } | 3456 | } |
3424 | pnode = rdata->pnode; | 3457 | pnode = rdata->pnode; |
3425 | fc_block_scsi_eh(cmnd); | 3458 | status = fc_block_scsi_eh(cmnd); |
3459 | if (status) | ||
3460 | return status; | ||
3426 | 3461 | ||
3427 | status = lpfc_chk_tgt_mapped(vport, cmnd); | 3462 | status = lpfc_chk_tgt_mapped(vport, cmnd); |
3428 | if (status == FAILED) { | 3463 | if (status == FAILED) { |
@@ -3488,7 +3523,9 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd) | |||
3488 | fc_host_post_vendor_event(shost, fc_get_event_number(), | 3523 | fc_host_post_vendor_event(shost, fc_get_event_number(), |
3489 | sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID); | 3524 | sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID); |
3490 | 3525 | ||
3491 | fc_block_scsi_eh(cmnd); | 3526 | ret = fc_block_scsi_eh(cmnd); |
3527 | if (ret) | ||
3528 | return ret; | ||
3492 | 3529 | ||
3493 | /* | 3530 | /* |
3494 | * Since the driver manages a single bus device, reset all | 3531 | * Since the driver manages a single bus device, reset all |
@@ -3561,11 +3598,13 @@ lpfc_slave_alloc(struct scsi_device *sdev) | |||
3561 | uint32_t total = 0; | 3598 | uint32_t total = 0; |
3562 | uint32_t num_to_alloc = 0; | 3599 | uint32_t num_to_alloc = 0; |
3563 | int num_allocated = 0; | 3600 | int num_allocated = 0; |
3601 | uint32_t sdev_cnt; | ||
3564 | 3602 | ||
3565 | if (!rport || fc_remote_port_chkready(rport)) | 3603 | if (!rport || fc_remote_port_chkready(rport)) |
3566 | return -ENXIO; | 3604 | return -ENXIO; |
3567 | 3605 | ||
3568 | sdev->hostdata = rport->dd_data; | 3606 | sdev->hostdata = rport->dd_data; |
3607 | sdev_cnt = atomic_inc_return(&phba->sdev_cnt); | ||
3569 | 3608 | ||
3570 | /* | 3609 | /* |
3571 | * Populate the cmds_per_lun count scsi_bufs into this host's globally | 3610 | * Populate the cmds_per_lun count scsi_bufs into this host's globally |
@@ -3577,6 +3616,10 @@ lpfc_slave_alloc(struct scsi_device *sdev) | |||
3577 | total = phba->total_scsi_bufs; | 3616 | total = phba->total_scsi_bufs; |
3578 | num_to_alloc = vport->cfg_lun_queue_depth + 2; | 3617 | num_to_alloc = vport->cfg_lun_queue_depth + 2; |
3579 | 3618 | ||
3619 | /* If allocated buffers are enough do nothing */ | ||
3620 | if ((sdev_cnt * (vport->cfg_lun_queue_depth + 2)) < total) | ||
3621 | return 0; | ||
3622 | |||
3580 | /* Allow some exchanges to be available always to complete discovery */ | 3623 | /* Allow some exchanges to be available always to complete discovery */ |
3581 | if (total >= phba->cfg_hba_queue_depth - LPFC_DISC_IOCB_BUFF_COUNT ) { | 3624 | if (total >= phba->cfg_hba_queue_depth - LPFC_DISC_IOCB_BUFF_COUNT ) { |
3582 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP, | 3625 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP, |
@@ -3658,6 +3701,9 @@ lpfc_slave_configure(struct scsi_device *sdev) | |||
3658 | static void | 3701 | static void |
3659 | lpfc_slave_destroy(struct scsi_device *sdev) | 3702 | lpfc_slave_destroy(struct scsi_device *sdev) |
3660 | { | 3703 | { |
3704 | struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata; | ||
3705 | struct lpfc_hba *phba = vport->phba; | ||
3706 | atomic_dec(&phba->sdev_cnt); | ||
3661 | sdev->hostdata = NULL; | 3707 | sdev->hostdata = NULL; |
3662 | return; | 3708 | return; |
3663 | } | 3709 | } |