diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_scsi.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_scsi.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 51e6a6394951..5f697ace9706 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c | |||
@@ -66,6 +66,8 @@ lpfc_update_stats(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) | |||
66 | if (cmd->result) | 66 | if (cmd->result) |
67 | return; | 67 | return; |
68 | 68 | ||
69 | latency = jiffies_to_msecs((long)jiffies - (long)lpfc_cmd->start_time); | ||
70 | |||
69 | spin_lock_irqsave(shost->host_lock, flags); | 71 | spin_lock_irqsave(shost->host_lock, flags); |
70 | if (!vport->stat_data_enabled || | 72 | if (!vport->stat_data_enabled || |
71 | vport->stat_data_blocked || | 73 | vport->stat_data_blocked || |
@@ -74,13 +76,15 @@ lpfc_update_stats(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) | |||
74 | spin_unlock_irqrestore(shost->host_lock, flags); | 76 | spin_unlock_irqrestore(shost->host_lock, flags); |
75 | return; | 77 | return; |
76 | } | 78 | } |
77 | latency = jiffies_to_msecs(jiffies - lpfc_cmd->start_time); | ||
78 | 79 | ||
79 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) { | 80 | if (phba->bucket_type == LPFC_LINEAR_BUCKET) { |
80 | i = (latency + phba->bucket_step - 1 - phba->bucket_base)/ | 81 | i = (latency + phba->bucket_step - 1 - phba->bucket_base)/ |
81 | phba->bucket_step; | 82 | phba->bucket_step; |
82 | if (i >= LPFC_MAX_BUCKET_COUNT) | 83 | /* check array subscript bounds */ |
83 | i = LPFC_MAX_BUCKET_COUNT; | 84 | if (i < 0) |
85 | i = 0; | ||
86 | else if (i >= LPFC_MAX_BUCKET_COUNT) | ||
87 | i = LPFC_MAX_BUCKET_COUNT - 1; | ||
84 | } else { | 88 | } else { |
85 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT-1; i++) | 89 | for (i = 0; i < LPFC_MAX_BUCKET_COUNT-1; i++) |
86 | if (latency <= (phba->bucket_base + | 90 | if (latency <= (phba->bucket_base + |
@@ -444,14 +448,14 @@ lpfc_new_scsi_buf(struct lpfc_vport *vport) | |||
444 | bpl[0].addrLow = le32_to_cpu(putPaddrLow(pdma_phys_fcp_cmd)); | 448 | bpl[0].addrLow = le32_to_cpu(putPaddrLow(pdma_phys_fcp_cmd)); |
445 | bpl[0].tus.f.bdeSize = sizeof(struct fcp_cmnd); | 449 | bpl[0].tus.f.bdeSize = sizeof(struct fcp_cmnd); |
446 | bpl[0].tus.f.bdeFlags = BUFF_TYPE_BDE_64; | 450 | bpl[0].tus.f.bdeFlags = BUFF_TYPE_BDE_64; |
447 | bpl[0].tus.w = le32_to_cpu(bpl->tus.w); | 451 | bpl[0].tus.w = le32_to_cpu(bpl[0].tus.w); |
448 | 452 | ||
449 | /* Setup the physical region for the FCP RSP */ | 453 | /* Setup the physical region for the FCP RSP */ |
450 | bpl[1].addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys_fcp_rsp)); | 454 | bpl[1].addrHigh = le32_to_cpu(putPaddrHigh(pdma_phys_fcp_rsp)); |
451 | bpl[1].addrLow = le32_to_cpu(putPaddrLow(pdma_phys_fcp_rsp)); | 455 | bpl[1].addrLow = le32_to_cpu(putPaddrLow(pdma_phys_fcp_rsp)); |
452 | bpl[1].tus.f.bdeSize = sizeof(struct fcp_rsp); | 456 | bpl[1].tus.f.bdeSize = sizeof(struct fcp_rsp); |
453 | bpl[1].tus.f.bdeFlags = BUFF_TYPE_BDE_64; | 457 | bpl[1].tus.f.bdeFlags = BUFF_TYPE_BDE_64; |
454 | bpl[1].tus.w = le32_to_cpu(bpl->tus.w); | 458 | bpl[1].tus.w = le32_to_cpu(bpl[1].tus.w); |
455 | 459 | ||
456 | /* | 460 | /* |
457 | * Since the IOCB for the FCP I/O is built into this lpfc_scsi_buf, | 461 | * Since the IOCB for the FCP I/O is built into this lpfc_scsi_buf, |