diff options
author | James Smart <James.Smart@Emulex.Com> | 2008-08-24 21:50:00 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-10-13 09:28:53 -0400 |
commit | d7c255b26d8e3f12164d82093de3bf22efad2b4a (patch) | |
tree | 0b3467eda322ec2d90e5a7369891ab4ba12ff0a1 /drivers/scsi/lpfc/lpfc_sli.c | |
parent | 34b02dcdcf1865405f4762b991965c0c3b8a3ae0 (diff) |
[SCSI] lpfc 8.2.8 : Miscellaneous Bug Fixes
Miscellaneous Fixes:
- Fix the wrong variable name used for checking node active usage status
- Fix numerous duplicate log message numbers
- Fix change KERN_WARNING messages to KERN_INFO.
- Stop sending erroneous LOGO to fabric after vport is already terminated
- Fix HBQ allocates that were kalloc'ing w/ GFP_KERNEL while holding a lock.
- Fix gcc 4.3.2 compiler warnings and a sparse warning
- Fix bugs in handling unsolicited ct event queue
- Reorder some of the initial link up checks, to remove odd VPI states.
- Correct poor VPI handling
- Add debug messages
- Expand Update_CFG mailbox definition
- Fix handling of VPD data offsets
- Reorder loopback flags
- convert to use offsetof()
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_sli.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_sli.c | 105 |
1 files changed, 62 insertions, 43 deletions
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 77afa2ba6a2b..c7a520fa1aaa 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c | |||
@@ -844,48 +844,58 @@ struct lpfc_hbq_init *lpfc_hbq_defs[] = { | |||
844 | * @hbqno: HBQ number. | 844 | * @hbqno: HBQ number. |
845 | * @count: Number of HBQ buffers to be posted. | 845 | * @count: Number of HBQ buffers to be posted. |
846 | * | 846 | * |
847 | * This function is called with no lock held to post more | 847 | * This function is called with no lock held to post more hbq buffers to the |
848 | * hbq buffers to the given HBQ. The function returns 0 | 848 | * given HBQ. The function returns the number of HBQ buffers successfully |
849 | * when successful and returns 1 other wise. | 849 | * posted. |
850 | **/ | 850 | **/ |
851 | static int | 851 | static int |
852 | lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count) | 852 | lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count) |
853 | { | 853 | { |
854 | uint32_t i, start, end; | 854 | uint32_t i, posted = 0; |
855 | unsigned long flags; | 855 | unsigned long flags; |
856 | struct hbq_dmabuf *hbq_buffer; | 856 | struct hbq_dmabuf *hbq_buffer; |
857 | 857 | LIST_HEAD(hbq_buf_list); | |
858 | if (!phba->hbqs[hbqno].hbq_alloc_buffer) | 858 | if (!phba->hbqs[hbqno].hbq_alloc_buffer) |
859 | return 0; | 859 | return 0; |
860 | 860 | ||
861 | start = phba->hbqs[hbqno].buffer_count; | 861 | if ((phba->hbqs[hbqno].buffer_count + count) > |
862 | end = count + start; | 862 | lpfc_hbq_defs[hbqno]->entry_count) |
863 | if (end > lpfc_hbq_defs[hbqno]->entry_count) | 863 | count = lpfc_hbq_defs[hbqno]->entry_count - |
864 | end = lpfc_hbq_defs[hbqno]->entry_count; | 864 | phba->hbqs[hbqno].buffer_count; |
865 | 865 | if (!count) | |
866 | return 0; | ||
867 | /* Allocate HBQ entries */ | ||
868 | for (i = 0; i < count; i++) { | ||
869 | hbq_buffer = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); | ||
870 | if (!hbq_buffer) | ||
871 | break; | ||
872 | list_add_tail(&hbq_buffer->dbuf.list, &hbq_buf_list); | ||
873 | } | ||
866 | /* Check whether HBQ is still in use */ | 874 | /* Check whether HBQ is still in use */ |
867 | spin_lock_irqsave(&phba->hbalock, flags); | 875 | spin_lock_irqsave(&phba->hbalock, flags); |
868 | if (!phba->hbq_in_use) | 876 | if (!phba->hbq_in_use) |
869 | goto out; | 877 | goto err; |
870 | 878 | while (!list_empty(&hbq_buf_list)) { | |
871 | /* Populate HBQ entries */ | 879 | list_remove_head(&hbq_buf_list, hbq_buffer, struct hbq_dmabuf, |
872 | for (i = start; i < end; i++) { | 880 | dbuf.list); |
873 | hbq_buffer = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); | 881 | hbq_buffer->tag = (phba->hbqs[hbqno].buffer_count | |
874 | if (!hbq_buffer) | 882 | (hbqno << 16)); |
875 | goto err; | 883 | if (lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buffer)) { |
876 | hbq_buffer->tag = (i | (hbqno << 16)); | ||
877 | if (lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buffer)) | ||
878 | phba->hbqs[hbqno].buffer_count++; | 884 | phba->hbqs[hbqno].buffer_count++; |
879 | else | 885 | posted++; |
886 | } else | ||
880 | (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); | 887 | (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); |
881 | } | 888 | } |
882 | |||
883 | out: | ||
884 | spin_unlock_irqrestore(&phba->hbalock, flags); | 889 | spin_unlock_irqrestore(&phba->hbalock, flags); |
885 | return 0; | 890 | return posted; |
886 | err: | 891 | err: |
887 | spin_unlock_irqrestore(&phba->hbalock, flags); | 892 | spin_unlock_irqrestore(&phba->hbalock, flags); |
888 | return 1; | 893 | while (!list_empty(&hbq_buf_list)) { |
894 | list_remove_head(&hbq_buf_list, hbq_buffer, struct hbq_dmabuf, | ||
895 | dbuf.list); | ||
896 | (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); | ||
897 | } | ||
898 | return 0; | ||
889 | } | 899 | } |
890 | 900 | ||
891 | /** | 901 | /** |
@@ -894,8 +904,8 @@ lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count) | |||
894 | * @qno: HBQ number. | 904 | * @qno: HBQ number. |
895 | * | 905 | * |
896 | * This function posts more buffers to the HBQ. This function | 906 | * This function posts more buffers to the HBQ. This function |
897 | * is called with no lock held. The function returns 0 when | 907 | * is called with no lock held. The function returns the number of HBQ entries |
898 | * successful and returns 1 otherwise. | 908 | * successfully allocated. |
899 | **/ | 909 | **/ |
900 | int | 910 | int |
901 | lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *phba, uint32_t qno) | 911 | lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *phba, uint32_t qno) |
@@ -911,7 +921,7 @@ lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *phba, uint32_t qno) | |||
911 | * | 921 | * |
912 | * This function is called from SLI initialization code path with | 922 | * This function is called from SLI initialization code path with |
913 | * no lock held to post initial HBQ buffers to firmware. The | 923 | * no lock held to post initial HBQ buffers to firmware. The |
914 | * function returns 0 when successful and returns 1 otherwise. | 924 | * function returns the number of HBQ entries successfully allocated. |
915 | **/ | 925 | **/ |
916 | static int | 926 | static int |
917 | lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *phba, uint32_t qno) | 927 | lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *phba, uint32_t qno) |
@@ -1253,7 +1263,9 @@ lpfc_sli_handle_mb_event(struct lpfc_hba *phba) | |||
1253 | * This function is called from unsolicited event handler code path to get the | 1263 | * This function is called from unsolicited event handler code path to get the |
1254 | * HBQ buffer associated with an unsolicited iocb. This function is called with | 1264 | * HBQ buffer associated with an unsolicited iocb. This function is called with |
1255 | * no lock held. It returns the buffer associated with the given tag and posts | 1265 | * no lock held. It returns the buffer associated with the given tag and posts |
1256 | * another buffer to the firmware. | 1266 | * another buffer to the firmware. Note that the new buffer must be allocated |
1267 | * before taking the hbalock and that the hba lock must be held until it is | ||
1268 | * finished with the hbq entry swap. | ||
1257 | **/ | 1269 | **/ |
1258 | static struct lpfc_dmabuf * | 1270 | static struct lpfc_dmabuf * |
1259 | lpfc_sli_replace_hbqbuff(struct lpfc_hba *phba, uint32_t tag) | 1271 | lpfc_sli_replace_hbqbuff(struct lpfc_hba *phba, uint32_t tag) |
@@ -1264,22 +1276,28 @@ lpfc_sli_replace_hbqbuff(struct lpfc_hba *phba, uint32_t tag) | |||
1264 | dma_addr_t phys; /* mapped address */ | 1276 | dma_addr_t phys; /* mapped address */ |
1265 | unsigned long flags; | 1277 | unsigned long flags; |
1266 | 1278 | ||
1279 | hbqno = tag >> 16; | ||
1280 | new_hbq_entry = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); | ||
1267 | /* Check whether HBQ is still in use */ | 1281 | /* Check whether HBQ is still in use */ |
1268 | spin_lock_irqsave(&phba->hbalock, flags); | 1282 | spin_lock_irqsave(&phba->hbalock, flags); |
1269 | if (!phba->hbq_in_use) { | 1283 | if (!phba->hbq_in_use) { |
1284 | if (new_hbq_entry) | ||
1285 | (phba->hbqs[hbqno].hbq_free_buffer)(phba, | ||
1286 | new_hbq_entry); | ||
1270 | spin_unlock_irqrestore(&phba->hbalock, flags); | 1287 | spin_unlock_irqrestore(&phba->hbalock, flags); |
1271 | return NULL; | 1288 | return NULL; |
1272 | } | 1289 | } |
1273 | 1290 | ||
1274 | hbq_entry = lpfc_sli_hbqbuf_find(phba, tag); | 1291 | hbq_entry = lpfc_sli_hbqbuf_find(phba, tag); |
1275 | if (hbq_entry == NULL) { | 1292 | if (hbq_entry == NULL) { |
1293 | if (new_hbq_entry) | ||
1294 | (phba->hbqs[hbqno].hbq_free_buffer)(phba, | ||
1295 | new_hbq_entry); | ||
1276 | spin_unlock_irqrestore(&phba->hbalock, flags); | 1296 | spin_unlock_irqrestore(&phba->hbalock, flags); |
1277 | return NULL; | 1297 | return NULL; |
1278 | } | 1298 | } |
1279 | list_del(&hbq_entry->dbuf.list); | 1299 | list_del(&hbq_entry->dbuf.list); |
1280 | 1300 | ||
1281 | hbqno = tag >> 16; | ||
1282 | new_hbq_entry = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); | ||
1283 | if (new_hbq_entry == NULL) { | 1301 | if (new_hbq_entry == NULL) { |
1284 | list_add_tail(&hbq_entry->dbuf.list, &phba->hbqbuf_in_list); | 1302 | list_add_tail(&hbq_entry->dbuf.list, &phba->hbqbuf_in_list); |
1285 | spin_unlock_irqrestore(&phba->hbalock, flags); | 1303 | spin_unlock_irqrestore(&phba->hbalock, flags); |
@@ -1748,8 +1766,8 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba *phba) | |||
1748 | irsp->un.ulpWord[3], | 1766 | irsp->un.ulpWord[3], |
1749 | irsp->un.ulpWord[4], | 1767 | irsp->un.ulpWord[4], |
1750 | irsp->un.ulpWord[5], | 1768 | irsp->un.ulpWord[5], |
1751 | *(((uint32_t *) irsp) + 6), | 1769 | *(uint32_t *)&irsp->un1, |
1752 | *(((uint32_t *) irsp) + 7)); | 1770 | *((uint32_t *)&irsp->un1 + 1)); |
1753 | } | 1771 | } |
1754 | 1772 | ||
1755 | switch (type) { | 1773 | switch (type) { |
@@ -1935,8 +1953,8 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba *phba, | |||
1935 | irsp->un.ulpWord[3], | 1953 | irsp->un.ulpWord[3], |
1936 | irsp->un.ulpWord[4], | 1954 | irsp->un.ulpWord[4], |
1937 | irsp->un.ulpWord[5], | 1955 | irsp->un.ulpWord[5], |
1938 | *(((uint32_t *) irsp) + 6), | 1956 | *(uint32_t *)&irsp->un1, |
1939 | *(((uint32_t *) irsp) + 7)); | 1957 | *((uint32_t *)&irsp->un1 + 1)); |
1940 | } | 1958 | } |
1941 | 1959 | ||
1942 | switch (type) { | 1960 | switch (type) { |
@@ -2921,10 +2939,8 @@ lpfc_sli_hbq_setup(struct lpfc_hba *phba) | |||
2921 | mempool_free(pmb, phba->mbox_mem_pool); | 2939 | mempool_free(pmb, phba->mbox_mem_pool); |
2922 | 2940 | ||
2923 | /* Initially populate or replenish the HBQs */ | 2941 | /* Initially populate or replenish the HBQs */ |
2924 | for (hbqno = 0; hbqno < hbq_count; ++hbqno) { | 2942 | for (hbqno = 0; hbqno < hbq_count; ++hbqno) |
2925 | if (lpfc_sli_hbqbuf_init_hbqs(phba, hbqno)) | 2943 | lpfc_sli_hbqbuf_init_hbqs(phba, hbqno); |
2926 | return -ENOMEM; | ||
2927 | } | ||
2928 | return 0; | 2944 | return 0; |
2929 | } | 2945 | } |
2930 | 2946 | ||
@@ -3034,6 +3050,7 @@ lpfc_do_config_port(struct lpfc_hba *phba, int sli_mode) | |||
3034 | phba->port_gp = phba->mbox->us.s2.port; | 3050 | phba->port_gp = phba->mbox->us.s2.port; |
3035 | phba->inb_ha_copy = NULL; | 3051 | phba->inb_ha_copy = NULL; |
3036 | phba->inb_counter = NULL; | 3052 | phba->inb_counter = NULL; |
3053 | phba->max_vpi = 0; | ||
3037 | } | 3054 | } |
3038 | do_prep_failed: | 3055 | do_prep_failed: |
3039 | mempool_free(pmb, phba->mbox_mem_pool); | 3056 | mempool_free(pmb, phba->mbox_mem_pool); |
@@ -4335,7 +4352,7 @@ lpfc_sli_ring_taggedbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
4335 | 4352 | ||
4336 | spin_unlock_irq(&phba->hbalock); | 4353 | spin_unlock_irq(&phba->hbalock); |
4337 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 4354 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
4338 | "0410 Cannot find virtual addr for buffer tag on " | 4355 | "0402 Cannot find virtual addr for buffer tag on " |
4339 | "ring %d Data x%lx x%p x%p x%x\n", | 4356 | "ring %d Data x%lx x%p x%p x%x\n", |
4340 | pring->ringno, (unsigned long) tag, | 4357 | pring->ringno, (unsigned long) tag, |
4341 | slp->next, slp->prev, pring->postbufq_cnt); | 4358 | slp->next, slp->prev, pring->postbufq_cnt); |
@@ -4482,7 +4499,7 @@ lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
4482 | 4499 | ||
4483 | /* ELS cmd tag <ulpIoTag> completes */ | 4500 | /* ELS cmd tag <ulpIoTag> completes */ |
4484 | lpfc_printf_log(phba, KERN_INFO, LOG_ELS, | 4501 | lpfc_printf_log(phba, KERN_INFO, LOG_ELS, |
4485 | "0133 Ignoring ELS cmd tag x%x completion Data: " | 4502 | "0139 Ignoring ELS cmd tag x%x completion Data: " |
4486 | "x%x x%x x%x\n", | 4503 | "x%x x%x x%x\n", |
4487 | irsp->ulpIoTag, irsp->ulpStatus, | 4504 | irsp->ulpIoTag, irsp->ulpStatus, |
4488 | irsp->un.ulpWord[4], irsp->ulpTimeout); | 4505 | irsp->un.ulpWord[4], irsp->ulpTimeout); |
@@ -4568,6 +4585,8 @@ lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
4568 | iabt->un.acxri.abortIoTag, abtsiocbp->iotag); | 4585 | iabt->un.acxri.abortIoTag, abtsiocbp->iotag); |
4569 | retval = __lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0); | 4586 | retval = __lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0); |
4570 | 4587 | ||
4588 | if (retval) | ||
4589 | __lpfc_sli_release_iocbq(phba, abtsiocbp); | ||
4571 | abort_iotag_exit: | 4590 | abort_iotag_exit: |
4572 | /* | 4591 | /* |
4573 | * Caller to this routine should check for IOCB_ERROR | 4592 | * Caller to this routine should check for IOCB_ERROR |
@@ -4899,7 +4918,7 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba, | |||
4899 | } | 4918 | } |
4900 | } else { | 4919 | } else { |
4901 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, | 4920 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, |
4902 | ":0332 IOCB wait issue failed, Data x%x\n", | 4921 | "0332 IOCB wait issue failed, Data x%x\n", |
4903 | retval); | 4922 | retval); |
4904 | retval = IOCB_ERROR; | 4923 | retval = IOCB_ERROR; |
4905 | } | 4924 | } |
@@ -5271,7 +5290,7 @@ lpfc_intr_handler(int irq, void *dev_id) | |||
5271 | lpfc_printf_log(phba, | 5290 | lpfc_printf_log(phba, |
5272 | KERN_ERR, | 5291 | KERN_ERR, |
5273 | LOG_MBOX | LOG_SLI, | 5292 | LOG_MBOX | LOG_SLI, |
5274 | "0306 rc should have" | 5293 | "0350 rc should have" |
5275 | "been MBX_BUSY"); | 5294 | "been MBX_BUSY"); |
5276 | goto send_current_mbox; | 5295 | goto send_current_mbox; |
5277 | } | 5296 | } |