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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
"This is quite a big update because it includes a rework of the lpfc
driver to separate the NVMe part from the FC part.

The reason for doing this is because two separate trees (the nvme and
scsi trees respectively) want to update the individual components and
this separation will prevent a really nasty cross tree entanglement by
the time we reach the next merge window.

The rest of the fixes are the usual minor sort with no significant
security implications"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (25 commits)
scsi: zero per-cmd private driver data for each MQ I/O
scsi: csiostor: fix use after free in csio_hw_use_fwconfig()
scsi: ufs: Clean up some rpm/spm level SysFS nodes upon remove
scsi: lpfc: fix build issue if NVME_FC_TARGET is not defined
scsi: lpfc: Fix NULL pointer dereference during PCI error recovery
scsi: lpfc: update version to 11.2.0.14
scsi: lpfc: Add MDS Diagnostic support.
scsi: lpfc: Fix NVMEI's handling of NVMET's PRLI response attributes
scsi: lpfc: Cleanup entry_repost settings on SLI4 queues
scsi: lpfc: Fix debugfs root inode "lpfc" not getting deleted on driver unload.
scsi: lpfc: Fix NVME I+T not registering NVME as a supported FC4 type
scsi: lpfc: Added recovery logic for running out of NVMET IO context resources
scsi: lpfc: Separate NVMET RQ buffer posting from IO resources SGL/iocbq/context
scsi: lpfc: Separate NVMET data buffer pool fir ELS/CT.
scsi: lpfc: Fix NMI watchdog assertions when running nvmet IOPS tests
scsi: lpfc: Fix NVMEI driver not decrementing counter causing bad rport state.
scsi: lpfc: Fix nvmet RQ resource needs for large block writes.
scsi: lpfc: Adding additional stats counters for nvme.
scsi: lpfc: Fix system crash when port is reset.
scsi: lpfc: Fix used-RPI accounting problem.
...

