diff options
author | James Smart <James.Smart@Emulex.Com> | 2006-07-06 15:50:08 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-07-09 11:25:27 -0400 |
commit | bcf4dbfaf38502d3919e0601c06afac7d5e42685 (patch) | |
tree | 32a29d9b1b006a85d7a4b2b08a3afd1b785c8b00 /drivers | |
parent | 9279565046f39f3ab338818c9923a23b9f25be5f (diff) |
[SCSI] lpfc 8.1.7: Consolidate dma buf cleanup into a separate function
Consolidate dma buf cleanup into a separate function
Signed-off-by: James Smart <James.Smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_scsi.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 578468810416..d45616e70c67 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c | |||
@@ -153,22 +153,6 @@ static void | |||
153 | lpfc_release_scsi_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb) | 153 | lpfc_release_scsi_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb) |
154 | { | 154 | { |
155 | unsigned long iflag = 0; | 155 | unsigned long iflag = 0; |
156 | /* | ||
157 | * There are only two special cases to consider. (1) the scsi command | ||
158 | * requested scatter-gather usage or (2) the scsi command allocated | ||
159 | * a request buffer, but did not request use_sg. There is a third | ||
160 | * case, but it does not require resource deallocation. | ||
161 | */ | ||
162 | if ((psb->seg_cnt > 0) && (psb->pCmd->use_sg)) { | ||
163 | dma_unmap_sg(&phba->pcidev->dev, psb->pCmd->request_buffer, | ||
164 | psb->seg_cnt, psb->pCmd->sc_data_direction); | ||
165 | } else { | ||
166 | if ((psb->nonsg_phys) && (psb->pCmd->request_bufflen)) { | ||
167 | dma_unmap_single(&phba->pcidev->dev, psb->nonsg_phys, | ||
168 | psb->pCmd->request_bufflen, | ||
169 | psb->pCmd->sc_data_direction); | ||
170 | } | ||
171 | } | ||
172 | 156 | ||
173 | spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag); | 157 | spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag); |
174 | psb->pCmd = NULL; | 158 | psb->pCmd = NULL; |
@@ -282,6 +266,27 @@ lpfc_scsi_prep_dma_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * lpfc_cmd) | |||
282 | } | 266 | } |
283 | 267 | ||
284 | static void | 268 | static void |
269 | lpfc_scsi_unprep_dma_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb) | ||
270 | { | ||
271 | /* | ||
272 | * There are only two special cases to consider. (1) the scsi command | ||
273 | * requested scatter-gather usage or (2) the scsi command allocated | ||
274 | * a request buffer, but did not request use_sg. There is a third | ||
275 | * case, but it does not require resource deallocation. | ||
276 | */ | ||
277 | if ((psb->seg_cnt > 0) && (psb->pCmd->use_sg)) { | ||
278 | dma_unmap_sg(&phba->pcidev->dev, psb->pCmd->request_buffer, | ||
279 | psb->seg_cnt, psb->pCmd->sc_data_direction); | ||
280 | } else { | ||
281 | if ((psb->nonsg_phys) && (psb->pCmd->request_bufflen)) { | ||
282 | dma_unmap_single(&phba->pcidev->dev, psb->nonsg_phys, | ||
283 | psb->pCmd->request_bufflen, | ||
284 | psb->pCmd->sc_data_direction); | ||
285 | } | ||
286 | } | ||
287 | } | ||
288 | |||
289 | static void | ||
285 | lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd) | 290 | lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd) |
286 | { | 291 | { |
287 | struct scsi_cmnd *cmnd = lpfc_cmd->pCmd; | 292 | struct scsi_cmnd *cmnd = lpfc_cmd->pCmd; |
@@ -454,6 +459,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
454 | cmd->scsi_done(cmd); | 459 | cmd->scsi_done(cmd); |
455 | 460 | ||
456 | if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { | 461 | if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { |
462 | lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd); | ||
457 | lpfc_release_scsi_buf(phba, lpfc_cmd); | 463 | lpfc_release_scsi_buf(phba, lpfc_cmd); |
458 | return; | 464 | return; |
459 | } | 465 | } |
@@ -511,6 +517,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
511 | } | 517 | } |
512 | } | 518 | } |
513 | 519 | ||
520 | lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd); | ||
514 | lpfc_release_scsi_buf(phba, lpfc_cmd); | 521 | lpfc_release_scsi_buf(phba, lpfc_cmd); |
515 | } | 522 | } |
516 | 523 | ||
@@ -822,6 +829,7 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) | |||
822 | return 0; | 829 | return 0; |
823 | 830 | ||
824 | out_host_busy_free_buf: | 831 | out_host_busy_free_buf: |
832 | lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd); | ||
825 | lpfc_release_scsi_buf(phba, lpfc_cmd); | 833 | lpfc_release_scsi_buf(phba, lpfc_cmd); |
826 | out_host_busy: | 834 | out_host_busy: |
827 | return SCSI_MLQUEUE_HOST_BUSY; | 835 | return SCSI_MLQUEUE_HOST_BUSY; |