+903 -435
+4 -1
drivers/scsi/csiostor/csio_hw.c
··· 1769 1769 goto bye; 1770 1770 } 1771 1771 1772 - mempool_free(mbp, hw->mb_mempool); 1773 1772 if (finicsum != cfcsum) { 1774 1773 csio_warn(hw, 1775 1774 "Config File checksum mismatch: csum=%#x, computed=%#x\n", ··· 1779 1780 rv = csio_hw_validate_caps(hw, mbp); 1780 1781 if (rv != 0) 1781 1782 goto bye; 1783 + 1784 + mempool_free(mbp, hw->mb_mempool); 1785 + mbp = NULL; 1786 + 1782 1787 /* 1783 1788 * Note that we're operating with parameters 1784 1789 * not supplied by the driver, rather than from hard-wired
+1 -1
drivers/scsi/libfc/fc_rport.c
··· 1422 1422 fp = fc_frame_alloc(lport, sizeof(*rtv)); 1423 1423 if (!fp) { 1424 1424 rjt_data.reason = ELS_RJT_UNAB; 1425 - rjt_data.reason = ELS_EXPL_INSUF_RES; 1425 + rjt_data.explan = ELS_EXPL_INSUF_RES; 1426 1426 fc_seq_els_rsp_send(in_fp, ELS_LS_RJT, &rjt_data); 1427 1427 goto drop; 1428 1428 }
+17 -6
drivers/scsi/lpfc/lpfc.h
··· 141 141 uint32_t buffer_tag; /* used for tagged queue ring */ 142 142 }; 143 143 144 + struct lpfc_nvmet_ctxbuf { 145 + struct list_head list; 146 + struct lpfc_nvmet_rcv_ctx *context; 147 + struct lpfc_iocbq *iocbq; 148 + struct lpfc_sglq *sglq; 149 + }; 150 + 144 151 struct lpfc_dma_pool { 145 152 struct lpfc_dmabuf *elements; 146 153 uint32_t max_count; ··· 170 163 struct lpfc_dmabuf dbuf; 171 164 uint16_t total_size; 172 165 uint16_t bytes_recv; 173 - void *context; 174 - struct lpfc_iocbq *iocbq; 175 - struct lpfc_sglq *sglq; 166 + uint16_t idx; 176 167 struct lpfc_queue *hrq; /* ptr to associated Header RQ */ 177 168 struct lpfc_queue *drq; /* ptr to associated Data RQ */ 178 169 }; ··· 675 670 /* INIT_LINK mailbox command */ 676 671 #define LS_NPIV_FAB_SUPPORTED 0x2 /* Fabric supports NPIV */ 677 672 #define LS_IGNORE_ERATT 0x4 /* intr handler should ignore ERATT */ 673 + #define LS_MDS_LINK_DOWN 0x8 /* MDS Diagnostics Link Down */ 674 + #define LS_MDS_LOOPBACK 0x16 /* MDS Diagnostics Link Up (Loopback) */ 678 675 679 676 uint32_t hba_flag; /* hba generic flags */ 680 677 #define HBA_ERATT_HANDLED 0x1 /* This flag is set when eratt handled */ ··· 784 777 uint32_t cfg_nvme_oas; 785 778 uint32_t cfg_nvme_io_channel; 786 779 uint32_t cfg_nvmet_mrq; 787 - uint32_t cfg_nvmet_mrq_post; 788 780 uint32_t cfg_enable_nvmet; 789 781 uint32_t cfg_nvme_enable_fb; 790 782 uint32_t cfg_nvmet_fb_size; ··· 949 943 struct pci_pool *lpfc_mbuf_pool; 950 944 struct pci_pool *lpfc_hrb_pool; /* header receive buffer pool */ 951 945 struct pci_pool *lpfc_drb_pool; /* data receive buffer pool */ 946 + struct pci_pool *lpfc_nvmet_drb_pool; /* data receive buffer pool */ 952 947 struct pci_pool *lpfc_hbq_pool; /* SLI3 hbq buffer pool */ 953 948 struct pci_pool *txrdy_payload_pool; 954 949 struct lpfc_dma_pool lpfc_mbuf_safety_pool; ··· 1235 1228 static inline struct lpfc_sli_ring * 1236 1229 lpfc_phba_elsring(struct lpfc_hba *phba) 1237 1230 { 1238 - if (phba->sli_rev == LPFC_SLI_REV4) 1239 - return phba->sli4_hba.els_wq->pring; 1231 + if (phba->sli_rev == LPFC_SLI_REV4) { 1232 + if (phba->sli4_hba.els_wq) 1233 + return phba->sli4_hba.els_wq->pring; 1234 + else 1235 + return NULL; 1236 + } 1240 1237 return &phba->sli.sli3_ring[LPFC_ELS_RING]; 1241 1238 }
+23 -24
drivers/scsi/lpfc/lpfc_attr.c
··· 60 60 #define LPFC_MIN_DEVLOSS_TMO 1 61 61 #define LPFC_MAX_DEVLOSS_TMO 255 62 62 63 - #define LPFC_DEF_MRQ_POST 256 64 - #define LPFC_MIN_MRQ_POST 32 65 - #define LPFC_MAX_MRQ_POST 512 63 + #define LPFC_DEF_MRQ_POST 512 64 + #define LPFC_MIN_MRQ_POST 512 65 + #define LPFC_MAX_MRQ_POST 2048 66 66 67 67 /* 68 68 * Write key size should be multiple of 4. If write key is changed ··· 205 205 atomic_read(&tgtp->xmt_ls_rsp_error)); 206 206 207 207 len += snprintf(buf+len, PAGE_SIZE-len, 208 - "FCP: Rcv %08x Drop %08x\n", 208 + "FCP: Rcv %08x Release %08x Drop %08x\n", 209 209 atomic_read(&tgtp->rcv_fcp_cmd_in), 210 + atomic_read(&tgtp->xmt_fcp_release), 210 211 atomic_read(&tgtp->rcv_fcp_cmd_drop)); 211 212 212 213 if (atomic_read(&tgtp->rcv_fcp_cmd_in) != ··· 219 218 } 220 219 221 220 len += snprintf(buf+len, PAGE_SIZE-len, 222 - "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x\n", 221 + "FCP Rsp: RD %08x rsp %08x WR %08x rsp %08x " 222 + "drop %08x\n", 223 223 atomic_read(&tgtp->xmt_fcp_read), 224 224 atomic_read(&tgtp->xmt_fcp_read_rsp), 225 225 atomic_read(&tgtp->xmt_fcp_write), 226 - atomic_read(&tgtp->xmt_fcp_rsp)); 227 - 228 - len += snprintf(buf+len, PAGE_SIZE-len, 229 - "FCP Rsp: abort %08x drop %08x\n", 230 - atomic_read(&tgtp->xmt_fcp_abort), 226 + atomic_read(&tgtp->xmt_fcp_rsp), 231 227 atomic_read(&tgtp->xmt_fcp_drop)); 232 228 233 229 len += snprintf(buf+len, PAGE_SIZE-len, ··· 234 236 atomic_read(&tgtp->xmt_fcp_rsp_drop)); 235 237 236 238 len += snprintf(buf+len, PAGE_SIZE-len, 237 - "ABORT: Xmt %08x Err %08x Cmpl %08x", 239 + "ABORT: Xmt %08x Cmpl %08x\n", 240 + atomic_read(&tgtp->xmt_fcp_abort), 241 + atomic_read(&tgtp->xmt_fcp_abort_cmpl)); 242 + 243 + len += snprintf(buf + len, PAGE_SIZE - len, 244 + "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x", 245 + atomic_read(&tgtp->xmt_abort_sol), 246 + atomic_read(&tgtp->xmt_abort_unsol), 238 247 atomic_read(&tgtp->xmt_abort_rsp), 239 - atomic_read(&tgtp->xmt_abort_rsp_error), 240 - atomic_read(&tgtp->xmt_abort_cmpl)); 248 + atomic_read(&tgtp->xmt_abort_rsp_error)); 249 + 250 + len += snprintf(buf + len, PAGE_SIZE - len, 251 + "IO_CTX: %08x outstanding %08x total %x", 252 + phba->sli4_hba.nvmet_ctx_cnt, 253 + phba->sli4_hba.nvmet_io_wait_cnt, 254 + phba->sli4_hba.nvmet_io_wait_total); 241 255 242 256 len += snprintf(buf+len, PAGE_SIZE-len, "\n"); 243 257 return len; ··· 3322 3312 "Specify number of RQ pairs for processing NVMET cmds"); 3323 3313 3324 3314 /* 3325 - * lpfc_nvmet_mrq_post: Specify number buffers to post on every MRQ 3326 - * 3327 - */ 3328 - LPFC_ATTR_R(nvmet_mrq_post, LPFC_DEF_MRQ_POST, 3329 - LPFC_MIN_MRQ_POST, LPFC_MAX_MRQ_POST, 3330 - "Specify number of buffers to post on every MRQ"); 3331 - 3332 - /* 3333 3315 * lpfc_enable_fc4_type: Defines what FC4 types are supported. 3334 3316 * Supported Values: 1 - register just FCP 3335 3317 * 3 - register both FCP and NVME ··· 5156 5154 &dev_attr_lpfc_suppress_rsp, 5157 5155 &dev_attr_lpfc_nvme_io_channel, 5158 5156 &dev_attr_lpfc_nvmet_mrq, 5159 - &dev_attr_lpfc_nvmet_mrq_post, 5160 5157 &dev_attr_lpfc_nvme_enable_fb, 5161 5158 &dev_attr_lpfc_nvmet_fb_size, 5162 5159 &dev_attr_lpfc_enable_bg, ··· 6195 6194 6196 6195 lpfc_enable_fc4_type_init(phba, lpfc_enable_fc4_type); 6197 6196 lpfc_nvmet_mrq_init(phba, lpfc_nvmet_mrq); 6198 - lpfc_nvmet_mrq_post_init(phba, lpfc_nvmet_mrq_post); 6199 6197 6200 6198 /* Initialize first burst. Target vs Initiator are different. */ 6201 6199 lpfc_nvme_enable_fb_init(phba, lpfc_nvme_enable_fb); ··· 6291 6291 /* Not NVME Target mode. Turn off Target parameters. */ 6292 6292 phba->nvmet_support = 0; 6293 6293 phba->cfg_nvmet_mrq = 0; 6294 - phba->cfg_nvmet_mrq_post = 0; 6295 6294 phba->cfg_nvmet_fb_size = 0; 6296 6295 } 6297 6296
+7 -4
drivers/scsi/lpfc/lpfc_crtn.h
··· 75 75 void lpfc_cancel_all_vport_retry_delay_timer(struct lpfc_hba *); 76 76 void lpfc_retry_pport_discovery(struct lpfc_hba *); 77 77 void lpfc_release_rpi(struct lpfc_hba *, struct lpfc_vport *, uint16_t); 78 + int lpfc_init_iocb_list(struct lpfc_hba *phba, int cnt); 79 + void lpfc_free_iocb_list(struct lpfc_hba *phba); 80 + int lpfc_post_rq_buffer(struct lpfc_hba *phba, struct lpfc_queue *hrq, 81 + struct lpfc_queue *drq, int count, int idx); 78 82 79 83 void lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *, LPFC_MBOXQ_t *); 80 84 void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); ··· 250 246 void lpfc_sli4_rb_free(struct lpfc_hba *, struct hbq_dmabuf *); 251 247 struct rqb_dmabuf *lpfc_sli4_nvmet_alloc(struct lpfc_hba *phba); 252 248 void lpfc_sli4_nvmet_free(struct lpfc_hba *phba, struct rqb_dmabuf *dmab); 253 - void lpfc_nvmet_rq_post(struct lpfc_hba *phba, struct lpfc_nvmet_rcv_ctx *ctxp, 254 - struct lpfc_dmabuf *mp); 249 + void lpfc_nvmet_ctxbuf_post(struct lpfc_hba *phba, 250 + struct lpfc_nvmet_ctxbuf *ctxp); 255 251 int lpfc_nvmet_rcv_unsol_abort(struct lpfc_vport *vport, 256 252 struct fc_frame_header *fc_hdr); 257 253 void lpfc_sli4_build_dflt_fcf_record(struct lpfc_hba *, struct fcf_record *, 258 254 uint16_t); 259 255 int lpfc_sli4_rq_put(struct lpfc_queue *hq, struct lpfc_queue *dq, 260 256 struct lpfc_rqe *hrqe, struct lpfc_rqe *drqe); 261 - int lpfc_post_rq_buffer(struct lpfc_hba *phba, struct lpfc_queue *hq, 262 - struct lpfc_queue *dq, int count); 263 257 int lpfc_free_rq_buffer(struct lpfc_hba *phba, struct lpfc_queue *hq); 264 258 void lpfc_unregister_fcf(struct lpfc_hba *); 265 259 void lpfc_unregister_fcf_rescan(struct lpfc_hba *); ··· 273 271 void lpfc_sli4_clear_fcf_rr_bmask(struct lpfc_hba *); 274 272 275 273 int lpfc_mem_alloc(struct lpfc_hba *, int align); 274 + int lpfc_nvmet_mem_alloc(struct lpfc_hba *phba); 276 275 int lpfc_mem_alloc_active_rrq_pool_s4(struct lpfc_hba *); 277 276 void lpfc_mem_free(struct lpfc_hba *); 278 277 void lpfc_mem_free_all(struct lpfc_hba *);
+1
drivers/scsi/lpfc/lpfc_ct.c
··· 2092 2092 2093 2093 ae->un.AttrTypes[3] = 0x02; /* Type 1 - ELS */ 2094 2094 ae->un.AttrTypes[2] = 0x01; /* Type 8 - FCP */ 2095 + ae->un.AttrTypes[6] = 0x01; /* Type 40 - NVME */ 2095 2096 ae->un.AttrTypes[7] = 0x01; /* Type 32 - CT */ 2096 2097 size = FOURBYTES + 32; 2097 2098 ad->AttrLen = cpu_to_be16(size);
+41 -28
drivers/scsi/lpfc/lpfc_debugfs.c
··· 798 798 atomic_read(&tgtp->xmt_fcp_rsp)); 799 799 800 800 len += snprintf(buf + len, size - len, 801 - "FCP Rsp: abort %08x drop %08x\n", 802 - atomic_read(&tgtp->xmt_fcp_abort), 803 - atomic_read(&tgtp->xmt_fcp_drop)); 804 - 805 - len += snprintf(buf + len, size - len, 806 801 "FCP Rsp Cmpl: %08x err %08x drop %08x\n", 807 802 atomic_read(&tgtp->xmt_fcp_rsp_cmpl), 808 803 atomic_read(&tgtp->xmt_fcp_rsp_error), 809 804 atomic_read(&tgtp->xmt_fcp_rsp_drop)); 810 805 811 806 len += snprintf(buf + len, size - len, 812 - "ABORT: Xmt %08x Err %08x Cmpl %08x", 807 + "ABORT: Xmt %08x Cmpl %08x\n", 808 + atomic_read(&tgtp->xmt_fcp_abort), 809 + atomic_read(&tgtp->xmt_fcp_abort_cmpl)); 810 + 811 + len += snprintf(buf + len, size - len, 812 + "ABORT: Sol %08x Usol %08x Err %08x Cmpl %08x", 813 + atomic_read(&tgtp->xmt_abort_sol), 814 + atomic_read(&tgtp->xmt_abort_unsol), 813 815 atomic_read(&tgtp->xmt_abort_rsp), 814 - atomic_read(&tgtp->xmt_abort_rsp_error), 815 - atomic_read(&tgtp->xmt_abort_cmpl)); 816 + atomic_read(&tgtp->xmt_abort_rsp_error)); 816 817 817 818 len += snprintf(buf + len, size - len, "\n"); 818 819 ··· 842 841 } 843 842 spin_unlock(&phba->sli4_hba.abts_nvme_buf_list_lock); 844 843 } 844 + 845 + len += snprintf(buf + len, size - len, 846 + "IO_CTX: %08x outstanding %08x total %08x\n", 847 + phba->sli4_hba.nvmet_ctx_cnt, 848 + phba->sli4_hba.nvmet_io_wait_cnt, 849 + phba->sli4_hba.nvmet_io_wait_total); 845 850 } else { 846 851 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) 847 852 return len; ··· 1966 1959 atomic_set(&tgtp->rcv_ls_req_out, 0); 1967 1960 atomic_set(&tgtp->rcv_ls_req_drop, 0); 1968 1961 atomic_set(&tgtp->xmt_ls_abort, 0); 1962 + atomic_set(&tgtp->xmt_ls_abort_cmpl, 0); 1969 1963 atomic_set(&tgtp->xmt_ls_rsp, 0); 1970 1964 atomic_set(&tgtp->xmt_ls_drop, 0); 1971 1965 atomic_set(&tgtp->xmt_ls_rsp_error, 0); ··· 1975 1967 atomic_set(&tgtp->rcv_fcp_cmd_in, 0); 1976 1968 atomic_set(&tgtp->rcv_fcp_cmd_out, 0); 1977 1969 atomic_set(&tgtp->rcv_fcp_cmd_drop, 0); 1978 - atomic_set(&tgtp->xmt_fcp_abort, 0); 1979 1970 atomic_set(&tgtp->xmt_fcp_drop, 0); 1980 1971 atomic_set(&tgtp->xmt_fcp_read_rsp, 0); 1981 1972 atomic_set(&tgtp->xmt_fcp_read, 0); 1982 1973 atomic_set(&tgtp->xmt_fcp_write, 0); 1983 1974 atomic_set(&tgtp->xmt_fcp_rsp, 0); 1975 + atomic_set(&tgtp->xmt_fcp_release, 0); 1984 1976 atomic_set(&tgtp->xmt_fcp_rsp_cmpl, 0); 1985 1977 atomic_set(&tgtp->xmt_fcp_rsp_error, 0); 1986 1978 atomic_set(&tgtp->xmt_fcp_rsp_drop, 0); 1987 1979 1980 + atomic_set(&tgtp->xmt_fcp_abort, 0); 1981 + atomic_set(&tgtp->xmt_fcp_abort_cmpl, 0); 1982 + atomic_set(&tgtp->xmt_abort_sol, 0); 1983 + atomic_set(&tgtp->xmt_abort_unsol, 0); 1988 1984 atomic_set(&tgtp->xmt_abort_rsp, 0); 1989 1985 atomic_set(&tgtp->xmt_abort_rsp_error, 0); 1990 - atomic_set(&tgtp->xmt_abort_cmpl, 0); 1991 1986 } 1992 1987 return nbytes; 1993 1988 } ··· 3081 3070 qp->assoc_qid, qp->q_cnt_1, 3082 3071 (unsigned long long)qp->q_cnt_4); 3083 3072 len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, 3084 - "\t\tWQID[%02d], QE-CNT[%04d], QE-SIZE[%04d], " 3085 - "HOST-IDX[%04d], PORT-IDX[%04d]", 3073 + "\t\tWQID[%02d], QE-CNT[%04d], QE-SZ[%04d], " 3074 + "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]", 3086 3075 qp->queue_id, qp->entry_count, 3087 3076 qp->entry_size, qp->host_index, 3088 - qp->hba_index); 3077 + qp->hba_index, qp->entry_repost); 3089 3078 len += snprintf(pbuffer + len, 3090 3079 LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n"); 3091 3080 return len; ··· 3132 3121 qp->assoc_qid, qp->q_cnt_1, qp->q_cnt_2, 3133 3122 qp->q_cnt_3, (unsigned long long)qp->q_cnt_4); 3134 3123 len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, 3135 - "\tCQID[%02d], QE-CNT[%04d], QE-SIZE[%04d], " 3136 - "HOST-IDX[%04d], PORT-IDX[%04d]", 3124 + "\tCQID[%02d], QE-CNT[%04d], QE-SZ[%04d], " 3125 + "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]", 3137 3126 qp->queue_id, qp->entry_count, 3138 3127 qp->entry_size, qp->host_index, 3139 - qp->hba_index); 3128 + qp->hba_index, qp->entry_repost); 3140 3129 3141 3130 len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n"); 3142 3131 ··· 3154 3143 "\t\t%s RQ info: ", rqtype); 3155 3144 len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, 3156 3145 "AssocCQID[%02d]: RQ-STAT[nopost:x%x nobuf:x%x " 3157 - "trunc:x%x rcv:x%llx]\n", 3146 + "posted:x%x rcv:x%llx]\n", 3158 3147 qp->assoc_qid, qp->q_cnt_1, qp->q_cnt_2, 3159 3148 qp->q_cnt_3, (unsigned long long)qp->q_cnt_4); 3160 3149 len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, 3161 - "\t\tHQID[%02d], QE-CNT[%04d], QE-SIZE[%04d], " 3162 - "HOST-IDX[%04d], PORT-IDX[%04d]\n", 3150 + "\t\tHQID[%02d], QE-CNT[%04d], QE-SZ[%04d], " 3151 + "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]\n", 3163 3152 qp->queue_id, qp->entry_count, qp->entry_size, 3164 - qp->host_index, qp->hba_index); 3153 + qp->host_index, qp->hba_index, qp->entry_repost); 3165 3154 len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, 3166 - "\t\tDQID[%02d], QE-CNT[%04d], QE-SIZE[%04d], " 3167 - "HOST-IDX[%04d], PORT-IDX[%04d]\n", 3155 + "\t\tDQID[%02d], QE-CNT[%04d], QE-SZ[%04d], " 3156 + "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]\n", 3168 3157 datqp->queue_id, datqp->entry_count, 3169 3158 datqp->entry_size, datqp->host_index, 3170 - datqp->hba_index); 3159 + datqp->hba_index, datqp->entry_repost); 3171 3160 return len; 3172 3161 } 3173 3162 ··· 3253 3242 eqtype, qp->q_cnt_1, qp->q_cnt_2, qp->q_cnt_3, 3254 3243 (unsigned long long)qp->q_cnt_4); 3255 3244 len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, 3256 - "EQID[%02d], QE-CNT[%04d], QE-SIZE[%04d], " 3257 - "HOST-IDX[%04d], PORT-IDX[%04d]", 3245 + "EQID[%02d], QE-CNT[%04d], QE-SZ[%04d], " 3246 + "HST-IDX[%04d], PRT-IDX[%04d], PST[%03d]", 3258 3247 qp->queue_id, qp->entry_count, qp->entry_size, 3259 - qp->host_index, qp->hba_index); 3248 + qp->host_index, qp->hba_index, qp->entry_repost); 3260 3249 len += snprintf(pbuffer + len, LPFC_QUE_INFO_GET_BUF_SIZE - len, "\n"); 3261 3250 3262 3251 return len; ··· 5866 5855 atomic_dec(&lpfc_debugfs_hba_count); 5867 5856 } 5868 5857 5869 - debugfs_remove(lpfc_debugfs_root); /* lpfc */ 5870 - lpfc_debugfs_root = NULL; 5858 + if (atomic_read(&lpfc_debugfs_hba_count) == 0) { 5859 + debugfs_remove(lpfc_debugfs_root); /* lpfc */ 5860 + lpfc_debugfs_root = NULL; 5861 + } 5871 5862 } 5872 5863 #endif 5873 5864 return;
+1
drivers/scsi/lpfc/lpfc_disc.h
··· 90 90 #define NLP_FCP_INITIATOR 0x10 /* entry is an FCP Initiator */ 91 91 #define NLP_NVME_TARGET 0x20 /* entry is a NVME Target */ 92 92 #define NLP_NVME_INITIATOR 0x40 /* entry is a NVME Initiator */ 93 + #define NLP_NVME_DISCOVERY 0x80 /* entry has NVME disc srvc */ 93 94 94 95 uint16_t nlp_fc4_type; /* FC types node supports. */ 95 96 /* Assigned from GID_FF, only
+22 -4
drivers/scsi/lpfc/lpfc_els.c
··· 1047 1047 irsp->ulpStatus, irsp->un.ulpWord[4], 1048 1048 irsp->ulpTimeout); 1049 1049 1050 + 1051 + /* If this is not a loop open failure, bail out */ 1052 + if (!(irsp->ulpStatus == IOSTAT_LOCAL_REJECT && 1053 + ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) == 1054 + IOERR_LOOP_OPEN_FAILURE))) 1055 + goto flogifail; 1056 + 1050 1057 /* FLOGI failed, so there is no fabric */ 1051 1058 spin_lock_irq(shost->host_lock); 1052 1059 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); ··· 2084 2077 2085 2078 if (irsp->ulpStatus) { 2086 2079 /* Check for retry */ 2080 + ndlp->fc4_prli_sent--; 2087 2081 if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { 2088 2082 /* ELS command is being retried */ 2089 - ndlp->fc4_prli_sent--; 2090 2083 goto out; 2091 2084 } 2085 + 2092 2086 /* PRLI failed */ 2093 2087 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, 2094 - "2754 PRLI failure DID:%06X Status:x%x/x%x\n", 2088 + "2754 PRLI failure DID:%06X Status:x%x/x%x, " 2089 + "data: x%x\n", 2095 2090 ndlp->nlp_DID, irsp->ulpStatus, 2096 - irsp->un.ulpWord[4]); 2091 + irsp->un.ulpWord[4], ndlp->fc4_prli_sent); 2092 + 2097 2093 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ 2098 2094 if (lpfc_error_lost_link(irsp)) 2099 2095 goto out; ··· 7451 7441 */ 7452 7442 spin_lock_irq(&phba->hbalock); 7453 7443 pring = lpfc_phba_elsring(phba); 7444 + 7445 + /* Bail out if we've no ELS wq, like in PCI error recovery case. */ 7446 + if (unlikely(!pring)) { 7447 + spin_unlock_irq(&phba->hbalock); 7448 + return; 7449 + } 7450 + 7454 7451 if (phba->sli_rev == LPFC_SLI_REV4) 7455 7452 spin_lock(&pring->ring_lock); 7456 7453 ··· 8684 8667 lpfc_do_scr_ns_plogi(phba, vport); 8685 8668 goto out; 8686 8669 fdisc_failed: 8687 - if (vport->fc_vport->vport_state != FC_VPORT_NO_FABRIC_RSCS) 8670 + if (vport->fc_vport && 8671 + (vport->fc_vport->vport_state != FC_VPORT_NO_FABRIC_RSCS)) 8688 8672 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 8689 8673 /* Cancel discovery timer */ 8690 8674 lpfc_can_disctmo(vport);
+5 -4
drivers/scsi/lpfc/lpfc_hbadisc.c
··· 693 693 pring = lpfc_phba_elsring(phba); 694 694 status = (ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING))); 695 695 status >>= (4*LPFC_ELS_RING); 696 - if ((status & HA_RXMASK) || 697 - (pring->flag & LPFC_DEFERRED_RING_EVENT) || 698 - (phba->hba_flag & HBA_SP_QUEUE_EVT)) { 696 + if (pring && (status & HA_RXMASK || 697 + pring->flag & LPFC_DEFERRED_RING_EVENT || 698 + phba->hba_flag & HBA_SP_QUEUE_EVT)) { 699 699 if (pring->flag & LPFC_STOP_IOCB_EVENT) { 700 700 pring->flag |= LPFC_DEFERRED_RING_EVENT; 701 701 /* Set the lpfc data pending flag */ 702 702 set_bit(LPFC_DATA_READY, &phba->data_flags); 703 703 } else { 704 - if (phba->link_state >= LPFC_LINK_UP) { 704 + if (phba->link_state >= LPFC_LINK_UP || 705 + phba->link_flag & LS_MDS_LOOPBACK) { 705 706 pring->flag &= ~LPFC_DEFERRED_RING_EVENT; 706 707 lpfc_sli_handle_slow_ring_event(phba, pring, 707 708 (status &
+15 -1
drivers/scsi/lpfc/lpfc_hw4.h
··· 1356 1356 1357 1357 #define LPFC_HDR_BUF_SIZE 128 1358 1358 #define LPFC_DATA_BUF_SIZE 2048 1359 + #define LPFC_NVMET_DATA_BUF_SIZE 128 1359 1360 struct rq_context { 1360 1361 uint32_t word0; 1361 1362 #define lpfc_rq_context_rqe_count_SHIFT 16 /* Version 0 Only */ ··· 4421 4420 }; 4422 4421 #define TXRDY_PAYLOAD_LEN 12 4423 4422 4423 + #define CMD_SEND_FRAME 0xE1 4424 + 4425 + struct send_frame_wqe { 4426 + struct ulp_bde64 bde; /* words 0-2 */ 4427 + uint32_t frame_len; /* word 3 */ 4428 + uint32_t fc_hdr_wd0; /* word 4 */ 4429 + uint32_t fc_hdr_wd1; /* word 5 */ 4430 + struct wqe_common wqe_com; /* words 6-11 */ 4431 + uint32_t fc_hdr_wd2; /* word 12 */ 4432 + uint32_t fc_hdr_wd3; /* word 13 */ 4433 + uint32_t fc_hdr_wd4; /* word 14 */ 4434 + uint32_t fc_hdr_wd5; /* word 15 */ 4435 + }; 4424 4436 4425 4437 union lpfc_wqe { 4426 4438 uint32_t words[16]; ··· 4452 4438 struct fcp_trsp64_wqe fcp_trsp; 4453 4439 struct fcp_tsend64_wqe fcp_tsend; 4454 4440 struct fcp_treceive64_wqe fcp_treceive; 4455 - 4441 + struct send_frame_wqe send_frame; 4456 4442 }; 4457 4443 4458 4444 union lpfc_wqe128 {
+39 -98
drivers/scsi/lpfc/lpfc_init.c
··· 1099 1099 1100 1100 list_for_each_entry_safe(ctxp, ctxp_next, &nvmet_aborts, list) { 1101 1101 ctxp->flag &= ~(LPFC_NVMET_XBUSY | LPFC_NVMET_ABORT_OP); 1102 - lpfc_nvmet_rq_post(phba, ctxp, &ctxp->rqb_buffer->hbuf); 1102 + lpfc_nvmet_ctxbuf_post(phba, ctxp->ctxbuf); 1103 1103 } 1104 1104 } 1105 1105 ··· 3381 3381 { 3382 3382 struct lpfc_sglq *sglq_entry = NULL, *sglq_entry_next = NULL; 3383 3383 uint16_t i, lxri, xri_cnt, els_xri_cnt; 3384 - uint16_t nvmet_xri_cnt, tot_cnt; 3384 + uint16_t nvmet_xri_cnt; 3385 3385 LIST_HEAD(nvmet_sgl_list); 3386 3386 int rc; 3387 3387 ··· 3389 3389 * update on pci function's nvmet xri-sgl list 3390 3390 */ 3391 3391 els_xri_cnt = lpfc_sli4_get_els_iocb_cnt(phba); 3392 - nvmet_xri_cnt = phba->cfg_nvmet_mrq * phba->cfg_nvmet_mrq_post; 3393 - tot_cnt = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; 3394 - if (nvmet_xri_cnt > tot_cnt) { 3395 - phba->cfg_nvmet_mrq_post = tot_cnt / phba->cfg_nvmet_mrq; 3396 - nvmet_xri_cnt = phba->cfg_nvmet_mrq * phba->cfg_nvmet_mrq_post; 3397 - lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 3398 - "6301 NVMET post-sgl count changed to %d\n", 3399 - phba->cfg_nvmet_mrq_post); 3400 - } 3392 + 3393 + /* For NVMET, ALL remaining XRIs are dedicated for IO processing */ 3394 + nvmet_xri_cnt = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; 3401 3395 3402 3396 if (nvmet_xri_cnt > phba->sli4_hba.nvmet_xri_cnt) { 3403 3397 /* els xri-sgl expanded */ ··· 4540 4546 pmb->vport = phba->pport; 4541 4547 4542 4548 if (phba->sli4_hba.link_state.status != LPFC_FC_LA_TYPE_LINK_UP) { 4549 + phba->link_flag &= ~(LS_MDS_LINK_DOWN | LS_MDS_LOOPBACK); 4550 + 4551 + switch (phba->sli4_hba.link_state.status) { 4552 + case LPFC_FC_LA_TYPE_MDS_LINK_DOWN: 4553 + phba->link_flag |= LS_MDS_LINK_DOWN; 4554 + break; 4555 + case LPFC_FC_LA_TYPE_MDS_LOOPBACK: 4556 + phba->link_flag |= LS_MDS_LOOPBACK; 4557 + break; 4558 + default: 4559 + break; 4560 + } 4561 + 4543 4562 /* Parse and translate status field */ 4544 4563 mb = &pmb->u.mb; 4545 4564 mb->mbxStatus = lpfc_sli4_parse_latt_fault(phba, ··· 5837 5830 spin_lock_init(&phba->sli4_hba.abts_nvme_buf_list_lock); 5838 5831 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvme_buf_list); 5839 5832 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); 5833 + INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_ctx_list); 5834 + INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_io_wait_list); 5835 + 5840 5836 /* Fast-path XRI aborted CQ Event work queue list */ 5841 5837 INIT_LIST_HEAD(&phba->sli4_hba.sp_nvme_xri_aborted_work_queue); 5842 5838 } ··· 5847 5837 /* This abort list used by worker thread */ 5848 5838 spin_lock_init(&phba->sli4_hba.sgl_list_lock); 5849 5839 spin_lock_init(&phba->sli4_hba.nvmet_io_lock); 5840 + spin_lock_init(&phba->sli4_hba.nvmet_io_wait_lock); 5850 5841 5851 5842 /* 5852 5843 * Initialize driver internal slow-path work queues ··· 5962 5951 for (i = 0; i < lpfc_enable_nvmet_cnt; i++) { 5963 5952 if (wwn == lpfc_enable_nvmet[i]) { 5964 5953 #if (IS_ENABLED(CONFIG_NVME_TARGET_FC)) 5954 + if (lpfc_nvmet_mem_alloc(phba)) 5955 + break; 5956 + 5957 + phba->nvmet_support = 1; /* a match */ 5958 + 5965 5959 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 5966 5960 "6017 NVME Target %016llx\n", 5967 5961 wwn); 5968 - phba->nvmet_support = 1; /* a match */ 5969 5962 #else 5970 5963 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 5971 5964 "6021 Can't enable NVME Target." 5972 5965 " NVME_TARGET_FC infrastructure" 5973 5966 " is not in kernel\n"); 5974 5967 #endif 5968 + break; 5975 5969 } 5976 5970 } 5977 5971 } ··· 6285 6269 * 6286 6270 * This routine is invoked to free the driver's IOCB list and memory. 6287 6271 **/ 6288 - static void 6272 + void 6289 6273 lpfc_free_iocb_list(struct lpfc_hba *phba) 6290 6274 { 6291 6275 struct lpfc_iocbq *iocbq_entry = NULL, *iocbq_next = NULL; ··· 6313 6297 * 0 - successful 6314 6298 * other values - error 6315 6299 **/ 6316 - static int 6300 + int 6317 6301 lpfc_init_iocb_list(struct lpfc_hba *phba, int iocb_count) 6318 6302 { 6319 6303 struct lpfc_iocbq *iocbq_entry = NULL; ··· 6541 6525 uint16_t rpi_limit, curr_rpi_range; 6542 6526 struct lpfc_dmabuf *dmabuf; 6543 6527 struct lpfc_rpi_hdr *rpi_hdr; 6544 - uint32_t rpi_count; 6545 6528 6546 6529 /* 6547 6530 * If the SLI4 port supports extents, posting the rpi header isn't ··· 6553 6538 return NULL; 6554 6539 6555 6540 /* The limit on the logical index is just the max_rpi count. */ 6556 - rpi_limit = phba->sli4_hba.max_cfg_param.rpi_base + 6557 - phba->sli4_hba.max_cfg_param.max_rpi - 1; 6541 + rpi_limit = phba->sli4_hba.max_cfg_param.max_rpi; 6558 6542 6559 6543 spin_lock_irq(&phba->hbalock); 6560 6544 /* ··· 6564 6550 curr_rpi_range = phba->sli4_hba.next_rpi; 6565 6551 spin_unlock_irq(&phba->hbalock); 6566 6552 6567 - /* 6568 - * The port has a limited number of rpis. The increment here 6569 - * is LPFC_RPI_HDR_COUNT - 1 to account for the starting value 6570 - * and to allow the full max_rpi range per port. 6571 - */ 6572 - if ((curr_rpi_range + (LPFC_RPI_HDR_COUNT - 1)) > rpi_limit) 6573 - rpi_count = rpi_limit - curr_rpi_range; 6574 - else 6575 - rpi_count = LPFC_RPI_HDR_COUNT; 6576 - 6577 - if (!rpi_count) 6553 + /* Reached full RPI range */ 6554 + if (curr_rpi_range == rpi_limit) 6578 6555 return NULL; 6556 + 6579 6557 /* 6580 6558 * First allocate the protocol header region for the port. The 6581 6559 * port expects a 4KB DMA-mapped memory region that is 4K aligned. ··· 6601 6595 6602 6596 /* The rpi_hdr stores the logical index only. */ 6603 6597 rpi_hdr->start_rpi = curr_rpi_range; 6598 + rpi_hdr->next_rpi = phba->sli4_hba.next_rpi + LPFC_RPI_HDR_COUNT; 6604 6599 list_add_tail(&rpi_hdr->list, &phba->sli4_hba.lpfc_rpi_hdr_list); 6605 6600 6606 - /* 6607 - * The next_rpi stores the next logical module-64 rpi value used 6608 - * to post physical rpis in subsequent rpi postings. 6609 - */ 6610 - phba->sli4_hba.next_rpi += rpi_count; 6611 6601 spin_unlock_irq(&phba->hbalock); 6612 6602 return rpi_hdr; 6613 6603 ··· 8174 8172 /* Create NVMET Receive Queue for header */ 8175 8173 qdesc = lpfc_sli4_queue_alloc(phba, 8176 8174 phba->sli4_hba.rq_esize, 8177 - phba->sli4_hba.rq_ecount); 8175 + LPFC_NVMET_RQE_DEF_COUNT); 8178 8176 if (!qdesc) { 8179 8177 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 8180 8178 "3146 Failed allocate " ··· 8196 8194 /* Create NVMET Receive Queue for data */ 8197 8195 qdesc = lpfc_sli4_queue_alloc(phba, 8198 8196 phba->sli4_hba.rq_esize, 8199 - phba->sli4_hba.rq_ecount); 8197 + LPFC_NVMET_RQE_DEF_COUNT); 8200 8198 if (!qdesc) { 8201 8199 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 8202 8200 "3156 Failed allocate " ··· 8325 8323 8326 8324 /* Everything on this list has been freed */ 8327 8325 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); 8328 - } 8329 - 8330 - int 8331 - lpfc_post_rq_buffer(struct lpfc_hba *phba, struct lpfc_queue *hrq, 8332 - struct lpfc_queue *drq, int count) 8333 - { 8334 - int rc, i; 8335 - struct lpfc_rqe hrqe; 8336 - struct lpfc_rqe drqe; 8337 - struct lpfc_rqb *rqbp; 8338 - struct rqb_dmabuf *rqb_buffer; 8339 - LIST_HEAD(rqb_buf_list); 8340 - 8341 - rqbp = hrq->rqbp; 8342 - for (i = 0; i < count; i++) { 8343 - rqb_buffer = (rqbp->rqb_alloc_buffer)(phba); 8344 - if (!rqb_buffer) 8345 - break; 8346 - rqb_buffer->hrq = hrq; 8347 - rqb_buffer->drq = drq; 8348 - list_add_tail(&rqb_buffer->hbuf.list, &rqb_buf_list); 8349 - } 8350 - while (!list_empty(&rqb_buf_list)) { 8351 - list_remove_head(&rqb_buf_list, rqb_buffer, struct rqb_dmabuf, 8352 - hbuf.list); 8353 - 8354 - hrqe.address_lo = putPaddrLow(rqb_buffer->hbuf.phys); 8355 - hrqe.address_hi = putPaddrHigh(rqb_buffer->hbuf.phys); 8356 - drqe.address_lo = putPaddrLow(rqb_buffer->dbuf.phys); 8357 - drqe.address_hi = putPaddrHigh(rqb_buffer->dbuf.phys); 8358 - rc = lpfc_sli4_rq_put(hrq, drq, &hrqe, &drqe); 8359 - if (rc < 0) { 8360 - (rqbp->rqb_free_buffer)(phba, rqb_buffer); 8361 - } else { 8362 - list_add_tail(&rqb_buffer->hbuf.list, 8363 - &rqbp->rqb_buffer_list); 8364 - rqbp->buffer_count++; 8365 - } 8366 - } 8367 - return 1; 8368 8326 } 8369 8327 8370 8328 int ··· 8745 8783 rc = -ENOMEM; 8746 8784 goto out_destroy; 8747 8785 } 8748 - 8749 - lpfc_rq_adjust_repost(phba, phba->sli4_hba.hdr_rq, LPFC_ELS_HBQ); 8750 - lpfc_rq_adjust_repost(phba, phba->sli4_hba.dat_rq, LPFC_ELS_HBQ); 8751 8786 8752 8787 rc = lpfc_rq_create(phba, phba->sli4_hba.hdr_rq, phba->sli4_hba.dat_rq, 8753 8788 phba->sli4_hba.els_cq, LPFC_USOL); ··· 11069 11110 struct lpfc_hba *phba; 11070 11111 struct lpfc_vport *vport = NULL; 11071 11112 struct Scsi_Host *shost = NULL; 11072 - int error, cnt; 11113 + int error; 11073 11114 uint32_t cfg_mode, intr_mode; 11074 11115 11075 11116 /* Allocate memory for HBA structure */ ··· 11103 11144 goto out_unset_pci_mem_s4; 11104 11145 } 11105 11146 11106 - cnt = phba->cfg_iocb_cnt * 1024; 11107 - if (phba->nvmet_support) 11108 - cnt += phba->cfg_nvmet_mrq_post * phba->cfg_nvmet_mrq; 11109 - 11110 - /* Initialize and populate the iocb list per host */ 11111 - lpfc_printf_log(phba, KERN_INFO, LOG_INIT, 11112 - "2821 initialize iocb list %d total %d\n", 11113 - phba->cfg_iocb_cnt, cnt); 11114 - error = lpfc_init_iocb_list(phba, cnt); 11115 - 11116 - if (error) { 11117 - lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 11118 - "1413 Failed to initialize iocb list.\n"); 11119 - goto out_unset_driver_resource_s4; 11120 - } 11121 - 11122 11147 INIT_LIST_HEAD(&phba->active_rrq_list); 11123 11148 INIT_LIST_HEAD(&phba->fcf.fcf_pri_list); 11124 11149 ··· 11111 11168 if (error) { 11112 11169 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 11113 11170 "1414 Failed to set up driver resource.\n"); 11114 - goto out_free_iocb_list; 11171 + goto out_unset_driver_resource_s4; 11115 11172 } 11116 11173 11117 11174 /* Get the default values for Model Name and Description */ ··· 11211 11268 lpfc_destroy_shost(phba); 11212 11269 out_unset_driver_resource: 11213 11270 lpfc_unset_driver_resource_phase2(phba); 11214 - out_free_iocb_list: 11215 - lpfc_free_iocb_list(phba); 11216 11271 out_unset_driver_resource_s4: 11217 11272 lpfc_sli4_driver_resource_unset(phba); 11218 11273 out_unset_pci_mem_s4:
+28 -72
drivers/scsi/lpfc/lpfc_mem.c
··· 214 214 return -ENOMEM; 215 215 } 216 216 217 + int 218 + lpfc_nvmet_mem_alloc(struct lpfc_hba *phba) 219 + { 220 + phba->lpfc_nvmet_drb_pool = 221 + pci_pool_create("lpfc_nvmet_drb_pool", 222 + phba->pcidev, LPFC_NVMET_DATA_BUF_SIZE, 223 + SGL_ALIGN_SZ, 0); 224 + if (!phba->lpfc_nvmet_drb_pool) { 225 + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 226 + "6024 Can't enable NVME Target - no memory\n"); 227 + return -ENOMEM; 228 + } 229 + return 0; 230 + } 231 + 217 232 /** 218 233 * lpfc_mem_free - Frees memory allocated by lpfc_mem_alloc 219 234 * @phba: HBA to free memory for ··· 247 232 248 233 /* Free HBQ pools */ 249 234 lpfc_sli_hbqbuf_free_all(phba); 235 + if (phba->lpfc_nvmet_drb_pool) 236 + pci_pool_destroy(phba->lpfc_nvmet_drb_pool); 237 + phba->lpfc_nvmet_drb_pool = NULL; 250 238 if (phba->lpfc_drb_pool) 251 239 pci_pool_destroy(phba->lpfc_drb_pool); 252 240 phba->lpfc_drb_pool = NULL; ··· 629 611 lpfc_sli4_nvmet_alloc(struct lpfc_hba *phba) 630 612 { 631 613 struct rqb_dmabuf *dma_buf; 632 - struct lpfc_iocbq *nvmewqe; 633 - union lpfc_wqe128 *wqe; 634 614 635 615 dma_buf = kzalloc(sizeof(struct rqb_dmabuf), GFP_KERNEL); 636 616 if (!dma_buf) ··· 640 624 kfree(dma_buf); 641 625 return NULL; 642 626 } 643 - dma_buf->dbuf.virt = pci_pool_alloc(phba->lpfc_drb_pool, GFP_KERNEL, 644 - &dma_buf->dbuf.phys); 627 + dma_buf->dbuf.virt = pci_pool_alloc(phba->lpfc_nvmet_drb_pool, 628 + GFP_KERNEL, &dma_buf->dbuf.phys); 645 629 if (!dma_buf->dbuf.virt) { 646 630 pci_pool_free(phba->lpfc_hrb_pool, dma_buf->hbuf.virt, 647 631 dma_buf->hbuf.phys); 648 632 kfree(dma_buf); 649 633 return NULL; 650 634 } 651 - dma_buf->total_size = LPFC_DATA_BUF_SIZE; 652 - 653 - dma_buf->context = kzalloc(sizeof(struct lpfc_nvmet_rcv_ctx), 654 - GFP_KERNEL); 655 - if (!dma_buf->context) { 656 - pci_pool_free(phba->lpfc_drb_pool, dma_buf->dbuf.virt, 657 - dma_buf->dbuf.phys); 658 - pci_pool_free(phba->lpfc_hrb_pool, dma_buf->hbuf.virt, 659 - dma_buf->hbuf.phys); 660 - kfree(dma_buf); 661 - return NULL; 662 - } 663 - 664 - dma_buf->iocbq = lpfc_sli_get_iocbq(phba); 665 - if (!dma_buf->iocbq) { 666 - kfree(dma_buf->context); 667 - pci_pool_free(phba->lpfc_drb_pool, dma_buf->dbuf.virt, 668 - dma_buf->dbuf.phys); 669 - pci_pool_free(phba->lpfc_hrb_pool, dma_buf->hbuf.virt, 670 - dma_buf->hbuf.phys); 671 - kfree(dma_buf); 672 - lpfc_printf_log(phba, KERN_ERR, LOG_NVME, 673 - "2621 Ran out of nvmet iocb/WQEs\n"); 674 - return NULL; 675 - } 676 - dma_buf->iocbq->iocb_flag = LPFC_IO_NVMET; 677 - nvmewqe = dma_buf->iocbq; 678 - wqe = (union lpfc_wqe128 *)&nvmewqe->wqe; 679 - /* Initialize WQE */ 680 - memset(wqe, 0, sizeof(union lpfc_wqe)); 681 - /* Word 7 */ 682 - bf_set(wqe_ct, &wqe->generic.wqe_com, SLI4_CT_RPI); 683 - bf_set(wqe_class, &wqe->generic.wqe_com, CLASS3); 684 - bf_set(wqe_pu, &wqe->generic.wqe_com, 1); 685 - /* Word 10 */ 686 - bf_set(wqe_nvme, &wqe->fcp_tsend.wqe_com, 1); 687 - bf_set(wqe_ebde_cnt, &wqe->generic.wqe_com, 0); 688 - bf_set(wqe_qosd, &wqe->generic.wqe_com, 0); 689 - 690 - dma_buf->iocbq->context1 = NULL; 691 - spin_lock(&phba->sli4_hba.sgl_list_lock); 692 - dma_buf->sglq = __lpfc_sli_get_nvmet_sglq(phba, dma_buf->iocbq); 693 - spin_unlock(&phba->sli4_hba.sgl_list_lock); 694 - if (!dma_buf->sglq) { 695 - lpfc_sli_release_iocbq(phba, dma_buf->iocbq); 696 - kfree(dma_buf->context); 697 - pci_pool_free(phba->lpfc_drb_pool, dma_buf->dbuf.virt, 698 - dma_buf->dbuf.phys); 699 - pci_pool_free(phba->lpfc_hrb_pool, dma_buf->hbuf.virt, 700 - dma_buf->hbuf.phys); 701 - kfree(dma_buf); 702 - lpfc_printf_log(phba, KERN_ERR, LOG_NVME, 703 - "6132 Ran out of nvmet XRIs\n"); 704 - return NULL; 705 - } 635 + dma_buf->total_size = LPFC_NVMET_DATA_BUF_SIZE; 706 636 return dma_buf; 707 637 } 708 638 ··· 667 705 void 668 706 lpfc_sli4_nvmet_free(struct lpfc_hba *phba, struct rqb_dmabuf *dmab) 669 707 { 670 - unsigned long flags; 671 - 672 - __lpfc_clear_active_sglq(phba, dmab->sglq->sli4_lxritag); 673 - dmab->sglq->state = SGL_FREED; 674 - dmab->sglq->ndlp = NULL; 675 - 676 - spin_lock_irqsave(&phba->sli4_hba.sgl_list_lock, flags); 677 - list_add_tail(&dmab->sglq->list, &phba->sli4_hba.lpfc_nvmet_sgl_list); 678 - spin_unlock_irqrestore(&phba->sli4_hba.sgl_list_lock, flags); 679 - 680 - lpfc_sli_release_iocbq(phba, dmab->iocbq); 681 - kfree(dmab->context); 682 708 pci_pool_free(phba->lpfc_hrb_pool, dmab->hbuf.virt, dmab->hbuf.phys); 683 - pci_pool_free(phba->lpfc_drb_pool, dmab->dbuf.virt, dmab->dbuf.phys); 709 + pci_pool_free(phba->lpfc_nvmet_drb_pool, 710 + dmab->dbuf.virt, dmab->dbuf.phys); 684 711 kfree(dmab); 685 712 } 686 713 ··· 754 803 rc = lpfc_sli4_rq_put(rqb_entry->hrq, rqb_entry->drq, &hrqe, &drqe); 755 804 if (rc < 0) { 756 805 (rqbp->rqb_free_buffer)(phba, rqb_entry); 806 + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 807 + "6409 Cannot post to RQ %d: %x %x\n", 808 + rqb_entry->hrq->queue_id, 809 + rqb_entry->hrq->host_index, 810 + rqb_entry->hrq->hba_index); 757 811 } else { 758 812 list_add_tail(&rqb_entry->hbuf.list, &rqbp->rqb_buffer_list); 759 813 rqbp->buffer_count++;
+6
drivers/scsi/lpfc/lpfc_nportdisc.c
··· 1944 1944 1945 1945 /* Target driver cannot solicit NVME FB. */ 1946 1946 if (bf_get_be32(prli_tgt, nvpr)) { 1947 + /* Complete the nvme target roles. The transport 1948 + * needs to know if the rport is capable of 1949 + * discovery in addition to its role. 1950 + */ 1947 1951 ndlp->nlp_type |= NLP_NVME_TARGET; 1952 + if (bf_get_be32(prli_disc, nvpr)) 1953 + ndlp->nlp_type |= NLP_NVME_DISCOVERY; 1948 1954 if ((bf_get_be32(prli_fba, nvpr) == 1) && 1949 1955 (bf_get_be32(prli_fb_sz, nvpr) > 0) && 1950 1956 (phba->cfg_nvme_enable_fb) &&
+335 -81
drivers/scsi/lpfc/lpfc_nvmet.c
··· 142 142 } 143 143 144 144 /** 145 - * lpfc_nvmet_rq_post - Repost a NVMET RQ DMA buffer and clean up context 145 + * lpfc_nvmet_ctxbuf_post - Repost a NVMET RQ DMA buffer and clean up context 146 146 * @phba: HBA buffer is associated with 147 147 * @ctxp: context to clean up 148 148 * @mp: Buffer to free ··· 155 155 * Returns: None 156 156 **/ 157 157 void 158 - lpfc_nvmet_rq_post(struct lpfc_hba *phba, struct lpfc_nvmet_rcv_ctx *ctxp, 159 - struct lpfc_dmabuf *mp) 158 + lpfc_nvmet_ctxbuf_post(struct lpfc_hba *phba, struct lpfc_nvmet_ctxbuf *ctx_buf) 160 159 { 161 - if (ctxp) { 162 - if (ctxp->flag) 163 - lpfc_printf_log(phba, KERN_INFO, LOG_NVME_ABTS, 164 - "6314 rq_post ctx xri x%x flag x%x\n", 165 - ctxp->oxid, ctxp->flag); 160 + #if (IS_ENABLED(CONFIG_NVME_TARGET_FC)) 161 + struct lpfc_nvmet_rcv_ctx *ctxp = ctx_buf->context; 162 + struct lpfc_nvmet_tgtport *tgtp; 163 + struct fc_frame_header *fc_hdr; 164 + struct rqb_dmabuf *nvmebuf; 165 + struct lpfc_dmabuf *hbufp; 166 + uint32_t *payload; 167 + uint32_t size, oxid, sid, rc; 168 + unsigned long iflag; 166 169 167 - if (ctxp->txrdy) { 168 - pci_pool_free(phba->txrdy_payload_pool, ctxp->txrdy, 169 - ctxp->txrdy_phys); 170 - ctxp->txrdy = NULL; 171 - ctxp->txrdy_phys = 0; 172 - } 173 - ctxp->state = LPFC_NVMET_STE_FREE; 170 + if (ctxp->txrdy) { 171 + pci_pool_free(phba->txrdy_payload_pool, ctxp->txrdy, 172 + ctxp->txrdy_phys); 173 + ctxp->txrdy = NULL; 174 + ctxp->txrdy_phys = 0; 174 175 } 175 - lpfc_rq_buf_free(phba, mp); 176 + ctxp->state = LPFC_NVMET_STE_FREE; 177 + 178 + spin_lock_irqsave(&phba->sli4_hba.nvmet_io_wait_lock, iflag); 179 + if (phba->sli4_hba.nvmet_io_wait_cnt) { 180 + hbufp = &nvmebuf->hbuf; 181 + list_remove_head(&phba->sli4_hba.lpfc_nvmet_io_wait_list, 182 + nvmebuf, struct rqb_dmabuf, 183 + hbuf.list); 184 + phba->sli4_hba.nvmet_io_wait_cnt--; 185 + spin_unlock_irqrestore(&phba->sli4_hba.nvmet_io_wait_lock, 186 + iflag); 187 + 188 + fc_hdr = (struct fc_frame_header *)(nvmebuf->hbuf.virt); 189 + oxid = be16_to_cpu(fc_hdr->fh_ox_id); 190 + tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; 191 + payload = (uint32_t *)(nvmebuf->dbuf.virt); 192 + size = nvmebuf->bytes_recv; 193 + sid = sli4_sid_from_fc_hdr(fc_hdr); 194 + 195 + ctxp = (struct lpfc_nvmet_rcv_ctx *)ctx_buf->context; 196 + memset(ctxp, 0, sizeof(ctxp->ctx)); 197 + ctxp->wqeq = NULL; 198 + ctxp->txrdy = NULL; 199 + ctxp->offset = 0; 200 + ctxp->phba = phba; 201 + ctxp->size = size; 202 + ctxp->oxid = oxid; 203 + ctxp->sid = sid; 204 + ctxp->state = LPFC_NVMET_STE_RCV; 205 + ctxp->entry_cnt = 1; 206 + ctxp->flag = 0; 207 + ctxp->ctxbuf = ctx_buf; 208 + spin_lock_init(&ctxp->ctxlock); 209 + 210 + #ifdef CONFIG_SCSI_LPFC_DEBUG_FS 211 + if (phba->ktime_on) { 212 + ctxp->ts_cmd_nvme = ktime_get_ns(); 213 + ctxp->ts_isr_cmd = ctxp->ts_cmd_nvme; 214 + ctxp->ts_nvme_data = 0; 215 + ctxp->ts_data_wqput = 0; 216 + ctxp->ts_isr_data = 0; 217 + ctxp->ts_data_nvme = 0; 218 + ctxp->ts_nvme_status = 0; 219 + ctxp->ts_status_wqput = 0; 220 + ctxp->ts_isr_status = 0; 221 + ctxp->ts_status_nvme = 0; 222 + } 223 + #endif 224 + atomic_inc(&tgtp->rcv_fcp_cmd_in); 225 + /* 226 + * The calling sequence should be: 227 + * nvmet_fc_rcv_fcp_req->lpfc_nvmet_xmt_fcp_op/cmp- req->done 228 + * lpfc_nvmet_xmt_fcp_op_cmp should free the allocated ctxp. 229 + * When we return from nvmet_fc_rcv_fcp_req, all relevant info 230 + * the NVME command / FC header is stored. 231 + * A buffer has already been reposted for this IO, so just free 232 + * the nvmebuf. 233 + */ 234 + rc = nvmet_fc_rcv_fcp_req(phba->targetport, &ctxp->ctx.fcp_req, 235 + payload, size); 236 + 237 + /* Process FCP command */ 238 + if (rc == 0) { 239 + atomic_inc(&tgtp->rcv_fcp_cmd_out); 240 + nvmebuf->hrq->rqbp->rqb_free_buffer(phba, nvmebuf); 241 + return; 242 + } 243 + 244 + atomic_inc(&tgtp->rcv_fcp_cmd_drop); 245 + lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR, 246 + "2582 FCP Drop IO x%x: err x%x: x%x x%x x%x\n", 247 + ctxp->oxid, rc, 248 + atomic_read(&tgtp->rcv_fcp_cmd_in), 249 + atomic_read(&tgtp->rcv_fcp_cmd_out), 250 + atomic_read(&tgtp->xmt_fcp_release)); 251 + 252 + lpfc_nvmet_defer_release(phba, ctxp); 253 + lpfc_nvmet_unsol_fcp_issue_abort(phba, ctxp, sid, oxid); 254 + nvmebuf->hrq->rqbp->rqb_free_buffer(phba, nvmebuf); 255 + return; 256 + } 257 + spin_unlock_irqrestore(&phba->sli4_hba.nvmet_io_wait_lock, iflag); 258 + 259 + spin_lock_irqsave(&phba->sli4_hba.nvmet_io_lock, iflag); 260 + list_add_tail(&ctx_buf->list, 261 + &phba->sli4_hba.lpfc_nvmet_ctx_list); 262 + phba->sli4_hba.nvmet_ctx_cnt++; 263 + spin_unlock_irqrestore(&phba->sli4_hba.nvmet_io_lock, iflag); 264 + #endif 176 265 } 177 266 178 267 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS ··· 591 502 "6150 LS Drop IO x%x: Prep\n", 592 503 ctxp->oxid); 593 504 lpfc_in_buf_free(phba, &nvmebuf->dbuf); 505 + atomic_inc(&nvmep->xmt_ls_abort); 594 506 lpfc_nvmet_unsol_ls_issue_abort(phba, ctxp, 595 507 ctxp->sid, ctxp->oxid); 596 508 return -ENOMEM; ··· 635 545 lpfc_nlp_put(nvmewqeq->context1); 636 546 637 547 lpfc_in_buf_free(phba, &nvmebuf->dbuf); 548 + atomic_inc(&nvmep->xmt_ls_abort); 638 549 lpfc_nvmet_unsol_ls_issue_abort(phba, ctxp, ctxp->sid, ctxp->oxid); 639 550 return -ENXIO; 640 551 } ··· 703 612 lpfc_nvmeio_data(phba, "NVMET FCP CMND: xri x%x op x%x len x%x\n", 704 613 ctxp->oxid, rsp->op, rsp->rsplen); 705 614 615 + ctxp->flag |= LPFC_NVMET_IO_INP; 706 616 rc = lpfc_sli4_issue_wqe(phba, LPFC_FCP_RING, nvmewqeq); 707 617 if (rc == WQE_SUCCESS) { 708 - ctxp->flag |= LPFC_NVMET_IO_INP; 709 618 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS 710 619 if (!phba->ktime_on) 711 620 return 0; ··· 783 692 lpfc_nvmet_xmt_fcp_release(struct nvmet_fc_target_port *tgtport, 784 693 struct nvmefc_tgt_fcp_req *rsp) 785 694 { 695 + struct lpfc_nvmet_tgtport *lpfc_nvmep = tgtport->private; 786 696 struct lpfc_nvmet_rcv_ctx *ctxp = 787 697 container_of(rsp, struct lpfc_nvmet_rcv_ctx, ctx.fcp_req); 788 698 struct lpfc_hba *phba = ctxp->phba; ··· 802 710 lpfc_nvmeio_data(phba, "NVMET FCP FREE: xri x%x ste %d\n", ctxp->oxid, 803 711 ctxp->state, 0); 804 712 713 + atomic_inc(&lpfc_nvmep->xmt_fcp_release); 714 + 805 715 if (aborting) 806 716 return; 807 717 808 - lpfc_nvmet_rq_post(phba, ctxp, &ctxp->rqb_buffer->hbuf); 718 + lpfc_nvmet_ctxbuf_post(phba, ctxp->ctxbuf); 809 719 } 810 720 811 721 static struct nvmet_fc_target_template lpfc_tgttemplate = { ··· 828 734 .target_priv_sz = sizeof(struct lpfc_nvmet_tgtport), 829 735 }; 830 736 737 + void 738 + lpfc_nvmet_cleanup_io_context(struct lpfc_hba *phba) 739 + { 740 + struct lpfc_nvmet_ctxbuf *ctx_buf, *next_ctx_buf; 741 + unsigned long flags; 742 + 743 + list_for_each_entry_safe( 744 + ctx_buf, next_ctx_buf, 745 + &phba->sli4_hba.lpfc_nvmet_ctx_list, list) { 746 + spin_lock_irqsave( 747 + &phba->sli4_hba.abts_nvme_buf_list_lock, flags); 748 + list_del_init(&ctx_buf->list); 749 + spin_unlock_irqrestore( 750 + &phba->sli4_hba.abts_nvme_buf_list_lock, flags); 751 + __lpfc_clear_active_sglq(phba, 752 + ctx_buf->sglq->sli4_lxritag); 753 + ctx_buf->sglq->state = SGL_FREED; 754 + ctx_buf->sglq->ndlp = NULL; 755 + 756 + spin_lock_irqsave(&phba->sli4_hba.sgl_list_lock, flags); 757 + list_add_tail(&ctx_buf->sglq->list, 758 + &phba->sli4_hba.lpfc_nvmet_sgl_list); 759 + spin_unlock_irqrestore(&phba->sli4_hba.sgl_list_lock, 760 + flags); 761 + 762 + lpfc_sli_release_iocbq(phba, ctx_buf->iocbq); 763 + kfree(ctx_buf->context); 764 + } 765 + } 766 + 767 + int 768 + lpfc_nvmet_setup_io_context(struct lpfc_hba *phba) 769 + { 770 + struct lpfc_nvmet_ctxbuf *ctx_buf; 771 + struct lpfc_iocbq *nvmewqe; 772 + union lpfc_wqe128 *wqe; 773 + int i; 774 + 775 + lpfc_printf_log(phba, KERN_INFO, LOG_NVME, 776 + "6403 Allocate NVMET resources for %d XRIs\n", 777 + phba->sli4_hba.nvmet_xri_cnt); 778 + 779 + /* For all nvmet xris, allocate resources needed to process a 780 + * received command on a per xri basis. 781 + */ 782 + for (i = 0; i < phba->sli4_hba.nvmet_xri_cnt; i++) { 783 + ctx_buf = kzalloc(sizeof(*ctx_buf), GFP_KERNEL); 784 + if (!ctx_buf) { 785 + lpfc_printf_log(phba, KERN_ERR, LOG_NVME, 786 + "6404 Ran out of memory for NVMET\n"); 787 + return -ENOMEM; 788 + } 789 + 790 + ctx_buf->context = kzalloc(sizeof(*ctx_buf->context), 791 + GFP_KERNEL); 792 + if (!ctx_buf->context) { 793 + kfree(ctx_buf); 794 + lpfc_printf_log(phba, KERN_ERR, LOG_NVME, 795 + "6405 Ran out of NVMET " 796 + "context memory\n"); 797 + return -ENOMEM; 798 + } 799 + ctx_buf->context->ctxbuf = ctx_buf; 800 + 801 + ctx_buf->iocbq = lpfc_sli_get_iocbq(phba); 802 + if (!ctx_buf->iocbq) { 803 + kfree(ctx_buf->context); 804 + kfree(ctx_buf); 805 + lpfc_printf_log(phba, KERN_ERR, LOG_NVME, 806 + "6406 Ran out of NVMET iocb/WQEs\n"); 807 + return -ENOMEM; 808 + } 809 + ctx_buf->iocbq->iocb_flag = LPFC_IO_NVMET; 810 + nvmewqe = ctx_buf->iocbq; 811 + wqe = (union lpfc_wqe128 *)&nvmewqe->wqe; 812 + /* Initialize WQE */ 813 + memset(wqe, 0, sizeof(union lpfc_wqe)); 814 + /* Word 7 */ 815 + bf_set(wqe_ct, &wqe->generic.wqe_com, SLI4_CT_RPI); 816 + bf_set(wqe_class, &wqe->generic.wqe_com, CLASS3); 817 + bf_set(wqe_pu, &wqe->generic.wqe_com, 1); 818 + /* Word 10 */ 819 + bf_set(wqe_nvme, &wqe->fcp_tsend.wqe_com, 1); 820 + bf_set(wqe_ebde_cnt, &wqe->generic.wqe_com, 0); 821 + bf_set(wqe_qosd, &wqe->generic.wqe_com, 0); 822 + 823 + ctx_buf->iocbq->context1 = NULL; 824 + spin_lock(&phba->sli4_hba.sgl_list_lock); 825 + ctx_buf->sglq = __lpfc_sli_get_nvmet_sglq(phba, ctx_buf->iocbq); 826 + spin_unlock(&phba->sli4_hba.sgl_list_lock); 827 + if (!ctx_buf->sglq) { 828 + lpfc_sli_release_iocbq(phba, ctx_buf->iocbq); 829 + kfree(ctx_buf->context); 830 + kfree(ctx_buf); 831 + lpfc_printf_log(phba, KERN_ERR, LOG_NVME, 832 + "6407 Ran out of NVMET XRIs\n"); 833 + return -ENOMEM; 834 + } 835 + spin_lock(&phba->sli4_hba.nvmet_io_lock); 836 + list_add_tail(&ctx_buf->list, 837 + &phba->sli4_hba.lpfc_nvmet_ctx_list); 838 + spin_unlock(&phba->sli4_hba.nvmet_io_lock); 839 + } 840 + phba->sli4_hba.nvmet_ctx_cnt = phba->sli4_hba.nvmet_xri_cnt; 841 + return 0; 842 + } 843 + 831 844 int 832 845 lpfc_nvmet_create_targetport(struct lpfc_hba *phba) 833 846 { 834 847 struct lpfc_vport *vport = phba->pport; 835 848 struct lpfc_nvmet_tgtport *tgtp; 836 849 struct nvmet_fc_port_info pinfo; 837 - int error = 0; 850 + int error; 838 851 839 852 if (phba->targetport) 840 853 return 0; 854 + 855 + error = lpfc_nvmet_setup_io_context(phba); 856 + if (error) 857 + return error; 841 858 842 859 memset(&pinfo, 0, sizeof(struct nvmet_fc_port_info)); 843 860 pinfo.node_name = wwn_to_u64(vport->fc_nodename.u.wwn); ··· 977 772 &phba->pcidev->dev, 978 773 &phba->targetport); 979 774 #else 980 - error = -ENOMEM; 775 + error = -ENOENT; 981 776 #endif 982 777 if (error) { 983 778 lpfc_printf_log(phba, KERN_ERR, LOG_NVME_DISC, 984 779 "6025 Cannot register NVME targetport " 985 780 "x%x\n", error); 986 781 phba->targetport = NULL; 782 + 783 + lpfc_nvmet_cleanup_io_context(phba); 784 + 987 785 } else { 988 786 tgtp = (struct lpfc_nvmet_tgtport *) 989 787 phba->targetport->private; ··· 1003 795 atomic_set(&tgtp->rcv_ls_req_out, 0); 1004 796 atomic_set(&tgtp->rcv_ls_req_drop, 0); 1005 797 atomic_set(&tgtp->xmt_ls_abort, 0); 798 + atomic_set(&tgtp->xmt_ls_abort_cmpl, 0); 1006 799 atomic_set(&tgtp->xmt_ls_rsp, 0); 1007 800 atomic_set(&tgtp->xmt_ls_drop, 0); 1008 801 atomic_set(&tgtp->xmt_ls_rsp_error, 0); ··· 1011 802 atomic_set(&tgtp->rcv_fcp_cmd_in, 0); 1012 803 atomic_set(&tgtp->rcv_fcp_cmd_out, 0); 1013 804 atomic_set(&tgtp->rcv_fcp_cmd_drop, 0); 1014 - atomic_set(&tgtp->xmt_fcp_abort, 0); 1015 805 atomic_set(&tgtp->xmt_fcp_drop, 0); 1016 806 atomic_set(&tgtp->xmt_fcp_read_rsp, 0); 1017 807 atomic_set(&tgtp->xmt_fcp_read, 0); 1018 808 atomic_set(&tgtp->xmt_fcp_write, 0); 1019 809 atomic_set(&tgtp->xmt_fcp_rsp, 0); 810 + atomic_set(&tgtp->xmt_fcp_release, 0); 1020 811 atomic_set(&tgtp->xmt_fcp_rsp_cmpl, 0); 1021 812 atomic_set(&tgtp->xmt_fcp_rsp_error, 0); 1022 813 atomic_set(&tgtp->xmt_fcp_rsp_drop, 0); 814 + atomic_set(&tgtp->xmt_fcp_abort, 0); 815 + atomic_set(&tgtp->xmt_fcp_abort_cmpl, 0); 816 + atomic_set(&tgtp->xmt_abort_unsol, 0); 817 + atomic_set(&tgtp->xmt_abort_sol, 0); 1023 818 atomic_set(&tgtp->xmt_abort_rsp, 0); 1024 819 atomic_set(&tgtp->xmt_abort_rsp_error, 0); 1025 - atomic_set(&tgtp->xmt_abort_cmpl, 0); 1026 820 } 1027 821 return error; 1028 822 } ··· 1076 864 list_for_each_entry_safe(ctxp, next_ctxp, 1077 865 &phba->sli4_hba.lpfc_abts_nvmet_ctx_list, 1078 866 list) { 1079 - if (ctxp->rqb_buffer->sglq->sli4_xritag != xri) 867 + if (ctxp->ctxbuf->sglq->sli4_xritag != xri) 1080 868 continue; 1081 869 1082 870 /* Check if we already received a free context call ··· 1097 885 (ndlp->nlp_state == NLP_STE_UNMAPPED_NODE || 1098 886 ndlp->nlp_state == NLP_STE_MAPPED_NODE)) { 1099 887 lpfc_set_rrq_active(phba, ndlp, 1100 - ctxp->rqb_buffer->sglq->sli4_lxritag, 888 + ctxp->ctxbuf->sglq->sli4_lxritag, 1101 889 rxid, 1); 1102 890 lpfc_sli4_abts_err_handler(phba, ndlp, axri); 1103 891 } ··· 1106 894 "6318 XB aborted %x flg x%x (%x)\n", 1107 895 ctxp->oxid, ctxp->flag, released); 1108 896 if (released) 1109 - lpfc_nvmet_rq_post(phba, ctxp, 1110 - &ctxp->rqb_buffer->hbuf); 897 + lpfc_nvmet_ctxbuf_post(phba, ctxp->ctxbuf); 898 + 1111 899 if (rrq_empty) 1112 900 lpfc_worker_wake_up(phba); 1113 901 return; ··· 1135 923 list_for_each_entry_safe(ctxp, next_ctxp, 1136 924 &phba->sli4_hba.lpfc_abts_nvmet_ctx_list, 1137 925 list) { 1138 - if (ctxp->rqb_buffer->sglq->sli4_xritag != xri) 926 + if (ctxp->ctxbuf->sglq->sli4_xritag != xri) 1139 927 continue; 1140 928 1141 929 spin_unlock(&phba->sli4_hba.abts_nvme_buf_list_lock); ··· 1187 975 init_completion(&tgtp->tport_unreg_done); 1188 976 nvmet_fc_unregister_targetport(phba->targetport); 1189 977 wait_for_completion_timeout(&tgtp->tport_unreg_done, 5); 978 + lpfc_nvmet_cleanup_io_context(phba); 1190 979 } 1191 980 phba->targetport = NULL; 1192 981 #endif ··· 1223 1010 oxid = 0; 1224 1011 size = 0; 1225 1012 sid = 0; 1013 + ctxp = NULL; 1226 1014 goto dropit; 1227 1015 } 1228 1016 ··· 1318 1104 struct lpfc_nvmet_rcv_ctx *ctxp; 1319 1105 struct lpfc_nvmet_tgtport *tgtp; 1320 1106 struct fc_frame_header *fc_hdr; 1107 + struct lpfc_nvmet_ctxbuf *ctx_buf; 1321 1108 uint32_t *payload; 1322 - uint32_t size, oxid, sid, rc; 1109 + uint32_t size, oxid, sid, rc, qno; 1110 + unsigned long iflag; 1323 1111 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS 1324 1112 uint32_t id; 1325 1113 #endif 1326 1114 1115 + ctx_buf = NULL; 1327 1116 if (!nvmebuf || !phba->targetport) { 1328 1117 lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR, 1329 - "6157 FCP Drop IO\n"); 1118 + "6157 NVMET FCP Drop IO\n"); 1330 1119 oxid = 0; 1331 1120 size = 0; 1332 1121 sid = 0; 1122 + ctxp = NULL; 1333 1123 goto dropit; 1334 1124 } 1335 1125 1126 + spin_lock_irqsave(&phba->sli4_hba.nvmet_io_lock, iflag); 1127 + if (phba->sli4_hba.nvmet_ctx_cnt) { 1128 + list_remove_head(&phba->sli4_hba.lpfc_nvmet_ctx_list, 1129 + ctx_buf, struct lpfc_nvmet_ctxbuf, list); 1130 + phba->sli4_hba.nvmet_ctx_cnt--; 1131 + } 1132 + spin_unlock_irqrestore(&phba->sli4_hba.nvmet_io_lock, iflag); 1133 + 1134 + fc_hdr = (struct fc_frame_header *)(nvmebuf->hbuf.virt); 1135 + oxid = be16_to_cpu(fc_hdr->fh_ox_id); 1136 + size = nvmebuf->bytes_recv; 1137 + 1138 + #ifdef CONFIG_SCSI_LPFC_DEBUG_FS 1139 + if (phba->cpucheck_on & LPFC_CHECK_NVMET_RCV) { 1140 + id = smp_processor_id(); 1141 + if (id < LPFC_CHECK_CPU_CNT) 1142 + phba->cpucheck_rcv_io[id]++; 1143 + } 1144 + #endif 1145 + 1146 + lpfc_nvmeio_data(phba, "NVMET FCP RCV: xri x%x sz %d CPU %02x\n", 1147 + oxid, size, smp_processor_id()); 1148 + 1149 + if (!ctx_buf) { 1150 + /* Queue this NVME IO to process later */ 1151 + spin_lock_irqsave(&phba->sli4_hba.nvmet_io_wait_lock, iflag); 1152 + list_add_tail(&nvmebuf->hbuf.list, 1153 + &phba->sli4_hba.lpfc_nvmet_io_wait_list); 1154 + phba->sli4_hba.nvmet_io_wait_cnt++; 1155 + phba->sli4_hba.nvmet_io_wait_total++; 1156 + spin_unlock_irqrestore(&phba->sli4_hba.nvmet_io_wait_lock, 1157 + iflag); 1158 + 1159 + /* Post a brand new DMA buffer to RQ */ 1160 + qno = nvmebuf->idx; 1161 + lpfc_post_rq_buffer( 1162 + phba, phba->sli4_hba.nvmet_mrq_hdr[qno], 1163 + phba->sli4_hba.nvmet_mrq_data[qno], 1, qno); 1164 + return; 1165 + } 1336 1166 1337 1167 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; 1338 1168 payload = (uint32_t *)(nvmebuf->dbuf.virt); 1339 - fc_hdr = (struct fc_frame_header *)(nvmebuf->hbuf.virt); 1340 - size = nvmebuf->bytes_recv; 1341 - oxid = be16_to_cpu(fc_hdr->fh_ox_id); 1342 1169 sid = sli4_sid_from_fc_hdr(fc_hdr); 1343 1170 1344 - ctxp = (struct lpfc_nvmet_rcv_ctx *)nvmebuf->context; 1345 - if (ctxp == NULL) { 1346 - atomic_inc(&tgtp->rcv_fcp_cmd_drop); 1347 - lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR, 1348 - "6158 FCP Drop IO x%x: Alloc\n", 1349 - oxid); 1350 - lpfc_nvmet_rq_post(phba, NULL, &nvmebuf->hbuf); 1351 - /* Cannot send ABTS without context */ 1352 - return; 1353 - } 1171 + ctxp = (struct lpfc_nvmet_rcv_ctx *)ctx_buf->context; 1354 1172 memset(ctxp, 0, sizeof(ctxp->ctx)); 1355 1173 ctxp->wqeq = NULL; 1356 1174 ctxp->txrdy = NULL; ··· 1392 1146 ctxp->oxid = oxid; 1393 1147 ctxp->sid = sid; 1394 1148 ctxp->state = LPFC_NVMET_STE_RCV; 1395 - ctxp->rqb_buffer = nvmebuf; 1396 1149 ctxp->entry_cnt = 1; 1397 1150 ctxp->flag = 0; 1151 + ctxp->ctxbuf = ctx_buf; 1398 1152 spin_lock_init(&ctxp->ctxlock); 1399 1153 1400 1154 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS ··· 1410 1164 ctxp->ts_isr_status = 0; 1411 1165 ctxp->ts_status_nvme = 0; 1412 1166 } 1413 - 1414 - if (phba->cpucheck_on & LPFC_CHECK_NVMET_RCV) { 1415 - id = smp_processor_id(); 1416 - if (id < LPFC_CHECK_CPU_CNT) 1417 - phba->cpucheck_rcv_io[id]++; 1418 - } 1419 1167 #endif 1420 - 1421 - lpfc_nvmeio_data(phba, "NVMET FCP RCV: xri x%x sz %d CPU %02x\n", 1422 - oxid, size, smp_processor_id()); 1423 1168 1424 1169 atomic_inc(&tgtp->rcv_fcp_cmd_in); 1425 1170 /* 1426 1171 * The calling sequence should be: 1427 1172 * nvmet_fc_rcv_fcp_req -> lpfc_nvmet_xmt_fcp_op/cmp -> req->done 1428 1173 * lpfc_nvmet_xmt_fcp_op_cmp should free the allocated ctxp. 1174 + * When we return from nvmet_fc_rcv_fcp_req, all relevant info in 1175 + * the NVME command / FC header is stored, so we are free to repost 1176 + * the buffer. 1429 1177 */ 1430 1178 rc = nvmet_fc_rcv_fcp_req(phba->targetport, &ctxp->ctx.fcp_req, 1431 1179 payload, size); ··· 1427 1187 /* Process FCP command */ 1428 1188 if (rc == 0) { 1429 1189 atomic_inc(&tgtp->rcv_fcp_cmd_out); 1190 + lpfc_rq_buf_free(phba, &nvmebuf->hbuf); /* repost */ 1430 1191 return; 1431 1192 } 1432 1193 1433 1194 atomic_inc(&tgtp->rcv_fcp_cmd_drop); 1434 1195 lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR, 1435 - "6159 FCP Drop IO x%x: err x%x\n", 1436 - ctxp->oxid, rc); 1196 + "6159 FCP Drop IO x%x: err x%x: x%x x%x x%x\n", 1197 + ctxp->oxid, rc, 1198 + atomic_read(&tgtp->rcv_fcp_cmd_in), 1199 + atomic_read(&tgtp->rcv_fcp_cmd_out), 1200 + atomic_read(&tgtp->xmt_fcp_release)); 1437 1201 dropit: 1438 1202 lpfc_nvmeio_data(phba, "NVMET FCP DROP: xri x%x sz %d from %06x\n", 1439 1203 oxid, size, sid); 1440 1204 if (oxid) { 1205 + lpfc_nvmet_defer_release(phba, ctxp); 1441 1206 lpfc_nvmet_unsol_fcp_issue_abort(phba, ctxp, sid, oxid); 1207 + lpfc_rq_buf_free(phba, &nvmebuf->hbuf); /* repost */ 1442 1208 return; 1443 1209 } 1444 1210 1445 - if (nvmebuf) { 1446 - nvmebuf->iocbq->hba_wqidx = 0; 1447 - /* We assume a rcv'ed cmd ALWAYs fits into 1 buffer */ 1448 - lpfc_nvmet_rq_post(phba, NULL, &nvmebuf->hbuf); 1449 - } 1211 + if (ctx_buf) 1212 + lpfc_nvmet_ctxbuf_post(phba, ctx_buf); 1213 + 1214 + if (nvmebuf) 1215 + lpfc_rq_buf_free(phba, &nvmebuf->hbuf); /* repost */ 1450 1216 #endif 1451 1217 } 1452 1218 ··· 1504 1258 uint64_t isr_timestamp) 1505 1259 { 1506 1260 if (phba->nvmet_support == 0) { 1507 - lpfc_nvmet_rq_post(phba, NULL, &nvmebuf->hbuf); 1261 + lpfc_rq_buf_free(phba, &nvmebuf->hbuf); 1508 1262 return; 1509 1263 } 1510 1264 lpfc_nvmet_unsol_fcp_buffer(phba, pring, nvmebuf, ··· 1705 1459 nvmewqe = ctxp->wqeq; 1706 1460 if (nvmewqe == NULL) { 1707 1461 /* Allocate buffer for command wqe */ 1708 - nvmewqe = ctxp->rqb_buffer->iocbq; 1462 + nvmewqe = ctxp->ctxbuf->iocbq; 1709 1463 if (nvmewqe == NULL) { 1710 1464 lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR, 1711 1465 "6110 lpfc_nvmet_prep_fcp_wqe: No " ··· 1732 1486 return NULL; 1733 1487 } 1734 1488 1735 - sgl = (struct sli4_sge *)ctxp->rqb_buffer->sglq->sgl; 1489 + sgl = (struct sli4_sge *)ctxp->ctxbuf->sglq->sgl; 1736 1490 switch (rsp->op) { 1737 1491 case NVMET_FCOP_READDATA: 1738 1492 case NVMET_FCOP_READDATA_RSP: ··· 2057 1811 result = wcqe->parameter; 2058 1812 2059 1813 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; 2060 - atomic_inc(&tgtp->xmt_abort_cmpl); 1814 + if (ctxp->flag & LPFC_NVMET_ABORT_OP) 1815 + atomic_inc(&tgtp->xmt_fcp_abort_cmpl); 2061 1816 2062 1817 ctxp->state = LPFC_NVMET_STE_DONE; 2063 1818 ··· 2073 1826 } 2074 1827 ctxp->flag &= ~LPFC_NVMET_ABORT_OP; 2075 1828 spin_unlock_irqrestore(&ctxp->ctxlock, flags); 1829 + atomic_inc(&tgtp->xmt_abort_rsp); 2076 1830 2077 1831 lpfc_printf_log(phba, KERN_ERR, LOG_NVME_ABTS, 2078 1832 "6165 ABORT cmpl: xri x%x flg x%x (%d) " ··· 2082 1834 wcqe->word0, wcqe->total_data_placed, 2083 1835 result, wcqe->word3); 2084 1836 1837 + cmdwqe->context2 = NULL; 1838 + cmdwqe->context3 = NULL; 2085 1839 /* 2086 1840 * if transport has released ctx, then can reuse it. Otherwise, 2087 1841 * will be recycled by transport release call. 2088 1842 */ 2089 1843 if (released) 2090 - lpfc_nvmet_rq_post(phba, ctxp, &ctxp->rqb_buffer->hbuf); 1844 + lpfc_nvmet_ctxbuf_post(phba, ctxp->ctxbuf); 2091 1845 2092 - cmdwqe->context2 = NULL; 2093 - cmdwqe->context3 = NULL; 1846 + /* This is the iocbq for the abort, not the command */ 2094 1847 lpfc_sli_release_iocbq(phba, cmdwqe); 2095 1848 2096 1849 /* Since iaab/iaar are NOT set, there is no work left. ··· 2125 1876 result = wcqe->parameter; 2126 1877 2127 1878 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; 2128 - atomic_inc(&tgtp->xmt_abort_cmpl); 1879 + if (ctxp->flag & LPFC_NVMET_ABORT_OP) 1880 + atomic_inc(&tgtp->xmt_fcp_abort_cmpl); 2129 1881 2130 1882 if (!ctxp) { 2131 1883 /* if context is clear, related io alrady complete */ ··· 2156 1906 } 2157 1907 ctxp->flag &= ~LPFC_NVMET_ABORT_OP; 2158 1908 spin_unlock_irqrestore(&ctxp->ctxlock, flags); 1909 + atomic_inc(&tgtp->xmt_abort_rsp); 2159 1910 2160 1911 lpfc_printf_log(phba, KERN_INFO, LOG_NVME_ABTS, 2161 1912 "6316 ABTS cmpl xri x%x flg x%x (%x) " ··· 2164 1913 ctxp->oxid, ctxp->flag, released, 2165 1914 wcqe->word0, wcqe->total_data_placed, 2166 1915 result, wcqe->word3); 1916 + 1917 + cmdwqe->context2 = NULL; 1918 + cmdwqe->context3 = NULL; 2167 1919 /* 2168 1920 * if transport has released ctx, then can reuse it. Otherwise, 2169 1921 * will be recycled by transport release call. 2170 1922 */ 2171 1923 if (released) 2172 - lpfc_nvmet_rq_post(phba, ctxp, &ctxp->rqb_buffer->hbuf); 2173 - 2174 - cmdwqe->context2 = NULL; 2175 - cmdwqe->context3 = NULL; 1924 + lpfc_nvmet_ctxbuf_post(phba, ctxp->ctxbuf); 2176 1925 2177 1926 /* Since iaab/iaar are NOT set, there is no work left. 2178 1927 * For LPFC_NVMET_XBUSY, lpfc_sli4_nvmet_xri_aborted ··· 2203 1952 result = wcqe->parameter; 2204 1953 2205 1954 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; 2206 - atomic_inc(&tgtp->xmt_abort_cmpl); 1955 + atomic_inc(&tgtp->xmt_ls_abort_cmpl); 2207 1956 2208 1957 lpfc_printf_log(phba, KERN_INFO, LOG_NVME_ABTS, 2209 1958 "6083 Abort cmpl: ctx %p WCQE: %08x %08x %08x %08x\n", ··· 2234 1983 sid, xri, ctxp->wqeq->sli4_xritag); 2235 1984 2236 1985 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; 2237 - if (!ctxp->wqeq) { 2238 - ctxp->wqeq = ctxp->rqb_buffer->iocbq; 2239 - ctxp->wqeq->hba_wqidx = 0; 2240 - } 2241 1986 2242 1987 ndlp = lpfc_findnode_did(phba->pport, sid); 2243 1988 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) || ··· 2329 2082 2330 2083 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; 2331 2084 if (!ctxp->wqeq) { 2332 - ctxp->wqeq = ctxp->rqb_buffer->iocbq; 2085 + ctxp->wqeq = ctxp->ctxbuf->iocbq; 2333 2086 ctxp->wqeq->hba_wqidx = 0; 2334 2087 } 2335 2088 ··· 2350 2103 /* Issue ABTS for this WQE based on iotag */ 2351 2104 ctxp->abort_wqeq = lpfc_sli_get_iocbq(phba); 2352 2105 if (!ctxp->abort_wqeq) { 2106 + atomic_inc(&tgtp->xmt_abort_rsp_error); 2353 2107 lpfc_printf_log(phba, KERN_WARNING, LOG_NVME_ABTS, 2354 2108 "6161 ABORT failed: No wqeqs: " 2355 2109 "xri: x%x\n", ctxp->oxid); ··· 2375 2127 /* driver queued commands are in process of being flushed */ 2376 2128 if (phba->hba_flag & HBA_NVME_IOQ_FLUSH) { 2377 2129 spin_unlock_irqrestore(&phba->hbalock, flags); 2130 + atomic_inc(&tgtp->xmt_abort_rsp_error); 2378 2131 lpfc_printf_log(phba, KERN_ERR, LOG_NVME, 2379 2132 "6163 Driver in reset cleanup - flushing " 2380 2133 "NVME Req now. hba_flag x%x oxid x%x\n", ··· 2388 2139 /* Outstanding abort is in progress */ 2389 2140 if (abts_wqeq->iocb_flag & LPFC_DRIVER_ABORTED) { 2390 2141 spin_unlock_irqrestore(&phba->hbalock, flags); 2142 + atomic_inc(&tgtp->xmt_abort_rsp_error); 2391 2143 lpfc_printf_log(phba, KERN_ERR, LOG_NVME, 2392 2144 "6164 Outstanding NVME I/O Abort Request " 2393 2145 "still pending on oxid x%x\n", ··· 2439 2189 abts_wqeq->context2 = ctxp; 2440 2190 rc = lpfc_sli4_issue_wqe(phba, LPFC_FCP_RING, abts_wqeq); 2441 2191 spin_unlock_irqrestore(&phba->hbalock, flags); 2442 - if (rc == WQE_SUCCESS) 2192 + if (rc == WQE_SUCCESS) { 2193 + atomic_inc(&tgtp->xmt_abort_sol); 2443 2194 return 0; 2195 + } 2444 2196 2197 + atomic_inc(&tgtp->xmt_abort_rsp_error); 2445 2198 ctxp->flag &= ~LPFC_NVMET_ABORT_OP; 2446 2199 lpfc_sli_release_iocbq(phba, abts_wqeq); 2447 2200 lpfc_printf_log(phba, KERN_ERR, LOG_NVME_ABTS, ··· 2467 2214 2468 2215 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; 2469 2216 if (!ctxp->wqeq) { 2470 - ctxp->wqeq = ctxp->rqb_buffer->iocbq; 2217 + ctxp->wqeq = ctxp->ctxbuf->iocbq; 2471 2218 ctxp->wqeq->hba_wqidx = 0; 2472 2219 } 2473 2220 ··· 2483 2230 rc = lpfc_sli4_issue_wqe(phba, LPFC_FCP_RING, abts_wqeq); 2484 2231 spin_unlock_irqrestore(&phba->hbalock, flags); 2485 2232 if (rc == WQE_SUCCESS) { 2486 - atomic_inc(&tgtp->xmt_abort_rsp); 2487 2233 return 0; 2488 2234 } 2489 2235 2490 2236 aerr: 2237 + atomic_inc(&tgtp->xmt_abort_rsp_error); 2491 2238 ctxp->flag &= ~LPFC_NVMET_ABORT_OP; 2492 2239 atomic_inc(&tgtp->xmt_abort_rsp_error); 2493 2240 lpfc_printf_log(phba, KERN_WARNING, LOG_NVME_ABTS, ··· 2522 2269 } 2523 2270 abts_wqeq = ctxp->wqeq; 2524 2271 wqe_abts = &abts_wqeq->wqe; 2272 + 2525 2273 lpfc_nvmet_unsol_issue_abort(phba, ctxp, sid, xri); 2526 2274 2527 2275 spin_lock_irqsave(&phba->hbalock, flags); ··· 2532 2278 rc = lpfc_sli4_issue_wqe(phba, LPFC_ELS_RING, abts_wqeq); 2533 2279 spin_unlock_irqrestore(&phba->hbalock, flags); 2534 2280 if (rc == WQE_SUCCESS) { 2535 - atomic_inc(&tgtp->xmt_abort_rsp); 2281 + atomic_inc(&tgtp->xmt_abort_unsol); 2536 2282 return 0; 2537 2283 } 2538 2284
+9 -5
drivers/scsi/lpfc/lpfc_nvmet.h
··· 22 22 ********************************************************************/ 23 23 24 24 #define LPFC_NVMET_DEFAULT_SEGS (64 + 1) /* 256K IOs */ 25 + #define LPFC_NVMET_RQE_DEF_COUNT 512 25 26 #define LPFC_NVMET_SUCCESS_LEN 12 26 27 27 28 /* Used for NVME Target */ ··· 35 34 atomic_t rcv_ls_req_out; 36 35 atomic_t rcv_ls_req_drop; 37 36 atomic_t xmt_ls_abort; 37 + atomic_t xmt_ls_abort_cmpl; 38 38 39 39 /* Stats counters - lpfc_nvmet_xmt_ls_rsp */ 40 40 atomic_t xmt_ls_rsp; ··· 49 47 atomic_t rcv_fcp_cmd_in; 50 48 atomic_t rcv_fcp_cmd_out; 51 49 atomic_t rcv_fcp_cmd_drop; 50 + atomic_t xmt_fcp_release; 52 51 53 52 /* Stats counters - lpfc_nvmet_xmt_fcp_op */ 54 - atomic_t xmt_fcp_abort; 55 53 atomic_t xmt_fcp_drop; 56 54 atomic_t xmt_fcp_read_rsp; 57 55 atomic_t xmt_fcp_read; ··· 64 62 atomic_t xmt_fcp_rsp_drop; 65 63 66 64 67 - /* Stats counters - lpfc_nvmet_unsol_issue_abort */ 65 + /* Stats counters - lpfc_nvmet_xmt_fcp_abort */ 66 + atomic_t xmt_fcp_abort; 67 + atomic_t xmt_fcp_abort_cmpl; 68 + atomic_t xmt_abort_sol; 69 + atomic_t xmt_abort_unsol; 68 70 atomic_t xmt_abort_rsp; 69 71 atomic_t xmt_abort_rsp_error; 70 - 71 - /* Stats counters - lpfc_nvmet_xmt_abort_cmp */ 72 - atomic_t xmt_abort_cmpl; 73 72 }; 74 73 75 74 struct lpfc_nvmet_rcv_ctx { ··· 106 103 #define LPFC_NVMET_CTX_RLS 0x8 /* ctx free requested */ 107 104 #define LPFC_NVMET_ABTS_RCV 0x10 /* ABTS received on exchange */ 108 105 struct rqb_dmabuf *rqb_buffer; 106 + struct lpfc_nvmet_ctxbuf *ctxbuf; 109 107 110 108 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS 111 109 uint64_t ts_isr_cmd;
+277 -80
drivers/scsi/lpfc/lpfc_sli.c
··· 74 74 struct lpfc_iocbq *); 75 75 static void lpfc_sli4_send_seq_to_ulp(struct lpfc_vport *, 76 76 struct hbq_dmabuf *); 77 + static void lpfc_sli4_handle_mds_loopback(struct lpfc_vport *vport, 78 + struct hbq_dmabuf *dmabuf); 77 79 static int lpfc_sli4_fp_handle_cqe(struct lpfc_hba *, struct lpfc_queue *, 78 80 struct lpfc_cqe *); 79 81 static int lpfc_sli4_post_sgl_list(struct lpfc_hba *, struct list_head *, ··· 481 479 if (unlikely(!hq) || unlikely(!dq)) 482 480 return -ENOMEM; 483 481 put_index = hq->host_index; 484 - temp_hrqe = hq->qe[hq->host_index].rqe; 482 + temp_hrqe = hq->qe[put_index].rqe; 485 483 temp_drqe = dq->qe[dq->host_index].rqe; 486 484 487 485 if (hq->type != LPFC_HRQ || dq->type != LPFC_DRQ) 488 486 return -EINVAL; 489 - if (hq->host_index != dq->host_index) 487 + if (put_index != dq->host_index) 490 488 return -EINVAL; 491 489 /* If the host has not yet processed the next entry then we are done */ 492 - if (((hq->host_index + 1) % hq->entry_count) == hq->hba_index) 490 + if (((put_index + 1) % hq->entry_count) == hq->hba_index) 493 491 return -EBUSY; 494 492 lpfc_sli_pcimem_bcopy(hrqe, temp_hrqe, hq->entry_size); 495 493 lpfc_sli_pcimem_bcopy(drqe, temp_drqe, dq->entry_size); 496 494 497 495 /* Update the host index to point to the next slot */ 498 - hq->host_index = ((hq->host_index + 1) % hq->entry_count); 496 + hq->host_index = ((put_index + 1) % hq->entry_count); 499 497 dq->host_index = ((dq->host_index + 1) % dq->entry_count); 498 + hq->RQ_buf_posted++; 500 499 501 500 /* Ring The Header Receive Queue Doorbell */ 502 501 if (!(hq->host_index % hq->entry_repost)) { ··· 5909 5906 bf_set(lpfc_mbx_set_feature_mds, 5910 5907 &mbox->u.mqe.un.set_feature, 1); 5911 5908 bf_set(lpfc_mbx_set_feature_mds_deep_loopbk, 5912 - &mbox->u.mqe.un.set_feature, 0); 5909 + &mbox->u.mqe.un.set_feature, 1); 5913 5910 mbox->u.mqe.un.set_feature.feature = LPFC_SET_MDS_DIAGS; 5914 5911 mbox->u.mqe.un.set_feature.param_len = 8; 5915 5912 break; ··· 6515 6512 (phba->hba_flag & HBA_FCOE_MODE) ? "FCoE" : "FC"); 6516 6513 } 6517 6514 6515 + int 6516 + lpfc_post_rq_buffer(struct lpfc_hba *phba, struct lpfc_queue *hrq, 6517 + struct lpfc_queue *drq, int count, int idx) 6518 + { 6519 + int rc, i; 6520 + struct lpfc_rqe hrqe; 6521 + struct lpfc_rqe drqe; 6522 + struct lpfc_rqb *rqbp; 6523 + struct rqb_dmabuf *rqb_buffer; 6524 + LIST_HEAD(rqb_buf_list); 6525 + 6526 + rqbp = hrq->rqbp; 6527 + for (i = 0; i < count; i++) { 6528 + /* IF RQ is already full, don't bother */ 6529 + if (rqbp->buffer_count + i >= rqbp->entry_count - 1) 6530 + break; 6531 + rqb_buffer = rqbp->rqb_alloc_buffer(phba); 6532 + if (!rqb_buffer) 6533 + break; 6534 + rqb_buffer->hrq = hrq; 6535 + rqb_buffer->drq = drq; 6536 + rqb_buffer->idx = idx; 6537 + list_add_tail(&rqb_buffer->hbuf.list, &rqb_buf_list); 6538 + } 6539 + while (!list_empty(&rqb_buf_list)) { 6540 + list_remove_head(&rqb_buf_list, rqb_buffer, struct rqb_dmabuf, 6541 + hbuf.list); 6542 + 6543 + hrqe.address_lo = putPaddrLow(rqb_buffer->hbuf.phys); 6544 + hrqe.address_hi = putPaddrHigh(rqb_buffer->hbuf.phys); 6545 + drqe.address_lo = putPaddrLow(rqb_buffer->dbuf.phys); 6546 + drqe.address_hi = putPaddrHigh(rqb_buffer->dbuf.phys); 6547 + rc = lpfc_sli4_rq_put(hrq, drq, &hrqe, &drqe); 6548 + if (rc < 0) { 6549 + rqbp->rqb_free_buffer(phba, rqb_buffer); 6550 + } else { 6551 + list_add_tail(&rqb_buffer->hbuf.list, 6552 + &rqbp->rqb_buffer_list); 6553 + rqbp->buffer_count++; 6554 + } 6555 + } 6556 + return 1; 6557 + } 6558 + 6518 6559 /** 6519 6560 * lpfc_sli4_hba_setup - SLI4 device initialization PCI function 6520 6561 * @phba: Pointer to HBA context object. ··· 6571 6524 int 6572 6525 lpfc_sli4_hba_setup(struct lpfc_hba *phba) 6573 6526 { 6574 - int rc, i; 6527 + int rc, i, cnt; 6575 6528 LPFC_MBOXQ_t *mboxq; 6576 6529 struct lpfc_mqe *mqe; 6577 6530 uint8_t *vpd; ··· 6922 6875 goto out_destroy_queue; 6923 6876 } 6924 6877 phba->sli4_hba.nvmet_xri_cnt = rc; 6878 + 6879 + cnt = phba->cfg_iocb_cnt * 1024; 6880 + /* We need 1 iocbq for every SGL, for IO processing */ 6881 + cnt += phba->sli4_hba.nvmet_xri_cnt; 6882 + /* Initialize and populate the iocb list per host */ 6883 + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, 6884 + "2821 initialize iocb list %d total %d\n", 6885 + phba->cfg_iocb_cnt, cnt); 6886 + rc = lpfc_init_iocb_list(phba, cnt); 6887 + if (rc) { 6888 + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 6889 + "1413 Failed to init iocb list.\n"); 6890 + goto out_destroy_queue; 6891 + } 6892 + 6925 6893 lpfc_nvmet_create_targetport(phba); 6926 6894 } else { 6927 6895 /* update host scsi xri-sgl sizes and mappings */ ··· 6956 6894 "and mapping: %d\n", rc); 6957 6895 goto out_destroy_queue; 6958 6896 } 6897 + 6898 + cnt = phba->cfg_iocb_cnt * 1024; 6899 + /* Initialize and populate the iocb list per host */ 6900 + lpfc_printf_log(phba, KERN_INFO, LOG_INIT, 6901 + "2820 initialize iocb list %d total %d\n", 6902 + phba->cfg_iocb_cnt, cnt); 6903 + rc = lpfc_init_iocb_list(phba, cnt); 6904 + if (rc) { 6905 + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 6906 + "6301 Failed to init iocb list.\n"); 6907 + goto out_destroy_queue; 6908 + } 6959 6909 } 6960 6910 6961 6911 if (phba->nvmet_support && phba->cfg_nvmet_mrq) { 6962 - 6963 6912 /* Post initial buffers to all RQs created */ 6964 6913 for (i = 0; i < phba->cfg_nvmet_mrq; i++) { 6965 6914 rqbp = phba->sli4_hba.nvmet_mrq_hdr[i]->rqbp; 6966 6915 INIT_LIST_HEAD(&rqbp->rqb_buffer_list); 6967 6916 rqbp->rqb_alloc_buffer = lpfc_sli4_nvmet_alloc; 6968 6917 rqbp->rqb_free_buffer = lpfc_sli4_nvmet_free; 6969 - rqbp->entry_count = 256; 6918 + rqbp->entry_count = LPFC_NVMET_RQE_DEF_COUNT; 6970 6919 rqbp->buffer_count = 0; 6971 - 6972 - /* Divide by 4 and round down to multiple of 16 */ 6973 - rc = (phba->cfg_nvmet_mrq_post >> 2) & 0xfff8; 6974 - phba->sli4_hba.nvmet_mrq_hdr[i]->entry_repost = rc; 6975 - phba->sli4_hba.nvmet_mrq_data[i]->entry_repost = rc; 6976 6920 6977 6921 lpfc_post_rq_buffer( 6978 6922 phba, phba->sli4_hba.nvmet_mrq_hdr[i], 6979 6923 phba->sli4_hba.nvmet_mrq_data[i], 6980 - phba->cfg_nvmet_mrq_post); 6924 + LPFC_NVMET_RQE_DEF_COUNT, i); 6981 6925 } 6982 6926 } 6983 6927 ··· 7150 7082 /* Unset all the queues set up in this routine when error out */ 7151 7083 lpfc_sli4_queue_unset(phba); 7152 7084 out_destroy_queue: 7085 + lpfc_free_iocb_list(phba); 7153 7086 lpfc_sli4_queue_destroy(phba); 7154 7087 out_stop_timers: 7155 7088 lpfc_stop_hba_timers(phba); ··· 8690 8621 memset(wqe, 0, sizeof(union lpfc_wqe128)); 8691 8622 /* Some of the fields are in the right position already */ 8692 8623 memcpy(wqe, &iocbq->iocb, sizeof(union lpfc_wqe)); 8693 - wqe->generic.wqe_com.word7 = 0; /* The ct field has moved so reset */ 8694 - wqe->generic.wqe_com.word10 = 0; 8624 + if (iocbq->iocb.ulpCommand != CMD_SEND_FRAME) { 8625 + /* The ct field has moved so reset */ 8626 + wqe->generic.wqe_com.word7 = 0; 8627 + wqe->generic.wqe_com.word10 = 0; 8628 + } 8695 8629 8696 8630 abort_tag = (uint32_t) iocbq->iotag; 8697 8631 xritag = iocbq->sli4_xritag; ··· 9188 9116 } 9189 9117 9190 9118 break; 9119 + case CMD_SEND_FRAME: 9120 + bf_set(wqe_xri_tag, &wqe->generic.wqe_com, xritag); 9121 + bf_set(wqe_reqtag, &wqe->generic.wqe_com, iocbq->iotag); 9122 + return 0; 9191 9123 case CMD_XRI_ABORTED_CX: 9192 9124 case CMD_CREATE_XRI_CR: /* Do we expect to use this? */ 9193 9125 case CMD_IOCB_FCP_IBIDIR64_CR: /* bidirectional xfer */ ··· 12864 12788 struct fc_frame_header *fc_hdr; 12865 12789 struct lpfc_queue *hrq = phba->sli4_hba.hdr_rq; 12866 12790 struct lpfc_queue *drq = phba->sli4_hba.dat_rq; 12791 + struct lpfc_nvmet_tgtport *tgtp; 12867 12792 struct hbq_dmabuf *dma_buf; 12868 12793 uint32_t status, rq_id; 12869 12794 unsigned long iflags; ··· 12885 12808 case FC_STATUS_RQ_BUF_LEN_EXCEEDED: 12886 12809 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 12887 12810 "2537 Receive Frame Truncated!!\n"); 12888 - hrq->RQ_buf_trunc++; 12889 12811 case FC_STATUS_RQ_SUCCESS: 12890 12812 lpfc_sli4_rq_release(hrq, drq); 12891 12813 spin_lock_irqsave(&phba->hbalock, iflags); ··· 12895 12819 goto out; 12896 12820 } 12897 12821 hrq->RQ_rcv_buf++; 12822 + hrq->RQ_buf_posted--; 12898 12823 memcpy(&dma_buf->cq_event.cqe.rcqe_cmpl, rcqe, sizeof(*rcqe)); 12899 12824 12900 12825 /* If a NVME LS event (type 0x28), treat it as Fast path */ ··· 12909 12832 spin_unlock_irqrestore(&phba->hbalock, iflags); 12910 12833 workposted = true; 12911 12834 break; 12912 - case FC_STATUS_INSUFF_BUF_NEED_BUF: 12913 12835 case FC_STATUS_INSUFF_BUF_FRM_DISC: 12836 + if (phba->nvmet_support) { 12837 + tgtp = phba->targetport->private; 12838 + lpfc_printf_log(phba, KERN_ERR, LOG_SLI | LOG_NVME, 12839 + "6402 RQE Error x%x, posted %d err_cnt " 12840 + "%d: %x %x %x\n", 12841 + status, hrq->RQ_buf_posted, 12842 + hrq->RQ_no_posted_buf, 12843 + atomic_read(&tgtp->rcv_fcp_cmd_in), 12844 + atomic_read(&tgtp->rcv_fcp_cmd_out), 12845 + atomic_read(&tgtp->xmt_fcp_release)); 12846 + } 12847 + /* fallthrough */ 12848 + 12849 + case FC_STATUS_INSUFF_BUF_NEED_BUF: 12914 12850 hrq->RQ_no_posted_buf++; 12915 12851 /* Post more buffers if possible */ 12916 12852 spin_lock_irqsave(&phba->hbalock, iflags); ··· 13041 12951 while ((cqe = lpfc_sli4_cq_get(cq))) { 13042 12952 workposted |= lpfc_sli4_sp_handle_mcqe(phba, cqe); 13043 12953 if (!(++ecount % cq->entry_repost)) 13044 - lpfc_sli4_cq_release(cq, LPFC_QUEUE_NOARM); 12954 + break; 13045 12955 cq->CQ_mbox++; 13046 12956 } 13047 12957 break; ··· 13055 12965 workposted |= lpfc_sli4_sp_handle_cqe(phba, cq, 13056 12966 cqe); 13057 12967 if (!(++ecount % cq->entry_repost)) 13058 - lpfc_sli4_cq_release(cq, LPFC_QUEUE_NOARM); 12968 + break; 13059 12969 } 13060 12970 13061 12971 /* Track the max number of CQEs processed in 1 EQ */ ··· 13225 13135 struct lpfc_queue *drq; 13226 13136 struct rqb_dmabuf *dma_buf; 13227 13137 struct fc_frame_header *fc_hdr; 13138 + struct lpfc_nvmet_tgtport *tgtp; 13228 13139 uint32_t status, rq_id; 13229 13140 unsigned long iflags; 13230 13141 uint32_t fctl, idx; ··· 13256 13165 case FC_STATUS_RQ_BUF_LEN_EXCEEDED: 13257 13166 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 13258 13167 "6126 Receive Frame Truncated!!\n"); 13259 - hrq->RQ_buf_trunc++; 13260 - break; 13261 13168 case FC_STATUS_RQ_SUCCESS: 13262 13169 lpfc_sli4_rq_release(hrq, drq); 13263 13170 spin_lock_irqsave(&phba->hbalock, iflags); ··· 13267 13178 } 13268 13179 spin_unlock_irqrestore(&phba->hbalock, iflags); 13269 13180 hrq->RQ_rcv_buf++; 13181 + hrq->RQ_buf_posted--; 13270 13182 fc_hdr = (struct fc_frame_header *)dma_buf->hbuf.virt; 13271 13183 13272 13184 /* Just some basic sanity checks on FCP Command frame */ ··· 13290 13200 drop: 13291 13201 lpfc_in_buf_free(phba, &dma_buf->dbuf); 13292 13202 break; 13293 - case FC_STATUS_INSUFF_BUF_NEED_BUF: 13294 13203 case FC_STATUS_INSUFF_BUF_FRM_DISC: 13204 + if (phba->nvmet_support) { 13205 + tgtp = phba->targetport->private; 13206 + lpfc_printf_log(phba, KERN_ERR, LOG_SLI | LOG_NVME, 13207 + "6401 RQE Error x%x, posted %d err_cnt " 13208 + "%d: %x %x %x\n", 13209 + status, hrq->RQ_buf_posted, 13210 + hrq->RQ_no_posted_buf, 13211 + atomic_read(&tgtp->rcv_fcp_cmd_in), 13212 + atomic_read(&tgtp->rcv_fcp_cmd_out), 13213 + atomic_read(&tgtp->xmt_fcp_release)); 13214 + } 13215 + /* fallthrough */ 13216 + 13217 + case FC_STATUS_INSUFF_BUF_NEED_BUF: 13295 13218 hrq->RQ_no_posted_buf++; 13296 13219 /* Post more buffers if possible */ 13297 - spin_lock_irqsave(&phba->hbalock, iflags); 13298 - phba->hba_flag |= HBA_POST_RECEIVE_BUFFER; 13299 - spin_unlock_irqrestore(&phba->hbalock, iflags); 13300 - workposted = true; 13301 13220 break; 13302 13221 } 13303 13222 out: ··· 13460 13361 while ((cqe = lpfc_sli4_cq_get(cq))) { 13461 13362 workposted |= lpfc_sli4_fp_handle_cqe(phba, cq, cqe); 13462 13363 if (!(++ecount % cq->entry_repost)) 13463 - lpfc_sli4_cq_release(cq, LPFC_QUEUE_NOARM); 13364 + break; 13464 13365 } 13465 13366 13466 13367 /* Track the max number of CQEs processed in 1 EQ */ ··· 13551 13452 while ((cqe = lpfc_sli4_cq_get(cq))) { 13552 13453 workposted |= lpfc_sli4_fp_handle_cqe(phba, cq, cqe); 13553 13454 if (!(++ecount % cq->entry_repost)) 13554 - lpfc_sli4_cq_release(cq, LPFC_QUEUE_NOARM); 13455 + break; 13555 13456 } 13556 13457 13557 13458 /* Track the max number of CQEs processed in 1 EQ */ ··· 13633 13534 while ((eqe = lpfc_sli4_eq_get(eq))) { 13634 13535 lpfc_sli4_fof_handle_eqe(phba, eqe); 13635 13536 if (!(++ecount % eq->entry_repost)) 13636 - lpfc_sli4_eq_release(eq, LPFC_QUEUE_NOARM); 13537 + break; 13637 13538 eq->EQ_processed++; 13638 13539 } 13639 13540 ··· 13750 13651 13751 13652 lpfc_sli4_hba_handle_eqe(phba, eqe, hba_eqidx); 13752 13653 if (!(++ecount % fpeq->entry_repost)) 13753 - lpfc_sli4_eq_release(fpeq, LPFC_QUEUE_NOARM); 13654 + break; 13754 13655 fpeq->EQ_processed++; 13755 13656 } 13756 13657 ··· 13931 13832 } 13932 13833 queue->entry_size = entry_size; 13933 13834 queue->entry_count = entry_count; 13934 - 13935 - /* 13936 - * entry_repost is calculated based on the number of entries in the 13937 - * queue. This works out except for RQs. If buffers are NOT initially 13938 - * posted for every RQE, entry_repost should be adjusted accordingly. 13939 - */ 13940 - queue->entry_repost = (entry_count >> 3); 13941 - if (queue->entry_repost < LPFC_QUEUE_MIN_REPOST) 13942 - queue->entry_repost = LPFC_QUEUE_MIN_REPOST; 13943 13835 queue->phba = phba; 13836 + 13837 + /* entry_repost will be set during q creation */ 13944 13838 13945 13839 return queue; 13946 13840 out_fail: ··· 14165 14073 status = -ENXIO; 14166 14074 eq->host_index = 0; 14167 14075 eq->hba_index = 0; 14076 + eq->entry_repost = LPFC_EQ_REPOST; 14168 14077 14169 14078 mempool_free(mbox, phba->mbox_mem_pool); 14170 14079 return status; ··· 14239 14146 default: 14240 14147 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 14241 14148 "0361 Unsupported CQ count: " 14242 - "entry cnt %d sz %d pg cnt %d repost %d\n", 14149 + "entry cnt %d sz %d pg cnt %d\n", 14243 14150 cq->entry_count, cq->entry_size, 14244 - cq->page_count, cq->entry_repost); 14151 + cq->page_count); 14245 14152 if (cq->entry_count < 256) { 14246 14153 status = -EINVAL; 14247 14154 goto out; ··· 14294 14201 cq->assoc_qid = eq->queue_id; 14295 14202 cq->host_index = 0; 14296 14203 cq->hba_index = 0; 14204 + cq->entry_repost = LPFC_CQ_REPOST; 14297 14205 14298 14206 out: 14299 14207 mempool_free(mbox, phba->mbox_mem_pool); ··· 14486 14392 cq->assoc_qid = eq->queue_id; 14487 14393 cq->host_index = 0; 14488 14394 cq->hba_index = 0; 14395 + cq->entry_repost = LPFC_CQ_REPOST; 14489 14396 14490 14397 rc = 0; 14491 14398 list_for_each_entry(dmabuf, &cq->page_list, list) { ··· 14735 14640 mq->subtype = subtype; 14736 14641 mq->host_index = 0; 14737 14642 mq->hba_index = 0; 14643 + mq->entry_repost = LPFC_MQ_REPOST; 14738 14644 14739 14645 /* link the mq onto the parent cq child list */ 14740 14646 list_add_tail(&mq->list, &cq->child_list); ··· 14961 14865 } 14962 14866 14963 14867 /** 14964 - * lpfc_rq_adjust_repost - Adjust entry_repost for an RQ 14965 - * @phba: HBA structure that indicates port to create a queue on. 14966 - * @rq: The queue structure to use for the receive queue. 14967 - * @qno: The associated HBQ number 14968 - * 14969 - * 14970 - * For SLI4 we need to adjust the RQ repost value based on 14971 - * the number of buffers that are initially posted to the RQ. 14972 - */ 14973 - void 14974 - lpfc_rq_adjust_repost(struct lpfc_hba *phba, struct lpfc_queue *rq, int qno) 14975 - { 14976 - uint32_t cnt; 14977 - 14978 - /* sanity check on queue memory */ 14979 - if (!rq) 14980 - return; 14981 - cnt = lpfc_hbq_defs[qno]->entry_count; 14982 - 14983 - /* Recalc repost for RQs based on buffers initially posted */ 14984 - cnt = (cnt >> 3); 14985 - if (cnt < LPFC_QUEUE_MIN_REPOST) 14986 - cnt = LPFC_QUEUE_MIN_REPOST; 14987 - 14988 - rq->entry_repost = cnt; 14989 - } 14990 - 14991 - /** 14992 14868 * lpfc_rq_create - Create a Receive Queue on the HBA 14993 14869 * @phba: HBA structure that indicates port to create a queue on. 14994 14870 * @hrq: The queue structure to use to create the header receive queue. ··· 15145 15077 hrq->subtype = subtype; 15146 15078 hrq->host_index = 0; 15147 15079 hrq->hba_index = 0; 15080 + hrq->entry_repost = LPFC_RQ_REPOST; 15148 15081 15149 15082 /* now create the data queue */ 15150 15083 lpfc_sli4_config(phba, mbox, LPFC_MBOX_SUBSYSTEM_FCOE, ··· 15156 15087 if (phba->sli4_hba.pc_sli4_params.rqv == LPFC_Q_CREATE_VERSION_1) { 15157 15088 bf_set(lpfc_rq_context_rqe_count_1, 15158 15089 &rq_create->u.request.context, hrq->entry_count); 15159 - rq_create->u.request.context.buffer_size = LPFC_DATA_BUF_SIZE; 15090 + if (subtype == LPFC_NVMET) 15091 + rq_create->u.request.context.buffer_size = 15092 + LPFC_NVMET_DATA_BUF_SIZE; 15093 + else 15094 + rq_create->u.request.context.buffer_size = 15095 + LPFC_DATA_BUF_SIZE; 15160 15096 bf_set(lpfc_rq_context_rqe_size, &rq_create->u.request.context, 15161 15097 LPFC_RQE_SIZE_8); 15162 15098 bf_set(lpfc_rq_context_page_size, &rq_create->u.request.context, ··· 15198 15124 LPFC_RQ_RING_SIZE_4096); 15199 15125 break; 15200 15126 } 15201 - bf_set(lpfc_rq_context_buf_size, &rq_create->u.request.context, 15202 - LPFC_DATA_BUF_SIZE); 15127 + if (subtype == LPFC_NVMET) 15128 + bf_set(lpfc_rq_context_buf_size, 15129 + &rq_create->u.request.context, 15130 + LPFC_NVMET_DATA_BUF_SIZE); 15131 + else 15132 + bf_set(lpfc_rq_context_buf_size, 15133 + &rq_create->u.request.context, 15134 + LPFC_DATA_BUF_SIZE); 15203 15135 } 15204 15136 bf_set(lpfc_rq_context_cq_id, &rq_create->u.request.context, 15205 15137 cq->queue_id); ··· 15238 15158 drq->subtype = subtype; 15239 15159 drq->host_index = 0; 15240 15160 drq->hba_index = 0; 15161 + drq->entry_repost = LPFC_RQ_REPOST; 15241 15162 15242 15163 /* link the header and data RQs onto the parent cq child list */ 15243 15164 list_add_tail(&hrq->list, &cq->child_list); ··· 15351 15270 cq->queue_id); 15352 15271 bf_set(lpfc_rq_context_data_size, 15353 15272 &rq_create->u.request.context, 15354 - LPFC_DATA_BUF_SIZE); 15273 + LPFC_NVMET_DATA_BUF_SIZE); 15355 15274 bf_set(lpfc_rq_context_hdr_size, 15356 15275 &rq_create->u.request.context, 15357 15276 LPFC_HDR_BUF_SIZE); ··· 15396 15315 hrq->subtype = subtype; 15397 15316 hrq->host_index = 0; 15398 15317 hrq->hba_index = 0; 15318 + hrq->entry_repost = LPFC_RQ_REPOST; 15399 15319 15400 15320 drq->db_format = LPFC_DB_RING_FORMAT; 15401 15321 drq->db_regaddr = phba->sli4_hba.RQDBregaddr; ··· 15405 15323 drq->subtype = subtype; 15406 15324 drq->host_index = 0; 15407 15325 drq->hba_index = 0; 15326 + drq->entry_repost = LPFC_RQ_REPOST; 15408 15327 15409 15328 list_add_tail(&hrq->list, &cq->child_list); 15410 15329 list_add_tail(&drq->list, &cq->child_list); ··· 16146 16063 struct fc_vft_header *fc_vft_hdr; 16147 16064 uint32_t *header = (uint32_t *) fc_hdr; 16148 16065 16066 + #define FC_RCTL_MDS_DIAGS 0xF4 16067 + 16149 16068 switch (fc_hdr->fh_r_ctl) { 16150 16069 case FC_RCTL_DD_UNCAT: /* uncategorized information */ 16151 16070 case FC_RCTL_DD_SOL_DATA: /* solicited data */ ··· 16175 16090 case FC_RCTL_F_BSY: /* fabric busy to data frame */ 16176 16091 case FC_RCTL_F_BSYL: /* fabric busy to link control frame */ 16177 16092 case FC_RCTL_LCR: /* link credit reset */ 16093 + case FC_RCTL_MDS_DIAGS: /* MDS Diagnostics */ 16178 16094 case FC_RCTL_END: /* end */ 16179 16095 break; 16180 16096 case FC_RCTL_VFTH: /* Virtual Fabric tagging Header */ ··· 16185 16099 default: 16186 16100 goto drop; 16187 16101 } 16102 + 16103 + #define FC_TYPE_VENDOR_UNIQUE 0xFF 16104 + 16188 16105 switch (fc_hdr->fh_type) { 16189 16106 case FC_TYPE_BLS: 16190 16107 case FC_TYPE_ELS: 16191 16108 case FC_TYPE_FCP: 16192 16109 case FC_TYPE_CT: 16193 16110 case FC_TYPE_NVME: 16111 + case FC_TYPE_VENDOR_UNIQUE: 16194 16112 break; 16195 16113 case FC_TYPE_IP: 16196 16114 case FC_TYPE_ILS: ··· 16205 16115 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 16206 16116 "2538 Received frame rctl:%s (x%x), type:%s (x%x), " 16207 16117 "frame Data:%08x %08x %08x %08x %08x %08x %08x\n", 16118 + (fc_hdr->fh_r_ctl == FC_RCTL_MDS_DIAGS) ? "MDS Diags" : 16208 16119 lpfc_rctl_names[fc_hdr->fh_r_ctl], fc_hdr->fh_r_ctl, 16209 - lpfc_type_names[fc_hdr->fh_type], fc_hdr->fh_type, 16210 - be32_to_cpu(header[0]), be32_to_cpu(header[1]), 16211 - be32_to_cpu(header[2]), be32_to_cpu(header[3]), 16212 - be32_to_cpu(header[4]), be32_to_cpu(header[5]), 16213 - be32_to_cpu(header[6])); 16120 + (fc_hdr->fh_type == FC_TYPE_VENDOR_UNIQUE) ? 16121 + "Vendor Unique" : lpfc_type_names[fc_hdr->fh_type], 16122 + fc_hdr->fh_type, be32_to_cpu(header[0]), 16123 + be32_to_cpu(header[1]), be32_to_cpu(header[2]), 16124 + be32_to_cpu(header[3]), be32_to_cpu(header[4]), 16125 + be32_to_cpu(header[5]), be32_to_cpu(header[6])); 16214 16126 return 0; 16215 16127 drop: 16216 16128 lpfc_printf_log(phba, KERN_WARNING, LOG_ELS, ··· 17018 16926 lpfc_sli_release_iocbq(phba, iocbq); 17019 16927 } 17020 16928 16929 + static void 16930 + lpfc_sli4_mds_loopback_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, 16931 + struct lpfc_iocbq *rspiocb) 16932 + { 16933 + struct lpfc_dmabuf *pcmd = cmdiocb->context2; 16934 + 16935 + if (pcmd && pcmd->virt) 16936 + pci_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys); 16937 + kfree(pcmd); 16938 + lpfc_sli_release_iocbq(phba, cmdiocb); 16939 + } 16940 + 16941 + static void 16942 + lpfc_sli4_handle_mds_loopback(struct lpfc_vport *vport, 16943 + struct hbq_dmabuf *dmabuf) 16944 + { 16945 + struct fc_frame_header *fc_hdr; 16946 + struct lpfc_hba *phba = vport->phba; 16947 + struct lpfc_iocbq *iocbq = NULL; 16948 + union lpfc_wqe *wqe; 16949 + struct lpfc_dmabuf *pcmd = NULL; 16950 + uint32_t frame_len; 16951 + int rc; 16952 + 16953 + fc_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; 16954 + frame_len = bf_get(lpfc_rcqe_length, &dmabuf->cq_event.cqe.rcqe_cmpl); 16955 + 16956 + /* Send the received frame back */ 16957 + iocbq = lpfc_sli_get_iocbq(phba); 16958 + if (!iocbq) 16959 + goto exit; 16960 + 16961 + /* Allocate buffer for command payload */ 16962 + pcmd = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); 16963 + if (pcmd) 16964 + pcmd->virt = pci_pool_alloc(phba->lpfc_drb_pool, GFP_KERNEL, 16965 + &pcmd->phys); 16966 + if (!pcmd || !pcmd->virt) 16967 + goto exit; 16968 + 16969 + INIT_LIST_HEAD(&pcmd->list); 16970 + 16971 + /* copyin the payload */ 16972 + memcpy(pcmd->virt, dmabuf->dbuf.virt, frame_len); 16973 + 16974 + /* fill in BDE's for command */ 16975 + iocbq->iocb.un.xseq64.bdl.addrHigh = putPaddrHigh(pcmd->phys); 16976 + iocbq->iocb.un.xseq64.bdl.addrLow = putPaddrLow(pcmd->phys); 16977 + iocbq->iocb.un.xseq64.bdl.bdeFlags = BUFF_TYPE_BDE_64; 16978 + iocbq->iocb.un.xseq64.bdl.bdeSize = frame_len; 16979 + 16980 + iocbq->context2 = pcmd; 16981 + iocbq->vport = vport; 16982 + iocbq->iocb_flag &= ~LPFC_FIP_ELS_ID_MASK; 16983 + iocbq->iocb_flag |= LPFC_USE_FCPWQIDX; 16984 + 16985 + /* 16986 + * Setup rest of the iocb as though it were a WQE 16987 + * Build the SEND_FRAME WQE 16988 + */ 16989 + wqe = (union lpfc_wqe *)&iocbq->iocb; 16990 + 16991 + wqe->send_frame.frame_len = frame_len; 16992 + wqe->send_frame.fc_hdr_wd0 = be32_to_cpu(*((uint32_t *)fc_hdr)); 16993 + wqe->send_frame.fc_hdr_wd1 = be32_to_cpu(*((uint32_t *)fc_hdr + 1)); 16994 + wqe->send_frame.fc_hdr_wd2 = be32_to_cpu(*((uint32_t *)fc_hdr + 2)); 16995 + wqe->send_frame.fc_hdr_wd3 = be32_to_cpu(*((uint32_t *)fc_hdr + 3)); 16996 + wqe->send_frame.fc_hdr_wd4 = be32_to_cpu(*((uint32_t *)fc_hdr + 4)); 16997 + wqe->send_frame.fc_hdr_wd5 = be32_to_cpu(*((uint32_t *)fc_hdr + 5)); 16998 + 16999 + iocbq->iocb.ulpCommand = CMD_SEND_FRAME; 17000 + iocbq->iocb.ulpLe = 1; 17001 + iocbq->iocb_cmpl = lpfc_sli4_mds_loopback_cmpl; 17002 + rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, iocbq, 0); 17003 + if (rc == IOCB_ERROR) 17004 + goto exit; 17005 + 17006 + lpfc_in_buf_free(phba, &dmabuf->dbuf); 17007 + return; 17008 + 17009 + exit: 17010 + lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, 17011 + "2023 Unable to process MDS loopback frame\n"); 17012 + if (pcmd && pcmd->virt) 17013 + pci_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys); 17014 + kfree(pcmd); 17015 + lpfc_sli_release_iocbq(phba, iocbq); 17016 + lpfc_in_buf_free(phba, &dmabuf->dbuf); 17017 + } 17018 + 17021 17019 /** 17022 17020 * lpfc_sli4_handle_received_buffer - Handle received buffers from firmware 17023 17021 * @phba: Pointer to HBA context object. ··· 17145 16963 else 17146 16964 fcfi = bf_get(lpfc_rcqe_fcf_id, 17147 16965 &dmabuf->cq_event.cqe.rcqe_cmpl); 16966 + 16967 + if (fc_hdr->fh_r_ctl == 0xF4 && fc_hdr->fh_type == 0xFF) { 16968 + vport = phba->pport; 16969 + /* Handle MDS Loopback frames */ 16970 + lpfc_sli4_handle_mds_loopback(vport, dmabuf); 16971 + return; 16972 + } 17148 16973 17149 16974 /* d_id this frame is directed to */ 17150 16975 did = sli4_did_from_fc_hdr(fc_hdr); ··· 17326 17137 "status x%x add_status x%x, mbx status x%x\n", 17327 17138 shdr_status, shdr_add_status, rc); 17328 17139 rc = -ENXIO; 17140 + } else { 17141 + /* 17142 + * The next_rpi stores the next logical module-64 rpi value used 17143 + * to post physical rpis in subsequent rpi postings. 17144 + */ 17145 + spin_lock_irq(&phba->hbalock); 17146 + phba->sli4_hba.next_rpi = rpi_page->next_rpi; 17147 + spin_unlock_irq(&phba->hbalock); 17329 17148 } 17330 17149 return rc; 17331 17150 } ··· 18914 18717 18915 18718 spin_lock_irqsave(&pring->ring_lock, iflags); 18916 18719 ctxp = pwqe->context2; 18917 - sglq = ctxp->rqb_buffer->sglq; 18720 + sglq = ctxp->ctxbuf->sglq; 18918 18721 if (pwqe->sli4_xritag == NO_XRI) { 18919 18722 pwqe->sli4_lxritag = sglq->sli4_lxritag; 18920 18723 pwqe->sli4_xritag = sglq->sli4_xritag;
+13 -6
drivers/scsi/lpfc/lpfc_sli4.h
··· 24 24 #define LPFC_XRI_EXCH_BUSY_WAIT_TMO 10000 25 25 #define LPFC_XRI_EXCH_BUSY_WAIT_T1 10 26 26 #define LPFC_XRI_EXCH_BUSY_WAIT_T2 30000 27 - #define LPFC_RELEASE_NOTIFICATION_INTERVAL 32 28 27 #define LPFC_RPI_LOW_WATER_MARK 10 29 28 30 29 #define LPFC_UNREG_FCF 1 ··· 154 155 uint32_t entry_count; /* Number of entries to support on the queue */ 155 156 uint32_t entry_size; /* Size of each queue entry. */ 156 157 uint32_t entry_repost; /* Count of entries before doorbell is rung */ 157 - #define LPFC_QUEUE_MIN_REPOST 8 158 + #define LPFC_EQ_REPOST 8 159 + #define LPFC_MQ_REPOST 8 160 + #define LPFC_CQ_REPOST 64 161 + #define LPFC_RQ_REPOST 64 162 + #define LPFC_RELEASE_NOTIFICATION_INTERVAL 32 /* For WQs */ 158 163 uint32_t queue_id; /* Queue ID assigned by the hardware */ 159 164 uint32_t assoc_qid; /* Queue ID associated with, for CQ/WQ/MQ */ 160 165 uint32_t page_count; /* Number of pages allocated for this queue */ ··· 198 195 /* defines for RQ stats */ 199 196 #define RQ_no_posted_buf q_cnt_1 200 197 #define RQ_no_buf_found q_cnt_2 201 - #define RQ_buf_trunc q_cnt_3 198 + #define RQ_buf_posted q_cnt_3 202 199 #define RQ_rcv_buf q_cnt_4 203 200 204 201 uint64_t isr_timestamp; ··· 620 617 uint16_t scsi_xri_start; 621 618 uint16_t els_xri_cnt; 622 619 uint16_t nvmet_xri_cnt; 620 + uint16_t nvmet_ctx_cnt; 621 + uint16_t nvmet_io_wait_cnt; 622 + uint16_t nvmet_io_wait_total; 623 623 struct list_head lpfc_els_sgl_list; 624 624 struct list_head lpfc_abts_els_sgl_list; 625 625 struct list_head lpfc_nvmet_sgl_list; 626 626 struct list_head lpfc_abts_nvmet_ctx_list; 627 627 struct list_head lpfc_abts_scsi_buf_list; 628 628 struct list_head lpfc_abts_nvme_buf_list; 629 + struct list_head lpfc_nvmet_ctx_list; 630 + struct list_head lpfc_nvmet_io_wait_list; 629 631 struct lpfc_sglq **lpfc_sglq_active_list; 630 632 struct list_head lpfc_rpi_hdr_list; 631 633 unsigned long *rpi_bmask; ··· 662 654 spinlock_t abts_scsi_buf_list_lock; /* list of aborted SCSI IOs */ 663 655 spinlock_t sgl_list_lock; /* list of aborted els IOs */ 664 656 spinlock_t nvmet_io_lock; 657 + spinlock_t nvmet_io_wait_lock; /* IOs waiting for ctx resources */ 665 658 uint32_t physical_port; 666 659 667 660 /* CPU to vector mapping information */ ··· 670 661 uint16_t num_online_cpu; 671 662 uint16_t num_present_cpu; 672 663 uint16_t curr_disp_cpu; 673 - 674 - uint16_t nvmet_mrq_post_idx; 675 664 }; 676 665 677 666 enum lpfc_sge_type { ··· 705 698 struct lpfc_dmabuf *dmabuf; 706 699 uint32_t page_count; 707 700 uint32_t start_rpi; 701 + uint16_t next_rpi; 708 702 }; 709 703 710 704 struct lpfc_rsrc_blks { ··· 770 762 int lpfc_mrq_create(struct lpfc_hba *phba, struct lpfc_queue **hrqp, 771 763 struct lpfc_queue **drqp, struct lpfc_queue **cqp, 772 764 uint32_t subtype); 773 - void lpfc_rq_adjust_repost(struct lpfc_hba *, struct lpfc_queue *, int); 774 765 int lpfc_eq_destroy(struct lpfc_hba *, struct lpfc_queue *); 775 766 int lpfc_cq_destroy(struct lpfc_hba *, struct lpfc_queue *); 776 767 int lpfc_mq_destroy(struct lpfc_hba *, struct lpfc_queue *);
+1 -1
drivers/scsi/lpfc/lpfc_version.h
··· 20 20 * included with this package. * 21 21 *******************************************************************/ 22 22 23 - #define LPFC_DRIVER_VERSION "11.2.0.12" 23 + #define LPFC_DRIVER_VERSION "11.2.0.14" 24 24 #define LPFC_DRIVER_NAME "lpfc" 25 25 26 26 /* Used for SLI 2/3 */
+1 -1
drivers/scsi/scsi_lib.c
··· 1851 1851 1852 1852 /* zero out the cmd, except for the embedded scsi_request */ 1853 1853 memset((char *)cmd + sizeof(cmd->req), 0, 1854 - sizeof(*cmd) - sizeof(cmd->req)); 1854 + sizeof(*cmd) - sizeof(cmd->req) + shost->hostt->cmd_size); 1855 1855 1856 1856 req->special = cmd; 1857 1857
+47 -16
drivers/scsi/sd.c
··· 827 827 struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); 828 828 u64 sector = blk_rq_pos(rq) >> (ilog2(sdp->sector_size) - 9); 829 829 u32 nr_sectors = blk_rq_sectors(rq) >> (ilog2(sdp->sector_size) - 9); 830 + int ret; 830 831 831 832 if (!(rq->cmd_flags & REQ_NOUNMAP)) { 832 833 switch (sdkp->zeroing_mode) { 833 834 case SD_ZERO_WS16_UNMAP: 834 - return sd_setup_write_same16_cmnd(cmd, true); 835 + ret = sd_setup_write_same16_cmnd(cmd, true); 836 + goto out; 835 837 case SD_ZERO_WS10_UNMAP: 836 - return sd_setup_write_same10_cmnd(cmd, true); 838 + ret = sd_setup_write_same10_cmnd(cmd, true); 839 + goto out; 837 840 } 838 841 } 839 842 840 843 if (sdp->no_write_same) 841 844 return BLKPREP_INVALID; 845 + 842 846 if (sdkp->ws16 || sector > 0xffffffff || nr_sectors > 0xffff) 843 - return sd_setup_write_same16_cmnd(cmd, false); 844 - return sd_setup_write_same10_cmnd(cmd, false); 847 + ret = sd_setup_write_same16_cmnd(cmd, false); 848 + else 849 + ret = sd_setup_write_same10_cmnd(cmd, false); 850 + 851 + out: 852 + if (sd_is_zoned(sdkp) && ret == BLKPREP_OK) 853 + return sd_zbc_write_lock_zone(cmd); 854 + 855 + return ret; 845 856 } 846 857 847 858 static void sd_config_write_same(struct scsi_disk *sdkp) ··· 959 948 rq->__data_len = sdp->sector_size; 960 949 ret = scsi_init_io(cmd); 961 950 rq->__data_len = nr_bytes; 951 + 952 + if (sd_is_zoned(sdkp) && ret != BLKPREP_OK) 953 + sd_zbc_write_unlock_zone(cmd); 954 + 962 955 return ret; 963 956 } 964 957 ··· 1582 1567 return retval; 1583 1568 } 1584 1569 1585 - static int sd_sync_cache(struct scsi_disk *sdkp) 1570 + static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) 1586 1571 { 1587 1572 int retries, res; 1588 1573 struct scsi_device *sdp = sdkp->device; 1589 1574 const int timeout = sdp->request_queue->rq_timeout 1590 1575 * SD_FLUSH_TIMEOUT_MULTIPLIER; 1591 - struct scsi_sense_hdr sshdr; 1576 + struct scsi_sense_hdr my_sshdr; 1592 1577 1593 1578 if (!scsi_device_online(sdp)) 1594 1579 return -ENODEV; 1580 + 1581 + /* caller might not be interested in sense, but we need it */ 1582 + if (!sshdr) 1583 + sshdr = &my_sshdr; 1595 1584 1596 1585 for (retries = 3; retries > 0; --retries) { 1597 1586 unsigned char cmd[10] = { 0 }; ··· 1605 1586 * Leave the rest of the command zero to indicate 1606 1587 * flush everything. 1607 1588 */ 1608 - res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr, 1589 + res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, sshdr, 1609 1590 timeout, SD_MAX_RETRIES, 0, RQF_PM, NULL); 1610 1591 if (res == 0) 1611 1592 break; ··· 1615 1596 sd_print_result(sdkp, "Synchronize Cache(10) failed", res); 1616 1597 1617 1598 if (driver_byte(res) & DRIVER_SENSE) 1618 - sd_print_sense_hdr(sdkp, &sshdr); 1599 + sd_print_sense_hdr(sdkp, sshdr); 1600 + 1619 1601 /* we need to evaluate the error return */ 1620 - if (scsi_sense_valid(&sshdr) && 1621 - (sshdr.asc == 0x3a || /* medium not present */ 1622 - sshdr.asc == 0x20)) /* invalid command */ 1602 + if (scsi_sense_valid(sshdr) && 1603 + (sshdr->asc == 0x3a || /* medium not present */ 1604 + sshdr->asc == 0x20)) /* invalid command */ 1623 1605 /* this is no error here */ 1624 1606 return 0; 1625 1607 ··· 3464 3444 3465 3445 if (sdkp->WCE && sdkp->media_present) { 3466 3446 sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); 3467 - sd_sync_cache(sdkp); 3447 + sd_sync_cache(sdkp, NULL); 3468 3448 } 3469 3449 3470 3450 if (system_state != SYSTEM_RESTART && sdkp->device->manage_start_stop) { ··· 3476 3456 static int sd_suspend_common(struct device *dev, bool ignore_stop_errors) 3477 3457 { 3478 3458 struct scsi_disk *sdkp = dev_get_drvdata(dev); 3459 + struct scsi_sense_hdr sshdr; 3479 3460 int ret = 0; 3480 3461 3481 3462 if (!sdkp) /* E.g.: runtime suspend following sd_remove() */ ··· 3484 3463 3485 3464 if (sdkp->WCE && sdkp->media_present) { 3486 3465 sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); 3487 - ret = sd_sync_cache(sdkp); 3466 + ret = sd_sync_cache(sdkp, &sshdr); 3467 + 3488 3468 if (ret) { 3489 3469 /* ignore OFFLINE device */ 3490 3470 if (ret == -ENODEV) 3491 - ret = 0; 3492 - goto done; 3471 + return 0; 3472 + 3473 + if (!scsi_sense_valid(&sshdr) || 3474 + sshdr.sense_key != ILLEGAL_REQUEST) 3475 + return ret; 3476 + 3477 + /* 3478 + * sshdr.sense_key == ILLEGAL_REQUEST means this drive 3479 + * doesn't support sync. There's not much to do and 3480 + * suspend shouldn't fail. 3481 + */ 3482 + ret = 0; 3493 3483 } 3494 3484 } 3495 3485 ··· 3512 3480 ret = 0; 3513 3481 } 3514 3482 3515 - done: 3516 3483 return ret; 3517 3484 } 3518 3485
+3 -2
drivers/scsi/sg.c
··· 2074 2074 if ((1 == resp->done) && (!resp->sg_io_owned) && 2075 2075 ((-1 == pack_id) || (resp->header.pack_id == pack_id))) { 2076 2076 resp->done = 2; /* guard against other readers */ 2077 - break; 2077 + write_unlock_irqrestore(&sfp->rq_list_lock, iflags); 2078 + return resp; 2078 2079 } 2079 2080 } 2080 2081 write_unlock_irqrestore(&sfp->rq_list_lock, iflags); 2081 - return resp; 2082 + return NULL; 2082 2083 } 2083 2084 2084 2085 /* always adds to end of list */
+7
drivers/scsi/ufs/ufshcd.c
··· 7698 7698 ufshcd_add_spm_lvl_sysfs_nodes(hba); 7699 7699 } 7700 7700 7701 + static inline void ufshcd_remove_sysfs_nodes(struct ufs_hba *hba) 7702 + { 7703 + device_remove_file(hba->dev, &hba->rpm_lvl_attr); 7704 + device_remove_file(hba->dev, &hba->spm_lvl_attr); 7705 + } 7706 + 7701 7707 /** 7702 7708 * ufshcd_shutdown - shutdown routine 7703 7709 * @hba: per adapter instance ··· 7741 7735 */ 7742 7736 void ufshcd_remove(struct ufs_hba *hba) 7743 7737 { 7738 + ufshcd_remove_sysfs_nodes(hba); 7744 7739 scsi_remove_host(hba->host); 7745 7740 /* disable interrupts */ 7746 7741 ufshcd_disable_intr(hba, hba->intr_mask);