History

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

Pull SCSI updates from James Bottomley: "This consists of a small set of driver updates (lpfc, ufs, mpt3sas mpi3mr, iscsi target). Apart from that this is mostly small fixes with very few core changes (the biggest one being VPD caching)" * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (177 commits) scsi: target: tcmu: Avoid holding XArray lock when calling lock_page scsi: elx: efct: Remove NULL check after calling container_of() scsi: dpt_i2o: Drop redundant spinlock initialization scsi: qedf: Remove redundant variable op scsi: hisi_sas: Fix memory ordering in hisi_sas_task_deliver() scsi: fnic: Replace DMA mask of 64 bits with 47 bits scsi: mpi3mr: Add target device related sysfs attributes scsi: mpi3mr: Add shost related sysfs attributes scsi: elx: efct: Remove redundant memset() statement scsi: megaraid_sas: Remove redundant memset() statement scsi: mpi3mr: Return error if dma_alloc_coherent() fails scsi: hisi_sas: Fix rescan after deleting a disk scsi: hisi_sas: Use sas_ata_wait_after_reset() in IT nexus reset scsi: libsas: Refactor sas_ata_hard_reset() scsi: mpt3sas: Update driver version to 42.100.00.00 scsi: mpt3sas: Fix junk chars displayed while printing ChipName scsi: ipr: Use kobj_to_dev() scsi: mpi3mr: Fix a NULL vs IS_ERR() bug in mpi3mr_bsg_init() scsi: bnx2fc: Avoid using get_cpu() in bnx2fc_cmd_alloc() scsi: libfc: Remove get_cpu() semantics in fc_exch_em_alloc() ...

Linus Torvalds committed 4 years ago

Commit fbe86da2 parents d722778 325d5c5169 files · +6840 −3470Browse files

Unified · Split

169 files
  1. Documentation/ABI/testing/sysfs-driver-ufs +11 −7
  2. drivers/infiniband/ulp/isert/ib_isert.c +52 −52
  3. drivers/infiniband/ulp/isert/ib_isert.h +2 −2
  4. drivers/message/fusion/mptctl.c +0 −3
  5. drivers/scsi/aacraid/aacraid.h +1 −1
  6. drivers/scsi/aha1542.c +10 −10
  7. drivers/scsi/bfa/bfad_debugfs.c +1 −2
  8. drivers/scsi/bfa/bfad_im.c +0 −1
  9. drivers/scsi/bnx2fc/bnx2fc_fcoe.c +6 −16
  10. drivers/scsi/bnx2fc/bnx2fc_io.c +6 −11
  11. drivers/scsi/dc395x.c +12 −3
  12. drivers/scsi/dpt_i2o.c +0 −1
  13. drivers/scsi/elx/efct/efct_hw.c +0 −1
  14. drivers/scsi/elx/efct/efct_io.c +0 −1
  15. drivers/scsi/elx/efct/efct_lio.c +0 −3
  16. drivers/scsi/fcoe/fcoe.c +17 −27
  17. drivers/scsi/fcoe/fcoe_ctlr.c +9 −17
  18. drivers/scsi/fcoe/fcoe_transport.c +3 −3
  19. drivers/scsi/fnic/fnic.h +1 −1
  20. drivers/scsi/fnic/fnic_debugfs.c +1 −2
  21. drivers/scsi/fnic/fnic_main.c +4 −6
  22. drivers/scsi/hisi_sas/hisi_sas_main.c +32 −36
  23. drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +8 −2
  24. drivers/scsi/hosts.c +4 −4
  25. drivers/scsi/ipr.c +6 −7
  26. drivers/scsi/libfc/fc_exch.c +1 −2
  27. drivers/scsi/libfc/fc_fcp.c +10 −19
  28. drivers/scsi/libfc/fc_lport.c +15 −15
  29. drivers/scsi/libsas/sas_ata.c +27 −14
  30. drivers/scsi/lpfc/lpfc.h +7 −3
  31. drivers/scsi/lpfc/lpfc_attr.c +41 −14
  32. drivers/scsi/lpfc/lpfc_bsg.c +36 −45
  33. drivers/scsi/lpfc/lpfc_crtn.h +4 −1
  34. drivers/scsi/lpfc/lpfc_ct.c +246 −120
  35. drivers/scsi/lpfc/lpfc_els.c +338 −377
  36. drivers/scsi/lpfc/lpfc_hbadisc.c +63 −101
  37. drivers/scsi/lpfc/lpfc_hw.h +44 −31
  38. drivers/scsi/lpfc/lpfc_hw4.h +12 −5
  39. drivers/scsi/lpfc/lpfc_init.c +131 −143
  40. drivers/scsi/lpfc/lpfc_logmsg.h +4 −4
  41. drivers/scsi/lpfc/lpfc_mbox.c +120 −83
  42. drivers/scsi/lpfc/lpfc_nportdisc.c +38 −41
  43. drivers/scsi/lpfc/lpfc_nvme.c +25 −19
  44. drivers/scsi/lpfc/lpfc_nvmet.c +37 −36
  45. drivers/scsi/lpfc/lpfc_scsi.c +34 −38
  46. drivers/scsi/lpfc/lpfc_sli.c +129 −141
  47. drivers/scsi/lpfc/lpfc_sli.h +24 −10
  48. drivers/scsi/lpfc/lpfc_sli4.h +3 −0
  49. drivers/scsi/lpfc/lpfc_version.h +1 −1
  50. drivers/scsi/lpfc/lpfc_vport.c +14 −17
  51. drivers/scsi/mac53c94.c +1 −1
  52. drivers/scsi/megaraid.c +1 −1
  53. drivers/scsi/megaraid/megaraid_sas_base.c +0 −2
  54. drivers/scsi/megaraid/megaraid_sas_fusion.c +0 −2
  55. drivers/scsi/mpi3mr/Kconfig +1 −0
  56. drivers/scsi/mpi3mr/Makefile +1 −0
  57. drivers/scsi/mpi3mr/mpi/mpi30_init.h +0 −53
  58. drivers/scsi/mpi3mr/mpi/mpi30_ioc.h +0 −27
  59. drivers/scsi/mpi3mr/mpi/mpi30_pci.h +1 −30
  60. drivers/scsi/mpi3mr/mpi3mr.h +130 −7
  61. drivers/scsi/mpi3mr/mpi3mr_app.c +1864 −0
  62. drivers/scsi/mpi3mr/mpi3mr_debug.h +31 −6
  63. drivers/scsi/mpi3mr/mpi3mr_fw.c +332 −3
  64. drivers/scsi/mpi3mr/mpi3mr_os.c +66 −5
  65. drivers/scsi/mpt3sas/mpt3sas_base.c +17 −17
  66. drivers/scsi/mpt3sas/mpt3sas_base.h +3 −3
  67. drivers/scsi/mpt3sas/mpt3sas_ctl.c +6 −5
  68. drivers/scsi/mpt3sas/mpt3sas_scsih.c +11 −13
  69. drivers/scsi/pmcraid.c +1 −1
  70. drivers/scsi/qedf/qedf_attr.c +0 −2
  71. drivers/scsi/qedf/qedf_io.c +1 −2
  72. drivers/scsi/qedf/qedf_main.c +5 −8
  73. drivers/scsi/qla2xxx/qla_edif.c +1 −2
  74. drivers/scsi/qla2xxx/qla_os.c +0 −1
  75. drivers/scsi/qla2xxx/qla_target.c +0 −2
  76. drivers/scsi/qla2xxx/qla_target.h +0 −1
  77. drivers/scsi/qla4xxx/ql4_os.c +0 −1
  78. drivers/scsi/scsi.c +79 −37
  79. drivers/scsi/scsi_debug.c +114 −35
  80. drivers/scsi/scsi_lib.c +1 −1
  81. drivers/scsi/scsi_scan.c +11 −1
  82. drivers/scsi/scsi_sysfs.c +28 −0
  83. drivers/scsi/sd.c +118 −75
  84. drivers/scsi/sd.h +26 −7
  85. drivers/scsi/sd_dif.c +3 −5
  86. drivers/scsi/sd_zbc.c +184 −52
  87. drivers/scsi/sr.c +8 −6
  88. drivers/scsi/ufs/Kconfig +1 −25
  89. drivers/scsi/ufs/cdns-pltfrm.c +1 −1
  90. drivers/scsi/ufs/tc-dwc-g210-pci.c +1 −0
  91. drivers/scsi/ufs/tc-dwc-g210-pltfrm.c +1 −0
  92. drivers/scsi/ufs/tc-dwc-g210.c +2 −0
  93. drivers/scsi/ufs/tc-dwc-g210.h +2 −0
  94. drivers/scsi/ufs/ti-j721e-ufs.c +2 −4
  95. drivers/scsi/ufs/ufs-debugfs.c +1 −0
  96. drivers/scsi/ufs/ufs-exynos.c +3 −2
  97. drivers/scsi/ufs/ufs-exynos.h +4 −4
  98. drivers/scsi/ufs/ufs-hisi.c +2 −0
  99. drivers/scsi/ufs/ufs-hwmon.c +1 −0
  100. drivers/scsi/ufs/ufs-mediatek.c +12 −19
  101. drivers/scsi/ufs/ufs-qcom-ice.c +1 −1
  102. drivers/scsi/ufs/ufs-qcom.c +25 −48
  103. drivers/scsi/ufs/ufs-qcom.h +2 −4
  104. drivers/scsi/ufs/ufs-sysfs.c +1 −0
  105. drivers/scsi/ufs/ufs-sysfs.h +2 −1
  106. drivers/scsi/ufs/ufs.h +0 −35
  107. drivers/scsi/ufs/ufs_bsg.c +6 −0
  108. drivers/scsi/ufs/ufs_bsg.h +1 −6
  109. drivers/scsi/ufs/ufs_quirks.h +3 −12
  110. drivers/scsi/ufs/ufshcd-crypto.h +4 −1
  111. drivers/scsi/ufs/ufshcd-dwc.c +2 −0
  112. drivers/scsi/ufs/ufshcd-dwc.h +2 −0
  113. drivers/scsi/ufs/ufshcd-pci.c +2 −2
  114. drivers/scsi/ufs/ufshcd-pltfrm.c +20 −18
  115. drivers/scsi/ufs/ufshcd-priv.h +298 −0
  116. drivers/scsi/ufs/ufshcd.c +116 −131
  117. drivers/scsi/ufs/ufshcd.h +80 −288
  118. drivers/scsi/ufs/ufshci.h +2 −0
  119. drivers/scsi/ufs/ufshpb.c +112 −91
  120. drivers/scsi/ufs/ufshpb.h +7 −9
  121. drivers/scsi/ufs/unipro.h +1 −17
  122. drivers/scsi/vmw_pvscsi.c +0 −1
  123. drivers/target/iscsi/cxgbit/cxgbit.h +11 −11
  124. drivers/target/iscsi/cxgbit/cxgbit_cm.c +4 −4
  125. drivers/target/iscsi/cxgbit/cxgbit_ddp.c +2 −2
  126. drivers/target/iscsi/cxgbit/cxgbit_main.c +1 −1
  127. drivers/target/iscsi/cxgbit/cxgbit_target.c +36 −36
  128. drivers/target/iscsi/iscsi_target.c +136 −136
  129. drivers/target/iscsi/iscsi_target.h +15 −15
  130. drivers/target/iscsi/iscsi_target_auth.c +5 −5
  131. drivers/target/iscsi/iscsi_target_auth.h +2 −2
  132. drivers/target/iscsi/iscsi_target_configfs.c +17 −17
  133. drivers/target/iscsi/iscsi_target_datain_values.c +14 −14
  134. drivers/target/iscsi/iscsi_target_datain_values.h +6 −6
  135. drivers/target/iscsi/iscsi_target_device.c +2 −2
  136. drivers/target/iscsi/iscsi_target_device.h +4 −4
  137. drivers/target/iscsi/iscsi_target_erl0.c +34 −34
  138. drivers/target/iscsi/iscsi_target_erl0.h +12 −12
  139. drivers/target/iscsi/iscsi_target_erl1.c +46 −46
  140. drivers/target/iscsi/iscsi_target_erl1.h +20 −20
  141. drivers/target/iscsi/iscsi_target_erl2.c +24 −24
  142. drivers/target/iscsi/iscsi_target_erl2.h +13 −13
  143. drivers/target/iscsi/iscsi_target_login.c +39 −39
  144. drivers/target/iscsi/iscsi_target_login.h +11 −11
  145. drivers/target/iscsi/iscsi_target_nego.c +30 −30
  146. drivers/target/iscsi/iscsi_target_nego.h +6 −6
  147. drivers/target/iscsi/iscsi_target_nodeattrib.c +2 −2
  148. drivers/target/iscsi/iscsi_target_parameters.c +4 −4
  149. drivers/target/iscsi/iscsi_target_parameters.h +4 −4
  150. drivers/target/iscsi/iscsi_target_seq_pdu_list.c +22 −22
  151. drivers/target/iscsi/iscsi_target_seq_pdu_list.h +5 −5
  152. drivers/target/iscsi/iscsi_target_stat.c +8 −8
  153. drivers/target/iscsi/iscsi_target_tmr.c +36 −36
  154. drivers/target/iscsi/iscsi_target_tmr.h +8 −8
  155. drivers/target/iscsi/iscsi_target_tpg.c +1 −1
  156. drivers/target/iscsi/iscsi_target_tpg.h +2 −2
  157. drivers/target/iscsi/iscsi_target_util.c +82 −82
  158. drivers/target/iscsi/iscsi_target_util.h +51 −51
  159. drivers/target/target_core_configfs.c +28 −19
  160. drivers/target/target_core_spc.c +1 −1
  161. drivers/target/target_core_user.c +42 −8
  162. include/scsi/libfcoe.h +2 −0
  163. include/scsi/libiscsi.h +3 −3
  164. include/scsi/sas_ata.h +7 −0
  165. include/scsi/scsi_device.h +8 −1
  166. include/scsi/scsi_proto.h +8 −1
  167. include/target/iscsi/iscsi_target_core.h +26 −26
  168. include/target/iscsi/iscsi_transport.h +63 −63
  169. include/uapi/scsi/scsi_bsg_mpi3mr.h +582 −0
Documentation/ABI/testing/sysfs-driver-ufs+11−7
@@ -1518,7 +1518,7 @@ Description: This entry shows the number of reads that cannot be changed to · 1517 unmodified lines
15181518
15191519 The file is read only.
15201520
1521−What: /sys/class/scsi_device/*/device/hpb_stats/rb_noti_cnt
1521+What: /sys/class/scsi_device/*/device/hpb_stats/rcmd_noti_cnt
15221522 Date: June 2021
15231523 Contact: Daejun Park <daejun7.park@samsung.com>
15241524 Description: This entry shows the number of response UPIUs that has
@@ -1526,19 +1526,23 @@ Description: This entry shows the number of response UPIUs that has · 1 unmodified line
15261526
15271527 The file is read only.
15281528
1529−What: /sys/class/scsi_device/*/device/hpb_stats/rb_active_cnt
1529+What: /sys/class/scsi_device/*/device/hpb_stats/rcmd_active_cnt
15301530 Date: June 2021
15311531 Contact: Daejun Park <daejun7.park@samsung.com>
1532−Description: This entry shows the number of active sub-regions recommended by
1533− response UPIUs.
1532+Description: For the HPB device control mode, this entry shows the number of
1533+ active sub-regions recommended by response UPIUs. For the HPB host control
1534+ mode, this entry shows the number of active sub-regions recommended by the
1535+ HPB host control mode heuristic algorithm.
15341536
15351537 The file is read only.
15361538
1537−What: /sys/class/scsi_device/*/device/hpb_stats/rb_inactive_cnt
1539+What: /sys/class/scsi_device/*/device/hpb_stats/rcmd_inactive_cnt
15381540 Date: June 2021
15391541 Contact: Daejun Park <daejun7.park@samsung.com>
1540−Description: This entry shows the number of inactive regions recommended by
1541− response UPIUs.
1542+Description: For the HPB device control mode, this entry shows the number of
1543+ inactive regions recommended by response UPIUs. For the HPB host control
1544+ mode, this entry shows the number of inactive regions recommended by the
1545+ HPB host control mode heuristic algorithm.
15421546
15431547 The file is read only.
15441548
drivers/infiniband/ulp/isert/ib_isert.c+52−52
@@ -46,7 +46,7 @@ static struct workqueue_struct *isert_comp_wq; · 45 unmodified lines
4646 static struct workqueue_struct *isert_release_wq;
4747
4848 static int
49−isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd);
49+isert_put_response(struct iscsit_conn *conn, struct iscsit_cmd *cmd);
5050 static int
5151 isert_login_post_recv(struct isert_conn *isert_conn);
5252 static int
@@ -909,7 +909,7 @@ isert_login_post_recv(struct isert_conn *isert_conn) · 856 unmodified lines
909909 }
910910
911911 static int
912−isert_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login,
912+isert_put_login_tx(struct iscsit_conn *conn, struct iscsi_login *login,
913913 u32 length)
914914 {
915915 struct isert_conn *isert_conn = conn->context;
@@ -976,7 +976,7 @@ isert_rx_login_req(struct isert_conn *isert_conn) · 60 unmodified lines
976976 {
977977 struct iser_rx_desc *rx_desc = isert_conn->login_desc;
978978 int rx_buflen = isert_conn->login_req_len;
979− struct iscsi_conn *conn = isert_conn->conn;
979+ struct iscsit_conn *conn = isert_conn->conn;
980980 struct iscsi_login *login = conn->conn_login;
981981 int size;
982982
@@ -1020,21 +1020,21 @@ isert_rx_login_req(struct isert_conn *isert_conn) · 37 unmodified lines
10201020 schedule_delayed_work(&conn->login_work, 0);
10211021 }
10221022
1023−static struct iscsi_cmd
1024−*isert_allocate_cmd(struct iscsi_conn *conn, struct iser_rx_desc *rx_desc)
1023+static struct iscsit_cmd
1024+*isert_allocate_cmd(struct iscsit_conn *conn, struct iser_rx_desc *rx_desc)
10251025 {
10261026 struct isert_conn *isert_conn = conn->context;
10271027 struct isert_cmd *isert_cmd;
1028− struct iscsi_cmd *cmd;
1028+ struct iscsit_cmd *cmd;
10291029
10301030 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);
10311031 if (!cmd) {
1032− isert_err("Unable to allocate iscsi_cmd + isert_cmd\n");
1032+ isert_err("Unable to allocate iscsit_cmd + isert_cmd\n");
10331033 return NULL;
10341034 }
10351035 isert_cmd = iscsit_priv_cmd(cmd);
10361036 isert_cmd->conn = isert_conn;
1037− isert_cmd->iscsi_cmd = cmd;
1037+ isert_cmd->iscsit_cmd = cmd;
10381038 isert_cmd->rx_desc = rx_desc;
10391039
10401040 return cmd;
@@ -1042,10 +1042,10 @@ static struct iscsi_cmd · 1 unmodified line
10421042
10431043 static int
10441044 isert_handle_scsi_cmd(struct isert_conn *isert_conn,
1045− struct isert_cmd *isert_cmd, struct iscsi_cmd *cmd,
1045+ struct isert_cmd *isert_cmd, struct iscsit_cmd *cmd,
10461046 struct iser_rx_desc *rx_desc, unsigned char *buf)
10471047 {
1048− struct iscsi_conn *conn = isert_conn->conn;
1048+ struct iscsit_conn *conn = isert_conn->conn;
10491049 struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)buf;
10501050 int imm_data, imm_data_len, unsol_data, sg_nents, rc;
10511051 bool dump_payload = false;
@@ -1114,8 +1114,8 @@ isert_handle_iscsi_dataout(struct isert_conn *isert_conn, · 62 unmodified lines
11141114 struct iser_rx_desc *rx_desc, unsigned char *buf)
11151115 {
11161116 struct scatterlist *sg_start;
1117− struct iscsi_conn *conn = isert_conn->conn;
1118− struct iscsi_cmd *cmd = NULL;
1117+ struct iscsit_conn *conn = isert_conn->conn;
1118+ struct iscsit_cmd *cmd = NULL;
11191119 struct iscsi_data *hdr = (struct iscsi_data *)buf;
11201120 u32 unsol_data_len = ntoh24(hdr->dlength);
11211121 int rc, sg_nents, sg_off, page_off;
@@ -1171,10 +1171,10 @@ isert_handle_iscsi_dataout(struct isert_conn *isert_conn, · 49 unmodified lines
11711171
11721172 static int
11731173 isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,
1174− struct iscsi_cmd *cmd, struct iser_rx_desc *rx_desc,
1174+ struct iscsit_cmd *cmd, struct iser_rx_desc *rx_desc,
11751175 unsigned char *buf)
11761176 {
1177− struct iscsi_conn *conn = isert_conn->conn;
1177+ struct iscsit_conn *conn = isert_conn->conn;
11781178 struct iscsi_nopout *hdr = (struct iscsi_nopout *)buf;
11791179 int rc;
11801180
@@ -1190,10 +1190,10 @@ isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, · 9 unmodified lines
11901190
11911191 static int
11921192 isert_handle_text_cmd(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,
1193− struct iscsi_cmd *cmd, struct iser_rx_desc *rx_desc,
1193+ struct iscsit_cmd *cmd, struct iser_rx_desc *rx_desc,
11941194 struct iscsi_text *hdr)
11951195 {
1196− struct iscsi_conn *conn = isert_conn->conn;
1196+ struct iscsit_conn *conn = isert_conn->conn;
11971197 u32 payload_length = ntoh24(hdr->dlength);
11981198 int rc;
11991199 unsigned char *text_in = NULL;
@@ -1220,8 +1220,8 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc, · 20 unmodified lines
12201220 uint32_t write_stag, uint64_t write_va)
12211221 {
12221222 struct iscsi_hdr *hdr = isert_get_iscsi_hdr(rx_desc);
1223− struct iscsi_conn *conn = isert_conn->conn;
1224− struct iscsi_cmd *cmd;
1223+ struct iscsit_conn *conn = isert_conn->conn;
1224+ struct iscsit_cmd *cmd;
12251225 struct isert_cmd *isert_cmd;
12261226 int ret = -EINVAL;
12271227 u8 opcode = (hdr->opcode & ISCSI_OPCODE_MASK);
@@ -1404,7 +1404,7 @@ isert_login_recv_done(struct ib_cq *cq, struct ib_wc *wc) · 176 unmodified lines
14041404 static void
14051405 isert_rdma_rw_ctx_destroy(struct isert_cmd *cmd, struct isert_conn *conn)
14061406 {
1407− struct se_cmd *se_cmd = &cmd->iscsi_cmd->se_cmd;
1407+ struct se_cmd *se_cmd = &cmd->iscsit_cmd->se_cmd;
14081408 enum dma_data_direction dir = target_reverse_dma_direction(se_cmd);
14091409
14101410 if (!cmd->rw.nr_ops)
@@ -1426,9 +1426,9 @@ isert_rdma_rw_ctx_destroy(struct isert_cmd *cmd, struct isert_conn *conn) · 15 unmodified lines
14261426 static void
14271427 isert_put_cmd(struct isert_cmd *isert_cmd, bool comp_err)
14281428 {
1429− struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;
1429+ struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd;
14301430 struct isert_conn *isert_conn = isert_cmd->conn;
1431− struct iscsi_conn *conn = isert_conn->conn;
1431+ struct iscsit_conn *conn = isert_conn->conn;
14321432 struct iscsi_text_rsp *hdr;
14331433
14341434 isert_dbg("Cmd %p\n", isert_cmd);
@@ -1575,7 +1575,7 @@ isert_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc) · 140 unmodified lines
15751575 struct isert_device *device = isert_conn->device;
15761576 struct iser_tx_desc *desc = cqe_to_tx_desc(wc->wr_cqe);
15771577 struct isert_cmd *isert_cmd = tx_desc_to_cmd(desc);
1578− struct se_cmd *cmd = &isert_cmd->iscsi_cmd->se_cmd;
1578+ struct se_cmd *cmd = &isert_cmd->iscsit_cmd->se_cmd;
15791579 int ret = 0;
15801580
15811581 if (unlikely(wc->status != IB_WC_SUCCESS)) {
@@ -1604,7 +1604,7 @@ isert_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc) · 22 unmodified lines
16041604 /*
16051605 * XXX: isert_put_response() failure is not retried.
16061606 */
1607− ret = isert_put_response(isert_conn->conn, isert_cmd->iscsi_cmd);
1607+ ret = isert_put_response(isert_conn->conn, isert_cmd->iscsit_cmd);
16081608 if (ret)
16091609 pr_warn_ratelimited("isert_put_response() ret: %d\n", ret);
16101610 }
@@ -1617,7 +1617,7 @@ isert_rdma_read_done(struct ib_cq *cq, struct ib_wc *wc) · 6 unmodified lines
16171617 struct isert_device *device = isert_conn->device;
16181618 struct iser_tx_desc *desc = cqe_to_tx_desc(wc->wr_cqe);
16191619 struct isert_cmd *isert_cmd = tx_desc_to_cmd(desc);
1620− struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;
1620+ struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd;
16211621 struct se_cmd *se_cmd = &cmd->se_cmd;
16221622 int ret = 0;
16231623
@@ -1662,7 +1662,7 @@ isert_do_control_comp(struct work_struct *work) · 38 unmodified lines
16621662 struct isert_cmd, comp_work);
16631663 struct isert_conn *isert_conn = isert_cmd->conn;
16641664 struct ib_device *ib_dev = isert_conn->cm_id->device;
1665− struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;
1665+ struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd;
16661666
16671667 isert_dbg("Cmd %p i_state %d\n", isert_cmd, cmd->i_state);
16681668
@@ -1720,7 +1720,7 @@ isert_send_done(struct ib_cq *cq, struct ib_wc *wc) · 51 unmodified lines
17201720
17211721 isert_dbg("Cmd %p\n", isert_cmd);
17221722
1723− switch (isert_cmd->iscsi_cmd->i_state) {
1723+ switch (isert_cmd->iscsit_cmd->i_state) {
17241724 case ISTATE_SEND_TASKMGTRSP:
17251725 case ISTATE_SEND_LOGOUTRSP:
17261726 case ISTATE_SEND_REJECT:
@@ -1731,7 +1731,7 @@ isert_send_done(struct ib_cq *cq, struct ib_wc *wc) · 4 unmodified lines
17311731 queue_work(isert_comp_wq, &isert_cmd->comp_work);
17321732 return;
17331733 default:
1734− isert_cmd->iscsi_cmd->i_state = ISTATE_SENT_STATUS;
1734+ isert_cmd->iscsit_cmd->i_state = ISTATE_SENT_STATUS;
17351735 isert_completion_put(tx_desc, isert_cmd, ib_dev, false);
17361736 break;
17371737 }
@@ -1755,7 +1755,7 @@ isert_post_response(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd) · 17 unmodified lines
17551755 }
17561756
17571757 static int
1758−isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
1758+isert_put_response(struct iscsit_conn *conn, struct iscsit_cmd *cmd)
17591759 {
17601760 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
17611761 struct isert_conn *isert_conn = conn->context;
@@ -1806,7 +1806,7 @@ isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd) · 44 unmodified lines
18061806 }
18071807
18081808 static void
1809−isert_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
1809+isert_aborted_task(struct iscsit_conn *conn, struct iscsit_cmd *cmd)
18101810 {
18111811 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
18121812 struct isert_conn *isert_conn = conn->context;
@@ -1822,7 +1822,7 @@ isert_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd) · 9 unmodified lines
18221822 }
18231823
18241824 static enum target_prot_op
1825−isert_get_sup_prot_ops(struct iscsi_conn *conn)
1825+isert_get_sup_prot_ops(struct iscsit_conn *conn)
18261826 {
18271827 struct isert_conn *isert_conn = conn->context;
18281828 struct isert_device *device = isert_conn->device;
@@ -1842,7 +1842,7 @@ isert_get_sup_prot_ops(struct iscsi_conn *conn) · 13 unmodified lines
18421842 }
18431843
18441844 static int
1845−isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
1845+isert_put_nopin(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
18461846 bool nopout_response)
18471847 {
18481848 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
@@ -1862,7 +1862,7 @@ isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn, · 13 unmodified lines
18621862 }
18631863
18641864 static int
1865−isert_put_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
1865+isert_put_logout_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
18661866 {
18671867 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
18681868 struct isert_conn *isert_conn = conn->context;
@@ -1880,7 +1880,7 @@ isert_put_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 11 unmodified lines
18801880 }
18811881
18821882 static int
1883−isert_put_tm_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
1883+isert_put_tm_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
18841884 {
18851885 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
18861886 struct isert_conn *isert_conn = conn->context;
@@ -1898,7 +1898,7 @@ isert_put_tm_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 11 unmodified lines
18981898 }
18991899
19001900 static int
1901−isert_put_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
1901+isert_put_reject(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
19021902 {
19031903 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
19041904 struct isert_conn *isert_conn = conn->context;
@@ -1933,7 +1933,7 @@ isert_put_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 28 unmodified lines
19331933 }
19341934
19351935 static int
1936−isert_put_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
1936+isert_put_text_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
19371937 {
19381938 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
19391939 struct isert_conn *isert_conn = conn->context;
@@ -2035,7 +2035,7 @@ static int · 95 unmodified lines
20352035 isert_rdma_rw_ctx_post(struct isert_cmd *cmd, struct isert_conn *conn,
20362036 struct ib_cqe *cqe, struct ib_send_wr *chain_wr)
20372037 {
2038− struct se_cmd *se_cmd = &cmd->iscsi_cmd->se_cmd;
2038+ struct se_cmd *se_cmd = &cmd->iscsit_cmd->se_cmd;
20392039 enum dma_data_direction dir = target_reverse_dma_direction(se_cmd);
20402040 u8 port_num = conn->cm_id->port_num;
20412041 u64 addr;
@@ -2048,7 +2048,7 @@ isert_rdma_rw_ctx_post(struct isert_cmd *cmd, struct isert_conn *conn, · 6 unmodified lines
20482048 if (dir == DMA_FROM_DEVICE) {
20492049 addr = cmd->write_va;
20502050 rkey = cmd->write_stag;
2051− offset = cmd->iscsi_cmd->write_data_done;
2051+ offset = cmd->iscsit_cmd->write_data_done;
20522052 } else {
20532053 addr = cmd->read_va;
20542054 rkey = cmd->read_stag;
@@ -2088,7 +2088,7 @@ rdma_ctx_post: · 33 unmodified lines
20882088 }
20892089
20902090 static int
2091−isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
2091+isert_put_datain(struct iscsit_conn *conn, struct iscsit_cmd *cmd)
20922092 {
20932093 struct se_cmd *se_cmd = &cmd->se_cmd;
20942094 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
@@ -2129,7 +2129,7 @@ isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd) · 34 unmodified lines
21292129 }
21302130
21312131 static int
2132−isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery)
2132+isert_get_dataout(struct iscsit_conn *conn, struct iscsit_cmd *cmd, bool recovery)
21332133 {
21342134 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
21352135 int ret;
@@ -2147,7 +2147,7 @@ isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery) · 11 unmodified lines
21472147 }
21482148
21492149 static int
2150−isert_immediate_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state)
2150+isert_immediate_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state)
21512151 {
21522152 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
21532153 int ret = 0;
@@ -2172,7 +2172,7 @@ isert_immediate_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state) · 18 unmodified lines
21722172 }
21732173
21742174 static int
2175−isert_response_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state)
2175+isert_response_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state)
21762176 {
21772177 struct isert_conn *isert_conn = conn->context;
21782178 int ret;
@@ -2332,7 +2332,7 @@ isert_rdma_accept(struct isert_conn *isert_conn) · 153 unmodified lines
23322332 }
23332333
23342334 static int
2335−isert_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login)
2335+isert_get_login_rx(struct iscsit_conn *conn, struct iscsi_login *login)
23362336 {
23372337 struct isert_conn *isert_conn = conn->context;
23382338 int ret;
@@ -2368,7 +2368,7 @@ isert_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login) · 29 unmodified lines
23682368 }
23692369
23702370 static void
2371−isert_set_conn_info(struct iscsi_np *np, struct iscsi_conn *conn,
2371+isert_set_conn_info(struct iscsi_np *np, struct iscsit_conn *conn,
23722372 struct isert_conn *isert_conn)
23732373 {
23742374 struct rdma_cm_id *cm_id = isert_conn->cm_id;
@@ -2381,7 +2381,7 @@ isert_set_conn_info(struct iscsi_np *np, struct iscsi_conn *conn, · 6 unmodified lines
23812381 }
23822382
23832383 static int
2384−isert_accept_np(struct iscsi_np *np, struct iscsi_conn *conn)
2384+isert_accept_np(struct iscsi_np *np, struct iscsit_conn *conn)
23852385 {
23862386 struct isert_np *isert_np = np->np_context;
23872387 struct isert_conn *isert_conn;
@@ -2489,7 +2489,7 @@ static void isert_release_work(struct work_struct *work) · 101 unmodified lines
24892489 static void
24902490 isert_wait4logout(struct isert_conn *isert_conn)
24912491 {
2492− struct iscsi_conn *conn = isert_conn->conn;
2492+ struct iscsit_conn *conn = isert_conn->conn;
24932493
24942494 isert_info("conn %p\n", isert_conn);
24952495
@@ -2501,9 +2501,9 @@ isert_wait4logout(struct isert_conn *isert_conn) · 5 unmodified lines
25012501 }
25022502
25032503 static void
2504−isert_wait4cmds(struct iscsi_conn *conn)
2504+isert_wait4cmds(struct iscsit_conn *conn)
25052505 {
2506− isert_info("iscsi_conn %p\n", conn);
2506+ isert_info("iscsit_conn %p\n", conn);
25072507
25082508 if (conn->sess) {
25092509 target_stop_session(conn->sess->se_sess);
@@ -2521,9 +2521,9 @@ isert_wait4cmds(struct iscsi_conn *conn) · 11 unmodified lines
25212521 * before blocking on the target_wait_for_session_cmds
25222522 */
25232523 static void
2524−isert_put_unsol_pending_cmds(struct iscsi_conn *conn)
2524+isert_put_unsol_pending_cmds(struct iscsit_conn *conn)
25252525 {
2526− struct iscsi_cmd *cmd, *tmp;
2526+ struct iscsit_cmd *cmd, *tmp;
25272527 static LIST_HEAD(drop_cmd_list);
25282528
25292529 spin_lock_bh(&conn->cmd_lock);
@@ -2546,7 +2546,7 @@ isert_put_unsol_pending_cmds(struct iscsi_conn *conn) · 16 unmodified lines
25462546 }
25472547 }
25482548
2549−static void isert_wait_conn(struct iscsi_conn *conn)
2549+static void isert_wait_conn(struct iscsit_conn *conn)
25502550 {
25512551 struct isert_conn *isert_conn = conn->context;
25522552
@@ -2564,7 +2564,7 @@ static void isert_wait_conn(struct iscsi_conn *conn) · 11 unmodified lines
25642564 queue_work(isert_release_wq, &isert_conn->release_work);
25652565 }
25662566
2567−static void isert_free_conn(struct iscsi_conn *conn)
2567+static void isert_free_conn(struct iscsit_conn *conn)
25682568 {
25692569 struct isert_conn *isert_conn = conn->context;
25702570
@@ -2572,7 +2572,7 @@ static void isert_free_conn(struct iscsi_conn *conn) · 1 unmodified line
25722572 isert_put_conn(isert_conn);
25732573 }
25742574
2575−static void isert_get_rx_pdu(struct iscsi_conn *conn)
2575+static void isert_get_rx_pdu(struct iscsit_conn *conn)
25762576 {
25772577 struct completion comp;
25782578
drivers/infiniband/ulp/isert/ib_isert.h+2−2
@@ -146,7 +146,7 @@ struct isert_cmd { · 145 unmodified lines
146146 u64 pdu_buf_dma;
147147 u32 pdu_buf_len;
148148 struct isert_conn *conn;
149− struct iscsi_cmd *iscsi_cmd;
149+ struct iscsit_cmd *iscsit_cmd;
150150 struct iser_tx_desc tx_desc;
151151 struct iser_rx_desc *rx_desc;
152152 struct rdma_rw_ctx rw;
@@ -173,7 +173,7 @@ struct isert_conn { · 20 unmodified lines
173173 u64 login_rsp_dma;
174174 struct iser_rx_desc *rx_descs;
175175 struct ib_recv_wr rx_wr[ISERT_QP_MAX_RECV_DTOS];
176− struct iscsi_conn *conn;
176+ struct iscsit_conn *conn;
177177 struct list_head node;
178178 struct completion login_comp;
179179 struct completion login_req_comp;
drivers/message/fusion/mptctl.c+0−3
@@ -2334,7 +2334,6 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size) · 2333 unmodified lines
23342334 ToolboxIstwiReadWriteRequest_t *IstwiRWRequest;
23352335 MPT_FRAME_HDR *mf = NULL;
23362336 unsigned long timeleft;
2337− int retval;
23382337 u32 msgcontext;
23392338
23402339 /* Reset long to int. Should affect IA64 and SPARC only
@@ -2488,7 +2487,6 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size) · 147 unmodified lines
24882487 ioc->add_sge((char *)&IstwiRWRequest->SGL,
24892488 (MPT_SGE_FLAGS_SSIMPLE_READ|4), buf_dma);
24902489
2491− retval = 0;
24922490 SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context,
24932491 IstwiRWRequest->MsgContext);
24942492 INITIALIZE_MGMT_STATUS(ioc->ioctl_cmds.status)
@@ -2498,7 +2496,6 @@ retry_wait: · 3 unmodified lines
24982496 timeleft = wait_for_completion_timeout(&ioc->ioctl_cmds.done,
24992497 HZ*MPT_IOCTL_DEFAULT_TIMEOUT);
25002498 if (!(ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) {
2501− retval = -ETIME;
25022499 printk(MYIOC_s_WARN_FMT "%s: failed\n", ioc->name, __func__);
25032500 if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) {
25042501 mpt_free_msg_frame(ioc, mf);
drivers/scsi/aacraid/aacraid.h+1−1
@@ -121,7 +121,7 @@ enum { · 120 unmodified lines
121121 #define SA_AIF_PDEV_CHANGE (1<<4)
122122 #define SA_AIF_LDEV_CHANGE (1<<5)
123123 #define SA_AIF_BPSTAT_CHANGE (1<<30)
124−#define SA_AIF_BPCFG_CHANGE (1<<31)
124+#define SA_AIF_BPCFG_CHANGE (1U<<31)
125125
126126 #define HBA_MAX_SG_EMBEDDED 28
127127 #define HBA_MAX_SG_SEPARATE 90
drivers/scsi/aha1542.c+10−10
@@ -302,7 +302,7 @@ static irqreturn_t aha1542_interrupt(int irq, void *dev_id) · 301 unmodified lines
302302 if (flag & SCRD)
303303 printk("SCRD ");
304304 printk("status %02x\n", inb(STATUS(sh->io_port)));
305− };
305+ }
306306 #endif
307307 number_serviced = 0;
308308
@@ -344,7 +344,7 @@ static irqreturn_t aha1542_interrupt(int irq, void *dev_id) · 35 unmodified lines
344344 if (!number_serviced)
345345 shost_printk(KERN_WARNING, sh, "interrupt received, but no mail.\n");
346346 return IRQ_HANDLED;
347− };
347+ }
348348
349349 mbo = (scsi2int(mb[mbi].ccbptr) - (unsigned long)aha1542->ccb_handle) / sizeof(struct ccb);
350350 mbistatus = mb[mbi].status;
@@ -408,7 +408,7 @@ static irqreturn_t aha1542_interrupt(int irq, void *dev_id) · 57 unmodified lines
408408 */
409409 scsi_done(tmp_cmd);
410410 number_serviced++;
411− };
411+ }
412412 }
413413
414414 static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
@@ -534,7 +534,7 @@ static void setup_mailboxes(struct Scsi_Host *sh) · 119 unmodified lines
534534 any2scsi(aha1542->mb[i].ccbptr,
535535 aha1542->ccb_handle + i * sizeof(struct ccb));
536536 aha1542->mb[AHA1542_MAILBOXES + i].status = 0;
537− };
537+ }
538538 aha1542_intr_reset(sh->io_port); /* reset interrupts, so they don't block */
539539 any2scsi(mb_cmd + 2, aha1542->mb_handle);
540540 if (aha1542_out(sh->io_port, mb_cmd, 5))
@@ -549,7 +549,7 @@ static int aha1542_getconfig(struct Scsi_Host *sh) · 8 unmodified lines
549549 i = inb(STATUS(sh->io_port));
550550 if (i & DF) {
551551 i = inb(DATA(sh->io_port));
552− };
552+ }
553553 aha1542_outb(sh->io_port, CMD_RETCONF);
554554 aha1542_in(sh->io_port, inquiry_result, 3, 0);
555555 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0))
@@ -578,7 +578,7 @@ static int aha1542_getconfig(struct Scsi_Host *sh) · 22 unmodified lines
578578 default:
579579 shost_printk(KERN_ERR, sh, "Unable to determine DMA channel.\n");
580580 return -1;
581− };
581+ }
582582 switch (inquiry_result[1]) {
583583 case 0x40:
584584 sh->irq = 15;
@@ -601,7 +601,7 @@ static int aha1542_getconfig(struct Scsi_Host *sh) · 16 unmodified lines
601601 default:
602602 shost_printk(KERN_ERR, sh, "Unable to determine IRQ level.\n");
603603 return -1;
604− };
604+ }
605605 sh->this_id = inquiry_result[2] & 7;
606606 return 0;
607607 }
@@ -636,7 +636,7 @@ static int aha1542_mbenable(struct Scsi_Host *sh) · 28 unmodified lines
636636
637637 if (aha1542_out(sh->io_port, mbenable_cmd, 3))
638638 goto fail;
639− };
639+ }
640640 while (0) {
641641 fail:
642642 shost_printk(KERN_ERR, sh, "Mailbox init failed\n");
@@ -654,7 +654,7 @@ static int aha1542_query(struct Scsi_Host *sh) · 11 unmodified lines
654654 i = inb(STATUS(sh->io_port));
655655 if (i & DF) {
656656 i = inb(DATA(sh->io_port));
657− };
657+ }
658658 aha1542_outb(sh->io_port, CMD_INQUIRY);
659659 aha1542_in(sh->io_port, inquiry_result, 4, 0);
660660 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0))
@@ -673,7 +673,7 @@ static int aha1542_query(struct Scsi_Host *sh) · 12 unmodified lines
673673 if (inquiry_result[0] == 0x43) {
674674 shost_printk(KERN_INFO, sh, "Emulation mode not supported for AHA-1740 hardware, use aha1740 driver instead.\n");
675675 return 1;
676− };
676+ }
677677
678678 /*
679679 * Always call this - boards that do not support extended bios translation
drivers/scsi/bfa/bfad_debugfs.c+1−2
@@ -371,8 +371,7 @@ bfad_debugfs_release_fwtrc(struct inode *inode, struct file *file) · 370 unmodified lines
371371 if (!fw_debug)
372372 return 0;
373373
374− if (fw_debug->debug_buffer)
375− vfree(fw_debug->debug_buffer);
374+ vfree(fw_debug->debug_buffer);
376375
377376 file->private_data = NULL;
378377 kfree(fw_debug);
drivers/scsi/bfa/bfad_im.c+0−1
@@ -755,7 +755,6 @@ void · 754 unmodified lines
755755 bfad_destroy_workq(struct bfad_im_s *im)
756756 {
757757 if (im && im->drv_workq) {
758− flush_workqueue(im->drv_workq);
759758 destroy_workqueue(im->drv_workq);
760759 im->drv_workq = NULL;
761760 }
drivers/scsi/bnx2fc/bnx2fc_fcoe.c+6−16
@@ -273,7 +273,6 @@ static int bnx2fc_xmit(struct fc_lport *lport, struct fc_frame *fp) · 272 unmodified lines
273273 struct fcoe_port *port;
274274 struct fcoe_hdr *hp;
275275 struct bnx2fc_rport *tgt;
276− struct fc_stats *stats;
277276 u8 sof, eof;
278277 u32 crc;
279278 unsigned int hlen, tlen, elen;
@@ -399,10 +398,8 @@ static int bnx2fc_xmit(struct fc_lport *lport, struct fc_frame *fp) · 119 unmodified lines
399398 }
400399
401400 /*update tx stats */
402− stats = per_cpu_ptr(lport->stats, get_cpu());
403− stats->TxFrames++;
404− stats->TxWords += wlen;
405− put_cpu();
401+ this_cpu_inc(lport->stats->TxFrames);
402+ this_cpu_add(lport->stats->TxWords, wlen);
406403
407404 /* send down to lld */
408405 fr_dev(fp) = lport;
@@ -512,7 +509,6 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) · 103 unmodified lines
512509 u32 fr_len, fr_crc;
513510 struct fc_lport *lport;
514511 struct fcoe_rcv_info *fr;
515− struct fc_stats *stats;
516512 struct fc_frame_header *fh;
517513 struct fcoe_crc_eof crc_eof;
518514 struct fc_frame *fp;
@@ -543,10 +539,8 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) · 24 unmodified lines
543539 skb_pull(skb, sizeof(struct fcoe_hdr));
544540 fr_len = skb->len - sizeof(struct fcoe_crc_eof);
545541
546− stats = per_cpu_ptr(lport->stats, get_cpu());
547− stats->RxFrames++;
548− stats->RxWords += fr_len / FCOE_WORD_TO_BYTE;
549− put_cpu();
542+ this_cpu_inc(lport->stats->RxFrames);
543+ this_cpu_add(lport->stats->RxWords, fr_len / FCOE_WORD_TO_BYTE);
550544
551545 fp = (struct fc_frame *)skb;
552546 fc_frame_init(fp);
@@ -633,9 +627,7 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) · 80 unmodified lines
633627 fr_crc = le32_to_cpu(fr_crc(fp));
634628
635629 if (unlikely(fr_crc != ~crc32(~0, skb->data, fr_len))) {
636− stats = per_cpu_ptr(lport->stats, get_cpu());
637− crc_err = (stats->InvalidCRCCount++);
638− put_cpu();
630+ crc_err = this_cpu_inc_return(lport->stats->InvalidCRCCount);
639631 if (crc_err < 5)
640632 printk(KERN_WARNING PFX "dropping frame with "
641633 "CRC error\n");
@@ -964,9 +956,7 @@ static void bnx2fc_indicate_netevent(void *context, unsigned long event, · 322 unmodified lines
964956 mutex_unlock(&lport->lp_mutex);
965957 fc_host_port_type(lport->host) =
966958 FC_PORTTYPE_UNKNOWN;
967− per_cpu_ptr(lport->stats,
968− get_cpu())->LinkFailureCount++;
969− put_cpu();
959+ this_cpu_inc(lport->stats->LinkFailureCount);
970960 fcoe_clean_pending_queue(lport);
971961 wait_for_upload = 1;
972962 }
drivers/scsi/bnx2fc/bnx2fc_io.c+6−11
@@ -472,7 +472,7 @@ struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt) · 471 unmodified lines
472472 u32 free_sqes;
473473 u32 max_sqes;
474474 u16 xid;
475− int index = get_cpu();
475+ int index = raw_smp_processor_id();
476476
477477 max_sqes = BNX2FC_SCSI_MAX_SQES;
478478 /*
@@ -485,7 +485,6 @@ struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt) · 6 unmodified lines
485485 (tgt->num_active_ios.counter >= max_sqes) ||
486486 (free_sqes + max_sqes <= BNX2FC_SQ_WQES_MAX)) {
487487 spin_unlock_bh(&cmd_mgr->free_list_lock[index]);
488− put_cpu();
489488 return NULL;
490489 }
491490
@@ -498,7 +497,6 @@ struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt) · 6 unmodified lines
498497 atomic_inc(&tgt->num_active_ios);
499498 atomic_dec(&tgt->free_sqes);
500499 spin_unlock_bh(&cmd_mgr->free_list_lock[index]);
501− put_cpu();
502500
503501 INIT_LIST_HEAD(&io_req->link);
504502
@@ -2032,7 +2030,6 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt, · 1527 unmodified lines
20322030 struct bnx2fc_interface *interface = port->priv;
20332031 struct bnx2fc_hba *hba = interface->hba;
20342032 struct fc_lport *lport = port->lport;
2035− struct fc_stats *stats;
20362033 int task_idx, index;
20372034 u16 xid;
20382035
@@ -2045,20 +2042,18 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt, · 6 unmodified lines
20452042 io_req->data_xfer_len = scsi_bufflen(sc_cmd);
20462043 bnx2fc_priv(sc_cmd)->io_req = io_req;
20472044
2048− stats = per_cpu_ptr(lport->stats, get_cpu());
20492045 if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) {
20502046 io_req->io_req_flags = BNX2FC_READ;
2051− stats->InputRequests++;
2052− stats->InputBytes += io_req->data_xfer_len;
2047+ this_cpu_inc(lport->stats->InputRequests);
2048+ this_cpu_add(lport->stats->InputBytes, io_req->data_xfer_len);
20532049 } else if (sc_cmd->sc_data_direction == DMA_TO_DEVICE) {
20542050 io_req->io_req_flags = BNX2FC_WRITE;
2055− stats->OutputRequests++;
2056− stats->OutputBytes += io_req->data_xfer_len;
2051+ this_cpu_inc(lport->stats->OutputRequests);
2052+ this_cpu_add(lport->stats->OutputBytes, io_req->data_xfer_len);
20572053 } else {
20582054 io_req->io_req_flags = 0;
2059− stats->ControlRequests++;
2055+ this_cpu_inc(lport->stats->ControlRequests);
20602056 }
2061− put_cpu();
20622057
20632058 xid = io_req->xid;
20642059
drivers/scsi/dc395x.c+12−3
@@ -3585,10 +3585,19 @@ static struct DeviceCtlBlk *device_alloc(struct AdapterCtlBlk *acb, · 3584 unmodified lines
35853585 #endif
35863586 if (dcb->target_lun != 0) {
35873587 /* Copy settings */
3588− struct DeviceCtlBlk *p;
3589− list_for_each_entry(p, &acb->dcb_list, list)
3590− if (p->target_id == dcb->target_id)
3588+ struct DeviceCtlBlk *p = NULL, *iter;
3589+
3590+ list_for_each_entry(iter, &acb->dcb_list, list)
3591+ if (iter->target_id == dcb->target_id) {
3592+ p = iter;
35913593 break;
3594+ }
3595+
3596+ if (!p) {
3597+ kfree(dcb);
3598+ return NULL;
3599+ }
3600+
35923601 dprintkdbg(DBG_1,
35933602 "device_alloc: <%02i-%i> copy from <%02i-%i>\n",
35943603 dcb->target_id, dcb->target_lun,
drivers/scsi/dpt_i2o.c+0−1
@@ -1000,7 +1000,6 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev · 999 unmodified lines
10001000
10011001 // Initializing the spinlocks
10021002 spin_lock_init(&pHba->state_lock);
1003− spin_lock_init(&adpt_post_wait_lock);
10041003
10051004 if(raptorFlag == 0){
10061005 printk(KERN_INFO "Adaptec I2O RAID controller"
drivers/scsi/elx/efct/efct_hw.c+0−1
@@ -1402,7 +1402,6 @@ efct_hw_command(struct efct_hw *hw, u8 *cmd, u32 opts, void *cb, void *arg) · 1401 unmodified lines
14021402 mutex_lock(&hw->bmbx_lock);
14031403 bmbx = hw->sli.bmbx.virt;
14041404
1405− memset(bmbx, 0, SLI4_BMBX_SIZE);
14061405 memcpy(bmbx, cmd, SLI4_BMBX_SIZE);
14071406
14081407 if (sli_bmbx_command(&hw->sli) == 0) {
drivers/scsi/elx/efct/efct_io.c+0−1
@@ -62,7 +62,6 @@ efct_io_pool_create(struct efct *efct, u32 num_sgl) · 61 unmodified lines
6262 return NULL;
6363 }
6464
65− memset(io->sgl, 0, sizeof(*io->sgl) * num_sgl);
6665 io->sgl_allocated = num_sgl;
6766 io->sgl_count = 0;
6867
drivers/scsi/elx/efct/efct_lio.c+0−3
@@ -370,9 +370,6 @@ static int efct_lio_get_cmd_state(struct se_cmd *cmd) · 369 unmodified lines
370370 container_of(cmd, struct efct_scsi_tgt_io, cmd);
371371 struct efct_io *io = container_of(ocp, struct efct_io, tgt_io);
372372
373− if (!io)
374− return 0;
375−
376373 return io->tgt_io.state;
377374 }
378375
drivers/scsi/fcoe/fcoe.c+17−27
@@ -1434,8 +1434,7 @@ static int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, · 1433 unmodified lines
14341434
14351435 return NET_RX_SUCCESS;
14361436 err:
1437− per_cpu_ptr(lport->stats, get_cpu())->ErrorFrames++;
1438− put_cpu();
1437+ this_cpu_inc(lport->stats->ErrorFrames);
14391438 err2:
14401439 kfree_skb(skb);
14411440 return NET_RX_DROP;
@@ -1453,9 +1452,10 @@ static int fcoe_alloc_paged_crc_eof(struct sk_buff *skb, int tlen) · 11 unmodified lines
14531452 struct fcoe_percpu_s *fps;
14541453 int rc;
14551454
1456− fps = &get_cpu_var(fcoe_percpu);
1455+ local_lock(&fcoe_percpu.lock);
1456+ fps = this_cpu_ptr(&fcoe_percpu);
14571457 rc = fcoe_get_paged_crc_eof(skb, tlen, fps);
1458− put_cpu_var(fcoe_percpu);
1458+ local_unlock(&fcoe_percpu.lock);
14591459
14601460 return rc;
14611461 }
@@ -1474,7 +1474,6 @@ static int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp) · 12 unmodified lines
14741474 struct ethhdr *eh;
14751475 struct fcoe_crc_eof *cp;
14761476 struct sk_buff *skb;
1477− struct fc_stats *stats;
14781477 struct fc_frame_header *fh;
14791478 unsigned int hlen; /* header length implies the version */
14801479 unsigned int tlen; /* trailer length */
@@ -1585,10 +1584,8 @@ static int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp) · 104 unmodified lines
15851584 skb_shinfo(skb)->gso_size = 0;
15861585 }
15871586 /* update tx stats: regardless if LLD fails */
1588− stats = per_cpu_ptr(lport->stats, get_cpu());
1589− stats->TxFrames++;
1590− stats->TxWords += wlen;
1591− put_cpu();
1587+ this_cpu_inc(lport->stats->TxFrames);
1588+ this_cpu_add(lport->stats->TxWords, wlen);
15921589
15931590 /* send down to lld */
15941591 fr_dev(fp) = lport;
@@ -1610,7 +1607,6 @@ static inline int fcoe_filter_frames(struct fc_lport *lport, · 15 unmodified lines
16101607 struct fcoe_interface *fcoe;
16111608 struct fc_frame_header *fh;
16121609 struct sk_buff *skb = (struct sk_buff *)fp;
1613− struct fc_stats *stats;
16141610
16151611 /*
16161612 * We only check CRC if no offload is available and if it is
@@ -1640,11 +1636,8 @@ static inline int fcoe_filter_frames(struct fc_lport *lport, · 23 unmodified lines
16401636 return 0;
16411637 }
16421638
1643− stats = per_cpu_ptr(lport->stats, get_cpu());
1644− stats->InvalidCRCCount++;
1645− if (stats->InvalidCRCCount < 5)
1639+ if (this_cpu_inc_return(lport->stats->InvalidCRCCount) < 5)
16461640 printk(KERN_WARNING "fcoe: dropping frame with CRC error\n");
1647− put_cpu();
16481641 return -EINVAL;
16491642 }
16501643
@@ -1657,7 +1650,6 @@ static void fcoe_recv_frame(struct sk_buff *skb) · 6 unmodified lines
16571650 u32 fr_len;
16581651 struct fc_lport *lport;
16591652 struct fcoe_rcv_info *fr;
1660− struct fc_stats *stats;
16611653 struct fcoe_crc_eof crc_eof;
16621654 struct fc_frame *fp;
16631655 struct fcoe_hdr *hp;
@@ -1685,9 +1677,11 @@ static void fcoe_recv_frame(struct sk_buff *skb) · 21 unmodified lines
16851677 */
16861678 hp = (struct fcoe_hdr *) skb_network_header(skb);
16871679
1688− stats = per_cpu_ptr(lport->stats, get_cpu());
16891680 if (unlikely(FC_FCOE_DECAPS_VER(hp) != FC_FCOE_VER)) {
1690− if (stats->ErrorFrames < 5)
1681+ struct fc_stats *stats;
1682+
1683+ stats = per_cpu_ptr(lport->stats, raw_smp_processor_id());
1684+ if (READ_ONCE(stats->ErrorFrames) < 5)
16911685 printk(KERN_WARNING "fcoe: FCoE version "
16921686 "mismatch: The frame has "
16931687 "version %x, but the "
@@ -1700,8 +1694,8 @@ static void fcoe_recv_frame(struct sk_buff *skb) · 6 unmodified lines
17001694 skb_pull(skb, sizeof(struct fcoe_hdr));
17011695 fr_len = skb->len - sizeof(struct fcoe_crc_eof);
17021696
1703− stats->RxFrames++;
1704− stats->RxWords += fr_len / FCOE_WORD_TO_BYTE;
1697+ this_cpu_inc(lport->stats->RxFrames);
1698+ this_cpu_add(lport->stats->RxWords, fr_len / FCOE_WORD_TO_BYTE);
17051699
17061700 fp = (struct fc_frame *)skb;
17071701 fc_frame_init(fp);
@@ -1717,13 +1711,11 @@ static void fcoe_recv_frame(struct sk_buff *skb) · 9 unmodified lines
17171711 goto drop;
17181712
17191713 if (!fcoe_filter_frames(lport, fp)) {
1720− put_cpu();
17211714 fc_exch_recv(lport, fp);
17221715 return;
17231716 }
17241717 drop:
1725− stats->ErrorFrames++;
1726− put_cpu();
1718+ this_cpu_inc(lport->stats->ErrorFrames);
17271719 kfree_skb(skb);
17281720 }
17291721
@@ -1847,7 +1839,6 @@ static int fcoe_device_notification(struct notifier_block *notifier, · 117 unmodified lines
18471839 struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
18481840 struct fcoe_ctlr *ctlr;
18491841 struct fcoe_interface *fcoe;
1850− struct fc_stats *stats;
18511842 u32 link_possible = 1;
18521843 u32 mfs;
18531844 int rc = NOTIFY_OK;
@@ -1921,9 +1912,7 @@ static int fcoe_device_notification(struct notifier_block *notifier, · 67 unmodified lines
19211912 break;
19221913 case FCOE_CTLR_ENABLED:
19231914 case FCOE_CTLR_UNUSED:
1924− stats = per_cpu_ptr(lport->stats, get_cpu());
1925− stats->LinkFailureCount++;
1926− put_cpu();
1915+ this_cpu_inc(lport->stats->LinkFailureCount);
19271916 fcoe_clean_pending_queue(lport);
19281917 }
19291918 }
@@ -2488,6 +2477,7 @@ static int __init fcoe_init(void) · 558 unmodified lines
24882477 p = per_cpu_ptr(&fcoe_percpu, cpu);
24892478 INIT_WORK(&p->work, fcoe_receive_work);
24902479 skb_queue_head_init(&p->fcoe_rx_list);
2480+ local_lock_init(&p->lock);
24912481 }
24922482
24932483 /* Setup link change notification */
@@ -2580,7 +2570,7 @@ static void fcoe_flogi_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) · 86 unmodified lines
25802570 /* pre-FIP */
25812571 if (is_zero_ether_addr(mac))
25822572 fcoe_ctlr_recv_flogi(fip, lport, fp);
2583− if (!is_zero_ether_addr(mac))
2573+ else
25842574 fcoe_update_src_mac(lport, mac);
25852575 done:
25862576 fc_lport_flogi_resp(seq, fp, lport);
drivers/scsi/fcoe/fcoe_ctlr.c+9−17
@@ -824,22 +824,21 @@ static unsigned long fcoe_ctlr_age_fcfs(struct fcoe_ctlr *fip) · 823 unmodified lines
824824 unsigned long deadline;
825825 unsigned long sel_time = 0;
826826 struct list_head del_list;
827− struct fc_stats *stats;
828827
829828 INIT_LIST_HEAD(&del_list);
830829
831− stats = per_cpu_ptr(fip->lp->stats, get_cpu());
832−
833830 list_for_each_entry_safe(fcf, next, &fip->fcfs, list) {
834831 deadline = fcf->time + fcf->fka_period + fcf->fka_period / 2;
835832 if (fip->sel_fcf == fcf) {
836833 if (time_after(jiffies, deadline)) {
837− stats->MissDiscAdvCount++;
834+ u64 miss_cnt;
835+
836+ miss_cnt = this_cpu_inc_return(fip->lp->stats->MissDiscAdvCount);
838837 printk(KERN_INFO "libfcoe: host%d: "
839838 "Missing Discovery Advertisement "
840839 "for fab %16.16llx count %lld\n",
841840 fip->lp->host->host_no, fcf->fabric_name,
842− stats->MissDiscAdvCount);
841+ miss_cnt);
843842 } else if (time_after(next_timer, deadline))
844843 next_timer = deadline;
845844 }
@@ -855,7 +854,7 @@ static unsigned long fcoe_ctlr_age_fcfs(struct fcoe_ctlr *fip) · 9 unmodified lines
855854 */
856855 list_del(&fcf->list);
857856 list_add(&fcf->list, &del_list);
858− stats->VLinkFailureCount++;
857+ this_cpu_inc(fip->lp->stats->VLinkFailureCount);
859858 } else {
860859 if (time_after(next_timer, deadline))
861860 next_timer = deadline;
@@ -864,7 +863,6 @@ static unsigned long fcoe_ctlr_age_fcfs(struct fcoe_ctlr *fip) · 2 unmodified lines
864863 sel_time = fcf->time;
865864 }
866865 }
867− put_cpu();
868866
869867 list_for_each_entry_safe(fcf, next, &del_list, list) {
870868 /* Removes fcf from current list */
@@ -1142,7 +1140,6 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb) · 271 unmodified lines
11421140 struct fip_desc *desc;
11431141 struct fip_encaps *els;
11441142 struct fcoe_fcf *sel;
1145− struct fc_stats *stats;
11461143 enum fip_desc_type els_dtype = 0;
11471144 u8 els_op;
11481145 u8 sub;
@@ -1286,10 +1283,8 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb) · 137 unmodified lines
12861283 fr_dev(fp) = lport;
12871284 fr_encaps(fp) = els_dtype;
12881285
1289− stats = per_cpu_ptr(lport->stats, get_cpu());
1290− stats->RxFrames++;
1291− stats->RxWords += skb->len / FIP_BPW;
1292− put_cpu();
1286+ this_cpu_inc(lport->stats->RxFrames);
1287+ this_cpu_add(lport->stats->RxWords, skb->len / FIP_BPW);
12931288
12941289 fc_exch_recv(lport, fp);
12951290 return;
@@ -1427,9 +1422,7 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip, · 131 unmodified lines
14271422 ntoh24(vp->fd_fc_id));
14281423 if (vn_port && (vn_port == lport)) {
14291424 mutex_lock(&fip->ctlr_mutex);
1430− per_cpu_ptr(lport->stats,
1431− get_cpu())->VLinkFailureCount++;
1432− put_cpu();
1425+ this_cpu_inc(lport->stats->VLinkFailureCount);
14331426 fcoe_ctlr_reset(fip);
14341427 mutex_unlock(&fip->ctlr_mutex);
14351428 }
@@ -1457,8 +1450,7 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip, · 21 unmodified lines
14571450 * followed by physical port
14581451 */
14591452 mutex_lock(&fip->ctlr_mutex);
1460− per_cpu_ptr(lport->stats, get_cpu())->VLinkFailureCount++;
1461− put_cpu();
1453+ this_cpu_inc(lport->stats->VLinkFailureCount);
14621454 fcoe_ctlr_reset(fip);
14631455 mutex_unlock(&fip->ctlr_mutex);
14641456
drivers/scsi/fcoe/fcoe_transport.c+3−3
@@ -183,9 +183,9 @@ void __fcoe_get_lesb(struct fc_lport *lport, · 182 unmodified lines
183183 memset(lesb, 0, sizeof(*lesb));
184184 for_each_possible_cpu(cpu) {
185185 stats = per_cpu_ptr(lport->stats, cpu);
186− lfc += stats->LinkFailureCount;
187− vlfc += stats->VLinkFailureCount;
188− mdac += stats->MissDiscAdvCount;
186+ lfc += READ_ONCE(stats->LinkFailureCount);
187+ vlfc += READ_ONCE(stats->VLinkFailureCount);
188+ mdac += READ_ONCE(stats->MissDiscAdvCount);
189189 }
190190 lesb->lesb_link_fail = htonl(lfc);
191191 lesb->lesb_vlink_fail = htonl(vlfc);
drivers/scsi/fnic/fnic.h+1−1
@@ -39,7 +39,7 @@ · 38 unmodified lines
3939
4040 #define DRV_NAME "fnic"
4141 #define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
42−#define DRV_VERSION "1.6.0.53"
42+#define DRV_VERSION "1.6.0.54"
4343 #define PFX DRV_NAME ": "
4444 #define DFX DRV_NAME "%d: "
4545
drivers/scsi/fnic/fnic_debugfs.c+1−2
@@ -86,8 +86,7 @@ void fnic_debugfs_terminate(void) · 85 unmodified lines
8686 debugfs_remove(fnic_trace_debugfs_root);
8787 fnic_trace_debugfs_root = NULL;
8888
89− if (fc_trc_flag)
90− vfree(fc_trc_flag);
89+ vfree(fc_trc_flag);
9190 }
9291
9392 /*
drivers/scsi/fnic/fnic_main.c+4−6
@@ -612,10 +612,10 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 611 unmodified lines
612612 pci_set_master(pdev);
613613
614614 /* Query PCI controller on system for DMA addressing
615− * limitation for the device. Try 64-bit first, and
616− * fail to 32-bit.
615+ * limitation for the device. Try 47-bit first, and
616+ * fail to 32-bit. Cisco VIC supports 47 bits only.
617617 */
618− err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
618+ err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(47));
619619 if (err) {
620620 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
621621 if (err) {
@@ -1146,10 +1146,8 @@ static void __exit fnic_cleanup_module(void) · 524 unmodified lines
11461146 {
11471147 pci_unregister_driver(&fnic_driver);
11481148 destroy_workqueue(fnic_event_queue);
1149− if (fnic_fip_queue) {
1150− flush_workqueue(fnic_fip_queue);
1149+ if (fnic_fip_queue)
11511150 destroy_workqueue(fnic_fip_queue);
1152− }
11531151 kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_MAX]);
11541152 kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]);
11551153 kmem_cache_destroy(fnic_io_req_cache);
drivers/scsi/hisi_sas/hisi_sas_main.c+32−36
@@ -446,6 +446,8 @@ void hisi_sas_task_deliver(struct hisi_hba *hisi_hba, · 445 unmodified lines
446446 return;
447447 }
448448
449+ /* Make slot memories observable before marking as ready */
450+ smp_wmb();
449451 WRITE_ONCE(slot->ready, 1);
450452
451453 spin_lock(&dq->lock);
@@ -709,8 +711,6 @@ static int hisi_sas_init_device(struct domain_device *device) · 257 unmodified lines
709711 struct scsi_lun lun;
710712 int retry = HISI_SAS_DISK_RECOVER_CNT;
711713 struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);
712− struct device *dev = hisi_hba->dev;
713− struct sas_phy *local_phy;
714714
715715 switch (device->dev_type) {
716716 case SAS_END_DEVICE:
@@ -729,30 +729,18 @@ static int hisi_sas_init_device(struct domain_device *device) · 12 unmodified lines
729729 case SAS_SATA_PM_PORT:
730730 case SAS_SATA_PENDING:
731731 /*
732− * send HARD RESET to clear previous affiliation of
733− * STP target port
732+ * If an expander is swapped when a SATA disk is attached then
733+ * we should issue a hard reset to clear previous affiliation
734+ * of STP target port, see SPL (chapter 6.19.4).
735+ *
736+ * However we don't need to issue a hard reset here for these
737+ * reasons:
738+ * a. When probing the device, libsas/libata already issues a
739+ * hard reset in sas_probe_sata() -> ata_sas_async_probe().
740+ * Note that in hisi_sas_debug_I_T_nexus_reset() we take care
741+ * to issue a hard reset by checking the dev status (== INIT).
742+ * b. When resetting the controller, this is simply unnecessary.
734743 */
735− local_phy = sas_get_local_phy(device);
736− if (!scsi_is_sas_phy_local(local_phy) &&
737− !test_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags)) {
738− unsigned long deadline = ata_deadline(jiffies, 20000);
739− struct sata_device *sata_dev = &device->sata_dev;
740− struct ata_host *ata_host = sata_dev->ata_host;
741− struct ata_port_operations *ops = ata_host->ops;
742− struct ata_port *ap = sata_dev->ap;
743− struct ata_link *link;
744− unsigned int classes;
745−
746− ata_for_each_link(link, ap, EDGE)
747− rc = ops->hardreset(link, &classes,
748− deadline);
749− }
750− sas_put_local_phy(local_phy);
751− if (rc) {
752− dev_warn(dev, "SATA disk hardreset fail: %d\n", rc);
753− return rc;
754− }
755−
756744 while (retry-- > 0) {
757745 rc = hisi_sas_softreset_ata_disk(device);
758746 if (!rc)
@@ -768,15 +756,19 @@ static int hisi_sas_init_device(struct domain_device *device) · 9 unmodified lines
768756
769757 int hisi_sas_slave_alloc(struct scsi_device *sdev)
770758 {
771− struct domain_device *ddev;
759+ struct domain_device *ddev = sdev_to_domain_dev(sdev);
760+ struct hisi_sas_device *sas_dev = ddev->lldd_dev;
772761 int rc;
773762
774763 rc = sas_slave_alloc(sdev);
775764 if (rc)
776765 return rc;
777− ddev = sdev_to_domain_dev(sdev);
778766
779− return hisi_sas_init_device(ddev);
767+ rc = hisi_sas_init_device(ddev);
768+ if (rc)
769+ return rc;
770+ sas_dev->dev_status = HISI_SAS_DEV_NORMAL;
771+ return 0;
780772 }
781773 EXPORT_SYMBOL_GPL(hisi_sas_slave_alloc);
782774
@@ -826,7 +818,6 @@ static int hisi_sas_dev_found(struct domain_device *device) · 43 unmodified lines
826818 dev_info(dev, "dev[%d:%x] found\n",
827819 sas_dev->device_id, sas_dev->dev_type);
828820
829− sas_dev->dev_status = HISI_SAS_DEV_NORMAL;
830821 return 0;
831822
832823 err_out:
@@ -1710,13 +1701,18 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device) · 877 unmodified lines
17101701 /* report PHY down if timed out */
17111702 if (rc == -ETIMEDOUT)
17121703 hisi_sas_phy_down(hisi_hba, sas_phy->id, 0, GFP_KERNEL);
1713− } else if (sas_dev->dev_status != HISI_SAS_DEV_INIT) {
1714− /*
1715− * If in init state, we rely on caller to wait for link to be
1716− * ready; otherwise, except phy reset is fail, delay.
1717− */
1718− if (!rc)
1719− msleep(2000);
1704+ return rc;
1705+ }
1706+
1707+ if (rc)
1708+ return rc;
1709+
1710+ /* Remote phy */
1711+ if (dev_is_sata(device)) {
1712+ rc = sas_ata_wait_after_reset(device,
1713+ HISI_SAS_WAIT_PHYUP_TIMEOUT);
1714+ } else {
1715+ msleep(2000);
17201716 }
17211717
17221718 return rc;
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c+8−2
@@ -1563,9 +1563,15 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba) · 1562 unmodified lines
15631563
15641564 phy->port_id = port_id;
15651565
1566− /* Call pm_runtime_put_sync() with pairs in hisi_sas_phyup_pm_work() */
1566+ /*
1567+ * Call pm_runtime_get_noresume() which pairs with
1568+ * hisi_sas_phyup_pm_work() -> pm_runtime_put_sync().
1569+ * For failure call pm_runtime_put() as we are in a hardirq context.
1570+ */
15671571 pm_runtime_get_noresume(dev);
1568− hisi_sas_notify_phy_event(phy, HISI_PHYE_PHY_UP_PM);
1572+ res = hisi_sas_notify_phy_event(phy, HISI_PHYE_PHY_UP_PM);
1573+ if (!res)
1574+ pm_runtime_put(dev);
15691575
15701576 res = IRQ_HANDLED;
15711577
drivers/scsi/hosts.c+4−4
@@ -229,10 +229,6 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, · 228 unmodified lines
229229 if (error)
230230 goto fail;
231231
232− error = scsi_mq_setup_tags(shost);
233− if (error)
234− goto fail;
235−
236232 if (!shost->shost_gendev.parent)
237233 shost->shost_gendev.parent = dev ? dev : &platform_bus;
238234 if (!dma_dev)
@@ -240,6 +236,10 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, · 1 unmodified line
240236
241237 shost->dma_dev = dma_dev;
242238
239+ error = scsi_mq_setup_tags(shost);
240+ if (error)
241+ goto fail;
242+
243243 /*
244244 * Increase usage count temporarily here so that calling
245245 * scsi_autopm_put_host() will trigger runtime idle if there is
drivers/scsi/ipr.c+6−7
@@ -3456,7 +3456,7 @@ static ssize_t ipr_read_trace(struct file *filp, struct kobject *kobj, · 3455 unmodified lines
34563456 struct bin_attribute *bin_attr,
34573457 char *buf, loff_t off, size_t count)
34583458 {
3459− struct device *dev = container_of(kobj, struct device, kobj);
3459+ struct device *dev = kobj_to_dev(kobj);
34603460 struct Scsi_Host *shost = class_to_shost(dev);
34613461 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
34623462 unsigned long lock_flags = 0;
@@ -4182,7 +4182,7 @@ static ssize_t ipr_read_async_err_log(struct file *filep, struct kobject *kobj, · 719 unmodified lines
41824182 struct bin_attribute *bin_attr, char *buf,
41834183 loff_t off, size_t count)
41844184 {
4185− struct device *cdev = container_of(kobj, struct device, kobj);
4185+ struct device *cdev = kobj_to_dev(kobj);
41864186 struct Scsi_Host *shost = class_to_shost(cdev);
41874187 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
41884188 struct ipr_hostrcb *hostrcb;
@@ -4206,7 +4206,7 @@ static ssize_t ipr_next_async_err_log(struct file *filep, struct kobject *kobj, · 17 unmodified lines
42064206 struct bin_attribute *bin_attr, char *buf,
42074207 loff_t off, size_t count)
42084208 {
4209− struct device *cdev = container_of(kobj, struct device, kobj);
4209+ struct device *cdev = kobj_to_dev(kobj);
42104210 struct Scsi_Host *shost = class_to_shost(cdev);
42114211 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
42124212 struct ipr_hostrcb *hostrcb;
@@ -4267,7 +4267,7 @@ static ssize_t ipr_read_dump(struct file *filp, struct kobject *kobj, · 54 unmodified lines
42674267 struct bin_attribute *bin_attr,
42684268 char *buf, loff_t off, size_t count)
42694269 {
4270− struct device *cdev = container_of(kobj, struct device, kobj);
4270+ struct device *cdev = kobj_to_dev(kobj);
42714271 struct Scsi_Host *shost = class_to_shost(cdev);
42724272 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
42734273 struct ipr_dump *dump;
@@ -4456,7 +4456,7 @@ static ssize_t ipr_write_dump(struct file *filp, struct kobject *kobj, · 182 unmodified lines
44564456 struct bin_attribute *bin_attr,
44574457 char *buf, loff_t off, size_t count)
44584458 {
4459− struct device *cdev = container_of(kobj, struct device, kobj);
4459+ struct device *cdev = kobj_to_dev(kobj);
44604460 struct Scsi_Host *shost = class_to_shost(cdev);
44614461 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
44624462 int rc;
@@ -10092,7 +10092,6 @@ static irqreturn_t ipr_test_intr(int irq, void *devp) · 5629 unmodified lines
1009210092 {
1009310093 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)devp;
1009410094 unsigned long lock_flags = 0;
10095− irqreturn_t rc = IRQ_HANDLED;
1009610095
1009710096 dev_info(&ioa_cfg->pdev->dev, "Received IRQ : %d\n", irq);
1009810097 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
@@ -10101,7 +10100,7 @@ static irqreturn_t ipr_test_intr(int irq, void *devp) · 2 unmodified lines
1010110100 wake_up(&ioa_cfg->msi_wait_q);
1010210101
1010310102 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
10104− return rc;
10103+ return IRQ_HANDLED;
1010510104 }
1010610105
1010710106 /**
drivers/scsi/libfc/fc_exch.c+1−2
@@ -825,10 +825,9 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport, · 824 unmodified lines
825825 }
826826 memset(ep, 0, sizeof(*ep));
827827
828− cpu = get_cpu();
828+ cpu = raw_smp_processor_id();
829829 pool = per_cpu_ptr(mp->pool, cpu);
830830 spin_lock_bh(&pool->lock);
831− put_cpu();
832831
833832 /* peek cache of free slot */
834833 if (pool->left != FC_XID_UNKNOWN) {
drivers/scsi/libfc/fc_fcp.c+10−19
@@ -143,8 +143,7 @@ static struct fc_fcp_pkt *fc_fcp_pkt_alloc(struct fc_lport *lport, gfp_t gfp) · 142 unmodified lines
143143 INIT_LIST_HEAD(&fsp->list);
144144 spin_lock_init(&fsp->scsi_pkt_lock);
145145 } else {
146− per_cpu_ptr(lport->stats, get_cpu())->FcpPktAllocFails++;
147− put_cpu();
146+ this_cpu_inc(lport->stats->FcpPktAllocFails);
148147 }
149148 return fsp;
150149 }
@@ -266,8 +265,7 @@ static int fc_fcp_send_abort(struct fc_fcp_pkt *fsp) · 115 unmodified lines
266265 if (!fsp->seq_ptr)
267266 return -EINVAL;
268267
269− per_cpu_ptr(fsp->lp->stats, get_cpu())->FcpPktAborts++;
270− put_cpu();
268+ this_cpu_inc(fsp->lp->stats->FcpPktAborts);
271269
272270 fsp->state |= FC_SRB_ABORT_PENDING;
273271 rc = fc_seq_exch_abort(fsp->seq_ptr, 0);
@@ -436,8 +434,7 @@ static inline struct fc_frame *fc_fcp_frame_alloc(struct fc_lport *lport, · 162 unmodified lines
436434 if (likely(fp))
437435 return fp;
438436
439− per_cpu_ptr(lport->stats, get_cpu())->FcpFrameAllocFails++;
440− put_cpu();
437+ this_cpu_inc(lport->stats->FcpFrameAllocFails);
441438 /* error case */
442439 fc_fcp_can_queue_ramp_down(lport);
443440 shost_printk(KERN_ERR, lport->host,
@@ -471,7 +468,6 @@ static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp) · 27 unmodified lines
471468 {
472469 struct scsi_cmnd *sc = fsp->cmd;
473470 struct fc_lport *lport = fsp->lp;
474− struct fc_stats *stats;
475471 struct fc_frame_header *fh;
476472 size_t start_offset;
477473 size_t offset;
@@ -533,14 +529,12 @@ static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp) · 55 unmodified lines
533529
534530 if (~crc != le32_to_cpu(fr_crc(fp))) {
535531 crc_err:
536− stats = per_cpu_ptr(lport->stats, get_cpu());
537− stats->ErrorFrames++;
532+ this_cpu_inc(lport->stats->ErrorFrames);
538533 /* per cpu count, not total count, but OK for limit */
539− if (stats->InvalidCRCCount++ < FC_MAX_ERROR_CNT)
534+ if (this_cpu_inc_return(lport->stats->InvalidCRCCount) < FC_MAX_ERROR_CNT)
540535 printk(KERN_WARNING "libfc: CRC error on data "
541536 "frame for port (%6.6x)\n",
542537 lport->port_id);
543− put_cpu();
544538 /*
545539 * Assume the frame is total garbage.
546540 * We may have copied it over the good part
@@ -1861,7 +1855,6 @@ int fc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc_cmd) · 1314 unmodified lines
18611855 struct fc_fcp_pkt *fsp;
18621856 int rval;
18631857 int rc = 0;
1864− struct fc_stats *stats;
18651858
18661859 rval = fc_remote_port_chkready(rport);
18671860 if (rval) {
@@ -1913,20 +1906,18 @@ int fc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc_cmd) · 45 unmodified lines
19131906 /*
19141907 * setup the data direction
19151908 */
1916− stats = per_cpu_ptr(lport->stats, get_cpu());
19171909 if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) {
19181910 fsp->req_flags = FC_SRB_READ;
1919− stats->InputRequests++;
1920− stats->InputBytes += fsp->data_len;
1911+ this_cpu_inc(lport->stats->InputRequests);
1912+ this_cpu_add(lport->stats->InputBytes, fsp->data_len);
19211913 } else if (sc_cmd->sc_data_direction == DMA_TO_DEVICE) {
19221914 fsp->req_flags = FC_SRB_WRITE;
1923− stats->OutputRequests++;
1924− stats->OutputBytes += fsp->data_len;
1915+ this_cpu_inc(lport->stats->OutputRequests);
1916+ this_cpu_add(lport->stats->OutputBytes, fsp->data_len);
19251917 } else {
19261918 fsp->req_flags = 0;
1927− stats->ControlRequests++;
1919+ this_cpu_inc(lport->stats->ControlRequests);
19281920 }
1929− put_cpu();
19301921
19311922 /*
19321923 * send it to the lower layer
drivers/scsi/libfc/fc_lport.c+15−15
@@ -308,21 +308,21 @@ struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost) · 307 unmodified lines
308308
309309 stats = per_cpu_ptr(lport->stats, cpu);
310310
311− fc_stats->tx_frames += stats->TxFrames;
312− fc_stats->tx_words += stats->TxWords;
313− fc_stats->rx_frames += stats->RxFrames;
314− fc_stats->rx_words += stats->RxWords;
315− fc_stats->error_frames += stats->ErrorFrames;
316− fc_stats->invalid_crc_count += stats->InvalidCRCCount;
317− fc_stats->fcp_input_requests += stats->InputRequests;
318− fc_stats->fcp_output_requests += stats->OutputRequests;
319− fc_stats->fcp_control_requests += stats->ControlRequests;
320− fcp_in_bytes += stats->InputBytes;
321− fcp_out_bytes += stats->OutputBytes;
322− fc_stats->fcp_packet_alloc_failures += stats->FcpPktAllocFails;
323− fc_stats->fcp_packet_aborts += stats->FcpPktAborts;
324− fc_stats->fcp_frame_alloc_failures += stats->FcpFrameAllocFails;
325− fc_stats->link_failure_count += stats->LinkFailureCount;
311+ fc_stats->tx_frames += READ_ONCE(stats->TxFrames);
312+ fc_stats->tx_words += READ_ONCE(stats->TxWords);
313+ fc_stats->rx_frames += READ_ONCE(stats->RxFrames);
314+ fc_stats->rx_words += READ_ONCE(stats->RxWords);
315+ fc_stats->error_frames += READ_ONCE(stats->ErrorFrames);
316+ fc_stats->invalid_crc_count += READ_ONCE(stats->InvalidCRCCount);
317+ fc_stats->fcp_input_requests += READ_ONCE(stats->InputRequests);
318+ fc_stats->fcp_output_requests += READ_ONCE(stats->OutputRequests);
319+ fc_stats->fcp_control_requests += READ_ONCE(stats->ControlRequests);
320+ fcp_in_bytes += READ_ONCE(stats->InputBytes);
321+ fcp_out_bytes += READ_ONCE(stats->OutputBytes);
322+ fc_stats->fcp_packet_alloc_failures += READ_ONCE(stats->FcpPktAllocFails);
323+ fc_stats->fcp_packet_aborts += READ_ONCE(stats->FcpPktAborts);
324+ fc_stats->fcp_frame_alloc_failures += READ_ONCE(stats->FcpFrameAllocFails);
325+ fc_stats->link_failure_count += READ_ONCE(stats->LinkFailureCount);
326326 }
327327 fc_stats->fcp_input_megabytes = div_u64(fcp_in_bytes, 1000000);
328328 fc_stats->fcp_output_megabytes = div_u64(fcp_out_bytes, 1000000);
drivers/scsi/libsas/sas_ata.c+27−14
@@ -358,22 +358,14 @@ static int sas_ata_printk(const char *level, const struct domain_device *ddev, · 357 unmodified lines
358358 return r;
359359 }
360360
361−static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class,
362− unsigned long deadline)
361+int sas_ata_wait_after_reset(struct domain_device *dev, unsigned long deadline)
363362 {
364− int ret = 0, res;
365− struct sas_phy *phy;
366− struct ata_port *ap = link->ap;
363+ struct sata_device *sata_dev = &dev->sata_dev;
367364 int (*check_ready)(struct ata_link *link);
368− struct domain_device *dev = ap->private_data;
369− struct sas_internal *i = dev_to_sas_internal(dev);
370−
371− res = i->dft->lldd_I_T_nexus_reset(dev);
372− if (res == -ENODEV)
373− return res;
374−
375− if (res != TMF_RESP_FUNC_COMPLETE)
376− sas_ata_printk(KERN_DEBUG, dev, "Unable to reset ata device?\n");
365+ struct ata_port *ap = sata_dev->ap;
366+ struct ata_link *link = &ap->link;
367+ struct sas_phy *phy;
368+ int ret;
377369
378370 phy = sas_get_local_phy(dev);
379371 if (scsi_is_sas_phy_local(phy))
@@ -386,6 +378,27 @@ static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class, · 6 unmodified lines
386378 if (ret && ret != -EAGAIN)
387379 sas_ata_printk(KERN_ERR, dev, "reset failed (errno=%d)\n", ret);
388380
381+ return ret;
382+}
383+EXPORT_SYMBOL_GPL(sas_ata_wait_after_reset);
384+
385+static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class,
386+ unsigned long deadline)
387+{
388+ struct ata_port *ap = link->ap;
389+ struct domain_device *dev = ap->private_data;
390+ struct sas_internal *i = dev_to_sas_internal(dev);
391+ int ret;
392+
393+ ret = i->dft->lldd_I_T_nexus_reset(dev);
394+ if (ret == -ENODEV)
395+ return ret;
396+
397+ if (ret != TMF_RESP_FUNC_COMPLETE)
398+ sas_ata_printk(KERN_DEBUG, dev, "Unable to reset ata device?\n");
399+
400+ ret = sas_ata_wait_after_reset(dev, deadline);
401+
389402 *class = dev->sata_dev.class;
390403
391404 ap->cbl = ATA_CBL_SATA;
drivers/scsi/lpfc/lpfc.h+7−3
@@ -604,6 +604,7 @@ struct lpfc_vport { · 603 unmodified lines
604604 #define FC_VFI_REGISTERED 0x800000 /* VFI is registered */
605605 #define FC_FDISC_COMPLETED 0x1000000/* FDISC completed */
606606 #define FC_DISC_DELAYED 0x2000000/* Delay NPort discovery */
607+#define FC_RSCN_MEMENTO 0x4000000/* RSCN cmd processed */
607608
608609 uint32_t ct_flags;
609610 #define FC_CT_RFF_ID 0x1 /* RFF_ID accepted by switch */
@@ -611,6 +612,7 @@ struct lpfc_vport { · 1 unmodified line
611612 #define FC_CT_RSNN_NN 0x4 /* RSNN_NN accepted by switch */
612613 #define FC_CT_RSPN_ID 0x8 /* RSPN_ID accepted by switch */
613614 #define FC_CT_RFT_ID 0x10 /* RFT_ID accepted by switch */
615+#define FC_CT_RPRT_DEFER 0x20 /* Defer issuing FDMI RPRT */
614616
615617 struct list_head fc_nodes;
616618
@@ -713,6 +715,7 @@ struct lpfc_vport { · 96 unmodified lines
713715 #define LPFC_VMID_QFPA_CMPL 0x4
714716 #define LPFC_VMID_QOS_ENABLED 0x8
715717 #define LPFC_VMID_TIMER_ENBLD 0x10
718+#define LPFC_VMID_TYPE_PRIO 0x20
716719 struct fc_qfpa_res *qfpa_res;
717720
718721 struct fc_vport *fc_vport;
@@ -738,9 +741,8 @@ struct lpfc_vport { · 19 unmodified lines
738741 struct list_head rcv_buffer_list;
739742 unsigned long rcv_buffer_time_stamp;
740743 uint32_t vport_flag;
741−#define STATIC_VPORT 1
742−#define FAWWPN_SET 2
743−#define FAWWPN_PARAM_CHG 4
744+#define STATIC_VPORT 0x1
745+#define FAWWPN_PARAM_CHG 0x2
744746
745747 uint16_t fdmi_num_disc;
746748 uint32_t fdmi_hba_mask;
@@ -1025,6 +1027,7 @@ struct lpfc_hba { · 278 unmodified lines
10251027 #define LS_MDS_LINK_DOWN 0x8 /* MDS Diagnostics Link Down */
10261028 #define LS_MDS_LOOPBACK 0x10 /* MDS Diagnostics Link Up (Loopback) */
10271029 #define LS_CT_VEN_RPA 0x20 /* Vendor RPA sent to switch */
1030+#define LS_EXTERNAL_LOOPBACK 0x40 /* External loopback plug inserted */
10281031
10291032 uint32_t hba_flag; /* hba generic flags */
10301033 #define HBA_ERATT_HANDLED 0x1 /* This flag is set when eratt handled */
@@ -1057,6 +1060,7 @@ struct lpfc_hba { · 26 unmodified lines
10571060 #define HBA_HBEAT_INP 0x4000000 /* mbox HBEAT is in progress */
10581061 #define HBA_HBEAT_TMO 0x8000000 /* HBEAT initiated after timeout */
10591062 #define HBA_FLOGI_OUTSTANDING 0x10000000 /* FLOGI is outstanding */
1063+#define HBA_RHBA_CMPL 0x20000000 /* RHBA FDMI command is successful */
10601064
10611065 struct completion *fw_dump_cmpl; /* cmpl event tracker for fw_dump */
10621066 uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/
drivers/scsi/lpfc/lpfc_attr.c+41−14
@@ -1,7 +1,7 @@
11 /*******************************************************************
22 * This file is part of the Emulex Linux Device Driver for *
33 * Fibre Channel Host Bus Adapters. *
4− * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term *
4+ * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
55 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
66 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
77 * EMULEX and SLI are trademarks of Emulex. *
@@ -1120,12 +1120,22 @@ lpfc_link_state_show(struct device *dev, struct device_attribute *attr, · 1112 unmodified lines
11201120 len += scnprintf(buf + len, PAGE_SIZE-len,
11211121 " Private Loop\n");
11221122 } else {
1123− if (vport->fc_flag & FC_FABRIC)
1124− len += scnprintf(buf + len, PAGE_SIZE-len,
1125− " Fabric\n");
1126− else
1123+ if (vport->fc_flag & FC_FABRIC) {
1124+ if (phba->sli_rev == LPFC_SLI_REV4 &&
1125+ vport->port_type == LPFC_PHYSICAL_PORT &&
1126+ phba->sli4_hba.fawwpn_flag &
1127+ LPFC_FAWWPN_FABRIC)
1128+ len += scnprintf(buf + len,
1129+ PAGE_SIZE - len,
1130+ " Fabric FA-PWWN\n");
1131+ else
1132+ len += scnprintf(buf + len,
1133+ PAGE_SIZE - len,
1134+ " Fabric\n");
1135+ } else {
11271136 len += scnprintf(buf + len, PAGE_SIZE-len,
11281137 " Point-2-Point\n");
1138+ }
11291139 }
11301140 }
11311141
@@ -6878,17 +6888,34 @@ lpfc_get_stats(struct Scsi_Host *shost) · 5746 unmodified lines
68786888 memset(hs, 0, sizeof (struct fc_host_statistics));
68796889
68806890 hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt;
6891+ hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt;
6892+
68816893 /*
6882− * The MBX_READ_STATUS returns tx_k_bytes which has to
6883− * converted to words
6894+ * The MBX_READ_STATUS returns tx_k_bytes which has to be
6895+ * converted to words.
6896+ *
6897+ * Check if extended byte flag is set, to know when to collect upper
6898+ * bits of 64 bit wide statistics counter.
68846899 */
6885− hs->tx_words = (uint64_t)
6886− ((uint64_t)pmb->un.varRdStatus.xmitByteCnt
6887− * (uint64_t)256);
6888− hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt;
6889− hs->rx_words = (uint64_t)
6890− ((uint64_t)pmb->un.varRdStatus.rcvByteCnt
6891− * (uint64_t)256);
6900+ if (pmb->un.varRdStatus.xkb & RD_ST_XKB) {
6901+ hs->tx_words = (u64)
6902+ ((((u64)(pmb->un.varRdStatus.xmit_xkb &
6903+ RD_ST_XMIT_XKB_MASK) << 32) |
6904+ (u64)pmb->un.varRdStatus.xmitByteCnt) *
6905+ (u64)256);
6906+ hs->rx_words = (u64)
6907+ ((((u64)(pmb->un.varRdStatus.rcv_xkb &
6908+ RD_ST_RCV_XKB_MASK) << 32) |
6909+ (u64)pmb->un.varRdStatus.rcvByteCnt) *
6910+ (u64)256);
6911+ } else {
6912+ hs->tx_words = (uint64_t)
6913+ ((uint64_t)pmb->un.varRdStatus.xmitByteCnt
6914+ * (uint64_t)256);
6915+ hs->rx_words = (uint64_t)
6916+ ((uint64_t)pmb->un.varRdStatus.rcvByteCnt
6917+ * (uint64_t)256);
6918+ }
68926919
68936920 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
68946921 pmb->mbxCommand = MBX_READ_LNK_STAT;
drivers/scsi/lpfc/lpfc_bsg.c+36−45
@@ -310,7 +310,7 @@ lpfc_bsg_send_mgmt_cmd_cmp(struct lpfc_hba *phba, · 309 unmodified lines
310310 int rc = 0;
311311 u32 ulp_status, ulp_word4, total_data_placed;
312312
313− dd_data = cmdiocbq->context1;
313+ dd_data = cmdiocbq->context_un.dd_data;
314314
315315 /* Determine if job has been aborted */
316316 spin_lock_irqsave(&phba->ct_ev_lock, flags);
@@ -328,10 +328,10 @@ lpfc_bsg_send_mgmt_cmd_cmp(struct lpfc_hba *phba, · 11 unmodified lines
328328 spin_unlock_irqrestore(&phba->hbalock, flags);
329329
330330 iocb = &dd_data->context_un.iocb;
331− ndlp = iocb->cmdiocbq->context_un.ndlp;
331+ ndlp = iocb->cmdiocbq->ndlp;
332332 rmp = iocb->rmp;
333− cmp = cmdiocbq->context2;
334− bmp = cmdiocbq->context3;
333+ cmp = cmdiocbq->cmd_dmabuf;
334+ bmp = cmdiocbq->bpl_dmabuf;
335335 ulp_status = get_job_ulpstatus(phba, rspiocbq);
336336 ulp_word4 = get_job_word4(phba, rspiocbq);
337337 total_data_placed = get_job_data_placed(phba, rspiocbq);
@@ -470,14 +470,12 @@ lpfc_bsg_send_mgmt_cmd(struct bsg_job *job) · 132 unmodified lines
470470
471471 cmdiocbq->num_bdes = num_entry;
472472 cmdiocbq->vport = phba->pport;
473− cmdiocbq->context2 = cmp;
474− cmdiocbq->context3 = bmp;
473+ cmdiocbq->cmd_dmabuf = cmp;
474+ cmdiocbq->bpl_dmabuf = bmp;
475475 cmdiocbq->cmd_flag |= LPFC_IO_LIBDFC;
476476
477477 cmdiocbq->cmd_cmpl = lpfc_bsg_send_mgmt_cmd_cmp;
478− cmdiocbq->context1 = dd_data;
479− cmdiocbq->context2 = cmp;
480− cmdiocbq->context3 = bmp;
478+ cmdiocbq->context_un.dd_data = dd_data;
481479
482480 dd_data->type = TYPE_IOCB;
483481 dd_data->set_job = job;
@@ -495,8 +493,8 @@ lpfc_bsg_send_mgmt_cmd(struct bsg_job *job) · 11 unmodified lines
495493 readl(phba->HCregaddr); /* flush */
496494 }
497495
498− cmdiocbq->context_un.ndlp = lpfc_nlp_get(ndlp);
499− if (!cmdiocbq->context_un.ndlp) {
496+ cmdiocbq->ndlp = lpfc_nlp_get(ndlp);
497+ if (!cmdiocbq->ndlp) {
500498 rc = -ENODEV;
501499 goto free_rmp;
502500 }
@@ -573,9 +571,9 @@ lpfc_bsg_rport_els_cmp(struct lpfc_hba *phba, · 70 unmodified lines
573571 int rc = 0;
574572 u32 ulp_status, ulp_word4, total_data_placed;
575573
576− dd_data = cmdiocbq->context1;
574+ dd_data = cmdiocbq->context_un.dd_data;
577575 ndlp = dd_data->context_un.iocb.ndlp;
578− cmdiocbq->context1 = ndlp;
576+ cmdiocbq->ndlp = ndlp;
579577
580578 /* Determine if job has been aborted */
581579 spin_lock_irqsave(&phba->ct_ev_lock, flags);
@@ -595,7 +593,7 @@ lpfc_bsg_rport_els_cmp(struct lpfc_hba *phba, · 13 unmodified lines
595593 ulp_status = get_job_ulpstatus(phba, rspiocbq);
596594 ulp_word4 = get_job_word4(phba, rspiocbq);
597595 total_data_placed = get_job_data_placed(phba, rspiocbq);
598− pcmd = (struct lpfc_dmabuf *)cmdiocbq->context2;
596+ pcmd = cmdiocbq->cmd_dmabuf;
599597 prsp = (struct lpfc_dmabuf *)pcmd->list.next;
600598
601599 /* Copy the completed job data or determine the job status if job is
@@ -711,8 +709,8 @@ lpfc_bsg_rport_els(struct bsg_job *job) · 109 unmodified lines
711709 /* Transfer the request payload to allocated command dma buffer */
712710 sg_copy_to_buffer(job->request_payload.sg_list,
713711 job->request_payload.sg_cnt,
714− ((struct lpfc_dmabuf *)cmdiocbq->context2)->virt,
715− job->request_payload.payload_len);
712+ cmdiocbq->cmd_dmabuf->virt,
713+ cmdsize);
716714
717715 rpi = ndlp->nlp_rpi;
718716
@@ -722,8 +720,8 @@ lpfc_bsg_rport_els(struct bsg_job *job) · 3 unmodified lines
722720 else
723721 cmdiocbq->iocb.ulpContext = rpi;
724722 cmdiocbq->cmd_flag |= LPFC_IO_LIBDFC;
725− cmdiocbq->context1 = dd_data;
726− cmdiocbq->context_un.ndlp = ndlp;
723+ cmdiocbq->context_un.dd_data = dd_data;
724+ cmdiocbq->ndlp = ndlp;
727725 cmdiocbq->cmd_cmpl = lpfc_bsg_rport_els_cmp;
728726 dd_data->type = TYPE_IOCB;
729727 dd_data->set_job = job;
@@ -742,12 +740,6 @@ lpfc_bsg_rport_els(struct bsg_job *job) · 12 unmodified lines
742740 readl(phba->HCregaddr); /* flush */
743741 }
744742
745− cmdiocbq->context1 = lpfc_nlp_get(ndlp);
746− if (!cmdiocbq->context1) {
747− rc = -EIO;
748− goto linkdown_err;
749− }
750−
751743 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, 0);
752744 if (rc == IOCB_SUCCESS) {
753745 spin_lock_irqsave(&phba->hbalock, flags);
@@ -917,8 +909,8 @@ lpfc_bsg_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 163 unmodified lines
917909 struct ulp_bde64 *bde;
918910 dma_addr_t dma_addr;
919911 int i;
920− struct lpfc_dmabuf *bdeBuf1 = piocbq->context2;
921− struct lpfc_dmabuf *bdeBuf2 = piocbq->context3;
912+ struct lpfc_dmabuf *bdeBuf1 = piocbq->cmd_dmabuf;
913+ struct lpfc_dmabuf *bdeBuf2 = piocbq->bpl_dmabuf;
922914 struct lpfc_sli_ct_request *ct_req;
923915 struct bsg_job *job = NULL;
924916 struct fc_bsg_reply *bsg_reply;
@@ -985,9 +977,8 @@ lpfc_bsg_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 60 unmodified lines
985977 list_for_each_entry(iocbq, &head, list) {
986978 size = 0;
987979 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {
988− bdeBuf1 = iocbq->context2;
989− bdeBuf2 = iocbq->context3;
990−
980+ bdeBuf1 = iocbq->cmd_dmabuf;
981+ bdeBuf2 = iocbq->bpl_dmabuf;
991982 }
992983 if (phba->sli_rev == LPFC_SLI_REV4)
993984 bde_count = iocbq->wcqe_cmpl.word3;
@@ -1384,7 +1375,7 @@ lpfc_issue_ct_rsp_cmp(struct lpfc_hba *phba, · 390 unmodified lines
13841375 int rc = 0;
13851376 u32 ulp_status, ulp_word4;
13861377
1387− dd_data = cmdiocbq->context1;
1378+ dd_data = cmdiocbq->context_un.dd_data;
13881379
13891380 /* Determine if job has been aborted */
13901381 spin_lock_irqsave(&phba->ct_ev_lock, flags);
@@ -1401,8 +1392,8 @@ lpfc_issue_ct_rsp_cmp(struct lpfc_hba *phba, · 10 unmodified lines
14011392 spin_unlock_irqrestore(&phba->hbalock, flags);
14021393
14031394 ndlp = dd_data->context_un.iocb.ndlp;
1404− cmp = cmdiocbq->context2;
1405− bmp = cmdiocbq->context3;
1395+ cmp = cmdiocbq->cmd_dmabuf;
1396+ bmp = cmdiocbq->bpl_dmabuf;
14061397
14071398 ulp_status = get_job_ulpstatus(phba, rspiocbq);
14081399 ulp_word4 = get_job_word4(phba, rspiocbq);
@@ -1529,10 +1520,10 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct bsg_job *job, uint32_t tag, · 120 unmodified lines
15291520
15301521 ctiocb->cmd_flag |= LPFC_IO_LIBDFC;
15311522 ctiocb->vport = phba->pport;
1532− ctiocb->context1 = dd_data;
1533− ctiocb->context2 = cmp;
1534− ctiocb->context3 = bmp;
1535− ctiocb->context_un.ndlp = ndlp;
1523+ ctiocb->context_un.dd_data = dd_data;
1524+ ctiocb->cmd_dmabuf = cmp;
1525+ ctiocb->bpl_dmabuf = bmp;
1526+ ctiocb->ndlp = ndlp;
15361527 ctiocb->cmd_cmpl = lpfc_issue_ct_rsp_cmp;
15371528
15381529 dd_data->type = TYPE_IOCB;
@@ -2671,7 +2662,7 @@ static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, uint16_t rpi, · 1132 unmodified lines
26712662 ctreq->CommandResponse.bits.CmdRsp = ELX_LOOPBACK_XRI_SETUP;
26722663 ctreq->CommandResponse.bits.Size = 0;
26732664
2674− cmdiocbq->context3 = dmabuf;
2665+ cmdiocbq->bpl_dmabuf = dmabuf;
26752666 cmdiocbq->cmd_flag |= LPFC_IO_LIBDFC;
26762667 cmdiocbq->vport = phba->pport;
26772668 cmdiocbq->cmd_cmpl = NULL;
@@ -3231,7 +3222,7 @@ lpfc_bsg_diag_loopback_run(struct bsg_job *job) · 553 unmodified lines
32313222 cmdiocbq->cmd_flag |= LPFC_IO_LOOPBACK;
32323223 cmdiocbq->vport = phba->pport;
32333224 cmdiocbq->cmd_cmpl = NULL;
3234− cmdiocbq->context3 = txbmp;
3225+ cmdiocbq->bpl_dmabuf = txbmp;
32353226
32363227 if (phba->sli_rev < LPFC_SLI_REV4) {
32373228 lpfc_sli_prep_xmit_seq64(phba, cmdiocbq, txbmp, 0, txxri,
@@ -3384,7 +3375,7 @@ job_error: · 146 unmodified lines
33843375 * This is completion handler function for mailbox commands issued from
33853376 * lpfc_bsg_issue_mbox function. This function is called by the
33863377 * mailbox event handler function with no lock held. This function
3387− * will wake up thread waiting on the wait queue pointed by context1
3378+ * will wake up thread waiting on the wait queue pointed by dd_data
33883379 * of the mailbox.
33893380 **/
33903381 static void
@@ -5034,9 +5025,9 @@ lpfc_bsg_menlo_cmd_cmp(struct lpfc_hba *phba, · 1643 unmodified lines
50345025 unsigned int rsp_size;
50355026 int rc = 0;
50365027
5037− dd_data = cmdiocbq->context1;
5038− cmp = cmdiocbq->context2;
5039− bmp = cmdiocbq->context3;
5028+ dd_data = cmdiocbq->context_un.dd_data;
5029+ cmp = cmdiocbq->cmd_dmabuf;
5030+ bmp = cmdiocbq->bpl_dmabuf;
50405031 menlo = &dd_data->context_un.menlo;
50415032 rmp = menlo->rmp;
50425033 rsp = &rspiocbq->iocb;
@@ -5233,9 +5224,9 @@ lpfc_menlo_cmd(struct bsg_job *job) · 190 unmodified lines
52335224 /* We want the firmware to timeout before we do */
52345225 cmd->ulpTimeout = MENLO_TIMEOUT - 5;
52355226 cmdiocbq->cmd_cmpl = lpfc_bsg_menlo_cmd_cmp;
5236− cmdiocbq->context1 = dd_data;
5237− cmdiocbq->context2 = cmp;
5238− cmdiocbq->context3 = bmp;
5227+ cmdiocbq->context_un.dd_data = dd_data;
5228+ cmdiocbq->cmd_dmabuf = cmp;
5229+ cmdiocbq->bpl_dmabuf = bmp;
52395230 if (menlo_cmd->cmd == LPFC_BSG_VENDOR_MENLO_CMD) {
52405231 cmd->ulpCommand = CMD_GEN_REQUEST64_CR;
52415232 cmd->ulpPU = MENLO_PU; /* 3 */
drivers/scsi/lpfc/lpfc_crtn.h+4−1
@@ -32,7 +32,9 @@ int lpfc_dump_static_vport(struct lpfc_hba *, LPFC_MBOXQ_t *, uint16_t); · 31 unmodified lines
3232 int lpfc_sli4_dump_cfg_rg23(struct lpfc_hba *, struct lpfcMboxq *);
3333 void lpfc_read_nv(struct lpfc_hba *, LPFC_MBOXQ_t *);
3434 void lpfc_config_async(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t);
35−
35+int lpfc_mbox_rsrc_prep(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox);
36+void lpfc_mbox_rsrc_cleanup(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox,
37+ enum lpfc_mbox_ctx locked);
3638 void lpfc_heart_beat(struct lpfc_hba *, LPFC_MBOXQ_t *);
3739 int lpfc_read_topology(struct lpfc_hba *, LPFC_MBOXQ_t *, struct lpfc_dmabuf *);
3840 void lpfc_clear_la(struct lpfc_hba *, LPFC_MBOXQ_t *);
@@ -432,6 +434,7 @@ void lpfc_nvmet_buf_free(struct lpfc_hba *phba, void *virtp, dma_addr_t dma); · 393 unmodified lines
432434
433435 void lpfc_in_buf_free(struct lpfc_hba *, struct lpfc_dmabuf *);
434436 void lpfc_rq_buf_free(struct lpfc_hba *phba, struct lpfc_dmabuf *mp);
437+void lpfc_setup_fdmi_mask(struct lpfc_vport *vport);
435438 int lpfc_link_reset(struct lpfc_vport *vport);
436439
437440 /* Function prototypes. */
drivers/scsi/lpfc/lpfc_ct.c+246−120
@@ -118,22 +118,22 @@ lpfc_ct_unsol_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 117 unmodified lines
118118 struct lpfc_nodelist *ndlp;
119119 struct lpfc_dmabuf *mp, *bmp;
120120
121− ndlp = (struct lpfc_nodelist *)cmdiocb->context1;
121+ ndlp = cmdiocb->ndlp;
122122 if (ndlp)
123123 lpfc_nlp_put(ndlp);
124124
125− mp = cmdiocb->context2;
126− bmp = cmdiocb->context3;
125+ mp = cmdiocb->rsp_dmabuf;
126+ bmp = cmdiocb->bpl_dmabuf;
127127 if (mp) {
128128 lpfc_mbuf_free(phba, mp->virt, mp->phys);
129129 kfree(mp);
130− cmdiocb->context2 = NULL;
130+ cmdiocb->rsp_dmabuf = NULL;
131131 }
132132
133133 if (bmp) {
134134 lpfc_mbuf_free(phba, bmp->virt, bmp->phys);
135135 kfree(bmp);
136− cmdiocb->context3 = NULL;
136+ cmdiocb->bpl_dmabuf = NULL;
137137 }
138138
139139 lpfc_sli_release_iocbq(phba, cmdiocb);
@@ -232,18 +232,17 @@ lpfc_ct_reject_event(struct lpfc_nodelist *ndlp, · 92 unmodified lines
232232 }
233233
234234 /* Save for completion so we can release these resources */
235− cmdiocbq->context2 = (uint8_t *)mp;
236− cmdiocbq->context3 = (uint8_t *)bmp;
235+ cmdiocbq->rsp_dmabuf = mp;
236+ cmdiocbq->bpl_dmabuf = bmp;
237237 cmdiocbq->cmd_cmpl = lpfc_ct_unsol_cmpl;
238238 tmo = (3 * phba->fc_ratov);
239239
240240 cmdiocbq->retry = 0;
241241 cmdiocbq->vport = vport;
242− cmdiocbq->context_un.ndlp = NULL;
243242 cmdiocbq->drvrTimeout = tmo + LPFC_DRVR_TIMEOUT;
244243
245− cmdiocbq->context1 = lpfc_nlp_get(ndlp);
246− if (!cmdiocbq->context1)
244+ cmdiocbq->ndlp = lpfc_nlp_get(ndlp);
245+ if (!cmdiocbq->ndlp)
247246 goto ct_no_ndlp;
248247
249248 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, 0);
@@ -310,8 +309,8 @@ lpfc_ct_handle_mibreq(struct lpfc_hba *phba, struct lpfc_iocbq *ctiocbq) · 60 unmodified lines
310309 return;
311310 }
312311
313− ct_req = ((struct lpfc_sli_ct_request *)
314− (((struct lpfc_dmabuf *)ctiocbq->context2)->virt));
312+ ct_req = (struct lpfc_sli_ct_request *)ctiocbq->cmd_dmabuf->virt;
313+
315314 mi_cmd = ct_req->CommandResponse.bits.CmdRsp;
316315 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
317316 "6442 : MI Cmd : x%x Not Supported\n", mi_cmd);
@@ -347,14 +346,14 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 29 unmodified lines
347346 uint32_t size;
348347 struct list_head head;
349348 struct lpfc_sli_ct_request *ct_req;
350− struct lpfc_dmabuf *bdeBuf1 = ctiocbq->context2;
351− struct lpfc_dmabuf *bdeBuf2 = ctiocbq->context3;
349+ struct lpfc_dmabuf *bdeBuf1 = ctiocbq->cmd_dmabuf;
350+ struct lpfc_dmabuf *bdeBuf2 = ctiocbq->bpl_dmabuf;
352351 u32 status, parameter, bde_count = 0;
353352 struct lpfc_wcqe_complete *wcqe_cmpl = NULL;
354353
355− ctiocbq->context1 = NULL;
356− ctiocbq->context2 = NULL;
357− ctiocbq->context3 = NULL;
354+ ctiocbq->cmd_dmabuf = NULL;
355+ ctiocbq->rsp_dmabuf = NULL;
356+ ctiocbq->bpl_dmabuf = NULL;
358357
359358 wcqe_cmpl = &ctiocbq->wcqe_cmpl;
360359 status = get_job_ulpstatus(phba, ctiocbq);
@@ -382,12 +381,11 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 21 unmodified lines
382381 if (bde_count == 0)
383382 return;
384383
385− ctiocbq->context2 = bdeBuf1;
384+ ctiocbq->cmd_dmabuf = bdeBuf1;
386385 if (bde_count == 2)
387− ctiocbq->context3 = bdeBuf2;
386+ ctiocbq->bpl_dmabuf = bdeBuf2;
388387
389− ct_req = ((struct lpfc_sli_ct_request *)
390− (((struct lpfc_dmabuf *)ctiocbq->context2)->virt));
388+ ct_req = (struct lpfc_sli_ct_request *)ctiocbq->cmd_dmabuf->virt;
391389
392390 if (ct_req->FsType == SLI_CT_MANAGEMENT_SERVICE &&
393391 ct_req->FsSubType == SLI_CT_MIB_Subtypes) {
@@ -408,8 +406,8 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 14 unmodified lines
408406
409407 if (!bde_count)
410408 continue;
411− bdeBuf1 = iocb->context2;
412− iocb->context2 = NULL;
409+ bdeBuf1 = iocb->cmd_dmabuf;
410+ iocb->cmd_dmabuf = NULL;
413411 if (phba->sli_rev == LPFC_SLI_REV4)
414412 size = iocb->wqe.gen_req.bde.tus.f.bdeSize;
415413 else
@@ -417,8 +415,8 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 1 unmodified line
417415 lpfc_ct_unsol_buffer(phba, ctiocbq, bdeBuf1, size);
418416 lpfc_in_buf_free(phba, bdeBuf1);
419417 if (bde_count == 2) {
420− bdeBuf2 = iocb->context3;
421− iocb->context3 = NULL;
418+ bdeBuf2 = iocb->bpl_dmabuf;
419+ iocb->bpl_dmabuf = NULL;
422420 if (phba->sli_rev == LPFC_SLI_REV4)
423421 size = iocb->unsol_rcv_len;
424422 else
@@ -549,24 +547,25 @@ lpfc_ct_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *ctiocb) · 124 unmodified lines
549547 {
550548 struct lpfc_dmabuf *buf_ptr;
551549
552− /* I/O job is complete so context is now invalid*/
553− ctiocb->context_un.ndlp = NULL;
554− if (ctiocb->context1) {
555− buf_ptr = (struct lpfc_dmabuf *) ctiocb->context1;
550+ /* IOCBQ job structure gets cleaned during release. Just release
551+ * the dma buffers here.
552+ */
553+ if (ctiocb->cmd_dmabuf) {
554+ buf_ptr = ctiocb->cmd_dmabuf;
556555 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
557556 kfree(buf_ptr);
558− ctiocb->context1 = NULL;
557+ ctiocb->cmd_dmabuf = NULL;
559558 }
560− if (ctiocb->context2) {
561− lpfc_free_ct_rsp(phba, (struct lpfc_dmabuf *) ctiocb->context2);
562− ctiocb->context2 = NULL;
559+ if (ctiocb->rsp_dmabuf) {
560+ lpfc_free_ct_rsp(phba, ctiocb->rsp_dmabuf);
561+ ctiocb->rsp_dmabuf = NULL;
563562 }
564563
565− if (ctiocb->context3) {
566− buf_ptr = (struct lpfc_dmabuf *) ctiocb->context3;
564+ if (ctiocb->bpl_dmabuf) {
565+ buf_ptr = ctiocb->bpl_dmabuf;
567566 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
568567 kfree(buf_ptr);
569− ctiocb->context3 = NULL;
568+ ctiocb->bpl_dmabuf = NULL;
570569 }
571570 lpfc_sli_release_iocbq(phba, ctiocb);
572571 return 0;
@@ -605,11 +604,11 @@ lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, · 32 unmodified lines
605604 /* Update the num_entry bde count */
606605 geniocb->num_bdes = num_entry;
607606
608− geniocb->context3 = (uint8_t *) bmp;
607+ geniocb->bpl_dmabuf = bmp;
609608
610609 /* Save for completion so we can release these resources */
611− geniocb->context1 = (uint8_t *) inp;
612− geniocb->context2 = (uint8_t *) outp;
610+ geniocb->cmd_dmabuf = inp;
611+ geniocb->rsp_dmabuf = outp;
613612
614613 geniocb->event_tag = event_tag;
615614
@@ -635,8 +634,8 @@ lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, · 19 unmodified lines
635634 geniocb->drvrTimeout = tmo + LPFC_DRVR_TIMEOUT;
636635 geniocb->vport = vport;
637636 geniocb->retry = retry;
638− geniocb->context_un.ndlp = lpfc_nlp_get(ndlp);
639− if (!geniocb->context_un.ndlp)
637+ geniocb->ndlp = lpfc_nlp_get(ndlp);
638+ if (!geniocb->ndlp)
640639 goto out;
641640
642641 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, geniocb, 0);
@@ -926,13 +925,12 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 283 unmodified lines
926925 int rc, type;
927926
928927 /* First save ndlp, before we overwrite it */
929− ndlp = cmdiocb->context_un.ndlp;
928+ ndlp = cmdiocb->ndlp;
930929
931930 /* we pass cmdiocb to state machine which needs rspiocb as well */
932− cmdiocb->context_un.rsp_iocb = rspiocb;
933−
934− inp = (struct lpfc_dmabuf *) cmdiocb->context1;
935− outp = (struct lpfc_dmabuf *) cmdiocb->context2;
931+ cmdiocb->rsp_iocb = rspiocb;
932+ inp = cmdiocb->cmd_dmabuf;
933+ outp = cmdiocb->rsp_dmabuf;
936934
937935 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
938936 "GID_FT cmpl: status:x%x/x%x rtry:%d",
@@ -962,9 +960,15 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 23 unmodified lines
962960 }
963961 if (lpfc_error_lost_link(ulp_status, ulp_word4)) {
964962 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
965− "0226 NS query failed due to link event\n");
963+ "0226 NS query failed due to link event: "
964+ "ulp_status x%x ulp_word4 x%x fc_flag x%x "
965+ "port_state x%x gidft_inp x%x\n",
966+ ulp_status, ulp_word4, vport->fc_flag,
967+ vport->port_state, vport->gidft_inp);
966968 if (vport->fc_flag & FC_RSCN_MODE)
967969 lpfc_els_flush_rscn(vport);
970+ if (vport->gidft_inp)
971+ vport->gidft_inp--;
968972 goto out;
969973 }
970974
@@ -1143,12 +1147,12 @@ lpfc_cmpl_ct_cmd_gid_pt(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 172 unmodified lines
11431147 int rc;
11441148
11451149 /* First save ndlp, before we overwrite it */
1146− ndlp = cmdiocb->context_un.ndlp;
1150+ ndlp = cmdiocb->ndlp;
11471151
11481152 /* we pass cmdiocb to state machine which needs rspiocb as well */
1149− cmdiocb->context_un.rsp_iocb = rspiocb;
1150− inp = (struct lpfc_dmabuf *)cmdiocb->context1;
1151− outp = (struct lpfc_dmabuf *)cmdiocb->context2;
1153+ cmdiocb->rsp_iocb = rspiocb;
1154+ inp = cmdiocb->cmd_dmabuf;
1155+ outp = cmdiocb->rsp_dmabuf;
11521156
11531157 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
11541158 "GID_PT cmpl: status:x%x/x%x rtry:%d",
@@ -1179,9 +1183,15 @@ lpfc_cmpl_ct_cmd_gid_pt(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 24 unmodified lines
11791183 }
11801184 if (lpfc_error_lost_link(ulp_status, ulp_word4)) {
11811185 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1182− "4166 NS query failed due to link event\n");
1186+ "4166 NS query failed due to link event: "
1187+ "ulp_status x%x ulp_word4 x%x fc_flag x%x "
1188+ "port_state x%x gidft_inp x%x\n",
1189+ ulp_status, ulp_word4, vport->fc_flag,
1190+ vport->port_state, vport->gidft_inp);
11831191 if (vport->fc_flag & FC_RSCN_MODE)
11841192 lpfc_els_flush_rscn(vport);
1193+ if (vport->gidft_inp)
1194+ vport->gidft_inp--;
11851195 goto out;
11861196 }
11871197
@@ -1346,8 +1356,8 @@ lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 158 unmodified lines
13461356 {
13471357 struct lpfc_vport *vport = cmdiocb->vport;
13481358 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1349− struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *) cmdiocb->context1;
1350− struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *) cmdiocb->context2;
1359+ struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf;
1360+ struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf;
13511361 struct lpfc_sli_ct_request *CTrsp;
13521362 int did, rc, retry;
13531363 uint8_t fbits;
@@ -1426,7 +1436,7 @@ lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 72 unmodified lines
14261436 cmdiocb->retry, did);
14271437 if (rc == 0) {
14281438 /* success */
1429− free_ndlp = cmdiocb->context_un.ndlp;
1439+ free_ndlp = cmdiocb->ndlp;
14301440 lpfc_ct_free_iocb(phba, cmdiocb);
14311441 lpfc_nlp_put(free_ndlp);
14321442 return;
@@ -1483,7 +1493,7 @@ out: · 50 unmodified lines
14831493 }
14841494
14851495 iocb_free:
1486− free_ndlp = cmdiocb->context_un.ndlp;
1496+ free_ndlp = cmdiocb->ndlp;
14871497 lpfc_ct_free_iocb(phba, cmdiocb);
14881498 lpfc_nlp_put(free_ndlp);
14891499 return;
@@ -1494,8 +1504,8 @@ lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 4 unmodified lines
14941504 struct lpfc_iocbq *rspiocb)
14951505 {
14961506 struct lpfc_vport *vport = cmdiocb->vport;
1497− struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *)cmdiocb->context1;
1498− struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *)cmdiocb->context2;
1507+ struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf;
1508+ struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf;
14991509 struct lpfc_sli_ct_request *CTrsp;
15001510 int did;
15011511 struct lpfc_nodelist *ndlp = NULL;
@@ -1519,7 +1529,7 @@ lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 17 unmodified lines
15191529 }
15201530
15211531 /* Preserve the nameserver node to release the reference. */
1522− ns_ndlp = cmdiocb->context_un.ndlp;
1532+ ns_ndlp = cmdiocb->ndlp;
15231533
15241534 if (ulp_status == IOSTAT_SUCCESS) {
15251535 /* Good status, continue checking */
@@ -1605,13 +1615,13 @@ lpfc_cmpl_ct(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 79 unmodified lines
16051615 u32 ulp_word4 = get_job_word4(phba, rspiocb);
16061616
16071617 /* First save ndlp, before we overwrite it */
1608− ndlp = cmdiocb->context_un.ndlp;
1618+ ndlp = cmdiocb->ndlp;
16091619
16101620 /* we pass cmdiocb to state machine which needs rspiocb as well */
1611− cmdiocb->context_un.rsp_iocb = rspiocb;
1621+ cmdiocb->rsp_iocb = rspiocb;
16121622
1613− inp = (struct lpfc_dmabuf *) cmdiocb->context1;
1614− outp = (struct lpfc_dmabuf *) cmdiocb->context2;
1623+ inp = cmdiocb->cmd_dmabuf;
1624+ outp = cmdiocb->rsp_dmabuf;
16151625
16161626 cmdcode = be16_to_cpu(((struct lpfc_sli_ct_request *) inp->virt)->
16171627 CommandResponse.bits.CmdRsp);
@@ -1672,8 +1682,8 @@ lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 54 unmodified lines
16721682 struct lpfc_dmabuf *outp;
16731683 struct lpfc_sli_ct_request *CTrsp;
16741684
1675− outp = (struct lpfc_dmabuf *) cmdiocb->context2;
1676− CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
1685+ outp = cmdiocb->rsp_dmabuf;
1686+ CTrsp = (struct lpfc_sli_ct_request *)outp->virt;
16771687 if (CTrsp->CommandResponse.bits.CmdRsp ==
16781688 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
16791689 vport->ct_flags |= FC_CT_RFT_ID;
@@ -1693,7 +1703,7 @@ lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 13 unmodified lines
16931703 struct lpfc_dmabuf *outp;
16941704 struct lpfc_sli_ct_request *CTrsp;
16951705
1696− outp = (struct lpfc_dmabuf *) cmdiocb->context2;
1706+ outp = cmdiocb->rsp_dmabuf;
16971707 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
16981708 if (CTrsp->CommandResponse.bits.CmdRsp ==
16991709 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
@@ -1714,8 +1724,8 @@ lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 14 unmodified lines
17141724 struct lpfc_dmabuf *outp;
17151725 struct lpfc_sli_ct_request *CTrsp;
17161726
1717− outp = (struct lpfc_dmabuf *) cmdiocb->context2;
1718− CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
1727+ outp = cmdiocb->rsp_dmabuf;
1728+ CTrsp = (struct lpfc_sli_ct_request *)outp->virt;
17191729 if (CTrsp->CommandResponse.bits.CmdRsp ==
17201730 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
17211731 vport->ct_flags |= FC_CT_RSPN_ID;
@@ -1735,7 +1745,7 @@ lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 13 unmodified lines
17351745 struct lpfc_dmabuf *outp;
17361746 struct lpfc_sli_ct_request *CTrsp;
17371747
1738− outp = (struct lpfc_dmabuf *) cmdiocb->context2;
1748+ outp = cmdiocb->rsp_dmabuf;
17391749 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
17401750 if (CTrsp->CommandResponse.bits.CmdRsp ==
17411751 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
@@ -1768,8 +1778,8 @@ lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 26 unmodified lines
17681778 struct lpfc_dmabuf *outp;
17691779 struct lpfc_sli_ct_request *CTrsp;
17701780
1771− outp = (struct lpfc_dmabuf *) cmdiocb->context2;
1772− CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
1781+ outp = cmdiocb->rsp_dmabuf;
1782+ CTrsp = (struct lpfc_sli_ct_request *)outp->virt;
17731783 if (CTrsp->CommandResponse.bits.CmdRsp ==
17741784 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
17751785 vport->ct_flags |= FC_CT_RFF_ID;
@@ -1865,7 +1875,7 @@ lpfc_get_gidft_type(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb) · 89 unmodified lines
18651875 struct lpfc_dmabuf *mp;
18661876 uint32_t type;
18671877
1868− mp = cmdiocb->context1;
1878+ mp = cmdiocb->cmd_dmabuf;
18691879 if (mp == NULL)
18701880 return 0;
18711881 CtReq = (struct lpfc_sli_ct_request *)mp->virt;
@@ -2018,28 +2028,30 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, · 146 unmodified lines
20182028 vport->ct_flags &= ~FC_CT_RFT_ID;
20192029 CtReq->CommandResponse.bits.CmdRsp =
20202030 cpu_to_be16(SLI_CTNS_RFT_ID);
2021− CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID);
2031+ CtReq->un.rft.port_id = cpu_to_be32(vport->fc_myDID);
2032+
2033+ /* Register Application Services type if vmid enabled. */
2034+ if (phba->cfg_vmid_app_header)
2035+ CtReq->un.rft.app_serv_reg =
2036+ cpu_to_be32(RFT_APP_SERV_REG);
20222037
20232038 /* Register FC4 FCP type if enabled. */
20242039 if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH ||
20252040 vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP)
2026− CtReq->un.rft.fcpReg = 1;
2041+ CtReq->un.rft.fcp_reg = cpu_to_be32(RFT_FCP_REG);
20272042
2028− /* Register NVME type if enabled. Defined LE and swapped.
2029− * rsvd[0] is used as word1 because of the hard-coded
2030− * word0 usage in the ct_request data structure.
2031− */
2043+ /* Register NVME type if enabled. */
20322044 if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH ||
20332045 vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
2034− CtReq->un.rft.rsvd[0] =
2035− cpu_to_be32(LPFC_FC4_TYPE_BITMASK);
2046+ CtReq->un.rft.nvme_reg = cpu_to_be32(RFT_NVME_REG);
20362047
20372048 ptr = (uint32_t *)CtReq;
20382049 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2039− "6433 Issue RFT (%s %s): %08x %08x %08x %08x "
2040− "%08x %08x %08x %08x\n",
2041− CtReq->un.rft.fcpReg ? "FCP" : " ",
2042− CtReq->un.rft.rsvd[0] ? "NVME" : " ",
2050+ "6433 Issue RFT (%s %s %s): %08x %08x %08x "
2051+ "%08x %08x %08x %08x %08x\n",
2052+ CtReq->un.rft.fcp_reg ? "FCP" : " ",
2053+ CtReq->un.rft.nvme_reg ? "NVME" : " ",
2054+ CtReq->un.rft.app_serv_reg ? "APPS" : " ",
20432055 *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3),
20442056 *(ptr + 4), *(ptr + 5),
20452057 *(ptr + 6), *(ptr + 7));
@@ -2155,6 +2167,41 @@ ns_cmd_exit: · 109 unmodified lines
21552167 return 1;
21562168 }
21572169
2170+/**
2171+ * lpfc_fdmi_rprt_defer - Check for any deferred FDMI RPRT commands
2172+ * @phba: Pointer to HBA context object.
2173+ * @mask: Initial port attributes mask
2174+ *
2175+ * This function checks to see if any vports have deferred their FDMI RPRT.
2176+ * A vports RPRT may be deferred if it is issued before the primary ports
2177+ * RHBA completes.
2178+ */
2179+static void
2180+lpfc_fdmi_rprt_defer(struct lpfc_hba *phba, uint32_t mask)
2181+{
2182+ struct lpfc_vport **vports;
2183+ struct lpfc_vport *vport;
2184+ struct lpfc_nodelist *ndlp;
2185+ int i;
2186+
2187+ phba->hba_flag |= HBA_RHBA_CMPL;
2188+ vports = lpfc_create_vport_work_array(phba);
2189+ if (vports) {
2190+ for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
2191+ vport = vports[i];
2192+ ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
2193+ if (!ndlp)
2194+ continue;
2195+ if (vport->ct_flags & FC_CT_RPRT_DEFER) {
2196+ vport->ct_flags &= ~FC_CT_RPRT_DEFER;
2197+ vport->fdmi_port_mask = mask;
2198+ lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT, 0);
2199+ }
2200+ }
2201+ }
2202+ lpfc_destroy_vport_work_array(phba, vports);
2203+}
2204+
21582205 /**
21592206 * lpfc_cmpl_ct_disc_fdmi - Handle a discovery FDMI completion
21602207 * @phba: Pointer to HBA context object.
@@ -2169,8 +2216,8 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 8 unmodified lines
21692216 struct lpfc_iocbq *rspiocb)
21702217 {
21712218 struct lpfc_vport *vport = cmdiocb->vport;
2172− struct lpfc_dmabuf *inp = cmdiocb->context1;
2173− struct lpfc_dmabuf *outp = cmdiocb->context2;
2219+ struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf;
2220+ struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf;
21742221 struct lpfc_sli_ct_request *CTcmd = inp->virt;
21752222 struct lpfc_sli_ct_request *CTrsp = outp->virt;
21762223 uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp;
@@ -2224,7 +2271,7 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 47 unmodified lines
22242271 ulp_word4);
22252272 }
22262273
2227− free_ndlp = cmdiocb->context_un.ndlp;
2274+ free_ndlp = cmdiocb->ndlp;
22282275 lpfc_ct_free_iocb(phba, cmdiocb);
22292276 lpfc_nlp_put(free_ndlp);
22302277
@@ -2236,15 +2283,19 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 5 unmodified lines
22362283 cmd = be16_to_cpu(fdmi_cmd);
22372284 if (fdmi_rsp == cpu_to_be16(SLI_CT_RESPONSE_FS_RJT)) {
22382285 /* FDMI rsp failed */
2239− lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2286+ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY | LOG_ELS,
22402287 "0220 FDMI cmd failed FS_RJT Data: x%x", cmd);
22412288
22422289 /* Should we fallback to FDMI-2 / FDMI-1 ? */
22432290 switch (cmd) {
22442291 case SLI_MGMT_RHBA:
22452292 if (vport->fdmi_hba_mask == LPFC_FDMI2_HBA_ATTR) {
2246− /* Fallback to FDMI-1 */
2293+ /* Fallback to FDMI-1 for HBA attributes */
22472294 vport->fdmi_hba_mask = LPFC_FDMI1_HBA_ATTR;
2295+
2296+ /* If HBA attributes are FDMI1, so should
2297+ * port attributes be for consistency.
2298+ */
22482299 vport->fdmi_port_mask = LPFC_FDMI1_PORT_ATTR;
22492300 /* Start over */
22502301 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA, 0);
@@ -2252,6 +2303,11 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 1 unmodified line
22522303 return;
22532304
22542305 case SLI_MGMT_RPRT:
2306+ if (vport->port_type != LPFC_PHYSICAL_PORT) {
2307+ ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
2308+ if (!ndlp)
2309+ return;
2310+ }
22552311 if (vport->fdmi_port_mask == LPFC_FDMI2_PORT_ATTR) {
22562312 /* Fallback to FDMI-1 */
22572313 vport->fdmi_port_mask = LPFC_FDMI1_PORT_ATTR;
@@ -2272,9 +2328,9 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 14 unmodified lines
22722328 phba->link_flag &= ~LS_CT_VEN_RPA;
22732329 if (phba->cmf_active_mode == LPFC_CFG_OFF)
22742330 return;
2275− lpfc_printf_log(phba, KERN_ERR,
2331+ lpfc_printf_log(phba, KERN_WARNING,
22762332 LOG_DISCOVERY | LOG_ELS,
2277− "6460 VEN FDMI RPA failure\n");
2333+ "6460 VEN FDMI RPA RJT\n");
22782334 return;
22792335 }
22802336 if (vport->fdmi_port_mask == LPFC_FDMI2_PORT_ATTR) {
@@ -2301,6 +2357,9 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 20 unmodified lines
23012357 */
23022358 switch (cmd) {
23032359 case SLI_MGMT_RHBA:
2360+ /* Check for any RPRTs deferred till after RHBA completes */
2361+ lpfc_fdmi_rprt_defer(phba, vport->fdmi_port_mask);
2362+
23042363 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA, 0);
23052364 break;
23062365
@@ -2309,10 +2368,26 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 2 unmodified lines
23092368 break;
23102369
23112370 case SLI_MGMT_DPRT:
2312− if (vport->port_type == LPFC_PHYSICAL_PORT)
2371+ if (vport->port_type == LPFC_PHYSICAL_PORT) {
23132372 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA, 0);
2314− else
2315− lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT, 0);
2373+ } else {
2374+ ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
2375+ if (!ndlp)
2376+ return;
2377+
2378+ /* Only issue a RPRT for the vport if the RHBA
2379+ * for the physical port completes successfully.
2380+ * We may have to defer the RPRT accordingly.
2381+ */
2382+ if (phba->hba_flag & HBA_RHBA_CMPL) {
2383+ lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT, 0);
2384+ } else {
2385+ lpfc_printf_vlog(vport, KERN_INFO,
2386+ LOG_DISCOVERY,
2387+ "6078 RPRT deferred\n");
2388+ vport->ct_flags |= FC_CT_RPRT_DEFER;
2389+ }
2390+ }
23162391 break;
23172392 case SLI_MGMT_RPA:
23182393 if (vport->port_type == LPFC_PHYSICAL_PORT &&
@@ -2327,7 +2402,8 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 8 unmodified lines
23272402 break;
23282403 }
23292404
2330− lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,
2405+ lpfc_printf_log(phba, KERN_INFO,
2406+ LOG_DISCOVERY | LOG_CGN_MGMT,
23312407 "6210 Issue Vendor MI FDMI %x\n",
23322408 phba->sli4_hba.pc_sli4_params.mi_ver);
23332409
@@ -2396,6 +2472,9 @@ lpfc_fdmi_change_check(struct lpfc_vport *vport) · 62 unmodified lines
23962472 phba->link_flag &= ~LS_CT_VEN_RPA;
23972473 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA, 0);
23982474 } else {
2475+ ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
2476+ if (!ndlp)
2477+ return;
23992478 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DPRT, 0);
24002479 }
24012480
@@ -2417,6 +2496,9 @@ lpfc_fdmi_change_check(struct lpfc_vport *vport) · 15 unmodified lines
24172496 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA,
24182497 LPFC_FDMI_PORT_ATTR_num_disc);
24192498 } else {
2499+ ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
2500+ if (!ndlp)
2501+ return;
24202502 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT,
24212503 LPFC_FDMI_PORT_ATTR_num_disc);
24222504 }
@@ -2830,31 +2912,59 @@ lpfc_fdmi_port_attr_support_speed(struct lpfc_vport *vport, · 407 unmodified lines
28302912 struct lpfc_hba *phba = vport->phba;
28312913 struct lpfc_fdmi_attr_entry *ae;
28322914 uint32_t size;
2915+ u32 tcfg;
2916+ u8 i, cnt;
28332917
28342918 ae = &ad->AttrValue;
28352919
28362920 ae->un.AttrInt = 0;
28372921 if (!(phba->hba_flag & HBA_FCOE_MODE)) {
2838− if (phba->lmt & LMT_256Gb)
2839− ae->un.AttrInt |= HBA_PORTSPEED_256GFC;
2840− if (phba->lmt & LMT_128Gb)
2841− ae->un.AttrInt |= HBA_PORTSPEED_128GFC;
2842− if (phba->lmt & LMT_64Gb)
2843− ae->un.AttrInt |= HBA_PORTSPEED_64GFC;
2844− if (phba->lmt & LMT_32Gb)
2845− ae->un.AttrInt |= HBA_PORTSPEED_32GFC;
2846− if (phba->lmt & LMT_16Gb)
2847− ae->un.AttrInt |= HBA_PORTSPEED_16GFC;
2848− if (phba->lmt & LMT_10Gb)
2849− ae->un.AttrInt |= HBA_PORTSPEED_10GFC;
2850− if (phba->lmt & LMT_8Gb)
2851− ae->un.AttrInt |= HBA_PORTSPEED_8GFC;
2852− if (phba->lmt & LMT_4Gb)
2853− ae->un.AttrInt |= HBA_PORTSPEED_4GFC;
2854− if (phba->lmt & LMT_2Gb)
2855− ae->un.AttrInt |= HBA_PORTSPEED_2GFC;
2856− if (phba->lmt & LMT_1Gb)
2857− ae->un.AttrInt |= HBA_PORTSPEED_1GFC;
2922+ cnt = 0;
2923+ if (phba->sli_rev == LPFC_SLI_REV4) {
2924+ tcfg = phba->sli4_hba.conf_trunk;
2925+ for (i = 0; i < 4; i++, tcfg >>= 1)
2926+ if (tcfg & 1)
2927+ cnt++;
2928+ }
2929+
2930+ if (cnt > 2) { /* 4 lane trunk group */
2931+ if (phba->lmt & LMT_64Gb)
2932+ ae->un.AttrInt |= HBA_PORTSPEED_256GFC;
2933+ if (phba->lmt & LMT_32Gb)
2934+ ae->un.AttrInt |= HBA_PORTSPEED_128GFC;
2935+ if (phba->lmt & LMT_16Gb)
2936+ ae->un.AttrInt |= HBA_PORTSPEED_64GFC;
2937+ } else if (cnt) { /* 2 lane trunk group */
2938+ if (phba->lmt & LMT_128Gb)
2939+ ae->un.AttrInt |= HBA_PORTSPEED_256GFC;
2940+ if (phba->lmt & LMT_64Gb)
2941+ ae->un.AttrInt |= HBA_PORTSPEED_128GFC;
2942+ if (phba->lmt & LMT_32Gb)
2943+ ae->un.AttrInt |= HBA_PORTSPEED_64GFC;
2944+ if (phba->lmt & LMT_16Gb)
2945+ ae->un.AttrInt |= HBA_PORTSPEED_32GFC;
2946+ } else {
2947+ if (phba->lmt & LMT_256Gb)
2948+ ae->un.AttrInt |= HBA_PORTSPEED_256GFC;
2949+ if (phba->lmt & LMT_128Gb)
2950+ ae->un.AttrInt |= HBA_PORTSPEED_128GFC;
2951+ if (phba->lmt & LMT_64Gb)
2952+ ae->un.AttrInt |= HBA_PORTSPEED_64GFC;
2953+ if (phba->lmt & LMT_32Gb)
2954+ ae->un.AttrInt |= HBA_PORTSPEED_32GFC;
2955+ if (phba->lmt & LMT_16Gb)
2956+ ae->un.AttrInt |= HBA_PORTSPEED_16GFC;
2957+ if (phba->lmt & LMT_10Gb)
2958+ ae->un.AttrInt |= HBA_PORTSPEED_10GFC;
2959+ if (phba->lmt & LMT_8Gb)
2960+ ae->un.AttrInt |= HBA_PORTSPEED_8GFC;
2961+ if (phba->lmt & LMT_4Gb)
2962+ ae->un.AttrInt |= HBA_PORTSPEED_4GFC;
2963+ if (phba->lmt & LMT_2Gb)
2964+ ae->un.AttrInt |= HBA_PORTSPEED_2GFC;
2965+ if (phba->lmt & LMT_1Gb)
2966+ ae->un.AttrInt |= HBA_PORTSPEED_1GFC;
2967+ }
28582968 } else {
28592969 /* FCoE links support only one speed */
28602970 switch (phba->fc_linkspeed) {
@@ -3125,6 +3235,7 @@ static int · 264 unmodified lines
31253235 lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport *vport,
31263236 struct lpfc_fdmi_attr_def *ad)
31273237 {
3238+ struct lpfc_hba *phba = vport->phba;
31283239 struct lpfc_fdmi_attr_entry *ae;
31293240 uint32_t size;
31303241
@@ -3135,7 +3246,8 @@ lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport *vport, · 4 unmodified lines
31353246 ae->un.AttrTypes[7] = 0x01; /* Type 0x20 - CT */
31363247
31373248 /* Check to see if NVME is configured or not */
3138− if (vport->phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)
3249+ if (vport == phba->pport &&
3250+ phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)
31393251 ae->un.AttrTypes[6] = 0x1; /* Type 0x28 - NVME */
31403252
31413253 size = FOURBYTES + 32;
@@ -3459,8 +3571,10 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 317 unmodified lines
34593571
34603572 /* FDMI request */
34613573 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
3462− "0218 FDMI Request Data: x%x x%x x%x\n",
3463− vport->fc_flag, vport->port_state, cmdcode);
3574+ "0218 FDMI Request x%x mask x%x Data: x%x x%x x%x\n",
3575+ cmdcode, new_mask, vport->fdmi_port_mask,
3576+ vport->fc_flag, vport->port_state);
3577+
34643578 CtReq = (struct lpfc_sli_ct_request *)mp->virt;
34653579
34663580 /* First populate the CT_IU preamble */
@@ -3529,6 +3643,12 @@ hba_out: · 62 unmodified lines
35293643 break;
35303644
35313645 case SLI_MGMT_RPRT:
3646+ if (vport->port_type != LPFC_PHYSICAL_PORT) {
3647+ ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
3648+ if (!ndlp)
3649+ return 0;
3650+ }
3651+ fallthrough;
35323652 case SLI_MGMT_RPA:
35333653 pab = (struct lpfc_fdmi_reg_portattr *)&CtReq->un.PortID;
35343654 if (cmdcode == SLI_MGMT_RPRT) {
@@ -3593,6 +3713,12 @@ port_out: · 58 unmodified lines
35933713 rsp_size = FC_MAX_NS_RSP;
35943714 fallthrough;
35953715 case SLI_MGMT_DPRT:
3716+ if (vport->port_type != LPFC_PHYSICAL_PORT) {
3717+ ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
3718+ if (!ndlp)
3719+ return 0;
3720+ }
3721+ fallthrough;
35963722 case SLI_MGMT_DPA:
35973723 pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID;
35983724 memcpy((uint8_t *)&pe->PortName,
@@ -3780,8 +3906,8 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 181 unmodified lines
37803906 struct lpfc_iocbq *rspiocb)
37813907 {
37823908 struct lpfc_vport *vport = cmdiocb->vport;
3783− struct lpfc_dmabuf *inp = cmdiocb->context1;
3784− struct lpfc_dmabuf *outp = cmdiocb->context2;
3909+ struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf;
3910+ struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf;
37853911 struct lpfc_sli_ct_request *ctcmd = inp->virt;
37863912 struct lpfc_sli_ct_request *ctrsp = outp->virt;
37873913 u16 rsp = ctrsp->CommandResponse.bits.CmdRsp;
drivers/scsi/lpfc/lpfc_els.c+338−377
@@ -152,7 +152,7 @@ lpfc_els_chk_latt(struct lpfc_vport *vport) · 151 unmodified lines
152152 * Buffer Descriptor Entries (BDEs), allocates buffers for both command
153153 * payload and response payload (if expected). The reference count on the
154154 * ndlp is incremented by 1 and the reference to the ndlp is put into
155− * context1 of the IOCB data structure for this IOCB to hold the ndlp
155+ * ndlp of the IOCB data structure for this IOCB to hold the ndlp
156156 * reference for the command's callback function to access later.
157157 *
158158 * Return code
@@ -279,8 +279,8 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, u8 expect_rsp, · 120 unmodified lines
279279 bpl->type_size |= cpu_to_le32(ULP_BDE64_TYPE_BDE_64);
280280 }
281281
282− elsiocb->context2 = pcmd;
283− elsiocb->context3 = pbuflist;
282+ elsiocb->cmd_dmabuf = pcmd;
283+ elsiocb->bpl_dmabuf = pbuflist;
284284 elsiocb->retry = retry;
285285 elsiocb->vport = vport;
286286 elsiocb->drvrTimeout = (phba->fc_ratov << 1) + LPFC_DRVR_TIMEOUT;
@@ -345,7 +345,6 @@ lpfc_issue_fabric_reglogin(struct lpfc_vport *vport) · 58 unmodified lines
345345 {
346346 struct lpfc_hba *phba = vport->phba;
347347 LPFC_MBOXQ_t *mbox;
348− struct lpfc_dmabuf *mp;
349348 struct lpfc_nodelist *ndlp;
350349 struct serv_parm *sp;
351350 int rc;
@@ -395,7 +394,7 @@ lpfc_issue_fabric_reglogin(struct lpfc_vport *vport) · 43 unmodified lines
395394 mbox->ctx_ndlp = lpfc_nlp_get(ndlp);
396395 if (!mbox->ctx_ndlp) {
397396 err = 6;
398− goto fail_no_ndlp;
397+ goto fail_free_mbox;
399398 }
400399
401400 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
@@ -411,13 +410,8 @@ fail_issue_reg_login: · 9 unmodified lines
411410 * for the failed mbox command.
412411 */
413412 lpfc_nlp_put(ndlp);
414−fail_no_ndlp:
415− mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
416− lpfc_mbuf_free(phba, mp->virt, mp->phys);
417− kfree(mp);
418413 fail_free_mbox:
419− mempool_free(mbox, phba->mbox_mem_pool);
420−
414+ lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
421415 fail:
422416 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
423417 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
@@ -465,45 +459,37 @@ lpfc_issue_reg_vfi(struct lpfc_vport *vport) · 41 unmodified lines
465459
466460 /* Supply CSP's only if we are fabric connect or pt-to-pt connect */
467461 if ((vport->fc_flag & FC_FABRIC) || (vport->fc_flag & FC_PT2PT)) {
468− dmabuf = kzalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
469− if (!dmabuf) {
470− rc = -ENOMEM;
471− goto fail;
472− }
473− dmabuf->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &dmabuf->phys);
474− if (!dmabuf->virt) {
462+ rc = lpfc_mbox_rsrc_prep(phba, mboxq);
463+ if (rc) {
475464 rc = -ENOMEM;
476− goto fail;
465+ goto fail_mbox;
477466 }
467+ dmabuf = mboxq->ctx_buf;
478468 memcpy(dmabuf->virt, &phba->fc_fabparam,
479469 sizeof(struct serv_parm));
480470 }
481471
482472 vport->port_state = LPFC_FABRIC_CFG_LINK;
483− if (dmabuf)
473+ if (dmabuf) {
484474 lpfc_reg_vfi(mboxq, vport, dmabuf->phys);
485− else
475+ /* lpfc_reg_vfi memsets the mailbox. Restore the ctx_buf. */
476+ mboxq->ctx_buf = dmabuf;
477+ } else {
486478 lpfc_reg_vfi(mboxq, vport, 0);
479+ }
487480
488481 mboxq->mbox_cmpl = lpfc_mbx_cmpl_reg_vfi;
489482 mboxq->vport = vport;
490− mboxq->ctx_buf = dmabuf;
491483 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT);
492484 if (rc == MBX_NOT_FINISHED) {
493485 rc = -ENXIO;
494− goto fail;
486+ goto fail_mbox;
495487 }
496488 return 0;
497489
490+fail_mbox:
491+ lpfc_mbox_rsrc_cleanup(phba, mboxq, MBOX_THD_UNLOCKED);
498492 fail:
499− if (mboxq)
500− mempool_free(mboxq, phba->mbox_mem_pool);
501− if (dmabuf) {
502− if (dmabuf->virt)
503− lpfc_mbuf_free(phba, dmabuf->virt, dmabuf->phys);
504− kfree(dmabuf);
505− }
506−
507493 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
508494 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
509495 "0289 Issue Register VFI failed: Err %d\n", rc);
@@ -959,9 +945,9 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 449 unmodified lines
959945 {
960946 struct lpfc_vport *vport = cmdiocb->vport;
961947 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
962− struct lpfc_nodelist *ndlp = cmdiocb->context1;
948+ struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
963949 IOCB_t *irsp;
964− struct lpfc_dmabuf *pcmd = cmdiocb->context2, *prsp;
950+ struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf, *prsp;
965951 struct serv_parm *sp;
966952 uint16_t fcf_index;
967953 int rc;
@@ -1119,7 +1105,8 @@ stop_rr_fcf_flogi: · 151 unmodified lines
11191105 sp->cmn.priority_tagging, kref_read(&ndlp->kref));
11201106
11211107 if (sp->cmn.priority_tagging)
1122− vport->vmid_flag |= LPFC_VMID_ISSUE_QFPA;
1108+ vport->phba->pport->vmid_flag |= (LPFC_VMID_ISSUE_QFPA |
1109+ LPFC_VMID_TYPE_PRIO);
11231110
11241111 if (vport->port_state == LPFC_FLOGI) {
11251112 /*
@@ -1232,7 +1219,7 @@ lpfc_cmpl_els_link_down(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 106 unmodified lines
12321219 uint32_t cmd;
12331220 u32 ulp_status, ulp_word4;
12341221
1235− pcmd = (uint32_t *)(((struct lpfc_dmabuf *)cmdiocb->context2)->virt);
1222+ pcmd = (uint32_t *)cmdiocb->cmd_dmabuf->virt;
12361223 cmd = *pcmd;
12371224
12381225 ulp_status = get_job_ulpstatus(phba, rspiocb);
@@ -1265,7 +1252,7 @@ lpfc_cmpl_els_link_down(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 26 unmodified lines
12651252 * out FLOGI ELS command with one outstanding fabric IOCB at a time.
12661253 *
12671254 * Note that the ndlp reference count will be incremented by 1 for holding the
1268− * ndlp and the reference to ndlp will be stored into the context1 field of
1255+ * ndlp and the reference to ndlp will be stored into the ndlp field of
12691256 * the IOCB for the completion callback function to the FLOGI ELS command.
12701257 *
12711258 * Return code
@@ -1295,7 +1282,7 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 23 unmodified lines
12951282 return 1;
12961283
12971284 wqe = &elsiocb->wqe;
1298− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
1285+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
12991286 icmd = &elsiocb->iocb;
13001287
13011288 /* For FLOGI request, remainder of payload is service parameters */
@@ -1372,8 +1359,8 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 70 unmodified lines
13721359 "Issue FLOGI: opt:x%x",
13731360 phba->sli3_options, 0, 0);
13741361
1375− elsiocb->context1 = lpfc_nlp_get(ndlp);
1376− if (!elsiocb->context1) {
1362+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
1363+ if (!elsiocb->ndlp) {
13771364 lpfc_els_free_iocb(phba, elsiocb);
13781365 return 1;
13791366 }
@@ -1387,6 +1374,9 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 7 unmodified lines
13871374
13881375 phba->hba_flag |= (HBA_FLOGI_ISSUED | HBA_FLOGI_OUTSTANDING);
13891376
1377+ /* Clear external loopback plug detected flag */
1378+ phba->link_flag &= ~LS_EXTERNAL_LOOPBACK;
1379+
13901380 /* Check for a deferred FLOGI ACC condition */
13911381 if (phba->defer_flogi_acc_flag) {
13921382 /* lookup ndlp for received FLOGI */
@@ -1474,7 +1464,7 @@ lpfc_els_abort_flogi(struct lpfc_hba *phba) · 81 unmodified lines
14741464 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
14751465 ulp_command = get_job_cmnd(phba, iocb);
14761466 if (ulp_command == CMD_ELS_REQUEST64_CR) {
1477− ndlp = (struct lpfc_nodelist *)(iocb->context1);
1467+ ndlp = iocb->ndlp;
14781468 if (ndlp && ndlp->nlp_DID == Fabric_DID) {
14791469 if ((phba->pport->fc_flag & FC_PT2PT) &&
14801470 !(phba->pport->fc_flag & FC_PT2PT_PLOGI))
@@ -1531,11 +1521,16 @@ lpfc_initial_flogi(struct lpfc_vport *vport) · 50 unmodified lines
15311521 lpfc_enqueue_node(vport, ndlp);
15321522 }
15331523
1524+ /* Reset the Fabric flag, topology change may have happened */
1525+ vport->fc_flag &= ~FC_FABRIC;
15341526 if (lpfc_issue_els_flogi(vport, ndlp, 0)) {
1535− /* This decrement of reference count to node shall kick off
1536− * the release of the node.
1527+ /* A node reference should be retained while registered with a
1528+ * transport or dev-loss-evt work is pending.
1529+ * Otherwise, decrement node reference to trigger release.
15371530 */
1538− lpfc_nlp_put(ndlp);
1531+ if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD)) &&
1532+ !(ndlp->nlp_flag & NLP_IN_DEV_LOSS))
1533+ lpfc_nlp_put(ndlp);
15391534 return 0;
15401535 }
15411536 return 1;
@@ -1578,10 +1573,13 @@ lpfc_initial_fdisc(struct lpfc_vport *vport) · 36 unmodified lines
15781573 }
15791574
15801575 if (lpfc_issue_els_fdisc(vport, ndlp, 0)) {
1581− /* decrement node reference count to trigger the release of
1582− * the node.
1576+ /* A node reference should be retained while registered with a
1577+ * transport or dev-loss-evt work is pending.
1578+ * Otherwise, decrement node reference to trigger release.
15831579 */
1584− lpfc_nlp_put(ndlp);
1580+ if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD)) &&
1581+ !(ndlp->nlp_flag & NLP_IN_DEV_LOSS))
1582+ lpfc_nlp_put(ndlp);
15851583 return 0;
15861584 }
15871585 return 1;
@@ -1888,6 +1886,7 @@ lpfc_end_rscn(struct lpfc_vport *vport) · 300 unmodified lines
18881886 else {
18891887 spin_lock_irq(shost->host_lock);
18901888 vport->fc_flag &= ~FC_RSCN_MODE;
1889+ vport->fc_flag |= FC_RSCN_MEMENTO;
18911890 spin_unlock_irq(shost->host_lock);
18921891 }
18931892 }
@@ -1910,14 +1909,14 @@ lpfc_cmpl_els_rrq(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 16 unmodified lines
19101909 struct lpfc_iocbq *rspiocb)
19111910 {
19121911 struct lpfc_vport *vport = cmdiocb->vport;
1913− struct lpfc_nodelist *ndlp = cmdiocb->context1;
1912+ struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
19141913 struct lpfc_node_rrq *rrq;
19151914 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
19161915 u32 ulp_word4 = get_job_word4(phba, rspiocb);
19171916
19181917 /* we pass cmdiocb to state machine which needs rspiocb as well */
19191918 rrq = cmdiocb->context_un.rrq;
1920− cmdiocb->context_un.rsp_iocb = rspiocb;
1919+ cmdiocb->rsp_iocb = rspiocb;
19211920
19221921 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
19231922 "RRQ cmpl: status:x%x/x%x did:x%x",
@@ -1983,9 +1982,10 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 59 unmodified lines
19831982 int disc;
19841983 struct serv_parm *sp = NULL;
19851984 u32 ulp_status, ulp_word4, did, iotag;
1985+ bool release_node = false;
19861986
19871987 /* we pass cmdiocb to state machine which needs rspiocb as well */
1988− cmdiocb->context_un.rsp_iocb = rspiocb;
1988+ cmdiocb->rsp_iocb = rspiocb;
19891989
19901990 ulp_status = get_job_ulpstatus(phba, rspiocb);
19911991 ulp_word4 = get_job_word4(phba, rspiocb);
@@ -2071,23 +2071,24 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 79 unmodified lines
20712071 spin_unlock_irq(&ndlp->lock);
20722072 goto out;
20732073 }
2074− spin_unlock_irq(&ndlp->lock);
20752074
20762075 /* No PLOGI collision and the node is not registered with the
20772076 * scsi or nvme transport. It is no longer an active node. Just
20782077 * start the device remove process.
20792078 */
20802079 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD))) {
2081− spin_lock_irq(&ndlp->lock);
20822080 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
2083− spin_unlock_irq(&ndlp->lock);
2081+ if (!(ndlp->nlp_flag & NLP_IN_DEV_LOSS))
2082+ release_node = true;
2083+ }
2084+ spin_unlock_irq(&ndlp->lock);
2085+
2086+ if (release_node)
20842087 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
20852088 NLP_EVT_DEVICE_RM);
2086− }
20872089 } else {
20882090 /* Good status, call state machine */
2089− prsp = list_entry(((struct lpfc_dmabuf *)
2090− cmdiocb->context2)->list.next,
2091+ prsp = list_entry(cmdiocb->cmd_dmabuf->list.next,
20912092 struct lpfc_dmabuf, list);
20922093 ndlp = lpfc_plogi_confirm_nport(phba, prsp->virt, ndlp);
20932094
@@ -2132,7 +2133,7 @@ out: · 38 unmodified lines
21322133
21332134 out_freeiocb:
21342135 /* Release the reference on the original I/O request. */
2135− free_ndlp = (struct lpfc_nodelist *)cmdiocb->context1;
2136+ free_ndlp = cmdiocb->ndlp;
21362137
21372138 lpfc_els_free_iocb(phba, cmdiocb);
21382139 lpfc_nlp_put(free_ndlp);
@@ -2152,7 +2153,7 @@ out_freeiocb: · 13 unmodified lines
21522153 * the lpfc_sli_issue_iocb() routine to send out PLOGI ELS command.
21532154 *
21542155 * Note that the ndlp reference count will be incremented by 1 for holding
2155− * the ndlp and the reference to ndlp will be stored into the context1 field
2156+ * the ndlp and the reference to ndlp will be stored into the ndlp field
21562157 * of the IOCB for the completion callback function to the PLOGI ELS command.
21572158 *
21582159 * Return code
@@ -2203,7 +2204,7 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) · 44 unmodified lines
22032204 ndlp->nlp_flag &= ~NLP_FCP_PRLI_RJT;
22042205 spin_unlock_irq(&ndlp->lock);
22052206
2206− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
2207+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
22072208
22082209 /* For PLOGI request, remainder of payload is service parameters */
22092210 *((uint32_t *) (pcmd)) = ELS_CMD_PLOGI;
@@ -2255,8 +2256,8 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) · 45 unmodified lines
22552256 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
22562257 "Issue PLOGI: did:x%x refcnt %d",
22572258 did, kref_read(&ndlp->kref), 0);
2258− elsiocb->context1 = lpfc_nlp_get(ndlp);
2259− if (!elsiocb->context1) {
2259+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
2260+ if (!elsiocb->ndlp) {
22602261 lpfc_els_free_iocb(phba, elsiocb);
22612262 return 1;
22622263 }
@@ -2294,11 +2295,12 @@ lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 31 unmodified lines
22942295 u32 loglevel;
22952296 u32 ulp_status;
22962297 u32 ulp_word4;
2298+ bool release_node = false;
22972299
22982300 /* we pass cmdiocb to state machine which needs rspiocb as well */
2299− cmdiocb->context_un.rsp_iocb = rspiocb;
2301+ cmdiocb->rsp_iocb = rspiocb;
23002302
2301− ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
2303+ ndlp = cmdiocb->ndlp;
23022304
23032305 ulp_status = get_job_ulpstatus(phba, rspiocb);
23042306 ulp_word4 = get_job_word4(phba, rspiocb);
@@ -2370,14 +2372,18 @@ lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 65 unmodified lines
23702372 * it is no longer an active node. Otherwise devloss
23712373 * handles the final cleanup.
23722374 */
2375+ spin_lock_irq(&ndlp->lock);
23732376 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD)) &&
23742377 !ndlp->fc4_prli_sent) {
2375− spin_lock_irq(&ndlp->lock);
23762378 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
2377− spin_unlock_irq(&ndlp->lock);
2379+ if (!(ndlp->nlp_flag & NLP_IN_DEV_LOSS))
2380+ release_node = true;
2381+ }
2382+ spin_unlock_irq(&ndlp->lock);
2383+
2384+ if (release_node)
23782385 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
23792386 NLP_EVT_DEVICE_RM);
2380− }
23812387 } else {
23822388 /* Good status, call state machine. However, if another
23832389 * PRLI is outstanding, don't call the state machine
@@ -2407,7 +2413,7 @@ out: · 23 unmodified lines
24072413 * routine lpfc_sli_issue_iocb() to send out PRLI command.
24082414 *
24092415 * Note that the ndlp reference count will be incremented by 1 for holding the
2410− * ndlp and the reference to ndlp will be stored into the context1 field of
2416+ * ndlp and the reference to ndlp will be stored into the ndlp field of
24112417 * the IOCB for the completion callback function to the PRLI ELS command.
24122418 *
24132419 * Return code
@@ -2428,13 +2434,14 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 14 unmodified lines
24282434 u32 local_nlp_type, elscmd;
24292435
24302436 /*
2431− * If we are in RSCN mode, the FC4 types supported from a
2437+ * If discovery was kicked off from RSCN mode,
2438+ * the FC4 types supported from a
24322439 * previous GFT_ID command may not be accurate. So, if we
24332440 * are a NVME Initiator, always look for the possibility of
24342441 * the remote NPort beng a NVME Target.
24352442 */
24362443 if (phba->sli_rev == LPFC_SLI_REV4 &&
2437− vport->fc_flag & FC_RSCN_MODE &&
2444+ vport->fc_flag & (FC_RSCN_MODE | FC_RSCN_MEMENTO) &&
24382445 vport->nvmei_support)
24392446 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
24402447 local_nlp_type = ndlp->nlp_fc4_type;
@@ -2481,7 +2488,7 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 40 unmodified lines
24812488 if (!elsiocb)
24822489 return 1;
24832490
2484− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
2491+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
24852492
24862493 /* For PRLI request, remainder of payload is service parameters */
24872494 memset(pcmd, 0, cmdsize);
@@ -2555,33 +2562,32 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 67 unmodified lines
25552562
25562563 phba->fc_stat.elsXmitPRLI++;
25572564 elsiocb->cmd_cmpl = lpfc_cmpl_els_prli;
2558− spin_lock_irq(&ndlp->lock);
2559− ndlp->nlp_flag |= NLP_PRLI_SND;
2560−
2561− /* The vport counters are used for lpfc_scan_finished, but
2562− * the ndlp is used to track outstanding PRLIs for different
2563− * FC4 types.
2564− */
2565− vport->fc_prli_sent++;
2566− ndlp->fc4_prli_sent++;
2567− spin_unlock_irq(&ndlp->lock);
25682565
25692566 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
25702567 "Issue PRLI: did:x%x refcnt %d",
25712568 ndlp->nlp_DID, kref_read(&ndlp->kref), 0);
2572− elsiocb->context1 = lpfc_nlp_get(ndlp);
2573− if (!elsiocb->context1) {
2569+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
2570+ if (!elsiocb->ndlp) {
25742571 lpfc_els_free_iocb(phba, elsiocb);
2575− goto err;
2572+ return 1;
25762573 }
25772574
25782575 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
25792576 if (rc == IOCB_ERROR) {
25802577 lpfc_els_free_iocb(phba, elsiocb);
25812578 lpfc_nlp_put(ndlp);
2582− goto err;
2579+ return 1;
25832580 }
25842581
2582+ /* The vport counters are used for lpfc_scan_finished, but
2583+ * the ndlp is used to track outstanding PRLIs for different
2584+ * FC4 types.
2585+ */
2586+ spin_lock_irq(&ndlp->lock);
2587+ ndlp->nlp_flag |= NLP_PRLI_SND;
2588+ vport->fc_prli_sent++;
2589+ ndlp->fc4_prli_sent++;
2590+ spin_unlock_irq(&ndlp->lock);
25852591
25862592 /* The driver supports 2 FC4 types. Make sure
25872593 * a PRLI is issued for all types before exiting.
@@ -2591,12 +2597,6 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 3 unmodified lines
25912597 goto send_next_prli;
25922598 else
25932599 return 0;
2594−
2595−err:
2596− spin_lock_irq(&ndlp->lock);
2597− ndlp->nlp_flag &= ~NLP_PRLI_SND;
2598− spin_unlock_irq(&ndlp->lock);
2599− return 1;
26002600 }
26012601
26022602 /**
@@ -2749,11 +2749,12 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 146 unmodified lines
27492749 struct lpfc_nodelist *ndlp;
27502750 int disc;
27512751 u32 ulp_status, ulp_word4, tmo;
2752+ bool release_node = false;
27522753
27532754 /* we pass cmdiocb to state machine which needs rspiocb as well */
2754− cmdiocb->context_un.rsp_iocb = rspiocb;
2755+ cmdiocb->rsp_iocb = rspiocb;
27552756
2756− ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
2757+ ndlp = cmdiocb->ndlp;
27572758
27582759 ulp_status = get_job_ulpstatus(phba, rspiocb);
27592760 ulp_word4 = get_job_word4(phba, rspiocb);
@@ -2815,13 +2816,17 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 55 unmodified lines
28152816 * transport, it is no longer an active node. Otherwise
28162817 * devloss handles the final cleanup.
28172818 */
2819+ spin_lock_irq(&ndlp->lock);
28182820 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD))) {
2819− spin_lock_irq(&ndlp->lock);
28202821 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
2821− spin_unlock_irq(&ndlp->lock);
2822+ if (!(ndlp->nlp_flag & NLP_IN_DEV_LOSS))
2823+ release_node = true;
2824+ }
2825+ spin_unlock_irq(&ndlp->lock);
2826+
2827+ if (release_node)
28222828 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
28232829 NLP_EVT_DEVICE_RM);
2824− }
28252830 } else
28262831 /* Good status, call state machine */
28272832 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
@@ -2848,7 +2853,7 @@ out: · 20 unmodified lines
28482853 * to issue the ADISC ELS command.
28492854 *
28502855 * Note that the ndlp reference count will be incremented by 1 for holding the
2851− * ndlp and the reference to ndlp will be stored into the context1 field of
2856+ * ndlp and the reference to ndlp will be stored into the ndlp field of
28522857 * the IOCB for the completion callback function to the ADISC ELS command.
28532858 *
28542859 * Return code
@@ -2872,7 +2877,7 @@ lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 17 unmodified lines
28722877 if (!elsiocb)
28732878 return 1;
28742879
2875− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
2880+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
28762881
28772882 /* For ADISC request, remainder of payload is service parameters */
28782883 *((uint32_t *) (pcmd)) = ELS_CMD_ADISC;
@@ -2890,8 +2895,8 @@ lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 11 unmodified lines
28902895 spin_lock_irq(&ndlp->lock);
28912896 ndlp->nlp_flag |= NLP_ADISC_SND;
28922897 spin_unlock_irq(&ndlp->lock);
2893− elsiocb->context1 = lpfc_nlp_get(ndlp);
2894− if (!elsiocb->context1) {
2898+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
2899+ if (!elsiocb->ndlp) {
28952900 lpfc_els_free_iocb(phba, elsiocb);
28962901 goto err;
28972902 }
@@ -2931,7 +2936,7 @@ static void · 33 unmodified lines
29312936 lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
29322937 struct lpfc_iocbq *rspiocb)
29332938 {
2934− struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
2939+ struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
29352940 struct lpfc_vport *vport = ndlp->vport;
29362941 IOCB_t *irsp;
29372942 unsigned long flags;
@@ -2942,7 +2947,7 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 4 unmodified lines
29422947 u32 tmo;
29432948
29442949 /* we pass cmdiocb to state machine which needs rspiocb as well */
2945− cmdiocb->context_un.rsp_iocb = rspiocb;
2950+ cmdiocb->rsp_iocb = rspiocb;
29462951
29472952 ulp_status = get_job_ulpstatus(phba, rspiocb);
29482953 ulp_word4 = get_job_word4(phba, rspiocb);
@@ -2993,7 +2998,10 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 44 unmodified lines
29932998 ndlp->nlp_DID, ulp_status,
29942999 ulp_word4);
29953000
3001+ /* Call NLP_EVT_DEVICE_RM if link is down or LOGO is aborted */
29963002 if (lpfc_error_lost_link(ulp_status, ulp_word4)) {
3003+ lpfc_disc_state_machine(vport, ndlp, cmdiocb,
3004+ NLP_EVT_DEVICE_RM);
29973005 skip_recovery = 1;
29983006 goto out;
29993007 }
@@ -3081,7 +3089,7 @@ out: · 81 unmodified lines
30813089 * lpfc_sli_issue_iocb() routine to send out the LOGO ELS command.
30823090 *
30833091 * Note that the ndlp reference count will be incremented by 1 for holding the
3084− * ndlp and the reference to ndlp will be stored into the context1 field of
3092+ * ndlp and the reference to ndlp will be stored into the ndlp field of
30853093 * the IOCB for the completion callback function to the LOGO ELS command.
30863094 *
30873095 * Callers of this routine are expected to unregister the RPI first
@@ -3113,7 +3121,7 @@ lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 25 unmodified lines
31133121 if (!elsiocb)
31143122 return 1;
31153123
3116− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
3124+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
31173125 *((uint32_t *) (pcmd)) = ELS_CMD_LOGO;
31183126 pcmd += sizeof(uint32_t);
31193127
@@ -3128,8 +3136,8 @@ lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 8 unmodified lines
31283136 ndlp->nlp_flag |= NLP_LOGO_SND;
31293137 ndlp->nlp_flag &= ~NLP_ISSUE_LOGO;
31303138 spin_unlock_irq(&ndlp->lock);
3131− elsiocb->context1 = lpfc_nlp_get(ndlp);
3132− if (!elsiocb->context1) {
3139+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
3140+ if (!elsiocb->ndlp) {
31333141 lpfc_els_free_iocb(phba, elsiocb);
31343142 goto err;
31353143 }
@@ -3207,7 +3215,7 @@ lpfc_cmpl_els_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 71 unmodified lines
32073215 /* Check to see if link went down during discovery */
32083216 lpfc_els_chk_latt(vport);
32093217
3210− free_ndlp = (struct lpfc_nodelist *)cmdiocb->context1;
3218+ free_ndlp = cmdiocb->ndlp;
32113219
32123220 lpfc_els_free_iocb(phba, cmdiocb);
32133221 lpfc_nlp_put(free_ndlp);
@@ -3234,7 +3242,6 @@ lpfc_reg_fab_ctrl_node(struct lpfc_vport *vport, struct lpfc_nodelist *fc_ndlp) · 20 unmodified lines
32343242 struct lpfc_hba *phba = vport->phba;
32353243 struct lpfc_nodelist *ns_ndlp;
32363244 LPFC_MBOXQ_t *mbox;
3237− struct lpfc_dmabuf *mp;
32383245
32393246 if (fc_ndlp->nlp_flag & NLP_RPI_REGISTERED)
32403247 return rc;
@@ -3271,7 +3278,7 @@ lpfc_reg_fab_ctrl_node(struct lpfc_vport *vport, struct lpfc_nodelist *fc_ndlp) · 30 unmodified lines
32713278 mbox->ctx_ndlp = lpfc_nlp_get(fc_ndlp);
32723279 if (!mbox->ctx_ndlp) {
32733280 rc = -ENOMEM;
3274− goto out_mem;
3281+ goto out;
32753282 }
32763283
32773284 mbox->vport = vport;
@@ -3279,21 +3286,15 @@ lpfc_reg_fab_ctrl_node(struct lpfc_vport *vport, struct lpfc_nodelist *fc_ndlp) · 1 unmodified line
32793286 if (rc == MBX_NOT_FINISHED) {
32803287 rc = -ENODEV;
32813288 lpfc_nlp_put(fc_ndlp);
3282− goto out_mem;
3289+ goto out;
32833290 }
32843291 /* Success path. Exit. */
32853292 lpfc_nlp_set_state(vport, fc_ndlp,
32863293 NLP_STE_REG_LOGIN_ISSUE);
32873294 return 0;
32883295
3289− out_mem:
3290− fc_ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
3291− mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
3292− lpfc_mbuf_free(phba, mp->virt, mp->phys);
3293− kfree(mp);
3294−
32953296 out:
3296− mempool_free(mbox, phba->mbox_mem_pool);
3297+ lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
32973298 lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE,
32983299 "0938 %s: failed to format reg_login "
32993300 "Data: x%x x%x x%x x%x\n", __func__,
@@ -3323,7 +3324,7 @@ lpfc_cmpl_els_disc_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 23 unmodified lines
33233324 struct lpfc_dmabuf *pcmd, *prsp;
33243325 u32 *pdata;
33253326 u32 cmd;
3326− struct lpfc_nodelist *ndlp = cmdiocb->context1;
3327+ struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
33273328 u32 ulp_status, ulp_word4, tmo, did, iotag;
33283329
33293330 ulp_status = get_job_ulpstatus(phba, rspiocb);
@@ -3348,7 +3349,7 @@ lpfc_cmpl_els_disc_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 18 unmodified lines
33483349 "0217 ELS cmd tag x%x completes Data: x%x x%x x%x x%x\n",
33493350 iotag, ulp_status, ulp_word4, tmo, cmdiocb->retry);
33503351
3351− pcmd = (struct lpfc_dmabuf *)cmdiocb->context2;
3352+ pcmd = cmdiocb->cmd_dmabuf;
33523353 if (!pcmd)
33533354 goto out;
33543355
@@ -3371,7 +3372,6 @@ lpfc_cmpl_els_disc_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 16 unmodified lines
33713372 lpfc_issue_els_edc(vport, cmdiocb->retry);
33723373 break;
33733374 case ELS_CMD_RDF:
3374− cmdiocb->context1 = NULL; /* save ndlp refcnt */
33753375 lpfc_issue_els_rdf(vport, cmdiocb->retry);
33763376 break;
33773377 }
@@ -3439,7 +3439,7 @@ out: · 61 unmodified lines
34393439 * routine is invoked to send the SCR IOCB.
34403440 *
34413441 * Note that the ndlp reference count will be incremented by 1 for holding the
3442− * ndlp and the reference to ndlp will be stored into the context1 field of
3442+ * ndlp and the reference to ndlp will be stored into the ndlp field of
34433443 * the IOCB for the completion callback function to the SCR ELS command.
34443444 *
34453445 * Return code
@@ -3481,7 +3481,7 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint8_t retry) · 35 unmodified lines
34813481 return 1;
34823482 }
34833483 }
3484− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
3484+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
34853485
34863486 *((uint32_t *) (pcmd)) = ELS_CMD_SCR;
34873487 pcmd += sizeof(uint32_t);
@@ -3496,8 +3496,8 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint8_t retry) · 8 unmodified lines
34963496
34973497 phba->fc_stat.elsXmitSCR++;
34983498 elsiocb->cmd_cmpl = lpfc_cmpl_els_disc_cmd;
3499− elsiocb->context1 = lpfc_nlp_get(ndlp);
3500− if (!elsiocb->context1) {
3499+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
3500+ if (!elsiocb->ndlp) {
35013501 lpfc_els_free_iocb(phba, elsiocb);
35023502 return 1;
35033503 }
@@ -3528,7 +3528,7 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint8_t retry) · 24 unmodified lines
35283528 * replay the RSCN to registered recipients.
35293529 *
35303530 * Note that the ndlp reference count will be incremented by 1 for holding the
3531− * ndlp and the reference to ndlp will be stored into the context1 field of
3531+ * ndlp and the reference to ndlp will be stored into the ndlp field of
35323532 * the IOCB for the completion callback function to the RSCN ELS command.
35333533 *
35343534 * Return code
@@ -3578,7 +3578,7 @@ lpfc_issue_els_rscn(struct lpfc_vport *vport, uint8_t retry) · 43 unmodified lines
35783578 if (!elsiocb)
35793579 return 1;
35803580
3581− event = ((struct lpfc_dmabuf *)elsiocb->context2)->virt;
3581+ event = elsiocb->cmd_dmabuf->virt;
35823582
35833583 event->rscn.rscn_cmd = ELS_RSCN;
35843584 event->rscn.rscn_page_len = sizeof(struct fc_els_rscn_page);
@@ -3593,8 +3593,8 @@ lpfc_issue_els_rscn(struct lpfc_vport *vport, uint8_t retry) · 8 unmodified lines
35933593
35943594 phba->fc_stat.elsXmitRSCN++;
35953595 elsiocb->cmd_cmpl = lpfc_cmpl_els_cmd;
3596− elsiocb->context1 = lpfc_nlp_get(ndlp);
3597− if (!elsiocb->context1) {
3596+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
3597+ if (!elsiocb->ndlp) {
35983598 lpfc_els_free_iocb(phba, elsiocb);
35993599 return 1;
36003600 }
@@ -3627,7 +3627,7 @@ lpfc_issue_els_rscn(struct lpfc_vport *vport, uint8_t retry) · 26 unmodified lines
36273627 * lpfc_sli_issue_iocb() routine is invoked to send the FARPR ELS command.
36283628 *
36293629 * Note that the ndlp reference count will be incremented by 1 for holding the
3630− * ndlp and the reference to ndlp will be stored into the context1 field of
3630+ * ndlp and the reference to ndlp will be stored into the ndlp field of
36313631 * the IOCB for the completion callback function to the FARPR ELS command.
36323632 *
36333633 * Return code
@@ -3662,7 +3662,7 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) · 28 unmodified lines
36623662 if (!elsiocb)
36633663 return 1;
36643664
3665− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
3665+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
36663666
36673667 *((uint32_t *) (pcmd)) = ELS_CMD_FARPR;
36683668 pcmd += sizeof(uint32_t);
@@ -3692,8 +3692,8 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) · 23 unmodified lines
36923692
36933693 phba->fc_stat.elsXmitFARPR++;
36943694 elsiocb->cmd_cmpl = lpfc_cmpl_els_cmd;
3695− elsiocb->context1 = lpfc_nlp_get(ndlp);
3696− if (!elsiocb->context1) {
3695+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
3696+ if (!elsiocb->ndlp) {
36973697 lpfc_els_free_iocb(phba, elsiocb);
36983698 return 1;
36993699 }
@@ -3724,7 +3724,7 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) · 24 unmodified lines
37243724 * for diagnostic functions.
37253725 *
37263726 * Note that the ndlp reference count will be incremented by 1 for holding the
3727− * ndlp and the reference to ndlp will be stored into the context1 field of
3727+ * ndlp and the reference to ndlp will be stored into the ndlp field of
37283728 * the IOCB for the completion callback function to the RDF ELS command.
37293729 *
37303730 * Return code
@@ -3761,8 +3761,7 @@ lpfc_issue_els_rdf(struct lpfc_vport *vport, uint8_t retry) · 30 unmodified lines
37613761 return -ENOMEM;
37623762
37633763 /* Configure the payload for the supported FPIN events. */
3764− prdf = (struct lpfc_els_rdf_req *)
3765− (((struct lpfc_dmabuf *)elsiocb->context2)->virt);
3764+ prdf = (struct lpfc_els_rdf_req *)elsiocb->cmd_dmabuf->virt;
37663765 memset(prdf, 0, cmdsize);
37673766 prdf->rdf.fpin_cmd = ELS_RDF;
37683767 prdf->rdf.desc_len = cpu_to_be32(sizeof(struct lpfc_els_rdf_req) -
@@ -3783,8 +3782,8 @@ lpfc_issue_els_rdf(struct lpfc_vport *vport, uint8_t retry) · 14 unmodified lines
37833782
37843783 phba->cgn_fpin_frequency = LPFC_FPIN_INIT_FREQ;
37853784 elsiocb->cmd_cmpl = lpfc_cmpl_els_disc_cmd;
3786− elsiocb->context1 = lpfc_nlp_get(ndlp);
3787− if (!elsiocb->context1) {
3785+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
3786+ if (!elsiocb->ndlp) {
37883787 lpfc_els_free_iocb(phba, elsiocb);
37893788 return -EIO;
37903789 }
@@ -3855,9 +3854,6 @@ lpfc_least_capable_settings(struct lpfc_hba *phba, · 64 unmodified lines
38553854 {
38563855 u32 rsp_sig_cap = 0, drv_sig_cap = 0;
38573856 u32 rsp_sig_freq_cyc = 0, rsp_sig_freq_scale = 0;
3858− struct lpfc_cgn_info *cp;
3859− u32 crc;
3860− u16 sig_freq;
38613857
38623858 /* Get rsp signal and frequency capabilities. */
38633859 rsp_sig_cap = be32_to_cpu(pcgd->xmt_signal_capability);
@@ -3913,25 +3909,7 @@ lpfc_least_capable_settings(struct lpfc_hba *phba, · 49 unmodified lines
39133909 }
39143910 }
39153911
3916− if (!phba->cgn_i)
3917− return;
3918−
3919− /* Update signal frequency in congestion info buffer */
3920− cp = (struct lpfc_cgn_info *)phba->cgn_i->virt;
3921−
3922− /* Frequency (in ms) Signal Warning/Signal Congestion Notifications
3923− * are received by the HBA
3924− */
3925− sig_freq = phba->cgn_sig_freq;
3926−
3927− if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY)
3928− cp->cgn_warn_freq = cpu_to_le16(sig_freq);
3929− if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) {
3930− cp->cgn_alarm_freq = cpu_to_le16(sig_freq);
3931− cp->cgn_warn_freq = cpu_to_le16(sig_freq);
3932− }
3933− crc = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ, LPFC_CGN_CRC32_SEED);
3934− cp->cgn_info_crc = cpu_to_le32(crc);
3912+ /* We are NOT recording signal frequency in congestion info buffer */
39353913 return;
39363914
39373915 out_no_support:
@@ -3973,7 +3951,7 @@ lpfc_cmpl_els_edc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 35 unmodified lines
39733951 struct lpfc_nodelist *ndlp;
39743952 u32 ulp_status, ulp_word4, tmo, did, iotag;
39753953
3976− ndlp = cmdiocb->context1;
3954+ ndlp = cmdiocb->ndlp;
39773955
39783956 ulp_status = get_job_ulpstatus(phba, rspiocb);
39793957 ulp_word4 = get_job_word4(phba, rspiocb);
@@ -3997,7 +3975,7 @@ lpfc_cmpl_els_edc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 17 unmodified lines
39973975 "4201 EDC cmd tag x%x completes Data: x%x x%x x%x\n",
39983976 iotag, ulp_status, ulp_word4, tmo);
39993977
4000− pcmd = (struct lpfc_dmabuf *)cmdiocb->context2;
3978+ pcmd = cmdiocb->cmd_dmabuf;
40013979 if (!pcmd)
40023980 goto out;
40033981
@@ -4246,7 +4224,7 @@ lpfc_issue_els_edc(struct lpfc_vport *vport, uint8_t retry) · 242 unmodified lines
42464224 goto try_rdf;
42474225
42484226 /* Configure the payload for the supported Diagnostics capabilities. */
4249− pcmd = (u8 *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt);
4227+ pcmd = (u8 *)elsiocb->cmd_dmabuf->virt;
42504228 memset(pcmd, 0, cmdsize);
42514229 edc_req = (struct lpfc_els_edc_req *)pcmd;
42524230 edc_req->edc.desc_len = cpu_to_be32(cgn_desc_size);
@@ -4258,15 +4236,15 @@ lpfc_issue_els_edc(struct lpfc_vport *vport, uint8_t retry) · 5 unmodified lines
42584236
42594237 phba->cgn_sig_freq = lpfc_fabric_cgn_frequency;
42604238
4261− lpfc_printf_vlog(vport, KERN_INFO, LOG_CGN_MGMT,
4239+ lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_CGN_MGMT,
42624240 "4623 Xmit EDC to remote "
42634241 "NPORT x%x reg_sig x%x reg_fpin:x%x\n",
42644242 ndlp->nlp_DID, phba->cgn_reg_signal,
42654243 phba->cgn_reg_fpin);
42664244
42674245 elsiocb->cmd_cmpl = lpfc_cmpl_els_disc_cmd;
4268− elsiocb->context1 = lpfc_nlp_get(ndlp);
4269− if (!elsiocb->context1) {
4246+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
4247+ if (!elsiocb->ndlp) {
42704248 lpfc_els_free_iocb(phba, elsiocb);
42714249 return -EIO;
42724250 }
@@ -4544,8 +4522,8 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 271 unmodified lines
45444522 {
45454523 struct lpfc_vport *vport = cmdiocb->vport;
45464524 union lpfc_wqe128 *irsp = &rspiocb->wqe;
4547− struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
4548− struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
4525+ struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
4526+ struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf;
45494527 uint32_t *elscmd;
45504528 struct ls_rjt stat;
45514529 int retry = 0, maxretry = lpfc_max_els_tries, delay = 0;
@@ -4557,7 +4535,7 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 5 unmodified lines
45574535 u32 ulp_word4 = get_job_word4(phba, rspiocb);
45584536
45594537
4560− /* Note: context2 may be 0 for internal driver abort
4538+ /* Note: cmd_dmabuf may be 0 for internal driver abort
45614539 * of delays ELS command.
45624540 */
45634541
@@ -5068,10 +5046,10 @@ lpfc_els_free_bpl(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr) · 504 unmodified lines
50685046 * command IOCB data structure contains the reference to various associated
50695047 * resources, these fields must be set to NULL if the associated reference
50705048 * not present:
5071− * context1 - reference to ndlp
5072− * context2 - reference to cmd
5073− * context2->next - reference to rsp
5074− * context3 - reference to bpl
5049+ * cmd_dmabuf - reference to cmd.
5050+ * cmd_dmabuf->next - reference to rsp
5051+ * rsp_dmabuf - unused
5052+ * bpl_dmabuf - reference to bpl
50755053 *
50765054 * It first properly decrements the reference count held on ndlp for the
50775055 * IOCB completion callback function. If LPFC_DELAY_MEM_FREE flag is not
@@ -5091,19 +5069,19 @@ lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb) · 13 unmodified lines
50915069 {
50925070 struct lpfc_dmabuf *buf_ptr, *buf_ptr1;
50935071
5094− /* The I/O iocb is complete. Clear the context1 data. */
5095− elsiocb->context1 = NULL;
5072+ /* The I/O iocb is complete. Clear the node and first dmbuf */
5073+ elsiocb->ndlp = NULL;
50965074
5097− /* context2 = cmd, context2->next = rsp, context3 = bpl */
5098− if (elsiocb->context2) {
5075+ /* cmd_dmabuf = cmd, cmd_dmabuf->next = rsp, bpl_dmabuf = bpl */
5076+ if (elsiocb->cmd_dmabuf) {
50995077 if (elsiocb->cmd_flag & LPFC_DELAY_MEM_FREE) {
51005078 /* Firmware could still be in progress of DMAing
51015079 * payload, so don't free data buffer till after
51025080 * a hbeat.
51035081 */
51045082 elsiocb->cmd_flag &= ~LPFC_DELAY_MEM_FREE;
5105− buf_ptr = elsiocb->context2;
5106− elsiocb->context2 = NULL;
5083+ buf_ptr = elsiocb->cmd_dmabuf;
5084+ elsiocb->cmd_dmabuf = NULL;
51075085 if (buf_ptr) {
51085086 buf_ptr1 = NULL;
51095087 spin_lock_irq(&phba->hbalock);
@@ -5122,16 +5100,16 @@ lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb) · 12 unmodified lines
51225100 spin_unlock_irq(&phba->hbalock);
51235101 }
51245102 } else {
5125− buf_ptr1 = (struct lpfc_dmabuf *) elsiocb->context2;
5103+ buf_ptr1 = elsiocb->cmd_dmabuf;
51265104 lpfc_els_free_data(phba, buf_ptr1);
5127− elsiocb->context2 = NULL;
5105+ elsiocb->cmd_dmabuf = NULL;
51285106 }
51295107 }
51305108
5131− if (elsiocb->context3) {
5132− buf_ptr = (struct lpfc_dmabuf *) elsiocb->context3;
5109+ if (elsiocb->bpl_dmabuf) {
5110+ buf_ptr = elsiocb->bpl_dmabuf;
51335111 lpfc_els_free_bpl(phba, buf_ptr);
5134− elsiocb->context3 = NULL;
5112+ elsiocb->bpl_dmabuf = NULL;
51355113 }
51365114 lpfc_sli_release_iocbq(phba, elsiocb);
51375115 return 0;
@@ -5147,7 +5125,7 @@ lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb) · 9 unmodified lines
51475125 * Accept (ACC) Response ELS command. This routine is invoked to indicate
51485126 * the completion of the LOGO process. It invokes the lpfc_nlp_not_used() to
51495127 * release the ndlp if it has the last reference remaining (reference count
5150− * is 1). If succeeded (meaning ndlp released), it sets the IOCB context1
5128+ * is 1). If succeeded (meaning ndlp released), it sets the iocb ndlp
51515129 * field to NULL to inform the following lpfc_els_free_iocb() routine no
51525130 * ndlp reference count needs to be decremented. Otherwise, the ndlp
51535131 * reference use-count shall be decremented by the lpfc_els_free_iocb()
@@ -5158,7 +5136,7 @@ static void · 4 unmodified lines
51585136 lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
51595137 struct lpfc_iocbq *rspiocb)
51605138 {
5161− struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
5139+ struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
51625140 struct lpfc_vport *vport = cmdiocb->vport;
51635141 u32 ulp_status, ulp_word4;
51645142
@@ -5204,7 +5182,7 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 39 unmodified lines
52045182 /* Indicate the node has already released, should
52055183 * not reference to it from within lpfc_els_free_iocb.
52065184 */
5207− cmdiocb->context1 = NULL;
5185+ cmdiocb->ndlp = NULL;
52085186 }
52095187 }
52105188 out:
@@ -5232,14 +5210,10 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 21 unmodified lines
52325210 void
52335211 lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
52345212 {
5235− struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);
5236− struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
5213+ struct lpfc_nodelist *ndlp = pmb->ctx_ndlp;
52375214 u32 mbx_flag = pmb->mbox_flag;
52385215 u32 mbx_cmd = pmb->u.mb.mbxCommand;
52395216
5240− pmb->ctx_buf = NULL;
5241− pmb->ctx_ndlp = NULL;
5242−
52435217 if (ndlp) {
52445218 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE,
52455219 "0006 rpi x%x DID:%x flg:%x %d x%px "
@@ -5262,10 +5236,7 @@ lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 16 unmodified lines
52625236 lpfc_drop_node(ndlp->vport, ndlp);
52635237 }
52645238
5265− lpfc_mbuf_free(phba, mp->virt, mp->phys);
5266− kfree(mp);
5267− mempool_free(pmb, phba->mbox_mem_pool);
5268− return;
5239+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
52695240 }
52705241
52715242 /**
@@ -5285,12 +5256,11 @@ static void · 13 unmodified lines
52855256 lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
52865257 struct lpfc_iocbq *rspiocb)
52875258 {
5288− struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
5259+ struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
52895260 struct lpfc_vport *vport = ndlp ? ndlp->vport : NULL;
52905261 struct Scsi_Host *shost = vport ? lpfc_shost_from_vport(vport) : NULL;
52915262 IOCB_t *irsp;
52925263 LPFC_MBOXQ_t *mbox = NULL;
5293− struct lpfc_dmabuf *mp = NULL;
52945264 u32 ulp_status, ulp_word4, tmo, did, iotag;
52955265
52965266 if (!vport) {
@@ -5316,14 +5286,8 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 19 unmodified lines
53165286
53175287 /* Check to see if link went down during discovery */
53185288 if (!ndlp || lpfc_els_chk_latt(vport)) {
5319− if (mbox) {
5320− mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
5321− if (mp) {
5322− lpfc_mbuf_free(phba, mp->virt, mp->phys);
5323− kfree(mp);
5324− }
5325− mempool_free(mbox, phba->mbox_mem_pool);
5326− }
5289+ if (mbox)
5290+ lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
53275291 goto out;
53285292 }
53295293
@@ -5354,14 +5318,7 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 24 unmodified lines
53545318 ndlp->nlp_state,
53555319 ndlp->nlp_rpi,
53565320 ndlp->nlp_flag);
5357− mp = mbox->ctx_buf;
5358− if (mp) {
5359− lpfc_mbuf_free(phba, mp->virt,
5360− mp->phys);
5361− kfree(mp);
5362− }
5363− mempool_free(mbox, phba->mbox_mem_pool);
5364− goto out;
5321+ goto out_free_mbox;
53655322 }
53665323 }
53675324
@@ -5370,7 +5327,7 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 2 unmodified lines
53705327 */
53715328 mbox->ctx_ndlp = lpfc_nlp_get(ndlp);
53725329 if (!mbox->ctx_ndlp)
5373− goto out;
5330+ goto out_free_mbox;
53745331
53755332 mbox->vport = vport;
53765333 if (ndlp->nlp_flag & NLP_RM_DFLT_RPI) {
@@ -5402,12 +5359,8 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 25 unmodified lines
54025359 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
54035360 ndlp->nlp_rpi);
54045361 }
5405− mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
5406− if (mp) {
5407− lpfc_mbuf_free(phba, mp->virt, mp->phys);
5408− kfree(mp);
5409− }
5410− mempool_free(mbox, phba->mbox_mem_pool);
5362+out_free_mbox:
5363+ lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
54115364 }
54125365 out:
54135366 if (ndlp && shost) {
@@ -5459,7 +5412,7 @@ out: · 45 unmodified lines
54595412 * mailbox command to the HBA later when callback is invoked.
54605413 *
54615414 * Note that the ndlp reference count will be incremented by 1 for holding the
5462− * ndlp and the reference to ndlp will be stored into the context1 field of
5415+ * ndlp and the reference to ndlp will be stored into the ndlp field of
54635416 * the IOCB for the completion callback function to the corresponding
54645417 * response ELS IOCB command.
54655418 *
@@ -5516,7 +5469,7 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, · 50 unmodified lines
55165469 oldcmd->unsli3.rcvsli3.ox_id;
55175470 }
55185471
5519− pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
5472+ pcmd = elsiocb->cmd_dmabuf->virt;
55205473 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
55215474 pcmd += sizeof(uint32_t);
55225475
@@ -5551,7 +5504,7 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, · 28 unmodified lines
55515504 oldcmd->unsli3.rcvsli3.ox_id;
55525505 }
55535506
5554− pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
5507+ pcmd = (u8 *)elsiocb->cmd_dmabuf->virt;
55555508
55565509 if (mbox)
55575510 elsiocb->context_un.mbox = mbox;
@@ -5629,9 +5582,9 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, · 71 unmodified lines
56295582 oldcmd->unsli3.rcvsli3.ox_id;
56305583 }
56315584
5632− pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
5585+ pcmd = (u8 *) elsiocb->cmd_dmabuf->virt;
56335586
5634− memcpy(pcmd, ((struct lpfc_dmabuf *) oldiocb->context2)->virt,
5587+ memcpy(pcmd, oldiocb->cmd_dmabuf->virt,
56355588 sizeof(uint32_t) + sizeof(PRLO));
56365589 *((uint32_t *) (pcmd)) = ELS_CMD_PRLO_ACC;
56375590 els_pkt_ptr = (ELS_PKT *) pcmd;
@@ -5667,7 +5620,7 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, · 29 unmodified lines
56675620 oldcmd->unsli3.rcvsli3.ox_id;
56685621 }
56695622
5670− pcmd = (((struct lpfc_dmabuf *)elsiocb->context2)->virt);
5623+ pcmd = (u8 *)elsiocb->cmd_dmabuf->virt;
56715624 rdf_resp = (struct fc_els_rdf_resp *)pcmd;
56725625 memset(rdf_resp, 0, sizeof(*rdf_resp));
56735626 rdf_resp->acc_hdr.la_cmd = ELS_LS_ACC;
@@ -5695,8 +5648,8 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, · 21 unmodified lines
56955648 }
56965649
56975650 phba->fc_stat.elsXmitACC++;
5698− elsiocb->context1 = lpfc_nlp_get(ndlp);
5699− if (!elsiocb->context1) {
5651+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
5652+ if (!elsiocb->ndlp) {
57005653 lpfc_els_free_iocb(phba, elsiocb);
57015654 return 1;
57025655 }
@@ -5733,7 +5686,7 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, · 30 unmodified lines
57335686 * to issue to the HBA later.
57345687 *
57355688 * Note that the ndlp reference count will be incremented by 1 for holding the
5736− * ndlp and the reference to ndlp will be stored into the context1 field of
5689+ * ndlp and the reference to ndlp will be stored into the ndlp field of
57375690 * the IOCB for the completion callback function to the reject response
57385691 * ELS IOCB command.
57395692 *
@@ -5774,7 +5727,7 @@ lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError, · 34 unmodified lines
57745727 icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id;
57755728 }
57765729
5777− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
5730+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
57785731
57795732 *((uint32_t *) (pcmd)) = ELS_CMD_LS_RJT;
57805733 pcmd += sizeof(uint32_t);
@@ -5797,8 +5750,8 @@ lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError, · 16 unmodified lines
57975750
57985751 phba->fc_stat.elsXmitLSRJT++;
57995752 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
5800− elsiocb->context1 = lpfc_nlp_get(ndlp);
5801− if (!elsiocb->context1) {
5753+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
5754+ if (!elsiocb->ndlp) {
58025755 lpfc_els_free_iocb(phba, elsiocb);
58035756 return 1;
58045757 }
@@ -5870,8 +5823,7 @@ lpfc_issue_els_edc_rsp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 65 unmodified lines
58705823 icmd->unsli3.rcvsli3.ox_id = cmd->unsli3.rcvsli3.ox_id;
58715824 }
58725825
5873− pcmd = (((struct lpfc_dmabuf *)elsiocb->context2)->virt);
5874−
5826+ pcmd = elsiocb->cmd_dmabuf->virt;
58755827 memset(pcmd, 0, cmdsize);
58765828
58775829 edc_rsp = (struct lpfc_els_edc_rsp *)pcmd;
@@ -5891,8 +5843,8 @@ lpfc_issue_els_edc_rsp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 13 unmodified lines
58915843 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
58925844
58935845 phba->fc_stat.elsXmitACC++;
5894− elsiocb->context1 = lpfc_nlp_get(ndlp);
5895− if (!elsiocb->context1) {
5846+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
5847+ if (!elsiocb->ndlp) {
58965848 lpfc_els_free_iocb(phba, elsiocb);
58975849 return 1;
58985850 }
@@ -5927,7 +5879,7 @@ lpfc_issue_els_edc_rsp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 28 unmodified lines
59275879 * and invokes the lpfc_sli_issue_iocb() routine to send out the command.
59285880 *
59295881 * Note that the ndlp reference count will be incremented by 1 for holding the
5930− * ndlp and the reference to ndlp will be stored into the context1 field of
5882+ * ndlp and the reference to ndlp will be stored into the ndlp field of
59315883 * the IOCB for the completion callback function to the ADISC Accept response
59325884 * ELS IOCB command.
59335885 *
@@ -5980,7 +5932,7 @@ lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, · 46 unmodified lines
59805932 elsiocb->iotag, ulp_context,
59815933 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
59825934 ndlp->nlp_rpi);
5983− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
5935+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
59845936
59855937 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
59865938 pcmd += sizeof(uint32_t);
@@ -5997,8 +5949,8 @@ lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, · 10 unmodified lines
59975949
59985950 phba->fc_stat.elsXmitACC++;
59995951 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
6000− elsiocb->context1 = lpfc_nlp_get(ndlp);
6001− if (!elsiocb->context1) {
5952+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
5953+ if (!elsiocb->ndlp) {
60025954 lpfc_els_free_iocb(phba, elsiocb);
60035955 return 1;
60045956 }
@@ -6024,7 +5976,7 @@ lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, · 19 unmodified lines
60245976 * and invokes the lpfc_sli_issue_iocb() routine to send out the command.
60255977 *
60265978 * Note that the ndlp reference count will be incremented by 1 for holding the
6027− * ndlp and the reference to ndlp will be stored into the context1 field of
5979+ * ndlp and the reference to ndlp will be stored into the ndlp field of
60285980 * the IOCB for the completion callback function to the PRLI Accept response
60295981 * ELS IOCB command.
60305982 *
@@ -6054,7 +6006,7 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, · 23 unmodified lines
60546006 /* Need the incoming PRLI payload to determine if the ACC is for an
60556007 * FC4 or NVME PRLI type. The PRLI type is at word 1.
60566008 */
6057− req_buf = (struct lpfc_dmabuf *)oldiocb->context2;
6009+ req_buf = oldiocb->cmd_dmabuf;
60586010 req_payload = (((uint32_t *)req_buf->virt) + 1);
60596011
60606012 /* PRLI type payload is at byte 3 for FCP or NVME. */
@@ -6102,7 +6054,7 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, · 41 unmodified lines
61026054 elsiocb->iotag, ulp_context,
61036055 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
61046056 ndlp->nlp_rpi);
6105− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
6057+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
61066058 memset(pcmd, 0, cmdsize);
61076059
61086060 *((uint32_t *)(pcmd)) = elsrspcmd;
@@ -6175,8 +6127,8 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, · 66 unmodified lines
61756127
61766128 phba->fc_stat.elsXmitACC++;
61776129 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
6178− elsiocb->context1 = lpfc_nlp_get(ndlp);
6179− if (!elsiocb->context1) {
6130+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
6131+ if (!elsiocb->ndlp) {
61806132 lpfc_els_free_iocb(phba, elsiocb);
61816133 return 1;
61826134 }
@@ -6204,7 +6156,7 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, · 21 unmodified lines
62046156 * issue the response.
62056157 *
62066158 * Note that the ndlp reference count will be incremented by 1 for holding the
6207− * ndlp and the reference to ndlp will be stored into the context1 field of
6159+ * ndlp and the reference to ndlp will be stored into the ndlp field of
62086160 * the IOCB for the completion callback function.
62096161 *
62106162 * Return code
@@ -6255,7 +6207,7 @@ lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format, · 44 unmodified lines
62556207 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
62566208 "0132 Xmit RNID ACC response tag x%x xri x%x\n",
62576209 elsiocb->iotag, ulp_context);
6258− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
6210+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
62596211 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
62606212 pcmd += sizeof(uint32_t);
62616213
@@ -6289,8 +6241,8 @@ lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format, · 27 unmodified lines
62896241
62906242 phba->fc_stat.elsXmitACC++;
62916243 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
6292− elsiocb->context1 = lpfc_nlp_get(ndlp);
6293− if (!elsiocb->context1) {
6244+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
6245+ if (!elsiocb->ndlp) {
62946246 lpfc_els_free_iocb(phba, elsiocb);
62956247 return 1;
62966248 }
@@ -6325,7 +6277,7 @@ lpfc_els_clear_rrq(struct lpfc_vport *vport, · 28 unmodified lines
63256277 struct lpfc_node_rrq *prrq;
63266278
63276279
6328− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) iocb->context2)->virt);
6280+ pcmd = (uint8_t *)iocb->cmd_dmabuf->virt;
63296281 pcmd += sizeof(uint32_t);
63306282 rrq = (struct RRQ *)pcmd;
63316283 rrq->rrq_exchg = be32_to_cpu(rrq->rrq_exchg);
@@ -6412,7 +6364,7 @@ lpfc_els_rsp_echo_acc(struct lpfc_vport *vport, uint8_t *data, · 80 unmodified lines
64126364 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
64136365 "2876 Xmit ECHO ACC response tag x%x xri x%x\n",
64146366 elsiocb->iotag, ulp_context);
6415− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
6367+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
64166368 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
64176369 pcmd += sizeof(uint32_t);
64186370 memcpy(pcmd, data, cmdsize - sizeof(uint32_t));
@@ -6423,8 +6375,8 @@ lpfc_els_rsp_echo_acc(struct lpfc_vport *vport, uint8_t *data, · 4 unmodified lines
64236375
64246376 phba->fc_stat.elsXmitACC++;
64256377 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
6426− elsiocb->context1 = lpfc_nlp_get(ndlp);
6427− if (!elsiocb->context1) {
6378+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
6379+ if (!elsiocb->ndlp) {
64286380 lpfc_els_free_iocb(phba, elsiocb);
64296381 return 1;
64306382 }
@@ -7048,9 +7000,8 @@ lpfc_els_rdp_cmpl(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context, · 617 unmodified lines
70487000 elsiocb->iotag, ulp_context,
70497001 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
70507002 ndlp->nlp_rpi);
7051− rdp_res = (struct fc_rdp_res_frame *)
7052− (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
7053− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
7003+ rdp_res = (struct fc_rdp_res_frame *)elsiocb->cmd_dmabuf->virt;
7004+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
70547005 memset(pcmd, 0, sizeof(struct fc_rdp_res_frame));
70557006 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
70567007
@@ -7101,15 +7052,14 @@ lpfc_els_rdp_cmpl(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context, · 44 unmodified lines
71017052 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
71027053
71037054 /* Now that we know the true size of the payload, update the BPL */
7104− bpl = (struct ulp_bde64 *)
7105− (((struct lpfc_dmabuf *)(elsiocb->context3))->virt);
7055+ bpl = (struct ulp_bde64 *)elsiocb->bpl_dmabuf->virt;
71067056 bpl->tus.f.bdeSize = len;
71077057 bpl->tus.f.bdeFlags = 0;
71087058 bpl->tus.w = le32_to_cpu(bpl->tus.w);
71097059
71107060 phba->fc_stat.elsXmitACC++;
7111− elsiocb->context1 = lpfc_nlp_get(ndlp);
7112− if (!elsiocb->context1) {
7061+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
7062+ if (!elsiocb->ndlp) {
71137063 lpfc_els_free_iocb(phba, elsiocb);
71147064 goto free_rdp_context;
71157065 }
@@ -7143,7 +7093,7 @@ error: · 27 unmodified lines
71437093 icmd->unsli3.rcvsli3.ox_id = rdp_context->ox_id;
71447094 }
71457095
7146− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
7096+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
71477097
71487098 *((uint32_t *) (pcmd)) = ELS_CMD_LS_RJT;
71497099 stat = (struct ls_rjt *)(pcmd + sizeof(uint32_t));
@@ -7151,8 +7101,8 @@ error: · 1 unmodified line
71517101
71527102 phba->fc_stat.elsXmitLSRJT++;
71537103 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
7154− elsiocb->context1 = lpfc_nlp_get(ndlp);
7155− if (!elsiocb->context1) {
7104+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
7105+ if (!elsiocb->ndlp) {
71567106 lpfc_els_free_iocb(phba, elsiocb);
71577107 goto free_rdp_context;
71587108 }
@@ -7175,7 +7125,6 @@ static int · 16 unmodified lines
71757125 lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context)
71767126 {
71777127 LPFC_MBOXQ_t *mbox = NULL;
7178− struct lpfc_dmabuf *mp;
71797128 int rc;
71807129
71817130 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
@@ -7186,21 +7135,19 @@ lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context) · 4 unmodified lines
71867135 }
71877136
71887137 if (lpfc_sli4_dump_page_a0(phba, mbox))
7189− goto prep_mbox_fail;
7138+ goto rdp_fail;
71907139 mbox->vport = rdp_context->ndlp->vport;
71917140 mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a0;
71927141 mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
71937142 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
71947143 if (rc == MBX_NOT_FINISHED) {
7195− mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
7196− lpfc_mbuf_free(phba, mp->virt, mp->phys);
7197− goto issue_mbox_fail;
7144+ lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
7145+ return 1;
71987146 }
71997147
72007148 return 0;
72017149
7202−prep_mbox_fail:
7203−issue_mbox_fail:
7150+rdp_fail:
72047151 mempool_free(mbox, phba->mbox_mem_pool);
72057152 return 1;
72067153 }
@@ -7248,7 +7195,7 @@ lpfc_els_rcv_rdp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 41 unmodified lines
72487195 goto error;
72497196 }
72507197
7251− pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
7198+ pcmd = cmdiocb->cmd_dmabuf;
72527199 rdp_req = (struct fc_rdp_req_frame *) pcmd->virt;
72537200
72547201 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
@@ -7360,8 +7307,7 @@ lpfc_els_lcb_rsp(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 105 unmodified lines
73607307 if (!elsiocb)
73617308 goto free_lcb_context;
73627309
7363− lcb_res = (struct fc_lcb_res_frame *)
7364− (((struct lpfc_dmabuf *)elsiocb->context2)->virt);
7310+ lcb_res = (struct fc_lcb_res_frame *)elsiocb->cmd_dmabuf->virt;
73657311
73667312 memset(lcb_res, 0, sizeof(struct fc_lcb_res_frame));
73677313
@@ -7376,7 +7322,7 @@ lpfc_els_lcb_rsp(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 8 unmodified lines
73767322 icmd->unsli3.rcvsli3.ox_id = lcb_context->ox_id;
73777323 }
73787324
7379− pcmd = (uint8_t *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt);
7325+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
73807326 *((uint32_t *)(pcmd)) = ELS_CMD_ACC;
73817327 lcb_res->lcb_sub_command = lcb_context->sub_command;
73827328 lcb_res->lcb_type = lcb_context->type;
@@ -7386,8 +7332,8 @@ lpfc_els_lcb_rsp(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 3 unmodified lines
73867332 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
73877333 phba->fc_stat.elsXmitACC++;
73887334
7389− elsiocb->context1 = lpfc_nlp_get(ndlp);
7390− if (!elsiocb->context1) {
7335+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
7336+ if (!elsiocb->ndlp) {
73917337 lpfc_els_free_iocb(phba, elsiocb);
73927338 goto out;
73937339 }
@@ -7421,7 +7367,7 @@ error: · 27 unmodified lines
74217367 icmd->unsli3.rcvsli3.ox_id = lcb_context->ox_id;
74227368 }
74237369
7424− pcmd = (uint8_t *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt);
7370+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
74257371
74267372 *((uint32_t *)(pcmd)) = ELS_CMD_LS_RJT;
74277373 stat = (struct ls_rjt *)(pcmd + sizeof(uint32_t));
@@ -7432,8 +7378,8 @@ error: · 4 unmodified lines
74327378
74337379 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
74347380 phba->fc_stat.elsXmitLSRJT++;
7435− elsiocb->context1 = lpfc_nlp_get(ndlp);
7436− if (!elsiocb->context1) {
7381+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
7382+ if (!elsiocb->ndlp) {
74377383 lpfc_els_free_iocb(phba, elsiocb);
74387384 goto free_lcb_context;
74397385 }
@@ -7545,7 +7491,7 @@ lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 105 unmodified lines
75457491 u8 state, rjt_err = 0;
75467492 struct ls_rjt stat;
75477493
7548− pcmd = (struct lpfc_dmabuf *)cmdiocb->context2;
7494+ pcmd = cmdiocb->cmd_dmabuf;
75497495 lp = (uint8_t *)pcmd->virt;
75507496 beacon = (struct fc_lcb_request_frame *)pcmd->virt;
75517497
@@ -7742,10 +7688,10 @@ return_did_out: · 190 unmodified lines
77427688 static int
77437689 lpfc_rscn_recovery_check(struct lpfc_vport *vport)
77447690 {
7745− struct lpfc_nodelist *ndlp = NULL;
7691+ struct lpfc_nodelist *ndlp = NULL, *n;
77467692
77477693 /* Move all affected nodes by pending RSCNs to NPR state. */
7748− list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
7694+ list_for_each_entry_safe(ndlp, n, &vport->fc_nodes, nlp_listp) {
77497695 if ((ndlp->nlp_state == NLP_STE_UNUSED_NODE) ||
77507696 !lpfc_rscn_payload_check(vport, ndlp->nlp_DID))
77517697 continue;
@@ -7791,7 +7737,7 @@ lpfc_send_rscn_event(struct lpfc_vport *vport, · 39 unmodified lines
77917737 uint32_t payload_len;
77927738 struct lpfc_rscn_event_header *rscn_event_data;
77937739
7794− pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
7740+ pcmd = cmdiocb->cmd_dmabuf;
77957741 payload_ptr = (uint32_t *) pcmd->virt;
77967742 payload_len = be32_to_cpu(*payload_ptr & ~ELS_CMD_MASK);
77977743
@@ -7851,7 +7797,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 53 unmodified lines
78517797 int rscn_id = 0, hba_id = 0;
78527798 int i, tmo;
78537799
7854− pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
7800+ pcmd = cmdiocb->cmd_dmabuf;
78557801 lp = (uint32_t *) pcmd->virt;
78567802
78577803 payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK);
@@ -7953,7 +7899,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 95 unmodified lines
79537899 /* Get the array count after successfully have the token */
79547900 rscn_cnt = vport->fc_rscn_id_cnt;
79557901 /* If we are already processing an RSCN, save the received
7956− * RSCN payload buffer, cmdiocb->context2 to process later.
7902+ * RSCN payload buffer, cmdiocb->cmd_dmabuf to process later.
79577903 */
79587904 if (vport->fc_flag & (FC_RSCN_MODE | FC_NDISC_ACTIVE)) {
79597905 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -7972,6 +7918,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 12 unmodified lines
79727918 if ((rscn_cnt < FC_MAX_HOLD_RSCN) &&
79737919 !(vport->fc_flag & FC_RSCN_DISCOVERY)) {
79747920 vport->fc_flag |= FC_RSCN_MODE;
7921+ vport->fc_flag &= ~FC_RSCN_MEMENTO;
79757922 spin_unlock_irq(shost->host_lock);
79767923 if (rscn_cnt) {
79777924 cmd = vport->fc_rscn_id_list[rscn_cnt-1]->virt;
@@ -7986,10 +7933,10 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 8 unmodified lines
79867933 } else {
79877934 vport->fc_rscn_id_list[rscn_cnt] = pcmd;
79887935 vport->fc_rscn_id_cnt++;
7989− /* If we zero, cmdiocb->context2, the calling
7936+ /* If we zero, cmdiocb->cmd_dmabuf, the calling
79907937 * routine will not try to free it.
79917938 */
7992− cmdiocb->context2 = NULL;
7939+ cmdiocb->cmd_dmabuf = NULL;
79937940 }
79947941 /* Deferred RSCN */
79957942 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
@@ -8021,15 +7968,16 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 25 unmodified lines
80217968
80227969 spin_lock_irq(shost->host_lock);
80237970 vport->fc_flag |= FC_RSCN_MODE;
7971+ vport->fc_flag &= ~FC_RSCN_MEMENTO;
80247972 spin_unlock_irq(shost->host_lock);
80257973 vport->fc_rscn_id_list[vport->fc_rscn_id_cnt++] = pcmd;
80267974 /* Indicate we are done walking fc_rscn_id_list on this vport */
80277975 vport->fc_rscn_flush = 0;
80287976 /*
8029− * If we zero, cmdiocb->context2, the calling routine will
7977+ * If we zero, cmdiocb->cmd_dmabuf, the calling routine will
80307978 * not try to free it.
80317979 */
8032− cmdiocb->context2 = NULL;
7980+ cmdiocb->cmd_dmabuf = NULL;
80337981 lpfc_set_disctmo(vport);
80347982 /* Send back ACC */
80357983 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
@@ -8153,7 +8101,7 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 117 unmodified lines
81538101 {
81548102 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
81558103 struct lpfc_hba *phba = vport->phba;
8156− struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
8104+ struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf;
81578105 uint32_t *lp = (uint32_t *) pcmd->virt;
81588106 union lpfc_wqe128 *wqe = &cmdiocb->wqe;
81598107 struct serv_parm *sp;
@@ -8163,6 +8111,9 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 3 unmodified lines
81638111 uint32_t fc_flag = 0;
81648112 uint32_t port_state = 0;
81658113
8114+ /* Clear external loopback plug detected flag */
8115+ phba->link_flag &= ~LS_EXTERNAL_LOOPBACK;
8116+
81668117 cmd = *lp++;
81678118 sp = (struct serv_parm *) lp;
81688119
@@ -8214,6 +8165,12 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 45 unmodified lines
82148165 return 1;
82158166 }
82168167
8168+ /* External loopback plug insertion detected */
8169+ phba->link_flag |= LS_EXTERNAL_LOOPBACK;
8170+
8171+ lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_LIBDFC,
8172+ "1119 External Loopback plug detected\n");
8173+
82178174 /* abort the flogi coming back to ourselves
82188175 * due to external loopback on the port.
82198176 */
@@ -8320,7 +8277,7 @@ lpfc_els_rcv_rnid(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 100 unmodified lines
83208277 RNID *rn;
83218278 struct ls_rjt stat;
83228279
8323− pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
8280+ pcmd = cmdiocb->cmd_dmabuf;
83248281 lp = (uint32_t *) pcmd->virt;
83258282
83268283 lp++;
@@ -8361,7 +8318,7 @@ lpfc_els_rcv_echo(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 34 unmodified lines
83618318 {
83628319 uint8_t *pcmd;
83638320
8364− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) cmdiocb->context2)->virt);
8321+ pcmd = (uint8_t *)cmdiocb->cmd_dmabuf->virt;
83658322
83668323 /* skip over first word of echo command to find echo data */
83678324 pcmd += sizeof(uint32_t);
@@ -8437,7 +8394,7 @@ lpfc_els_rcv_rrq(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 69 unmodified lines
84378394 * response to the RLS.
84388395 *
84398396 * Note that the ndlp reference count will be incremented by 1 for holding the
8440− * ndlp and the reference to ndlp will be stored into the context1 field of
8397+ * ndlp and the reference to ndlp will be stored into the ndlp field of
84418398 * the IOCB for the completion callback function to the RLS Accept Response
84428399 * ELS IOCB command.
84438400 *
@@ -8460,7 +8417,7 @@ lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 16 unmodified lines
84608417
84618418 mb = &pmb->u.mb;
84628419
8463− ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
8420+ ndlp = pmb->ctx_ndlp;
84648421 rxid = (uint16_t)((unsigned long)(pmb->ctx_buf) & 0xffff);
84658422 oxid = (uint16_t)(((unsigned long)(pmb->ctx_buf) >> 16) & 0xffff);
84668423 pmb->ctx_buf = NULL;
@@ -8496,7 +8453,7 @@ lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 29 unmodified lines
84968453 icmd->unsli3.rcvsli3.ox_id = oxid;
84978454 }
84988455
8499− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
8456+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
85008457 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
85018458 pcmd += sizeof(uint32_t); /* Skip past command */
85028459 rls_rsp = (struct RLS_RSP *)pcmd;
@@ -8517,8 +8474,8 @@ lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 14 unmodified lines
85178474 ndlp->nlp_rpi);
85188475 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
85198476 phba->fc_stat.elsXmitACC++;
8520− elsiocb->context1 = lpfc_nlp_get(ndlp);
8521− if (!elsiocb->context1) {
8477+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
8478+ if (!elsiocb->ndlp) {
85228479 lpfc_els_free_iocb(phba, elsiocb);
85238480 return;
85248481 }
@@ -8609,7 +8566,7 @@ reject_out: · 84 unmodified lines
86098566 * Value (RTV) unsolicited IOCB event.
86108567 *
86118568 * Note that the ndlp reference count will be incremented by 1 for holding the
8612− * ndlp and the reference to ndlp will be stored into the context1 field of
8569+ * ndlp and the reference to ndlp will be stored into the ndlp field of
86138570 * the IOCB for the completion callback function to the RTV Accept Response
86148571 * ELS IOCB command.
86158572 *
@@ -8644,7 +8601,7 @@ lpfc_els_rcv_rtv(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 28 unmodified lines
86448601 if (!elsiocb)
86458602 return 1;
86468603
8647− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
8604+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
86488605 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
86498606 pcmd += sizeof(uint32_t); /* Skip past command */
86508607
@@ -8682,8 +8639,8 @@ lpfc_els_rcv_rtv(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 31 unmodified lines
86828639 rtv_rsp->ratov, rtv_rsp->edtov, rtv_rsp->qtov);
86838640 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
86848641 phba->fc_stat.elsXmitACC++;
8685− elsiocb->context1 = lpfc_nlp_get(ndlp);
8686− if (!elsiocb->context1) {
8642+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
8643+ if (!elsiocb->ndlp) {
86878644 lpfc_els_free_iocb(phba, elsiocb);
86888645 return 0;
86898646 }
@@ -8739,7 +8696,7 @@ lpfc_issue_els_rrq(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 49 unmodified lines
87398696 if (!elsiocb)
87408697 return 1;
87418698
8742− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
8699+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
87438700
87448701 /* For RRQ request, remainder of payload is Exchange IDs */
87458702 *((uint32_t *) (pcmd)) = ELS_CMD_RRQ;
@@ -8759,17 +8716,19 @@ lpfc_issue_els_rrq(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 13 unmodified lines
87598716 elsiocb->context_un.rrq = rrq;
87608717 elsiocb->cmd_cmpl = lpfc_cmpl_els_rrq;
87618718
8762− lpfc_nlp_get(ndlp);
8763− elsiocb->context1 = ndlp;
8719+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
8720+ if (!elsiocb->ndlp)
8721+ goto io_err;
87648722
87658723 ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
8766− if (ret == IOCB_ERROR)
8724+ if (ret == IOCB_ERROR) {
8725+ lpfc_nlp_put(ndlp);
87678726 goto io_err;
8727+ }
87688728 return 0;
87698729
87708730 io_err:
87718731 lpfc_els_free_iocb(phba, elsiocb);
8772− lpfc_nlp_put(ndlp);
87738732 return 1;
87748733 }
87758734
@@ -8811,7 +8770,7 @@ lpfc_send_rrq(struct lpfc_hba *phba, struct lpfc_node_rrq *rrq) · 35 unmodified lines
88118770 * It is to be called by the lpfc_els_rcv_rpl() routine to accept the RPL.
88128771 *
88138772 * Note that the ndlp reference count will be incremented by 1 for holding the
8814− * ndlp and the reference to ndlp will be stored into the context1 field of
8773+ * ndlp and the reference to ndlp will be stored into the ndlp field of
88158774 * the IOCB for the completion callback function to the RPL Accept Response
88168775 * ELS command.
88178776 *
@@ -8852,7 +8811,7 @@ lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize, · 34 unmodified lines
88528811 icmd->unsli3.rcvsli3.ox_id = get_job_rcvoxid(phba, oldiocb);
88538812 }
88548813
8855− pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
8814+ pcmd = elsiocb->cmd_dmabuf->virt;
88568815 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
88578816 pcmd += sizeof(uint16_t);
88588817 *((uint16_t *)(pcmd)) = be16_to_cpu(cmdsize);
@@ -8876,8 +8835,8 @@ lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize, · 17 unmodified lines
88768835 ndlp->nlp_rpi);
88778836 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
88788837 phba->fc_stat.elsXmitACC++;
8879− elsiocb->context1 = lpfc_nlp_get(ndlp);
8880− if (!elsiocb->context1) {
8838+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
8839+ if (!elsiocb->ndlp) {
88818840 lpfc_els_free_iocb(phba, elsiocb);
88828841 return 1;
88838842 }
@@ -8932,7 +8891,7 @@ lpfc_els_rcv_rpl(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 48 unmodified lines
89328891 return 0;
89338892 }
89348893
8935− pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
8894+ pcmd = cmdiocb->cmd_dmabuf;
89368895 lp = (uint32_t *) pcmd->virt;
89378896 rpl = (RPL *) (lp + 1);
89388897 maxsize = be32_to_cpu(rpl->maxsize);
@@ -8984,7 +8943,7 @@ lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 45 unmodified lines
89848943 uint32_t cnt, did;
89858944
89868945 did = get_job_els_rsp64_did(vport->phba, cmdiocb);
8987− pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
8946+ pcmd = cmdiocb->cmd_dmabuf;
89888947 lp = (uint32_t *) pcmd->virt;
89898948
89908949 lp++;
@@ -9054,8 +9013,8 @@ lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 63 unmodified lines
90549013 uint32_t did;
90559014
90569015 did = get_job_els_rsp64_did(vport->phba, cmdiocb);
9057− pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
9058− lp = (uint32_t *) pcmd->virt;
9016+ pcmd = cmdiocb->cmd_dmabuf;
9017+ lp = (uint32_t *)pcmd->virt;
90599018
90609019 lp++;
90619020 /* FARP-RSP received from DID <did> */
@@ -9095,7 +9054,7 @@ lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 33 unmodified lines
90959054 FAN *fp;
90969055
90979056 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, "0265 FAN received\n");
9098− lp = (uint32_t *)((struct lpfc_dmabuf *)cmdiocb->context2)->virt;
9057+ lp = (uint32_t *)cmdiocb->cmd_dmabuf->virt;
90999058 fp = (FAN *) ++lp;
91009059 /* FAN received; Fan does not have a reply sequence */
91019060 if ((vport == phba->pport) &&
@@ -9144,7 +9103,7 @@ lpfc_els_rcv_edc(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 42 unmodified lines
91449103 int desc_cnt = 0, bytes_remain;
91459104 bool rcv_cap_desc = false;
91469105
9147− payload = ((struct lpfc_dmabuf *)cmdiocb->context2)->virt;
9106+ payload = cmdiocb->cmd_dmabuf->virt;
91489107
91499108 edc_req = (struct fc_els_edc *)payload;
91509109 bytes_remain = be32_to_cpu(edc_req->desc_len);
@@ -9329,7 +9288,7 @@ lpfc_els_timeout_handler(struct lpfc_vport *vport) · 178 unmodified lines
93299288 if (piocb->vport != vport)
93309289 continue;
93319290
9332− pcmd = (struct lpfc_dmabuf *) piocb->context2;
9291+ pcmd = piocb->cmd_dmabuf;
93339292 if (pcmd)
93349293 els_command = *(uint32_t *) (pcmd->virt);
93359294
@@ -9584,7 +9543,7 @@ lpfc_send_els_failure_event(struct lpfc_hba *phba, · 248 unmodified lines
95849543 uint32_t *pcmd;
95859544 u32 ulp_status, ulp_word4;
95869545
9587− ndlp = cmdiocbp->context1;
9546+ ndlp = cmdiocbp->ndlp;
95889547 if (!ndlp)
95899548 return;
95909549
@@ -9598,8 +9557,7 @@ lpfc_send_els_failure_event(struct lpfc_hba *phba, · 7 unmodified lines
95989557 sizeof(struct lpfc_name));
95999558 memcpy(lsrjt_event.header.wwnn, &ndlp->nlp_nodename,
96009559 sizeof(struct lpfc_name));
9601− pcmd = (uint32_t *) (((struct lpfc_dmabuf *)
9602− cmdiocbp->context2)->virt);
9560+ pcmd = (uint32_t *)cmdiocbp->cmd_dmabuf->virt;
96039561 lsrjt_event.command = (pcmd != NULL) ? *pcmd : 0;
96049562 stat.un.ls_rjt_error_be = cpu_to_be32(ulp_word4);
96059563 lsrjt_event.reason_code = stat.un.b.lsRjtRsnCode;
@@ -9940,11 +9898,14 @@ lpfc_els_rcv_fpin_cgn(struct lpfc_hba *phba, struct fc_tlv_desc *tlv) · 334 unmodified lines
99409898 /* Take action here for an Alarm event */
99419899 if (phba->cmf_active_mode != LPFC_CFG_OFF) {
99429900 if (phba->cgn_reg_fpin & LPFC_CGN_FPIN_ALARM) {
9943− /* Track of alarm cnt for cgn_info */
9944− atomic_inc(&phba->cgn_fabric_alarm_cnt);
99459901 /* Track of alarm cnt for SYNC_WQE */
99469902 atomic_inc(&phba->cgn_sync_alarm_cnt);
99479903 }
9904+ /* Track alarm cnt for cgn_info regardless
9905+ * of whether CMF is configured for Signals
9906+ * or FPINs.
9907+ */
9908+ atomic_inc(&phba->cgn_fabric_alarm_cnt);
99489909 goto cleanup;
99499910 }
99509911 break;
@@ -9952,11 +9913,14 @@ lpfc_els_rcv_fpin_cgn(struct lpfc_hba *phba, struct fc_tlv_desc *tlv) · 1 unmodified line
99529913 /* Take action here for a Warning event */
99539914 if (phba->cmf_active_mode != LPFC_CFG_OFF) {
99549915 if (phba->cgn_reg_fpin & LPFC_CGN_FPIN_WARN) {
9955− /* Track of warning cnt for cgn_info */
9956− atomic_inc(&phba->cgn_fabric_warn_cnt);
99579916 /* Track of warning cnt for SYNC_WQE */
99589917 atomic_inc(&phba->cgn_sync_warn_cnt);
99599918 }
9919+ /* Track warning cnt and freq for cgn_info
9920+ * regardless of whether CMF is configured for
9921+ * Signals or FPINs.
9922+ */
9923+ atomic_inc(&phba->cgn_fabric_warn_cnt);
99609924 cleanup:
99619925 /* Save frequency in ms */
99629926 phba->cgn_fpin_frequency =
@@ -9965,14 +9929,10 @@ cleanup: · 2 unmodified lines
99659929 if (phba->cgn_i) {
99669930 cp = (struct lpfc_cgn_info *)
99679931 phba->cgn_i->virt;
9968− if (phba->cgn_reg_fpin &
9969− LPFC_CGN_FPIN_ALARM)
9970− cp->cgn_alarm_freq =
9971− cpu_to_le16(value);
9972− if (phba->cgn_reg_fpin &
9973− LPFC_CGN_FPIN_WARN)
9974− cp->cgn_warn_freq =
9975− cpu_to_le16(value);
9932+ cp->cgn_alarm_freq =
9933+ cpu_to_le16(value);
9934+ cp->cgn_warn_freq =
9935+ cpu_to_le16(value);
99769936 crc = lpfc_cgn_calc_crc32
99779937 (cp,
99789938 LPFC_CGN_INFO_SZ,
@@ -10133,12 +10093,12 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 154 unmodified lines
1013310093 struct lpfc_wcqe_complete *wcqe_cmpl = NULL;
1013410094 LPFC_MBOXQ_t *mbox;
1013510095
10136− if (!vport || !(elsiocb->context2))
10096+ if (!vport || !elsiocb->cmd_dmabuf)
1013710097 goto dropit;
1013810098
1013910099 newnode = 0;
1014010100 wcqe_cmpl = &elsiocb->wcqe_cmpl;
10141− payload = ((struct lpfc_dmabuf *)elsiocb->context2)->virt;
10101+ payload = elsiocb->cmd_dmabuf->virt;
1014210102 if (phba->sli_rev == LPFC_SLI_REV4)
1014310103 payload_len = wcqe_cmpl->total_data_placed;
1014410104 else
@@ -10199,8 +10159,8 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 54 unmodified lines
1019910159 }
1020010160 spin_unlock_irq(&ndlp->lock);
1020110161
10202− elsiocb->context1 = lpfc_nlp_get(ndlp);
10203− if (!elsiocb->context1)
10162+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
10163+ if (!elsiocb->ndlp)
1020410164 goto dropit;
1020510165 elsiocb->vport = vport;
1020610166
@@ -10556,8 +10516,8 @@ lsrjt: · 349 unmodified lines
1055610516 }
1055710517
1055810518 /* Release the reference on this elsiocb, not the ndlp. */
10559− lpfc_nlp_put(elsiocb->context1);
10560− elsiocb->context1 = NULL;
10519+ lpfc_nlp_put(elsiocb->ndlp);
10520+ elsiocb->ndlp = NULL;
1056110521
1056210522 /* Special case. Driver received an unsolicited command that
1056310523 * unsupportable given the driver's current state. Reset the
@@ -10611,13 +10571,13 @@ lpfc_els_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 47 unmodified lines
1061110571 u32 ulp_command, status, parameter, bde_count = 0;
1061210572 IOCB_t *icmd;
1061310573 struct lpfc_wcqe_complete *wcqe_cmpl = NULL;
10614− struct lpfc_dmabuf *bdeBuf1 = elsiocb->context2;
10615− struct lpfc_dmabuf *bdeBuf2 = elsiocb->context3;
10574+ struct lpfc_dmabuf *bdeBuf1 = elsiocb->cmd_dmabuf;
10575+ struct lpfc_dmabuf *bdeBuf2 = elsiocb->bpl_dmabuf;
1061610576 dma_addr_t paddr;
1061710577
10618− elsiocb->context1 = NULL;
10619− elsiocb->context2 = NULL;
10620− elsiocb->context3 = NULL;
10578+ elsiocb->cmd_dmabuf = NULL;
10579+ elsiocb->rsp_dmabuf = NULL;
10580+ elsiocb->bpl_dmabuf = NULL;
1062110581
1062210582 wcqe_cmpl = &elsiocb->wcqe_cmpl;
1062310583 ulp_command = get_job_cmnd(phba, elsiocb);
@@ -10661,38 +10621,39 @@ lpfc_els_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 37 unmodified lines
1066110621
1066210622 /* Account for SLI2 or SLI3 and later unsolicited buffering */
1066310623 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {
10664− elsiocb->context2 = bdeBuf1;
10624+ elsiocb->cmd_dmabuf = bdeBuf1;
1066510625 if (bde_count == 2)
10666− elsiocb->context3 = bdeBuf2;
10626+ elsiocb->bpl_dmabuf = bdeBuf2;
1066710627 } else {
1066810628 icmd = &elsiocb->iocb;
1066910629 paddr = getPaddr(icmd->un.cont64[0].addrHigh,
1067010630 icmd->un.cont64[0].addrLow);
10671− elsiocb->context2 = lpfc_sli_ringpostbuf_get(phba, pring,
10672− paddr);
10631+ elsiocb->cmd_dmabuf = lpfc_sli_ringpostbuf_get(phba, pring,
10632+ paddr);
1067310633 if (bde_count == 2) {
1067410634 paddr = getPaddr(icmd->un.cont64[1].addrHigh,
1067510635 icmd->un.cont64[1].addrLow);
10676− elsiocb->context3 = lpfc_sli_ringpostbuf_get(phba,
10677− pring,
10678− paddr);
10636+ elsiocb->bpl_dmabuf = lpfc_sli_ringpostbuf_get(phba,
10637+ pring,
10638+ paddr);
1067910639 }
1068010640 }
1068110641
1068210642 lpfc_els_unsol_buffer(phba, pring, vport, elsiocb);
1068310643 /*
1068410644 * The different unsolicited event handlers would tell us
10685− * if they are done with "mp" by setting context2 to NULL.
10645+ * if they are done with "mp" by setting cmd_dmabuf to NULL.
1068610646 */
10687− if (elsiocb->context2) {
10688− lpfc_in_buf_free(phba, (struct lpfc_dmabuf *)elsiocb->context2);
10689− elsiocb->context2 = NULL;
10647+ if (elsiocb->cmd_dmabuf) {
10648+ lpfc_in_buf_free(phba, elsiocb->cmd_dmabuf);
10649+ elsiocb->cmd_dmabuf = NULL;
1069010650 }
1069110651
10692− if (elsiocb->context3) {
10693− lpfc_in_buf_free(phba, elsiocb->context3);
10694− elsiocb->context3 = NULL;
10652+ if (elsiocb->bpl_dmabuf) {
10653+ lpfc_in_buf_free(phba, elsiocb->bpl_dmabuf);
10654+ elsiocb->bpl_dmabuf = NULL;
1069510655 }
10656+
1069610657 }
1069710658
1069810659 static void
@@ -10803,7 +10764,7 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 104 unmodified lines
1080310764 {
1080410765 struct lpfc_vport *vport = pmb->vport;
1080510766 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
10806− struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
10767+ struct lpfc_nodelist *ndlp = pmb->ctx_ndlp;
1080710768 MAILBOX_t *mb = &pmb->u.mb;
1080810769 int rc;
1080910770
@@ -11068,11 +11029,11 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 258 unmodified lines
1106811029 {
1106911030 struct lpfc_vport *vport = cmdiocb->vport;
1107011031 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
11071− struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
11032+ struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
1107211033 struct lpfc_nodelist *np;
1107311034 struct lpfc_nodelist *next_np;
1107411035 struct lpfc_iocbq *piocb;
11075− struct lpfc_dmabuf *pcmd = cmdiocb->context2, *prsp;
11036+ struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf, *prsp;
1107611037 struct serv_parm *sp;
1107711038 uint8_t fabric_param_changed;
1107811039 u32 ulp_status, ulp_word4;
@@ -11210,7 +11171,7 @@ out: · 131 unmodified lines
1121011171 * IOCB will be sent off HBA at any given time.
1121111172 *
1121211173 * Note that the ndlp reference count will be incremented by 1 for holding the
11213− * ndlp and the reference to ndlp will be stored into the context1 field of
11174+ * ndlp and the reference to ndlp will be stored into the ndlp field of
1121411175 * the IOCB for the completion callback function to the FDISC ELS command.
1121511176 *
1121611177 * Return code
@@ -11255,7 +11216,7 @@ lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 38 unmodified lines
1125511216 icmd->ulpCt_l = 0;
1125611217 }
1125711218
11258− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
11219+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
1125911220 *((uint32_t *) (pcmd)) = ELS_CMD_FDISC;
1126011221 pcmd += sizeof(uint32_t); /* CSP Word 1 */
1126111222 memcpy(pcmd, &vport->phba->pport->fc_sparam, sizeof(struct serv_parm));
@@ -11287,8 +11248,8 @@ lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 25 unmodified lines
1128711248 "Issue FDISC: did:x%x",
1128811249 did, 0, 0);
1128911250
11290− elsiocb->context1 = lpfc_nlp_get(ndlp);
11291− if (!elsiocb->context1)
11251+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
11252+ if (!elsiocb->ndlp)
1129211253 goto err_out;
1129311254
1129411255 rc = lpfc_issue_fabric_iocb(phba, elsiocb);
@@ -11332,7 +11293,7 @@ lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 37 unmodified lines
1133211293 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1133311294 u32 ulp_status, ulp_word4, did, tmo;
1133411295
11335− ndlp = (struct lpfc_nodelist *)cmdiocb->context1;
11296+ ndlp = cmdiocb->ndlp;
1133611297
1133711298 ulp_status = get_job_ulpstatus(phba, rspiocb);
1133811299 ulp_word4 = get_job_word4(phba, rspiocb);
@@ -11390,7 +11351,7 @@ lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 51 unmodified lines
1139011351 * This routine issues a LOGO ELS command to an @ndlp off a @vport.
1139111352 *
1139211353 * Note that the ndlp reference count will be incremented by 1 for holding the
11393− * ndlp and the reference to ndlp will be stored into the context1 field of
11354+ * ndlp and the reference to ndlp will be stored into the ndlp field of
1139411355 * the IOCB for the completion callback function to the LOGO ELS command.
1139511356 *
1139611357 * Return codes
@@ -11412,7 +11373,7 @@ lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 15 unmodified lines
1141211373 if (!elsiocb)
1141311374 return 1;
1141411375
11415− pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
11376+ pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
1141611377 *((uint32_t *) (pcmd)) = ELS_CMD_LOGO;
1141711378 pcmd += sizeof(uint32_t);
1141811379
@@ -11429,8 +11390,8 @@ lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 10 unmodified lines
1142911390 spin_lock_irq(&ndlp->lock);
1143011391 ndlp->nlp_flag |= NLP_LOGO_SND;
1143111392 spin_unlock_irq(&ndlp->lock);
11432− elsiocb->context1 = lpfc_nlp_get(ndlp);
11433− if (!elsiocb->context1) {
11393+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
11394+ if (!elsiocb->ndlp) {
1143411395 lpfc_els_free_iocb(phba, elsiocb);
1143511396 goto err;
1143611397 }
@@ -11989,12 +11950,12 @@ lpfc_cmpl_els_qfpa(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 552 unmodified lines
1198911950 struct lpfc_dmabuf *prsp = NULL;
1199011951 struct lpfc_vmid_priority_range *vmid_range = NULL;
1199111952 u32 *data;
11992− struct lpfc_dmabuf *dmabuf = cmdiocb->context2;
11953+ struct lpfc_dmabuf *dmabuf = cmdiocb->cmd_dmabuf;
1199311954 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
1199411955 u32 ulp_word4 = get_job_word4(phba, rspiocb);
1199511956 u8 *pcmd, max_desc;
1199611957 u32 len, i;
11997− struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)cmdiocb->context1;
11958+ struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
1199811959
1199911960 prsp = list_get_first(&dmabuf->list, struct lpfc_dmabuf, list);
1200011961 if (!prsp)
@@ -12090,15 +12051,15 @@ int lpfc_issue_els_qfpa(struct lpfc_vport *vport) · 89 unmodified lines
1209012051 if (!elsiocb)
1209112052 return -ENOMEM;
1209212053
12093− pcmd = (u8 *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt);
12054+ pcmd = (u8 *)elsiocb->cmd_dmabuf->virt;
1209412055
1209512056 *((u32 *)(pcmd)) = ELS_CMD_QFPA;
1209612057 pcmd += 4;
1209712058
1209812059 elsiocb->cmd_cmpl = lpfc_cmpl_els_qfpa;
1209912060
12100− elsiocb->context1 = lpfc_nlp_get(ndlp);
12101− if (!elsiocb->context1) {
12061+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
12062+ if (!elsiocb->ndlp) {
1210212063 lpfc_els_free_iocb(vport->phba, elsiocb);
1210312064 return -ENXIO;
1210412065 }
@@ -12145,7 +12106,7 @@ lpfc_vmid_uvem(struct lpfc_vport *vport, · 40 unmodified lines
1214512106 vmid_context->nlp = ndlp;
1214612107 vmid_context->instantiated = instantiated;
1214712108 elsiocb->vmid_tag.vmid_context = vmid_context;
12148− pcmd = (u8 *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt);
12109+ pcmd = (u8 *)elsiocb->cmd_dmabuf->virt;
1214912110
1215012111 if (uuid_is_null((uuid_t *)vport->lpfc_vmid_host_uuid))
1215112112 memcpy(vport->lpfc_vmid_host_uuid, vmid->host_vmid,
@@ -12180,8 +12141,8 @@ lpfc_vmid_uvem(struct lpfc_vport *vport, · 28 unmodified lines
1218012141
1218112142 elsiocb->cmd_cmpl = lpfc_cmpl_els_uvem;
1218212143
12183− elsiocb->context1 = lpfc_nlp_get(ndlp);
12184− if (!elsiocb->context1) {
12144+ elsiocb->ndlp = lpfc_nlp_get(ndlp);
12145+ if (!elsiocb->ndlp) {
1218512146 lpfc_els_free_iocb(vport->phba, elsiocb);
1218612147 goto out;
1218712148 }
@@ -12207,12 +12168,12 @@ lpfc_cmpl_els_uvem(struct lpfc_hba *phba, struct lpfc_iocbq *icmdiocb, · 19 unmodified lines
1220712168 struct lpfc_dmabuf *prsp = NULL;
1220812169 struct lpfc_vmid_context *vmid_context =
1220912170 icmdiocb->vmid_tag.vmid_context;
12210− struct lpfc_nodelist *ndlp = icmdiocb->context1;
12171+ struct lpfc_nodelist *ndlp = icmdiocb->ndlp;
1221112172 u8 *pcmd;
1221212173 u32 *data;
1221312174 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
1221412175 u32 ulp_word4 = get_job_word4(phba, rspiocb);
12215− struct lpfc_dmabuf *dmabuf = icmdiocb->context2;
12176+ struct lpfc_dmabuf *dmabuf = icmdiocb->cmd_dmabuf;
1221612177 struct lpfc_vmid *vmid;
1221712178
1221812179 vmid = vmid_context->vmp;
drivers/scsi/lpfc/lpfc_hbadisc.c+63−101
@@ -1183,6 +1183,7 @@ lpfc_port_link_failure(struct lpfc_vport *vport) · 1182 unmodified lines
11831183 void
11841184 lpfc_linkdown_port(struct lpfc_vport *vport)
11851185 {
1186+ struct lpfc_hba *phba = vport->phba;
11861187 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
11871188
11881189 if (vport->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
@@ -1200,6 +1201,13 @@ lpfc_linkdown_port(struct lpfc_vport *vport) · 11 unmodified lines
12001201 vport->fc_flag &= ~FC_DISC_DELAYED;
12011202 spin_unlock_irq(shost->host_lock);
12021203 del_timer_sync(&vport->delayed_disc_tmo);
1204+
1205+ if (phba->sli_rev == LPFC_SLI_REV4 &&
1206+ vport->port_type == LPFC_PHYSICAL_PORT &&
1207+ phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG) {
1208+ /* Assume success on link up */
1209+ phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_FABRIC;
1210+ }
12031211 }
12041212
12051213 int
@@ -1221,6 +1229,9 @@ lpfc_linkdown(struct lpfc_hba *phba) · 15 unmodified lines
12211229
12221230 phba->defer_flogi_acc_flag = false;
12231231
1232+ /* Clear external loopback plug detected flag */
1233+ phba->link_flag &= ~LS_EXTERNAL_LOOPBACK;
1234+
12241235 spin_lock_irq(&phba->hbalock);
12251236 phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE);
12261237 spin_unlock_irq(&phba->hbalock);
@@ -1343,10 +1354,12 @@ lpfc_linkup_port(struct lpfc_vport *vport) · 116 unmodified lines
13431354
13441355 spin_lock_irq(shost->host_lock);
13451356 vport->fc_flag &= ~(FC_PT2PT | FC_PT2PT_PLOGI | FC_ABORT_DISCOVERY |
1346− FC_RSCN_MODE | FC_NLP_MORE | FC_RSCN_DISCOVERY);
1357+ FC_RSCN_MEMENTO | FC_RSCN_MODE |
1358+ FC_NLP_MORE | FC_RSCN_DISCOVERY);
13471359 vport->fc_flag |= FC_NDISC_ACTIVE;
13481360 vport->fc_ns_retry = 0;
13491361 spin_unlock_irq(shost->host_lock);
1362+ lpfc_setup_fdmi_mask(vport);
13501363
13511364 lpfc_linkup_cleanup_nodes(vport);
13521365 }
@@ -1378,8 +1391,8 @@ lpfc_linkup(struct lpfc_hba *phba) · 25 unmodified lines
13781391 phba->pport->rcv_flogi_cnt = 0;
13791392 spin_unlock_irq(shost->host_lock);
13801393
1381− /* reinitialize initial FLOGI flag */
1382− phba->hba_flag &= ~(HBA_FLOGI_ISSUED);
1394+ /* reinitialize initial HBA flag */
1395+ phba->hba_flag &= ~(HBA_FLOGI_ISSUED | HBA_RHBA_CMPL);
13831396 phba->defer_flogi_acc_flag = false;
13841397
13851398 return 0;
@@ -1458,7 +1471,6 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 72 unmodified lines
14581471 {
14591472 struct lpfc_vport *vport = pmb->vport;
14601473 LPFC_MBOXQ_t *sparam_mb;
1461− struct lpfc_dmabuf *sparam_mp;
14621474 u16 status = pmb->u.mb.mbxStatus;
14631475 int rc;
14641476
@@ -1507,13 +1519,8 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 42 unmodified lines
15071519 sparam_mb->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;
15081520 rc = lpfc_sli_issue_mbox(phba, sparam_mb, MBX_NOWAIT);
15091521 if (rc == MBX_NOT_FINISHED) {
1510− sparam_mp = (struct lpfc_dmabuf *)
1511− sparam_mb->ctx_buf;
1512− lpfc_mbuf_free(phba, sparam_mp->virt,
1513− sparam_mp->phys);
1514− kfree(sparam_mp);
1515− sparam_mb->ctx_buf = NULL;
1516− mempool_free(sparam_mb, phba->mbox_mem_pool);
1522+ lpfc_mbox_rsrc_cleanup(phba, sparam_mb,
1523+ MBOX_THD_UNLOCKED);
15171524 goto sparam_out;
15181525 }
15191526
@@ -3312,7 +3319,6 @@ lpfc_start_fdiscs(struct lpfc_hba *phba) · 1792 unmodified lines
33123319 void
33133320 lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
33143321 {
3315− struct lpfc_dmabuf *dmabuf = mboxq->ctx_buf;
33163322 struct lpfc_vport *vport = mboxq->vport;
33173323 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
33183324
@@ -3393,12 +3399,7 @@ lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) · 74 unmodified lines
33933399 }
33943400
33953401 out_free_mem:
3396− mempool_free(mboxq, phba->mbox_mem_pool);
3397− if (dmabuf) {
3398− lpfc_mbuf_free(phba, dmabuf->virt, dmabuf->phys);
3399− kfree(dmabuf);
3400− }
3401− return;
3402+ lpfc_mbox_rsrc_cleanup(phba, mboxq, MBOX_THD_UNLOCKED);
34023403 }
34033404
34043405 static void
@@ -3443,9 +3444,7 @@ lpfc_mbx_cmpl_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 38 unmodified lines
34433444 memcpy(&phba->wwpn, &vport->fc_portname, sizeof(phba->wwnn));
34443445 }
34453446
3446− lpfc_mbuf_free(phba, mp->virt, mp->phys);
3447− kfree(mp);
3448− mempool_free(pmb, phba->mbox_mem_pool);
3447+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
34493448
34503449 /* Check if sending the FLOGI is being deferred to after we get
34513450 * up to date CSPs from MBX_READ_SPARAM.
@@ -3457,12 +3456,8 @@ lpfc_mbx_cmpl_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 5 unmodified lines
34573456 return;
34583457
34593458 out:
3460− pmb->ctx_buf = NULL;
3461− lpfc_mbuf_free(phba, mp->virt, mp->phys);
3462− kfree(mp);
3459+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
34633460 lpfc_issue_clear_la(phba, vport);
3464− mempool_free(pmb, phba->mbox_mem_pool);
3465− return;
34663461 }
34673462
34683463 static void
@@ -3472,7 +3467,6 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la) · 3 unmodified lines
34723467 LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox = NULL;
34733468 struct Scsi_Host *shost;
34743469 int i;
3475− struct lpfc_dmabuf *mp;
34763470 int rc;
34773471 struct fcf_record *fcf_record;
34783472 uint32_t fc_flags = 0;
@@ -3600,10 +3594,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la) · 121 unmodified lines
36003594 sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;
36013595 rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT);
36023596 if (rc == MBX_NOT_FINISHED) {
3603− mp = (struct lpfc_dmabuf *)sparam_mbox->ctx_buf;
3604− lpfc_mbuf_free(phba, mp->virt, mp->phys);
3605− kfree(mp);
3606− mempool_free(sparam_mbox, phba->mbox_mem_pool);
3597+ lpfc_mbox_rsrc_cleanup(phba, sparam_mbox, MBOX_THD_UNLOCKED);
36073598 goto out;
36083599 }
36093600
@@ -3879,10 +3870,7 @@ lpfc_mbx_cmpl_read_topology(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 269 unmodified lines
38793870 }
38803871
38813872 lpfc_mbx_cmpl_read_topology_free_mbuf:
3882− lpfc_mbuf_free(phba, mp->virt, mp->phys);
3883− kfree(mp);
3884− mempool_free(pmb, phba->mbox_mem_pool);
3885− return;
3873+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
38863874 }
38873875
38883876 /*
@@ -3895,9 +3883,13 @@ void · 6 unmodified lines
38953883 lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
38963884 {
38973885 struct lpfc_vport *vport = pmb->vport;
3898− struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);
3886+ struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
38993887 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
39003888
3889+ /* The driver calls the state machine with the pmb pointer
3890+ * but wants to make sure a stale ctx_buf isn't acted on.
3891+ * The ctx_buf is restored later and cleaned up.
3892+ */
39013893 pmb->ctx_buf = NULL;
39023894 pmb->ctx_ndlp = NULL;
39033895
@@ -3934,10 +3926,9 @@ lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 30 unmodified lines
39343926
39353927 /* Call state machine */
39363928 lpfc_disc_state_machine(vport, ndlp, pmb, NLP_EVT_CMPL_REG_LOGIN);
3929+ pmb->ctx_buf = mp;
3930+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
39373931
3938− lpfc_mbuf_free(phba, mp->virt, mp->phys);
3939− kfree(mp);
3940− mempool_free(pmb, phba->mbox_mem_pool);
39413932 /* decrement the node reference count held for this callback
39423933 * function.
39433934 */
@@ -4104,11 +4095,15 @@ lpfc_create_static_vport(struct lpfc_hba *phba) · 160 unmodified lines
41044095
41054096 vport_buff = (uint8_t *) vport_info;
41064097 do {
4107− /* free dma buffer from previous round */
4098+ /* While loop iteration forces a free dma buffer from
4099+ * the previous loop because the mbox is reused and
4100+ * the dump routine is a single-use construct.
4101+ */
41084102 if (pmb->ctx_buf) {
41094103 mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
41104104 lpfc_mbuf_free(phba, mp->virt, mp->phys);
41114105 kfree(mp);
4106+ pmb->ctx_buf = NULL;
41124107 }
41134108 if (lpfc_dump_static_vport(phba, pmb, offset))
41144109 goto out;
@@ -4193,16 +4188,8 @@ lpfc_create_static_vport(struct lpfc_hba *phba) · 78 unmodified lines
41934188
41944189 out:
41954190 kfree(vport_info);
4196− if (mbx_wait_rc != MBX_TIMEOUT) {
4197− if (pmb->ctx_buf) {
4198− mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
4199− lpfc_mbuf_free(phba, mp->virt, mp->phys);
4200− kfree(mp);
4201− }
4202− mempool_free(pmb, phba->mbox_mem_pool);
4203− }
4204−
4205− return;
4191+ if (mbx_wait_rc != MBX_TIMEOUT)
4192+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
42064193 }
42074194
42084195 /*
@@ -4216,22 +4203,16 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 7 unmodified lines
42164203 {
42174204 struct lpfc_vport *vport = pmb->vport;
42184205 MAILBOX_t *mb = &pmb->u.mb;
4219− struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);
4220− struct lpfc_nodelist *ndlp;
4206+ struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
42214207 struct Scsi_Host *shost;
42224208
4223− ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
42244209 pmb->ctx_ndlp = NULL;
4225− pmb->ctx_buf = NULL;
42264210
42274211 if (mb->mbxStatus) {
42284212 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
42294213 "0258 Register Fabric login error: 0x%x\n",
42304214 mb->mbxStatus);
4231− lpfc_mbuf_free(phba, mp->virt, mp->phys);
4232− kfree(mp);
4233− mempool_free(pmb, phba->mbox_mem_pool);
4234−
4215+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
42354216 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
42364217 /* FLOGI failed, use loop map to make discovery list */
42374218 lpfc_disc_list_loopmap(vport);
@@ -4273,9 +4254,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 35 unmodified lines
42734254 lpfc_do_scr_ns_plogi(phba, vport);
42744255 }
42754256
4276− lpfc_mbuf_free(phba, mp->virt, mp->phys);
4277− kfree(mp);
4278− mempool_free(pmb, phba->mbox_mem_pool);
4257+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
42794258
42804259 /* Drop the reference count from the mbox at the end after
42814260 * all the current reference to the ndlp have been done.
@@ -4369,12 +4348,10 @@ void · 87 unmodified lines
43694348 lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
43704349 {
43714350 MAILBOX_t *mb = &pmb->u.mb;
4372− struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);
43734351 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
43744352 struct lpfc_vport *vport = pmb->vport;
43754353 int rc;
43764354
4377− pmb->ctx_buf = NULL;
43784355 pmb->ctx_ndlp = NULL;
43794356 vport->gidft_inp = 0;
43804357
@@ -4388,9 +4365,7 @@ out: · 7 unmodified lines
43884365 * callback function.
43894366 */
43904367 lpfc_nlp_put(ndlp);
4391− lpfc_mbuf_free(phba, mp->virt, mp->phys);
4392− kfree(mp);
4393− mempool_free(pmb, phba->mbox_mem_pool);
4368+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
43944369
43954370 /* If the node is not registered with the scsi or nvme
43964371 * transport, remove the fabric node. The failed reg_login
@@ -4479,10 +4454,7 @@ out: · 82 unmodified lines
44794454 * callback function.
44804455 */
44814456 lpfc_nlp_put(ndlp);
4482− lpfc_mbuf_free(phba, mp->virt, mp->phys);
4483− kfree(mp);
4484− mempool_free(pmb, phba->mbox_mem_pool);
4485−
4457+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
44864458 return;
44874459 }
44884460
@@ -4496,13 +4468,9 @@ lpfc_mbx_cmpl_fc_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 7 unmodified lines
44964468 {
44974469 struct lpfc_vport *vport = pmb->vport;
44984470 MAILBOX_t *mb = &pmb->u.mb;
4499− struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);
4500− struct lpfc_nodelist *ndlp;
4471+ struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
45014472
4502− ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
45034473 pmb->ctx_ndlp = NULL;
4504− pmb->ctx_buf = NULL;
4505−
45064474 if (mb->mbxStatus) {
45074475 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
45084476 "0933 %s: Register FC login error: 0x%x\n",
@@ -4526,9 +4494,7 @@ lpfc_mbx_cmpl_fc_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 17 unmodified lines
45264494 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
45274495
45284496 out:
4529− lpfc_mbuf_free(phba, mp->virt, mp->phys);
4530− kfree(mp);
4531− mempool_free(pmb, phba->mbox_mem_pool);
4497+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
45324498
45334499 /* Drop the reference count from the mbox at the end after
45344500 * all the current reference to the ndlp have been done.
@@ -5155,7 +5121,7 @@ lpfc_check_sli_ndlp(struct lpfc_hba *phba, · 620 unmodified lines
51555121 if (pring->ringno == LPFC_ELS_RING) {
51565122 switch (ulp_command) {
51575123 case CMD_GEN_REQUEST64_CR:
5158− if (iocb->context_un.ndlp == ndlp)
5124+ if (iocb->ndlp == ndlp)
51595125 return 1;
51605126 fallthrough;
51615127 case CMD_ELS_REQUEST64_CR:
@@ -5163,7 +5129,7 @@ lpfc_check_sli_ndlp(struct lpfc_hba *phba, · 1 unmodified line
51635129 return 1;
51645130 fallthrough;
51655131 case CMD_XMIT_ELS_RSP64_CX:
5166− if (iocb->context1 == (uint8_t *) ndlp)
5132+ if (iocb->ndlp == ndlp)
51675133 return 1;
51685134 }
51695135 } else if (pring->ringno == LPFC_FCP_RING) {
@@ -5273,7 +5239,6 @@ lpfc_nlp_logo_unreg(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 103 unmodified lines
52735239 if (!ndlp)
52745240 return;
52755241 lpfc_issue_els_logo(vport, ndlp, 0);
5276− mempool_free(pmb, phba->mbox_mem_pool);
52775242
52785243 /* Check to see if there are any deferred events to process */
52795244 if ((ndlp->nlp_flag & NLP_UNREG_INP) &&
@@ -5300,6 +5265,13 @@ lpfc_nlp_logo_unreg(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 20 unmodified lines
53005265 ndlp->nlp_flag &= ~NLP_UNREG_INP;
53015266 spin_unlock_irq(&ndlp->lock);
53025267 }
5268+
5269+ /* The node has an outstanding reference for the unreg. Now
5270+ * that the LOGO action and cleanup are finished, release
5271+ * resources.
5272+ */
5273+ lpfc_nlp_put(ndlp);
5274+ mempool_free(pmb, phba->mbox_mem_pool);
53035275 }
53045276
53055277 /*
@@ -5569,7 +5541,6 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 263 unmodified lines
55695541 {
55705542 struct lpfc_hba *phba = vport->phba;
55715543 LPFC_MBOXQ_t *mb, *nextmb;
5572− struct lpfc_dmabuf *mp;
55735544
55745545 /* Cleanup node for NPort <nlp_DID> */
55755546 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
@@ -5607,16 +5578,11 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 31 unmodified lines
56075578 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
56085579 !(mb->mbox_flag & LPFC_MBX_IMED_UNREG) &&
56095580 (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {
5610− mp = (struct lpfc_dmabuf *)(mb->ctx_buf);
5611− if (mp) {
5612− __lpfc_mbuf_free(phba, mp->virt, mp->phys);
5613− kfree(mp);
5614− }
56155581 list_del(&mb->list);
5616− mempool_free(mb, phba->mbox_mem_pool);
5617− /* We shall not invoke the lpfc_nlp_put to decrement
5618− * the ndlp reference count as we are in the process
5619− * of lpfc_nlp_release.
5582+ lpfc_mbox_rsrc_cleanup(phba, mb, MBOX_THD_LOCKED);
5583+
5584+ /* Don't invoke lpfc_nlp_put. The driver is in
5585+ * lpfc_nlp_release context.
56205586 */
56215587 }
56225588 }
@@ -6098,7 +6064,7 @@ lpfc_free_tx(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) · 475 unmodified lines
60986064 */
60996065 spin_lock_irq(&phba->hbalock);
61006066 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
6101− if (iocb->context1 != ndlp)
6067+ if (iocb->ndlp != ndlp)
61026068 continue;
61036069
61046070 ulp_command = get_job_cmnd(phba, iocb);
@@ -6112,7 +6078,7 @@ lpfc_free_tx(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) · 7 unmodified lines
61126078
61136079 /* Next check the txcmplq */
61146080 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
6115− if (iocb->context1 != ndlp)
6081+ if (iocb->ndlp != ndlp)
61166082 continue;
61176083
61186084 ulp_command = get_job_cmnd(phba, iocb);
@@ -6390,8 +6356,9 @@ restart_disc: · 271 unmodified lines
63906356 lpfc_printf_vlog(vport, KERN_ERR,
63916357 LOG_TRACE_EVENT,
63926358 "0231 RSCN timeout Data: x%x "
6393− "x%x\n",
6394− vport->fc_ns_retry, LPFC_MAX_NS_RETRY);
6359+ "x%x x%x x%x\n",
6360+ vport->fc_ns_retry, LPFC_MAX_NS_RETRY,
6361+ vport->port_state, vport->gidft_inp);
63956362
63966363 /* Cleanup any outstanding ELS commands */
63976364 lpfc_els_flush_cmd(vport);
@@ -6461,11 +6428,9 @@ void · 63 unmodified lines
64616428 lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
64626429 {
64636430 MAILBOX_t *mb = &pmb->u.mb;
6464− struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);
64656431 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
64666432 struct lpfc_vport *vport = pmb->vport;
64676433
6468− pmb->ctx_buf = NULL;
64696434 pmb->ctx_ndlp = NULL;
64706435
64716436 if (phba->sli_rev < LPFC_SLI_REV4)
@@ -6496,10 +6461,7 @@ lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 24 unmodified lines
64966461 * function.
64976462 */
64986463 lpfc_nlp_put(ndlp);
6499− lpfc_mbuf_free(phba, mp->virt, mp->phys);
6500− kfree(mp);
6501− mempool_free(pmb, phba->mbox_mem_pool);
6502−
6464+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
65036465 return;
65046466 }
65056467
drivers/scsi/lpfc/lpfc_hw.h+44−31
@@ -97,6 +97,18 @@ union CtCommandResponse { · 96 unmodified lines
9797 #define FC4_FEATURE_INIT 0x2
9898 #define FC4_FEATURE_NVME_DISC 0x4
9999
100+enum rft_word0 {
101+ RFT_FCP_REG = (0x1 << 8),
102+};
103+
104+enum rft_word1 {
105+ RFT_NVME_REG = (0x1 << 8),
106+};
107+
108+enum rft_word3 {
109+ RFT_APP_SERV_REG = (0x1 << 0),
110+};
111+
100112 struct lpfc_sli_ct_request {
101113 /* Structure is in Big Endian format */
102114 union CtRevisionId RevisionId;
@@ -131,25 +143,13 @@ struct lpfc_sli_ct_request { · 28 unmodified lines
131143 uint8_t Fc4Type;
132144 } gid_ff;
133145 struct rft {
134− uint32_t PortId; /* For RFT_ID requests */
146+ __be32 port_id; /* For RFT_ID requests */
135147
136−#ifdef __BIG_ENDIAN_BITFIELD
137− uint32_t rsvd0:16;
138− uint32_t rsvd1:7;
139− uint32_t fcpReg:1; /* Type 8 */
140− uint32_t rsvd2:2;
141− uint32_t ipReg:1; /* Type 5 */
142− uint32_t rsvd3:5;
143−#else /* __LITTLE_ENDIAN_BITFIELD */
144− uint32_t rsvd0:16;
145− uint32_t fcpReg:1; /* Type 8 */
146− uint32_t rsvd1:7;
147− uint32_t rsvd3:5;
148− uint32_t ipReg:1; /* Type 5 */
149− uint32_t rsvd2:2;
150−#endif
151−
152− uint32_t rsvd[7];
148+ __be32 fcp_reg; /* rsvd 31:9, fcp_reg 8, rsvd 7:0 */
149+ __be32 nvme_reg; /* rsvd 31:9, nvme_reg 8, rsvd 7:0 */
150+ __be32 word2;
151+ __be32 app_serv_reg; /* rsvd 31:1, app_serv_reg 0 */
152+ __be32 word[4];
153153 } rft;
154154 struct rnn {
155155 uint32_t PortId; /* For RNN_ID requests */
@@ -511,8 +511,6 @@ struct class_parms { · 355 unmodified lines
511511 uint8_t word3Reserved2; /* Fc Word 3, bit 0: 7 */
512512 };
513513
514−#define FAPWWN_KEY_VENDOR 0x42524344 /*valid vendor version fawwpn key*/
515−
516514 struct serv_parm { /* Structure is in Big Endian format */
517515 struct csp cmn;
518516 struct lpfc_name portName;
@@ -2650,19 +2648,26 @@ typedef struct { · 2131 unmodified lines
26502648 } READ_SPARM_VAR;
26512649
26522650 /* Structure for MB Command READ_STATUS (14) */
2651+enum read_status_word1 {
2652+ RD_ST_CC = 0x01,
2653+ RD_ST_XKB = 0x80,
2654+};
2655+
2656+enum read_status_word17 {
2657+ RD_ST_XMIT_XKB_MASK = 0x3fffff,
2658+};
2659+
2660+enum read_status_word18 {
2661+ RD_ST_RCV_XKB_MASK = 0x3fffff,
2662+};
26532663
26542664 typedef struct {
2655−#ifdef __BIG_ENDIAN_BITFIELD
2656− uint32_t rsvd1:31;
2657− uint32_t clrCounters:1;
2658− uint16_t activeXriCnt;
2659− uint16_t activeRpiCnt;
2660−#else /* __LITTLE_ENDIAN_BITFIELD */
2661− uint32_t clrCounters:1;
2662− uint32_t rsvd1:31;
2663− uint16_t activeRpiCnt;
2664− uint16_t activeXriCnt;
2665−#endif
2665+ u8 clear_counters; /* rsvd 7:1, cc 0 */
2666+ u8 rsvd5;
2667+ u8 rsvd6;
2668+ u8 xkb; /* xkb 7, rsvd 6:0 */
2669+
2670+ u32 rsvd8;
26662671
26672672 uint32_t xmitByteCnt;
26682673 uint32_t rcvByteCnt;
@@ -2674,6 +2679,14 @@ typedef struct { · 5 unmodified lines
26742679 uint32_t totalRespExchanges;
26752680 uint32_t rcvPbsyCnt;
26762681 uint32_t rcvFbsyCnt;
2682+
2683+ u32 drop_frame_no_rq;
2684+ u32 empty_rq;
2685+ u32 drop_frame_no_xri;
2686+ u32 empty_xri;
2687+
2688+ u32 xmit_xkb; /* rsvd 31:22, xmit_xkb 21:0 */
2689+ u32 rcv_xkb; /* rsvd 31:22, rcv_xkb 21:0 */
26772690 } READ_STATUS_VAR;
26782691
26792692 /* Structure for MB Command READ_RPI (15) */
drivers/scsi/lpfc/lpfc_hw4.h+12−5
@@ -2893,6 +2893,9 @@ struct lpfc_mbx_read_config { · 2892 unmodified lines
28932893 #define lpfc_mbx_rd_conf_extnts_inuse_SHIFT 31
28942894 #define lpfc_mbx_rd_conf_extnts_inuse_MASK 0x00000001
28952895 #define lpfc_mbx_rd_conf_extnts_inuse_WORD word1
2896+#define lpfc_mbx_rd_conf_fawwpn_SHIFT 30
2897+#define lpfc_mbx_rd_conf_fawwpn_MASK 0x00000001
2898+#define lpfc_mbx_rd_conf_fawwpn_WORD word1
28962899 #define lpfc_mbx_rd_conf_wcs_SHIFT 28 /* warning signaling */
28972900 #define lpfc_mbx_rd_conf_wcs_MASK 0x00000001
28982901 #define lpfc_mbx_rd_conf_wcs_WORD word1
@@ -4473,12 +4476,8 @@ struct wqe_common { · 1574 unmodified lines
44734476 #define wqe_cmd_type_MASK 0x0000000f
44744477 #define wqe_cmd_type_WORD word11
44754478 #define wqe_els_id_SHIFT 4
4476−#define wqe_els_id_MASK 0x00000003
4479+#define wqe_els_id_MASK 0x00000007
44774480 #define wqe_els_id_WORD word11
4478−#define LPFC_ELS_ID_FLOGI 3
4479−#define LPFC_ELS_ID_FDISC 2
4480−#define LPFC_ELS_ID_LOGO 1
4481−#define LPFC_ELS_ID_DEFAULT 0
44824481 #define wqe_irsp_SHIFT 4
44834482 #define wqe_irsp_MASK 0x00000001
44844483 #define wqe_irsp_WORD word11
@@ -4525,6 +4524,14 @@ struct lpfc_wqe_generic{ · 40 unmodified lines
45254524 uint32_t payload[4];
45264525 };
45274526
4527+enum els_request64_wqe_word11 {
4528+ LPFC_ELS_ID_DEFAULT,
4529+ LPFC_ELS_ID_LOGO,
4530+ LPFC_ELS_ID_FDISC,
4531+ LPFC_ELS_ID_FLOGI,
4532+ LPFC_ELS_ID_PLOGI,
4533+};
4534+
45284535 struct els_request64_wqe {
45294536 struct ulp_bde64 bde;
45304537 uint32_t payload_len;
drivers/scsi/lpfc/lpfc_init.c+131−143
@@ -350,8 +350,7 @@ lpfc_dump_wakeup_param_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq) · 349 unmodified lines
350350 void
351351 lpfc_update_vport_wwn(struct lpfc_vport *vport)
352352 {
353− uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level;
354− u32 *fawwpn_key = (u32 *)&vport->fc_sparam.un.vendorVersion[0];
353+ struct lpfc_hba *phba = vport->phba;
355354
356355 /*
357356 * If the name is empty or there exists a soft name
@@ -370,21 +369,32 @@ lpfc_update_vport_wwn(struct lpfc_vport *vport) · 12 unmodified lines
370369 */
371370 if (vport->fc_portname.u.wwn[0] != 0 &&
372371 memcmp(&vport->fc_portname, &vport->fc_sparam.portName,
373− sizeof(struct lpfc_name)))
372+ sizeof(struct lpfc_name))) {
374373 vport->vport_flag |= FAWWPN_PARAM_CHG;
375374
376− if (vport->fc_portname.u.wwn[0] == 0 ||
377− (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR) ||
378− vport->vport_flag & FAWWPN_SET) {
379− memcpy(&vport->fc_portname, &vport->fc_sparam.portName,
380− sizeof(struct lpfc_name));
381− vport->vport_flag &= ~FAWWPN_SET;
382− if (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR)
383− vport->vport_flag |= FAWWPN_SET;
375+ if (phba->sli_rev == LPFC_SLI_REV4 &&
376+ vport->port_type == LPFC_PHYSICAL_PORT &&
377+ phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_FABRIC) {
378+ lpfc_printf_log(phba, KERN_INFO,
379+ LOG_SLI | LOG_DISCOVERY | LOG_ELS,
380+ "2701 FA-PWWN change WWPN from %llx to "
381+ "%llx: vflag x%x fawwpn_flag x%x\n",
382+ wwn_to_u64(vport->fc_portname.u.wwn),
383+ wwn_to_u64
384+ (vport->fc_sparam.portName.u.wwn),
385+ vport->vport_flag,
386+ phba->sli4_hba.fawwpn_flag);
387+ memcpy(&vport->fc_portname, &vport->fc_sparam.portName,
388+ sizeof(struct lpfc_name));
389+ }
384390 }
391+
392+ if (vport->fc_portname.u.wwn[0] == 0)
393+ memcpy(&vport->fc_portname, &vport->fc_sparam.portName,
394+ sizeof(struct lpfc_name));
385395 else
386396 memcpy(&vport->fc_sparam.portName, &vport->fc_portname,
387− sizeof(struct lpfc_name));
397+ sizeof(struct lpfc_name));
388398 }
389399
390400 /**
@@ -443,15 +453,16 @@ lpfc_config_port_post(struct lpfc_hba *phba) · 52 unmodified lines
443453 "READ_SPARM mbxStatus x%x\n",
444454 mb->mbxCommand, mb->mbxStatus);
445455 phba->link_state = LPFC_HBA_ERROR;
446− mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
447− mempool_free(pmb, phba->mbox_mem_pool);
448− lpfc_mbuf_free(phba, mp->virt, mp->phys);
449− kfree(mp);
456+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
450457 return -EIO;
451458 }
452459
453460 mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
454461
462+ /* This dmabuf was allocated by lpfc_read_sparam. The dmabuf is no
463+ * longer needed. Prevent unintended ctx_buf access as the mbox is
464+ * reused.
465+ */
455466 memcpy(&vport->fc_sparam, mp->virt, sizeof (struct serv_parm));
456467 lpfc_mbuf_free(phba, mp->virt, mp->phys);
457468 kfree(mp);
@@ -686,8 +697,14 @@ lpfc_sli4_refresh_params(struct lpfc_hba *phba) · 228 unmodified lines
686697 return rc;
687698 }
688699 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters;
689− phba->sli4_hba.pc_sli4_params.mi_ver =
700+
701+ /* Are we forcing MI off via module parameter? */
702+ if (phba->cfg_enable_mi)
703+ phba->sli4_hba.pc_sli4_params.mi_ver =
690704 bf_get(cfg_mi_ver, mbx_sli4_parameters);
705+ else
706+ phba->sli4_hba.pc_sli4_params.mi_ver = 0;
707+
691708 phba->sli4_hba.pc_sli4_params.cmf =
692709 bf_get(cfg_cmf, mbx_sli4_parameters);
693710 phba->sli4_hba.pc_sli4_params.pls =
@@ -2176,7 +2193,6 @@ lpfc_handle_latt(struct lpfc_hba *phba) · 1482 unmodified lines
21762193 struct lpfc_sli *psli = &phba->sli;
21772194 LPFC_MBOXQ_t *pmb;
21782195 volatile uint32_t control;
2179− struct lpfc_dmabuf *mp;
21802196 int rc = 0;
21812197
21822198 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
@@ -2185,23 +2201,17 @@ lpfc_handle_latt(struct lpfc_hba *phba) · 2 unmodified lines
21852201 goto lpfc_handle_latt_err_exit;
21862202 }
21872203
2188− mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
2189− if (!mp) {
2204+ rc = lpfc_mbox_rsrc_prep(phba, pmb);
2205+ if (rc) {
21902206 rc = 2;
2191− goto lpfc_handle_latt_free_pmb;
2192− }
2193−
2194− mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
2195− if (!mp->virt) {
2196− rc = 3;
2197− goto lpfc_handle_latt_free_mp;
2207+ mempool_free(pmb, phba->mbox_mem_pool);
2208+ goto lpfc_handle_latt_err_exit;
21982209 }
21992210
22002211 /* Cleanup any outstanding ELS commands */
22012212 lpfc_els_flush_all_cmd(phba);
2202−
22032213 psli->slistat.link_event++;
2204− lpfc_read_topology(phba, pmb, mp);
2214+ lpfc_read_topology(phba, pmb, (struct lpfc_dmabuf *)pmb->ctx_buf);
22052215 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology;
22062216 pmb->vport = vport;
22072217 /* Block ELS IOCBs until we have processed this mbox command */
@@ -2222,11 +2232,7 @@ lpfc_handle_latt(struct lpfc_hba *phba) · 14 unmodified lines
22222232
22232233 lpfc_handle_latt_free_mbuf:
22242234 phba->sli.sli3_ring[LPFC_ELS_RING].flag &= ~LPFC_STOP_IOCB_EVENT;
2225− lpfc_mbuf_free(phba, mp->virt, mp->phys);
2226−lpfc_handle_latt_free_mp:
2227− kfree(mp);
2228−lpfc_handle_latt_free_pmb:
2229− mempool_free(pmb, phba->mbox_mem_pool);
2235+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
22302236 lpfc_handle_latt_err_exit:
22312237 /* Enable Link attention interrupts */
22322238 spin_lock_irq(&phba->hbalock);
@@ -4317,9 +4323,10 @@ lpfc_sli4_io_sgl_update(struct lpfc_hba *phba) · 2084 unmodified lines
43174323
43184324 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
43194325 "6074 Current allocated XRI sgl count:%d, "
4320− "maximum XRI count:%d\n",
4326+ "maximum XRI count:%d els_xri_cnt:%d\n\n",
43214327 phba->sli4_hba.io_xri_cnt,
4322− phba->sli4_hba.io_xri_max);
4328+ phba->sli4_hba.io_xri_max,
4329+ els_xri_cnt);
43234330
43244331 cnt = lpfc_io_buf_flush(phba, &io_sgl_list);
43254332
@@ -4458,12 +4465,11 @@ lpfc_new_io_buf(struct lpfc_hba *phba, int num_to_alloc) · 132 unmodified lines
44584465 }
44594466 pwqeq->sli4_lxritag = lxri;
44604467 pwqeq->sli4_xritag = phba->sli4_hba.xri_ids[lxri];
4461− pwqeq->context1 = lpfc_ncmd;
44624468
44634469 /* Initialize local short-hand pointers. */
44644470 lpfc_ncmd->dma_sgl = lpfc_ncmd->data;
44654471 lpfc_ncmd->dma_phys_sgl = lpfc_ncmd->dma_handle;
4466− lpfc_ncmd->cur_iocbq.context1 = lpfc_ncmd;
4472+ lpfc_ncmd->cur_iocbq.io_buf = lpfc_ncmd;
44674473 spin_lock_init(&lpfc_ncmd->buf_lock);
44684474
44694475 /* add the nvme buffer to a post list */
@@ -4472,7 +4478,9 @@ lpfc_new_io_buf(struct lpfc_hba *phba, int num_to_alloc) · 2 unmodified lines
44724478 }
44734479 lpfc_printf_log(phba, KERN_INFO, LOG_NVME,
44744480 "6114 Allocate %d out of %d requested new NVME "
4475− "buffers\n", bcnt, num_to_alloc);
4481+ "buffers of size x%zu bytes\n", bcnt, num_to_alloc,
4482+ sizeof(*lpfc_ncmd));
4483+
44764484
44774485 /* post the list of nvme buffer sgls to port if available */
44784486 if (!list_empty(&post_nblist))
@@ -5307,7 +5315,6 @@ static void · 828 unmodified lines
53075315 lpfc_sli4_async_link_evt(struct lpfc_hba *phba,
53085316 struct lpfc_acqe_link *acqe_link)
53095317 {
5310− struct lpfc_dmabuf *mp;
53115318 LPFC_MBOXQ_t *pmb;
53125319 MAILBOX_t *mb;
53135320 struct lpfc_mbx_read_top *la;
@@ -5324,18 +5331,13 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, · 10 unmodified lines
53245331 "0395 The mboxq allocation failed\n");
53255332 return;
53265333 }
5327− mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
5328− if (!mp) {
5334+
5335+ rc = lpfc_mbox_rsrc_prep(phba, pmb);
5336+ if (rc) {
53295337 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
5330− "0396 The lpfc_dmabuf allocation failed\n");
5338+ "0396 mailbox allocation failed\n");
53315339 goto out_free_pmb;
53325340 }
5333− mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
5334− if (!mp->virt) {
5335− lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
5336− "0397 The mbuf allocation failed\n");
5337− goto out_free_dmabuf;
5338− }
53395341
53405342 /* Cleanup any outstanding ELS commands */
53415343 lpfc_els_flush_all_cmd(phba);
@@ -5347,7 +5349,7 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, · 5 unmodified lines
53475349 phba->sli.slistat.link_event++;
53485350
53495351 /* Create lpfc_handle_latt mailbox command from link ACQE */
5350− lpfc_read_topology(phba, pmb, mp);
5352+ lpfc_read_topology(phba, pmb, (struct lpfc_dmabuf *)pmb->ctx_buf);
53515353 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology;
53525354 pmb->vport = phba->pport;
53535355
@@ -5385,10 +5387,8 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, · 31 unmodified lines
53855387 */
53865388 if (!(phba->hba_flag & HBA_FCOE_MODE)) {
53875389 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
5388− if (rc == MBX_NOT_FINISHED) {
5389− lpfc_mbuf_free(phba, mp->virt, mp->phys);
5390− goto out_free_dmabuf;
5391− }
5390+ if (rc == MBX_NOT_FINISHED)
5391+ goto out_free_pmb;
53925392 return;
53935393 }
53945394 /*
@@ -5423,10 +5423,8 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, · 28 unmodified lines
54235423
54245424 return;
54255425
5426−out_free_dmabuf:
5427− kfree(mp);
54285426 out_free_pmb:
5429− mempool_free(pmb, phba->mbox_mem_pool);
5427+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
54305428 }
54315429
54325430 /**
@@ -5533,7 +5531,7 @@ lpfc_cgn_update_stat(struct lpfc_hba *phba, uint32_t dtag) · 100 unmodified lines
55335531 struct tm broken;
55345532 struct timespec64 cur_time;
55355533 u32 cnt;
5536− u16 value;
5534+ u32 value;
55375535
55385536 /* Make sure we have a congestion info buffer */
55395537 if (!phba->cgn_i)
@@ -5866,21 +5864,8 @@ lpfc_cgn_save_evt_cnt(struct lpfc_hba *phba) · 326 unmodified lines
58665864
58675865 /* Use the frequency found in the last rcv'ed FPIN */
58685866 value = phba->cgn_fpin_frequency;
5869− if (phba->cgn_reg_fpin & LPFC_CGN_FPIN_WARN)
5870− cp->cgn_warn_freq = cpu_to_le16(value);
5871− if (phba->cgn_reg_fpin & LPFC_CGN_FPIN_ALARM)
5872− cp->cgn_alarm_freq = cpu_to_le16(value);
5873−
5874− /* Frequency (in ms) Signal Warning/Signal Congestion Notifications
5875− * are received by the HBA
5876− */
5877− value = phba->cgn_sig_freq;
5878−
5879− if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY ||
5880− phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM)
5881− cp->cgn_warn_freq = cpu_to_le16(value);
5882− if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM)
5883− cp->cgn_alarm_freq = cpu_to_le16(value);
5867+ cp->cgn_warn_freq = cpu_to_le16(value);
5868+ cp->cgn_alarm_freq = cpu_to_le16(value);
58845869
58855870 lvalue = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ,
58865871 LPFC_CGN_CRC32_SEED);
@@ -6237,7 +6222,6 @@ lpfc_update_trunk_link_status(struct lpfc_hba *phba, · 350 unmodified lines
62376222 static void
62386223 lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc)
62396224 {
6240− struct lpfc_dmabuf *mp;
62416225 LPFC_MBOXQ_t *pmb;
62426226 MAILBOX_t *mb;
62436227 struct lpfc_mbx_read_top *la;
@@ -6297,18 +6281,12 @@ lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc) · 53 unmodified lines
62976281 "2897 The mboxq allocation failed\n");
62986282 return;
62996283 }
6300− mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
6301− if (!mp) {
6284+ rc = lpfc_mbox_rsrc_prep(phba, pmb);
6285+ if (rc) {
63026286 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
6303− "2898 The lpfc_dmabuf allocation failed\n");
6287+ "2898 The mboxq prep failed\n");
63046288 goto out_free_pmb;
63056289 }
6306− mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
6307− if (!mp->virt) {
6308− lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
6309− "2899 The mbuf allocation failed\n");
6310− goto out_free_dmabuf;
6311− }
63126290
63136291 /* Cleanup any outstanding ELS commands */
63146292 lpfc_els_flush_all_cmd(phba);
@@ -6320,7 +6298,7 @@ lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc) · 5 unmodified lines
63206298 phba->sli.slistat.link_event++;
63216299
63226300 /* Create lpfc_handle_latt mailbox command from link ACQE */
6323− lpfc_read_topology(phba, pmb, mp);
6301+ lpfc_read_topology(phba, pmb, (struct lpfc_dmabuf *)pmb->ctx_buf);
63246302 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology;
63256303 pmb->vport = phba->pport;
63266304
@@ -6364,16 +6342,12 @@ lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc) · 37 unmodified lines
63646342 }
63656343
63666344 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
6367− if (rc == MBX_NOT_FINISHED) {
6368− lpfc_mbuf_free(phba, mp->virt, mp->phys);
6369− goto out_free_dmabuf;
6370− }
6345+ if (rc == MBX_NOT_FINISHED)
6346+ goto out_free_pmb;
63716347 return;
63726348
6373−out_free_dmabuf:
6374− kfree(mp);
63756349 out_free_pmb:
6376− mempool_free(pmb, phba->mbox_mem_pool);
6350+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
63776351 }
63786352
63796353 /**
@@ -6565,12 +6539,15 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli) · 185 unmodified lines
65656539 case LPFC_SLI_EVENT_TYPE_MISCONF_FAWWN:
65666540 /* Misconfigured WWN. Reports that the SLI Port is configured
65676541 * to use FA-WWN, but the attached device doesn’t support it.
6568− * No driver action is required.
65696542 * Event Data1 - N.A, Event Data2 - N.A
6543+ * This event only happens on the physical port.
65706544 */
6571− lpfc_log_msg(phba, KERN_WARNING, LOG_SLI,
6572− "2699 Misconfigured FA-WWN - Attached device does "
6573− "not support FA-WWN\n");
6545+ lpfc_log_msg(phba, KERN_WARNING, LOG_SLI | LOG_DISCOVERY,
6546+ "2699 Misconfigured FA-PWWN - Attached device "
6547+ "does not support FA-PWWN\n");
6548+ phba->sli4_hba.fawwpn_flag &= ~LPFC_FAWWPN_FABRIC;
6549+ memset(phba->pport->fc_portname.u.wwn, 0,
6550+ sizeof(struct lpfc_name));
65746551 break;
65756552 case LPFC_SLI_EVENT_TYPE_EEPROM_FAILURE:
65766553 /* EEPROM failure. No driver action is required */
@@ -6595,9 +6572,6 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli) · 18 unmodified lines
65956572 /* Alarm overrides warning, so check that first */
65966573 if (cgn_signal->alarm_cnt) {
65976574 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) {
6598− /* Keep track of alarm cnt for cgn_info */
6599− atomic_add(cgn_signal->alarm_cnt,
6600− &phba->cgn_fabric_alarm_cnt);
66016575 /* Keep track of alarm cnt for CMF_SYNC_WQE */
66026576 atomic_add(cgn_signal->alarm_cnt,
66036577 &phba->cgn_sync_alarm_cnt);
@@ -6606,8 +6580,6 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli) · 2 unmodified lines
66066580 /* signal action needs to be taken */
66076581 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY ||
66086582 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) {
6609− /* Keep track of warning cnt for cgn_info */
6610− atomic_add(cnt, &phba->cgn_fabric_warn_cnt);
66116583 /* Keep track of warning cnt for CMF_SYNC_WQE */
66126584 atomic_add(cnt, &phba->cgn_sync_warn_cnt);
66136585 }
@@ -8027,6 +7999,18 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) · 1413 unmodified lines
80277999 rc = lpfc_sli4_read_config(phba);
80288000 if (unlikely(rc))
80298001 goto out_free_bsmbx;
8002+
8003+ if (phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG) {
8004+ /* Right now the link is down, if FA-PWWN is configured the
8005+ * firmware will try FLOGI before the driver gets a link up.
8006+ * If it fails, the driver should get a MISCONFIGURED async
8007+ * event which will clear this flag. The only notification
8008+ * the driver gets is if it fails, if it succeeds there is no
8009+ * notification given. Assume success.
8010+ */
8011+ phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_FABRIC;
8012+ }
8013+
80308014 rc = lpfc_mem_alloc_active_rrq_pool_s4(phba);
80318015 if (unlikely(rc))
80328016 goto out_free_bsmbx;
@@ -9000,6 +8984,36 @@ lpfc_hba_free(struct lpfc_hba *phba) · 967 unmodified lines
90008984 return;
90018985 }
90028986
8987+/**
8988+ * lpfc_setup_fdmi_mask - Setup initial FDMI mask for HBA and Port attributes
8989+ * @vport: pointer to lpfc vport data structure.
8990+ *
8991+ * This routine is will setup initial FDMI attribute masks for
8992+ * FDMI2 or SmartSAN depending on module parameters. The driver will attempt
8993+ * to get these attributes first before falling back, the attribute
8994+ * fallback hierarchy is SmartSAN -> FDMI2 -> FMDI1
8995+ **/
8996+void
8997+lpfc_setup_fdmi_mask(struct lpfc_vport *vport)
8998+{
8999+ struct lpfc_hba *phba = vport->phba;
9000+
9001+ vport->load_flag |= FC_ALLOW_FDMI;
9002+ if (phba->cfg_enable_SmartSAN ||
9003+ phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT) {
9004+ /* Setup appropriate attribute masks */
9005+ vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR;
9006+ if (phba->cfg_enable_SmartSAN)
9007+ vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR;
9008+ else
9009+ vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR;
9010+ }
9011+
9012+ lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY,
9013+ "6077 Setup FDMI mask: hba x%x port x%x\n",
9014+ vport->fdmi_hba_mask, vport->fdmi_port_mask);
9015+}
9016+
90039017 /**
90049018 * lpfc_create_shost - Create hba physical port with associated scsi host.
90059019 * @phba: pointer to lpfc hba data structure.
@@ -9043,21 +9057,12 @@ lpfc_create_shost(struct lpfc_hba *phba) · 37 unmodified lines
90439057 /* Put reference to SCSI host to driver's device private data */
90449058 pci_set_drvdata(phba->pcidev, shost);
90459059
9060+ lpfc_setup_fdmi_mask(vport);
9061+
90469062 /*
90479063 * At this point we are fully registered with PSA. In addition,
90489064 * any initial discovery should be completed.
90499065 */
9050− vport->load_flag |= FC_ALLOW_FDMI;
9051− if (phba->cfg_enable_SmartSAN ||
9052− (phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT)) {
9053−
9054− /* Setup appropriate attribute masks */
9055− vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR;
9056− if (phba->cfg_enable_SmartSAN)
9057− vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR;
9058− else
9059− vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR;
9060− }
90619066 return 0;
90629067 }
90639068
@@ -9830,7 +9835,7 @@ lpfc_sli4_read_config(struct lpfc_hba *phba) · 766 unmodified lines
98309835 struct lpfc_rsrc_desc_fcfcoe *desc;
98319836 char *pdesc_0;
98329837 uint16_t forced_link_speed;
9833− uint32_t if_type, qmin;
9838+ uint32_t if_type, qmin, fawwpn;
98349839 int length, i, rc = 0, rc2;
98359840
98369841 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
@@ -9872,10 +9877,23 @@ lpfc_sli4_read_config(struct lpfc_hba *phba) · 35 unmodified lines
98729877 phba->sli4_hba.bbscn_params.word0 = rd_config->word8;
98739878 }
98749879
9880+ fawwpn = bf_get(lpfc_mbx_rd_conf_fawwpn, rd_config);
9881+
9882+ if (fawwpn) {
9883+ lpfc_printf_log(phba, KERN_INFO,
9884+ LOG_INIT | LOG_DISCOVERY,
9885+ "2702 READ_CONFIG: FA-PWWN is "
9886+ "configured on\n");
9887+ phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_CONFIG;
9888+ } else {
9889+ phba->sli4_hba.fawwpn_flag = 0;
9890+ }
9891+
98759892 phba->sli4_hba.conf_trunk =
98769893 bf_get(lpfc_mbx_rd_conf_trunk, rd_config);
98779894 phba->sli4_hba.extents_in_use =
98789895 bf_get(lpfc_mbx_rd_conf_extnts_inuse, rd_config);
9896+
98799897 phba->sli4_hba.max_cfg_param.max_xri =
98809898 bf_get(lpfc_mbx_rd_conf_xri_count, rd_config);
98819899 /* Reduce resource usage in kdump environment */
@@ -14832,9 +14850,6 @@ lpfc_pci_probe_one_s4(struct pci_dev *pdev, const struct pci_device_id *pid) · 4950 unmodified lines
1483214850 /* Check if there are static vports to be created. */
1483314851 lpfc_create_static_vport(phba);
1483414852
14835− /* Enable RAS FW log support */
14836− lpfc_sli4_ras_setup(phba);
14837−
1483814853 timer_setup(&phba->cpuhp_poll_timer, lpfc_sli4_poll_hbtimer, 0);
1483914854 cpuhp_state_add_instance_nocalls(lpfc_cpuhp_state, &phba->cpuhp);
1484014855
@@ -15700,34 +15715,7 @@ void lpfc_dmp_dbg(struct lpfc_hba *phba) · 859 unmodified lines
1570015715 unsigned int temp_idx;
1570115716 int i;
1570215717 int j = 0;
15703− unsigned long rem_nsec, iflags;
15704− bool log_verbose = false;
15705− struct lpfc_vport *port_iterator;
15706−
15707− /* Don't dump messages if we explicitly set log_verbose for the
15708− * physical port or any vport.
15709− */
15710− if (phba->cfg_log_verbose)
15711− return;
15712−
15713− spin_lock_irqsave(&phba->port_list_lock, iflags);
15714− list_for_each_entry(port_iterator, &phba->port_list, listentry) {
15715− if (port_iterator->load_flag & FC_UNLOADING)
15716− continue;
15717− if (scsi_host_get(lpfc_shost_from_vport(port_iterator))) {
15718− if (port_iterator->cfg_log_verbose)
15719− log_verbose = true;
15720−
15721− scsi_host_put(lpfc_shost_from_vport(port_iterator));
15722−
15723− if (log_verbose) {
15724− spin_unlock_irqrestore(&phba->port_list_lock,
15725− iflags);
15726− return;
15727− }
15728− }
15729− }
15730− spin_unlock_irqrestore(&phba->port_list_lock, iflags);
15718+ unsigned long rem_nsec;
1573115719
1573215720 if (atomic_cmpxchg(&phba->dbg_log_dmping, 0, 1) != 0)
1573315721 return;
drivers/scsi/lpfc/lpfc_logmsg.h+4−4
@@ -1,7 +1,7 @@
11 /*******************************************************************
22 * This file is part of the Emulex Linux Device Driver for *
33 * Fibre Channel Host Bus Adapters. *
4− * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term *
4+ * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
55 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
66 * Copyright (C) 2004-2009 Emulex. All rights reserved. *
77 * EMULEX and SLI are trademarks of Emulex. *
@@ -73,7 +73,7 @@ do { \ · 65 unmodified lines
7373 #define lpfc_printf_vlog(vport, level, mask, fmt, arg...) \
7474 do { \
7575 { if (((mask) & (vport)->cfg_log_verbose) || (level[1] <= '3')) { \
76− if ((mask) & LOG_TRACE_EVENT) \
76+ if ((mask) & LOG_TRACE_EVENT && !(vport)->cfg_log_verbose) \
7777 lpfc_dmp_dbg((vport)->phba); \
7878 dev_printk(level, &((vport)->phba->pcidev)->dev, "%d:(%d):" \
7979 fmt, (vport)->phba->brd_no, vport->vpi, ##arg); \
@@ -89,11 +89,11 @@ do { \ · 9 unmodified lines
8989 (phba)->pport->cfg_log_verbose : \
9090 (phba)->cfg_log_verbose; \
9191 if (((mask) & log_verbose) || (level[1] <= '3')) { \
92− if ((mask) & LOG_TRACE_EVENT) \
92+ if ((mask) & LOG_TRACE_EVENT && !log_verbose) \
9393 lpfc_dmp_dbg(phba); \
9494 dev_printk(level, &((phba)->pcidev)->dev, "%d:" \
9595 fmt, phba->brd_no, ##arg); \
96− } else if (!(phba)->cfg_log_verbose)\
96+ } else if (!log_verbose)\
9797 lpfc_dbg_print(phba, "%d:" fmt, phba->brd_no, ##arg); \
9898 } \
9999 } while (0)
drivers/scsi/lpfc/lpfc_mbox.c+120−83
@@ -1,7 +1,7 @@
11 /*******************************************************************
22 * This file is part of the Emulex Linux Device Driver for *
33 * Fibre Channel Host Bus Adapters. *
4− * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term *
4+ * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
55 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
66 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
77 * EMULEX and SLI are trademarks of Emulex. *
@@ -43,6 +43,80 @@ · 35 unmodified lines
4343 #include "lpfc_crtn.h"
4444 #include "lpfc_compat.h"
4545
46+/**
47+ * lpfc_mbox_rsrc_prep - Prepare a mailbox with DMA buffer memory.
48+ * @phba: pointer to lpfc hba data structure.
49+ * @mbox: pointer to the driver internal queue element for mailbox command.
50+ *
51+ * A mailbox command consists of the pool memory for the command, @mbox, and
52+ * one or more DMA buffers for the data transfer. This routine provides
53+ * a standard framework for allocating the dma buffer and assigning to the
54+ * @mbox. Callers should cleanup the mbox with a call to
55+ * lpfc_mbox_rsrc_cleanup.
56+ *
57+ * The lpfc_mbuf_alloc routine acquires the hbalock so the caller is
58+ * responsible to ensure the hbalock is released. Also note that the
59+ * driver design is a single dmabuf/mbuf per mbox in the ctx_buf.
60+ *
61+ **/
62+int
63+lpfc_mbox_rsrc_prep(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox)
64+{
65+ struct lpfc_dmabuf *mp;
66+
67+ mp = kmalloc(sizeof(*mp), GFP_KERNEL);
68+ if (!mp)
69+ return -ENOMEM;
70+
71+ mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
72+ if (!mp->virt) {
73+ kfree(mp);
74+ return -ENOMEM;
75+ }
76+
77+ memset(mp->virt, 0, LPFC_BPL_SIZE);
78+
79+ /* Initialization only. Driver does not use a list of dmabufs. */
80+ INIT_LIST_HEAD(&mp->list);
81+ mbox->ctx_buf = mp;
82+ return 0;
83+}
84+
85+/**
86+ * lpfc_mbox_rsrc_cleanup - Free the mailbox DMA buffer and virtual memory.
87+ * @phba: pointer to lpfc hba data structure.
88+ * @mbox: pointer to the driver internal queue element for mailbox command.
89+ * @locked: value that indicates if the hbalock is held (1) or not (0).
90+ *
91+ * A mailbox command consists of the pool memory for the command, @mbox, and
92+ * possibly a DMA buffer for the data transfer. This routine provides
93+ * a standard framework for releasing any dma buffers and freeing all
94+ * memory resources in it as well as releasing the @mbox back to the @phba pool.
95+ * Callers should use this routine for cleanup for all mailboxes prepped with
96+ * lpfc_mbox_rsrc_prep.
97+ *
98+ **/
99+void
100+lpfc_mbox_rsrc_cleanup(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox,
101+ enum lpfc_mbox_ctx locked)
102+{
103+ struct lpfc_dmabuf *mp;
104+
105+ mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
106+ mbox->ctx_buf = NULL;
107+
108+ /* Release the generic BPL buffer memory. */
109+ if (mp) {
110+ if (locked == MBOX_THD_LOCKED)
111+ __lpfc_mbuf_free(phba, mp->virt, mp->phys);
112+ else
113+ lpfc_mbuf_free(phba, mp->virt, mp->phys);
114+ kfree(mp);
115+ }
116+
117+ mempool_free(mbox, phba->mbox_mem_pool);
118+}
119+
46120 /**
47121 * lpfc_dump_static_vport - Dump HBA's static vport information.
48122 * @phba: pointer to lpfc hba data structure.
@@ -61,6 +135,7 @@ lpfc_dump_static_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, · 12 unmodified lines
61135 {
62136 MAILBOX_t *mb;
63137 struct lpfc_dmabuf *mp;
138+ int rc;
64139
65140 mb = &pmb->u.mb;
66141
@@ -79,22 +154,15 @@ lpfc_dump_static_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, · 12 unmodified lines
79154 return 0;
80155 }
81156
82− /* For SLI4 HBAs driver need to allocate memory */
83− mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
84− if (mp)
85− mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
86−
87− if (!mp || !mp->virt) {
88− kfree(mp);
157+ rc = lpfc_mbox_rsrc_prep(phba, pmb);
158+ if (rc) {
89159 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX,
90− "2605 lpfc_dump_static_vport: memory"
91− " allocation failed\n");
160+ "2605 %s: memory allocation failed\n",
161+ __func__);
92162 return 1;
93163 }
94− memset(mp->virt, 0, LPFC_BPL_SIZE);
95− INIT_LIST_HEAD(&mp->list);
96− /* save address for completion */
97− pmb->ctx_buf = (uint8_t *)mp;
164+
165+ mp = pmb->ctx_buf;
98166 mb->un.varWords[3] = putPaddrLow(mp->phys);
99167 mb->un.varWords[4] = putPaddrHigh(mp->phys);
100168 mb->un.varDmp.sli4_length = sizeof(struct static_vport_info);
@@ -606,26 +674,21 @@ lpfc_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, int vpi) · 505 unmodified lines
606674 {
607675 struct lpfc_dmabuf *mp;
608676 MAILBOX_t *mb;
677+ int rc;
609678
610− mb = &pmb->u.mb;
611679 memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
612680
613− mb->mbxOwner = OWN_HOST;
614−
615681 /* Get a buffer to hold the HBAs Service Parameters */
616−
617− mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL);
618− if (mp)
619− mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
620− if (!mp || !mp->virt) {
621− kfree(mp);
622− mb->mbxCommand = MBX_READ_SPARM64;
623− /* READ_SPARAM: no buffers */
682+ rc = lpfc_mbox_rsrc_prep(phba, pmb);
683+ if (rc) {
624684 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
625685 "0301 READ_SPARAM: no buffers\n");
626− return (1);
686+ return 1;
627687 }
628− INIT_LIST_HEAD(&mp->list);
688+
689+ mp = pmb->ctx_buf;
690+ mb = &pmb->u.mb;
691+ mb->mbxOwner = OWN_HOST;
629692 mb->mbxCommand = MBX_READ_SPARM64;
630693 mb->un.varRdSparm.un.sp64.tus.f.bdeSize = sizeof (struct serv_parm);
631694 mb->un.varRdSparm.un.sp64.addrHigh = putPaddrHigh(mp->phys);
@@ -633,9 +696,6 @@ lpfc_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, int vpi) · 1 unmodified line
633696 if (phba->sli_rev >= LPFC_SLI_REV3)
634697 mb->un.varRdSparm.vpi = phba->vpi_ids[vpi];
635698
636− /* save address for completion */
637− pmb->ctx_buf = mp;
638−
639699 return (0);
640700 }
641701
@@ -756,6 +816,7 @@ lpfc_reg_rpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, · 114 unmodified lines
756816 MAILBOX_t *mb = &pmb->u.mb;
757817 uint8_t *sparam;
758818 struct lpfc_dmabuf *mp;
819+ int rc;
759820
760821 memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
761822
@@ -766,12 +827,10 @@ lpfc_reg_rpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, · 4 unmodified lines
766827 mb->un.varRegLogin.vpi = phba->vpi_ids[vpi];
767828 mb->un.varRegLogin.did = did;
768829 mb->mbxOwner = OWN_HOST;
830+
769831 /* Get a buffer to hold NPorts Service Parameters */
770− mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL);
771− if (mp)
772− mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
773− if (!mp || !mp->virt) {
774− kfree(mp);
832+ rc = lpfc_mbox_rsrc_prep(phba, pmb);
833+ if (rc) {
775834 mb->mbxCommand = MBX_REG_LOGIN64;
776835 /* REG_LOGIN: no buffers */
777836 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
@@ -779,15 +838,13 @@ lpfc_reg_rpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, · 1 unmodified line
779838 "rpi x%x\n", vpi, did, rpi);
780839 return 1;
781840 }
782− INIT_LIST_HEAD(&mp->list);
783− sparam = mp->virt;
784841
785842 /* Copy param's into a new buffer */
843+ mp = pmb->ctx_buf;
844+ sparam = mp->virt;
786845 memcpy(sparam, param, sizeof (struct serv_parm));
787846
788− /* save address for completion */
789− pmb->ctx_buf = (uint8_t *)mp;
790−
847+ /* Finish initializing the mailbox. */
791848 mb->mbxCommand = MBX_REG_LOGIN64;
792849 mb->un.varRegLogin.un.sp64.tus.f.bdeSize = sizeof (struct serv_parm);
793850 mb->un.varRegLogin.un.sp64.addrHigh = putPaddrHigh(mp->phys);
@@ -1723,7 +1780,9 @@ lpfc_sli4_mbx_sge_get(struct lpfcMboxq *mbox, uint32_t sgentry, · 929 unmodified lines
17231780 * @phba: pointer to lpfc hba data structure.
17241781 * @mbox: pointer to lpfc mbox command.
17251782 *
1726− * This routine frees SLI4 specific mailbox command for sending IOCTL command.
1783+ * This routine cleans up and releases an SLI4 mailbox command that was
1784+ * configured using lpfc_sli4_config. It accounts for the embedded and
1785+ * non-embedded config types.
17271786 **/
17281787 void
17291788 lpfc_sli4_mbox_cmd_free(struct lpfc_hba *phba, struct lpfcMboxq *mbox)
@@ -2277,33 +2336,24 @@ lpfc_sli4_dump_cfg_rg23(struct lpfc_hba *phba, struct lpfcMboxq *mbox) · 547 unmodified lines
22772336 {
22782337 struct lpfc_dmabuf *mp = NULL;
22792338 MAILBOX_t *mb;
2339+ int rc;
22802340
22812341 memset(mbox, 0, sizeof(*mbox));
22822342 mb = &mbox->u.mb;
22832343
2284− mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
2285− if (mp)
2286− mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
2287−
2288− if (!mp || !mp->virt) {
2289− kfree(mp);
2290− /* dump config region 23 failed to allocate memory */
2344+ rc = lpfc_mbox_rsrc_prep(phba, mbox);
2345+ if (rc) {
22912346 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
2292− "2569 lpfc dump config region 23: memory"
2293− " allocation failed\n");
2347+ "2569 %s: memory allocation failed\n",
2348+ __func__);
22942349 return 1;
22952350 }
22962351
2297− memset(mp->virt, 0, LPFC_BPL_SIZE);
2298− INIT_LIST_HEAD(&mp->list);
2299−
2300− /* save address for completion */
2301− mbox->ctx_buf = (uint8_t *)mp;
2302−
23032352 mb->mbxCommand = MBX_DUMP_MEMORY;
23042353 mb->un.varDmp.type = DMP_NV_PARAMS;
23052354 mb->un.varDmp.region_id = DMP_REGION_23;
23062355 mb->un.varDmp.sli4_length = DMP_RGN23_SIZE;
2356+ mp = mbox->ctx_buf;
23072357 mb->un.varWords[3] = putPaddrLow(mp->phys);
23082358 mb->un.varWords[4] = putPaddrHigh(mp->phys);
23092359 return 0;
@@ -2326,7 +2376,7 @@ lpfc_mbx_cmpl_rdp_link_stat(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) · 16 unmodified lines
23262376 rc = SUCCESS;
23272377
23282378 mbx_failed:
2329− lpfc_sli4_mbox_cmd_free(phba, mboxq);
2379+ lpfc_mbox_rsrc_cleanup(phba, mboxq, MBOX_THD_UNLOCKED);
23302380 rdp_context->cmpl(phba, rdp_context, rc);
23312381 }
23322382
@@ -2338,30 +2388,25 @@ lpfc_mbx_cmpl_rdp_page_a2(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox) · 5 unmodified lines
23382388 (struct lpfc_rdp_context *)(mbox->ctx_ndlp);
23392389
23402390 if (bf_get(lpfc_mqe_status, &mbox->u.mqe))
2341− goto error_mbuf_free;
2391+ goto error_mbox_free;
23422392
23432393 lpfc_sli_bemem_bcopy(mp->virt, &rdp_context->page_a2,
23442394 DMP_SFF_PAGE_A2_SIZE);
23452395
2346− /* We don't need dma buffer for link stat. */
2347− lpfc_mbuf_free(phba, mp->virt, mp->phys);
2348− kfree(mp);
2349−
2350− memset(mbox, 0, sizeof(*mbox));
23512396 lpfc_read_lnk_stat(phba, mbox);
23522397 mbox->vport = rdp_context->ndlp->vport;
2398+
2399+ /* Save the dma buffer for cleanup in the final completion. */
2400+ mbox->ctx_buf = mp;
23532401 mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_link_stat;
23542402 mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
23552403 if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) == MBX_NOT_FINISHED)
2356− goto error_cmd_free;
2404+ goto error_mbox_free;
23572405
23582406 return;
23592407
2360−error_mbuf_free:
2361− lpfc_mbuf_free(phba, mp->virt, mp->phys);
2362− kfree(mp);
2363−error_cmd_free:
2364− lpfc_sli4_mbox_cmd_free(phba, mbox);
2408+error_mbox_free:
2409+ lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
23652410 rdp_context->cmpl(phba, rdp_context, FAILURE);
23662411 }
23672412
@@ -2409,9 +2454,7 @@ lpfc_mbx_cmpl_rdp_page_a0(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox) · 41 unmodified lines
24092454 return;
24102455
24112456 error:
2412− lpfc_mbuf_free(phba, mp->virt, mp->phys);
2413− kfree(mp);
2414− lpfc_sli4_mbox_cmd_free(phba, mbox);
2457+ lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
24152458 rdp_context->cmpl(phba, rdp_context, FAILURE);
24162459 }
24172460
@@ -2427,27 +2470,19 @@ error: · 9 unmodified lines
24272470 int
24282471 lpfc_sli4_dump_page_a0(struct lpfc_hba *phba, struct lpfcMboxq *mbox)
24292472 {
2473+ int rc;
24302474 struct lpfc_dmabuf *mp = NULL;
24312475
24322476 memset(mbox, 0, sizeof(*mbox));
24332477
2434− mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
2435− if (mp)
2436− mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
2437− if (!mp || !mp->virt) {
2438− kfree(mp);
2478+ rc = lpfc_mbox_rsrc_prep(phba, mbox);
2479+ if (rc) {
24392480 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
24402481 "3569 dump type 3 page 0xA0 allocation failed\n");
24412482 return 1;
24422483 }
24432484
2444− memset(mp->virt, 0, LPFC_BPL_SIZE);
2445− INIT_LIST_HEAD(&mp->list);
2446−
24472485 bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_DUMP_MEMORY);
2448− /* save address for completion */
2449− mbox->ctx_buf = mp;
2450−
24512486 bf_set(lpfc_mbx_memory_dump_type3_type,
24522487 &mbox->u.mqe.un.mem_dump_type3, DMP_LMSD);
24532488 bf_set(lpfc_mbx_memory_dump_type3_link,
@@ -2456,6 +2491,8 @@ lpfc_sli4_dump_page_a0(struct lpfc_hba *phba, struct lpfcMboxq *mbox) · 2 unmodified lines
24562491 &mbox->u.mqe.un.mem_dump_type3, DMP_PAGE_A0);
24572492 bf_set(lpfc_mbx_memory_dump_type3_length,
24582493 &mbox->u.mqe.un.mem_dump_type3, DMP_SFF_PAGE_A0_SIZE);
2494+
2495+ mp = mbox->ctx_buf;
24592496 mbox->u.mqe.un.mem_dump_type3.addr_lo = putPaddrLow(mp->phys);
24602497 mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys);
24612498
drivers/scsi/lpfc/lpfc_nportdisc.c+38−41
@@ -173,9 +173,9 @@ lpfc_check_elscmpl_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 172 unmodified lines
173173 void *ptr = NULL;
174174 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
175175
176− pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
176+ pcmd = cmdiocb->cmd_dmabuf;
177177
178− /* For lpfc_els_abort, context2 could be zero'ed to delay
178+ /* For lpfc_els_abort, cmd_dmabuf could be zero'ed to delay
179179 * freeing associated memory till after ABTS completes.
180180 */
181181 if (pcmd) {
@@ -327,7 +327,6 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 145 unmodified lines
327327 {
328328 struct lpfc_hba *phba = vport->phba;
329329 struct lpfc_dmabuf *pcmd;
330− struct lpfc_dmabuf *mp;
331330 uint64_t nlp_portwwn = 0;
332331 uint32_t *lp;
333332 union lpfc_wqe128 *wqe;
@@ -343,7 +342,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 9 unmodified lines
343342 u32 remote_did;
344343
345344 memset(&stat, 0, sizeof (struct ls_rjt));
346− pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
345+ pcmd = cmdiocb->cmd_dmabuf;
347346 lp = (uint32_t *) pcmd->virt;
348347 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
349348 if (wwn_to_u64(sp->portName.u.wwn) == 0) {
@@ -514,6 +513,10 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 164 unmodified lines
514513 lpfc_config_link(phba, link_mbox);
515514 link_mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
516515 link_mbox->vport = vport;
516+
517+ /* The default completion handling for CONFIG_LINK
518+ * does not require the ndlp so no reference is needed.
519+ */
517520 link_mbox->ctx_ndlp = ndlp;
518521
519522 rc = lpfc_sli_issue_mbox(phba, link_mbox, MBX_NOWAIT);
@@ -592,12 +595,8 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 72 unmodified lines
592595 * a default RPI.
593596 */
594597 if (phba->sli_rev == LPFC_SLI_REV4) {
595− mp = (struct lpfc_dmabuf *)login_mbox->ctx_buf;
596− if (mp) {
597− lpfc_mbuf_free(phba, mp->virt, mp->phys);
598− kfree(mp);
599− }
600− mempool_free(login_mbox, phba->mbox_mem_pool);
598+ lpfc_mbox_rsrc_cleanup(phba, login_mbox,
599+ MBOX_THD_UNLOCKED);
601600 login_mbox = NULL;
602601 } else {
603602 /* In order to preserve RPIs, we want to cleanup
@@ -614,9 +613,10 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 10 unmodified lines
614613 stat.un.b.lsRjtRsnCode = LSRJT_INVALID_CMD;
615614 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
616615 rc = lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb,
617− ndlp, login_mbox);
618− if (rc)
619− mempool_free(login_mbox, phba->mbox_mem_pool);
616+ ndlp, login_mbox);
617+ if (rc && login_mbox)
618+ lpfc_mbox_rsrc_cleanup(phba, login_mbox,
619+ MBOX_THD_UNLOCKED);
620620 return 1;
621621 }
622622
@@ -637,6 +637,9 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 14 unmodified lines
637637 */
638638 login_mbox->mbox_cmpl = lpfc_defer_plogi_acc;
639639 login_mbox->ctx_ndlp = lpfc_nlp_get(ndlp);
640+ if (!login_mbox->ctx_ndlp)
641+ goto out;
642+
640643 login_mbox->context3 = save_iocb; /* For PLOGI ACC */
641644
642645 spin_lock_irq(&ndlp->lock);
@@ -645,8 +648,10 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 2 unmodified lines
645648
646649 /* Start the ball rolling by issuing REG_LOGIN here */
647650 rc = lpfc_sli_issue_mbox(phba, login_mbox, MBX_NOWAIT);
648− if (rc == MBX_NOT_FINISHED)
651+ if (rc == MBX_NOT_FINISHED) {
652+ lpfc_nlp_put(ndlp);
649653 goto out;
654+ }
650655 lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE);
651656
652657 return 1;
@@ -710,7 +715,7 @@ lpfc_rcv_padisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 57 unmodified lines
710715 uint32_t *lp;
711716 uint32_t cmd;
712717
713− pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
718+ pcmd = cmdiocb->cmd_dmabuf;
714719 lp = (uint32_t *) pcmd->virt;
715720
716721 cmd = *lp++;
@@ -918,7 +923,7 @@ lpfc_rcv_prli_support_check(struct lpfc_vport *vport, · 201 unmodified lines
918923 uint32_t *payload;
919924 uint32_t cmd;
920925
921− payload = ((struct lpfc_dmabuf *)cmdiocb->context2)->virt;
926+ payload = cmdiocb->cmd_dmabuf->virt;
922927 cmd = *payload;
923928 if (vport->phba->nvmet_support) {
924929 /* Must be a NVME PRLI */
@@ -955,9 +960,9 @@ lpfc_rcv_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 30 unmodified lines
955960 struct fc_rport *rport = ndlp->rport;
956961 u32 roles;
957962
958− pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
959− lp = (uint32_t *) pcmd->virt;
960− npr = (PRLI *) ((uint8_t *) lp + sizeof (uint32_t));
963+ pcmd = cmdiocb->cmd_dmabuf;
964+ lp = (uint32_t *)pcmd->virt;
965+ npr = (PRLI *)((uint8_t *)lp + sizeof(uint32_t));
961966
962967 if ((npr->prliType == PRLI_FCP_TYPE) ||
963968 (npr->prliType == PRLI_NVME_TYPE)) {
@@ -1103,8 +1108,10 @@ lpfc_release_rpi(struct lpfc_hba *phba, struct lpfc_vport *vport, · 139 unmodified lines
11031108 ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag);
11041109
11051110 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
1106− if (rc == MBX_NOT_FINISHED)
1111+ if (rc == MBX_NOT_FINISHED) {
1112+ lpfc_nlp_put(ndlp);
11071113 mempool_free(pmb, phba->mbox_mem_pool);
1114+ }
11081115 }
11091116 }
11101117
@@ -1218,7 +1225,7 @@ lpfc_rcv_plogi_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 107 unmodified lines
12181225 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
12191226 struct lpfc_hba *phba = vport->phba;
12201227 struct lpfc_iocbq *cmdiocb = arg;
1221− struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
1228+ struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf;
12221229 uint32_t *lp = (uint32_t *) pcmd->virt;
12231230 struct serv_parm *sp = (struct serv_parm *) (lp + 1);
12241231 struct ls_rjt stat;
@@ -1328,7 +1335,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport, · 103 unmodified lines
13281335 {
13291336 struct lpfc_hba *phba = vport->phba;
13301337 struct lpfc_iocbq *cmdiocb, *rspiocb;
1331− struct lpfc_dmabuf *pcmd, *prsp, *mp;
1338+ struct lpfc_dmabuf *pcmd, *prsp;
13321339 uint32_t *lp;
13331340 uint32_t vid, flag;
13341341 struct serv_parm *sp;
@@ -1339,7 +1346,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport, · 4 unmodified lines
13391346 u32 did;
13401347
13411348 cmdiocb = (struct lpfc_iocbq *) arg;
1342− rspiocb = cmdiocb->context_un.rsp_iocb;
1349+ rspiocb = cmdiocb->rsp_iocb;
13431350
13441351 ulp_status = get_job_ulpstatus(phba, rspiocb);
13451352
@@ -1351,7 +1358,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport, · 5 unmodified lines
13511358 if (ulp_status)
13521359 goto out;
13531360
1354− pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
1361+ pcmd = cmdiocb->cmd_dmabuf;
13551362
13561363 prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list);
13571364 if (!prsp)
@@ -1495,11 +1502,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport, · 137 unmodified lines
14951502 * command
14961503 */
14971504 lpfc_nlp_put(ndlp);
1498− mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
1499− lpfc_mbuf_free(phba, mp->virt, mp->phys);
1500− kfree(mp);
1501− mempool_free(mbox, phba->mbox_mem_pool);
1502−
1505+ lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
15031506 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
15041507 "0134 PLOGI: cannot issue reg_login "
15051508 "Data: x%x x%x x%x x%x\n",
@@ -1697,7 +1700,7 @@ lpfc_cmpl_adisc_adisc_issue(struct lpfc_vport *vport, · 191 unmodified lines
16971700 u32 ulp_status;
16981701
16991702 cmdiocb = (struct lpfc_iocbq *) arg;
1700− rspiocb = cmdiocb->context_un.rsp_iocb;
1703+ rspiocb = cmdiocb->rsp_iocb;
17011704
17021705 ulp_status = get_job_ulpstatus(phba, rspiocb);
17031706
@@ -1850,7 +1853,6 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport, · 146 unmodified lines
18501853 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
18511854 LPFC_MBOXQ_t *mb;
18521855 LPFC_MBOXQ_t *nextmb;
1853− struct lpfc_dmabuf *mp;
18541856 struct lpfc_nodelist *ns_ndlp;
18551857
18561858 cmdiocb = (struct lpfc_iocbq *) arg;
@@ -1870,16 +1872,11 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport, · 13 unmodified lines
18701872 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
18711873 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
18721874 (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {
1873− mp = (struct lpfc_dmabuf *)(mb->ctx_buf);
1874− if (mp) {
1875− __lpfc_mbuf_free(phba, mp->virt, mp->phys);
1876− kfree(mp);
1877− }
18781875 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
18791876 lpfc_nlp_put(ndlp);
18801877 list_del(&mb->list);
18811878 phba->sli.mboxq_cnt--;
1882− mempool_free(mb, phba->mbox_mem_pool);
1879+ lpfc_mbox_rsrc_cleanup(phba, mb, MBOX_THD_LOCKED);
18831880 }
18841881 }
18851882 spin_unlock_irq(&phba->hbalock);
@@ -2152,7 +2149,7 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 266 unmodified lines
21522149 u32 ulp_status;
21532150
21542151 cmdiocb = (struct lpfc_iocbq *) arg;
2155− rspiocb = cmdiocb->context_un.rsp_iocb;
2152+ rspiocb = cmdiocb->rsp_iocb;
21562153
21572154 ulp_status = get_job_ulpstatus(phba, rspiocb);
21582155
@@ -2772,7 +2769,7 @@ lpfc_cmpl_plogi_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 613 unmodified lines
27722769 u32 ulp_status;
27732770
27742771 cmdiocb = (struct lpfc_iocbq *) arg;
2775− rspiocb = cmdiocb->context_un.rsp_iocb;
2772+ rspiocb = cmdiocb->rsp_iocb;
27762773
27772774 ulp_status = get_job_ulpstatus(phba, rspiocb);
27782775
@@ -2791,7 +2788,7 @@ lpfc_cmpl_prli_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 12 unmodified lines
27912788 u32 ulp_status;
27922789
27932790 cmdiocb = (struct lpfc_iocbq *) arg;
2794− rspiocb = cmdiocb->context_un.rsp_iocb;
2791+ rspiocb = cmdiocb->rsp_iocb;
27952792
27962793 ulp_status = get_job_ulpstatus(phba, rspiocb);
27972794
@@ -2827,7 +2824,7 @@ lpfc_cmpl_adisc_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 29 unmodified lines
28272824 u32 ulp_status;
28282825
28292826 cmdiocb = (struct lpfc_iocbq *) arg;
2830− rspiocb = cmdiocb->context_un.rsp_iocb;
2827+ rspiocb = cmdiocb->rsp_iocb;
28312828
28322829 ulp_status = get_job_ulpstatus(phba, rspiocb);
28332830
drivers/scsi/lpfc/lpfc_nvme.c+25−19
@@ -319,8 +319,10 @@ __lpfc_nvme_ls_req_cmp(struct lpfc_hba *phba, struct lpfc_vport *vport, · 318 unmodified lines
319319 struct lpfc_nodelist *ndlp;
320320 uint32_t status;
321321
322− pnvme_lsreq = (struct nvmefc_ls_req *)cmdwqe->context2;
323− ndlp = (struct lpfc_nodelist *)cmdwqe->context1;
322+ pnvme_lsreq = cmdwqe->context_un.nvme_lsreq;
323+ ndlp = cmdwqe->ndlp;
324+ buf_ptr = cmdwqe->bpl_dmabuf;
325+
324326 status = bf_get(lpfc_wcqe_c_status, wcqe) & LPFC_IOCB_STATUS_MASK;
325327
326328 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
@@ -330,16 +332,16 @@ __lpfc_nvme_ls_req_cmp(struct lpfc_hba *phba, struct lpfc_vport *vport, · 3 unmodified lines
330332 pnvme_lsreq, ndlp ? ndlp->nlp_DID : 0,
331333 cmdwqe->sli4_xritag, status,
332334 (wcqe->parameter & 0xffff),
333− cmdwqe, pnvme_lsreq, cmdwqe->context3, ndlp);
335+ cmdwqe, pnvme_lsreq, cmdwqe->bpl_dmabuf,
336+ ndlp);
334337
335338 lpfc_nvmeio_data(phba, "NVMEx LS CMPL: xri x%x stat x%x parm x%x\n",
336339 cmdwqe->sli4_xritag, status, wcqe->parameter);
337340
338− if (cmdwqe->context3) {
339− buf_ptr = (struct lpfc_dmabuf *)cmdwqe->context3;
341+ if (buf_ptr) {
340342 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
341343 kfree(buf_ptr);
342− cmdwqe->context3 = NULL;
344+ cmdwqe->bpl_dmabuf = NULL;
343345 }
344346 if (pnvme_lsreq->done)
345347 pnvme_lsreq->done(pnvme_lsreq, status);
@@ -351,7 +353,7 @@ __lpfc_nvme_ls_req_cmp(struct lpfc_hba *phba, struct lpfc_vport *vport, · 5 unmodified lines
351353 cmdwqe->sli4_xritag, status);
352354 if (ndlp) {
353355 lpfc_nlp_put(ndlp);
354− cmdwqe->context1 = NULL;
356+ cmdwqe->ndlp = NULL;
355357 }
356358 lpfc_sli_release_iocbq(phba, cmdwqe);
357359 }
@@ -407,19 +409,19 @@ lpfc_nvme_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, · 49 unmodified lines
407409 /* Initialize only 64 bytes */
408410 memset(wqe, 0, sizeof(union lpfc_wqe));
409411
410− genwqe->context3 = (uint8_t *)bmp;
412+ genwqe->bpl_dmabuf = bmp;
411413 genwqe->cmd_flag |= LPFC_IO_NVME_LS;
412414
413415 /* Save for completion so we can release these resources */
414− genwqe->context1 = lpfc_nlp_get(ndlp);
415− if (!genwqe->context1) {
416+ genwqe->ndlp = lpfc_nlp_get(ndlp);
417+ if (!genwqe->ndlp) {
416418 dev_warn(&phba->pcidev->dev,
417419 "Warning: Failed node ref, not sending LS_REQ\n");
418420 lpfc_sli_release_iocbq(phba, genwqe);
419421 return 1;
420422 }
421423
422− genwqe->context2 = (uint8_t *)pnvme_lsreq;
424+ genwqe->context_un.nvme_lsreq = pnvme_lsreq;
423425 /* Fill in payload, bp points to frame payload */
424426
425427 if (!tmo)
@@ -730,7 +732,7 @@ __lpfc_nvme_ls_abort(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 304 unmodified lines
730732 spin_lock_irq(&phba->hbalock);
731733 spin_lock(&pring->ring_lock);
732734 list_for_each_entry_safe(wqe, next_wqe, &pring->txcmplq, list) {
733− if (wqe->context2 == pnvme_lsreq) {
735+ if (wqe->context_un.nvme_lsreq == pnvme_lsreq) {
734736 wqe->cmd_flag |= LPFC_DRIVER_ABORTED;
735737 foundit = true;
736738 break;
@@ -929,8 +931,7 @@ static void · 192 unmodified lines
929931 lpfc_nvme_io_cmd_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
930932 struct lpfc_iocbq *pwqeOut)
931933 {
932− struct lpfc_io_buf *lpfc_ncmd =
933− (struct lpfc_io_buf *)pwqeIn->context1;
934+ struct lpfc_io_buf *lpfc_ncmd = pwqeIn->io_buf;
934935 struct lpfc_wcqe_complete *wcqe = &pwqeOut->wcqe_cmpl;
935936 struct lpfc_vport *vport = pwqeIn->vport;
936937 struct nvmefc_fcp_req *nCmd;
@@ -1400,8 +1401,8 @@ lpfc_nvme_prep_io_dma(struct lpfc_vport *vport, · 463 unmodified lines
14001401 if ((nseg - 1) == i)
14011402 bf_set(lpfc_sli4_sge_last, sgl, 1);
14021403
1403− physaddr = data_sg->dma_address;
1404− dma_len = data_sg->length;
1404+ physaddr = sg_dma_address(data_sg);
1405+ dma_len = sg_dma_len(data_sg);
14051406 sgl->addr_lo = cpu_to_le32(
14061407 putPaddrLow(physaddr));
14071408 sgl->addr_hi = cpu_to_le32(
@@ -2356,6 +2357,11 @@ lpfc_nvme_register_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 948 unmodified lines
23562357 rpinfo.dev_loss_tmo = vport->cfg_devloss_tmo;
23572358
23582359 spin_lock_irq(&ndlp->lock);
2360+
2361+ /* If an oldrport exists, so does the ndlp reference. If not
2362+ * a new reference is needed because either the node has never
2363+ * been registered or it's been unregistered and getting deleted.
2364+ */
23592365 oldrport = lpfc_ndlp_get_nrport(ndlp);
23602366 if (oldrport) {
23612367 prev_ndlp = oldrport->ndlp;
@@ -2466,12 +2472,12 @@ lpfc_nvme_rescan_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 104 unmodified lines
24662472 if (!nrport || !remoteport)
24672473 goto rescan_exit;
24682474
2469− /* Only rescan if we are an NVME target in the MAPPED state */
2475+ /* Rescan an NVME target in MAPPED state with DISCOVERY role set */
24702476 if (remoteport->port_role & FC_PORT_ROLE_NVME_DISCOVERY &&
24712477 ndlp->nlp_state == NLP_STE_MAPPED_NODE) {
24722478 nvme_fc_rescan_remoteport(remoteport);
24732479
2474− lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
2480+ lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
24752481 "6172 NVME rescanned DID x%06x "
24762482 "port_state x%x\n",
24772483 ndlp->nlp_DID, remoteport->port_state);
@@ -2717,7 +2723,7 @@ lpfc_nvme_cancel_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, · 239 unmodified lines
27172723 struct lpfc_wcqe_complete wcqe;
27182724 struct lpfc_wcqe_complete *wcqep = &wcqe;
27192725
2720− lpfc_ncmd = (struct lpfc_io_buf *)pwqeIn->context1;
2726+ lpfc_ncmd = pwqeIn->io_buf;
27212727 if (!lpfc_ncmd) {
27222728 lpfc_sli_release_iocbq(phba, pwqeIn);
27232729 return;
drivers/scsi/lpfc/lpfc_nvmet.c+37−36
@@ -295,7 +295,7 @@ void · 294 unmodified lines
295295 __lpfc_nvme_xmt_ls_rsp_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe,
296296 struct lpfc_iocbq *rspwqe)
297297 {
298− struct lpfc_async_xchg_ctx *axchg = cmdwqe->context2;
298+ struct lpfc_async_xchg_ctx *axchg = cmdwqe->context_un.axchg;
299299 struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl;
300300 struct nvmefc_ls_rsp *ls_rsp = &axchg->ls_rsp;
301301 uint32_t status, result;
@@ -317,9 +317,9 @@ __lpfc_nvme_xmt_ls_rsp_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 15 unmodified lines
317317 "6038 NVMEx LS rsp cmpl: %d %d oxid x%x\n",
318318 status, result, axchg->oxid);
319319
320− lpfc_nlp_put(cmdwqe->context1);
321− cmdwqe->context2 = NULL;
322− cmdwqe->context3 = NULL;
320+ lpfc_nlp_put(cmdwqe->ndlp);
321+ cmdwqe->context_un.axchg = NULL;
322+ cmdwqe->bpl_dmabuf = NULL;
323323 lpfc_sli_release_iocbq(phba, cmdwqe);
324324 ls_rsp->done(ls_rsp);
325325 lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC,
@@ -728,7 +728,7 @@ lpfc_nvmet_xmt_fcp_op_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 402 unmodified lines
728728 int id;
729729 #endif
730730
731− ctxp = cmdwqe->context2;
731+ ctxp = cmdwqe->context_un.axchg;
732732 ctxp->flag &= ~LPFC_NVME_IO_INP;
733733
734734 rsp = &ctxp->hdlrctx.fcp_req;
@@ -903,7 +903,7 @@ __lpfc_nvme_xmt_ls_rsp(struct lpfc_async_xchg_ctx *axchg, · 168 unmodified lines
903903 /* Save numBdes for bpl2sgl */
904904 nvmewqeq->num_bdes = 1;
905905 nvmewqeq->hba_wqidx = 0;
906− nvmewqeq->context3 = &dmabuf;
906+ nvmewqeq->bpl_dmabuf = &dmabuf;
907907 dmabuf.virt = &bpl;
908908 bpl.addrLow = nvmewqeq->wqe.xmit_sequence.bde.addrLow;
909909 bpl.addrHigh = nvmewqeq->wqe.xmit_sequence.bde.addrHigh;
@@ -917,7 +917,7 @@ __lpfc_nvme_xmt_ls_rsp(struct lpfc_async_xchg_ctx *axchg, · 7 unmodified lines
917917 */
918918
919919 nvmewqeq->cmd_cmpl = xmt_ls_rsp_cmp;
920− nvmewqeq->context2 = axchg;
920+ nvmewqeq->context_un.axchg = axchg;
921921
922922 lpfc_nvmeio_data(phba, "NVMEx LS RSP: xri x%x wqidx x%x len x%x\n",
923923 axchg->oxid, nvmewqeq->hba_wqidx, ls_rsp->rsplen);
@@ -925,7 +925,7 @@ __lpfc_nvme_xmt_ls_rsp(struct lpfc_async_xchg_ctx *axchg, · 1 unmodified line
925925 rc = lpfc_sli4_issue_wqe(phba, axchg->hdwq, nvmewqeq);
926926
927927 /* clear to be sure there's no reference */
928− nvmewqeq->context3 = NULL;
928+ nvmewqeq->bpl_dmabuf = NULL;
929929
930930 if (rc == WQE_SUCCESS) {
931931 /*
@@ -942,7 +942,7 @@ __lpfc_nvme_xmt_ls_rsp(struct lpfc_async_xchg_ctx *axchg, · 10 unmodified lines
942942
943943 rc = -ENXIO;
944944
945− lpfc_nlp_put(nvmewqeq->context1);
945+ lpfc_nlp_put(nvmewqeq->ndlp);
946946
947947 out_free_buf:
948948 /* Give back resources */
@@ -1075,7 +1075,7 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport, · 126 unmodified lines
10751075 }
10761076
10771077 nvmewqeq->cmd_cmpl = lpfc_nvmet_xmt_fcp_op_cmp;
1078− nvmewqeq->context2 = ctxp;
1078+ nvmewqeq->context_un.axchg = ctxp;
10791079 nvmewqeq->cmd_flag |= LPFC_IO_NVMET;
10801080 ctxp->wqeq->hba_wqidx = rsp->hwqid;
10811081
@@ -1119,8 +1119,8 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport, · 37 unmodified lines
11191119 ctxp->oxid, rc);
11201120
11211121 ctxp->wqeq->hba_wqidx = 0;
1122− nvmewqeq->context2 = NULL;
1123− nvmewqeq->context3 = NULL;
1122+ nvmewqeq->context_un.axchg = NULL;
1123+ nvmewqeq->bpl_dmabuf = NULL;
11241124 rc = -EBUSY;
11251125 aerr:
11261126 return rc;
@@ -1590,7 +1590,7 @@ lpfc_nvmet_setup_io_context(struct lpfc_hba *phba) · 463 unmodified lines
15901590 /* Initialize WQE */
15911591 memset(wqe, 0, sizeof(union lpfc_wqe));
15921592
1593− ctx_buf->iocbq->context1 = NULL;
1593+ ctx_buf->iocbq->cmd_dmabuf = NULL;
15941594 spin_lock(&phba->sli4_hba.sgl_list_lock);
15951595 ctx_buf->sglq = __lpfc_sli_get_nvmet_sglq(phba, ctx_buf->iocbq);
15961596 spin_unlock(&phba->sli4_hba.sgl_list_lock);
@@ -2025,7 +2025,7 @@ lpfc_nvmet_wqfull_flush(struct lpfc_hba *phba, struct lpfc_queue *wq, · 428 unmodified lines
20252025 &wq->wqfull_list, list) {
20262026 if (ctxp) {
20272027 /* Checking for a specific IO to flush */
2028− if (nvmewqeq->context2 == ctxp) {
2028+ if (nvmewqeq->context_un.axchg == ctxp) {
20292029 list_del(&nvmewqeq->list);
20302030 spin_unlock_irqrestore(&pring->ring_lock,
20312031 iflags);
@@ -2071,7 +2071,7 @@ lpfc_nvmet_wqfull_process(struct lpfc_hba *phba, · 39 unmodified lines
20712071 list_remove_head(&wq->wqfull_list, nvmewqeq, struct lpfc_iocbq,
20722072 list);
20732073 spin_unlock_irqrestore(&pring->ring_lock, iflags);
2074− ctxp = (struct lpfc_async_xchg_ctx *)nvmewqeq->context2;
2074+ ctxp = nvmewqeq->context_un.axchg;
20752075 rc = lpfc_sli4_issue_wqe(phba, ctxp->hdwq, nvmewqeq);
20762076 spin_lock_irqsave(&pring->ring_lock, iflags);
20772077 if (rc == -EBUSY) {
@@ -2617,10 +2617,10 @@ lpfc_nvmet_prep_ls_wqe(struct lpfc_hba *phba, · 539 unmodified lines
26172617 ctxp->wqeq = nvmewqe;
26182618
26192619 /* prevent preparing wqe with NULL ndlp reference */
2620− nvmewqe->context1 = lpfc_nlp_get(ndlp);
2621− if (nvmewqe->context1 == NULL)
2620+ nvmewqe->ndlp = lpfc_nlp_get(ndlp);
2621+ if (!nvmewqe->ndlp)
26222622 goto nvme_wqe_free_wqeq_exit;
2623− nvmewqe->context2 = ctxp;
2623+ nvmewqe->context_un.axchg = ctxp;
26242624
26252625 wqe = &nvmewqe->wqe;
26262626 memset(wqe, 0, sizeof(union lpfc_wqe));
@@ -2692,8 +2692,9 @@ lpfc_nvmet_prep_ls_wqe(struct lpfc_hba *phba, · 65 unmodified lines
26922692 return nvmewqe;
26932693
26942694 nvme_wqe_free_wqeq_exit:
2695− nvmewqe->context2 = NULL;
2696− nvmewqe->context3 = NULL;
2695+ nvmewqe->context_un.axchg = NULL;
2696+ nvmewqe->ndlp = NULL;
2697+ nvmewqe->bpl_dmabuf = NULL;
26972698 lpfc_sli_release_iocbq(phba, nvmewqe);
26982699 return NULL;
26992700 }
@@ -2995,7 +2996,7 @@ lpfc_nvmet_prep_fcp_wqe(struct lpfc_hba *phba, · 295 unmodified lines
29952996 nvmewqe->retry = 1;
29962997 nvmewqe->vport = phba->pport;
29972998 nvmewqe->drvrTimeout = (phba->fc_ratov * 3) + LPFC_DRVR_TIMEOUT;
2998− nvmewqe->context1 = ndlp;
2999+ nvmewqe->ndlp = ndlp;
29993000
30003001 for_each_sg(rsp->sg, sgel, nsegs, i) {
30013002 physaddr = sg_dma_address(sgel);
@@ -3053,7 +3054,7 @@ lpfc_nvmet_sol_fcp_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 51 unmodified lines
30533054 bool released = false;
30543055 struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl;
30553056
3056− ctxp = cmdwqe->context2;
3057+ ctxp = cmdwqe->context_un.axchg;
30573058 result = wcqe->parameter;
30583059
30593060 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
@@ -3084,8 +3085,8 @@ lpfc_nvmet_sol_fcp_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 24 unmodified lines
30843085 wcqe->word0, wcqe->total_data_placed,
30853086 result, wcqe->word3);
30863087
3087− cmdwqe->context2 = NULL;
3088− cmdwqe->context3 = NULL;
3088+ cmdwqe->rsp_dmabuf = NULL;
3089+ cmdwqe->bpl_dmabuf = NULL;
30893090 /*
30903091 * if transport has released ctx, then can reuse it. Otherwise,
30913092 * will be recycled by transport release call.
@@ -3123,7 +3124,7 @@ lpfc_nvmet_unsol_fcp_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 31 unmodified lines
31233124 bool released = false;
31243125 struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl;
31253126
3126− ctxp = cmdwqe->context2;
3127+ ctxp = cmdwqe->context_un.axchg;
31273128 result = wcqe->parameter;
31283129
31293130 if (!ctxp) {
@@ -3169,8 +3170,8 @@ lpfc_nvmet_unsol_fcp_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 39 unmodified lines
31693170 wcqe->word0, wcqe->total_data_placed,
31703171 result, wcqe->word3);
31713172
3172− cmdwqe->context2 = NULL;
3173− cmdwqe->context3 = NULL;
3173+ cmdwqe->rsp_dmabuf = NULL;
3174+ cmdwqe->bpl_dmabuf = NULL;
31743175 /*
31753176 * if transport has released ctx, then can reuse it. Otherwise,
31763177 * will be recycled by transport release call.
@@ -3203,7 +3204,7 @@ lpfc_nvmet_xmt_ls_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 26 unmodified lines
32033204 uint32_t result;
32043205 struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl;
32053206
3206− ctxp = cmdwqe->context2;
3207+ ctxp = cmdwqe->context_un.axchg;
32073208 result = wcqe->parameter;
32083209
32093210 if (phba->nvmet_support) {
@@ -3234,8 +3235,8 @@ lpfc_nvmet_xmt_ls_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 24 unmodified lines
32343235 ctxp->oxid, ctxp->state, ctxp->entry_cnt);
32353236 }
32363237
3237− cmdwqe->context2 = NULL;
3238− cmdwqe->context3 = NULL;
3238+ cmdwqe->rsp_dmabuf = NULL;
3239+ cmdwqe->bpl_dmabuf = NULL;
32393240 lpfc_sli_release_iocbq(phba, cmdwqe);
32403241 kfree(ctxp);
32413242 }
@@ -3322,9 +3323,9 @@ lpfc_nvmet_unsol_issue_abort(struct lpfc_hba *phba, · 80 unmodified lines
33223323 OTHER_COMMAND);
33233324
33243325 abts_wqeq->vport = phba->pport;
3325− abts_wqeq->context1 = ndlp;
3326− abts_wqeq->context2 = ctxp;
3327− abts_wqeq->context3 = NULL;
3326+ abts_wqeq->ndlp = ndlp;
3327+ abts_wqeq->context_un.axchg = ctxp;
3328+ abts_wqeq->bpl_dmabuf = NULL;
33283329 abts_wqeq->num_bdes = 0;
33293330 /* hba_wqidx should already be setup from command we are aborting */
33303331 abts_wqeq->iocb.ulpCommand = CMD_XMIT_SEQUENCE64_CR;
@@ -3477,7 +3478,7 @@ lpfc_nvmet_sol_fcp_issue_abort(struct lpfc_hba *phba, · 146 unmodified lines
34773478 abts_wqeq->hba_wqidx = ctxp->wqeq->hba_wqidx;
34783479 abts_wqeq->cmd_cmpl = lpfc_nvmet_sol_fcp_abort_cmp;
34793480 abts_wqeq->cmd_flag |= LPFC_IO_NVME;
3480− abts_wqeq->context2 = ctxp;
3481+ abts_wqeq->context_un.axchg = ctxp;
34813482 abts_wqeq->vport = phba->pport;
34823483 if (!ctxp->hdwq)
34833484 ctxp->hdwq = &phba->sli4_hba.hdwq[abts_wqeq->hba_wqidx];
@@ -3630,8 +3631,8 @@ lpfc_nvme_unsol_ls_issue_abort(struct lpfc_hba *phba, · 146 unmodified lines
36303631 out:
36313632 if (tgtp)
36323633 atomic_inc(&tgtp->xmt_abort_rsp_error);
3633− abts_wqeq->context2 = NULL;
3634− abts_wqeq->context3 = NULL;
3634+ abts_wqeq->rsp_dmabuf = NULL;
3635+ abts_wqeq->bpl_dmabuf = NULL;
36353636 lpfc_sli_release_iocbq(phba, abts_wqeq);
36363637 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
36373638 "6056 Failed to Issue ABTS. Status x%x\n", rc);
drivers/scsi/lpfc/lpfc_scsi.c+34−38
@@ -433,7 +433,7 @@ lpfc_new_scsi_buf_s3(struct lpfc_vport *vport, int num_to_alloc) · 432 unmodified lines
433433 iocb->ulpClass = CLASS3;
434434 psb->status = IOSTAT_SUCCESS;
435435 /* Put it back into the SCSI buffer list */
436− psb->cur_iocbq.context1 = psb;
436+ psb->cur_iocbq.io_buf = psb;
437437 spin_lock_init(&psb->buf_lock);
438438 lpfc_release_scsi_buf_s3(phba, psb);
439439
@@ -3835,7 +3835,7 @@ lpfc_update_cmf_cmpl(struct lpfc_hba *phba, · 3395 unmodified lines
38353835 else
38363836 time = div_u64(time + 500, 1000); /* round it */
38373837
3838− cgs = this_cpu_ptr(phba->cmf_stat);
3838+ cgs = per_cpu_ptr(phba->cmf_stat, raw_smp_processor_id());
38393839 atomic64_add(size, &cgs->rcv_bytes);
38403840 atomic64_add(time, &cgs->rx_latency);
38413841 atomic_inc(&cgs->rx_io_cnt);
@@ -3879,7 +3879,7 @@ lpfc_update_cmf_cmd(struct lpfc_hba *phba, uint32_t size) · 37 unmodified lines
38793879 atomic_set(&phba->rx_max_read_cnt, size);
38803880 }
38813881
3882− cgs = this_cpu_ptr(phba->cmf_stat);
3882+ cgs = per_cpu_ptr(phba->cmf_stat, raw_smp_processor_id());
38833883 atomic64_add(size, &cgs->total_bytes);
38843884 return 0;
38853885 }
@@ -4082,8 +4082,7 @@ static void · 196 unmodified lines
40824082 lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
40834083 struct lpfc_iocbq *pwqeOut)
40844084 {
4085− struct lpfc_io_buf *lpfc_cmd =
4086− (struct lpfc_io_buf *)pwqeIn->context1;
4085+ struct lpfc_io_buf *lpfc_cmd = pwqeIn->io_buf;
40874086 struct lpfc_wcqe_complete *wcqe = &pwqeOut->wcqe_cmpl;
40884087 struct lpfc_vport *vport = pwqeIn->vport;
40894088 struct lpfc_rport_data *rdata;
@@ -4276,6 +4275,7 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, · 186 unmodified lines
42764275 break;
42774276 }
42784277 if (lpfc_cmd->result == IOERR_INVALID_RPI ||
4278+ lpfc_cmd->result == IOERR_LINK_DOWN ||
42794279 lpfc_cmd->result == IOERR_NO_RESOURCES ||
42804280 lpfc_cmd->result == IOERR_ABORT_REQUESTED ||
42814281 lpfc_cmd->result == IOERR_RPI_SUSPENDED ||
@@ -4420,7 +4420,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, · 138 unmodified lines
44204420 struct lpfc_iocbq *pIocbOut)
44214421 {
44224422 struct lpfc_io_buf *lpfc_cmd =
4423− (struct lpfc_io_buf *) pIocbIn->context1;
4423+ (struct lpfc_io_buf *) pIocbIn->io_buf;
44244424 struct lpfc_vport *vport = pIocbIn->vport;
44254425 struct lpfc_rport_data *rdata = lpfc_cmd->rdata;
44264426 struct lpfc_nodelist *pnode = rdata->pnode;
@@ -4743,7 +4743,7 @@ static int lpfc_scsi_prep_cmnd_buf_s3(struct lpfc_vport *vport, · 316 unmodified lines
47434743 piocbq->iocb.ulpFCP2Rcvy = 0;
47444744
47454745 piocbq->iocb.ulpClass = (pnode->nlp_fcp_info & 0x0f);
4746− piocbq->context1 = lpfc_cmd;
4746+ piocbq->io_buf = lpfc_cmd;
47474747 if (!piocbq->cmd_cmpl)
47484748 piocbq->cmd_cmpl = lpfc_scsi_cmd_iocb_cmpl;
47494749 piocbq->iocb.ulpTimeout = tmo;
@@ -4855,8 +4855,7 @@ static int lpfc_scsi_prep_cmnd_buf_s4(struct lpfc_vport *vport, · 105 unmodified lines
48554855 bf_set(wqe_reqtag, &wqe->generic.wqe_com, pwqeq->iotag);
48564856
48574857 pwqeq->vport = vport;
4858− pwqeq->vport = vport;
4859− pwqeq->context1 = lpfc_cmd;
4858+ pwqeq->io_buf = lpfc_cmd;
48604859 pwqeq->hba_wqidx = lpfc_cmd->hdwq_no;
48614860 pwqeq->cmd_cmpl = lpfc_fcp_io_cmd_wqe_cmpl;
48624861
@@ -5097,8 +5096,7 @@ lpfc_tskmgmt_def_cmpl(struct lpfc_hba *phba, · 234 unmodified lines
50975096 struct lpfc_iocbq *cmdiocbq,
50985097 struct lpfc_iocbq *rspiocbq)
50995098 {
5100− struct lpfc_io_buf *lpfc_cmd =
5101− (struct lpfc_io_buf *) cmdiocbq->context1;
5099+ struct lpfc_io_buf *lpfc_cmd = cmdiocbq->io_buf;
51025100 if (lpfc_cmd)
51035101 lpfc_release_scsi_buf(phba, lpfc_cmd);
51045102 return;
@@ -5346,9 +5344,9 @@ static void lpfc_vmid_update_entry(struct lpfc_vport *vport, struct scsi_cmnd · 241 unmodified lines
53465344 {
53475345 u64 *lta;
53485346
5349− if (vport->vmid_priority_tagging)
5347+ if (vport->phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO)
53505348 tag->cs_ctl_vmid = vmp->un.cs_ctl_vmid;
5351− else
5349+ else if (vport->phba->cfg_vmid_app_header)
53525350 tag->app_id = vmp->un.app_id;
53535351
53545352 if (cmd->sc_data_direction == DMA_TO_DEVICE)
@@ -5393,11 +5391,12 @@ static int lpfc_vmid_get_appid(struct lpfc_vport *vport, char *uuid, struct · 38 unmodified lines
53935391 scsi_cmnd * cmd, union lpfc_vmid_io_tag *tag)
53945392 {
53955393 struct lpfc_vmid *vmp = NULL;
5396− int hash, len, rc, i;
5394+ int hash, len, rc = -EPERM, i;
53975395
53985396 /* check if QFPA is complete */
5399− if (lpfc_vmid_is_type_priority_tag(vport) && !(vport->vmid_flag &
5400− LPFC_VMID_QFPA_CMPL)) {
5397+ if (lpfc_vmid_is_type_priority_tag(vport) &&
5398+ !(vport->vmid_flag & LPFC_VMID_QFPA_CMPL) &&
5399+ (vport->vmid_flag & LPFC_VMID_ISSUE_QFPA)) {
54015400 vport->work_port_events |= WORKER_CHECK_VMID_ISSUE_QFPA;
54025401 return -EAGAIN;
54035402 }
@@ -5471,7 +5470,7 @@ static int lpfc_vmid_get_appid(struct lpfc_vport *vport, char *uuid, struct · 67 unmodified lines
54715470 vport->vmid_inactivity_timeout ? 1 : 0;
54725471
54735472 /* if type priority tag, get next available VMID */
5474− if (lpfc_vmid_is_type_priority_tag(vport))
5473+ if (vport->phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO)
54755474 lpfc_vmid_assign_cs_ctl(vport, vmp);
54765475
54775476 /* allocate the per cpu variable for holding */
@@ -5490,9 +5489,9 @@ static int lpfc_vmid_get_appid(struct lpfc_vport *vport, char *uuid, struct · 12 unmodified lines
54905489 write_unlock(&vport->vmid_lock);
54915490
54925491 /* complete transaction with switch */
5493− if (lpfc_vmid_is_type_priority_tag(vport))
5492+ if (vport->phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO)
54945493 rc = lpfc_vmid_uvem(vport, vmp, true);
5495− else
5494+ else if (vport->phba->cfg_vmid_app_header)
54965495 rc = lpfc_vmid_cmd(vport, SLI_CTAS_RAPP_IDENT, vmp);
54975496 if (!rc) {
54985497 write_lock(&vport->vmid_lock);
@@ -5866,25 +5865,25 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) · 367 unmodified lines
58665865 if (!lpfc_cmd)
58675866 return ret;
58685867
5869− spin_lock_irqsave(&phba->hbalock, flags);
5868+ /* Guard against IO completion being called at same time */
5869+ spin_lock_irqsave(&lpfc_cmd->buf_lock, flags);
5870+
5871+ spin_lock(&phba->hbalock);
58705872 /* driver queued commands are in process of being flushed */
58715873 if (phba->hba_flag & HBA_IOQ_FLUSH) {
58725874 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
58735875 "3168 SCSI Layer abort requested I/O has been "
58745876 "flushed by LLD.\n");
58755877 ret = FAILED;
5876− goto out_unlock;
5878+ goto out_unlock_hba;
58775879 }
58785880
5879− /* Guard against IO completion being called at same time */
5880− spin_lock(&lpfc_cmd->buf_lock);
5881−
58825881 if (!lpfc_cmd->pCmd) {
58835882 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
58845883 "2873 SCSI Layer I/O Abort Request IO CMPL Status "
58855884 "x%x ID %d LUN %llu\n",
58865885 SUCCESS, cmnd->device->id, cmnd->device->lun);
5887− goto out_unlock_buf;
5886+ goto out_unlock_hba;
58885887 }
58895888
58905889 iocb = &lpfc_cmd->cur_iocbq;
@@ -5892,7 +5891,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) · 1 unmodified line
58925891 pring_s4 = phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring;
58935892 if (!pring_s4) {
58945893 ret = FAILED;
5895− goto out_unlock_buf;
5894+ goto out_unlock_hba;
58965895 }
58975896 spin_lock(&pring_s4->ring_lock);
58985897 }
@@ -5917,7 +5916,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) · 18 unmodified lines
59175916 goto out_unlock_ring;
59185917 }
59195918
5920− BUG_ON(iocb->context1 != lpfc_cmd);
5919+ WARN_ON(iocb->io_buf != lpfc_cmd);
59215920
59225921 /* abort issued in recovery is still in progress */
59235922 if (iocb->cmd_flag & LPFC_DRIVER_ABORTED) {
@@ -5925,8 +5924,8 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) · 1 unmodified line
59255924 "3389 SCSI Layer I/O Abort Request is pending\n");
59265925 if (phba->sli_rev == LPFC_SLI_REV4)
59275926 spin_unlock(&pring_s4->ring_lock);
5928− spin_unlock(&lpfc_cmd->buf_lock);
5929− spin_unlock_irqrestore(&phba->hbalock, flags);
5927+ spin_unlock(&phba->hbalock);
5928+ spin_unlock_irqrestore(&lpfc_cmd->buf_lock, flags);
59305929 goto wait_for_cmpl;
59315930 }
59325931
@@ -5947,15 +5946,13 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) · 14 unmodified lines
59475946 if (ret_val != IOCB_SUCCESS) {
59485947 /* Indicate the IO is not being aborted by the driver. */
59495948 lpfc_cmd->waitq = NULL;
5950− spin_unlock(&lpfc_cmd->buf_lock);
5951− spin_unlock_irqrestore(&phba->hbalock, flags);
59525949 ret = FAILED;
5953− goto out;
5950+ goto out_unlock_hba;
59545951 }
59555952
59565953 /* no longer need the lock after this point */
5957− spin_unlock(&lpfc_cmd->buf_lock);
5958− spin_unlock_irqrestore(&phba->hbalock, flags);
5954+ spin_unlock(&phba->hbalock);
5955+ spin_unlock_irqrestore(&lpfc_cmd->buf_lock, flags);
59595956
59605957 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
59615958 lpfc_sli_handle_fast_ring_event(phba,
@@ -5990,10 +5987,9 @@ wait_for_cmpl: · 28 unmodified lines
59905987 out_unlock_ring:
59915988 if (phba->sli_rev == LPFC_SLI_REV4)
59925989 spin_unlock(&pring_s4->ring_lock);
5993−out_unlock_buf:
5994− spin_unlock(&lpfc_cmd->buf_lock);
5995−out_unlock:
5996− spin_unlock_irqrestore(&phba->hbalock, flags);
5990+out_unlock_hba:
5991+ spin_unlock(&phba->hbalock);
5992+ spin_unlock_irqrestore(&lpfc_cmd->buf_lock, flags);
59975993 out:
59985994 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
59995995 "0749 SCSI Layer I/O Abort Request Status x%x ID %d "
drivers/scsi/lpfc/lpfc_sli.c+129−141
@@ -1254,19 +1254,19 @@ __lpfc_sli_get_els_sglq(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq) · 1253 unmodified lines
12541254
12551255 cmnd = get_job_cmnd(phba, piocbq);
12561256
1257− if (piocbq->cmd_flag & LPFC_IO_FCP) {
1258− lpfc_cmd = (struct lpfc_io_buf *) piocbq->context1;
1257+ if (piocbq->cmd_flag & LPFC_IO_FCP) {
1258+ lpfc_cmd = piocbq->io_buf;
12591259 ndlp = lpfc_cmd->rdata->pnode;
12601260 } else if ((cmnd == CMD_GEN_REQUEST64_CR) &&
12611261 !(piocbq->cmd_flag & LPFC_IO_LIBDFC)) {
1262− ndlp = piocbq->context_un.ndlp;
1262+ ndlp = piocbq->ndlp;
12631263 } else if (piocbq->cmd_flag & LPFC_IO_LIBDFC) {
12641264 if (piocbq->cmd_flag & LPFC_IO_LOOPBACK)
12651265 ndlp = NULL;
12661266 else
1267− ndlp = piocbq->context_un.ndlp;
1267+ ndlp = piocbq->ndlp;
12681268 } else {
1269− ndlp = piocbq->context1;
1269+ ndlp = piocbq->ndlp;
12701270 }
12711271
12721272 spin_lock(&phba->sli4_hba.sgl_list_lock);
@@ -1373,7 +1373,7 @@ static void · 100 unmodified lines
13731373 __lpfc_sli_release_iocbq_s4(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
13741374 {
13751375 struct lpfc_sglq *sglq;
1376− size_t start_clean = offsetof(struct lpfc_iocbq, iocb);
1376+ size_t start_clean = offsetof(struct lpfc_iocbq, wqe);
13771377 unsigned long iflag = 0;
13781378 struct lpfc_sli_ring *pring;
13791379
@@ -1996,9 +1996,9 @@ initpath: · 616 unmodified lines
19961996
19971997 sync_buf->vport = phba->pport;
19981998 sync_buf->cmd_cmpl = lpfc_cmf_sync_cmpl;
1999− sync_buf->context1 = NULL;
2000− sync_buf->context2 = NULL;
2001− sync_buf->context3 = NULL;
1999+ sync_buf->cmd_dmabuf = NULL;
2000+ sync_buf->rsp_dmabuf = NULL;
2001+ sync_buf->bpl_dmabuf = NULL;
20022002 sync_buf->sli4_xritag = NO_XRI;
20032003
20042004 sync_buf->cmd_flag |= LPFC_IO_CMF;
@@ -2848,19 +2848,11 @@ void · 843 unmodified lines
28482848 lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
28492849 {
28502850 struct lpfc_vport *vport = pmb->vport;
2851− struct lpfc_dmabuf *mp;
28522851 struct lpfc_nodelist *ndlp;
28532852 struct Scsi_Host *shost;
28542853 uint16_t rpi, vpi;
28552854 int rc;
28562855
2857− mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);
2858−
2859− if (mp) {
2860− lpfc_mbuf_free(phba, mp->virt, mp->phys);
2861− kfree(mp);
2862− }
2863−
28642856 /*
28652857 * If a REG_LOGIN succeeded after node is destroyed or node
28662858 * is in re-discovery driver need to cleanup the RPI.
@@ -2893,8 +2885,6 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 26 unmodified lines
28932885 if (pmb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
28942886 ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
28952887 lpfc_nlp_put(ndlp);
2896− pmb->ctx_buf = NULL;
2897− pmb->ctx_ndlp = NULL;
28982888 }
28992889
29002890 if (pmb->u.mb.mbxCommand == MBX_UNREG_LOGIN) {
@@ -2945,7 +2935,7 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 44 unmodified lines
29452935 if (bf_get(lpfc_mqe_command, &pmb->u.mqe) == MBX_SLI4_CONFIG)
29462936 lpfc_sli4_mbox_cmd_free(phba, pmb);
29472937 else
2948− mempool_free(pmb, phba->mbox_mem_pool);
2938+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
29492939 }
29502940 /**
29512941 * lpfc_sli4_unreg_rpi_cmpl_clr - mailbox completion handler
@@ -3197,7 +3187,7 @@ lpfc_nvme_unsol_ls_handler(struct lpfc_hba *phba, struct lpfc_iocbq *piocb) · 245 unmodified lines
31973187 uint32_t oxid, sid, did, fctl, size;
31983188 int ret = 1;
31993189
3200− d_buf = piocb->context2;
3190+ d_buf = piocb->cmd_dmabuf;
32013191
32023192 nvmebuf = container_of(d_buf, struct hbq_dmabuf, dbuf);
32033193 fc_hdr = nvmebuf->hbuf.virt;
@@ -3478,9 +3468,9 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 274 unmodified lines
34783468
34793469 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {
34803470 if (irsp->ulpBdeCount != 0) {
3481− saveq->context2 = lpfc_sli_get_buff(phba, pring,
3471+ saveq->cmd_dmabuf = lpfc_sli_get_buff(phba, pring,
34823472 irsp->un.ulpWord[3]);
3483− if (!saveq->context2)
3473+ if (!saveq->cmd_dmabuf)
34843474 lpfc_printf_log(phba,
34853475 KERN_ERR,
34863476 LOG_SLI,
@@ -3490,9 +3480,9 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 3 unmodified lines
34903480 irsp->un.ulpWord[3]);
34913481 }
34923482 if (irsp->ulpBdeCount == 2) {
3493− saveq->context3 = lpfc_sli_get_buff(phba, pring,
3483+ saveq->bpl_dmabuf = lpfc_sli_get_buff(phba, pring,
34943484 irsp->unsli3.sli3Words[7]);
3495− if (!saveq->context3)
3485+ if (!saveq->bpl_dmabuf)
34963486 lpfc_printf_log(phba,
34973487 KERN_ERR,
34983488 LOG_SLI,
@@ -3504,10 +3494,10 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 5 unmodified lines
35043494 list_for_each_entry(iocbq, &saveq->list, list) {
35053495 irsp = &iocbq->iocb;
35063496 if (irsp->ulpBdeCount != 0) {
3507− iocbq->context2 = lpfc_sli_get_buff(phba,
3497+ iocbq->cmd_dmabuf = lpfc_sli_get_buff(phba,
35083498 pring,
35093499 irsp->un.ulpWord[3]);
3510− if (!iocbq->context2)
3500+ if (!iocbq->cmd_dmabuf)
35113501 lpfc_printf_log(phba,
35123502 KERN_ERR,
35133503 LOG_SLI,
@@ -3517,10 +3507,10 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 3 unmodified lines
35173507 irsp->un.ulpWord[3]);
35183508 }
35193509 if (irsp->ulpBdeCount == 2) {
3520− iocbq->context3 = lpfc_sli_get_buff(phba,
3510+ iocbq->bpl_dmabuf = lpfc_sli_get_buff(phba,
35213511 pring,
35223512 irsp->unsli3.sli3Words[7]);
3523− if (!iocbq->context3)
3513+ if (!iocbq->bpl_dmabuf)
35243514 lpfc_printf_log(phba,
35253515 KERN_ERR,
35263516 LOG_SLI,
@@ -3534,12 +3524,12 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 7 unmodified lines
35343524 } else {
35353525 paddr = getPaddr(irsp->un.cont64[0].addrHigh,
35363526 irsp->un.cont64[0].addrLow);
3537− saveq->context2 = lpfc_sli_ringpostbuf_get(phba, pring,
3527+ saveq->cmd_dmabuf = lpfc_sli_ringpostbuf_get(phba, pring,
35383528 paddr);
35393529 if (irsp->ulpBdeCount == 2) {
35403530 paddr = getPaddr(irsp->un.cont64[1].addrHigh,
35413531 irsp->un.cont64[1].addrLow);
3542− saveq->context3 = lpfc_sli_ringpostbuf_get(phba,
3532+ saveq->bpl_dmabuf = lpfc_sli_ringpostbuf_get(phba,
35433533 pring,
35443534 paddr);
35453535 }
@@ -3717,7 +3707,6 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 171 unmodified lines
37173707 struct lpfc_iocbq *saveq)
37183708 {
37193709 struct lpfc_iocbq *cmdiocbp;
3720− int rc = 1;
37213710 unsigned long iflag;
37223711 u32 ulp_command, ulp_status, ulp_word4, ulp_context, iotag;
37233712
@@ -3857,7 +3846,7 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 133 unmodified lines
38573846 }
38583847 }
38593848
3860− return rc;
3849+ return 1;
38613850 }
38623851
38633852 /**
@@ -5275,6 +5264,7 @@ lpfc_sli_brdrestart_s4(struct lpfc_hba *phba) · 1411 unmodified lines
52755264 phba->pport->stopped = 0;
52765265 phba->link_state = LPFC_INIT_START;
52775266 phba->hba_flag = 0;
5267+ phba->sli4_hba.fawwpn_flag = 0;
52785268 spin_unlock_irq(&phba->hbalock);
52795269
52805270 memset(&psli->lnk_stat_offsets, 0, sizeof(psli->lnk_stat_offsets));
@@ -5851,26 +5841,20 @@ lpfc_sli4_read_fcoe_params(struct lpfc_hba *phba) · 570 unmodified lines
58515841 mboxq->mcqe.trailer);
58525842
58535843 if (rc) {
5854− lpfc_mbuf_free(phba, mp->virt, mp->phys);
5855− kfree(mp);
58565844 rc = -EIO;
58575845 goto out_free_mboxq;
58585846 }
58595847 data_length = mqe->un.mb_words[5];
58605848 if (data_length > DMP_RGN23_SIZE) {
5861− lpfc_mbuf_free(phba, mp->virt, mp->phys);
5862− kfree(mp);
58635849 rc = -EIO;
58645850 goto out_free_mboxq;
58655851 }
58665852
58675853 lpfc_parse_fcoe_conf(phba, mp->virt, data_length);
5868− lpfc_mbuf_free(phba, mp->virt, mp->phys);
5869− kfree(mp);
58705854 rc = 0;
58715855
58725856 out_free_mboxq:
5873− mempool_free(mboxq, phba->mbox_mem_pool);
5857+ lpfc_mbox_rsrc_cleanup(phba, mboxq, MBOX_THD_UNLOCKED);
58745858 return rc;
58755859 }
58765860
@@ -7994,10 +7978,6 @@ lpfc_cmf_setup(struct lpfc_hba *phba) · 2117 unmodified lines
79947978
79957979 sli4_params = &phba->sli4_hba.pc_sli4_params;
79967980
7997− /* Are we forcing MI off via module parameter? */
7998− if (!phba->cfg_enable_mi)
7999− sli4_params->mi_ver = 0;
8000−
80017981 /* Always try to enable MI feature if we can */
80027982 if (sli4_params->mi_ver) {
80037983 lpfc_set_features(phba, mboxq, LPFC_SET_ENABLE_MI);
@@ -8543,8 +8523,9 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba) · 539 unmodified lines
85438523 }
85448524
85458525 /*
8546− * This memory was allocated by the lpfc_read_sparam routine. Release
8547− * it to the mbuf pool.
8526+ * This memory was allocated by the lpfc_read_sparam routine but is
8527+ * no longer needed. It is released and ctx_buf NULLed to prevent
8528+ * unintended pointer access as the mbox is reused.
85488529 */
85498530 lpfc_mbuf_free(phba, mp->virt, mp->phys);
85508531 kfree(mp);
@@ -8864,6 +8845,9 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba) · 313 unmodified lines
88648845 }
88658846 mempool_free(mboxq, phba->mbox_mem_pool);
88668847
8848+ /* Enable RAS FW log support */
8849+ lpfc_sli4_ras_setup(phba);
8850+
88678851 phba->hba_flag |= HBA_SETUP;
88688852 return rc;
88698853
@@ -10343,8 +10327,7 @@ __lpfc_sli_issue_fcp_io_s4(struct lpfc_hba *phba, uint32_t ring_number, · 1473 unmodified lines
1034310327 struct lpfc_iocbq *piocb, uint32_t flag)
1034410328 {
1034510329 int rc;
10346− struct lpfc_io_buf *lpfc_cmd =
10347− (struct lpfc_io_buf *)piocb->context1;
10330+ struct lpfc_io_buf *lpfc_cmd = piocb->io_buf;
1034810331
1034910332 lpfc_prep_embed_io(phba, lpfc_cmd);
1035010333 rc = lpfc_sli4_issue_wqe(phba, lpfc_cmd->hdwq, piocb);
@@ -10394,11 +10377,11 @@ lpfc_prep_embed_io(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) · 43 unmodified lines
1039410377
1039510378 /* add the VMID tags as per switch response */
1039610379 if (unlikely(piocb->cmd_flag & LPFC_IO_VMID)) {
10397− if (phba->pport->vmid_priority_tagging) {
10380+ if (phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO) {
1039810381 bf_set(wqe_ccpe, &wqe->fcp_iwrite.wqe_com, 1);
1039910382 bf_set(wqe_ccp, &wqe->fcp_iwrite.wqe_com,
1040010383 (piocb->vmid_tag.cs_ctl_vmid));
10401− } else {
10384+ } else if (phba->cfg_vmid_app_header) {
1040210385 bf_set(wqe_appid, &wqe->fcp_iwrite.wqe_com, 1);
1040310386 bf_set(wqe_wqes, &wqe->fcp_iwrite.wqe_com, 1);
1040410387 wqe->words[31] = piocb->vmid_tag.app_id;
@@ -10599,6 +10582,7 @@ __lpfc_sli_prep_els_req_rsp_s4(struct lpfc_iocbq *cmdiocbq, · 194 unmodified lines
1059910582 struct lpfc_hba *phba = vport->phba;
1060010583 union lpfc_wqe128 *wqe;
1060110584 struct ulp_bde64_le *bde;
10585+ u8 els_id;
1060210586
1060310587 wqe = &cmdiocbq->wqe;
1060410588 memset(wqe, 0, sizeof(*wqe));
@@ -10611,7 +10595,7 @@ __lpfc_sli_prep_els_req_rsp_s4(struct lpfc_iocbq *cmdiocbq, · 6 unmodified lines
1061110595 bde->type_size |= cpu_to_le32(ULP_BDE64_TYPE_BDE_64);
1061210596
1061310597 if (expect_rsp) {
10614− bf_set(wqe_cmnd, &wqe->els_req.wqe_com, CMD_ELS_REQUEST64_CR);
10598+ bf_set(wqe_cmnd, &wqe->els_req.wqe_com, CMD_ELS_REQUEST64_WQE);
1061510599
1061610600 /* Transfer length */
1061710601 wqe->els_req.payload_len = cmd_size;
@@ -10619,6 +10603,30 @@ __lpfc_sli_prep_els_req_rsp_s4(struct lpfc_iocbq *cmdiocbq, · 1 unmodified line
1061910603
1062010604 /* DID */
1062110605 bf_set(wqe_els_did, &wqe->els_req.wqe_dest, did);
10606+
10607+ /* Word 11 - ELS_ID */
10608+ switch (elscmd) {
10609+ case ELS_CMD_PLOGI:
10610+ els_id = LPFC_ELS_ID_PLOGI;
10611+ break;
10612+ case ELS_CMD_FLOGI:
10613+ els_id = LPFC_ELS_ID_FLOGI;
10614+ break;
10615+ case ELS_CMD_LOGO:
10616+ els_id = LPFC_ELS_ID_LOGO;
10617+ break;
10618+ case ELS_CMD_FDISC:
10619+ if (!vport->fc_myDID) {
10620+ els_id = LPFC_ELS_ID_FDISC;
10621+ break;
10622+ }
10623+ fallthrough;
10624+ default:
10625+ els_id = LPFC_ELS_ID_DEFAULT;
10626+ break;
10627+ }
10628+
10629+ bf_set(wqe_els_id, &wqe->els_req.wqe_com, els_id);
1062210630 } else {
1062310631 /* DID */
1062410632 bf_set(wqe_els_did, &wqe->xmit_els_rsp.wqe_dest, did);
@@ -10627,7 +10635,7 @@ __lpfc_sli_prep_els_req_rsp_s4(struct lpfc_iocbq *cmdiocbq, · 2 unmodified lines
1062710635 wqe->xmit_els_rsp.response_payload_len = cmd_size;
1062810636
1062910637 bf_set(wqe_cmnd, &wqe->xmit_els_rsp.wqe_com,
10630− CMD_XMIT_ELS_RSP64_CX);
10638+ CMD_XMIT_ELS_RSP64_WQE);
1063110639 }
1063210640
1063310641 bf_set(wqe_tmo, &wqe->generic.wqe_com, tmo);
@@ -10643,7 +10651,7 @@ __lpfc_sli_prep_els_req_rsp_s4(struct lpfc_iocbq *cmdiocbq, · 9 unmodified lines
1064310651 if (expect_rsp) {
1064410652 bf_set(els_req64_sid, &wqe->els_req, vport->fc_myDID);
1064510653
10646− /* For ELS_REQUEST64_CR, use the VPI by default */
10654+ /* For ELS_REQUEST64_WQE, use the VPI by default */
1064710655 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com,
1064810656 phba->vpi_ids[vport->vpi]);
1064910657 }
@@ -10800,24 +10808,15 @@ __lpfc_sli_prep_xmit_seq64_s4(struct lpfc_iocbq *cmdiocbq, · 150 unmodified lines
1080010808 {
1080110809 union lpfc_wqe128 *wqe;
1080210810 struct ulp_bde64 *bpl;
10803− struct ulp_bde64_le *bde;
1080410811
1080510812 wqe = &cmdiocbq->wqe;
1080610813 memset(wqe, 0, sizeof(*wqe));
1080710814
1080810815 /* Words 0 - 2 */
1080910816 bpl = (struct ulp_bde64 *)bmp->virt;
10810− if (cmdiocbq->cmd_flag & (LPFC_IO_LIBDFC | LPFC_IO_LOOPBACK)) {
10811− wqe->xmit_sequence.bde.addrHigh = bpl->addrHigh;
10812− wqe->xmit_sequence.bde.addrLow = bpl->addrLow;
10813− wqe->xmit_sequence.bde.tus.w = bpl->tus.w;
10814− } else {
10815− bde = (struct ulp_bde64_le *)&wqe->xmit_sequence.bde;
10816− bde->addr_low = cpu_to_le32(putPaddrLow(bmp->phys));
10817− bde->addr_high = cpu_to_le32(putPaddrHigh(bmp->phys));
10818− bde->type_size = cpu_to_le32(bpl->tus.f.bdeSize);
10819− bde->type_size |= cpu_to_le32(ULP_BDE64_TYPE_BDE_64);
10820− }
10817+ wqe->xmit_sequence.bde.addrHigh = bpl->addrHigh;
10818+ wqe->xmit_sequence.bde.addrLow = bpl->addrLow;
10819+ wqe->xmit_sequence.bde.tus.w = bpl->tus.w;
1082110820
1082210821 /* Word 5 */
1082310822 bf_set(wqe_ls, &wqe->xmit_sequence.wge_ctl, last_seq);
@@ -10990,7 +10989,7 @@ lpfc_sli4_calc_ring(struct lpfc_hba *phba, struct lpfc_iocbq *piocb) · 166 unmodified lines
1099010989 * be setup based on what work queue we used.
1099110990 */
1099210991 if (!(piocb->cmd_flag & LPFC_USE_FCPWQIDX)) {
10993− lpfc_cmd = (struct lpfc_io_buf *)piocb->context1;
10992+ lpfc_cmd = piocb->io_buf;
1099410993 piocb->hba_wqidx = lpfc_cmd->hdwq_no;
1099510994 }
1099610995 return phba->sli4_hba.hdwq[piocb->hba_wqidx].io_wq->pring;
@@ -12064,8 +12063,9 @@ void · 1067 unmodified lines
1206412063 lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1206512064 struct lpfc_iocbq *rspiocb)
1206612065 {
12067− struct lpfc_nodelist *ndlp = NULL;
12066+ struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
1206812067 IOCB_t *irsp;
12068+ LPFC_MBOXQ_t *mbox;
1206912069 u32 ulp_command, ulp_status, ulp_word4, iotag;
1207012070
1207112071 ulp_command = get_job_cmnd(phba, cmdiocb);
@@ -12077,25 +12077,32 @@ lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 5 unmodified lines
1207712077 } else {
1207812078 irsp = &rspiocb->iocb;
1207912079 iotag = irsp->ulpIoTag;
12080+
12081+ /* It is possible a PLOGI_RJT for NPIV ports to get aborted.
12082+ * The MBX_REG_LOGIN64 mbox command is freed back to the
12083+ * mbox_mem_pool here.
12084+ */
12085+ if (cmdiocb->context_un.mbox) {
12086+ mbox = cmdiocb->context_un.mbox;
12087+ lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
12088+ cmdiocb->context_un.mbox = NULL;
12089+ }
1208012090 }
1208112091
1208212092 /* ELS cmd tag <ulpIoTag> completes */
1208312093 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
1208412094 "0139 Ignoring ELS cmd code x%x completion Data: "
12085− "x%x x%x x%x\n",
12086− ulp_command, ulp_status, ulp_word4, iotag);
12087−
12095+ "x%x x%x x%x x%px\n",
12096+ ulp_command, ulp_status, ulp_word4, iotag,
12097+ cmdiocb->ndlp);
1208812098 /*
1208912099 * Deref the ndlp after free_iocb. sli_release_iocb will access the ndlp
1209012100 * if exchange is busy.
1209112101 */
12092− if (ulp_command == CMD_GEN_REQUEST64_CR) {
12093− ndlp = cmdiocb->context_un.ndlp;
12102+ if (ulp_command == CMD_GEN_REQUEST64_CR)
1209412103 lpfc_ct_free_iocb(phba, cmdiocb);
12095− } else {
12096− ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
12104+ else
1209712105 lpfc_els_free_iocb(phba, cmdiocb);
12098− }
1209912106
1210012107 lpfc_nlp_put(ndlp);
1210112108 }
@@ -12176,7 +12183,7 @@ lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 74 unmodified lines
1217612183 } else {
1217712184 iotag = cmdiocb->iocb.ulpIoTag;
1217812185 if (pring->ringno == LPFC_ELS_RING) {
12179− ndlp = (struct lpfc_nodelist *)(cmdiocb->context1);
12186+ ndlp = cmdiocb->ndlp;
1218012187 ulp_context = ndlp->nlp_rpi;
1218112188 } else {
1218212189 ulp_context = cmdiocb->iocb.ulpContext;
@@ -12185,7 +12192,8 @@ lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 2 unmodified lines
1218512192
1218612193 if (phba->link_state < LPFC_LINK_UP ||
1218712194 (phba->sli_rev == LPFC_SLI_REV4 &&
12188− phba->sli4_hba.link_state.status == LPFC_FC_LA_TYPE_LINK_DOWN))
12195+ phba->sli4_hba.link_state.status == LPFC_FC_LA_TYPE_LINK_DOWN) ||
12196+ (phba->link_flag & LS_EXTERNAL_LOOPBACK))
1218912197 ia = true;
1219012198 else
1219112199 ia = false;
@@ -12634,7 +12642,7 @@ lpfc_sli_abort_taskmgmt(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, · 442 unmodified lines
1263412642 } else {
1263512643 iotag = iocbq->iocb.ulpIoTag;
1263612644 if (pring->ringno == LPFC_ELS_RING) {
12637− ndlp = (struct lpfc_nodelist *)(iocbq->context1);
12645+ ndlp = iocbq->ndlp;
1263812646 ulp_context = ndlp->nlp_rpi;
1263912647 } else {
1264012648 ulp_context = iocbq->iocb.ulpContext;
@@ -12644,7 +12652,8 @@ lpfc_sli_abort_taskmgmt(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, · 3 unmodified lines
1264412652 ndlp = lpfc_cmd->rdata->pnode;
1264512653
1264612654 if (lpfc_is_link_up(phba) &&
12647− (ndlp && ndlp->nlp_state == NLP_STE_MAPPED_NODE))
12655+ (ndlp && ndlp->nlp_state == NLP_STE_MAPPED_NODE) &&
12656+ !(phba->link_flag & LS_EXTERNAL_LOOPBACK))
1264812657 ia = false;
1264912658 else
1265012659 ia = true;
@@ -12739,8 +12748,8 @@ lpfc_sli_wake_iocb_wait(struct lpfc_hba *phba, · 88 unmodified lines
1273912748
1274012749 /* Copy the contents of the local rspiocb into the caller's buffer. */
1274112750 cmdiocbq->cmd_flag |= LPFC_IO_WAKE;
12742− if (cmdiocbq->context2 && rspiocbq)
12743− memcpy((char *)cmdiocbq->context2 + offset,
12751+ if (cmdiocbq->rsp_iocb && rspiocbq)
12752+ memcpy((char *)cmdiocbq->rsp_iocb + offset,
1274412753 (char *)rspiocbq + offset, sizeof(*rspiocbq) - offset);
1274512754
1274612755 /* Set the exchange busy flag for task management commands */
@@ -12848,13 +12857,13 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba, · 101 unmodified lines
1284812857 } else
1284912858 pring = &phba->sli.sli3_ring[ring_number];
1285012859 /*
12851− * If the caller has provided a response iocbq buffer, then context2
12860+ * If the caller has provided a response iocbq buffer, then rsp_iocb
1285212861 * is NULL or its an error.
1285312862 */
1285412863 if (prspiocbq) {
12855− if (piocb->context2)
12864+ if (piocb->rsp_iocb)
1285612865 return IOCB_ERROR;
12857− piocb->context2 = prspiocbq;
12866+ piocb->rsp_iocb = prspiocbq;
1285812867 }
1285912868
1286012869 piocb->wait_cmd_cmpl = piocb->cmd_cmpl;
@@ -12938,7 +12947,7 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba, · 77 unmodified lines
1293812947 }
1293912948
1294012949 if (prspiocbq)
12941− piocb->context2 = NULL;
12950+ piocb->rsp_iocb = NULL;
1294212951
1294312952 piocb->context_un.wait_queue = NULL;
1294412953 piocb->cmd_cmpl = NULL;
@@ -15732,7 +15741,6 @@ lpfc_modify_hba_eq_delay(struct lpfc_hba *phba, uint32_t startq, · 2787 unmodified lines
1573215741
1573315742 mbox->vport = phba->pport;
1573415743 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
15735− mbox->ctx_buf = NULL;
1573615744 mbox->ctx_ndlp = NULL;
1573715745 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
1573815746 shdr = (union lpfc_sli4_cfg_shdr *) &eq_delay->header.cfg_shdr;
@@ -18107,7 +18115,6 @@ lpfc_fc_frame_check(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr) · 2368 unmodified lines
1810718115 case FC_RCTL_ELS_REP: /* extended link services reply */
1810818116 case FC_RCTL_ELS4_REQ: /* FC-4 ELS request */
1810918117 case FC_RCTL_ELS4_REP: /* FC-4 ELS reply */
18110− case FC_RCTL_BA_NOP: /* basic link service NOP */
1811118118 case FC_RCTL_BA_ABTS: /* basic link service abort */
1811218119 case FC_RCTL_BA_RMC: /* remove connection */
1811318120 case FC_RCTL_BA_ACC: /* basic accept */
@@ -18128,6 +18135,7 @@ lpfc_fc_frame_check(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr) · 14 unmodified lines
1812818135 fc_vft_hdr = (struct fc_vft_header *)fc_hdr;
1812918136 fc_hdr = &((struct fc_frame_header *)fc_vft_hdr)[1];
1813018137 return lpfc_fc_frame_check(phba, fc_hdr);
18138+ case FC_RCTL_BA_NOP: /* basic link service NOP */
1813118139 default:
1813218140 goto drop;
1813318141 }
@@ -18512,11 +18520,8 @@ lpfc_sli4_seq_abort_rsp_cmpl(struct lpfc_hba *phba, · 378 unmodified lines
1851218520 struct lpfc_iocbq *cmd_iocbq,
1851318521 struct lpfc_iocbq *rsp_iocbq)
1851418522 {
18515− struct lpfc_nodelist *ndlp;
18516−
1851718523 if (cmd_iocbq) {
18518− ndlp = (struct lpfc_nodelist *)cmd_iocbq->context1;
18519− lpfc_nlp_put(ndlp);
18524+ lpfc_nlp_put(cmd_iocbq->ndlp);
1852018525 lpfc_sli_release_iocbq(phba, cmd_iocbq);
1852118526 }
1852218527
@@ -18600,8 +18605,8 @@ lpfc_sli4_seq_abort_rsp(struct lpfc_vport *vport, · 77 unmodified lines
1860018605 /* Extract the F_CTL field from FC_HDR */
1860118606 fctl = sli4_fctl_from_fc_hdr(fc_hdr);
1860218607
18603− ctiocb->context1 = lpfc_nlp_get(ndlp);
18604− if (!ctiocb->context1) {
18608+ ctiocb->ndlp = lpfc_nlp_get(ndlp);
18609+ if (!ctiocb->ndlp) {
1860518610 lpfc_sli_release_iocbq(phba, ctiocb);
1860618611 return;
1860718612 }
@@ -18677,13 +18682,11 @@ lpfc_sli4_seq_abort_rsp(struct lpfc_vport *vport, · 69 unmodified lines
1867718682 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]);
1867818683 bf_set(wqe_cmnd, &icmd->generic.wqe_com, CMD_XMIT_BLS_RSP64_CX);
1867918684
18680−
1868118685 /* Xmit CT abts response on exchange <xid> */
1868218686 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1868318687 "1200 Send BLS cmd x%x on oxid x%x Data: x%x\n",
1868418688 ctiocb->abort_rctl, oxid, phba->link_state);
1868518689
18686− lpfc_sli_prep_wqe(phba, ctiocb);
1868718690 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, ctiocb, 0);
1868818691 if (rc == IOCB_ERROR) {
1868918692 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
@@ -18692,7 +18695,7 @@ lpfc_sli4_seq_abort_rsp(struct lpfc_vport *vport, · 2 unmodified lines
1869218695 ctiocb->abort_rctl, oxid,
1869318696 phba->link_state);
1869418697 lpfc_nlp_put(ndlp);
18695− ctiocb->context1 = NULL;
18698+ ctiocb->ndlp = NULL;
1869618699 lpfc_sli_release_iocbq(phba, ctiocb);
1869718700 }
1869818701 }
@@ -18844,8 +18847,8 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf) · 145 unmodified lines
1884418847 tot_len = bf_get(lpfc_rcqe_length,
1884518848 &seq_dmabuf->cq_event.cqe.rcqe_cmpl);
1884618849
18847− first_iocbq->context2 = &seq_dmabuf->dbuf;
18848− first_iocbq->context3 = NULL;
18850+ first_iocbq->cmd_dmabuf = &seq_dmabuf->dbuf;
18851+ first_iocbq->bpl_dmabuf = NULL;
1884918852 /* Keep track of the BDE count */
1885018853 first_iocbq->wcqe_cmpl.word3 = 1;
1885118854
@@ -18869,8 +18872,8 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf) · 17 unmodified lines
1886918872 lpfc_in_buf_free(vport->phba, d_buf);
1887018873 continue;
1887118874 }
18872− if (!iocbq->context3) {
18873− iocbq->context3 = d_buf;
18875+ if (!iocbq->bpl_dmabuf) {
18876+ iocbq->bpl_dmabuf = d_buf;
1887418877 iocbq->wcqe_cmpl.word3++;
1887518878 /* We need to get the size out of the right CQE */
1887618879 hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
@@ -18896,8 +18899,8 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf) · 19 unmodified lines
1889618899 hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
1889718900 len = bf_get(lpfc_rcqe_length,
1889818901 &hbq_buf->cq_event.cqe.rcqe_cmpl);
18899− iocbq->context2 = d_buf;
18900− iocbq->context3 = NULL;
18902+ iocbq->cmd_dmabuf = d_buf;
18903+ iocbq->bpl_dmabuf = NULL;
1890118904 iocbq->wcqe_cmpl.word3 = 1;
1890218905
1890318906 if (len > LPFC_DATA_BUF_SIZE)
@@ -18942,12 +18945,14 @@ lpfc_sli4_send_seq_to_ulp(struct lpfc_vport *vport, · 38 unmodified lines
1894218945 if (!lpfc_complete_unsol_iocb(phba,
1894318946 phba->sli4_hba.els_wq->pring,
1894418947 iocbq, fc_hdr->fh_r_ctl,
18945− fc_hdr->fh_type))
18948+ fc_hdr->fh_type)) {
1894618949 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
1894718950 "2540 Ring %d handler: unexpected Rctl "
1894818951 "x%x Type x%x received\n",
1894918952 LPFC_ELS_RING,
1895018953 fc_hdr->fh_r_ctl, fc_hdr->fh_type);
18954+ lpfc_in_buf_free(phba, &seq_dmabuf->dbuf);
18955+ }
1895118956
1895218957 /* Free iocb created in lpfc_prep_seq */
1895318958 list_for_each_entry_safe(curr_iocb, next_iocb,
@@ -18962,7 +18967,7 @@ static void · 8 unmodified lines
1896218967 lpfc_sli4_mds_loopback_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1896318968 struct lpfc_iocbq *rspiocb)
1896418969 {
18965− struct lpfc_dmabuf *pcmd = cmdiocb->context2;
18970+ struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf;
1896618971
1896718972 if (pcmd && pcmd->virt)
1896818973 dma_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys);
@@ -19013,7 +19018,7 @@ lpfc_sli4_handle_mds_loopback(struct lpfc_vport *vport, · 44 unmodified lines
1901319018 /* copyin the payload */
1901419019 memcpy(pcmd->virt, dmabuf->dbuf.virt, frame_len);
1901519020
19016− iocbq->context2 = pcmd;
19021+ iocbq->cmd_dmabuf = pcmd;
1901719022 iocbq->vport = vport;
1901819023 iocbq->cmd_flag &= ~LPFC_FIP_ELS_ID_MASK;
1901919024 iocbq->cmd_flag |= LPFC_USE_FCPWQIDX;
@@ -20332,11 +20337,7 @@ lpfc_sli4_get_config_region23(struct lpfc_hba *phba, char *rgn23_data) · 1312 unmodified lines
2033220337 }
2033320338 lpfc_sli_pcimem_bcopy((char *)mp->virt, rgn23_data, data_length);
2033420339 out:
20335− mempool_free(mboxq, phba->mbox_mem_pool);
20336− if (mp) {
20337− lpfc_mbuf_free(phba, mp->virt, mp->phys);
20338− kfree(mp);
20339− }
20340+ lpfc_mbox_rsrc_cleanup(phba, mboxq, MBOX_THD_UNLOCKED);
2034020341 return data_length;
2034120342 }
2034220343
@@ -20651,7 +20652,6 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport) · 308 unmodified lines
2065120652 {
2065220653 struct lpfc_hba *phba = vport->phba;
2065320654 LPFC_MBOXQ_t *mb, *nextmb;
20654− struct lpfc_dmabuf *mp;
2065520655 struct lpfc_nodelist *ndlp;
2065620656 struct lpfc_nodelist *act_mbx_ndlp = NULL;
2065720657 LIST_HEAD(mbox_cmd_list);
@@ -20677,8 +20677,12 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport) · 19 unmodified lines
2067720677 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
2067820678 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
2067920679 act_mbx_ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp;
20680− /* Put reference count for delayed processing */
20680+
20681+ /* This reference is local to this routine. The
20682+ * reference is removed at routine exit.
20683+ */
2068120684 act_mbx_ndlp = lpfc_nlp_get(act_mbx_ndlp);
20685+
2068220686 /* Unregister the RPI when mailbox complete */
2068320687 mb->mbox_flag |= LPFC_MBX_IMED_UNREG;
2068420688 }
@@ -20721,12 +20725,6 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport) · 36 unmodified lines
2072120725 while (!list_empty(&mbox_cmd_list)) {
2072220726 list_remove_head(&mbox_cmd_list, mb, LPFC_MBOXQ_t, list);
2072320727 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
20724− mp = (struct lpfc_dmabuf *)(mb->ctx_buf);
20725− if (mp) {
20726− __lpfc_mbuf_free(phba, mp->virt, mp->phys);
20727− kfree(mp);
20728− }
20729− mb->ctx_buf = NULL;
2073020728 ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp;
2073120729 mb->ctx_ndlp = NULL;
2073220730 if (ndlp) {
@@ -20736,7 +20734,7 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport) · 3 unmodified lines
2073620734 lpfc_nlp_put(ndlp);
2073720735 }
2073820736 }
20739− mempool_free(mb, phba->mbox_mem_pool);
20737+ lpfc_mbox_rsrc_cleanup(phba, mb, MBOX_THD_UNLOCKED);
2074020738 }
2074120739
2074220740 /* Release the ndlp with the cleaned-up active mailbox command */
@@ -20888,8 +20886,8 @@ lpfc_wqe_bpl2sgl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeq, · 145 unmodified lines
2088820886 * have not been byteswapped yet so there is no
2088920887 * need to swap them back.
2089020888 */
20891− if (pwqeq->context3)
20892− dmabuf = (struct lpfc_dmabuf *)pwqeq->context3;
20889+ if (pwqeq->bpl_dmabuf)
20890+ dmabuf = pwqeq->bpl_dmabuf;
2089320891 else
2089420892 return xritag;
2089520893
@@ -21041,7 +21039,7 @@ lpfc_sli4_issue_wqe(struct lpfc_hba *phba, struct lpfc_sli4_hdw_queue *qp, · 145 unmodified lines
2104121039 wq = qp->io_wq;
2104221040 pring = wq->pring;
2104321041
21044− ctxp = pwqe->context2;
21042+ ctxp = pwqe->context_un.axchg;
2104521043 sglq = ctxp->ctxbuf->sglq;
2104621044 if (pwqe->sli4_xritag == NO_XRI) {
2104721045 pwqe->sli4_lxritag = sglq->sli4_lxritag;
@@ -21107,7 +21105,7 @@ lpfc_sli4_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 59 unmodified lines
2110721105 abtswqe = &abtsiocb->wqe;
2110821106 memset(abtswqe, 0, sizeof(*abtswqe));
2110921107
21110− if (!lpfc_is_link_up(phba))
21108+ if (!lpfc_is_link_up(phba) || (phba->link_flag & LS_EXTERNAL_LOOPBACK))
2111121109 bf_set(abort_cmd_ia, &abtswqe->abort_cmd, 1);
2111221110 bf_set(abort_cmd_criteria, &abtswqe->abort_cmd, T_XRI_TAG);
2111321111 abtswqe->abort_cmd.rsrvd5 = 0;
@@ -21883,7 +21881,6 @@ lpfc_read_object(struct lpfc_hba *phba, char *rdobject, uint32_t *datap, · 769 unmodified lines
2188321881
2188421882 mbox->vport = phba->pport;
2188521883 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
21886− mbox->ctx_buf = NULL;
2188721884 mbox->ctx_ndlp = NULL;
2188821885
2188921886 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
@@ -21920,9 +21917,12 @@ lpfc_read_object(struct lpfc_hba *phba, char *rdobject, uint32_t *datap, · 30 unmodified lines
2192021917 }
2192121918
2192221919 exit:
21920+ /* This is an embedded SLI4 mailbox with an external buffer allocated.
21921+ * Free the pcmd and then cleanup with the correct routine.
21922+ */
2192321923 lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys);
2192421924 kfree(pcmd);
21925− mempool_free(mbox, phba->mbox_mem_pool);
21925+ lpfc_sli4_mbox_cmd_free(phba, mbox);
2192621926 return byte_cnt;
2192721927 }
2192821928
@@ -22114,7 +22114,7 @@ lpfc_get_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba, · 185 unmodified lines
2211422114 return NULL;
2211522115 }
2211622116
22117− tmp->fcp_cmnd = dma_pool_alloc(phba->lpfc_cmd_rsp_buf_pool,
22117+ tmp->fcp_cmnd = dma_pool_zalloc(phba->lpfc_cmd_rsp_buf_pool,
2211822118 GFP_ATOMIC,
2211922119 &tmp->fcp_cmd_rsp_dma_handle);
2212022120
@@ -22236,8 +22236,6 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) · 115 unmodified lines
2223622236 u32 fip, abort_tag;
2223722237 struct lpfc_nodelist *ndlp = NULL;
2223822238 union lpfc_wqe128 *wqe = &job->wqe;
22239− struct lpfc_dmabuf *context2;
22240− u32 els_id = LPFC_ELS_ID_DEFAULT;
2224122239 u8 command_type = ELS_COMMAND_NON_FIP;
2224222240
2224322241 fip = phba->hba_flag & HBA_FIP_SUPPORT;
@@ -22254,21 +22252,12 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) · 10 unmodified lines
2225422252
2225522253 switch (cmnd) {
2225622254 case CMD_ELS_REQUEST64_WQE:
22257− if (job->cmd_flag & LPFC_IO_LIBDFC)
22258− ndlp = job->context_un.ndlp;
22259− else
22260− ndlp = (struct lpfc_nodelist *)job->context1;
22261−
22262− /* CCP CCPE PV PRI in word10 were set in the memcpy */
22263− if (command_type == ELS_COMMAND_FIP)
22264− els_id = ((job->cmd_flag & LPFC_FIP_ELS_ID_MASK)
22265− >> LPFC_FIP_ELS_ID_SHIFT);
22255+ ndlp = job->ndlp;
2226622256
2226722257 if_type = bf_get(lpfc_sli_intf_if_type,
2226822258 &phba->sli4_hba.sli_intf);
2226922259 if (if_type >= LPFC_SLI_INTF_IF_TYPE_2) {
22270− context2 = (struct lpfc_dmabuf *)job->context2;
22271− pcmd = (u32 *)context2->virt;
22260+ pcmd = (u32 *)job->cmd_dmabuf->virt;
2227222261 if (pcmd && (*pcmd == ELS_CMD_FLOGI ||
2227322262 *pcmd == ELS_CMD_SCR ||
2227422263 *pcmd == ELS_CMD_RDF ||
@@ -22301,7 +22290,6 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) · 26 unmodified lines
2230122290 bf_set(wqe_temp_rpi, &wqe->els_req.wqe_com,
2230222291 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]);
2230322292
22304− bf_set(wqe_els_id, &wqe->els_req.wqe_com, els_id);
2230522293 bf_set(wqe_dbde, &wqe->els_req.wqe_com, 1);
2230622294 bf_set(wqe_iod, &wqe->els_req.wqe_com, LPFC_WQE_IOD_READ);
2230722295 bf_set(wqe_qosd, &wqe->els_req.wqe_com, 1);
@@ -22309,7 +22297,7 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) · 1 unmodified line
2230922297 bf_set(wqe_ebde_cnt, &wqe->els_req.wqe_com, 0);
2231022298 break;
2231122299 case CMD_XMIT_ELS_RSP64_WQE:
22312− ndlp = (struct lpfc_nodelist *)job->context1;
22300+ ndlp = job->ndlp;
2231322301
2231422302 /* word4 */
2231522303 wqe->xmit_els_rsp.word4 = 0;
drivers/scsi/lpfc/lpfc_sli.h+24−10
@@ -35,6 +35,12 @@ typedef enum _lpfc_ctx_cmd { · 34 unmodified lines
3535 LPFC_CTX_HOST
3636 } lpfc_ctx_cmd;
3737
38+/* Enumeration to describe the thread lock context. */
39+enum lpfc_mbox_ctx {
40+ MBOX_THD_UNLOCKED,
41+ MBOX_THD_LOCKED
42+};
43+
3844 union lpfc_vmid_tag {
3945 uint32_t app_id;
4046 uint8_t cs_ctl_vmid;
@@ -77,11 +83,15 @@ struct lpfc_iocbq { · 36 unmodified lines
7783
7884 u32 unsol_rcv_len; /* Receive len in usol path */
7985
80− uint8_t num_bdes;
81− uint8_t abort_bls; /* ABTS by initiator or responder */
82− u8 abort_rctl; /* ACC or RJT flag */
83− uint8_t priority; /* OAS priority */
84− uint8_t retry; /* retry counter for IOCB cmd - if needed */
86+ /* Pack the u8's together and make them module-4. */
87+ u8 num_bdes; /* Number of BDEs */
88+ u8 abort_bls; /* ABTS by initiator or responder */
89+ u8 abort_rctl; /* ACC or RJT flag */
90+ u8 priority; /* OAS priority */
91+ u8 retry; /* retry counter for IOCB cmd - if needed */
92+ u8 rsvd1; /* Pad for u32 */
93+ u8 rsvd2; /* Pad for u32 */
94+ u8 rsvd3; /* Pad for u32 */
8595
8696 u32 cmd_flag;
8797 #define LPFC_IO_LIBDFC 1 /* libdfc iocb */
@@ -116,18 +126,22 @@ struct lpfc_iocbq { · 28 unmodified lines
116126
117127 uint32_t drvrTimeout; /* driver timeout in seconds */
118128 struct lpfc_vport *vport;/* virtual port pointer */
119− void *context1; /* caller context information */
120− void *context2; /* caller context information */
121− void *context3; /* caller context information */
129+ struct lpfc_dmabuf *cmd_dmabuf;
130+ struct lpfc_dmabuf *rsp_dmabuf;
131+ struct lpfc_dmabuf *bpl_dmabuf;
122132 uint32_t event_tag; /* LA Event tag */
123133 union {
124134 wait_queue_head_t *wait_queue;
125− struct lpfc_iocbq *rsp_iocb;
126135 struct lpfcMboxq *mbox;
127− struct lpfc_nodelist *ndlp;
128136 struct lpfc_node_rrq *rrq;
137+ struct nvmefc_ls_req *nvme_lsreq;
138+ struct lpfc_async_xchg_ctx *axchg;
139+ struct bsg_job_data *dd_data;
129140 } context_un;
130141
142+ struct lpfc_io_buf *io_buf;
143+ struct lpfc_iocbq *rsp_iocb;
144+ struct lpfc_nodelist *ndlp;
131145 union lpfc_vmid_tag vmid_tag;
132146 void (*fabric_cmd_cmpl)(struct lpfc_hba *phba, struct lpfc_iocbq *cmd,
133147 struct lpfc_iocbq *rsp);
drivers/scsi/lpfc/lpfc_sli4.h+3−0
@@ -981,6 +981,9 @@ struct lpfc_sli4_hba { · 980 unmodified lines
981981 #define lpfc_conf_trunk_port3_nd_MASK 0x1
982982 uint8_t flash_id;
983983 uint8_t asic_rev;
984+ uint16_t fawwpn_flag; /* FA-WWPN support state */
985+#define LPFC_FAWWPN_CONFIG 0x1 /* FA-PWWN is configured */
986+#define LPFC_FAWWPN_FABRIC 0x2 /* FA-PWWN success with Fabric */
984987 };
985988
986989 enum lpfc_sge_type {
drivers/scsi/lpfc/lpfc_version.h+1−1
@@ -20,7 +20,7 @@ · 19 unmodified lines
2020 * included with this package. *
2121 *******************************************************************/
2222
23−#define LPFC_DRIVER_VERSION "14.2.0.1"
23+#define LPFC_DRIVER_VERSION "14.2.0.3"
2424 #define LPFC_DRIVER_NAME "lpfc"
2525
2626 /* Used for SLI 2/3 */
drivers/scsi/lpfc/lpfc_vport.c+14−17
@@ -1,7 +1,7 @@
11 /*******************************************************************
22 * This file is part of the Emulex Linux Device Driver for *
33 * Fibre Channel Host Bus Adapters. *
4− * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term *
4+ * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
55 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
66 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
77 * EMULEX and SLI are trademarks of Emulex. *
@@ -135,12 +135,14 @@ lpfc_vport_sparm(struct lpfc_hba *phba, struct lpfc_vport *vport) · 127 unmodified lines
135135 }
136136
137137 /*
138− * Grab buffer pointer and clear context1 so we can use
139− * lpfc_sli_issue_box_wait
138+ * Wait for the read_sparams mailbox to complete. Driver needs
139+ * this per vport to start the FDISC. If the mailbox fails,
140+ * just cleanup and return an error unless the failure is a
141+ * mailbox timeout. For MBX_TIMEOUT, allow the default
142+ * mbox completion handler to take care of the cleanup. This
143+ * is safe as the mailbox command isn't one that triggers
144+ * another mailbox.
140145 */
141− mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
142− pmb->ctx_buf = NULL;
143−
144146 pmb->vport = vport;
145147 rc = lpfc_sli_issue_mbox_wait(phba, pmb, phba->fc_ratov * 2);
146148 if (rc != MBX_SUCCESS) {
@@ -148,34 +150,29 @@ lpfc_vport_sparm(struct lpfc_hba *phba, struct lpfc_vport *vport) · 1 unmodified line
148150 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
149151 "1830 Signal aborted mbxCmd x%x\n",
150152 mb->mbxCommand);
151− lpfc_mbuf_free(phba, mp->virt, mp->phys);
152− kfree(mp);
153153 if (rc != MBX_TIMEOUT)
154− mempool_free(pmb, phba->mbox_mem_pool);
154+ lpfc_mbox_rsrc_cleanup(phba, pmb,
155+ MBOX_THD_UNLOCKED);
155156 return -EINTR;
156157 } else {
157158 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
158159 "1818 VPort failed init, mbxCmd x%x "
159160 "READ_SPARM mbxStatus x%x, rc = x%x\n",
160161 mb->mbxCommand, mb->mbxStatus, rc);
161− lpfc_mbuf_free(phba, mp->virt, mp->phys);
162− kfree(mp);
163162 if (rc != MBX_TIMEOUT)
164− mempool_free(pmb, phba->mbox_mem_pool);
163+ lpfc_mbox_rsrc_cleanup(phba, pmb,
164+ MBOX_THD_UNLOCKED);
165165 return -EIO;
166166 }
167167 }
168168
169+ mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
169170 memcpy(&vport->fc_sparam, mp->virt, sizeof (struct serv_parm));
170171 memcpy(&vport->fc_nodename, &vport->fc_sparam.nodeName,
171172 sizeof (struct lpfc_name));
172173 memcpy(&vport->fc_portname, &vport->fc_sparam.portName,
173174 sizeof (struct lpfc_name));
174−
175− lpfc_mbuf_free(phba, mp->virt, mp->phys);
176− kfree(mp);
177− mempool_free(pmb, phba->mbox_mem_pool);
178−
175+ lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
179176 return 0;
180177 }
181178
drivers/scsi/mac53c94.c+1−1
@@ -234,7 +234,7 @@ static void mac53c94_interrupt(int irq, void *dev_id) · 233 unmodified lines
234234 ++mac53c94_errors;
235235 writeb(CMD_NOP + CMD_DMA_MODE, &regs->command);
236236 }
237− if (cmd == 0) {
237+ if (!cmd) {
238238 printk(KERN_DEBUG "53c94: interrupt with no command active?\n");
239239 return;
240240 }
drivers/scsi/megaraid.c+1−1
@@ -4607,7 +4607,7 @@ static int __init megaraid_init(void) · 4606 unmodified lines
46074607 * major number allocation.
46084608 */
46094609 major = register_chrdev(0, "megadev_legacy", &megadev_fops);
4610− if (!major) {
4610+ if (major < 0) {
46114611 printk(KERN_WARNING
46124612 "megaraid: failed to register char device\n");
46134613 }
drivers/scsi/megaraid/megaraid_sas_base.c+0−2
@@ -4473,8 +4473,6 @@ int megasas_alloc_cmds(struct megasas_instance *instance) · 4472 unmodified lines
44734473 return -ENOMEM;
44744474 }
44754475
4476− memset(instance->cmd_list, 0, sizeof(struct megasas_cmd *) *max_cmd);
4477−
44784476 for (i = 0; i < max_cmd; i++) {
44794477 instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd),
44804478 GFP_KERNEL);
drivers/scsi/megaraid/megaraid_sas_fusion.c+0−2
@@ -2047,8 +2047,6 @@ map_cmd_status(struct fusion_context *fusion, · 2046 unmodified lines
20472047
20482048 scmd->result = (DID_OK << 16) | ext_status;
20492049 if (ext_status == SAM_STAT_CHECK_CONDITION) {
2050− memset(scmd->sense_buffer, 0,
2051− SCSI_SENSE_BUFFERSIZE);
20522050 memcpy(scmd->sense_buffer, sense,
20532051 SCSI_SENSE_BUFFERSIZE);
20542052 }
drivers/scsi/mpi3mr/Kconfig+1−0
@@ -3,5 +3,6 @@ · 2 unmodified lines
33 config SCSI_MPI3MR
44 tristate "Broadcom MPI3 Storage Controller Device Driver"
55 depends on PCI && SCSI
6+ select BLK_DEV_BSGLIB
67 help
78 MPI3 based Storage & RAID Controllers Driver.
drivers/scsi/mpi3mr/Makefile+1−0
@@ -2,3 +2,4 @@ · 1 unmodified line
22 obj-m += mpi3mr.o
33 mpi3mr-y += mpi3mr_os.o \
44 mpi3mr_fw.o \
5+ mpi3mr_app.o \
drivers/scsi/mpi3mr/mpi/mpi30_init.h+0−53
@@ -115,57 +115,4 @@ struct mpi3_scsi_io_reply { · 114 unmodified lines
115115 #define MPI3_SCSI_RSP_ARI0_MASK (0xff000000)
116116 #define MPI3_SCSI_RSP_ARI0_SHIFT (24)
117117 #define MPI3_SCSI_TASKTAG_UNKNOWN (0xffff)
118−struct mpi3_scsi_task_mgmt_request {
119− __le16 host_tag;
120− u8 ioc_use_only02;
121− u8 function;
122− __le16 ioc_use_only04;
123− u8 ioc_use_only06;
124− u8 msg_flags;
125− __le16 change_count;
126− __le16 dev_handle;
127− __le16 task_host_tag;
128− u8 task_type;
129− u8 reserved0f;
130− __le16 task_request_queue_id;
131− __le16 reserved12;
132− __le32 reserved14;
133− u8 lun[8];
134−};
135−
136−#define MPI3_SCSITASKMGMT_MSGFLAGS_DO_NOT_SEND_TASK_IU (0x08)
137−#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK (0x01)
138−#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK_SET (0x02)
139−#define MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET (0x03)
140−#define MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET (0x05)
141−#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET (0x06)
142−#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07)
143−#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_ACA (0x08)
144−#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK_SET (0x09)
145−#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_ASYNC_EVENT (0x0a)
146−#define MPI3_SCSITASKMGMT_TASKTYPE_I_T_NEXUS_RESET (0x0b)
147−struct mpi3_scsi_task_mgmt_reply {
148− __le16 host_tag;
149− u8 ioc_use_only02;
150− u8 function;
151− __le16 ioc_use_only04;
152− u8 ioc_use_only06;
153− u8 msg_flags;
154− __le16 ioc_use_only08;
155− __le16 ioc_status;
156− __le32 ioc_log_info;
157− __le32 termination_count;
158− __le32 response_data;
159− __le32 reserved18;
160−};
161−
162−#define MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE (0x00)
163−#define MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME (0x02)
164−#define MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED (0x04)
165−#define MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED (0x05)
166−#define MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED (0x08)
167−#define MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN (0x09)
168−#define MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG (0x0a)
169−#define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC (0x80)
170−#define MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED (0x81)
171118 #endif
drivers/scsi/mpi3mr/mpi/mpi30_ioc.h+0−27
@@ -38,16 +38,6 @@ struct mpi3_ioc_init_request { · 37 unmodified lines
3838 #define MPI3_WHOINIT_ROM_BIOS (0x02)
3939 #define MPI3_WHOINIT_HOST_DRIVER (0x03)
4040 #define MPI3_WHOINIT_MANUFACTURER (0x04)
41−struct mpi3_driver_info_layout {
42− __le32 information_length;
43− u8 driver_signature[12];
44− u8 os_name[16];
45− u8 os_version[12];
46− u8 driver_name[20];
47− u8 driver_version[32];
48− u8 driver_release_date[20];
49− __le32 driver_capabilities;
50−};
5141
5242 struct mpi3_ioc_facts_request {
5343 __le16 host_tag;
@@ -647,23 +637,6 @@ struct mpi3_event_data_diag_buffer_status_change { · 593 unmodified lines
647637 #define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_RELEASED (0x01)
648638 #define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_PAUSED (0x02)
649639 #define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_RESUMED (0x03)
650−#define MPI3_PEL_LOCALE_FLAGS_NON_BLOCKING_BOOT_EVENT (0x0200)
651−#define MPI3_PEL_LOCALE_FLAGS_BLOCKING_BOOT_EVENT (0x0100)
652−#define MPI3_PEL_LOCALE_FLAGS_PCIE (0x0080)
653−#define MPI3_PEL_LOCALE_FLAGS_CONFIGURATION (0x0040)
654−#define MPI3_PEL_LOCALE_FLAGS_CONTROLER (0x0020)
655−#define MPI3_PEL_LOCALE_FLAGS_SAS (0x0010)
656−#define MPI3_PEL_LOCALE_FLAGS_EPACK (0x0008)
657−#define MPI3_PEL_LOCALE_FLAGS_ENCLOSURE (0x0004)
658−#define MPI3_PEL_LOCALE_FLAGS_PD (0x0002)
659−#define MPI3_PEL_LOCALE_FLAGS_VD (0x0001)
660−#define MPI3_PEL_CLASS_DEBUG (0x00)
661−#define MPI3_PEL_CLASS_PROGRESS (0x01)
662−#define MPI3_PEL_CLASS_INFORMATIONAL (0x02)
663−#define MPI3_PEL_CLASS_WARNING (0x03)
664−#define MPI3_PEL_CLASS_CRITICAL (0x04)
665−#define MPI3_PEL_CLASS_FATAL (0x05)
666−#define MPI3_PEL_CLASS_FAULT (0x06)
667640 #define MPI3_PEL_CLEARTYPE_CLEAR (0x00)
668641 #define MPI3_PEL_WAITTIME_INFINITE_WAIT (0x00)
669642 #define MPI3_PEL_ACTION_GET_SEQNUM (0x01)
drivers/scsi/mpi3mr/mpi/mpi30_pci.h+1−30
@@ -5,24 +5,6 @@ · 4 unmodified lines
55 */
66 #ifndef MPI30_PCI_H
77 #define MPI30_PCI_H 1
8−#ifndef MPI3_NVME_ENCAP_CMD_MAX
9−#define MPI3_NVME_ENCAP_CMD_MAX (1)
10−#endif
11−struct mpi3_nvme_encapsulated_request {
12− __le16 host_tag;
13− u8 ioc_use_only02;
14− u8 function;
15− __le16 ioc_use_only04;
16− u8 ioc_use_only06;
17− u8 msg_flags;
18− __le16 change_count;
19− __le16 dev_handle;
20− __le16 encapsulated_command_length;
21− __le16 flags;
22− __le32 data_length;
23− __le32 reserved14[3];
24− __le32 command[MPI3_NVME_ENCAP_CMD_MAX];
25−};
268
279 #define MPI3_NVME_FLAGS_FORCE_ADMIN_ERR_REPLY_MASK (0x0002)
2810 #define MPI3_NVME_FLAGS_FORCE_ADMIN_ERR_REPLY_FAIL_ONLY (0x0000)
@@ -30,16 +12,5 @@ struct mpi3_nvme_encapsulated_request { · 1 unmodified line
3012 #define MPI3_NVME_FLAGS_SUBMISSIONQ_MASK (0x0001)
3113 #define MPI3_NVME_FLAGS_SUBMISSIONQ_IO (0x0000)
3214 #define MPI3_NVME_FLAGS_SUBMISSIONQ_ADMIN (0x0001)
33−struct mpi3_nvme_encapsulated_error_reply {
34− __le16 host_tag;
35− u8 ioc_use_only02;
36− u8 function;
37− __le16 ioc_use_only04;
38− u8 ioc_use_only06;
39− u8 msg_flags;
40− __le16 ioc_use_only08;
41− __le16 ioc_status;
42− __le32 ioc_log_info;
43− __le32 nvme_completion_entry[4];
44−};
15+
4516 #endif
drivers/scsi/mpi3mr/mpi3mr.h+130−7
@@ -38,6 +38,7 @@ · 37 unmodified lines
3838 #include <scsi/scsi_device.h>
3939 #include <scsi/scsi_host.h>
4040 #include <scsi/scsi_tcq.h>
41+#include <uapi/scsi/scsi_bsg_mpi3mr.h>
4142
4243 #include "mpi/mpi30_transport.h"
4344 #include "mpi/mpi30_cnfg.h"
@@ -52,9 +53,10 @@ · 8 unmodified lines
5253 extern spinlock_t mrioc_list_lock;
5354 extern struct list_head mrioc_list;
5455 extern int prot_mask;
56+extern atomic64_t event_counter;
5557
56−#define MPI3MR_DRIVER_VERSION "8.0.0.68.0"
57−#define MPI3MR_DRIVER_RELDATE "10-February-2022"
58+#define MPI3MR_DRIVER_VERSION "8.0.0.69.0"
59+#define MPI3MR_DRIVER_RELDATE "16-March-2022"
5860
5961 #define MPI3MR_DRIVER_NAME "mpi3mr"
6062 #define MPI3MR_DRIVER_LICENSE "GPL"
@@ -89,7 +91,9 @@ extern int prot_mask; · 28 unmodified lines
8991 /* Reserved Host Tag definitions */
9092 #define MPI3MR_HOSTTAG_INVALID 0xFFFF
9193 #define MPI3MR_HOSTTAG_INITCMDS 1
92−#define MPI3MR_HOSTTAG_IOCTLCMDS 2
94+#define MPI3MR_HOSTTAG_BSG_CMDS 2
95+#define MPI3MR_HOSTTAG_PEL_ABORT 3
96+#define MPI3MR_HOSTTAG_PEL_WAIT 4
9397 #define MPI3MR_HOSTTAG_BLK_TMS 5
9498
9599 #define MPI3MR_NUM_DEVRMCMD 16
@@ -120,6 +124,9 @@ extern int prot_mask; · 24 unmodified lines
120124
121125 #define MPI3MR_WATCHDOG_INTERVAL 1000 /* in milli seconds */
122126
127+#define MPI3MR_SCMD_TIMEOUT (60 * HZ)
128+#define MPI3MR_EH_SCMD_TIMEOUT (60 * HZ)
129+
123130 /* Internal admin command state definitions*/
124131 #define MPI3MR_CMD_NOTUSED 0x8000
125132 #define MPI3MR_CMD_COMPLETE 0x0001
@@ -148,8 +155,10 @@ extern int prot_mask; · 22 unmodified lines
148155
149156 #define MPI3MR_DEFAULT_MDTS (128 * 1024)
150157 #define MPI3MR_DEFAULT_PGSZEXP (12)
158+
151159 /* Command retry count definitions */
152160 #define MPI3MR_DEV_RMHS_RETRY_COUNT 3
161+#define MPI3MR_PEL_RETRY_COUNT 3
153162
154163 /* Default target device queue depth */
155164 #define MPI3MR_DEFAULT_SDEV_QD 32
@@ -175,6 +184,57 @@ extern int prot_mask; · 19 unmodified lines
175184 /* MSI Index from Reply Queue Index */
176185 #define REPLY_QUEUE_IDX_TO_MSIX_IDX(qidx, offset) (qidx + offset)
177186
187+/*
188+ * Maximum data transfer size definitions for management
189+ * application commands
190+ */
191+#define MPI3MR_MAX_APP_XFER_SIZE (1 * 1024 * 1024)
192+#define MPI3MR_MAX_APP_XFER_SEGMENTS 512
193+/*
194+ * 2048 sectors are for data buffers and additional 512 sectors for
195+ * other buffers
196+ */
197+#define MPI3MR_MAX_APP_XFER_SECTORS (2048 + 512)
198+
199+/**
200+ * struct mpi3mr_nvme_pt_sge - Structure to store SGEs for NVMe
201+ * Encapsulated commands.
202+ *
203+ * @base_addr: Physical address
204+ * @length: SGE length
205+ * @rsvd: Reserved
206+ * @rsvd1: Reserved
207+ * @sgl_type: sgl type
208+ */
209+struct mpi3mr_nvme_pt_sge {
210+ u64 base_addr;
211+ u32 length;
212+ u16 rsvd;
213+ u8 rsvd1;
214+ u8 sgl_type;
215+};
216+
217+/**
218+ * struct mpi3mr_buf_map - local structure to
219+ * track kernel and user buffers associated with an BSG
220+ * structure.
221+ *
222+ * @bsg_buf: BSG buffer virtual address
223+ * @bsg_buf_len: BSG buffer length
224+ * @kern_buf: Kernel buffer virtual address
225+ * @kern_buf_len: Kernel buffer length
226+ * @kern_buf_dma: Kernel buffer DMA address
227+ * @data_dir: Data direction.
228+ */
229+struct mpi3mr_buf_map {
230+ void *bsg_buf;
231+ u32 bsg_buf_len;
232+ void *kern_buf;
233+ u32 kern_buf_len;
234+ dma_addr_t kern_buf_dma;
235+ u8 data_dir;
236+};
237+
178238 /* IOC State definitions */
179239 enum mpi3mr_iocstate {
180240 MRIOC_STATE_READY = 1,
@@ -189,10 +249,10 @@ enum mpi3mr_iocstate { · 8 unmodified lines
189249 enum mpi3mr_reset_reason {
190250 MPI3MR_RESET_FROM_BRINGUP = 1,
191251 MPI3MR_RESET_FROM_FAULT_WATCH = 2,
192− MPI3MR_RESET_FROM_IOCTL = 3,
252+ MPI3MR_RESET_FROM_APP = 3,
193253 MPI3MR_RESET_FROM_EH_HOS = 4,
194254 MPI3MR_RESET_FROM_TM_TIMEOUT = 5,
195− MPI3MR_RESET_FROM_IOCTL_TIMEOUT = 6,
255+ MPI3MR_RESET_FROM_APP_TIMEOUT = 6,
196256 MPI3MR_RESET_FROM_MUR_FAILURE = 7,
197257 MPI3MR_RESET_FROM_CTLR_CLEANUP = 8,
198258 MPI3MR_RESET_FROM_CIACTIV_FAULT = 9,
@@ -543,6 +603,7 @@ struct mpi3mr_sdev_priv_data { · 344 unmodified lines
543603 * @ioc_status: IOC status from the firmware
544604 * @ioc_loginfo:IOC log info from the firmware
545605 * @is_waiting: Is the command issued in block mode
606+ * @is_sense: Is Sense data present
546607 * @retry_count: Retry count for retriable commands
547608 * @host_tag: Host tag used by the command
548609 * @callback: Callback for non blocking commands
@@ -558,6 +619,7 @@ struct mpi3mr_drv_cmd { · 9 unmodified lines
558619 u16 ioc_status;
559620 u32 ioc_loginfo;
560621 u8 is_waiting;
622+ u8 is_sense;
561623 u8 retry_count;
562624 u16 host_tag;
563625
@@ -685,6 +747,7 @@ struct scmd_priv { · 121 unmodified lines
685747 * @chain_bitmap_sz: Chain buffer allocator bitmap size
686748 * @chain_bitmap: Chain buffer allocator bitmap
687749 * @chain_buf_lock: Chain buffer list lock
750+ * @bsg_cmds: Command tracker for BSG command
688751 * @host_tm_cmds: Command tracker for task management commands
689752 * @dev_rmhs_cmds: Command tracker for device removal commands
690753 * @evtack_cmds: Command tracker for event ack commands
@@ -704,16 +767,35 @@ struct scmd_priv { · 13 unmodified lines
704767 * @reset_waitq: Controller reset wait queue
705768 * @prepare_for_reset: Prepare for reset event received
706769 * @prepare_for_reset_timeout_counter: Prepare for reset timeout
770+ * @prp_list_virt: NVMe encapsulated PRP list virtual base
771+ * @prp_list_dma: NVMe encapsulated PRP list DMA
772+ * @prp_sz: NVME encapsulated PRP list size
707773 * @diagsave_timeout: Diagnostic information save timeout
708774 * @logging_level: Controller debug logging level
709775 * @flush_io_count: I/O count to flush after reset
710776 * @current_event: Firmware event currently in process
711777 * @driver_info: Driver, Kernel, OS information to firmware
712778 * @change_count: Topology change count
779+ * @pel_enabled: Persistent Event Log(PEL) enabled or not
780+ * @pel_abort_requested: PEL abort is requested or not
781+ * @pel_class: PEL Class identifier
782+ * @pel_locale: PEL Locale identifier
783+ * @pel_cmds: Command tracker for PEL wait command
784+ * @pel_abort_cmd: Command tracker for PEL abort command
785+ * @pel_newest_seqnum: Newest PEL sequenece number
786+ * @pel_seqnum_virt: PEL sequence number virtual address
787+ * @pel_seqnum_dma: PEL sequence number DMA address
788+ * @pel_seqnum_sz: PEL sequenece number size
713789 * @op_reply_q_offset: Operational reply queue offset with MSIx
714790 * @default_qcount: Total Default queues
715791 * @active_poll_qcount: Currently active poll queue count
716792 * @requested_poll_qcount: User requested poll queue count
793+ * @bsg_dev: BSG device structure
794+ * @bsg_queue: Request queue for BSG device
795+ * @stop_bsgs: Stop BSG request flag
796+ * @logdata_buf: Circular buffer to store log data entries
797+ * @logdata_buf_idx: Index of entry in buffer to store
798+ * @logdata_entry_sz: log data entry size
717799 */
718800 struct mpi3mr_ioc {
719801 struct list_head list;
@@ -820,6 +902,7 @@ struct mpi3mr_ioc { · 100 unmodified lines
820902 void *chain_bitmap;
821903 spinlock_t chain_buf_lock;
822904
905+ struct mpi3mr_drv_cmd bsg_cmds;
823906 struct mpi3mr_drv_cmd host_tm_cmds;
824907 struct mpi3mr_drv_cmd dev_rmhs_cmds[MPI3MR_NUM_DEVRMCMD];
825908 struct mpi3mr_drv_cmd evtack_cmds[MPI3MR_NUM_EVTACKCMD];
@@ -842,6 +925,10 @@ struct mpi3mr_ioc { · 16 unmodified lines
842925 u8 prepare_for_reset;
843926 u16 prepare_for_reset_timeout_counter;
844927
928+ void *prp_list_virt;
929+ dma_addr_t prp_list_dma;
930+ u32 prp_sz;
931+
845932 u16 diagsave_timeout;
846933 int logging_level;
847934 u16 flush_io_count;
@@ -849,11 +936,30 @@ struct mpi3mr_ioc { · 1 unmodified line
849936 struct mpi3mr_fwevt *current_event;
850937 struct mpi3_driver_info_layout driver_info;
851938 u16 change_count;
852− u16 op_reply_q_offset;
853939
940+ u8 pel_enabled;
941+ u8 pel_abort_requested;
942+ u8 pel_class;
943+ u16 pel_locale;
944+ struct mpi3mr_drv_cmd pel_cmds;
945+ struct mpi3mr_drv_cmd pel_abort_cmd;
946+
947+ u32 pel_newest_seqnum;
948+ void *pel_seqnum_virt;
949+ dma_addr_t pel_seqnum_dma;
950+ u32 pel_seqnum_sz;
951+
952+ u16 op_reply_q_offset;
854953 u16 default_qcount;
855954 u16 active_poll_qcount;
856955 u16 requested_poll_qcount;
956+
957+ struct device *bsg_dev;
958+ struct request_queue *bsg_queue;
959+ u8 stop_bsgs;
960+ u8 *logdata_buf;
961+ u16 logdata_buf_idx;
962+ u16 logdata_entry_sz;
857963 };
858964
859965 /**
@@ -866,6 +972,7 @@ struct mpi3mr_ioc { · 6 unmodified lines
866972 * @send_ack: Event acknowledgment required or not
867973 * @process_evt: Bottomhalf processing required or not
868974 * @evt_ctx: Event context to send in Ack
975+ * @event_data_size: size of the event data in bytes
869976 * @pending_at_sml: waiting for device add/remove API to complete
870977 * @discard: discard this event
871978 * @ref_count: kref count
@@ -879,6 +986,7 @@ struct mpi3mr_fwevt { · 7 unmodified lines
879986 bool send_ack;
880987 bool process_evt;
881988 u32 evt_ctx;
989+ u16 event_data_size;
882990 bool pending_at_sml;
883991 bool discard;
884992 struct kref ref_count;
@@ -962,5 +1070,20 @@ void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code); · 77 unmodified lines
9621070 int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc,
9631071 struct op_reply_qinfo *op_reply_q);
9641072 int mpi3mr_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num);
965−
1073+void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc);
1074+void mpi3mr_bsg_exit(struct mpi3mr_ioc *mrioc);
1075+int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
1076+ u16 handle, uint lun, u16 htag, ulong timeout,
1077+ struct mpi3mr_drv_cmd *drv_cmd,
1078+ u8 *resp_code, struct scsi_cmnd *scmd);
1079+struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle(
1080+ struct mpi3mr_ioc *mrioc, u16 handle);
1081+void mpi3mr_pel_get_seqnum_complete(struct mpi3mr_ioc *mrioc,
1082+ struct mpi3mr_drv_cmd *drv_cmd);
1083+int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc,
1084+ struct mpi3mr_drv_cmd *drv_cmd);
1085+void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data,
1086+ u16 event_data_size);
1087+extern const struct attribute_group *mpi3mr_host_groups[];
1088+extern const struct attribute_group *mpi3mr_dev_groups[];
9661089 #endif /*MPI3MR_H_INCLUDED*/
drivers/scsi/mpi3mr/mpi3mr_app.c+1864−0
@@ -0,0 +1,1864 @@
1+// SPDX-License-Identifier: GPL-2.0-or-later
2+/*
3+ * Driver for Broadcom MPI3 Storage Controllers
4+ *
5+ * Copyright (C) 2017-2022 Broadcom Inc.
6+ * (mailto: mpi3mr-linuxdrv.pdl@broadcom.com)
7+ *
8+ */
9+
10+#include "mpi3mr.h"
11+#include <linux/bsg-lib.h>
12+#include <uapi/scsi/scsi_bsg_mpi3mr.h>
13+
14+/**
15+ * mpi3mr_bsg_pel_abort - sends PEL abort request
16+ * @mrioc: Adapter instance reference
17+ *
18+ * This function sends PEL abort request to the firmware through
19+ * admin request queue.
20+ *
21+ * Return: 0 on success, -1 on failure
22+ */
23+static int mpi3mr_bsg_pel_abort(struct mpi3mr_ioc *mrioc)
24+{
25+ struct mpi3_pel_req_action_abort pel_abort_req;
26+ struct mpi3_pel_reply *pel_reply;
27+ int retval = 0;
28+ u16 pe_log_status;
29+
30+ if (mrioc->reset_in_progress) {
31+ dprint_bsg_err(mrioc, "%s: reset in progress\n", __func__);
32+ return -1;
33+ }
34+ if (mrioc->stop_bsgs) {
35+ dprint_bsg_err(mrioc, "%s: bsgs are blocked\n", __func__);
36+ return -1;
37+ }
38+
39+ memset(&pel_abort_req, 0, sizeof(pel_abort_req));
40+ mutex_lock(&mrioc->pel_abort_cmd.mutex);
41+ if (mrioc->pel_abort_cmd.state & MPI3MR_CMD_PENDING) {
42+ dprint_bsg_err(mrioc, "%s: command is in use\n", __func__);
43+ mutex_unlock(&mrioc->pel_abort_cmd.mutex);
44+ return -1;
45+ }
46+ mrioc->pel_abort_cmd.state = MPI3MR_CMD_PENDING;
47+ mrioc->pel_abort_cmd.is_waiting = 1;
48+ mrioc->pel_abort_cmd.callback = NULL;
49+ pel_abort_req.host_tag = cpu_to_le16(MPI3MR_HOSTTAG_PEL_ABORT);
50+ pel_abort_req.function = MPI3_FUNCTION_PERSISTENT_EVENT_LOG;
51+ pel_abort_req.action = MPI3_PEL_ACTION_ABORT;
52+ pel_abort_req.abort_host_tag = cpu_to_le16(MPI3MR_HOSTTAG_PEL_WAIT);
53+
54+ mrioc->pel_abort_requested = 1;
55+ init_completion(&mrioc->pel_abort_cmd.done);
56+ retval = mpi3mr_admin_request_post(mrioc, &pel_abort_req,
57+ sizeof(pel_abort_req), 0);
58+ if (retval) {
59+ retval = -1;
60+ dprint_bsg_err(mrioc, "%s: admin request post failed\n",
61+ __func__);
62+ mrioc->pel_abort_requested = 0;
63+ goto out_unlock;
64+ }
65+
66+ wait_for_completion_timeout(&mrioc->pel_abort_cmd.done,
67+ (MPI3MR_INTADMCMD_TIMEOUT * HZ));
68+ if (!(mrioc->pel_abort_cmd.state & MPI3MR_CMD_COMPLETE)) {
69+ mrioc->pel_abort_cmd.is_waiting = 0;
70+ dprint_bsg_err(mrioc, "%s: command timedout\n", __func__);
71+ if (!(mrioc->pel_abort_cmd.state & MPI3MR_CMD_RESET))
72+ mpi3mr_soft_reset_handler(mrioc,
73+ MPI3MR_RESET_FROM_PELABORT_TIMEOUT, 1);
74+ retval = -1;
75+ goto out_unlock;
76+ }
77+ if ((mrioc->pel_abort_cmd.ioc_status & MPI3_IOCSTATUS_STATUS_MASK)
78+ != MPI3_IOCSTATUS_SUCCESS) {
79+ dprint_bsg_err(mrioc,
80+ "%s: command failed, ioc_status(0x%04x) log_info(0x%08x)\n",
81+ __func__, (mrioc->pel_abort_cmd.ioc_status &
82+ MPI3_IOCSTATUS_STATUS_MASK),
83+ mrioc->pel_abort_cmd.ioc_loginfo);
84+ retval = -1;
85+ goto out_unlock;
86+ }
87+ if (mrioc->pel_abort_cmd.state & MPI3MR_CMD_REPLY_VALID) {
88+ pel_reply = (struct mpi3_pel_reply *)mrioc->pel_abort_cmd.reply;
89+ pe_log_status = le16_to_cpu(pel_reply->pe_log_status);
90+ if (pe_log_status != MPI3_PEL_STATUS_SUCCESS) {
91+ dprint_bsg_err(mrioc,
92+ "%s: command failed, pel_status(0x%04x)\n",
93+ __func__, pe_log_status);
94+ retval = -1;
95+ }
96+ }
97+
98+out_unlock:
99+ mrioc->pel_abort_cmd.state = MPI3MR_CMD_NOTUSED;
100+ mutex_unlock(&mrioc->pel_abort_cmd.mutex);
101+ return retval;
102+}
103+/**
104+ * mpi3mr_bsg_verify_adapter - verify adapter number is valid
105+ * @ioc_number: Adapter number
106+ *
107+ * This function returns the adapter instance pointer of given
108+ * adapter number. If adapter number does not match with the
109+ * driver's adapter list, driver returns NULL.
110+ *
111+ * Return: adapter instance reference
112+ */
113+static struct mpi3mr_ioc *mpi3mr_bsg_verify_adapter(int ioc_number)
114+{
115+ struct mpi3mr_ioc *mrioc = NULL;
116+
117+ spin_lock(&mrioc_list_lock);
118+ list_for_each_entry(mrioc, &mrioc_list, list) {
119+ if (mrioc->id == ioc_number) {
120+ spin_unlock(&mrioc_list_lock);
121+ return mrioc;
122+ }
123+ }
124+ spin_unlock(&mrioc_list_lock);
125+ return NULL;
126+}
127+
128+/**
129+ * mpi3mr_enable_logdata - Handler for log data enable
130+ * @mrioc: Adapter instance reference
131+ * @job: BSG job reference
132+ *
133+ * This function enables log data caching in the driver if not
134+ * already enabled and return the maximum number of log data
135+ * entries that can be cached in the driver.
136+ *
137+ * Return: 0 on success and proper error codes on failure
138+ */
139+static long mpi3mr_enable_logdata(struct mpi3mr_ioc *mrioc,
140+ struct bsg_job *job)
141+{
142+ struct mpi3mr_logdata_enable logdata_enable;
143+
144+ if (!mrioc->logdata_buf) {
145+ mrioc->logdata_entry_sz =
146+ (mrioc->reply_sz - (sizeof(struct mpi3_event_notification_reply) - 4))
147+ + MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ;
148+ mrioc->logdata_buf_idx = 0;
149+ mrioc->logdata_buf = kcalloc(MPI3MR_BSG_LOGDATA_MAX_ENTRIES,
150+ mrioc->logdata_entry_sz, GFP_KERNEL);
151+
152+ if (!mrioc->logdata_buf)
153+ return -ENOMEM;
154+ }
155+
156+ memset(&logdata_enable, 0, sizeof(logdata_enable));
157+ logdata_enable.max_entries =
158+ MPI3MR_BSG_LOGDATA_MAX_ENTRIES;
159+ if (job->request_payload.payload_len >= sizeof(logdata_enable)) {
160+ sg_copy_from_buffer(job->request_payload.sg_list,
161+ job->request_payload.sg_cnt,
162+ &logdata_enable, sizeof(logdata_enable));
163+ return 0;
164+ }
165+
166+ return -EINVAL;
167+}
168+/**
169+ * mpi3mr_get_logdata - Handler for get log data
170+ * @mrioc: Adapter instance reference
171+ * @job: BSG job pointer
172+ * This function copies the log data entries to the user buffer
173+ * when log caching is enabled in the driver.
174+ *
175+ * Return: 0 on success and proper error codes on failure
176+ */
177+static long mpi3mr_get_logdata(struct mpi3mr_ioc *mrioc,
178+ struct bsg_job *job)
179+{
180+ u16 num_entries, sz, entry_sz = mrioc->logdata_entry_sz;
181+
182+ if ((!mrioc->logdata_buf) || (job->request_payload.payload_len < entry_sz))
183+ return -EINVAL;
184+
185+ num_entries = job->request_payload.payload_len / entry_sz;
186+ if (num_entries > MPI3MR_BSG_LOGDATA_MAX_ENTRIES)
187+ num_entries = MPI3MR_BSG_LOGDATA_MAX_ENTRIES;
188+ sz = num_entries * entry_sz;
189+
190+ if (job->request_payload.payload_len >= sz) {
191+ sg_copy_from_buffer(job->request_payload.sg_list,
192+ job->request_payload.sg_cnt,
193+ mrioc->logdata_buf, sz);
194+ return 0;
195+ }
196+ return -EINVAL;
197+}
198+
199+/**
200+ * mpi3mr_bsg_pel_enable - Handler for PEL enable driver
201+ * @mrioc: Adapter instance reference
202+ * @job: BSG job pointer
203+ *
204+ * This function is the handler for PEL enable driver.
205+ * Validates the application given class and locale and if
206+ * requires aborts the existing PEL wait request and/or issues
207+ * new PEL wait request to the firmware and returns.
208+ *
209+ * Return: 0 on success and proper error codes on failure.
210+ */
211+static long mpi3mr_bsg_pel_enable(struct mpi3mr_ioc *mrioc,
212+ struct bsg_job *job)
213+{
214+ long rval = -EINVAL;
215+ struct mpi3mr_bsg_out_pel_enable pel_enable;
216+ u8 issue_pel_wait;
217+ u8 tmp_class;
218+ u16 tmp_locale;
219+
220+ if (job->request_payload.payload_len != sizeof(pel_enable)) {
221+ dprint_bsg_err(mrioc, "%s: invalid size argument\n",
222+ __func__);
223+ return rval;
224+ }
225+
226+ sg_copy_to_buffer(job->request_payload.sg_list,
227+ job->request_payload.sg_cnt,
228+ &pel_enable, sizeof(pel_enable));
229+
230+ if (pel_enable.pel_class > MPI3_PEL_CLASS_FAULT) {
231+ dprint_bsg_err(mrioc, "%s: out of range class %d sent\n",
232+ __func__, pel_enable.pel_class);
233+ rval = 0;
234+ goto out;
235+ }
236+ if (!mrioc->pel_enabled)
237+ issue_pel_wait = 1;
238+ else {
239+ if ((mrioc->pel_class <= pel_enable.pel_class) &&
240+ !((mrioc->pel_locale & pel_enable.pel_locale) ^
241+ pel_enable.pel_locale)) {
242+ issue_pel_wait = 0;
243+ rval = 0;
244+ } else {
245+ pel_enable.pel_locale |= mrioc->pel_locale;
246+
247+ if (mrioc->pel_class < pel_enable.pel_class)
248+ pel_enable.pel_class = mrioc->pel_class;
249+
250+ rval = mpi3mr_bsg_pel_abort(mrioc);
251+ if (rval) {
252+ dprint_bsg_err(mrioc,
253+ "%s: pel_abort failed, status(%ld)\n",
254+ __func__, rval);
255+ goto out;
256+ }
257+ issue_pel_wait = 1;
258+ }
259+ }
260+ if (issue_pel_wait) {
261+ tmp_class = mrioc->pel_class;
262+ tmp_locale = mrioc->pel_locale;
263+ mrioc->pel_class = pel_enable.pel_class;
264+ mrioc->pel_locale = pel_enable.pel_locale;
265+ mrioc->pel_enabled = 1;
266+ rval = mpi3mr_pel_get_seqnum_post(mrioc, NULL);
267+ if (rval) {
268+ mrioc->pel_class = tmp_class;
269+ mrioc->pel_locale = tmp_locale;
270+ mrioc->pel_enabled = 0;
271+ dprint_bsg_err(mrioc,
272+ "%s: pel get sequence number failed, status(%ld)\n",
273+ __func__, rval);
274+ }
275+ }
276+
277+out:
278+ return rval;
279+}
280+/**
281+ * mpi3mr_get_all_tgt_info - Get all target information
282+ * @mrioc: Adapter instance reference
283+ * @job: BSG job reference
284+ *
285+ * This function copies the driver managed target devices device
286+ * handle, persistent ID, bus ID and taret ID to the user
287+ * provided buffer for the specific controller. This function
288+ * also provides the number of devices managed by the driver for
289+ * the specific controller.
290+ *
291+ * Return: 0 on success and proper error codes on failure
292+ */
293+static long mpi3mr_get_all_tgt_info(struct mpi3mr_ioc *mrioc,
294+ struct bsg_job *job)
295+{
296+ long rval = -EINVAL;
297+ u16 num_devices = 0, i = 0, size;
298+ unsigned long flags;
299+ struct mpi3mr_tgt_dev *tgtdev;
300+ struct mpi3mr_device_map_info *devmap_info = NULL;
301+ struct mpi3mr_all_tgt_info *alltgt_info = NULL;
302+ uint32_t min_entrylen = 0, kern_entrylen = 0, usr_entrylen = 0;
303+
304+ if (job->request_payload.payload_len < sizeof(u32)) {
305+ dprint_bsg_err(mrioc, "%s: invalid size argument\n",
306+ __func__);
307+ return rval;
308+ }
309+
310+ spin_lock_irqsave(&mrioc->tgtdev_lock, flags);
311+ list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list)
312+ num_devices++;
313+ spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags);
314+
315+ if ((job->request_payload.payload_len == sizeof(u32)) ||
316+ list_empty(&mrioc->tgtdev_list)) {
317+ sg_copy_from_buffer(job->request_payload.sg_list,
318+ job->request_payload.sg_cnt,
319+ &num_devices, sizeof(num_devices));
320+ return 0;
321+ }
322+
323+ kern_entrylen = (num_devices - 1) * sizeof(*devmap_info);
324+ size = sizeof(*alltgt_info) + kern_entrylen;
325+ alltgt_info = kzalloc(size, GFP_KERNEL);
326+ if (!alltgt_info)
327+ return -ENOMEM;
328+
329+ devmap_info = alltgt_info->dmi;
330+ memset((u8 *)devmap_info, 0xFF, (kern_entrylen + sizeof(*devmap_info)));
331+ spin_lock_irqsave(&mrioc->tgtdev_lock, flags);
332+ list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list) {
333+ if (i < num_devices) {
334+ devmap_info[i].handle = tgtdev->dev_handle;
335+ devmap_info[i].perst_id = tgtdev->perst_id;
336+ if (tgtdev->host_exposed && tgtdev->starget) {
337+ devmap_info[i].target_id = tgtdev->starget->id;
338+ devmap_info[i].bus_id =
339+ tgtdev->starget->channel;
340+ }
341+ i++;
342+ }
343+ }
344+ num_devices = i;
345+ spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags);
346+
347+ memcpy(&alltgt_info->num_devices, &num_devices, sizeof(num_devices));
348+
349+ usr_entrylen = (job->request_payload.payload_len - sizeof(u32)) / sizeof(*devmap_info);
350+ usr_entrylen *= sizeof(*devmap_info);
351+ min_entrylen = min(usr_entrylen, kern_entrylen);
352+ if (min_entrylen && (!memcpy(&alltgt_info->dmi, devmap_info, min_entrylen))) {
353+ dprint_bsg_err(mrioc, "%s:%d: device map info copy failed\n",
354+ __func__, __LINE__);
355+ rval = -EFAULT;
356+ goto out;
357+ }
358+
359+ sg_copy_from_buffer(job->request_payload.sg_list,
360+ job->request_payload.sg_cnt,
361+ alltgt_info, job->request_payload.payload_len);
362+ rval = 0;
363+out:
364+ kfree(alltgt_info);
365+ return rval;
366+}
367+/**
368+ * mpi3mr_get_change_count - Get topology change count
369+ * @mrioc: Adapter instance reference
370+ * @job: BSG job reference
371+ *
372+ * This function copies the toplogy change count provided by the
373+ * driver in events and cached in the driver to the user
374+ * provided buffer for the specific controller.
375+ *
376+ * Return: 0 on success and proper error codes on failure
377+ */
378+static long mpi3mr_get_change_count(struct mpi3mr_ioc *mrioc,
379+ struct bsg_job *job)
380+{
381+ struct mpi3mr_change_count chgcnt;
382+
383+ memset(&chgcnt, 0, sizeof(chgcnt));
384+ chgcnt.change_count = mrioc->change_count;
385+ if (job->request_payload.payload_len >= sizeof(chgcnt)) {
386+ sg_copy_from_buffer(job->request_payload.sg_list,
387+ job->request_payload.sg_cnt,
388+ &chgcnt, sizeof(chgcnt));
389+ return 0;
390+ }
391+ return -EINVAL;
392+}
393+
394+/**
395+ * mpi3mr_bsg_adp_reset - Issue controller reset
396+ * @mrioc: Adapter instance reference
397+ * @job: BSG job reference
398+ *
399+ * This function identifies the user provided reset type and
400+ * issues approporiate reset to the controller and wait for that
401+ * to complete and reinitialize the controller and then returns
402+ *
403+ * Return: 0 on success and proper error codes on failure
404+ */
405+static long mpi3mr_bsg_adp_reset(struct mpi3mr_ioc *mrioc,
406+ struct bsg_job *job)
407+{
408+ long rval = -EINVAL;
409+ u8 save_snapdump;
410+ struct mpi3mr_bsg_adp_reset adpreset;
411+
412+ if (job->request_payload.payload_len !=
413+ sizeof(adpreset)) {
414+ dprint_bsg_err(mrioc, "%s: invalid size argument\n",
415+ __func__);
416+ goto out;
417+ }
418+
419+ sg_copy_to_buffer(job->request_payload.sg_list,
420+ job->request_payload.sg_cnt,
421+ &adpreset, sizeof(adpreset));
422+
423+ switch (adpreset.reset_type) {
424+ case MPI3MR_BSG_ADPRESET_SOFT:
425+ save_snapdump = 0;
426+ break;
427+ case MPI3MR_BSG_ADPRESET_DIAG_FAULT:
428+ save_snapdump = 1;
429+ break;
430+ default:
431+ dprint_bsg_err(mrioc, "%s: unknown reset_type(%d)\n",
432+ __func__, adpreset.reset_type);
433+ goto out;
434+ }
435+
436+ rval = mpi3mr_soft_reset_handler(mrioc, MPI3MR_RESET_FROM_APP,
437+ save_snapdump);
438+
439+ if (rval)
440+ dprint_bsg_err(mrioc,
441+ "%s: reset handler returned error(%ld) for reset type %d\n",
442+ __func__, rval, adpreset.reset_type);
443+out:
444+ return rval;
445+}
446+
447+/**
448+ * mpi3mr_bsg_populate_adpinfo - Get adapter info command handler
449+ * @mrioc: Adapter instance reference
450+ * @job: BSG job reference
451+ *
452+ * This function provides adapter information for the given
453+ * controller
454+ *
455+ * Return: 0 on success and proper error codes on failure
456+ */
457+static long mpi3mr_bsg_populate_adpinfo(struct mpi3mr_ioc *mrioc,
458+ struct bsg_job *job)
459+{
460+ enum mpi3mr_iocstate ioc_state;
461+ struct mpi3mr_bsg_in_adpinfo adpinfo;
462+
463+ memset(&adpinfo, 0, sizeof(adpinfo));
464+ adpinfo.adp_type = MPI3MR_BSG_ADPTYPE_AVGFAMILY;
465+ adpinfo.pci_dev_id = mrioc->pdev->device;
466+ adpinfo.pci_dev_hw_rev = mrioc->pdev->revision;
467+ adpinfo.pci_subsys_dev_id = mrioc->pdev->subsystem_device;
468+ adpinfo.pci_subsys_ven_id = mrioc->pdev->subsystem_vendor;
469+ adpinfo.pci_bus = mrioc->pdev->bus->number;
470+ adpinfo.pci_dev = PCI_SLOT(mrioc->pdev->devfn);
471+ adpinfo.pci_func = PCI_FUNC(mrioc->pdev->devfn);
472+ adpinfo.pci_seg_id = pci_domain_nr(mrioc->pdev->bus);
473+ adpinfo.app_intfc_ver = MPI3MR_IOCTL_VERSION;
474+
475+ ioc_state = mpi3mr_get_iocstate(mrioc);
476+ if (ioc_state == MRIOC_STATE_UNRECOVERABLE)
477+ adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_UNRECOVERABLE;
478+ else if ((mrioc->reset_in_progress) || (mrioc->stop_bsgs))
479+ adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_IN_RESET;
480+ else if (ioc_state == MRIOC_STATE_FAULT)
481+ adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_FAULT;
482+ else
483+ adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_OPERATIONAL;
484+
485+ memcpy((u8 *)&adpinfo.driver_info, (u8 *)&mrioc->driver_info,
486+ sizeof(adpinfo.driver_info));
487+
488+ if (job->request_payload.payload_len >= sizeof(adpinfo)) {
489+ sg_copy_from_buffer(job->request_payload.sg_list,
490+ job->request_payload.sg_cnt,
491+ &adpinfo, sizeof(adpinfo));
492+ return 0;
493+ }
494+ return -EINVAL;
495+}
496+
497+/**
498+ * mpi3mr_bsg_process_drv_cmds - Driver Command handler
499+ * @job: BSG job reference
500+ *
501+ * This function is the top level handler for driver commands,
502+ * this does basic validation of the buffer and identifies the
503+ * opcode and switches to correct sub handler.
504+ *
505+ * Return: 0 on success and proper error codes on failure
506+ */
507+static long mpi3mr_bsg_process_drv_cmds(struct bsg_job *job)
508+{
509+ long rval = -EINVAL;
510+ struct mpi3mr_ioc *mrioc = NULL;
511+ struct mpi3mr_bsg_packet *bsg_req = NULL;
512+ struct mpi3mr_bsg_drv_cmd *drvrcmd = NULL;
513+
514+ bsg_req = job->request;
515+ drvrcmd = &bsg_req->cmd.drvrcmd;
516+
517+ mrioc = mpi3mr_bsg_verify_adapter(drvrcmd->mrioc_id);
518+ if (!mrioc)
519+ return -ENODEV;
520+
521+ if (drvrcmd->opcode == MPI3MR_DRVBSG_OPCODE_ADPINFO) {
522+ rval = mpi3mr_bsg_populate_adpinfo(mrioc, job);
523+ return rval;
524+ }
525+
526+ if (mutex_lock_interruptible(&mrioc->bsg_cmds.mutex))
527+ return -ERESTARTSYS;
528+
529+ switch (drvrcmd->opcode) {
530+ case MPI3MR_DRVBSG_OPCODE_ADPRESET:
531+ rval = mpi3mr_bsg_adp_reset(mrioc, job);
532+ break;
533+ case MPI3MR_DRVBSG_OPCODE_ALLTGTDEVINFO:
534+ rval = mpi3mr_get_all_tgt_info(mrioc, job);
535+ break;
536+ case MPI3MR_DRVBSG_OPCODE_GETCHGCNT:
537+ rval = mpi3mr_get_change_count(mrioc, job);
538+ break;
539+ case MPI3MR_DRVBSG_OPCODE_LOGDATAENABLE:
540+ rval = mpi3mr_enable_logdata(mrioc, job);
541+ break;
542+ case MPI3MR_DRVBSG_OPCODE_GETLOGDATA:
543+ rval = mpi3mr_get_logdata(mrioc, job);
544+ break;
545+ case MPI3MR_DRVBSG_OPCODE_PELENABLE:
546+ rval = mpi3mr_bsg_pel_enable(mrioc, job);
547+ break;
548+ case MPI3MR_DRVBSG_OPCODE_UNKNOWN:
549+ default:
550+ pr_err("%s: unsupported driver command opcode %d\n",
551+ MPI3MR_DRIVER_NAME, drvrcmd->opcode);
552+ break;
553+ }
554+ mutex_unlock(&mrioc->bsg_cmds.mutex);
555+ return rval;
556+}
557+
558+/**
559+ * mpi3mr_bsg_build_sgl - SGL construction for MPI commands
560+ * @mpi_req: MPI request
561+ * @sgl_offset: offset to start sgl in the MPI request
562+ * @drv_bufs: DMA address of the buffers to be placed in sgl
563+ * @bufcnt: Number of DMA buffers
564+ * @is_rmc: Does the buffer list has management command buffer
565+ * @is_rmr: Does the buffer list has management response buffer
566+ * @num_datasges: Number of data buffers in the list
567+ *
568+ * This function places the DMA address of the given buffers in
569+ * proper format as SGEs in the given MPI request.
570+ *
571+ * Return: Nothing
572+ */
573+static void mpi3mr_bsg_build_sgl(u8 *mpi_req, uint32_t sgl_offset,
574+ struct mpi3mr_buf_map *drv_bufs, u8 bufcnt, u8 is_rmc,
575+ u8 is_rmr, u8 num_datasges)
576+{
577+ u8 *sgl = (mpi_req + sgl_offset), count = 0;
578+ struct mpi3_mgmt_passthrough_request *rmgmt_req =
579+ (struct mpi3_mgmt_passthrough_request *)mpi_req;
580+ struct mpi3mr_buf_map *drv_buf_iter = drv_bufs;
581+ u8 sgl_flags, sgl_flags_last;
582+
583+ sgl_flags = MPI3_SGE_FLAGS_ELEMENT_TYPE_SIMPLE |
584+ MPI3_SGE_FLAGS_DLAS_SYSTEM | MPI3_SGE_FLAGS_END_OF_BUFFER;
585+ sgl_flags_last = sgl_flags | MPI3_SGE_FLAGS_END_OF_LIST;
586+
587+ if (is_rmc) {
588+ mpi3mr_add_sg_single(&rmgmt_req->command_sgl,
589+ sgl_flags_last, drv_buf_iter->kern_buf_len,
590+ drv_buf_iter->kern_buf_dma);
591+ sgl = (u8 *)drv_buf_iter->kern_buf + drv_buf_iter->bsg_buf_len;
592+ drv_buf_iter++;
593+ count++;
594+ if (is_rmr) {
595+ mpi3mr_add_sg_single(&rmgmt_req->response_sgl,
596+ sgl_flags_last, drv_buf_iter->kern_buf_len,
597+ drv_buf_iter->kern_buf_dma);
598+ drv_buf_iter++;
599+ count++;
600+ } else
601+ mpi3mr_build_zero_len_sge(
602+ &rmgmt_req->response_sgl);
603+ }
604+ if (!num_datasges) {
605+ mpi3mr_build_zero_len_sge(sgl);
606+ return;
607+ }
608+ for (; count < bufcnt; count++, drv_buf_iter++) {
609+ if (drv_buf_iter->data_dir == DMA_NONE)
610+ continue;
611+ if (num_datasges == 1 || !is_rmc)
612+ mpi3mr_add_sg_single(sgl, sgl_flags_last,
613+ drv_buf_iter->kern_buf_len, drv_buf_iter->kern_buf_dma);
614+ else
615+ mpi3mr_add_sg_single(sgl, sgl_flags,
616+ drv_buf_iter->kern_buf_len, drv_buf_iter->kern_buf_dma);
617+ sgl += sizeof(struct mpi3_sge_common);
618+ num_datasges--;
619+ }
620+}
621+
622+/**
623+ * mpi3mr_get_nvme_data_fmt - returns the NVMe data format
624+ * @nvme_encap_request: NVMe encapsulated MPI request
625+ *
626+ * This function returns the type of the data format specified
627+ * in user provided NVMe command in NVMe encapsulated request.
628+ *
629+ * Return: Data format of the NVMe command (PRP/SGL etc)
630+ */
631+static unsigned int mpi3mr_get_nvme_data_fmt(
632+ struct mpi3_nvme_encapsulated_request *nvme_encap_request)
633+{
634+ u8 format = 0;
635+
636+ format = ((nvme_encap_request->command[0] & 0xc000) >> 14);
637+ return format;
638+
639+}
640+
641+/**
642+ * mpi3mr_build_nvme_sgl - SGL constructor for NVME
643+ * encapsulated request
644+ * @mrioc: Adapter instance reference
645+ * @nvme_encap_request: NVMe encapsulated MPI request
646+ * @drv_bufs: DMA address of the buffers to be placed in sgl
647+ * @bufcnt: Number of DMA buffers
648+ *
649+ * This function places the DMA address of the given buffers in
650+ * proper format as SGEs in the given NVMe encapsulated request.
651+ *
652+ * Return: 0 on success, -1 on failure
653+ */
654+static int mpi3mr_build_nvme_sgl(struct mpi3mr_ioc *mrioc,
655+ struct mpi3_nvme_encapsulated_request *nvme_encap_request,
656+ struct mpi3mr_buf_map *drv_bufs, u8 bufcnt)
657+{
658+ struct mpi3mr_nvme_pt_sge *nvme_sgl;
659+ u64 sgl_ptr;
660+ u8 count;
661+ size_t length = 0;
662+ struct mpi3mr_buf_map *drv_buf_iter = drv_bufs;
663+ u64 sgemod_mask = ((u64)((mrioc->facts.sge_mod_mask) <<
664+ mrioc->facts.sge_mod_shift) << 32);
665+ u64 sgemod_val = ((u64)(mrioc->facts.sge_mod_value) <<
666+ mrioc->facts.sge_mod_shift) << 32;
667+
668+ /*
669+ * Not all commands require a data transfer. If no data, just return
670+ * without constructing any sgl.
671+ */
672+ for (count = 0; count < bufcnt; count++, drv_buf_iter++) {
673+ if (drv_buf_iter->data_dir == DMA_NONE)
674+ continue;
675+ sgl_ptr = (u64)drv_buf_iter->kern_buf_dma;
676+ length = drv_buf_iter->kern_buf_len;
677+ break;
678+ }
679+ if (!length)
680+ return 0;
681+
682+ if (sgl_ptr & sgemod_mask) {
683+ dprint_bsg_err(mrioc,
684+ "%s: SGL address collides with SGE modifier\n",
685+ __func__);
686+ return -1;
687+ }
688+
689+ sgl_ptr &= ~sgemod_mask;
690+ sgl_ptr |= sgemod_val;
691+ nvme_sgl = (struct mpi3mr_nvme_pt_sge *)
692+ ((u8 *)(nvme_encap_request->command) + MPI3MR_NVME_CMD_SGL_OFFSET);
693+ memset(nvme_sgl, 0, sizeof(struct mpi3mr_nvme_pt_sge));
694+ nvme_sgl->base_addr = sgl_ptr;
695+ nvme_sgl->length = length;
696+ return 0;
697+}
698+
699+/**
700+ * mpi3mr_build_nvme_prp - PRP constructor for NVME
701+ * encapsulated request
702+ * @mrioc: Adapter instance reference
703+ * @nvme_encap_request: NVMe encapsulated MPI request
704+ * @drv_bufs: DMA address of the buffers to be placed in SGL
705+ * @bufcnt: Number of DMA buffers
706+ *
707+ * This function places the DMA address of the given buffers in
708+ * proper format as PRP entries in the given NVMe encapsulated
709+ * request.
710+ *
711+ * Return: 0 on success, -1 on failure
712+ */
713+static int mpi3mr_build_nvme_prp(struct mpi3mr_ioc *mrioc,
714+ struct mpi3_nvme_encapsulated_request *nvme_encap_request,
715+ struct mpi3mr_buf_map *drv_bufs, u8 bufcnt)
716+{
717+ int prp_size = MPI3MR_NVME_PRP_SIZE;
718+ __le64 *prp_entry, *prp1_entry, *prp2_entry;
719+ __le64 *prp_page;
720+ dma_addr_t prp_entry_dma, prp_page_dma, dma_addr;
721+ u32 offset, entry_len, dev_pgsz;
722+ u32 page_mask_result, page_mask;
723+ size_t length = 0;
724+ u8 count;
725+ struct mpi3mr_buf_map *drv_buf_iter = drv_bufs;
726+ u64 sgemod_mask = ((u64)((mrioc->facts.sge_mod_mask) <<
727+ mrioc->facts.sge_mod_shift) << 32);
728+ u64 sgemod_val = ((u64)(mrioc->facts.sge_mod_value) <<
729+ mrioc->facts.sge_mod_shift) << 32;
730+ u16 dev_handle = nvme_encap_request->dev_handle;
731+ struct mpi3mr_tgt_dev *tgtdev;
732+
733+ tgtdev = mpi3mr_get_tgtdev_by_handle(mrioc, dev_handle);
734+ if (!tgtdev) {
735+ dprint_bsg_err(mrioc, "%s: invalid device handle 0x%04x\n",
736+ __func__, dev_handle);
737+ return -1;
738+ }
739+
740+ if (tgtdev->dev_spec.pcie_inf.pgsz == 0) {
741+ dprint_bsg_err(mrioc,
742+ "%s: NVMe device page size is zero for handle 0x%04x\n",
743+ __func__, dev_handle);
744+ mpi3mr_tgtdev_put(tgtdev);
745+ return -1;
746+ }
747+
748+ dev_pgsz = 1 << (tgtdev->dev_spec.pcie_inf.pgsz);
749+ mpi3mr_tgtdev_put(tgtdev);
750+
751+ /*
752+ * Not all commands require a data transfer. If no data, just return
753+ * without constructing any PRP.
754+ */
755+ for (count = 0; count < bufcnt; count++, drv_buf_iter++) {
756+ if (drv_buf_iter->data_dir == DMA_NONE)
757+ continue;
758+ dma_addr = drv_buf_iter->kern_buf_dma;
759+ length = drv_buf_iter->kern_buf_len;
760+ break;
761+ }
762+
763+ if (!length)
764+ return 0;
765+
766+ mrioc->prp_sz = 0;
767+ mrioc->prp_list_virt = dma_alloc_coherent(&mrioc->pdev->dev,
768+ dev_pgsz, &mrioc->prp_list_dma, GFP_KERNEL);
769+
770+ if (!mrioc->prp_list_virt)
771+ return -1;
772+ mrioc->prp_sz = dev_pgsz;
773+
774+ /*
775+ * Set pointers to PRP1 and PRP2, which are in the NVMe command.
776+ * PRP1 is located at a 24 byte offset from the start of the NVMe
777+ * command. Then set the current PRP entry pointer to PRP1.
778+ */
779+ prp1_entry = (__le64 *)((u8 *)(nvme_encap_request->command) +
780+ MPI3MR_NVME_CMD_PRP1_OFFSET);
781+ prp2_entry = (__le64 *)((u8 *)(nvme_encap_request->command) +
782+ MPI3MR_NVME_CMD_PRP2_OFFSET);
783+ prp_entry = prp1_entry;
784+ /*
785+ * For the PRP entries, use the specially allocated buffer of
786+ * contiguous memory.
787+ */
788+ prp_page = (__le64 *)mrioc->prp_list_virt;
789+ prp_page_dma = mrioc->prp_list_dma;
790+
791+ /*
792+ * Check if we are within 1 entry of a page boundary we don't
793+ * want our first entry to be a PRP List entry.
794+ */
795+ page_mask = dev_pgsz - 1;
796+ page_mask_result = (uintptr_t)((u8 *)prp_page + prp_size) & page_mask;
797+ if (!page_mask_result) {
798+ dprint_bsg_err(mrioc, "%s: PRP page is not page aligned\n",
799+ __func__);
800+ goto err_out;
801+ }
802+
803+ /*
804+ * Set PRP physical pointer, which initially points to the current PRP
805+ * DMA memory page.
806+ */
807+ prp_entry_dma = prp_page_dma;
808+
809+
810+ /* Loop while the length is not zero. */
811+ while (length) {
812+ page_mask_result = (prp_entry_dma + prp_size) & page_mask;
813+ if (!page_mask_result && (length > dev_pgsz)) {
814+ dprint_bsg_err(mrioc,
815+ "%s: single PRP page is not sufficient\n",
816+ __func__);
817+ goto err_out;
818+ }
819+
820+ /* Need to handle if entry will be part of a page. */
821+ offset = dma_addr & page_mask;
822+ entry_len = dev_pgsz - offset;
823+
824+ if (prp_entry == prp1_entry) {
825+ /*
826+ * Must fill in the first PRP pointer (PRP1) before
827+ * moving on.
828+ */
829+ *prp1_entry = cpu_to_le64(dma_addr);
830+ if (*prp1_entry & sgemod_mask) {
831+ dprint_bsg_err(mrioc,
832+ "%s: PRP1 address collides with SGE modifier\n",
833+ __func__);
834+ goto err_out;
835+ }
836+ *prp1_entry &= ~sgemod_mask;
837+ *prp1_entry |= sgemod_val;
838+
839+ /*
840+ * Now point to the second PRP entry within the
841+ * command (PRP2).
842+ */
843+ prp_entry = prp2_entry;
844+ } else if (prp_entry == prp2_entry) {
845+ /*
846+ * Should the PRP2 entry be a PRP List pointer or just
847+ * a regular PRP pointer? If there is more than one
848+ * more page of data, must use a PRP List pointer.
849+ */
850+ if (length > dev_pgsz) {
851+ /*
852+ * PRP2 will contain a PRP List pointer because
853+ * more PRP's are needed with this command. The
854+ * list will start at the beginning of the
855+ * contiguous buffer.
856+ */
857+ *prp2_entry = cpu_to_le64(prp_entry_dma);
858+ if (*prp2_entry & sgemod_mask) {
859+ dprint_bsg_err(mrioc,
860+ "%s: PRP list address collides with SGE modifier\n",
861+ __func__);
862+ goto err_out;
863+ }
864+ *prp2_entry &= ~sgemod_mask;
865+ *prp2_entry |= sgemod_val;
866+
867+ /*
868+ * The next PRP Entry will be the start of the
869+ * first PRP List.
870+ */
871+ prp_entry = prp_page;
872+ continue;
873+ } else {
874+ /*
875+ * After this, the PRP Entries are complete.
876+ * This command uses 2 PRP's and no PRP list.
877+ */
878+ *prp2_entry = cpu_to_le64(dma_addr);
879+ if (*prp2_entry & sgemod_mask) {
880+ dprint_bsg_err(mrioc,
881+ "%s: PRP2 collides with SGE modifier\n",
882+ __func__);
883+ goto err_out;
884+ }
885+ *prp2_entry &= ~sgemod_mask;
886+ *prp2_entry |= sgemod_val;
887+ }
888+ } else {
889+ /*
890+ * Put entry in list and bump the addresses.
891+ *
892+ * After PRP1 and PRP2 are filled in, this will fill in
893+ * all remaining PRP entries in a PRP List, one per
894+ * each time through the loop.
895+ */
896+ *prp_entry = cpu_to_le64(dma_addr);
897+ if (*prp1_entry & sgemod_mask) {
898+ dprint_bsg_err(mrioc,
899+ "%s: PRP address collides with SGE modifier\n",
900+ __func__);
901+ goto err_out;
902+ }
903+ *prp_entry &= ~sgemod_mask;
904+ *prp_entry |= sgemod_val;
905+ prp_entry++;
906+ prp_entry_dma++;
907+ }
908+
909+ /*
910+ * Bump the phys address of the command's data buffer by the
911+ * entry_len.
912+ */
913+ dma_addr += entry_len;
914+
915+ /* decrement length accounting for last partial page. */
916+ if (entry_len > length)
917+ length = 0;
918+ else
919+ length -= entry_len;
920+ }
921+ return 0;
922+err_out:
923+ if (mrioc->prp_list_virt) {
924+ dma_free_coherent(&mrioc->pdev->dev, mrioc->prp_sz,
925+ mrioc->prp_list_virt, mrioc->prp_list_dma);
926+ mrioc->prp_list_virt = NULL;
927+ }
928+ return -1;
929+}
930+/**
931+ * mpi3mr_bsg_process_mpt_cmds - MPI Pass through BSG handler
932+ * @job: BSG job reference
933+ *
934+ * This function is the top level handler for MPI Pass through
935+ * command, this does basic validation of the input data buffers,
936+ * identifies the given buffer types and MPI command, allocates
937+ * DMAable memory for user given buffers, construstcs SGL
938+ * properly and passes the command to the firmware.
939+ *
940+ * Once the MPI command is completed the driver copies the data
941+ * if any and reply, sense information to user provided buffers.
942+ * If the command is timed out then issues controller reset
943+ * prior to returning.
944+ *
945+ * Return: 0 on success and proper error codes on failure
946+ */
947+
948+static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *reply_payload_rcv_len)
949+{
950+ long rval = -EINVAL;
951+
952+ struct mpi3mr_ioc *mrioc = NULL;
953+ u8 *mpi_req = NULL, *sense_buff_k = NULL;
954+ u8 mpi_msg_size = 0;
955+ struct mpi3mr_bsg_packet *bsg_req = NULL;
956+ struct mpi3mr_bsg_mptcmd *karg;
957+ struct mpi3mr_buf_entry *buf_entries = NULL;
958+ struct mpi3mr_buf_map *drv_bufs = NULL, *drv_buf_iter = NULL;
959+ u8 count, bufcnt = 0, is_rmcb = 0, is_rmrb = 0, din_cnt = 0, dout_cnt = 0;
960+ u8 invalid_be = 0, erb_offset = 0xFF, mpirep_offset = 0xFF, sg_entries = 0;
961+ u8 block_io = 0, resp_code = 0, nvme_fmt = 0;
962+ struct mpi3_request_header *mpi_header = NULL;
963+ struct mpi3_status_reply_descriptor *status_desc;
964+ struct mpi3_scsi_task_mgmt_request *tm_req;
965+ u32 erbsz = MPI3MR_SENSE_BUF_SZ, tmplen;
966+ u16 dev_handle;
967+ struct mpi3mr_tgt_dev *tgtdev;
968+ struct mpi3mr_stgt_priv_data *stgt_priv = NULL;
969+ struct mpi3mr_bsg_in_reply_buf *bsg_reply_buf = NULL;
970+ u32 din_size = 0, dout_size = 0;
971+ u8 *din_buf = NULL, *dout_buf = NULL;
972+ u8 *sgl_iter = NULL, *sgl_din_iter = NULL, *sgl_dout_iter = NULL;
973+
974+ bsg_req = job->request;
975+ karg = (struct mpi3mr_bsg_mptcmd *)&bsg_req->cmd.mptcmd;
976+
977+ mrioc = mpi3mr_bsg_verify_adapter(karg->mrioc_id);
978+ if (!mrioc)
979+ return -ENODEV;
980+
981+ if (karg->timeout < MPI3MR_APP_DEFAULT_TIMEOUT)
982+ karg->timeout = MPI3MR_APP_DEFAULT_TIMEOUT;
983+
984+ mpi_req = kzalloc(MPI3MR_ADMIN_REQ_FRAME_SZ, GFP_KERNEL);
985+ if (!mpi_req)
986+ return -ENOMEM;
987+ mpi_header = (struct mpi3_request_header *)mpi_req;
988+
989+ bufcnt = karg->buf_entry_list.num_of_entries;
990+ drv_bufs = kzalloc((sizeof(*drv_bufs) * bufcnt), GFP_KERNEL);
991+ if (!drv_bufs) {
992+ rval = -ENOMEM;
993+ goto out;
994+ }
995+
996+ dout_buf = kzalloc(job->request_payload.payload_len,
997+ GFP_KERNEL);
998+ if (!dout_buf) {
999+ rval = -ENOMEM;
1000+ goto out;
1001+ }
1002+
1003+ din_buf = kzalloc(job->reply_payload.payload_len,
1004+ GFP_KERNEL);
1005+ if (!din_buf) {
1006+ rval = -ENOMEM;
1007+ goto out;
1008+ }
1009+
1010+ sg_copy_to_buffer(job->request_payload.sg_list,
1011+ job->request_payload.sg_cnt,
1012+ dout_buf, job->request_payload.payload_len);
1013+
1014+ buf_entries = karg->buf_entry_list.buf_entry;
1015+ sgl_din_iter = din_buf;
1016+ sgl_dout_iter = dout_buf;
1017+ drv_buf_iter = drv_bufs;
1018+
1019+ for (count = 0; count < bufcnt; count++, buf_entries++, drv_buf_iter++) {
1020+
1021+ if (sgl_dout_iter > (dout_buf + job->request_payload.payload_len)) {
1022+ dprint_bsg_err(mrioc, "%s: data_out buffer length mismatch\n",
1023+ __func__);
1024+ rval = -EINVAL;
1025+ goto out;
1026+ }
1027+ if (sgl_din_iter > (din_buf + job->reply_payload.payload_len)) {
1028+ dprint_bsg_err(mrioc, "%s: data_in buffer length mismatch\n",
1029+ __func__);
1030+ rval = -EINVAL;
1031+ goto out;
1032+ }
1033+
1034+ switch (buf_entries->buf_type) {
1035+ case MPI3MR_BSG_BUFTYPE_RAIDMGMT_CMD:
1036+ sgl_iter = sgl_dout_iter;
1037+ sgl_dout_iter += buf_entries->buf_len;
1038+ drv_buf_iter->data_dir = DMA_TO_DEVICE;
1039+ is_rmcb = 1;
1040+ if (count != 0)
1041+ invalid_be = 1;
1042+ break;
1043+ case MPI3MR_BSG_BUFTYPE_RAIDMGMT_RESP:
1044+ sgl_iter = sgl_din_iter;
1045+ sgl_din_iter += buf_entries->buf_len;
1046+ drv_buf_iter->data_dir = DMA_FROM_DEVICE;
1047+ is_rmrb = 1;
1048+ if (count != 1 || !is_rmcb)
1049+ invalid_be = 1;
1050+ break;
1051+ case MPI3MR_BSG_BUFTYPE_DATA_IN:
1052+ sgl_iter = sgl_din_iter;
1053+ sgl_din_iter += buf_entries->buf_len;
1054+ drv_buf_iter->data_dir = DMA_FROM_DEVICE;
1055+ din_cnt++;
1056+ din_size += drv_buf_iter->bsg_buf_len;
1057+ if ((din_cnt > 1) && !is_rmcb)
1058+ invalid_be = 1;
1059+ break;
1060+ case MPI3MR_BSG_BUFTYPE_DATA_OUT:
1061+ sgl_iter = sgl_dout_iter;
1062+ sgl_dout_iter += buf_entries->buf_len;
1063+ drv_buf_iter->data_dir = DMA_TO_DEVICE;
1064+ dout_cnt++;
1065+ dout_size += drv_buf_iter->bsg_buf_len;
1066+ if ((dout_cnt > 1) && !is_rmcb)
1067+ invalid_be = 1;
1068+ break;
1069+ case MPI3MR_BSG_BUFTYPE_MPI_REPLY:
1070+ sgl_iter = sgl_din_iter;
1071+ sgl_din_iter += buf_entries->buf_len;
1072+ drv_buf_iter->data_dir = DMA_NONE;
1073+ mpirep_offset = count;
1074+ break;
1075+ case MPI3MR_BSG_BUFTYPE_ERR_RESPONSE:
1076+ sgl_iter = sgl_din_iter;
1077+ sgl_din_iter += buf_entries->buf_len;
1078+ drv_buf_iter->data_dir = DMA_NONE;
1079+ erb_offset = count;
1080+ break;
1081+ case MPI3MR_BSG_BUFTYPE_MPI_REQUEST:
1082+ sgl_iter = sgl_dout_iter;
1083+ sgl_dout_iter += buf_entries->buf_len;
1084+ drv_buf_iter->data_dir = DMA_NONE;
1085+ mpi_msg_size = buf_entries->buf_len;
1086+ if ((!mpi_msg_size || (mpi_msg_size % 4)) ||
1087+ (mpi_msg_size > MPI3MR_ADMIN_REQ_FRAME_SZ)) {
1088+ dprint_bsg_err(mrioc, "%s: invalid MPI message size\n",
1089+ __func__);
1090+ rval = -EINVAL;
1091+ goto out;
1092+ }
1093+ memcpy(mpi_req, sgl_iter, buf_entries->buf_len);
1094+ break;
1095+ default:
1096+ invalid_be = 1;
1097+ break;
1098+ }
1099+ if (invalid_be) {
1100+ dprint_bsg_err(mrioc, "%s: invalid buffer entries passed\n",
1101+ __func__);
1102+ rval = -EINVAL;
1103+ goto out;
1104+ }
1105+
1106+ drv_buf_iter->bsg_buf = sgl_iter;
1107+ drv_buf_iter->bsg_buf_len = buf_entries->buf_len;
1108+
1109+ }
1110+ if (!is_rmcb && (dout_cnt || din_cnt)) {
1111+ sg_entries = dout_cnt + din_cnt;
1112+ if (((mpi_msg_size) + (sg_entries *
1113+ sizeof(struct mpi3_sge_common))) > MPI3MR_ADMIN_REQ_FRAME_SZ) {
1114+ dprint_bsg_err(mrioc,
1115+ "%s:%d: invalid message size passed\n",
1116+ __func__, __LINE__);
1117+ rval = -EINVAL;
1118+ goto out;
1119+ }
1120+ }
1121+ if (din_size > MPI3MR_MAX_APP_XFER_SIZE) {
1122+ dprint_bsg_err(mrioc,
1123+ "%s:%d: invalid data transfer size passed for function 0x%x din_size=%d\n",
1124+ __func__, __LINE__, mpi_header->function, din_size);
1125+ rval = -EINVAL;
1126+ goto out;
1127+ }
1128+ if (dout_size > MPI3MR_MAX_APP_XFER_SIZE) {
1129+ dprint_bsg_err(mrioc,
1130+ "%s:%d: invalid data transfer size passed for function 0x%x dout_size = %d\n",
1131+ __func__, __LINE__, mpi_header->function, dout_size);
1132+ rval = -EINVAL;
1133+ goto out;
1134+ }
1135+
1136+ drv_buf_iter = drv_bufs;
1137+ for (count = 0; count < bufcnt; count++, drv_buf_iter++) {
1138+ if (drv_buf_iter->data_dir == DMA_NONE)
1139+ continue;
1140+
1141+ drv_buf_iter->kern_buf_len = drv_buf_iter->bsg_buf_len;
1142+ if (is_rmcb && !count)
1143+ drv_buf_iter->kern_buf_len += ((dout_cnt + din_cnt) *
1144+ sizeof(struct mpi3_sge_common));
1145+
1146+ if (!drv_buf_iter->kern_buf_len)
1147+ continue;
1148+
1149+ drv_buf_iter->kern_buf = dma_alloc_coherent(&mrioc->pdev->dev,
1150+ drv_buf_iter->kern_buf_len, &drv_buf_iter->kern_buf_dma,
1151+ GFP_KERNEL);
1152+ if (!drv_buf_iter->kern_buf) {
1153+ rval = -ENOMEM;
1154+ goto out;
1155+ }
1156+ if (drv_buf_iter->data_dir == DMA_TO_DEVICE) {
1157+ tmplen = min(drv_buf_iter->kern_buf_len,
1158+ drv_buf_iter->bsg_buf_len);
1159+ memcpy(drv_buf_iter->kern_buf, drv_buf_iter->bsg_buf, tmplen);
1160+ }
1161+ }
1162+
1163+ if (erb_offset != 0xFF) {
1164+ sense_buff_k = kzalloc(erbsz, GFP_KERNEL);
1165+ if (!sense_buff_k) {
1166+ rval = -ENOMEM;
1167+ goto out;
1168+ }
1169+ }
1170+
1171+ if (mutex_lock_interruptible(&mrioc->bsg_cmds.mutex)) {
1172+ rval = -ERESTARTSYS;
1173+ goto out;
1174+ }
1175+ if (mrioc->bsg_cmds.state & MPI3MR_CMD_PENDING) {
1176+ rval = -EAGAIN;
1177+ dprint_bsg_err(mrioc, "%s: command is in use\n", __func__);
1178+ mutex_unlock(&mrioc->bsg_cmds.mutex);
1179+ goto out;
1180+ }
1181+ if (mrioc->unrecoverable) {
1182+ dprint_bsg_err(mrioc, "%s: unrecoverable controller\n",
1183+ __func__);
1184+ rval = -EFAULT;
1185+ mutex_unlock(&mrioc->bsg_cmds.mutex);
1186+ goto out;
1187+ }
1188+ if (mrioc->reset_in_progress) {
1189+ dprint_bsg_err(mrioc, "%s: reset in progress\n", __func__);
1190+ rval = -EAGAIN;
1191+ mutex_unlock(&mrioc->bsg_cmds.mutex);
1192+ goto out;
1193+ }
1194+ if (mrioc->stop_bsgs) {
1195+ dprint_bsg_err(mrioc, "%s: bsgs are blocked\n", __func__);
1196+ rval = -EAGAIN;
1197+ mutex_unlock(&mrioc->bsg_cmds.mutex);
1198+ goto out;
1199+ }
1200+
1201+ if (mpi_header->function == MPI3_BSG_FUNCTION_NVME_ENCAPSULATED) {
1202+ nvme_fmt = mpi3mr_get_nvme_data_fmt(
1203+ (struct mpi3_nvme_encapsulated_request *)mpi_req);
1204+ if (nvme_fmt == MPI3MR_NVME_DATA_FORMAT_PRP) {
1205+ if (mpi3mr_build_nvme_prp(mrioc,
1206+ (struct mpi3_nvme_encapsulated_request *)mpi_req,
1207+ drv_bufs, bufcnt)) {
1208+ rval = -ENOMEM;
1209+ mutex_unlock(&mrioc->bsg_cmds.mutex);
1210+ goto out;
1211+ }
1212+ } else if (nvme_fmt == MPI3MR_NVME_DATA_FORMAT_SGL1 ||
1213+ nvme_fmt == MPI3MR_NVME_DATA_FORMAT_SGL2) {
1214+ if (mpi3mr_build_nvme_sgl(mrioc,
1215+ (struct mpi3_nvme_encapsulated_request *)mpi_req,
1216+ drv_bufs, bufcnt)) {
1217+ rval = -EINVAL;
1218+ mutex_unlock(&mrioc->bsg_cmds.mutex);
1219+ goto out;
1220+ }
1221+ } else {
1222+ dprint_bsg_err(mrioc,
1223+ "%s:invalid NVMe command format\n", __func__);
1224+ rval = -EINVAL;
1225+ mutex_unlock(&mrioc->bsg_cmds.mutex);
1226+ goto out;
1227+ }
1228+ } else {
1229+ mpi3mr_bsg_build_sgl(mpi_req, (mpi_msg_size),
1230+ drv_bufs, bufcnt, is_rmcb, is_rmrb,
1231+ (dout_cnt + din_cnt));
1232+ }
1233+
1234+ if (mpi_header->function == MPI3_BSG_FUNCTION_SCSI_TASK_MGMT) {
1235+ tm_req = (struct mpi3_scsi_task_mgmt_request *)mpi_req;
1236+ if (tm_req->task_type !=
1237+ MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK) {
1238+ dev_handle = tm_req->dev_handle;
1239+ block_io = 1;
1240+ }
1241+ }
1242+ if (block_io) {
1243+ tgtdev = mpi3mr_get_tgtdev_by_handle(mrioc, dev_handle);
1244+ if (tgtdev && tgtdev->starget && tgtdev->starget->hostdata) {
1245+ stgt_priv = (struct mpi3mr_stgt_priv_data *)
1246+ tgtdev->starget->hostdata;
1247+ atomic_inc(&stgt_priv->block_io);
1248+ mpi3mr_tgtdev_put(tgtdev);
1249+ }
1250+ }
1251+
1252+ mrioc->bsg_cmds.state = MPI3MR_CMD_PENDING;
1253+ mrioc->bsg_cmds.is_waiting = 1;
1254+ mrioc->bsg_cmds.callback = NULL;
1255+ mrioc->bsg_cmds.is_sense = 0;
1256+ mrioc->bsg_cmds.sensebuf = sense_buff_k;
1257+ memset(mrioc->bsg_cmds.reply, 0, mrioc->reply_sz);
1258+ mpi_header->host_tag = cpu_to_le16(MPI3MR_HOSTTAG_BSG_CMDS);
1259+ if (mrioc->logging_level & MPI3_DEBUG_BSG_INFO) {
1260+ dprint_bsg_info(mrioc,
1261+ "%s: posting bsg request to the controller\n", __func__);
1262+ dprint_dump(mpi_req, MPI3MR_ADMIN_REQ_FRAME_SZ,
1263+ "bsg_mpi3_req");
1264+ if (mpi_header->function == MPI3_BSG_FUNCTION_MGMT_PASSTHROUGH) {
1265+ drv_buf_iter = &drv_bufs[0];
1266+ dprint_dump(drv_buf_iter->kern_buf,
1267+ drv_buf_iter->kern_buf_len, "mpi3_mgmt_req");
1268+ }
1269+ }
1270+
1271+ init_completion(&mrioc->bsg_cmds.done);
1272+ rval = mpi3mr_admin_request_post(mrioc, mpi_req,
1273+ MPI3MR_ADMIN_REQ_FRAME_SZ, 0);
1274+
1275+
1276+ if (rval) {
1277+ mrioc->bsg_cmds.is_waiting = 0;
1278+ dprint_bsg_err(mrioc,
1279+ "%s: posting bsg request is failed\n", __func__);
1280+ rval = -EAGAIN;
1281+ goto out_unlock;
1282+ }
1283+ wait_for_completion_timeout(&mrioc->bsg_cmds.done,
1284+ (karg->timeout * HZ));
1285+ if (block_io && stgt_priv)
1286+ atomic_dec(&stgt_priv->block_io);
1287+ if (!(mrioc->bsg_cmds.state & MPI3MR_CMD_COMPLETE)) {
1288+ mrioc->bsg_cmds.is_waiting = 0;
1289+ rval = -EAGAIN;
1290+ if (mrioc->bsg_cmds.state & MPI3MR_CMD_RESET)
1291+ goto out_unlock;
1292+ dprint_bsg_err(mrioc,
1293+ "%s: bsg request timedout after %d seconds\n", __func__,
1294+ karg->timeout);
1295+ if (mrioc->logging_level & MPI3_DEBUG_BSG_ERROR) {
1296+ dprint_dump(mpi_req, MPI3MR_ADMIN_REQ_FRAME_SZ,
1297+ "bsg_mpi3_req");
1298+ if (mpi_header->function ==
1299+ MPI3_BSG_FUNCTION_MGMT_PASSTHROUGH) {
1300+ drv_buf_iter = &drv_bufs[0];
1301+ dprint_dump(drv_buf_iter->kern_buf,
1302+ drv_buf_iter->kern_buf_len, "mpi3_mgmt_req");
1303+ }
1304+ }
1305+
1306+ if ((mpi_header->function == MPI3_BSG_FUNCTION_NVME_ENCAPSULATED) ||
1307+ (mpi_header->function == MPI3_BSG_FUNCTION_SCSI_IO))
1308+ mpi3mr_issue_tm(mrioc,
1309+ MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
1310+ mpi_header->function_dependent, 0,
1311+ MPI3MR_HOSTTAG_BLK_TMS, MPI3MR_RESETTM_TIMEOUT,
1312+ &mrioc->host_tm_cmds, &resp_code, NULL);
1313+ if (!(mrioc->bsg_cmds.state & MPI3MR_CMD_COMPLETE) &&
1314+ !(mrioc->bsg_cmds.state & MPI3MR_CMD_RESET))
1315+ mpi3mr_soft_reset_handler(mrioc,
1316+ MPI3MR_RESET_FROM_APP_TIMEOUT, 1);
1317+ goto out_unlock;
1318+ }
1319+ dprint_bsg_info(mrioc, "%s: bsg request is completed\n", __func__);
1320+
1321+ if (mrioc->prp_list_virt) {
1322+ dma_free_coherent(&mrioc->pdev->dev, mrioc->prp_sz,
1323+ mrioc->prp_list_virt, mrioc->prp_list_dma);
1324+ mrioc->prp_list_virt = NULL;
1325+ }
1326+
1327+ if ((mrioc->bsg_cmds.ioc_status & MPI3_IOCSTATUS_STATUS_MASK)
1328+ != MPI3_IOCSTATUS_SUCCESS) {
1329+ dprint_bsg_info(mrioc,
1330+ "%s: command failed, ioc_status(0x%04x) log_info(0x%08x)\n",
1331+ __func__,
1332+ (mrioc->bsg_cmds.ioc_status & MPI3_IOCSTATUS_STATUS_MASK),
1333+ mrioc->bsg_cmds.ioc_loginfo);
1334+ }
1335+
1336+ if ((mpirep_offset != 0xFF) &&
1337+ drv_bufs[mpirep_offset].bsg_buf_len) {
1338+ drv_buf_iter = &drv_bufs[mpirep_offset];
1339+ drv_buf_iter->kern_buf_len = (sizeof(*bsg_reply_buf) - 1 +
1340+ mrioc->reply_sz);
1341+ bsg_reply_buf = kzalloc(drv_buf_iter->kern_buf_len, GFP_KERNEL);
1342+
1343+ if (!bsg_reply_buf) {
1344+ rval = -ENOMEM;
1345+ goto out_unlock;
1346+ }
1347+ if (mrioc->bsg_cmds.state & MPI3MR_CMD_REPLY_VALID) {
1348+ bsg_reply_buf->mpi_reply_type =
1349+ MPI3MR_BSG_MPI_REPLY_BUFTYPE_ADDRESS;
1350+ memcpy(bsg_reply_buf->reply_buf,
1351+ mrioc->bsg_cmds.reply, mrioc->reply_sz);
1352+ } else {
1353+ bsg_reply_buf->mpi_reply_type =
1354+ MPI3MR_BSG_MPI_REPLY_BUFTYPE_STATUS;
1355+ status_desc = (struct mpi3_status_reply_descriptor *)
1356+ bsg_reply_buf->reply_buf;
1357+ status_desc->ioc_status = mrioc->bsg_cmds.ioc_status;
1358+ status_desc->ioc_log_info = mrioc->bsg_cmds.ioc_loginfo;
1359+ }
1360+ tmplen = min(drv_buf_iter->kern_buf_len,
1361+ drv_buf_iter->bsg_buf_len);
1362+ memcpy(drv_buf_iter->bsg_buf, bsg_reply_buf, tmplen);
1363+ }
1364+
1365+ if (erb_offset != 0xFF && mrioc->bsg_cmds.sensebuf &&
1366+ mrioc->bsg_cmds.is_sense) {
1367+ drv_buf_iter = &drv_bufs[erb_offset];
1368+ tmplen = min(erbsz, drv_buf_iter->bsg_buf_len);
1369+ memcpy(drv_buf_iter->bsg_buf, sense_buff_k, tmplen);
1370+ }
1371+
1372+ drv_buf_iter = drv_bufs;
1373+ for (count = 0; count < bufcnt; count++, drv_buf_iter++) {
1374+ if (drv_buf_iter->data_dir == DMA_NONE)
1375+ continue;
1376+ if (drv_buf_iter->data_dir == DMA_FROM_DEVICE) {
1377+ tmplen = min(drv_buf_iter->kern_buf_len,
1378+ drv_buf_iter->bsg_buf_len);
1379+ memcpy(drv_buf_iter->bsg_buf,
1380+ drv_buf_iter->kern_buf, tmplen);
1381+ }
1382+ }
1383+
1384+out_unlock:
1385+ if (din_buf) {
1386+ *reply_payload_rcv_len =
1387+ sg_copy_from_buffer(job->reply_payload.sg_list,
1388+ job->reply_payload.sg_cnt,
1389+ din_buf, job->reply_payload.payload_len);
1390+ }
1391+ mrioc->bsg_cmds.is_sense = 0;
1392+ mrioc->bsg_cmds.sensebuf = NULL;
1393+ mrioc->bsg_cmds.state = MPI3MR_CMD_NOTUSED;
1394+ mutex_unlock(&mrioc->bsg_cmds.mutex);
1395+out:
1396+ kfree(sense_buff_k);
1397+ kfree(dout_buf);
1398+ kfree(din_buf);
1399+ kfree(mpi_req);
1400+ if (drv_bufs) {
1401+ drv_buf_iter = drv_bufs;
1402+ for (count = 0; count < bufcnt; count++, drv_buf_iter++) {
1403+ if (drv_buf_iter->kern_buf && drv_buf_iter->kern_buf_dma)
1404+ dma_free_coherent(&mrioc->pdev->dev,
1405+ drv_buf_iter->kern_buf_len,
1406+ drv_buf_iter->kern_buf,
1407+ drv_buf_iter->kern_buf_dma);
1408+ }
1409+ kfree(drv_bufs);
1410+ }
1411+ kfree(bsg_reply_buf);
1412+ return rval;
1413+}
1414+
1415+/**
1416+ * mpi3mr_app_save_logdata - Save Log Data events
1417+ * @mrioc: Adapter instance reference
1418+ * @event_data: event data associated with log data event
1419+ * @event_data_size: event data size to copy
1420+ *
1421+ * If log data event caching is enabled by the applicatiobns,
1422+ * then this function saves the log data in the circular queue
1423+ * and Sends async signal SIGIO to indicate there is an async
1424+ * event from the firmware to the event monitoring applications.
1425+ *
1426+ * Return:Nothing
1427+ */
1428+void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data,
1429+ u16 event_data_size)
1430+{
1431+ u32 index = mrioc->logdata_buf_idx, sz;
1432+ struct mpi3mr_logdata_entry *entry;
1433+
1434+ if (!(mrioc->logdata_buf))
1435+ return;
1436+
1437+ entry = (struct mpi3mr_logdata_entry *)
1438+ (mrioc->logdata_buf + (index * mrioc->logdata_entry_sz));
1439+ entry->valid_entry = 1;
1440+ sz = min(mrioc->logdata_entry_sz, event_data_size);
1441+ memcpy(entry->data, event_data, sz);
1442+ mrioc->logdata_buf_idx =
1443+ ((++index) % MPI3MR_BSG_LOGDATA_MAX_ENTRIES);
1444+ atomic64_inc(&event_counter);
1445+}
1446+
1447+/**
1448+ * mpi3mr_bsg_request - bsg request entry point
1449+ * @job: BSG job reference
1450+ *
1451+ * This is driver's entry point for bsg requests
1452+ *
1453+ * Return: 0 on success and proper error codes on failure
1454+ */
1455+static int mpi3mr_bsg_request(struct bsg_job *job)
1456+{
1457+ long rval = -EINVAL;
1458+ unsigned int reply_payload_rcv_len = 0;
1459+
1460+ struct mpi3mr_bsg_packet *bsg_req = job->request;
1461+
1462+ switch (bsg_req->cmd_type) {
1463+ case MPI3MR_DRV_CMD:
1464+ rval = mpi3mr_bsg_process_drv_cmds(job);
1465+ break;
1466+ case MPI3MR_MPT_CMD:
1467+ rval = mpi3mr_bsg_process_mpt_cmds(job, &reply_payload_rcv_len);
1468+ break;
1469+ default:
1470+ pr_err("%s: unsupported BSG command(0x%08x)\n",
1471+ MPI3MR_DRIVER_NAME, bsg_req->cmd_type);
1472+ break;
1473+ }
1474+
1475+ bsg_job_done(job, rval, reply_payload_rcv_len);
1476+
1477+ return 0;
1478+}
1479+
1480+/**
1481+ * mpi3mr_bsg_exit - de-registration from bsg layer
1482+ *
1483+ * This will be called during driver unload and all
1484+ * bsg resources allocated during load will be freed.
1485+ *
1486+ * Return:Nothing
1487+ */
1488+void mpi3mr_bsg_exit(struct mpi3mr_ioc *mrioc)
1489+{
1490+ if (!mrioc->bsg_queue)
1491+ return;
1492+
1493+ bsg_remove_queue(mrioc->bsg_queue);
1494+ mrioc->bsg_queue = NULL;
1495+
1496+ device_del(mrioc->bsg_dev);
1497+ put_device(mrioc->bsg_dev);
1498+ kfree(mrioc->bsg_dev);
1499+}
1500+
1501+/**
1502+ * mpi3mr_bsg_node_release -release bsg device node
1503+ * @dev: bsg device node
1504+ *
1505+ * decrements bsg dev reference count
1506+ *
1507+ * Return:Nothing
1508+ */
1509+static void mpi3mr_bsg_node_release(struct device *dev)
1510+{
1511+ put_device(dev);
1512+}
1513+
1514+/**
1515+ * mpi3mr_bsg_init - registration with bsg layer
1516+ *
1517+ * This will be called during driver load and it will
1518+ * register driver with bsg layer
1519+ *
1520+ * Return:Nothing
1521+ */
1522+void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc)
1523+{
1524+ mrioc->bsg_dev = kzalloc(sizeof(struct device), GFP_KERNEL);
1525+ if (!mrioc->bsg_dev) {
1526+ ioc_err(mrioc, "bsg device mem allocation failed\n");
1527+ return;
1528+ }
1529+
1530+ device_initialize(mrioc->bsg_dev);
1531+ dev_set_name(mrioc->bsg_dev, "mpi3mrctl%u", mrioc->id);
1532+
1533+ if (device_add(mrioc->bsg_dev)) {
1534+ ioc_err(mrioc, "%s: bsg device add failed\n",
1535+ dev_name(mrioc->bsg_dev));
1536+ goto err_device_add;
1537+ }
1538+
1539+ mrioc->bsg_dev->release = mpi3mr_bsg_node_release;
1540+
1541+ mrioc->bsg_queue = bsg_setup_queue(mrioc->bsg_dev, dev_name(mrioc->bsg_dev),
1542+ mpi3mr_bsg_request, NULL, 0);
1543+ if (IS_ERR(mrioc->bsg_queue)) {
1544+ ioc_err(mrioc, "%s: bsg registration failed\n",
1545+ dev_name(mrioc->bsg_dev));
1546+ goto err_setup_queue;
1547+ }
1548+
1549+ blk_queue_max_segments(mrioc->bsg_queue, MPI3MR_MAX_APP_XFER_SEGMENTS);
1550+ blk_queue_max_hw_sectors(mrioc->bsg_queue, MPI3MR_MAX_APP_XFER_SECTORS);
1551+
1552+ return;
1553+
1554+err_setup_queue:
1555+ device_del(mrioc->bsg_dev);
1556+ put_device(mrioc->bsg_dev);
1557+err_device_add:
1558+ kfree(mrioc->bsg_dev);
1559+}
1560+
1561+/**
1562+ * version_fw_show - SysFS callback for firmware version read
1563+ * @dev: class device
1564+ * @attr: Device attributes
1565+ * @buf: Buffer to copy
1566+ *
1567+ * Return: sysfs_emit() return after copying firmware version
1568+ */
1569+static ssize_t
1570+version_fw_show(struct device *dev, struct device_attribute *attr,
1571+ char *buf)
1572+{
1573+ struct Scsi_Host *shost = class_to_shost(dev);
1574+ struct mpi3mr_ioc *mrioc = shost_priv(shost);
1575+ struct mpi3mr_compimg_ver *fwver = &mrioc->facts.fw_ver;
1576+
1577+ return sysfs_emit(buf, "%d.%d.%d.%d.%05d-%05d\n",
1578+ fwver->gen_major, fwver->gen_minor, fwver->ph_major,
1579+ fwver->ph_minor, fwver->cust_id, fwver->build_num);
1580+}
1581+static DEVICE_ATTR_RO(version_fw);
1582+
1583+/**
1584+ * fw_queue_depth_show - SysFS callback for firmware max cmds
1585+ * @dev: class device
1586+ * @attr: Device attributes
1587+ * @buf: Buffer to copy
1588+ *
1589+ * Return: sysfs_emit() return after copying firmware max commands
1590+ */
1591+static ssize_t
1592+fw_queue_depth_show(struct device *dev, struct device_attribute *attr,
1593+ char *buf)
1594+{
1595+ struct Scsi_Host *shost = class_to_shost(dev);
1596+ struct mpi3mr_ioc *mrioc = shost_priv(shost);
1597+
1598+ return sysfs_emit(buf, "%d\n", mrioc->facts.max_reqs);
1599+}
1600+static DEVICE_ATTR_RO(fw_queue_depth);
1601+
1602+/**
1603+ * op_req_q_count_show - SysFS callback for request queue count
1604+ * @dev: class device
1605+ * @attr: Device attributes
1606+ * @buf: Buffer to copy
1607+ *
1608+ * Return: sysfs_emit() return after copying request queue count
1609+ */
1610+static ssize_t
1611+op_req_q_count_show(struct device *dev, struct device_attribute *attr,
1612+ char *buf)
1613+{
1614+ struct Scsi_Host *shost = class_to_shost(dev);
1615+ struct mpi3mr_ioc *mrioc = shost_priv(shost);
1616+
1617+ return sysfs_emit(buf, "%d\n", mrioc->num_op_req_q);
1618+}
1619+static DEVICE_ATTR_RO(op_req_q_count);
1620+
1621+/**
1622+ * reply_queue_count_show - SysFS callback for reply queue count
1623+ * @dev: class device
1624+ * @attr: Device attributes
1625+ * @buf: Buffer to copy
1626+ *
1627+ * Return: sysfs_emit() return after copying reply queue count
1628+ */
1629+static ssize_t
1630+reply_queue_count_show(struct device *dev, struct device_attribute *attr,
1631+ char *buf)
1632+{
1633+ struct Scsi_Host *shost = class_to_shost(dev);
1634+ struct mpi3mr_ioc *mrioc = shost_priv(shost);
1635+
1636+ return sysfs_emit(buf, "%d\n", mrioc->num_op_reply_q);
1637+}
1638+
1639+static DEVICE_ATTR_RO(reply_queue_count);
1640+
1641+/**
1642+ * logging_level_show - Show controller debug level
1643+ * @dev: class device
1644+ * @attr: Device attributes
1645+ * @buf: Buffer to copy
1646+ *
1647+ * A sysfs 'read/write' shost attribute, to show the current
1648+ * debug log level used by the driver for the specific
1649+ * controller.
1650+ *
1651+ * Return: sysfs_emit() return
1652+ */
1653+static ssize_t
1654+logging_level_show(struct device *dev,
1655+ struct device_attribute *attr, char *buf)
1656+
1657+{
1658+ struct Scsi_Host *shost = class_to_shost(dev);
1659+ struct mpi3mr_ioc *mrioc = shost_priv(shost);
1660+
1661+ return sysfs_emit(buf, "%08xh\n", mrioc->logging_level);
1662+}
1663+
1664+/**
1665+ * logging_level_store- Change controller debug level
1666+ * @dev: class device
1667+ * @attr: Device attributes
1668+ * @buf: Buffer to copy
1669+ * @count: size of the buffer
1670+ *
1671+ * A sysfs 'read/write' shost attribute, to change the current
1672+ * debug log level used by the driver for the specific
1673+ * controller.
1674+ *
1675+ * Return: strlen() return
1676+ */
1677+static ssize_t
1678+logging_level_store(struct device *dev,
1679+ struct device_attribute *attr,
1680+ const char *buf, size_t count)
1681+{
1682+ struct Scsi_Host *shost = class_to_shost(dev);
1683+ struct mpi3mr_ioc *mrioc = shost_priv(shost);
1684+ int val = 0;
1685+
1686+ if (kstrtoint(buf, 0, &val) != 0)
1687+ return -EINVAL;
1688+
1689+ mrioc->logging_level = val;
1690+ ioc_info(mrioc, "logging_level=%08xh\n", mrioc->logging_level);
1691+ return strlen(buf);
1692+}
1693+static DEVICE_ATTR_RW(logging_level);
1694+
1695+/**
1696+ * adapter_state_show - SysFS callback for adapter state show
1697+ * @dev: class device
1698+ * @attr: Device attributes
1699+ * @buf: Buffer to copy
1700+ *
1701+ * Return: sysfs_emit() return after copying adapter state
1702+ */
1703+static ssize_t
1704+adp_state_show(struct device *dev, struct device_attribute *attr,
1705+ char *buf)
1706+{
1707+ struct Scsi_Host *shost = class_to_shost(dev);
1708+ struct mpi3mr_ioc *mrioc = shost_priv(shost);
1709+ enum mpi3mr_iocstate ioc_state;
1710+ uint8_t adp_state;
1711+
1712+ ioc_state = mpi3mr_get_iocstate(mrioc);
1713+ if (ioc_state == MRIOC_STATE_UNRECOVERABLE)
1714+ adp_state = MPI3MR_BSG_ADPSTATE_UNRECOVERABLE;
1715+ else if ((mrioc->reset_in_progress) || (mrioc->stop_bsgs))
1716+ adp_state = MPI3MR_BSG_ADPSTATE_IN_RESET;
1717+ else if (ioc_state == MRIOC_STATE_FAULT)
1718+ adp_state = MPI3MR_BSG_ADPSTATE_FAULT;
1719+ else
1720+ adp_state = MPI3MR_BSG_ADPSTATE_OPERATIONAL;
1721+
1722+ return sysfs_emit(buf, "%u\n", adp_state);
1723+}
1724+
1725+static DEVICE_ATTR_RO(adp_state);
1726+
1727+static struct attribute *mpi3mr_host_attrs[] = {
1728+ &dev_attr_version_fw.attr,
1729+ &dev_attr_fw_queue_depth.attr,
1730+ &dev_attr_op_req_q_count.attr,
1731+ &dev_attr_reply_queue_count.attr,
1732+ &dev_attr_logging_level.attr,
1733+ &dev_attr_adp_state.attr,
1734+ NULL,
1735+};
1736+
1737+static const struct attribute_group mpi3mr_host_attr_group = {
1738+ .attrs = mpi3mr_host_attrs
1739+};
1740+
1741+const struct attribute_group *mpi3mr_host_groups[] = {
1742+ &mpi3mr_host_attr_group,
1743+ NULL,
1744+};
1745+
1746+
1747+/*
1748+ * SCSI Device attributes under sysfs
1749+ */
1750+
1751+/**
1752+ * sas_address_show - SysFS callback for dev SASaddress display
1753+ * @dev: class device
1754+ * @attr: Device attributes
1755+ * @buf: Buffer to copy
1756+ *
1757+ * Return: sysfs_emit() return after copying SAS address of the
1758+ * specific SAS/SATA end device.
1759+ */
1760+static ssize_t
1761+sas_address_show(struct device *dev, struct device_attribute *attr,
1762+ char *buf)
1763+{
1764+ struct scsi_device *sdev = to_scsi_device(dev);
1765+ struct mpi3mr_sdev_priv_data *sdev_priv_data;
1766+ struct mpi3mr_stgt_priv_data *tgt_priv_data;
1767+ struct mpi3mr_tgt_dev *tgtdev;
1768+
1769+ sdev_priv_data = sdev->hostdata;
1770+ if (!sdev_priv_data)
1771+ return 0;
1772+
1773+ tgt_priv_data = sdev_priv_data->tgt_priv_data;
1774+ if (!tgt_priv_data)
1775+ return 0;
1776+ tgtdev = tgt_priv_data->tgt_dev;
1777+ if (!tgtdev || tgtdev->dev_type != MPI3_DEVICE_DEVFORM_SAS_SATA)
1778+ return 0;
1779+ return sysfs_emit(buf, "0x%016llx\n",
1780+ (unsigned long long)tgtdev->dev_spec.sas_sata_inf.sas_address);
1781+}
1782+
1783+static DEVICE_ATTR_RO(sas_address);
1784+
1785+/**
1786+ * device_handle_show - SysFS callback for device handle display
1787+ * @dev: class device
1788+ * @attr: Device attributes
1789+ * @buf: Buffer to copy
1790+ *
1791+ * Return: sysfs_emit() return after copying firmware internal
1792+ * device handle of the specific device.
1793+ */
1794+static ssize_t
1795+device_handle_show(struct device *dev, struct device_attribute *attr,
1796+ char *buf)
1797+{
1798+ struct scsi_device *sdev = to_scsi_device(dev);
1799+ struct mpi3mr_sdev_priv_data *sdev_priv_data;
1800+ struct mpi3mr_stgt_priv_data *tgt_priv_data;
1801+ struct mpi3mr_tgt_dev *tgtdev;
1802+
1803+ sdev_priv_data = sdev->hostdata;
1804+ if (!sdev_priv_data)
1805+ return 0;
1806+
1807+ tgt_priv_data = sdev_priv_data->tgt_priv_data;
1808+ if (!tgt_priv_data)
1809+ return 0;
1810+ tgtdev = tgt_priv_data->tgt_dev;
1811+ if (!tgtdev)
1812+ return 0;
1813+ return sysfs_emit(buf, "0x%04x\n", tgtdev->dev_handle);
1814+}
1815+
1816+static DEVICE_ATTR_RO(device_handle);
1817+
1818+/**
1819+ * persistent_id_show - SysFS callback for persisten ID display
1820+ * @dev: class device
1821+ * @attr: Device attributes
1822+ * @buf: Buffer to copy
1823+ *
1824+ * Return: sysfs_emit() return after copying persistent ID of the
1825+ * of the specific device.
1826+ */
1827+static ssize_t
1828+persistent_id_show(struct device *dev, struct device_attribute *attr,
1829+ char *buf)
1830+{
1831+ struct scsi_device *sdev = to_scsi_device(dev);
1832+ struct mpi3mr_sdev_priv_data *sdev_priv_data;
1833+ struct mpi3mr_stgt_priv_data *tgt_priv_data;
1834+ struct mpi3mr_tgt_dev *tgtdev;
1835+
1836+ sdev_priv_data = sdev->hostdata;
1837+ if (!sdev_priv_data)
1838+ return 0;
1839+
1840+ tgt_priv_data = sdev_priv_data->tgt_priv_data;
1841+ if (!tgt_priv_data)
1842+ return 0;
1843+ tgtdev = tgt_priv_data->tgt_dev;
1844+ if (!tgtdev)
1845+ return 0;
1846+ return sysfs_emit(buf, "%d\n", tgtdev->perst_id);
1847+}
1848+static DEVICE_ATTR_RO(persistent_id);
1849+
1850+static struct attribute *mpi3mr_dev_attrs[] = {
1851+ &dev_attr_sas_address.attr,
1852+ &dev_attr_device_handle.attr,
1853+ &dev_attr_persistent_id.attr,
1854+ NULL,
1855+};
1856+
1857+static const struct attribute_group mpi3mr_dev_attr_group = {
1858+ .attrs = mpi3mr_dev_attrs
1859+};
1860+
1861+const struct attribute_group *mpi3mr_dev_groups[] = {
1862+ &mpi3mr_dev_attr_group,
1863+ NULL,
1864+};
drivers/scsi/mpi3mr/mpi3mr_debug.h+31−6
@@ -23,8 +23,8 @@ · 22 unmodified lines
2323 #define MPI3_DEBUG_RESET 0x00000020
2424 #define MPI3_DEBUG_SCSI_ERROR 0x00000040
2525 #define MPI3_DEBUG_REPLY 0x00000080
26−#define MPI3_DEBUG_IOCTL_ERROR 0x00008000
27−#define MPI3_DEBUG_IOCTL_INFO 0x00010000
26+#define MPI3_DEBUG_BSG_ERROR 0x00008000
27+#define MPI3_DEBUG_BSG_INFO 0x00010000
2828 #define MPI3_DEBUG_SCSI_INFO 0x00020000
2929 #define MPI3_DEBUG 0x01000000
3030 #define MPI3_DEBUG_SG 0x02000000
@@ -110,20 +110,45 @@ · 79 unmodified lines
110110 } while (0)
111111
112112
113−#define dprint_ioctl_info(ioc, fmt, ...) \
113+#define dprint_bsg_info(ioc, fmt, ...) \
114114 do { \
115− if (ioc->logging_level & MPI3_DEBUG_IOCTL_INFO) \
115+ if (ioc->logging_level & MPI3_DEBUG_BSG_INFO) \
116116 pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
117117 } while (0)
118118
119−#define dprint_ioctl_err(ioc, fmt, ...) \
119+#define dprint_bsg_err(ioc, fmt, ...) \
120120 do { \
121− if (ioc->logging_level & MPI3_DEBUG_IOCTL_ERROR) \
121+ if (ioc->logging_level & MPI3_DEBUG_BSG_ERROR) \
122122 pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
123123 } while (0)
124124
125125 #endif /* MPT3SAS_DEBUG_H_INCLUDED */
126126
127+/**
128+ * dprint_dump - print contents of a memory buffer
129+ * @req: Pointer to a memory buffer
130+ * @sz: Memory buffer size
131+ * @namestr: Name String to identify the buffer type
132+ */
133+static inline void
134+dprint_dump(void *req, int sz, const char *name_string)
135+{
136+ int i;
137+ __le32 *mfp = (__le32 *)req;
138+
139+ sz = sz/4;
140+ if (name_string)
141+ pr_info("%s:\n\t", name_string);
142+ else
143+ pr_info("request:\n\t");
144+ for (i = 0; i < sz; i++) {
145+ if (i && ((i % 8) == 0))
146+ pr_info("\n\t");
147+ pr_info("%08x ", le32_to_cpu(mfp[i]));
148+ }
149+ pr_info("\n");
150+}
151+
127152 /**
128153 * dprint_dump_req - print message frame contents
129154 * @req: pointer to message frame
drivers/scsi/mpi3mr/mpi3mr_fw.c+332−3
@@ -15,6 +15,8 @@ mpi3mr_issue_reset(struct mpi3mr_ioc *mrioc, u16 reset_type, u32 reset_reason); · 14 unmodified lines
1515 static int mpi3mr_setup_admin_qpair(struct mpi3mr_ioc *mrioc);
1616 static void mpi3mr_process_factsdata(struct mpi3mr_ioc *mrioc,
1717 struct mpi3_ioc_facts_data *facts_data);
18+static void mpi3mr_pel_wait_complete(struct mpi3mr_ioc *mrioc,
19+ struct mpi3mr_drv_cmd *drv_cmd);
1820
1921 static int poll_queues;
2022 module_param(poll_queues, int, 0444);
@@ -297,8 +299,14 @@ mpi3mr_get_drv_cmd(struct mpi3mr_ioc *mrioc, u16 host_tag, · 276 unmodified lines
297299 switch (host_tag) {
298300 case MPI3MR_HOSTTAG_INITCMDS:
299301 return &mrioc->init_cmds;
302+ case MPI3MR_HOSTTAG_BSG_CMDS:
303+ return &mrioc->bsg_cmds;
300304 case MPI3MR_HOSTTAG_BLK_TMS:
301305 return &mrioc->host_tm_cmds;
306+ case MPI3MR_HOSTTAG_PEL_ABORT:
307+ return &mrioc->pel_abort_cmd;
308+ case MPI3MR_HOSTTAG_PEL_WAIT:
309+ return &mrioc->pel_cmds;
302310 case MPI3MR_HOSTTAG_INVALID:
303311 if (def_reply && def_reply->function ==
304312 MPI3_FUNCTION_EVENT_NOTIFICATION)
@@ -865,10 +873,10 @@ static const struct { · 560 unmodified lines
865873 } mpi3mr_reset_reason_codes[] = {
866874 { MPI3MR_RESET_FROM_BRINGUP, "timeout in bringup" },
867875 { MPI3MR_RESET_FROM_FAULT_WATCH, "fault" },
868− { MPI3MR_RESET_FROM_IOCTL, "application invocation" },
876+ { MPI3MR_RESET_FROM_APP, "application invocation" },
869877 { MPI3MR_RESET_FROM_EH_HOS, "error handling" },
870878 { MPI3MR_RESET_FROM_TM_TIMEOUT, "TM timeout" },
871− { MPI3MR_RESET_FROM_IOCTL_TIMEOUT, "IOCTL timeout" },
879+ { MPI3MR_RESET_FROM_APP_TIMEOUT, "application command timeout" },
872880 { MPI3MR_RESET_FROM_MUR_FAILURE, "MUR failure" },
873881 { MPI3MR_RESET_FROM_CTLR_CLEANUP, "timeout in controller cleanup" },
874882 { MPI3MR_RESET_FROM_CIACTIV_FAULT, "component image activation fault" },
@@ -2813,6 +2821,10 @@ static int mpi3mr_alloc_reply_sense_bufs(struct mpi3mr_ioc *mrioc) · 1938 unmodified lines
28132821 if (!mrioc->init_cmds.reply)
28142822 goto out_failed;
28152823
2824+ mrioc->bsg_cmds.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL);
2825+ if (!mrioc->bsg_cmds.reply)
2826+ goto out_failed;
2827+
28162828 for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++) {
28172829 mrioc->dev_rmhs_cmds[i].reply = kzalloc(mrioc->reply_sz,
28182830 GFP_KERNEL);
@@ -2831,6 +2843,14 @@ static int mpi3mr_alloc_reply_sense_bufs(struct mpi3mr_ioc *mrioc) · 12 unmodified lines
28312843 if (!mrioc->host_tm_cmds.reply)
28322844 goto out_failed;
28332845
2846+ mrioc->pel_cmds.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL);
2847+ if (!mrioc->pel_cmds.reply)
2848+ goto out_failed;
2849+
2850+ mrioc->pel_abort_cmd.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL);
2851+ if (!mrioc->pel_abort_cmd.reply)
2852+ goto out_failed;
2853+
28342854 mrioc->dev_handle_bitmap_sz = mrioc->facts.max_devhandle / 8;
28352855 if (mrioc->facts.max_devhandle % 8)
28362856 mrioc->dev_handle_bitmap_sz++;
@@ -3728,6 +3748,18 @@ retry_init: · 891 unmodified lines
37283748 goto out_failed;
37293749 }
37303750
3751+ if (!mrioc->pel_seqnum_virt) {
3752+ dprint_init(mrioc, "allocating memory for pel_seqnum_virt\n");
3753+ mrioc->pel_seqnum_sz = sizeof(struct mpi3_pel_seq);
3754+ mrioc->pel_seqnum_virt = dma_alloc_coherent(&mrioc->pdev->dev,
3755+ mrioc->pel_seqnum_sz, &mrioc->pel_seqnum_dma,
3756+ GFP_KERNEL);
3757+ if (!mrioc->pel_seqnum_virt) {
3758+ retval = -ENOMEM;
3759+ goto out_failed_noretry;
3760+ }
3761+ }
3762+
37313763 retval = mpi3mr_enable_events(mrioc);
37323764 if (retval) {
37333765 ioc_err(mrioc, "failed to enable events %d\n",
@@ -3837,6 +3869,18 @@ retry_init: · 103 unmodified lines
38373869 goto out_failed;
38383870 }
38393871
3872+ if (!mrioc->pel_seqnum_virt) {
3873+ dprint_reset(mrioc, "allocating memory for pel_seqnum_virt\n");
3874+ mrioc->pel_seqnum_sz = sizeof(struct mpi3_pel_seq);
3875+ mrioc->pel_seqnum_virt = dma_alloc_coherent(&mrioc->pdev->dev,
3876+ mrioc->pel_seqnum_sz, &mrioc->pel_seqnum_dma,
3877+ GFP_KERNEL);
3878+ if (!mrioc->pel_seqnum_virt) {
3879+ retval = -ENOMEM;
3880+ goto out_failed_noretry;
3881+ }
3882+ }
3883+
38403884 if (mrioc->shost->nr_hw_queues > mrioc->num_op_reply_q) {
38413885 ioc_err(mrioc,
38423886 "cannot create minimum number of operational queues expected:%d created:%d\n",
@@ -3948,8 +3992,14 @@ void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc) · 105 unmodified lines
39483992
39493993 if (mrioc->init_cmds.reply) {
39503994 memset(mrioc->init_cmds.reply, 0, sizeof(*mrioc->init_cmds.reply));
3995+ memset(mrioc->bsg_cmds.reply, 0,
3996+ sizeof(*mrioc->bsg_cmds.reply));
39513997 memset(mrioc->host_tm_cmds.reply, 0,
39523998 sizeof(*mrioc->host_tm_cmds.reply));
3999+ memset(mrioc->pel_cmds.reply, 0,
4000+ sizeof(*mrioc->pel_cmds.reply));
4001+ memset(mrioc->pel_abort_cmd.reply, 0,
4002+ sizeof(*mrioc->pel_abort_cmd.reply));
39534003 for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++)
39544004 memset(mrioc->dev_rmhs_cmds[i].reply, 0,
39554005 sizeof(*mrioc->dev_rmhs_cmds[i].reply));
@@ -4050,9 +4100,18 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc) · 94 unmodified lines
40504100 kfree(mrioc->init_cmds.reply);
40514101 mrioc->init_cmds.reply = NULL;
40524102
4103+ kfree(mrioc->bsg_cmds.reply);
4104+ mrioc->bsg_cmds.reply = NULL;
4105+
40534106 kfree(mrioc->host_tm_cmds.reply);
40544107 mrioc->host_tm_cmds.reply = NULL;
40554108
4109+ kfree(mrioc->pel_cmds.reply);
4110+ mrioc->pel_cmds.reply = NULL;
4111+
4112+ kfree(mrioc->pel_abort_cmd.reply);
4113+ mrioc->pel_abort_cmd.reply = NULL;
4114+
40564115 for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) {
40574116 kfree(mrioc->evtack_cmds[i].reply);
40584117 mrioc->evtack_cmds[i].reply = NULL;
@@ -4101,6 +4160,16 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc) · 42 unmodified lines
41014160 mrioc->admin_req_base, mrioc->admin_req_dma);
41024161 mrioc->admin_req_base = NULL;
41034162 }
4163+
4164+ if (mrioc->pel_seqnum_virt) {
4165+ dma_free_coherent(&mrioc->pdev->dev, mrioc->pel_seqnum_sz,
4166+ mrioc->pel_seqnum_virt, mrioc->pel_seqnum_dma);
4167+ mrioc->pel_seqnum_virt = NULL;
4168+ }
4169+
4170+ kfree(mrioc->logdata_buf);
4171+ mrioc->logdata_buf = NULL;
4172+
41044173 }
41054174
41064175 /**
@@ -4235,6 +4304,8 @@ static void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc) · 128 unmodified lines
42354304
42364305 cmdptr = &mrioc->init_cmds;
42374306 mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
4307+ cmdptr = &mrioc->bsg_cmds;
4308+ mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
42384309 cmdptr = &mrioc->host_tm_cmds;
42394310 mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
42404311
@@ -4247,6 +4318,254 @@ static void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc) · 6 unmodified lines
42474318 cmdptr = &mrioc->evtack_cmds[i];
42484319 mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
42494320 }
4321+
4322+ cmdptr = &mrioc->pel_cmds;
4323+ mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
4324+
4325+ cmdptr = &mrioc->pel_abort_cmd;
4326+ mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
4327+
4328+}
4329+
4330+/**
4331+ * mpi3mr_pel_wait_post - Issue PEL Wait
4332+ * @mrioc: Adapter instance reference
4333+ * @drv_cmd: Internal command tracker
4334+ *
4335+ * Issue PEL Wait MPI request through admin queue and return.
4336+ *
4337+ * Return: Nothing.
4338+ */
4339+static void mpi3mr_pel_wait_post(struct mpi3mr_ioc *mrioc,
4340+ struct mpi3mr_drv_cmd *drv_cmd)
4341+{
4342+ struct mpi3_pel_req_action_wait pel_wait;
4343+
4344+ mrioc->pel_abort_requested = false;
4345+
4346+ memset(&pel_wait, 0, sizeof(pel_wait));
4347+ drv_cmd->state = MPI3MR_CMD_PENDING;
4348+ drv_cmd->is_waiting = 0;
4349+ drv_cmd->callback = mpi3mr_pel_wait_complete;
4350+ drv_cmd->ioc_status = 0;
4351+ drv_cmd->ioc_loginfo = 0;
4352+ pel_wait.host_tag = cpu_to_le16(MPI3MR_HOSTTAG_PEL_WAIT);
4353+ pel_wait.function = MPI3_FUNCTION_PERSISTENT_EVENT_LOG;
4354+ pel_wait.action = MPI3_PEL_ACTION_WAIT;
4355+ pel_wait.starting_sequence_number = cpu_to_le32(mrioc->pel_newest_seqnum);
4356+ pel_wait.locale = cpu_to_le16(mrioc->pel_locale);
4357+ pel_wait.class = cpu_to_le16(mrioc->pel_class);
4358+ pel_wait.wait_time = MPI3_PEL_WAITTIME_INFINITE_WAIT;
4359+ dprint_bsg_info(mrioc, "sending pel_wait seqnum(%d), class(%d), locale(0x%08x)\n",
4360+ mrioc->pel_newest_seqnum, mrioc->pel_class, mrioc->pel_locale);
4361+
4362+ if (mpi3mr_admin_request_post(mrioc, &pel_wait, sizeof(pel_wait), 0)) {
4363+ dprint_bsg_err(mrioc,
4364+ "Issuing PELWait: Admin post failed\n");
4365+ drv_cmd->state = MPI3MR_CMD_NOTUSED;
4366+ drv_cmd->callback = NULL;
4367+ drv_cmd->retry_count = 0;
4368+ mrioc->pel_enabled = false;
4369+ }
4370+}
4371+
4372+/**
4373+ * mpi3mr_pel_get_seqnum_post - Issue PEL Get Sequence number
4374+ * @mrioc: Adapter instance reference
4375+ * @drv_cmd: Internal command tracker
4376+ *
4377+ * Issue PEL get sequence number MPI request through admin queue
4378+ * and return.
4379+ *
4380+ * Return: 0 on success, non-zero on failure.
4381+ */
4382+int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc,
4383+ struct mpi3mr_drv_cmd *drv_cmd)
4384+{
4385+ struct mpi3_pel_req_action_get_sequence_numbers pel_getseq_req;
4386+ u8 sgl_flags = MPI3MR_SGEFLAGS_SYSTEM_SIMPLE_END_OF_LIST;
4387+ int retval = 0;
4388+
4389+ memset(&pel_getseq_req, 0, sizeof(pel_getseq_req));
4390+ mrioc->pel_cmds.state = MPI3MR_CMD_PENDING;
4391+ mrioc->pel_cmds.is_waiting = 0;
4392+ mrioc->pel_cmds.ioc_status = 0;
4393+ mrioc->pel_cmds.ioc_loginfo = 0;
4394+ mrioc->pel_cmds.callback = mpi3mr_pel_get_seqnum_complete;
4395+ pel_getseq_req.host_tag = cpu_to_le16(MPI3MR_HOSTTAG_PEL_WAIT);
4396+ pel_getseq_req.function = MPI3_FUNCTION_PERSISTENT_EVENT_LOG;
4397+ pel_getseq_req.action = MPI3_PEL_ACTION_GET_SEQNUM;
4398+ mpi3mr_add_sg_single(&pel_getseq_req.sgl, sgl_flags,
4399+ mrioc->pel_seqnum_sz, mrioc->pel_seqnum_dma);
4400+
4401+ retval = mpi3mr_admin_request_post(mrioc, &pel_getseq_req,
4402+ sizeof(pel_getseq_req), 0);
4403+ if (retval) {
4404+ if (drv_cmd) {
4405+ drv_cmd->state = MPI3MR_CMD_NOTUSED;
4406+ drv_cmd->callback = NULL;
4407+ drv_cmd->retry_count = 0;
4408+ }
4409+ mrioc->pel_enabled = false;
4410+ }
4411+
4412+ return retval;
4413+}
4414+
4415+/**
4416+ * mpi3mr_pel_wait_complete - PELWait Completion callback
4417+ * @mrioc: Adapter instance reference
4418+ * @drv_cmd: Internal command tracker
4419+ *
4420+ * This is a callback handler for the PELWait request and
4421+ * firmware completes a PELWait request when it is aborted or a
4422+ * new PEL entry is available. This sends AEN to the application
4423+ * and if the PELwait completion is not due to PELAbort then
4424+ * this will send a request for new PEL Sequence number
4425+ *
4426+ * Return: Nothing.
4427+ */
4428+static void mpi3mr_pel_wait_complete(struct mpi3mr_ioc *mrioc,
4429+ struct mpi3mr_drv_cmd *drv_cmd)
4430+{
4431+ struct mpi3_pel_reply *pel_reply = NULL;
4432+ u16 ioc_status, pe_log_status;
4433+ bool do_retry = false;
4434+
4435+ if (drv_cmd->state & MPI3MR_CMD_RESET)
4436+ goto cleanup_drv_cmd;
4437+
4438+ ioc_status = drv_cmd->ioc_status & MPI3_IOCSTATUS_STATUS_MASK;
4439+ if (ioc_status != MPI3_IOCSTATUS_SUCCESS) {
4440+ ioc_err(mrioc, "%s: Failed ioc_status(0x%04x) Loginfo(0x%08x)\n",
4441+ __func__, ioc_status, drv_cmd->ioc_loginfo);
4442+ dprint_bsg_err(mrioc,
4443+ "pel_wait: failed with ioc_status(0x%04x), log_info(0x%08x)\n",
4444+ ioc_status, drv_cmd->ioc_loginfo);
4445+ do_retry = true;
4446+ }
4447+
4448+ if (drv_cmd->state & MPI3MR_CMD_REPLY_VALID)
4449+ pel_reply = (struct mpi3_pel_reply *)drv_cmd->reply;
4450+
4451+ if (!pel_reply) {
4452+ dprint_bsg_err(mrioc,
4453+ "pel_wait: failed due to no reply\n");
4454+ goto out_failed;
4455+ }
4456+
4457+ pe_log_status = le16_to_cpu(pel_reply->pe_log_status);
4458+ if ((pe_log_status != MPI3_PEL_STATUS_SUCCESS) &&
4459+ (pe_log_status != MPI3_PEL_STATUS_ABORTED)) {
4460+ ioc_err(mrioc, "%s: Failed pe_log_status(0x%04x)\n",
4461+ __func__, pe_log_status);
4462+ dprint_bsg_err(mrioc,
4463+ "pel_wait: failed due to pel_log_status(0x%04x)\n",
4464+ pe_log_status);
4465+ do_retry = true;
4466+ }
4467+
4468+ if (do_retry) {
4469+ if (drv_cmd->retry_count < MPI3MR_PEL_RETRY_COUNT) {
4470+ drv_cmd->retry_count++;
4471+ dprint_bsg_err(mrioc, "pel_wait: retrying(%d)\n",
4472+ drv_cmd->retry_count);
4473+ mpi3mr_pel_wait_post(mrioc, drv_cmd);
4474+ return;
4475+ }
4476+ dprint_bsg_err(mrioc,
4477+ "pel_wait: failed after all retries(%d)\n",
4478+ drv_cmd->retry_count);
4479+ goto out_failed;
4480+ }
4481+ atomic64_inc(&event_counter);
4482+ if (!mrioc->pel_abort_requested) {
4483+ mrioc->pel_cmds.retry_count = 0;
4484+ mpi3mr_pel_get_seqnum_post(mrioc, &mrioc->pel_cmds);
4485+ }
4486+
4487+ return;
4488+out_failed:
4489+ mrioc->pel_enabled = false;
4490+cleanup_drv_cmd:
4491+ drv_cmd->state = MPI3MR_CMD_NOTUSED;
4492+ drv_cmd->callback = NULL;
4493+ drv_cmd->retry_count = 0;
4494+}
4495+
4496+/**
4497+ * mpi3mr_pel_get_seqnum_complete - PELGetSeqNum Completion callback
4498+ * @mrioc: Adapter instance reference
4499+ * @drv_cmd: Internal command tracker
4500+ *
4501+ * This is a callback handler for the PEL get sequence number
4502+ * request and a new PEL wait request will be issued to the
4503+ * firmware from this
4504+ *
4505+ * Return: Nothing.
4506+ */
4507+void mpi3mr_pel_get_seqnum_complete(struct mpi3mr_ioc *mrioc,
4508+ struct mpi3mr_drv_cmd *drv_cmd)
4509+{
4510+ struct mpi3_pel_reply *pel_reply = NULL;
4511+ struct mpi3_pel_seq *pel_seqnum_virt;
4512+ u16 ioc_status;
4513+ bool do_retry = false;
4514+
4515+ pel_seqnum_virt = (struct mpi3_pel_seq *)mrioc->pel_seqnum_virt;
4516+
4517+ if (drv_cmd->state & MPI3MR_CMD_RESET)
4518+ goto cleanup_drv_cmd;
4519+
4520+ ioc_status = drv_cmd->ioc_status & MPI3_IOCSTATUS_STATUS_MASK;
4521+ if (ioc_status != MPI3_IOCSTATUS_SUCCESS) {
4522+ dprint_bsg_err(mrioc,
4523+ "pel_get_seqnum: failed with ioc_status(0x%04x), log_info(0x%08x)\n",
4524+ ioc_status, drv_cmd->ioc_loginfo);
4525+ do_retry = true;
4526+ }
4527+
4528+ if (drv_cmd->state & MPI3MR_CMD_REPLY_VALID)
4529+ pel_reply = (struct mpi3_pel_reply *)drv_cmd->reply;
4530+ if (!pel_reply) {
4531+ dprint_bsg_err(mrioc,
4532+ "pel_get_seqnum: failed due to no reply\n");
4533+ goto out_failed;
4534+ }
4535+
4536+ if (le16_to_cpu(pel_reply->pe_log_status) != MPI3_PEL_STATUS_SUCCESS) {
4537+ dprint_bsg_err(mrioc,
4538+ "pel_get_seqnum: failed due to pel_log_status(0x%04x)\n",
4539+ le16_to_cpu(pel_reply->pe_log_status));
4540+ do_retry = true;
4541+ }
4542+
4543+ if (do_retry) {
4544+ if (drv_cmd->retry_count < MPI3MR_PEL_RETRY_COUNT) {
4545+ drv_cmd->retry_count++;
4546+ dprint_bsg_err(mrioc,
4547+ "pel_get_seqnum: retrying(%d)\n",
4548+ drv_cmd->retry_count);
4549+ mpi3mr_pel_get_seqnum_post(mrioc, drv_cmd);
4550+ return;
4551+ }
4552+
4553+ dprint_bsg_err(mrioc,
4554+ "pel_get_seqnum: failed after all retries(%d)\n",
4555+ drv_cmd->retry_count);
4556+ goto out_failed;
4557+ }
4558+ mrioc->pel_newest_seqnum = le32_to_cpu(pel_seqnum_virt->newest) + 1;
4559+ drv_cmd->retry_count = 0;
4560+ mpi3mr_pel_wait_post(mrioc, drv_cmd);
4561+
4562+ return;
4563+out_failed:
4564+ mrioc->pel_enabled = false;
4565+cleanup_drv_cmd:
4566+ drv_cmd->state = MPI3MR_CMD_NOTUSED;
4567+ drv_cmd->callback = NULL;
4568+ drv_cmd->retry_count = 0;
42504569 }
42514570
42524571 /**
@@ -4258,7 +4577,7 @@ static void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc) · 5 unmodified lines
42584577 * This is an handler for recovering controller by issuing soft
42594578 * reset are diag fault reset. This is a blocking function and
42604579 * when one reset is executed if any other resets they will be
4261− * blocked. All IOCTLs/IO will be blocked during the reset. If
4580+ * blocked. All BSG requests will be blocked during the reset. If
42624581 * controller reset is successful then the controller will be
42634582 * reinitalized, otherwise the controller will be marked as not
42644583 * recoverable
@@ -4305,6 +4624,7 @@ int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc, · 40 unmodified lines
43054624 mpi3mr_reset_rc_name(reset_reason));
43064625
43074626 mrioc->reset_in_progress = 1;
4627+ mrioc->stop_bsgs = 1;
43084628 mrioc->prev_reset_result = -1;
43094629
43104630 if ((!snapdump) && (reset_reason != MPI3MR_RESET_FROM_FAULT_WATCH) &&
@@ -4369,6 +4689,12 @@ out: · 58 unmodified lines
43694689 if (!retval) {
43704690 mrioc->diagsave_timeout = 0;
43714691 mrioc->reset_in_progress = 0;
4692+ mrioc->pel_abort_requested = 0;
4693+ if (mrioc->pel_enabled) {
4694+ mrioc->pel_cmds.retry_count = 0;
4695+ mpi3mr_pel_wait_post(mrioc, &mrioc->pel_cmds);
4696+ }
4697+
43724698 mpi3mr_rfresh_tgtdevs(mrioc);
43734699 mrioc->ts_update_counter = 0;
43744700 spin_lock_irqsave(&mrioc->watchdog_lock, flags);
@@ -4377,6 +4703,9 @@ out: · 2 unmodified lines
43774703 &mrioc->watchdog_work,
43784704 msecs_to_jiffies(MPI3MR_WATCHDOG_INTERVAL));
43794705 spin_unlock_irqrestore(&mrioc->watchdog_lock, flags);
4706+ mrioc->stop_bsgs = 0;
4707+ if (mrioc->pel_enabled)
4708+ atomic64_inc(&event_counter);
43804709 } else {
43814710 mpi3mr_issue_reset(mrioc,
43824711 MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, reset_reason);
drivers/scsi/mpi3mr/mpi3mr_os.c+66−5
@@ -14,6 +14,7 @@ LIST_HEAD(mrioc_list); · 13 unmodified lines
1414 DEFINE_SPINLOCK(mrioc_list_lock);
1515 static int mrioc_ids;
1616 static int warn_non_secure_ctlr;
17+atomic64_t event_counter;
1718
1819 MODULE_AUTHOR(MPI3MR_DRIVER_AUTHOR);
1920 MODULE_DESCRIPTION(MPI3MR_DRIVER_DESC);
@@ -634,7 +635,7 @@ found_tgtdev: · 614 unmodified lines
634635 *
635636 * Return: Target device reference.
636637 */
637−static struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle(
638+struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle(
638639 struct mpi3mr_ioc *mrioc, u16 handle)
639640 {
640641 struct mpi3mr_tgt_dev *tgtdev;
@@ -910,9 +911,11 @@ void mpi3mr_rfresh_tgtdevs(struct mpi3mr_ioc *mrioc) · 269 unmodified lines
910911
911912 list_for_each_entry_safe(tgtdev, tgtdev_next, &mrioc->tgtdev_list,
912913 list) {
913− if ((tgtdev->dev_handle == MPI3MR_INVALID_DEV_HANDLE) &&
914− tgtdev->host_exposed) {
915− mpi3mr_remove_tgtdev_from_host(mrioc, tgtdev);
914+ if (tgtdev->dev_handle == MPI3MR_INVALID_DEV_HANDLE) {
915+ dprint_reset(mrioc, "removing target device with perst_id(%d)\n",
916+ tgtdev->perst_id);
917+ if (tgtdev->host_exposed)
918+ mpi3mr_remove_tgtdev_from_host(mrioc, tgtdev);
916919 mpi3mr_tgtdev_del_from_list(mrioc, tgtdev);
917920 mpi3mr_tgtdev_put(tgtdev);
918921 }
@@ -1415,6 +1418,23 @@ static void mpi3mr_pcietopochg_evt_bh(struct mpi3mr_ioc *mrioc, · 496 unmodified lines
14151418 }
14161419 }
14171420
1421+/**
1422+ * mpi3mr_logdata_evt_bh - Log data event bottomhalf
1423+ * @mrioc: Adapter instance reference
1424+ * @fwevt: Firmware event reference
1425+ *
1426+ * Extracts the event data and calls application interfacing
1427+ * function to process the event further.
1428+ *
1429+ * Return: Nothing.
1430+ */
1431+static void mpi3mr_logdata_evt_bh(struct mpi3mr_ioc *mrioc,
1432+ struct mpi3mr_fwevt *fwevt)
1433+{
1434+ mpi3mr_app_save_logdata(mrioc, fwevt->event_data,
1435+ fwevt->event_data_size);
1436+}
1437+
14181438 /**
14191439 * mpi3mr_fwevt_bh - Firmware event bottomhalf handler
14201440 * @mrioc: Adapter instance reference
@@ -1467,6 +1487,11 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, · 46 unmodified lines
14671487 mpi3mr_pcietopochg_evt_bh(mrioc, fwevt);
14681488 break;
14691489 }
1490+ case MPI3_EVENT_LOG_DATA:
1491+ {
1492+ mpi3mr_logdata_evt_bh(mrioc, fwevt);
1493+ break;
1494+ }
14701495 default:
14711496 break;
14721497 }
@@ -2298,6 +2323,7 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc, · 825 unmodified lines
22982323 break;
22992324 }
23002325 case MPI3_EVENT_DEVICE_INFO_CHANGED:
2326+ case MPI3_EVENT_LOG_DATA:
23012327 {
23022328 process_evt_bh = 1;
23032329 break;
@@ -2996,7 +3022,7 @@ inline void mpi3mr_poll_pend_io_completions(struct mpi3mr_ioc *mrioc) · 692 unmodified lines
29963022 *
29973023 * Return: 0 on success, non-zero on errors
29983024 */
2999−static int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
3025+int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
30003026 u16 handle, uint lun, u16 htag, ulong timeout,
30013027 struct mpi3mr_drv_cmd *drv_cmd,
30023028 u8 *resp_code, struct scsi_cmnd *scmd)
@@ -3589,6 +3615,7 @@ static int mpi3mr_scan_finished(struct Scsi_Host *shost, · 586 unmodified lines
35893615
35903616 mpi3mr_start_watchdog(mrioc);
35913617 mrioc->is_driver_loading = 0;
3618+ mrioc->stop_bsgs = 0;
35923619 return 1;
35933620 }
35943621
@@ -3700,6 +3727,10 @@ static int mpi3mr_slave_configure(struct scsi_device *sdev) · 105 unmodified lines
37003727 return -ENXIO;
37013728
37023729 mpi3mr_change_queue_depth(sdev, tgt_dev->q_depth);
3730+
3731+ sdev->eh_timeout = MPI3MR_EH_SCMD_TIMEOUT;
3732+ blk_queue_rq_timeout(sdev->request_queue, MPI3MR_SCMD_TIMEOUT);
3733+
37033734 switch (tgt_dev->dev_type) {
37043735 case MPI3_DEVICE_DEVFORM_PCIE:
37053736 /*The block layer hw sector size = 512*/
@@ -3971,6 +4002,12 @@ static int mpi3mr_qcmd(struct Scsi_Host *shost, · 265 unmodified lines
39714002 int iprio_class;
39724003 u8 is_pcie_dev = 0;
39734004
4005+ if (mrioc->unrecoverable) {
4006+ scmd->result = DID_ERROR << 16;
4007+ scsi_done(scmd);
4008+ goto out;
4009+ }
4010+
39744011 sdev_priv_data = scmd->device->hostdata;
39754012 if (!sdev_priv_data || !sdev_priv_data->tgt_priv_data) {
39764013 scmd->result = DID_NO_CONNECT << 16;
@@ -4109,6 +4146,8 @@ static struct scsi_host_template mpi3mr_driver_template = { · 132 unmodified lines
41094146 .max_segment_size = 0xffffffff,
41104147 .track_queue_depth = 1,
41114148 .cmd_size = sizeof(struct scmd_priv),
4149+ .shost_groups = mpi3mr_host_groups,
4150+ .sdev_groups = mpi3mr_dev_groups,
41124151 };
41134152
41144153 /**
@@ -4259,6 +4298,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 144 unmodified lines
42594298 mutex_init(&mrioc->reset_mutex);
42604299 mpi3mr_init_drv_cmd(&mrioc->init_cmds, MPI3MR_HOSTTAG_INITCMDS);
42614300 mpi3mr_init_drv_cmd(&mrioc->host_tm_cmds, MPI3MR_HOSTTAG_BLK_TMS);
4301+ mpi3mr_init_drv_cmd(&mrioc->bsg_cmds, MPI3MR_HOSTTAG_BSG_CMDS);
42624302
42634303 for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++)
42644304 mpi3mr_init_drv_cmd(&mrioc->dev_rmhs_cmds[i],
@@ -4271,6 +4311,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 6 unmodified lines
42714311 mrioc->logging_level = logging_level;
42724312 mrioc->shost = shost;
42734313 mrioc->pdev = pdev;
4314+ mrioc->stop_bsgs = 1;
42744315
42754316 /* init shost parameters */
42764317 shost->max_cmd_len = MPI3MR_MAX_CDB_LENGTH;
@@ -4345,6 +4386,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 68 unmodified lines
43454386 }
43464387
43474388 scsi_scan_host(shost);
4389+ mpi3mr_bsg_init(mrioc);
43484390 return retval;
43494391
43504392 addhost_failed:
@@ -4389,6 +4431,7 @@ static void mpi3mr_remove(struct pci_dev *pdev) · 38 unmodified lines
43894431 while (mrioc->reset_in_progress || mrioc->is_driver_loading)
43904432 ssleep(1);
43914433
4434+ mpi3mr_bsg_exit(mrioc);
43924435 mrioc->stop_drv_processing = 1;
43934436 mpi3mr_cleanup_fwevt_list(mrioc);
43944437 spin_lock_irqsave(&mrioc->fwevt_lock, flags);
@@ -4563,6 +4606,12 @@ static struct pci_driver mpi3mr_pci_driver = { · 168 unmodified lines
45634606 #endif
45644607 };
45654608
4609+static ssize_t event_counter_show(struct device_driver *dd, char *buf)
4610+{
4611+ return sprintf(buf, "%llu\n", atomic64_read(&event_counter));
4612+}
4613+static DRIVER_ATTR_RO(event_counter);
4614+
45664615 static int __init mpi3mr_init(void)
45674616 {
45684617 int ret_val;
@@ -4571,6 +4620,16 @@ static int __init mpi3mr_init(void) · 2 unmodified lines
45714620 MPI3MR_DRIVER_VERSION);
45724621
45734622 ret_val = pci_register_driver(&mpi3mr_pci_driver);
4623+ if (ret_val) {
4624+ pr_err("%s failed to load due to pci register driver failure\n",
4625+ MPI3MR_DRIVER_NAME);
4626+ return ret_val;
4627+ }
4628+
4629+ ret_val = driver_create_file(&mpi3mr_pci_driver.driver,
4630+ &driver_attr_event_counter);
4631+ if (ret_val)
4632+ pci_unregister_driver(&mpi3mr_pci_driver);
45744633
45754634 return ret_val;
45764635 }
@@ -4585,6 +4644,8 @@ static void __exit mpi3mr_exit(void) · 8 unmodified lines
45854644 pr_info("Unloading %s version %s\n", MPI3MR_DRIVER_NAME,
45864645 MPI3MR_DRIVER_VERSION);
45874646
4647+ driver_remove_file(&mpi3mr_pci_driver.driver,
4648+ &driver_attr_event_counter);
45884649 pci_unregister_driver(&mpi3mr_pci_driver);
45894650 }
45904651
drivers/scsi/mpt3sas/mpt3sas_base.c+17−17
@@ -3692,10 +3692,11 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc) · 3691 unmodified lines
36923692 }
36933693
36943694 for (i = 0; i < ioc->combined_reply_index_count; i++) {
3695− ioc->replyPostRegisterIndex[i] = (resource_size_t *)
3696− ((u8 __force *)&ioc->chip->Doorbell +
3697− MPI25_SUP_REPLY_POST_HOST_INDEX_OFFSET +
3698− (i * MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET));
3695+ ioc->replyPostRegisterIndex[i] =
3696+ (resource_size_t __iomem *)
3697+ ((u8 __force *)&ioc->chip->Doorbell +
3698+ MPI25_SUP_REPLY_POST_HOST_INDEX_OFFSET +
3699+ (i * MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET));
36993700 }
37003701 }
37013702
@@ -4312,7 +4313,7 @@ _base_put_smid_scsi_io_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid, · 610 unmodified lines
43124313 descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
43134314 descriptor.SMID = cpu_to_le16(smid);
43144315
4315− writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);
4316+ writel(*request, &ioc->chip->AtomicRequestDescriptorPost);
43164317 }
43174318
43184319 /**
@@ -4334,7 +4335,7 @@ _base_put_smid_fast_path_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid, · 15 unmodified lines
43344335 descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
43354336 descriptor.SMID = cpu_to_le16(smid);
43364337
4337− writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);
4338+ writel(*request, &ioc->chip->AtomicRequestDescriptorPost);
43384339 }
43394340
43404341 /**
@@ -4357,7 +4358,7 @@ _base_put_smid_hi_priority_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid, · 16 unmodified lines
43574358 descriptor.MSIxIndex = msix_task;
43584359 descriptor.SMID = cpu_to_le16(smid);
43594360
4360− writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);
4361+ writel(*request, &ioc->chip->AtomicRequestDescriptorPost);
43614362 }
43624363
43634364 /**
@@ -4378,7 +4379,7 @@ _base_put_smid_default_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid) · 14 unmodified lines
43784379 descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
43794380 descriptor.SMID = cpu_to_le16(smid);
43804381
4381− writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);
4382+ writel(*request, &ioc->chip->AtomicRequestDescriptorPost);
43824383 }
43834384
43844385 /**
@@ -4752,7 +4753,7 @@ static void · 367 unmodified lines
47524753 _base_display_ioc_capabilities(struct MPT3SAS_ADAPTER *ioc)
47534754 {
47544755 int i = 0;
4755− char desc[16];
4756+ char desc[17] = {0};
47564757 u32 iounit_pg1_flags;
47574758 u32 bios_version;
47584759
@@ -6893,7 +6894,7 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, · 2134 unmodified lines
68936894
68946895 /* send message 32-bits at a time */
68956896 for (i = 0, failed = 0; i < request_bytes/4 && !failed; i++) {
6896− writel(cpu_to_le32(request[i]), &ioc->chip->Doorbell);
6897+ writel(request[i], &ioc->chip->Doorbell);
68976898 if ((_base_wait_for_doorbell_ack(ioc, 5)))
68986899 failed = 1;
68996900 }
@@ -6912,16 +6913,16 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, · 12 unmodified lines
69126913 }
69136914
69146915 /* read the first two 16-bits, it gives the total length of the reply */
6915− reply[0] = le16_to_cpu(ioc->base_readl(&ioc->chip->Doorbell)
6916− & MPI2_DOORBELL_DATA_MASK);
6916+ reply[0] = ioc->base_readl(&ioc->chip->Doorbell)
6917+ & MPI2_DOORBELL_DATA_MASK;
69176918 writel(0, &ioc->chip->HostInterruptStatus);
69186919 if ((_base_wait_for_doorbell_int(ioc, 5))) {
69196920 ioc_err(ioc, "doorbell handshake int failed (line=%d)\n",
69206921 __LINE__);
69216922 return -EFAULT;
69226923 }
6923− reply[1] = le16_to_cpu(ioc->base_readl(&ioc->chip->Doorbell)
6924− & MPI2_DOORBELL_DATA_MASK);
6924+ reply[1] = ioc->base_readl(&ioc->chip->Doorbell)
6925+ & MPI2_DOORBELL_DATA_MASK;
69256926 writel(0, &ioc->chip->HostInterruptStatus);
69266927
69276928 for (i = 2; i < default_reply->MsgLength * 2; i++) {
@@ -6933,9 +6934,8 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, · 5 unmodified lines
69336934 if (i >= reply_bytes/2) /* overflow case */
69346935 ioc->base_readl(&ioc->chip->Doorbell);
69356936 else
6936− reply[i] = le16_to_cpu(
6937− ioc->base_readl(&ioc->chip->Doorbell)
6938− & MPI2_DOORBELL_DATA_MASK);
6937+ reply[i] = ioc->base_readl(&ioc->chip->Doorbell)
6938+ & MPI2_DOORBELL_DATA_MASK;
69396939 writel(0, &ioc->chip->HostInterruptStatus);
69406940 }
69416941
drivers/scsi/mpt3sas/mpt3sas_base.h+3−3
@@ -77,8 +77,8 @@ · 76 unmodified lines
7777 #define MPT3SAS_DRIVER_NAME "mpt3sas"
7878 #define MPT3SAS_AUTHOR "Avago Technologies <MPT-FusionLinux.pdl@avagotech.com>"
7979 #define MPT3SAS_DESCRIPTION "LSI MPT Fusion SAS 3.0 Device Driver"
80−#define MPT3SAS_DRIVER_VERSION "40.100.00.00"
81−#define MPT3SAS_MAJOR_VERSION 40
80+#define MPT3SAS_DRIVER_VERSION "42.100.00.00"
81+#define MPT3SAS_MAJOR_VERSION 42
8282 #define MPT3SAS_MINOR_VERSION 100
8383 #define MPT3SAS_BUILD_VERSION 0
8484 #define MPT3SAS_RELEASE_VERSION 00
@@ -1588,7 +1588,7 @@ struct MPT3SAS_ADAPTER { · 1503 unmodified lines
15881588 u8 combined_reply_index_count;
15891589 u8 smp_affinity_enable;
15901590 /* reply post register index */
1591− resource_size_t **replyPostRegisterIndex;
1591+ resource_size_t __iomem **replyPostRegisterIndex;
15921592
15931593 struct list_head delayed_tr_list;
15941594 struct list_head delayed_tr_volume_list;
drivers/scsi/mpt3sas/mpt3sas_ctl.c+6−5
@@ -578,7 +578,7 @@ static int · 577 unmodified lines
578578 _ctl_set_task_mid(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command *karg,
579579 Mpi2SCSITaskManagementRequest_t *tm_request)
580580 {
581− u8 found = 0;
581+ bool found = false;
582582 u16 smid;
583583 u16 handle;
584584 struct scsi_cmnd *scmd;
@@ -600,6 +600,7 @@ _ctl_set_task_mid(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command *karg, · 15 unmodified lines
600600 handle = le16_to_cpu(tm_request->DevHandle);
601601 for (smid = ioc->scsiio_depth; smid && !found; smid--) {
602602 struct scsiio_tracker *st;
603+ __le16 task_mid;
603604
604605 scmd = mpt3sas_scsih_scsi_lookup_get(ioc, smid);
605606 if (!scmd)
@@ -618,10 +619,10 @@ _ctl_set_task_mid(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command *karg, · 12 unmodified lines
618619 * first outstanding smid will be picked up. Otherwise,
619620 * targeted smid will be the one.
620621 */
621− if (!tm_request->TaskMID || tm_request->TaskMID == st->smid) {
622− tm_request->TaskMID = cpu_to_le16(st->smid);
623− found = 1;
624− }
622+ task_mid = cpu_to_le16(st->smid);
623+ if (!tm_request->TaskMID)
624+ tm_request->TaskMID = task_mid;
625+ found = tm_request->TaskMID == task_mid;
625626 }
626627
627628 if (!found) {
drivers/scsi/mpt3sas/mpt3sas_scsih.c+11−13
@@ -10926,20 +10926,20 @@ mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index, · 10925 unmodified lines
1092610926 case MPI2_EVENT_LOG_ENTRY_ADDED:
1092710927 {
1092810928 Mpi2EventDataLogEntryAdded_t *log_entry;
10929− u32 *log_code;
10929+ u32 log_code;
1093010930
1093110931 if (!ioc->is_warpdrive)
1093210932 break;
1093310933
1093410934 log_entry = (Mpi2EventDataLogEntryAdded_t *)
1093510935 mpi_reply->EventData;
10936− log_code = (u32 *)log_entry->LogData;
10936+ log_code = le32_to_cpu(*(__le32 *)log_entry->LogData);
1093710937
1093810938 if (le16_to_cpu(log_entry->LogEntryQualifier)
1093910939 != MPT2_WARPDRIVE_LOGENTRY)
1094010940 break;
1094110941
10942− switch (le32_to_cpu(*log_code)) {
10942+ switch (log_code) {
1094310943 case MPT2_WARPDRIVE_LC_SSDT:
1094410944 ioc_warn(ioc, "WarpDrive Warning: IO Throttling has occurred in the WarpDrive subsystem. Check WarpDrive documentation for additional details.\n");
1094510945 break;
@@ -12588,20 +12588,18 @@ scsih_pci_mmio_enabled(struct pci_dev *pdev) · 1642 unmodified lines
1258812588 */
1258912589 bool scsih_ncq_prio_supp(struct scsi_device *sdev)
1259012590 {
12591− unsigned char *buf;
12591+ struct scsi_vpd *vpd;
1259212592 bool ncq_prio_supp = false;
1259312593
12594− if (!scsi_device_supports_vpd(sdev))
12595− return ncq_prio_supp;
12596−
12597− buf = kmalloc(SCSI_VPD_PG_LEN, GFP_KERNEL);
12598− if (!buf)
12599− return ncq_prio_supp;
12594+ rcu_read_lock();
12595+ vpd = rcu_dereference(sdev->vpd_pg89);
12596+ if (!vpd || vpd->len < 214)
12597+ goto out;
1260012598
12601− if (!scsi_get_vpd_page(sdev, 0x89, buf, SCSI_VPD_PG_LEN))
12602− ncq_prio_supp = (buf[213] >> 4) & 1;
12599+ ncq_prio_supp = (vpd->data[213] >> 4) & 1;
12600+out:
12601+ rcu_read_unlock();
1260312602
12604− kfree(buf);
1260512603 return ncq_prio_supp;
1260612604 }
1260712605 /*
drivers/scsi/pmcraid.c+1−1
@@ -4590,7 +4590,7 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host, · 4589 unmodified lines
45904590 mapped_pci_addr + chip_cfg->ioa_host_mask_clr;
45914591 pint_regs->global_interrupt_mask_reg =
45924592 mapped_pci_addr + chip_cfg->global_intr_mask;
4593− };
4593+ }
45944594
45954595 pinstance->ioa_reset_attempts = 0;
45964596 init_waitqueue_head(&pinstance->reset_wait_q);
drivers/scsi/qedf/qedf_attr.c+0−2
@@ -131,7 +131,6 @@ qedf_sysfs_write_grcdump(struct file *filep, struct kobject *kobj, · 130 unmodified lines
131131 struct qedf_ctx *qedf = NULL;
132132 long reading;
133133 int ret = 0;
134− char msg[40];
135134
136135 if (off != 0)
137136 return ret;
@@ -148,7 +147,6 @@ qedf_sysfs_write_grcdump(struct file *filep, struct kobject *kobj, · 10 unmodified lines
148147 return ret;
149148 }
150149
151− memset(msg, 0, sizeof(msg));
152150 switch (reading) {
153151 case 0:
154152 memset(qedf->grcdump, 0, qedf->grcdump_size);
drivers/scsi/qedf/qedf_io.c+1−2
@@ -804,7 +804,6 @@ static void qedf_trace_io(struct qedf_rport *fcport, struct qedf_ioreq *io_req, · 803 unmodified lines
804804 struct qedf_io_log *io_log;
805805 struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
806806 unsigned long flags;
807− uint8_t op;
808807
809808 spin_lock_irqsave(&qedf->io_trace_lock, flags);
810809
@@ -813,7 +812,7 @@ static void qedf_trace_io(struct qedf_rport *fcport, struct qedf_ioreq *io_req, · 2 unmodified lines
813812 io_log->task_id = io_req->xid;
814813 io_log->port_id = fcport->rdata->ids.port_id;
815814 io_log->lun = sc_cmd->device->lun;
816− io_log->op = op = sc_cmd->cmnd[0];
815+ io_log->op = sc_cmd->cmnd[0];
817816 io_log->lba[0] = sc_cmd->cmnd[2];
818817 io_log->lba[1] = sc_cmd->cmnd[3];
819818 io_log->lba[2] = sc_cmd->cmnd[4];
drivers/scsi/qedf/qedf_main.c+5−8
@@ -873,7 +873,7 @@ static int qedf_eh_device_reset(struct scsi_cmnd *sc_cmd) · 872 unmodified lines
873873
874874 bool qedf_wait_for_upload(struct qedf_ctx *qedf)
875875 {
876− struct qedf_rport *fcport = NULL;
876+ struct qedf_rport *fcport;
877877 int wait_cnt = 120;
878878
879879 while (wait_cnt--) {
@@ -888,7 +888,7 @@ bool qedf_wait_for_upload(struct qedf_ctx *qedf) · 8 unmodified lines
888888
889889 rcu_read_lock();
890890 list_for_each_entry_rcu(fcport, &qedf->fcports, peers) {
891− if (fcport && test_bit(QEDF_RPORT_SESSION_READY,
891+ if (test_bit(QEDF_RPORT_SESSION_READY,
892892 &fcport->flags)) {
893893 if (fcport->rdata)
894894 QEDF_ERR(&qedf->dbg_ctx,
@@ -899,9 +899,9 @@ bool qedf_wait_for_upload(struct qedf_ctx *qedf) · 4 unmodified lines
899899 "Waiting for fcport %p.\n", fcport);
900900 }
901901 }
902+
902903 rcu_read_unlock();
903904 return false;
904−
905905 }
906906
907907 /* Performs soft reset of qedf_ctx by simulating a link down/up */
@@ -1067,7 +1067,6 @@ static int qedf_xmit(struct fc_lport *lport, struct fc_frame *fp) · 159 unmodified lines
10671067 u32 crc;
10681068 unsigned int hlen, tlen, elen;
10691069 int wlen;
1070− struct fc_stats *stats;
10711070 struct fc_lport *tmp_lport;
10721071 struct fc_lport *vn_port = NULL;
10731072 struct qedf_rport *fcport;
@@ -1215,10 +1214,8 @@ static int qedf_xmit(struct fc_lport *lport, struct fc_frame *fp) · 141 unmodified lines
12151214 hp->fcoe_sof = sof;
12161215
12171216 /*update tx stats */
1218− stats = per_cpu_ptr(lport->stats, get_cpu());
1219− stats->TxFrames++;
1220− stats->TxWords += wlen;
1221− put_cpu();
1217+ this_cpu_inc(lport->stats->TxFrames);
1218+ this_cpu_add(lport->stats->TxWords, wlen);
12221219
12231220 /* Get VLAN ID from skb for printing purposes */
12241221 __vlan_hwaccel_get_tag(skb, &vlan_tci);
drivers/scsi/qla2xxx/qla_edif.c+1−2
@@ -657,7 +657,6 @@ qla_edif_app_chk_sa_update(scsi_qla_host_t *vha, fc_port_t *fcport, · 656 unmodified lines
657657 static int
658658 qla_edif_app_authok(scsi_qla_host_t *vha, struct bsg_job *bsg_job)
659659 {
660− int32_t rval = 0;
661660 struct auth_complete_cmd appplogiok;
662661 struct app_plogi_reply appplogireply = {0};
663662 struct fc_bsg_reply *bsg_reply = bsg_job->reply;
@@ -758,7 +757,7 @@ errstate_exit: · 94 unmodified lines
758757 &appplogireply,
759758 sizeof(struct app_plogi_reply));
760759
761− return rval;
760+ return 0;
762761 }
763762
764763 /**
drivers/scsi/qla2xxx/qla_os.c+0−1
@@ -3933,7 +3933,6 @@ qla2x00_free_device(scsi_qla_host_t *vha) · 3932 unmodified lines
39333933
39343934 /* Flush the work queue and remove it */
39353935 if (ha->wq) {
3936− flush_workqueue(ha->wq);
39373936 destroy_workqueue(ha->wq);
39383937 ha->wq = NULL;
39393938 }
drivers/scsi/qla2xxx/qla_target.c+0−2
@@ -3866,8 +3866,6 @@ void qlt_free_cmd(struct qla_tgt_cmd *cmd) · 3865 unmodified lines
38663866
38673867 BUG_ON(cmd->sg_mapped);
38683868 cmd->jiffies_at_free = get_jiffies_64();
3869− if (unlikely(cmd->free_sg))
3870− kfree(cmd->sg);
38713869
38723870 if (!sess || !sess->se_sess) {
38733871 WARN_ON(1);
drivers/scsi/qla2xxx/qla_target.h+0−1
@@ -883,7 +883,6 @@ struct qla_tgt_cmd { · 882 unmodified lines
883883 /* to save extra sess dereferences */
884884 unsigned int conf_compl_supported:1;
885885 unsigned int sg_mapped:1;
886− unsigned int free_sg:1;
887886 unsigned int write_data_transferred:1;
888887 unsigned int q_full:1;
889888 unsigned int term_exchg:1;
drivers/scsi/qla4xxx/ql4_os.c+0−1
@@ -671,7 +671,6 @@ static void qla4xxx_create_chap_list(struct scsi_qla_host *ha) · 670 unmodified lines
671671 goto exit_chap_list;
672672 }
673673
674− memset(ha->chap_list, 0, chap_size);
675674 memcpy(ha->chap_list, chap_flash_data, chap_size);
676675
677676 exit_chap_list:
drivers/scsi/scsi.c+79−37
@@ -200,11 +200,11 @@ void scsi_finish_command(struct scsi_cmnd *cmd) · 199 unmodified lines
200200
201201
202202 /*
203− * 1024 is big enough for saturating fast SCSI LUNs.
203+ * 4096 is big enough for saturating fast SCSI LUNs.
204204 */
205205 int scsi_device_max_queue_depth(struct scsi_device *sdev)
206206 {
207− return min_t(int, sdev->host->can_queue, 1024);
207+ return min_t(int, sdev->host->can_queue, 4096);
208208 }
209209
210210 /**
@@ -321,6 +321,31 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer, · 110 unmodified lines
321321 return get_unaligned_be16(&buffer[2]) + 4;
322322 }
323323
324+static int scsi_get_vpd_size(struct scsi_device *sdev, u8 page)
325+{
326+ unsigned char vpd_header[SCSI_VPD_HEADER_SIZE] __aligned(4);
327+ int result;
328+
329+ /*
330+ * Fetch the VPD page header to find out how big the page
331+ * is. This is done to prevent problems on legacy devices
332+ * which can not handle allocation lengths as large as
333+ * potentially requested by the caller.
334+ */
335+ result = scsi_vpd_inquiry(sdev, vpd_header, page, sizeof(vpd_header));
336+ if (result < 0)
337+ return 0;
338+
339+ if (result < SCSI_VPD_HEADER_SIZE) {
340+ dev_warn_once(&sdev->sdev_gendev,
341+ "%s: short VPD page 0x%02x length: %d bytes\n",
342+ __func__, page, result);
343+ return 0;
344+ }
345+
346+ return result;
347+}
348+
324349 /**
325350 * scsi_get_vpd_page - Get Vital Product Data from a SCSI device
326351 * @sdev: The device to ask
@@ -330,47 +355,38 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer, · 3 unmodified lines
330355 *
331356 * SCSI devices may optionally supply Vital Product Data. Each 'page'
332357 * of VPD is defined in the appropriate SCSI document (eg SPC, SBC).
333− * If the device supports this VPD page, this routine returns a pointer
334− * to a buffer containing the data from that page. The caller is
335− * responsible for calling kfree() on this pointer when it is no longer
336− * needed. If we cannot retrieve the VPD page this routine returns %NULL.
358+ * If the device supports this VPD page, this routine fills @buf
359+ * with the data from that page and return 0. If the VPD page is not
360+ * supported or its content cannot be retrieved, -EINVAL is returned.
337361 */
338362 int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf,
339363 int buf_len)
340364 {
341− int i, result;
342−
343− if (sdev->skip_vpd_pages)
344− goto fail;
345−
346− /* Ask for all the pages supported by this device */
347− result = scsi_vpd_inquiry(sdev, buf, 0, buf_len);
348− if (result < 4)
349− goto fail;
365+ int result, vpd_len;
350366
351− /* If the user actually wanted this page, we can skip the rest */
352− if (page == 0)
353− return 0;
367+ if (!scsi_device_supports_vpd(sdev))
368+ return -EINVAL;
354369
355− for (i = 4; i < min(result, buf_len); i++)
356− if (buf[i] == page)
357− goto found;
370+ vpd_len = scsi_get_vpd_size(sdev, page);
371+ if (vpd_len <= 0)
372+ return -EINVAL;
358373
359− if (i < result && i >= buf_len)
360− /* ran off the end of the buffer, give us benefit of doubt */
361− goto found;
362− /* The device claims it doesn't support the requested page */
363− goto fail;
374+ vpd_len = min(vpd_len, buf_len);
364375
365− found:
366− result = scsi_vpd_inquiry(sdev, buf, page, buf_len);
376+ /*
377+ * Fetch the actual page. Since the appropriate size was reported
378+ * by the device it is now safe to ask for something bigger.
379+ */
380+ memset(buf, 0, buf_len);
381+ result = scsi_vpd_inquiry(sdev, buf, page, vpd_len);
367382 if (result < 0)
368− goto fail;
383+ return -EINVAL;
384+ else if (result > vpd_len)
385+ dev_warn_once(&sdev->sdev_gendev,
386+ "%s: VPD page 0x%02x result %d > %d bytes\n",
387+ __func__, page, result, vpd_len);
369388
370389 return 0;
371−
372− fail:
373− return -EINVAL;
374390 }
375391 EXPORT_SYMBOL_GPL(scsi_get_vpd_page);
376392
@@ -384,9 +400,17 @@ EXPORT_SYMBOL_GPL(scsi_get_vpd_page); · 7 unmodified lines
384400 static struct scsi_vpd *scsi_get_vpd_buf(struct scsi_device *sdev, u8 page)
385401 {
386402 struct scsi_vpd *vpd_buf;
387− int vpd_len = SCSI_VPD_PG_LEN, result;
403+ int vpd_len, result;
404+
405+ vpd_len = scsi_get_vpd_size(sdev, page);
406+ if (vpd_len <= 0)
407+ return NULL;
388408
389409 retry_pg:
410+ /*
411+ * Fetch the actual page. Since the appropriate size was reported
412+ * by the device it is now safe to ask for something bigger.
413+ */
390414 vpd_buf = kmalloc(sizeof(*vpd_buf) + vpd_len, GFP_KERNEL);
391415 if (!vpd_buf)
392416 return NULL;
@@ -397,6 +421,9 @@ retry_pg: · 4 unmodified lines
397421 return NULL;
398422 }
399423 if (result > vpd_len) {
424+ dev_warn_once(&sdev->sdev_gendev,
425+ "%s: VPD page 0x%02x result %d > %d bytes\n",
426+ __func__, page, result, vpd_len);
400427 vpd_len = result;
401428 kfree(vpd_buf);
402429 goto retry_pg;
@@ -456,6 +483,12 @@ void scsi_attach_vpd(struct scsi_device *sdev) · 53 unmodified lines
456483 scsi_update_vpd_page(sdev, 0x83, &sdev->vpd_pg83);
457484 if (vpd_buf->data[i] == 0x89)
458485 scsi_update_vpd_page(sdev, 0x89, &sdev->vpd_pg89);
486+ if (vpd_buf->data[i] == 0xb0)
487+ scsi_update_vpd_page(sdev, 0xb0, &sdev->vpd_pgb0);
488+ if (vpd_buf->data[i] == 0xb1)
489+ scsi_update_vpd_page(sdev, 0xb1, &sdev->vpd_pgb1);
490+ if (vpd_buf->data[i] == 0xb2)
491+ scsi_update_vpd_page(sdev, 0xb2, &sdev->vpd_pgb2);
459492 }
460493 kfree(vpd_buf);
461494 }
@@ -476,21 +509,30 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer, · 14 unmodified lines
476509 {
477510 unsigned char cmd[16];
478511 struct scsi_sense_hdr sshdr;
479− int result;
512+ int result, request_len;
480513
481514 if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3)
482515 return -EINVAL;
483516
517+ /* RSOC header + size of command we are asking about */
518+ request_len = 4 + COMMAND_SIZE(opcode);
519+ if (request_len > len) {
520+ dev_warn_once(&sdev->sdev_gendev,
521+ "%s: len %u bytes, opcode 0x%02x needs %u\n",
522+ __func__, len, opcode, request_len);
523+ return -EINVAL;
524+ }
525+
484526 memset(cmd, 0, 16);
485527 cmd[0] = MAINTENANCE_IN;
486528 cmd[1] = MI_REPORT_SUPPORTED_OPERATION_CODES;
487529 cmd[2] = 1; /* One command format */
488530 cmd[3] = opcode;
489− put_unaligned_be32(len, &cmd[6]);
531+ put_unaligned_be32(request_len, &cmd[6]);
490532 memset(buffer, 0, len);
491533
492− result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len,
493− &sshdr, 30 * HZ, 3, NULL);
534+ result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer,
535+ request_len, &sshdr, 30 * HZ, 3, NULL);
494536
495537 if (result < 0)
496538 return result;
drivers/scsi/scsi_debug.c+114−35
@@ -16,7 +16,7 @@ · 15 unmodified lines
1616 #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
1717
1818 #include <linux/module.h>
19−
19+#include <linux/align.h>
2020 #include <linux/kernel.h>
2121 #include <linux/errno.h>
2222 #include <linux/jiffies.h>
@@ -98,6 +98,7 @@ static const char *sdebug_version_date = "20210520"; · 75 unmodified lines
9898 #define WRITE_BOUNDARY_ASCQ 0x5
9999 #define READ_INVDATA_ASCQ 0x6
100100 #define READ_BOUNDARY_ASCQ 0x7
101+#define ATTEMPT_ACCESS_GAP 0x9
101102 #define INSUFF_ZONE_ASCQ 0xe
102103
103104 /* Additional Sense Code Qualifier (ASCQ) */
@@ -251,9 +252,11 @@ static const char *sdebug_version_date = "20210520"; · 147 unmodified lines
251252
252253 /* Zone types (zbcr05 table 25) */
253254 enum sdebug_z_type {
254− ZBC_ZONE_TYPE_CNV = 0x1,
255− ZBC_ZONE_TYPE_SWR = 0x2,
256− ZBC_ZONE_TYPE_SWP = 0x3,
255+ ZBC_ZTYPE_CNV = 0x1,
256+ ZBC_ZTYPE_SWR = 0x2,
257+ ZBC_ZTYPE_SWP = 0x3,
258+ /* ZBC_ZTYPE_SOBR = 0x4, */
259+ ZBC_ZTYPE_GAP = 0x5,
257260 };
258261
259262 /* enumeration names taken from table 26, zbcr05 */
@@ -291,10 +294,12 @@ struct sdebug_dev_info { · 31 unmodified lines
291294
292295 /* For ZBC devices */
293296 enum blk_zoned_model zmodel;
297+ unsigned int zcap;
294298 unsigned int zsize;
295299 unsigned int zsize_shift;
296300 unsigned int nr_zones;
297301 unsigned int nr_conv_zones;
302+ unsigned int nr_seq_zones;
298303 unsigned int nr_imp_open;
299304 unsigned int nr_exp_open;
300305 unsigned int nr_closed;
@@ -829,6 +834,7 @@ static int dif_errors; · 528 unmodified lines
829834
830835 /* ZBC global data */
831836 static bool sdeb_zbc_in_use; /* true for host-aware and host-managed disks */
837+static int sdeb_zbc_zone_cap_mb;
832838 static int sdeb_zbc_zone_size_mb;
833839 static int sdeb_zbc_max_open = DEF_ZBC_MAX_OPEN_ZONES;
834840 static int sdeb_zbc_nr_conv = DEF_ZBC_NR_CONV_ZONES;
@@ -1559,6 +1565,12 @@ static int inquiry_vpd_b6(struct sdebug_dev_info *devip, unsigned char *arr) · 724 unmodified lines
15591565 put_unaligned_be32(devip->max_open, &arr[12]);
15601566 else
15611567 put_unaligned_be32(0xffffffff, &arr[12]);
1568+ if (devip->zcap < devip->zsize) {
1569+ arr[19] = ZBC_CONSTANT_ZONE_START_OFFSET;
1570+ put_unaligned_be64(devip->zsize, &arr[20]);
1571+ } else {
1572+ arr[19] = 0;
1573+ }
15621574 return 0x3c;
15631575 }
15641576
@@ -2711,12 +2723,38 @@ static inline bool sdebug_dev_is_zoned(struct sdebug_dev_info *devip) · 1146 unmodified lines
27112723 static struct sdeb_zone_state *zbc_zone(struct sdebug_dev_info *devip,
27122724 unsigned long long lba)
27132725 {
2714− return &devip->zstate[lba >> devip->zsize_shift];
2726+ u32 zno = lba >> devip->zsize_shift;
2727+ struct sdeb_zone_state *zsp;
2728+
2729+ if (devip->zcap == devip->zsize || zno < devip->nr_conv_zones)
2730+ return &devip->zstate[zno];
2731+
2732+ /*
2733+ * If the zone capacity is less than the zone size, adjust for gap
2734+ * zones.
2735+ */
2736+ zno = 2 * zno - devip->nr_conv_zones;
2737+ WARN_ONCE(zno >= devip->nr_zones, "%u > %u\n", zno, devip->nr_zones);
2738+ zsp = &devip->zstate[zno];
2739+ if (lba >= zsp->z_start + zsp->z_size)
2740+ zsp++;
2741+ WARN_ON_ONCE(lba >= zsp->z_start + zsp->z_size);
2742+ return zsp;
27152743 }
27162744
27172745 static inline bool zbc_zone_is_conv(struct sdeb_zone_state *zsp)
27182746 {
2719− return zsp->z_type == ZBC_ZONE_TYPE_CNV;
2747+ return zsp->z_type == ZBC_ZTYPE_CNV;
2748+}
2749+
2750+static inline bool zbc_zone_is_gap(struct sdeb_zone_state *zsp)
2751+{
2752+ return zsp->z_type == ZBC_ZTYPE_GAP;
2753+}
2754+
2755+static inline bool zbc_zone_is_seq(struct sdeb_zone_state *zsp)
2756+{
2757+ return !zbc_zone_is_conv(zsp) && !zbc_zone_is_gap(zsp);
27202758 }
27212759
27222760 static void zbc_close_zone(struct sdebug_dev_info *devip,
@@ -2724,7 +2762,7 @@ static void zbc_close_zone(struct sdebug_dev_info *devip, · 1 unmodified line
27242762 {
27252763 enum sdebug_z_cond zc;
27262764
2727− if (zbc_zone_is_conv(zsp))
2765+ if (!zbc_zone_is_seq(zsp))
27282766 return;
27292767
27302768 zc = zsp->z_cond;
@@ -2762,7 +2800,7 @@ static void zbc_open_zone(struct sdebug_dev_info *devip, · 31 unmodified lines
27622800 {
27632801 enum sdebug_z_cond zc;
27642802
2765− if (zbc_zone_is_conv(zsp))
2803+ if (!zbc_zone_is_seq(zsp))
27662804 return;
27672805
27682806 zc = zsp->z_cond;
@@ -2794,10 +2832,10 @@ static void zbc_inc_wp(struct sdebug_dev_info *devip, · 25 unmodified lines
27942832 struct sdeb_zone_state *zsp = zbc_zone(devip, lba);
27952833 unsigned long long n, end, zend = zsp->z_start + zsp->z_size;
27962834
2797− if (zbc_zone_is_conv(zsp))
2835+ if (!zbc_zone_is_seq(zsp))
27982836 return;
27992837
2800− if (zsp->z_type == ZBC_ZONE_TYPE_SWR) {
2838+ if (zsp->z_type == ZBC_ZTYPE_SWR) {
28012839 zsp->z_wp += num;
28022840 if (zsp->z_wp >= zend)
28032841 zsp->z_cond = ZC5_FULL;
@@ -2842,9 +2880,7 @@ static int check_zbc_access_params(struct scsi_cmnd *scp, · 38 unmodified lines
28422880 if (devip->zmodel == BLK_ZONED_HA)
28432881 return 0;
28442882 /* For host-managed, reads cannot cross zone types boundaries */
2845− if (zsp_end != zsp &&
2846− zbc_zone_is_conv(zsp) &&
2847− !zbc_zone_is_conv(zsp_end)) {
2883+ if (zsp->z_type != zsp_end->z_type) {
28482884 mk_sense_buffer(scp, ILLEGAL_REQUEST,
28492885 LBA_OUT_OF_RANGE,
28502886 READ_INVDATA_ASCQ);
@@ -2853,6 +2889,13 @@ static int check_zbc_access_params(struct scsi_cmnd *scp, · 2 unmodified lines
28532889 return 0;
28542890 }
28552891
2892+ /* Writing into a gap zone is not allowed */
2893+ if (zbc_zone_is_gap(zsp)) {
2894+ mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE,
2895+ ATTEMPT_ACCESS_GAP);
2896+ return check_condition_result;
2897+ }
2898+
28562899 /* No restrictions for writes within conventional zones */
28572900 if (zbc_zone_is_conv(zsp)) {
28582901 if (!zbc_zone_is_conv(zsp_end)) {
@@ -2864,7 +2907,7 @@ static int check_zbc_access_params(struct scsi_cmnd *scp, · 5 unmodified lines
28642907 return 0;
28652908 }
28662909
2867− if (zsp->z_type == ZBC_ZONE_TYPE_SWR) {
2910+ if (zsp->z_type == ZBC_ZTYPE_SWR) {
28682911 /* Writes cannot cross sequential zone boundaries */
28692912 if (zsp_end != zsp) {
28702913 mk_sense_buffer(scp, ILLEGAL_REQUEST,
@@ -4404,18 +4447,18 @@ cleanup: · 1533 unmodified lines
44044447
44054448 #define RZONES_DESC_HD 64
44064449
4407−/* Report zones depending on start LBA nad reporting options */
4450+/* Report zones depending on start LBA and reporting options */
44084451 static int resp_report_zones(struct scsi_cmnd *scp,
44094452 struct sdebug_dev_info *devip)
44104453 {
4411− unsigned int i, max_zones, rep_max_zones, nrz = 0;
4454+ unsigned int rep_max_zones, nrz = 0;
44124455 int ret = 0;
44134456 u32 alloc_len, rep_opts, rep_len;
44144457 bool partial;
44154458 u64 lba, zs_lba;
44164459 u8 *arr = NULL, *desc;
44174460 u8 *cmd = scp->cmnd;
4418− struct sdeb_zone_state *zsp;
4461+ struct sdeb_zone_state *zsp = NULL;
44194462 struct sdeb_store_info *sip = devip2sip(devip, false);
44204463
44214464 if (!sdebug_dev_is_zoned(devip)) {
@@ -4434,9 +4477,7 @@ static int resp_report_zones(struct scsi_cmnd *scp, · 12 unmodified lines
44344477 return check_condition_result;
44354478 }
44364479
4437− max_zones = devip->nr_zones - (zs_lba >> devip->zsize_shift);
4438− rep_max_zones = min((alloc_len - 64) >> ilog2(RZONES_DESC_HD),
4439− max_zones);
4480+ rep_max_zones = (alloc_len - 64) >> ilog2(RZONES_DESC_HD);
44404481
44414482 arr = kzalloc(alloc_len, GFP_ATOMIC);
44424483 if (!arr) {
@@ -4448,9 +4489,9 @@ static int resp_report_zones(struct scsi_cmnd *scp, · 5 unmodified lines
44484489 sdeb_read_lock(sip);
44494490
44504491 desc = arr + 64;
4451− for (i = 0; i < max_zones; i++) {
4452− lba = zs_lba + devip->zsize * i;
4453− if (lba > sdebug_capacity)
4492+ for (lba = zs_lba; lba < sdebug_capacity;
4493+ lba = zsp->z_start + zsp->z_size) {
4494+ if (WARN_ONCE(zbc_zone(devip, lba) == zsp, "lba = %llu\n", lba))
44544495 break;
44554496 zsp = zbc_zone(devip, lba);
44564497 switch (rep_opts) {
@@ -4495,9 +4536,14 @@ static int resp_report_zones(struct scsi_cmnd *scp, · 38 unmodified lines
44954536 if (!zsp->z_non_seq_resource)
44964537 continue;
44974538 break;
4539+ case 0x3e:
4540+ /* All zones except gap zones. */
4541+ if (zbc_zone_is_gap(zsp))
4542+ continue;
4543+ break;
44984544 case 0x3f:
44994545 /* Not write pointer (conventional) zones */
4500− if (!zbc_zone_is_conv(zsp))
4546+ if (zbc_zone_is_seq(zsp))
45014547 continue;
45024548 break;
45034549 default:
@@ -4526,8 +4572,13 @@ static int resp_report_zones(struct scsi_cmnd *scp, · 22 unmodified lines
45264572 }
45274573
45284574 /* Report header */
4575+ /* Zone list length. */
45294576 put_unaligned_be32(nrz * RZONES_DESC_HD, arr + 0);
4577+ /* Maximum LBA */
45304578 put_unaligned_be64(sdebug_capacity - 1, arr + 8);
4579+ /* Zone starting LBA granularity. */
4580+ if (devip->zcap < devip->zsize)
4581+ put_unaligned_be64(devip->zsize, arr + 16);
45314582
45324583 rep_len = (unsigned long)desc - (unsigned long)arr;
45334584 ret = fill_from_dev_buffer(scp, arr, min_t(u32, alloc_len, rep_len));
@@ -4752,7 +4803,7 @@ static void zbc_rwp_zone(struct sdebug_dev_info *devip, · 218 unmodified lines
47524803 enum sdebug_z_cond zc;
47534804 struct sdeb_store_info *sip = devip2sip(devip, false);
47544805
4755− if (zbc_zone_is_conv(zsp))
4806+ if (!zbc_zone_is_seq(zsp))
47564807 return;
47574808
47584809 zc = zsp->z_cond;
@@ -4942,6 +4993,7 @@ static int sdebug_device_create_zones(struct sdebug_dev_info *devip) · 183 unmodified lines
49424993 {
49434994 struct sdeb_zone_state *zsp;
49444995 sector_t capacity = get_sdebug_capacity();
4996+ sector_t conv_capacity;
49454997 sector_t zstart = 0;
49464998 unsigned int i;
49474999
@@ -4976,11 +5028,30 @@ static int sdebug_device_create_zones(struct sdebug_dev_info *devip) · 28 unmodified lines
49765028 devip->zsize_shift = ilog2(devip->zsize);
49775029 devip->nr_zones = (capacity + devip->zsize - 1) >> devip->zsize_shift;
49785030
4979− if (sdeb_zbc_nr_conv >= devip->nr_zones) {
5031+ if (sdeb_zbc_zone_cap_mb == 0) {
5032+ devip->zcap = devip->zsize;
5033+ } else {
5034+ devip->zcap = (sdeb_zbc_zone_cap_mb * SZ_1M) >>
5035+ ilog2(sdebug_sector_size);
5036+ if (devip->zcap > devip->zsize) {
5037+ pr_err("Zone capacity too large\n");
5038+ return -EINVAL;
5039+ }
5040+ }
5041+
5042+ conv_capacity = (sector_t)sdeb_zbc_nr_conv << devip->zsize_shift;
5043+ if (conv_capacity >= capacity) {
49805044 pr_err("Number of conventional zones too large\n");
49815045 return -EINVAL;
49825046 }
49835047 devip->nr_conv_zones = sdeb_zbc_nr_conv;
5048+ devip->nr_seq_zones = ALIGN(capacity - conv_capacity, devip->zsize) >>
5049+ devip->zsize_shift;
5050+ devip->nr_zones = devip->nr_conv_zones + devip->nr_seq_zones;
5051+
5052+ /* Add gap zones if zone capacity is smaller than the zone size */
5053+ if (devip->zcap < devip->zsize)
5054+ devip->nr_zones += devip->nr_seq_zones;
49845055
49855056 if (devip->zmodel == BLK_ZONED_HM) {
49865057 /* zbc_max_open_zones can be 0, meaning "not reported" */
@@ -5001,23 +5072,29 @@ static int sdebug_device_create_zones(struct sdebug_dev_info *devip) · 14 unmodified lines
50015072 zsp->z_start = zstart;
50025073
50035074 if (i < devip->nr_conv_zones) {
5004− zsp->z_type = ZBC_ZONE_TYPE_CNV;
5075+ zsp->z_type = ZBC_ZTYPE_CNV;
50055076 zsp->z_cond = ZBC_NOT_WRITE_POINTER;
50065077 zsp->z_wp = (sector_t)-1;
5007− } else {
5078+ zsp->z_size =
5079+ min_t(u64, devip->zsize, capacity - zstart);
5080+ } else if ((zstart & (devip->zsize - 1)) == 0) {
50085081 if (devip->zmodel == BLK_ZONED_HM)
5009− zsp->z_type = ZBC_ZONE_TYPE_SWR;
5082+ zsp->z_type = ZBC_ZTYPE_SWR;
50105083 else
5011− zsp->z_type = ZBC_ZONE_TYPE_SWP;
5084+ zsp->z_type = ZBC_ZTYPE_SWP;
50125085 zsp->z_cond = ZC1_EMPTY;
50135086 zsp->z_wp = zsp->z_start;
5087+ zsp->z_size =
5088+ min_t(u64, devip->zcap, capacity - zstart);
5089+ } else {
5090+ zsp->z_type = ZBC_ZTYPE_GAP;
5091+ zsp->z_cond = ZBC_NOT_WRITE_POINTER;
5092+ zsp->z_wp = (sector_t)-1;
5093+ zsp->z_size = min_t(u64, devip->zsize - devip->zcap,
5094+ capacity - zstart);
50145095 }
50155096
5016− if (zsp->z_start + devip->zsize < capacity)
5017− zsp->z_size = devip->zsize;
5018− else
5019− zsp->z_size = capacity - zsp->z_start;
5020−
5097+ WARN_ON_ONCE((int)zsp->z_size <= 0);
50215098 zstart += zsp->z_size;
50225099 }
50235100
@@ -5779,6 +5856,7 @@ module_param_named(wp, sdebug_wp, bool, S_IRUGO | S_IWUSR); · 755 unmodified lines
57795856 module_param_named(write_same_length, sdebug_write_same_length, int,
57805857 S_IRUGO | S_IWUSR);
57815858 module_param_named(zbc, sdeb_zbc_model_s, charp, S_IRUGO);
5859+module_param_named(zone_cap_mb, sdeb_zbc_zone_cap_mb, int, S_IRUGO);
57825860 module_param_named(zone_max_open, sdeb_zbc_max_open, int, S_IRUGO);
57835861 module_param_named(zone_nr_conv, sdeb_zbc_nr_conv, int, S_IRUGO);
57845862 module_param_named(zone_size_mb, sdeb_zbc_zone_size_mb, int, S_IRUGO);
@@ -5850,6 +5928,7 @@ MODULE_PARM_DESC(vpd_use_hostno, "0 -> dev ids ignore hostno (def=1 -> unique de · 65 unmodified lines
58505928 MODULE_PARM_DESC(wp, "Write Protect (def=0)");
58515929 MODULE_PARM_DESC(write_same_length, "Maximum blocks per WRITE SAME cmd (def=0xffff)");
58525930 MODULE_PARM_DESC(zbc, "'none' [0]; 'aware' [1]; 'managed' [2] (def=0). Can have 'host-' prefix");
5931+MODULE_PARM_DESC(zone_cap_mb, "Zone capacity in MiB (def=zone size)");
58535932 MODULE_PARM_DESC(zone_max_open, "Maximum number of open zones; [0] for no limit (def=auto)");
58545933 MODULE_PARM_DESC(zone_nr_conv, "Number of conventional zones (def=1)");
58555934 MODULE_PARM_DESC(zone_size_mb, "Zone size in MiB (def=auto)");
drivers/scsi/scsi_lib.c+1−1
@@ -1977,7 +1977,7 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost) · 1976 unmodified lines
19771977 tag_set->nr_maps = shost->nr_maps ? : 1;
19781978 tag_set->queue_depth = shost->can_queue;
19791979 tag_set->cmd_size = cmd_size;
1980− tag_set->numa_node = NUMA_NO_NODE;
1980+ tag_set->numa_node = dev_to_node(shost->dma_dev);
19811981 tag_set->flags = BLK_MQ_F_SHOULD_MERGE;
19821982 tag_set->flags |=
19831983 BLK_ALLOC_POLICY_TO_MQ_FLAG(shost->hostt->tag_alloc_policy);
drivers/scsi/scsi_scan.c+11−1
@@ -733,7 +733,17 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, · 732 unmodified lines
733733 if (pass == 1) {
734734 if (BLIST_INQUIRY_36 & *bflags)
735735 next_inquiry_len = 36;
736− else if (sdev->inquiry_len)
736+ /*
737+ * LLD specified a maximum sdev->inquiry_len
738+ * but device claims it has more data. Capping
739+ * the length only makes sense for legacy
740+ * devices. If a device supports SPC-4 (2014)
741+ * or newer, assume that it is safe to ask for
742+ * as much as the device says it supports.
743+ */
744+ else if (sdev->inquiry_len &&
745+ response_len > sdev->inquiry_len &&
746+ (inq_result[2] & 0x7) < 6) /* SPC-4 */
737747 next_inquiry_len = sdev->inquiry_len;
738748 else
739749 next_inquiry_len = response_len;
drivers/scsi/scsi_sysfs.c+28−0
@@ -448,6 +448,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work) · 447 unmodified lines
448448 struct list_head *this, *tmp;
449449 struct scsi_vpd *vpd_pg80 = NULL, *vpd_pg83 = NULL;
450450 struct scsi_vpd *vpd_pg0 = NULL, *vpd_pg89 = NULL;
451+ struct scsi_vpd *vpd_pgb0 = NULL, *vpd_pgb1 = NULL, *vpd_pgb2 = NULL;
451452 unsigned long flags;
452453 struct module *mod;
453454
@@ -490,6 +491,12 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work) · 36 unmodified lines
490491 lockdep_is_held(&sdev->inquiry_mutex));
491492 vpd_pg89 = rcu_replace_pointer(sdev->vpd_pg89, vpd_pg89,
492493 lockdep_is_held(&sdev->inquiry_mutex));
494+ vpd_pgb0 = rcu_replace_pointer(sdev->vpd_pgb0, vpd_pgb0,
495+ lockdep_is_held(&sdev->inquiry_mutex));
496+ vpd_pgb1 = rcu_replace_pointer(sdev->vpd_pgb1, vpd_pgb1,
497+ lockdep_is_held(&sdev->inquiry_mutex));
498+ vpd_pgb2 = rcu_replace_pointer(sdev->vpd_pgb2, vpd_pgb2,
499+ lockdep_is_held(&sdev->inquiry_mutex));
493500 mutex_unlock(&sdev->inquiry_mutex);
494501
495502 if (vpd_pg0)
@@ -500,6 +507,12 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work) · 4 unmodified lines
500507 kfree_rcu(vpd_pg80, rcu);
501508 if (vpd_pg89)
502509 kfree_rcu(vpd_pg89, rcu);
510+ if (vpd_pgb0)
511+ kfree_rcu(vpd_pgb0, rcu);
512+ if (vpd_pgb1)
513+ kfree_rcu(vpd_pgb1, rcu);
514+ if (vpd_pgb2)
515+ kfree_rcu(vpd_pgb2, rcu);
503516 kfree(sdev->inquiry);
504517 kfree(sdev);
505518
@@ -913,6 +926,9 @@ static struct bin_attribute dev_attr_vpd_##_page = { \ · 407 unmodified lines
913926 sdev_vpd_pg_attr(pg83);
914927 sdev_vpd_pg_attr(pg80);
915928 sdev_vpd_pg_attr(pg89);
929+sdev_vpd_pg_attr(pgb0);
930+sdev_vpd_pg_attr(pgb1);
931+sdev_vpd_pg_attr(pgb2);
916932 sdev_vpd_pg_attr(pg0);
917933
918934 static ssize_t show_inquiry(struct file *filep, struct kobject *kobj,
@@ -1250,6 +1266,15 @@ static umode_t scsi_sdev_bin_attr_is_visible(struct kobject *kobj, · 331 unmodified lines
12501266 if (attr == &dev_attr_vpd_pg89 && !sdev->vpd_pg89)
12511267 return 0;
12521268
1269+ if (attr == &dev_attr_vpd_pgb0 && !sdev->vpd_pgb0)
1270+ return 0;
1271+
1272+ if (attr == &dev_attr_vpd_pgb1 && !sdev->vpd_pgb1)
1273+ return 0;
1274+
1275+ if (attr == &dev_attr_vpd_pgb2 && !sdev->vpd_pgb2)
1276+ return 0;
1277+
12531278 return S_IRUGO;
12541279 }
12551280
@@ -1296,6 +1321,9 @@ static struct bin_attribute *scsi_sdev_bin_attrs[] = { · 40 unmodified lines
12961321 &dev_attr_vpd_pg83,
12971322 &dev_attr_vpd_pg80,
12981323 &dev_attr_vpd_pg89,
1324+ &dev_attr_vpd_pgb0,
1325+ &dev_attr_vpd_pgb1,
1326+ &dev_attr_vpd_pgb2,
12991327 &dev_attr_inquiry,
13001328 NULL
13011329 };
drivers/scsi/sd.c+118−75
@@ -2174,40 +2174,48 @@ static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer · 2173 unmodified lines
21742174 {
21752175 struct scsi_device *sdp = sdkp->device;
21762176 u8 type;
2177− int ret = 0;
21782177
21792178 if (scsi_device_protection(sdp) == 0 || (buffer[12] & 1) == 0) {
21802179 sdkp->protection_type = 0;
2181− return ret;
2180+ return 0;
21822181 }
21832182
21842183 type = ((buffer[12] >> 1) & 7) + 1; /* P_TYPE 0 = Type 1 */
21852184
2186− if (type > T10_PI_TYPE3_PROTECTION)
2187− ret = -ENODEV;
2188− else if (scsi_host_dif_capable(sdp->host, type))
2189− ret = 1;
2190−
2191− if (sdkp->first_scan || type != sdkp->protection_type)
2192− switch (ret) {
2193− case -ENODEV:
2194− sd_printk(KERN_ERR, sdkp, "formatted with unsupported" \
2195− " protection type %u. Disabling disk!\n",
2196− type);
2197− break;
2198− case 1:
2199− sd_printk(KERN_NOTICE, sdkp,
2200− "Enabling DIF Type %u protection\n", type);
2201− break;
2202− case 0:
2203− sd_printk(KERN_NOTICE, sdkp,
2204− "Disabling DIF Type %u protection\n", type);
2205− break;
2206− }
2185+ if (type > T10_PI_TYPE3_PROTECTION) {
2186+ sd_printk(KERN_ERR, sdkp, "formatted with unsupported" \
2187+ " protection type %u. Disabling disk!\n",
2188+ type);
2189+ sdkp->protection_type = 0;
2190+ return -ENODEV;
2191+ }
22072192
22082193 sdkp->protection_type = type;
22092194
2210− return ret;
2195+ return 0;
2196+}
2197+
2198+static void sd_config_protection(struct scsi_disk *sdkp)
2199+{
2200+ struct scsi_device *sdp = sdkp->device;
2201+
2202+ if (!sdkp->first_scan)
2203+ return;
2204+
2205+ sd_dif_config_host(sdkp);
2206+
2207+ if (!sdkp->protection_type)
2208+ return;
2209+
2210+ if (!scsi_host_dif_capable(sdp->host, sdkp->protection_type)) {
2211+ sd_printk(KERN_NOTICE, sdkp,
2212+ "Disabling DIF Type %u protection\n",
2213+ sdkp->protection_type);
2214+ sdkp->protection_type = 0;
2215+ }
2216+
2217+ sd_printk(KERN_NOTICE, sdkp, "Enabling DIF Type %u protection\n",
2218+ sdkp->protection_type);
22112219 }
22122220
22132221 static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp,
@@ -2841,40 +2849,37 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer) · 627 unmodified lines
28412849 */
28422850 static void sd_read_block_limits(struct scsi_disk *sdkp)
28432851 {
2844− unsigned int sector_sz = sdkp->device->sector_size;
2845− const int vpd_len = 64;
2846− unsigned char *buffer = kmalloc(vpd_len, GFP_KERNEL);
2852+ struct scsi_vpd *vpd;
28472853
2848− if (!buffer ||
2849− /* Block Limits VPD */
2850− scsi_get_vpd_page(sdkp->device, 0xb0, buffer, vpd_len))
2851− goto out;
2854+ rcu_read_lock();
28522855
2853− blk_queue_io_min(sdkp->disk->queue,
2854− get_unaligned_be16(&buffer[6]) * sector_sz);
2856+ vpd = rcu_dereference(sdkp->device->vpd_pgb0);
2857+ if (!vpd || vpd->len < 16)
2858+ goto out;
28552859
2856− sdkp->max_xfer_blocks = get_unaligned_be32(&buffer[8]);
2857− sdkp->opt_xfer_blocks = get_unaligned_be32(&buffer[12]);
2860+ sdkp->min_xfer_blocks = get_unaligned_be16(&vpd->data[6]);
2861+ sdkp->max_xfer_blocks = get_unaligned_be32(&vpd->data[8]);
2862+ sdkp->opt_xfer_blocks = get_unaligned_be32(&vpd->data[12]);
28582863
2859− if (buffer[3] == 0x3c) {
2864+ if (vpd->len >= 64) {
28602865 unsigned int lba_count, desc_count;
28612866
2862− sdkp->max_ws_blocks = (u32)get_unaligned_be64(&buffer[36]);
2867+ sdkp->max_ws_blocks = (u32)get_unaligned_be64(&vpd->data[36]);
28632868
28642869 if (!sdkp->lbpme)
28652870 goto out;
28662871
2867− lba_count = get_unaligned_be32(&buffer[20]);
2868− desc_count = get_unaligned_be32(&buffer[24]);
2872+ lba_count = get_unaligned_be32(&vpd->data[20]);
2873+ desc_count = get_unaligned_be32(&vpd->data[24]);
28692874
28702875 if (lba_count && desc_count)
28712876 sdkp->max_unmap_blocks = lba_count;
28722877
2873− sdkp->unmap_granularity = get_unaligned_be32(&buffer[28]);
2878+ sdkp->unmap_granularity = get_unaligned_be32(&vpd->data[28]);
28742879
2875− if (buffer[32] & 0x80)
2880+ if (vpd->data[32] & 0x80)
28762881 sdkp->unmap_alignment =
2877− get_unaligned_be32(&buffer[32]) & ~(1 << 31);
2882+ get_unaligned_be32(&vpd->data[32]) & ~(1 << 31);
28782883
28792884 if (!sdkp->lbpvpd) { /* LBP VPD page not provided */
28802885
@@ -2896,7 +2901,7 @@ static void sd_read_block_limits(struct scsi_disk *sdkp) · 15 unmodified lines
28962901 }
28972902
28982903 out:
2899− kfree(buffer);
2904+ rcu_read_unlock();
29002905 }
29012906
29022907 /**
@@ -2906,18 +2911,21 @@ static void sd_read_block_limits(struct scsi_disk *sdkp) · 3 unmodified lines
29062911 static void sd_read_block_characteristics(struct scsi_disk *sdkp)
29072912 {
29082913 struct request_queue *q = sdkp->disk->queue;
2909− unsigned char *buffer;
2914+ struct scsi_vpd *vpd;
29102915 u16 rot;
2911− const int vpd_len = 64;
2916+ u8 zoned;
29122917
2913− buffer = kmalloc(vpd_len, GFP_KERNEL);
2918+ rcu_read_lock();
2919+ vpd = rcu_dereference(sdkp->device->vpd_pgb1);
29142920
2915− if (!buffer ||
2916− /* Block Device Characteristics VPD */
2917− scsi_get_vpd_page(sdkp->device, 0xb1, buffer, vpd_len))
2918− goto out;
2921+ if (!vpd || vpd->len < 8) {
2922+ rcu_read_unlock();
2923+ return;
2924+ }
29192925
2920− rot = get_unaligned_be16(&buffer[4]);
2926+ rot = get_unaligned_be16(&vpd->data[4]);
2927+ zoned = (vpd->data[8] >> 4) & 3;
2928+ rcu_read_unlock();
29212929
29222930 if (rot == 1) {
29232931 blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
@@ -2928,7 +2936,7 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) · 4 unmodified lines
29282936 /* Host-managed */
29292937 blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HM);
29302938 } else {
2931− sdkp->zoned = (buffer[8] >> 4) & 3;
2939+ sdkp->zoned = zoned;
29322940 if (sdkp->zoned == 1) {
29332941 /* Host-aware */
29342942 blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HA);
@@ -2939,7 +2947,7 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) · 4 unmodified lines
29392947 }
29402948
29412949 if (!sdkp->first_scan)
2942− goto out;
2950+ return;
29432951
29442952 if (blk_queue_is_zoned(q)) {
29452953 sd_printk(KERN_NOTICE, sdkp, "Host-%s zoned block device\n",
@@ -2952,9 +2960,6 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) · 6 unmodified lines
29522960 sd_printk(KERN_NOTICE, sdkp,
29532961 "Drive-managed SMR disk\n");
29542962 }
2955−
2956− out:
2957− kfree(buffer);
29582963 }
29592964
29602965 /**
@@ -2963,24 +2968,24 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) · 2 unmodified lines
29632968 */
29642969 static void sd_read_block_provisioning(struct scsi_disk *sdkp)
29652970 {
2966− unsigned char *buffer;
2967− const int vpd_len = 8;
2971+ struct scsi_vpd *vpd;
29682972
29692973 if (sdkp->lbpme == 0)
29702974 return;
29712975
2972− buffer = kmalloc(vpd_len, GFP_KERNEL);
2976+ rcu_read_lock();
2977+ vpd = rcu_dereference(sdkp->device->vpd_pgb2);
29732978
2974− if (!buffer || scsi_get_vpd_page(sdkp->device, 0xb2, buffer, vpd_len))
2975− goto out;
2979+ if (!vpd || vpd->len < 8) {
2980+ rcu_read_unlock();
2981+ return;
2982+ }
29762983
29772984 sdkp->lbpvpd = 1;
2978− sdkp->lbpu = (buffer[5] >> 7) & 1; /* UNMAP */
2979− sdkp->lbpws = (buffer[5] >> 6) & 1; /* WRITE SAME(16) with UNMAP */
2980− sdkp->lbpws10 = (buffer[5] >> 5) & 1; /* WRITE SAME(10) with UNMAP */
2981−
2982− out:
2983− kfree(buffer);
2985+ sdkp->lbpu = (vpd->data[5] >> 7) & 1; /* UNMAP */
2986+ sdkp->lbpws = (vpd->data[5] >> 6) & 1; /* WRITE SAME(16) w/ UNMAP */
2987+ sdkp->lbpws10 = (vpd->data[5] >> 5) & 1; /* WRITE SAME(10) w/ UNMAP */
2988+ rcu_read_unlock();
29842989 }
29852990
29862991 static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer)
@@ -2994,8 +2999,7 @@ static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer) · 7 unmodified lines
29942999 }
29953000
29963001 if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, INQUIRY) < 0) {
2997− /* too large values might cause issues with arcmsr */
2998− int vpd_buf_len = 64;
3002+ struct scsi_vpd *vpd;
29993003
30003004 sdev->no_report_opcodes = 1;
30013005
@@ -3003,8 +3007,11 @@ static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer) · 1 unmodified line
30033007 * CODES is unsupported and the device has an ATA
30043008 * Information VPD page (SAT).
30053009 */
3006− if (!scsi_get_vpd_page(sdev, 0x89, buffer, vpd_buf_len))
3010+ rcu_read_lock();
3011+ vpd = rcu_dereference(sdev->vpd_pg89);
3012+ if (vpd)
30073013 sdev->no_write_same = 1;
3014+ rcu_read_unlock();
30083015 }
30093016
30103017 if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, WRITE_SAME_16) == 1)
@@ -3108,6 +3115,29 @@ out: · 97 unmodified lines
31083115 kfree(buffer);
31093116 }
31103117
3118+static bool sd_validate_min_xfer_size(struct scsi_disk *sdkp)
3119+{
3120+ struct scsi_device *sdp = sdkp->device;
3121+ unsigned int min_xfer_bytes =
3122+ logical_to_bytes(sdp, sdkp->min_xfer_blocks);
3123+
3124+ if (sdkp->min_xfer_blocks == 0)
3125+ return false;
3126+
3127+ if (min_xfer_bytes & (sdkp->physical_block_size - 1)) {
3128+ sd_first_printk(KERN_WARNING, sdkp,
3129+ "Preferred minimum I/O size %u bytes not a " \
3130+ "multiple of physical block size (%u bytes)\n",
3131+ min_xfer_bytes, sdkp->physical_block_size);
3132+ sdkp->min_xfer_blocks = 0;
3133+ return false;
3134+ }
3135+
3136+ sd_first_printk(KERN_INFO, sdkp, "Preferred minimum I/O size %u bytes\n",
3137+ min_xfer_bytes);
3138+ return true;
3139+}
3140+
31113141 /*
31123142 * Determine the device's preferred I/O size for reads and writes
31133143 * unless the reported value is unreasonably small, large, not a
@@ -3119,6 +3149,8 @@ static bool sd_validate_opt_xfer_size(struct scsi_disk *sdkp, · 5 unmodified lines
31193149 struct scsi_device *sdp = sdkp->device;
31203150 unsigned int opt_xfer_bytes =
31213151 logical_to_bytes(sdp, sdkp->opt_xfer_blocks);
3152+ unsigned int min_xfer_bytes =
3153+ logical_to_bytes(sdp, sdkp->min_xfer_blocks);
31223154
31233155 if (sdkp->opt_xfer_blocks == 0)
31243156 return false;
@@ -3147,6 +3179,15 @@ static bool sd_validate_opt_xfer_size(struct scsi_disk *sdkp, · 22 unmodified lines
31473179 return false;
31483180 }
31493181
3182+ if (min_xfer_bytes && opt_xfer_bytes % min_xfer_bytes) {
3183+ sd_first_printk(KERN_WARNING, sdkp,
3184+ "Optimal transfer size %u bytes not a " \
3185+ "multiple of preferred minimum block " \
3186+ "size (%u bytes)\n",
3187+ opt_xfer_bytes, min_xfer_bytes);
3188+ return false;
3189+ }
3190+
31503191 if (opt_xfer_bytes & (sdkp->physical_block_size - 1)) {
31513192 sd_first_printk(KERN_WARNING, sdkp,
31523193 "Optimal transfer size %u bytes not a " \
@@ -3224,6 +3265,7 @@ static int sd_revalidate_disk(struct gendisk *disk) · 71 unmodified lines
32243265 sd_read_app_tag_own(sdkp, buffer);
32253266 sd_read_write_same(sdkp, buffer);
32263267 sd_read_security(sdkp, buffer);
3268+ sd_config_protection(sdkp);
32273269 }
32283270
32293271 /*
@@ -3239,6 +3281,12 @@ static int sd_revalidate_disk(struct gendisk *disk) · 9 unmodified lines
32393281 dev_max = min_not_zero(dev_max, sdkp->max_xfer_blocks);
32403282 q->limits.max_dev_sectors = logical_to_sectors(sdp, dev_max);
32413283
3284+ if (sd_validate_min_xfer_size(sdkp))
3285+ blk_queue_io_min(sdkp->disk->queue,
3286+ logical_to_bytes(sdp, sdkp->min_xfer_blocks));
3287+ else
3288+ blk_queue_io_min(sdkp->disk->queue, 0);
3289+
32423290 if (sd_validate_opt_xfer_size(sdkp, dev_max)) {
32433291 q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks);
32443292 rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
@@ -3477,11 +3525,6 @@ static int sd_probe(struct device *dev) · 232 unmodified lines
34773525 goto out;
34783526 }
34793527
3480− if (sdkp->capacity)
3481− sd_dif_config_host(sdkp);
3482−
3483− sd_revalidate_disk(gd);
3484−
34853528 if (sdkp->security) {
34863529 sdkp->opal_dev = init_opal_dev(sdkp, &sd_sec_submit);
34873530 if (sdkp->opal_dev)
drivers/scsi/sd.h+26−7
@@ -67,6 +67,20 @@ enum { · 66 unmodified lines
6767 SD_ZERO_WS10_UNMAP, /* Use WRITE SAME(10) with UNMAP */
6868 };
6969
70+/**
71+ * struct zoned_disk_info - Specific properties of a ZBC SCSI device.
72+ * @nr_zones: number of zones.
73+ * @zone_blocks: number of logical blocks per zone.
74+ *
75+ * This data structure holds the ZBC SCSI device properties that are retrieved
76+ * twice: a first time before the gendisk capacity is known and a second time
77+ * after the gendisk capacity is known.
78+ */
79+struct zoned_disk_info {
80+ u32 nr_zones;
81+ u32 zone_blocks;
82+};
83+
7084 struct scsi_disk {
7185 struct scsi_device *device;
7286
@@ -78,13 +92,18 @@ struct scsi_disk { · 5 unmodified lines
7892 struct gendisk *disk;
7993 struct opal_dev *opal_dev;
8094 #ifdef CONFIG_BLK_DEV_ZONED
81− u32 nr_zones;
82− u32 rev_nr_zones;
83− u32 zone_blocks;
84− u32 rev_zone_blocks;
95+ /* Updated during revalidation before the gendisk capacity is known. */
96+ struct zoned_disk_info early_zone_info;
97+ /* Updated during revalidation after the gendisk capacity is known. */
98+ struct zoned_disk_info zone_info;
8599 u32 zones_optimal_open;
86100 u32 zones_optimal_nonseq;
87101 u32 zones_max_open;
102+ /*
103+ * Either zero or a power of two. If not zero it means that the offset
104+ * between zone starting LBAs is constant.
105+ */
106+ u32 zone_starting_lba_gran;
88107 u32 *zones_wp_offset;
89108 spinlock_t zones_wp_offset_lock;
90109 u32 *rev_wp_offset;
@@ -95,6 +114,7 @@ struct scsi_disk { · 4 unmodified lines
95114 atomic_t openers;
96115 sector_t capacity; /* size in logical blocks */
97116 int max_retries;
117+ u32 min_xfer_blocks;
98118 u32 max_xfer_blocks;
99119 u32 opt_xfer_blocks;
100120 u32 max_ws_blocks;
@@ -222,7 +242,7 @@ static inline int sd_is_zoned(struct scsi_disk *sdkp) · 121 unmodified lines
222242 #ifdef CONFIG_BLK_DEV_ZONED
223243
224244 void sd_zbc_release_disk(struct scsi_disk *sdkp);
225−int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buffer);
245+int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE]);
226246 int sd_zbc_revalidate_zones(struct scsi_disk *sdkp);
227247 blk_status_t sd_zbc_setup_zone_mgmt_cmnd(struct scsi_cmnd *cmd,
228248 unsigned char op, bool all);
@@ -238,8 +258,7 @@ blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba, · 9 unmodified lines
238258
239259 static inline void sd_zbc_release_disk(struct scsi_disk *sdkp) {}
240260
241−static inline int sd_zbc_read_zones(struct scsi_disk *sdkp,
242− unsigned char *buf)
261+static inline int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
243262 {
244263 return 0;
245264 }
drivers/scsi/sd_dif.c+3−5
@@ -59,8 +59,6 @@ void sd_dif_config_host(struct scsi_disk *sdkp) · 58 unmodified lines
5959 bi.profile = &t10_pi_type1_crc;
6060
6161 bi.tuple_size = sizeof(struct t10_pi_tuple);
62− sd_printk(KERN_NOTICE, sdkp,
63− "Enabling DIX %s protection\n", bi.profile->name);
6462
6563 if (dif && type) {
6664 bi.flags |= BLK_INTEGRITY_DEVICE_CAPABLE;
@@ -72,11 +70,11 @@ void sd_dif_config_host(struct scsi_disk *sdkp) · 5 unmodified lines
7270 bi.tag_size = sizeof(u16) + sizeof(u32);
7371 else
7472 bi.tag_size = sizeof(u16);
75−
76− sd_printk(KERN_NOTICE, sdkp, "DIF application tag size %u\n",
77− bi.tag_size);
7873 }
7974
75+ sd_printk(KERN_NOTICE, sdkp,
76+ "Enabling DIX %s, application tag size %u bytes\n",
77+ bi.profile->name, bi.tag_size);
8078 out:
8179 blk_integrity_register(disk, &bi);
8280 }
drivers/scsi/sd_zbc.c+184−52
@@ -20,6 +20,12 @@ · 19 unmodified lines
2020
2121 #include "sd.h"
2222
23+/**
24+ * sd_zbc_get_zone_wp_offset - Get zone write pointer offset.
25+ * @zone: Zone for which to return the write pointer offset.
26+ *
27+ * Return: offset of the write pointer from the start of the zone.
28+ */
2329 static unsigned int sd_zbc_get_zone_wp_offset(struct blk_zone *zone)
2430 {
2531 if (zone->type == ZBC_ZONE_TYPE_CONV)
@@ -44,13 +50,37 @@ static unsigned int sd_zbc_get_zone_wp_offset(struct blk_zone *zone) · 18 unmodified lines
4450 }
4551 }
4652
47−static int sd_zbc_parse_report(struct scsi_disk *sdkp, u8 *buf,
53+/* Whether or not a SCSI zone descriptor describes a gap zone. */
54+static bool sd_zbc_is_gap_zone(const u8 buf[64])
55+{
56+ return (buf[0] & 0xf) == ZBC_ZONE_TYPE_GAP;
57+}
58+
59+/**
60+ * sd_zbc_parse_report - Parse a SCSI zone descriptor
61+ * @sdkp: SCSI disk pointer.
62+ * @buf: SCSI zone descriptor.
63+ * @idx: Index of the zone relative to the first zone reported by the current
64+ * sd_zbc_report_zones() call.
65+ * @cb: Callback function pointer.
66+ * @data: Second argument passed to @cb.
67+ *
68+ * Return: Value returned by @cb.
69+ *
70+ * Convert a SCSI zone descriptor into struct blk_zone format. Additionally,
71+ * call @cb(blk_zone, @data).
72+ */
73+static int sd_zbc_parse_report(struct scsi_disk *sdkp, const u8 buf[64],
4874 unsigned int idx, report_zones_cb cb, void *data)
4975 {
5076 struct scsi_device *sdp = sdkp->device;
5177 struct blk_zone zone = { 0 };
78+ sector_t start_lba, gran;
5279 int ret;
5380
81+ if (WARN_ON_ONCE(sd_zbc_is_gap_zone(buf)))
82+ return -EINVAL;
83+
5484 zone.type = buf[0] & 0x0f;
5585 zone.cond = (buf[1] >> 4) & 0xf;
5686 if (buf[1] & 0x01)
@@ -58,9 +88,27 @@ static int sd_zbc_parse_report(struct scsi_disk *sdkp, u8 *buf, · 1 unmodified line
5888 if (buf[1] & 0x02)
5989 zone.non_seq = 1;
6090
61− zone.len = logical_to_sectors(sdp, get_unaligned_be64(&buf[8]));
62− zone.capacity = zone.len;
63− zone.start = logical_to_sectors(sdp, get_unaligned_be64(&buf[16]));
91+ start_lba = get_unaligned_be64(&buf[16]);
92+ zone.start = logical_to_sectors(sdp, start_lba);
93+ zone.capacity = logical_to_sectors(sdp, get_unaligned_be64(&buf[8]));
94+ zone.len = zone.capacity;
95+ if (sdkp->zone_starting_lba_gran) {
96+ gran = logical_to_sectors(sdp, sdkp->zone_starting_lba_gran);
97+ if (zone.len > gran) {
98+ sd_printk(KERN_ERR, sdkp,
99+ "Invalid zone at LBA %llu with capacity %llu and length %llu; granularity = %llu\n",
100+ start_lba,
101+ sectors_to_logical(sdp, zone.capacity),
102+ sectors_to_logical(sdp, zone.len),
103+ sectors_to_logical(sdp, gran));
104+ return -EINVAL;
105+ }
106+ /*
107+ * Use the starting LBA granularity instead of the zone length
108+ * obtained from the REPORT ZONES command.
109+ */
110+ zone.len = gran;
111+ }
64112 if (zone.cond == ZBC_ZONE_COND_FULL)
65113 zone.wp = zone.start + zone.len;
66114 else
@@ -161,7 +209,7 @@ static void *sd_zbc_alloc_report_buffer(struct scsi_disk *sdkp, · 94 unmodified lines
161209 * sure that the allocated buffer can always be mapped by limiting the
162210 * number of pages allocated to the HBA max segments limit.
163211 */
164− nr_zones = min(nr_zones, sdkp->nr_zones);
212+ nr_zones = min(nr_zones, sdkp->zone_info.nr_zones);
165213 bufsize = roundup((nr_zones + 1) * 64, SECTOR_SIZE);
166214 bufsize = min_t(size_t, bufsize,
167215 queue_max_hw_sectors(q) << SECTOR_SHIFT);
@@ -186,16 +234,28 @@ static void *sd_zbc_alloc_report_buffer(struct scsi_disk *sdkp, · 18 unmodified lines
186234 */
187235 static inline sector_t sd_zbc_zone_sectors(struct scsi_disk *sdkp)
188236 {
189− return logical_to_sectors(sdkp->device, sdkp->zone_blocks);
237+ return logical_to_sectors(sdkp->device, sdkp->zone_info.zone_blocks);
190238 }
191239
240+/**
241+ * sd_zbc_report_zones - SCSI .report_zones() callback.
242+ * @disk: Disk to report zones for.
243+ * @sector: Start sector.
244+ * @nr_zones: Maximum number of zones to report.
245+ * @cb: Callback function called to report zone information.
246+ * @data: Second argument passed to @cb.
247+ *
248+ * Called by the block layer to iterate over zone information. See also the
249+ * disk->fops->report_zones() calls in block/blk-zoned.c.
250+ */
192251 int sd_zbc_report_zones(struct gendisk *disk, sector_t sector,
193252 unsigned int nr_zones, report_zones_cb cb, void *data)
194253 {
195254 struct scsi_disk *sdkp = scsi_disk(disk);
196− sector_t capacity = logical_to_sectors(sdkp->device, sdkp->capacity);
255+ sector_t lba = sectors_to_logical(sdkp->device, sector);
197256 unsigned int nr, i;
198257 unsigned char *buf;
258+ u64 zone_length, start_lba;
199259 size_t offset, buflen = 0;
200260 int zone_idx = 0;
201261 int ret;
@@ -204,7 +264,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, · 2 unmodified lines
204264 /* Not a zoned device */
205265 return -EOPNOTSUPP;
206266
207− if (!capacity)
267+ if (!sdkp->capacity)
208268 /* Device gone or invalid */
209269 return -ENODEV;
210270
@@ -212,9 +272,8 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, · 1 unmodified line
212272 if (!buf)
213273 return -ENOMEM;
214274
215− while (zone_idx < nr_zones && sector < capacity) {
216− ret = sd_zbc_do_report_zones(sdkp, buf, buflen,
217− sectors_to_logical(sdkp->device, sector), true);
275+ while (zone_idx < nr_zones && lba < sdkp->capacity) {
276+ ret = sd_zbc_do_report_zones(sdkp, buf, buflen, lba, true);
218277 if (ret)
219278 goto out;
220279
@@ -225,14 +284,36 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, · 4 unmodified lines
225284
226285 for (i = 0; i < nr && zone_idx < nr_zones; i++) {
227286 offset += 64;
287+ start_lba = get_unaligned_be64(&buf[offset + 16]);
288+ zone_length = get_unaligned_be64(&buf[offset + 8]);
289+ if ((zone_idx == 0 &&
290+ (lba < start_lba ||
291+ lba >= start_lba + zone_length)) ||
292+ (zone_idx > 0 && start_lba != lba) ||
293+ start_lba + zone_length < start_lba) {
294+ sd_printk(KERN_ERR, sdkp,
295+ "Zone %d at LBA %llu is invalid: %llu + %llu\n",
296+ zone_idx, lba, start_lba, zone_length);
297+ ret = -EINVAL;
298+ goto out;
299+ }
300+ lba = start_lba + zone_length;
301+ if (sd_zbc_is_gap_zone(&buf[offset])) {
302+ if (sdkp->zone_starting_lba_gran)
303+ continue;
304+ sd_printk(KERN_ERR, sdkp,
305+ "Gap zone without constant LBA offsets\n");
306+ ret = -EINVAL;
307+ goto out;
308+ }
309+
228310 ret = sd_zbc_parse_report(sdkp, buf + offset, zone_idx,
229311 cb, data);
230312 if (ret)
231313 goto out;
314+
232315 zone_idx++;
233316 }
234−
235− sector += sd_zbc_zone_sectors(sdkp) * i;
236317 }
237318
238319 ret = zone_idx;
@@ -276,6 +357,10 @@ static int sd_zbc_update_wp_offset_cb(struct blk_zone *zone, unsigned int idx, · 37 unmodified lines
276357 return 0;
277358 }
278359
360+/*
361+ * An attempt to append a zone triggered an invalid write pointer error.
362+ * Reread the write pointer of the zone(s) in which the append failed.
363+ */
279364 static void sd_zbc_update_wp_offset_workfn(struct work_struct *work)
280365 {
281366 struct scsi_disk *sdkp;
@@ -286,14 +371,14 @@ static void sd_zbc_update_wp_offset_workfn(struct work_struct *work) · 4 unmodified lines
286371 sdkp = container_of(work, struct scsi_disk, zone_wp_offset_work);
287372
288373 spin_lock_irqsave(&sdkp->zones_wp_offset_lock, flags);
289− for (zno = 0; zno < sdkp->nr_zones; zno++) {
374+ for (zno = 0; zno < sdkp->zone_info.nr_zones; zno++) {
290375 if (sdkp->zones_wp_offset[zno] != SD_ZBC_UPDATING_WP_OFST)
291376 continue;
292377
293378 spin_unlock_irqrestore(&sdkp->zones_wp_offset_lock, flags);
294379 ret = sd_zbc_do_report_zones(sdkp, sdkp->zone_wp_update_buf,
295380 SD_BUF_SIZE,
296− zno * sdkp->zone_blocks, true);
381+ zno * sdkp->zone_info.zone_blocks, true);
297382 spin_lock_irqsave(&sdkp->zones_wp_offset_lock, flags);
298383 if (!ret)
299384 sd_zbc_parse_report(sdkp, sdkp->zone_wp_update_buf + 64,
@@ -360,7 +445,7 @@ blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba, · 60 unmodified lines
360445 break;
361446 default:
362447 wp_offset = sectors_to_logical(sdkp->device, wp_offset);
363− if (wp_offset + nr_blocks > sdkp->zone_blocks) {
448+ if (wp_offset + nr_blocks > sdkp->zone_info.zone_blocks) {
364449 ret = BLK_STS_IOERR;
365450 break;
366451 }
@@ -489,7 +574,7 @@ static unsigned int sd_zbc_zone_wp_update(struct scsi_cmnd *cmd, · 122 unmodified lines
489574 break;
490575 case REQ_OP_ZONE_RESET_ALL:
491576 memset(sdkp->zones_wp_offset, 0,
492− sdkp->nr_zones * sizeof(unsigned int));
577+ sdkp->zone_info.nr_zones * sizeof(unsigned int));
493578 break;
494579 default:
495580 break;
@@ -545,6 +630,7 @@ unsigned int sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes, · 49 unmodified lines
545630 static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp,
546631 unsigned char *buf)
547632 {
633+ u64 zone_starting_lba_gran;
548634
549635 if (scsi_get_vpd_page(sdkp->device, 0xb6, buf, 64)) {
550636 sd_printk(KERN_NOTICE, sdkp,
@@ -558,12 +644,36 @@ static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp, · 7 unmodified lines
558644 sdkp->zones_optimal_open = get_unaligned_be32(&buf[8]);
559645 sdkp->zones_optimal_nonseq = get_unaligned_be32(&buf[12]);
560646 sdkp->zones_max_open = 0;
561− } else {
562− /* Host-managed */
563− sdkp->urswrz = buf[4] & 1;
564− sdkp->zones_optimal_open = 0;
565− sdkp->zones_optimal_nonseq = 0;
566− sdkp->zones_max_open = get_unaligned_be32(&buf[16]);
647+ return 0;
648+ }
649+
650+ /* Host-managed */
651+ sdkp->urswrz = buf[4] & 1;
652+ sdkp->zones_optimal_open = 0;
653+ sdkp->zones_optimal_nonseq = 0;
654+ sdkp->zones_max_open = get_unaligned_be32(&buf[16]);
655+ /* Check zone alignment method */
656+ switch (buf[23] & 0xf) {
657+ case 0:
658+ case ZBC_CONSTANT_ZONE_LENGTH:
659+ /* Use zone length */
660+ break;
661+ case ZBC_CONSTANT_ZONE_START_OFFSET:
662+ zone_starting_lba_gran = get_unaligned_be64(&buf[24]);
663+ if (zone_starting_lba_gran == 0 ||
664+ !is_power_of_2(zone_starting_lba_gran) ||
665+ logical_to_sectors(sdkp->device, zone_starting_lba_gran) >
666+ UINT_MAX) {
667+ sd_printk(KERN_ERR, sdkp,
668+ "Invalid zone starting LBA granularity %llu\n",
669+ zone_starting_lba_gran);
670+ return -ENODEV;
671+ }
672+ sdkp->zone_starting_lba_gran = zone_starting_lba_gran;
673+ break;
674+ default:
675+ sd_printk(KERN_ERR, sdkp, "Invalid zone alignment method\n");
676+ return -ENODEV;
567677 }
568678
569679 /*
@@ -585,7 +695,7 @@ static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp, · 15 unmodified lines
585695 * sd_zbc_check_capacity - Check the device capacity
586696 * @sdkp: Target disk
587697 * @buf: command buffer
588− * @zblocks: zone size in number of blocks
698+ * @zblocks: zone size in logical blocks
589699 *
590700 * Get the device zone size and check that the device capacity as reported
591701 * by READ CAPACITY matches the max_lba value (plus one) of the report zones
@@ -619,14 +729,25 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf, · 27 unmodified lines
619729 }
620730 }
621731
622− /* Get the size of the first reported zone */
623− rec = buf + 64;
624− zone_blocks = get_unaligned_be64(&rec[8]);
625− if (logical_to_sectors(sdkp->device, zone_blocks) > UINT_MAX) {
626− if (sdkp->first_scan)
627− sd_printk(KERN_NOTICE, sdkp,
628− "Zone size too large\n");
629− return -EFBIG;
732+ if (sdkp->zone_starting_lba_gran == 0) {
733+ /* Get the size of the first reported zone */
734+ rec = buf + 64;
735+ zone_blocks = get_unaligned_be64(&rec[8]);
736+ if (logical_to_sectors(sdkp->device, zone_blocks) > UINT_MAX) {
737+ if (sdkp->first_scan)
738+ sd_printk(KERN_NOTICE, sdkp,
739+ "Zone size too large\n");
740+ return -EFBIG;
741+ }
742+ } else {
743+ zone_blocks = sdkp->zone_starting_lba_gran;
744+ }
745+
746+ if (!is_power_of_2(zone_blocks)) {
747+ sd_printk(KERN_ERR, sdkp,
748+ "Zone size %llu is not a power of two.\n",
749+ zone_blocks);
750+ return -EINVAL;
630751 }
631752
632753 *zblocks = zone_blocks;
@@ -639,16 +760,16 @@ static void sd_zbc_print_zones(struct scsi_disk *sdkp) · 6 unmodified lines
639760 if (!sd_is_zoned(sdkp) || !sdkp->capacity)
640761 return;
641762
642− if (sdkp->capacity & (sdkp->zone_blocks - 1))
763+ if (sdkp->capacity & (sdkp->zone_info.zone_blocks - 1))
643764 sd_printk(KERN_NOTICE, sdkp,
644765 "%u zones of %u logical blocks + 1 runt zone\n",
645− sdkp->nr_zones - 1,
646− sdkp->zone_blocks);
766+ sdkp->zone_info.nr_zones - 1,
767+ sdkp->zone_info.zone_blocks);
647768 else
648769 sd_printk(KERN_NOTICE, sdkp,
649770 "%u zones of %u logical blocks\n",
650− sdkp->nr_zones,
651− sdkp->zone_blocks);
771+ sdkp->zone_info.nr_zones,
772+ sdkp->zone_info.zone_blocks);
652773 }
653774
654775 static int sd_zbc_init_disk(struct scsi_disk *sdkp)
@@ -675,10 +796,8 @@ static void sd_zbc_clear_zone_info(struct scsi_disk *sdkp) · 20 unmodified lines
675796 kfree(sdkp->zone_wp_update_buf);
676797 sdkp->zone_wp_update_buf = NULL;
677798
678− sdkp->nr_zones = 0;
679− sdkp->rev_nr_zones = 0;
680− sdkp->zone_blocks = 0;
681− sdkp->rev_zone_blocks = 0;
799+ sdkp->early_zone_info = (struct zoned_disk_info){ };
800+ sdkp->zone_info = (struct zoned_disk_info){ };
682801
683802 mutex_unlock(&sdkp->rev_mutex);
684803 }
@@ -696,12 +815,17 @@ static void sd_zbc_revalidate_zones_cb(struct gendisk *disk) · 11 unmodified lines
696815 swap(sdkp->zones_wp_offset, sdkp->rev_wp_offset);
697816 }
698817
818+/*
819+ * Call blk_revalidate_disk_zones() if any of the zoned disk properties have
820+ * changed that make it necessary to call that function. Called by
821+ * sd_revalidate_disk() after the gendisk capacity has been set.
822+ */
699823 int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)
700824 {
701825 struct gendisk *disk = sdkp->disk;
702826 struct request_queue *q = disk->queue;
703− u32 zone_blocks = sdkp->rev_zone_blocks;
704− unsigned int nr_zones = sdkp->rev_nr_zones;
827+ u32 zone_blocks = sdkp->early_zone_info.zone_blocks;
828+ unsigned int nr_zones = sdkp->early_zone_info.nr_zones;
705829 u32 max_append;
706830 int ret = 0;
707831 unsigned int flags;
@@ -732,14 +856,14 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp) · 24 unmodified lines
732856 */
733857 mutex_lock(&sdkp->rev_mutex);
734858
735− if (sdkp->zone_blocks == zone_blocks &&
736− sdkp->nr_zones == nr_zones &&
859+ if (sdkp->zone_info.zone_blocks == zone_blocks &&
860+ sdkp->zone_info.nr_zones == nr_zones &&
737861 disk->queue->nr_zones == nr_zones)
738862 goto unlock;
739863
740864 flags = memalloc_noio_save();
741− sdkp->zone_blocks = zone_blocks;
742− sdkp->nr_zones = nr_zones;
865+ sdkp->zone_info.zone_blocks = zone_blocks;
866+ sdkp->zone_info.nr_zones = nr_zones;
743867 sdkp->rev_wp_offset = kvcalloc(nr_zones, sizeof(u32), GFP_KERNEL);
744868 if (!sdkp->rev_wp_offset) {
745869 ret = -ENOMEM;
@@ -754,8 +878,7 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp) · 8 unmodified lines
754878 sdkp->rev_wp_offset = NULL;
755879
756880 if (ret) {
757− sdkp->zone_blocks = 0;
758− sdkp->nr_zones = 0;
881+ sdkp->zone_info = (struct zoned_disk_info){ };
759882 sdkp->capacity = 0;
760883 goto unlock;
761884 }
@@ -774,7 +897,16 @@ unlock: · 12 unmodified lines
774897 return ret;
775898 }
776899
777−int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)
900+/**
901+ * sd_zbc_read_zones - Read zone information and update the request queue
902+ * @sdkp: SCSI disk pointer.
903+ * @buf: 512 byte buffer used for storing SCSI command output.
904+ *
905+ * Read zone information and update the request queue zone characteristics and
906+ * also the zoned device information in *sdkp. Called by sd_revalidate_disk()
907+ * before the gendisk capacity has been set.
908+ */
909+int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
778910 {
779911 struct gendisk *disk = sdkp->disk;
780912 struct request_queue *q = disk->queue;
@@ -832,8 +964,8 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf) · 51 unmodified lines
832964 if (blk_queue_zoned_model(q) == BLK_ZONED_HM)
833965 blk_queue_zone_write_granularity(q, sdkp->physical_block_size);
834966
835− sdkp->rev_nr_zones = nr_zones;
836− sdkp->rev_zone_blocks = zone_blocks;
967+ sdkp->early_zone_info.nr_zones = nr_zones;
968+ sdkp->early_zone_info.zone_blocks = zone_blocks;
837969
838970 return 0;
839971
drivers/scsi/sr.c+8−6
@@ -113,7 +113,7 @@ static int sr_open(struct cdrom_device_info *, int); · 112 unmodified lines
113113 static void sr_release(struct cdrom_device_info *);
114114
115115 static void get_sectorsize(struct scsi_cd *);
116−static void get_capabilities(struct scsi_cd *);
116+static int get_capabilities(struct scsi_cd *);
117117
118118 static unsigned int sr_check_events(struct cdrom_device_info *cdi,
119119 unsigned int clearing, int slot);
@@ -669,8 +669,9 @@ static int sr_probe(struct device *dev) · 549 unmodified lines
669669
670670 sdev->sector_size = 2048; /* A guess, just in case */
671671
672− /* FIXME: need to handle a get_capabilities failure properly ?? */
673− get_capabilities(cd);
672+ error = -ENOMEM;
673+ if (get_capabilities(cd))
674+ goto fail_minor;
674675 sr_vendor_init(cd);
675676
676677 set_capacity(disk, cd->capacity);
@@ -794,7 +795,7 @@ static void get_sectorsize(struct scsi_cd *cd) · 117 unmodified lines
794795 return;
795796 }
796797
797−static void get_capabilities(struct scsi_cd *cd)
798+static int get_capabilities(struct scsi_cd *cd)
798799 {
799800 unsigned char *buffer;
800801 struct scsi_mode_data data;
@@ -819,7 +820,7 @@ static void get_capabilities(struct scsi_cd *cd) · 18 unmodified lines
819820 buffer = kmalloc(512, GFP_KERNEL);
820821 if (!buffer) {
821822 sr_printk(KERN_ERR, cd, "out of memory.\n");
822− return;
823+ return -ENOMEM;
823824 }
824825
825826 /* eat unit attentions */
@@ -839,7 +840,7 @@ static void get_capabilities(struct scsi_cd *cd) · 13 unmodified lines
839840 CDC_MRW | CDC_MRW_W | CDC_RAM);
840841 kfree(buffer);
841842 sr_printk(KERN_INFO, cd, "scsi-1 drive");
842− return;
843+ return 0;
843844 }
844845
845846 n = data.header_length + data.block_descriptor_length;
@@ -898,6 +899,7 @@ static void get_capabilities(struct scsi_cd *cd) · 52 unmodified lines
898899 }
899900
900901 kfree(buffer);
902+ return 0;
901903 }
902904
903905 /*
drivers/scsi/ufs/Kconfig+1−25
@@ -1,36 +1,12 @@
1+# SPDX-License-Identifier: GPL-2.0+
12 #
23 # Kernel configuration file for the UFS Host Controller
34 #
4−# This code is based on drivers/scsi/ufs/Kconfig
55 # Copyright (C) 2011-2013 Samsung India Software Operations
66 #
77 # Authors:
88 # Santosh Yaraganavi <santosh.sy@samsung.com>
99 # Vinayak Holikatti <h.vinayak@samsung.com>
10−#
11−# This program is free software; you can redistribute it and/or
12−# modify it under the terms of the GNU General Public License
13−# as published by the Free Software Foundation; either version 2
14−# of the License, or (at your option) any later version.
15−# See the COPYING file in the top-level directory or visit
16−# <http://www.gnu.org/licenses/gpl-2.0.html>
17−#
18−# This program is distributed in the hope that it will be useful,
19−# but WITHOUT ANY WARRANTY; without even the implied warranty of
20−# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21−# GNU General Public License for more details.
22−#
23−# This program is provided "AS IS" and "WITH ALL FAULTS" and
24−# without warranty of any kind. You are solely responsible for
25−# determining the appropriateness of using and distributing
26−# the program and assume all risks associated with your exercise
27−# of rights with respect to the program, including but not limited
28−# to infringement of third party rights, the risks and costs of
29−# program errors, damage to or loss of data, programs or equipment,
30−# and unavailability or interruption of operations. Under no
31−# circumstances will the contributor of this Program be liable for
32−# any damages of any kind arising from your use or distribution of
33−# this program.
3410
3511 config SCSI_UFSHCD
3612 tristate "Universal Flash Storage Controller Driver Core"
drivers/scsi/ufs/cdns-pltfrm.c+1−1
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 *
1010 */
1111
12+#include <linux/clk.h>
1213 #include <linux/kernel.h>
1314 #include <linux/module.h>
1415 #include <linux/platform_device.h>
@@ -340,4 +341,3 @@ module_platform_driver(cdns_ufs_pltfrm_driver); · 325 unmodified lines
340341 MODULE_AUTHOR("Jan Kotas <jank@cadence.com>");
341342 MODULE_DESCRIPTION("Cadence UFS host controller platform driver");
342343 MODULE_LICENSE("GPL v2");
343−MODULE_VERSION(UFSHCD_DRIVER_VERSION);
drivers/scsi/ufs/tc-dwc-g210-pci.c+1−0
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111 #include "ufshcd-dwc.h"
1212 #include "tc-dwc-g210.h"
1313
14+#include <linux/module.h>
1415 #include <linux/pci.h>
1516 #include <linux/pm_runtime.h>
1617
drivers/scsi/ufs/tc-dwc-g210-pltfrm.c+1−0
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 #include <linux/platform_device.h>
1313 #include <linux/of.h>
1414 #include <linux/delay.h>
15+#include <linux/pm_runtime.h>
1516
1617 #include "ufshcd-pltfrm.h"
1718 #include "ufshcd-dwc.h"
drivers/scsi/ufs/tc-dwc-g210.c+2−0
@@ -7,6 +7,8 @@ · 6 unmodified lines
77 * Authors: Joao Pinto <jpinto@synopsys.com>
88 */
99
10+#include <linux/module.h>
11+
1012 #include "ufshcd.h"
1113 #include "unipro.h"
1214
drivers/scsi/ufs/tc-dwc-g210.h+2−0
@@ -10,6 +10,8 @@ · 9 unmodified lines
1010 #ifndef _TC_DWC_G210_H
1111 #define _TC_DWC_G210_H
1212
13+struct ufs_hba;
14+
1315 int tc_dwc_g210_config_40_bit(struct ufs_hba *hba);
1416 int tc_dwc_g210_config_20_bit(struct ufs_hba *hba);
1517
drivers/scsi/ufs/ti-j721e-ufs.c+2−4
@@ -29,11 +29,9 @@ static int ti_j721e_ufs_probe(struct platform_device *pdev) · 28 unmodified lines
2929 return PTR_ERR(regbase);
3030
3131 pm_runtime_enable(dev);
32− ret = pm_runtime_get_sync(dev);
33− if (ret < 0) {
34− pm_runtime_put_noidle(dev);
32+ ret = pm_runtime_resume_and_get(dev);
33+ if (ret < 0)
3534 goto disable_pm;
36− }
3735
3836 /* Select MPHY refclk frequency */
3937 clk = devm_clk_get(dev, NULL);
drivers/scsi/ufs/ufs-debugfs.c+1−0
@@ -5,6 +5,7 @@ · 4 unmodified lines
55
66 #include "ufs-debugfs.h"
77 #include "ufshcd.h"
8+#include "ufshcd-priv.h"
89
910 static struct dentry *ufs_debugfs_root;
1011
drivers/scsi/ufs/ufs-exynos.c+3−2
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 */
1010
1111 #include <linux/clk.h>
12+#include <linux/delay.h>
1213 #include <linux/module.h>
1314 #include <linux/of.h>
1415 #include <linux/of_address.h>
@@ -704,7 +705,7 @@ static void exynos_ufs_establish_connt(struct exynos_ufs *ufs) · 689 unmodified lines
704705
705706 /* local unipro attributes */
706707 ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID), DEV_ID);
707− ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID_VALID), TRUE);
708+ ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID_VALID), true);
708709 ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERDEVICEID), PEER_DEV_ID);
709710 ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERCPORTID), PEER_CPORT_ID);
710711 ufshcd_dme_set(hba, UIC_ARG_MIB(T_CPORTFLAGS), CPORT_DEF_FLAGS);
@@ -1028,7 +1029,7 @@ static int exynos_ufs_post_link(struct ufs_hba *hba) · 317 unmodified lines
10281029
10291030 if (ufs->opts & EXYNOS_UFS_OPT_SKIP_CONNECTION_ESTAB)
10301031 ufshcd_dme_set(hba,
1031− UIC_ARG_MIB(T_DBG_SKIP_INIT_HIBERN8_EXIT), TRUE);
1032+ UIC_ARG_MIB(T_DBG_SKIP_INIT_HIBERN8_EXIT), true);
10321033
10331034 if (attr->pa_granularity) {
10341035 exynos_ufs_enable_dbg_mode(hba);
drivers/scsi/ufs/ufs-exynos.h+4−4
@@ -248,22 +248,22 @@ long exynos_ufs_calc_time_cntr(struct exynos_ufs *, long); · 247 unmodified lines
248248
249249 static inline void exynos_ufs_enable_ov_tm(struct ufs_hba *hba)
250250 {
251− ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), TRUE);
251+ ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), true);
252252 }
253253
254254 static inline void exynos_ufs_disable_ov_tm(struct ufs_hba *hba)
255255 {
256− ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), FALSE);
256+ ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), false);
257257 }
258258
259259 static inline void exynos_ufs_enable_dbg_mode(struct ufs_hba *hba)
260260 {
261− ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), TRUE);
261+ ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), true);
262262 }
263263
264264 static inline void exynos_ufs_disable_dbg_mode(struct ufs_hba *hba)
265265 {
266− ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), FALSE);
266+ ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), false);
267267 }
268268
269269 #endif /* _UFS_EXYNOS_H_ */
drivers/scsi/ufs/ufs-hisi.c+2−0
@@ -7,6 +7,8 @@ · 6 unmodified lines
77 */
88
99 #include <linux/time.h>
10+#include <linux/delay.h>
11+#include <linux/module.h>
1012 #include <linux/of.h>
1113 #include <linux/of_address.h>
1214 #include <linux/dma-mapping.h>
drivers/scsi/ufs/ufs-hwmon.c+1−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 #include <linux/units.h>
99
1010 #include "ufshcd.h"
11+#include "ufshcd-priv.h"
1112
1213 struct ufs_hwmon_data {
1314 struct ufs_hba *hba;
drivers/scsi/ufs/ufs-mediatek.c+12−19
@@ -8,6 +8,9 @@ · 7 unmodified lines
88
99 #include <linux/arm-smccc.h>
1010 #include <linux/bitfield.h>
11+#include <linux/clk.h>
12+#include <linux/delay.h>
13+#include <linux/module.h>
1114 #include <linux/of.h>
1215 #include <linux/of_address.h>
1316 #include <linux/of_device.h>
@@ -19,7 +22,6 @@ · 5 unmodified lines
1922 #include <linux/soc/mediatek/mtk_sip_svc.h>
2023
2124 #include "ufshcd.h"
22−#include "ufshcd-crypto.h"
2325 #include "ufshcd-pltfrm.h"
2426 #include "ufs_quirks.h"
2527 #include "unipro.h"
@@ -44,12 +46,14 @@ · 18 unmodified lines
4446 #define ufs_mtk_device_reset_ctrl(high, res) \
4547 ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, high, res)
4648
47−static struct ufs_dev_fix ufs_mtk_dev_fixups[] = {
48− UFS_FIX(UFS_VENDOR_MICRON, UFS_ANY_MODEL,
49− UFS_DEVICE_QUIRK_DELAY_AFTER_LPM),
50− UFS_FIX(UFS_VENDOR_SKHYNIX, "H9HQ21AFAMZDAR",
51− UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES),
52− END_FIX
49+static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] = {
50+ { .wmanufacturerid = UFS_VENDOR_MICRON,
51+ .model = UFS_ANY_MODEL,
52+ .quirk = UFS_DEVICE_QUIRK_DELAY_AFTER_LPM },
53+ { .wmanufacturerid = UFS_VENDOR_SKHYNIX,
54+ .model = "H9HQ21AFAMZDAR",
55+ .quirk = UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES },
56+ {}
5357 };
5458
5559 static const struct of_device_id ufs_mtk_of_match[] = {
@@ -169,7 +173,6 @@ static int ufs_mtk_hce_enable_notify(struct ufs_hba *hba, · 113 unmodified lines
169173 enum ufs_notify_change_status status)
170174 {
171175 struct ufs_mtk_host *host = ufshcd_get_variant(hba);
172− unsigned long flags;
173176
174177 if (status == PRE_CHANGE) {
175178 if (host->unipro_lpm) {
@@ -183,12 +186,8 @@ static int ufs_mtk_hce_enable_notify(struct ufs_hba *hba, · 7 unmodified lines
183186 ufs_mtk_crypto_enable(hba);
184187
185188 if (host->caps & UFS_MTK_CAP_DISABLE_AH8) {
186− spin_lock_irqsave(hba->host->host_lock, flags);
187189 ufshcd_writel(hba, 0,
188190 REG_AUTO_HIBERNATE_IDLE_TIMER);
189− spin_unlock_irqrestore(hba->host->host_lock,
190− flags);
191−
192191 hba->capabilities &= ~MASK_AUTO_HIBERN8_SUPPORT;
193192 hba->ahit = 0;
194193 }
@@ -860,7 +859,6 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba) · 665 unmodified lines
860859
861860 static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba)
862861 {
863− unsigned long flags;
864862 u32 ah_ms;
865863
866864 if (ufshcd_is_clkgating_allowed(hba)) {
@@ -869,9 +867,7 @@ static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba) · 2 unmodified lines
869867 hba->ahit);
870868 else
871869 ah_ms = 10;
872− spin_lock_irqsave(hba->host->host_lock, flags);
873− hba->clk_gating.delay_ms = ah_ms + 5;
874− spin_unlock_irqrestore(hba->host->host_lock, flags);
870+ ufshcd_clkgate_delay_set(hba->dev, ah_ms + 5);
875871 }
876872 }
877873
@@ -992,13 +988,10 @@ static void ufs_mtk_vreg_set_lpm(struct ufs_hba *hba, bool lpm) · 114 unmodified lines
992988
993989 static void ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
994990 {
995− unsigned long flags;
996991 int ret;
997992
998993 /* disable auto-hibern8 */
999− spin_lock_irqsave(hba->host->host_lock, flags);
1000994 ufshcd_writel(hba, 0, REG_AUTO_HIBERNATE_IDLE_TIMER);
1001− spin_unlock_irqrestore(hba->host->host_lock, flags);
1002995
1003996 /* wait host return to idle state when auto-hibern8 off */
1004997 ufs_mtk_wait_idle_state(hba, 5);
drivers/scsi/ufs/ufs-qcom-ice.c+1−1
@@ -6,10 +6,10 @@ · 5 unmodified lines
66 * Copyright 2019 Google LLC
77 */
88
9+#include <linux/delay.h>
910 #include <linux/platform_device.h>
1011 #include <linux/qcom_scm.h>
1112
12−#include "ufshcd-crypto.h"
1313 #include "ufs-qcom.h"
1414
1515 #define AES_256_XTS_KEY_SIZE 64
drivers/scsi/ufs/ufs-qcom.c+25−48
@@ -5,6 +5,9 @@ · 4 unmodified lines
55
66 #include <linux/acpi.h>
77 #include <linux/time.h>
8+#include <linux/clk.h>
9+#include <linux/delay.h>
10+#include <linux/module.h>
811 #include <linux/of.h>
912 #include <linux/platform_device.h>
1013 #include <linux/phy/phy.h>
@@ -18,6 +21,7 @@ · 7 unmodified lines
1821 #include "ufs-qcom.h"
1922 #include "ufshci.h"
2023 #include "ufs_quirks.h"
24+
2125 #define UFS_QCOM_DEFAULT_DBG_PRINT_EN \
2226 (UFS_QCOM_DBG_PRINT_REGS_EN | UFS_QCOM_DBG_PRINT_TEST_BUS_EN)
2327
@@ -299,8 +303,7 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba) · 275 unmodified lines
299303 struct ufs_qcom_host *host = ufshcd_get_variant(hba);
300304 struct phy *phy = host->generic_phy;
301305 int ret = 0;
302− bool is_rate_B = (UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B)
303− ? true : false;
306+ bool is_rate_B = UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B;
304307
305308 /* Reset UFS Host Controller and PHY */
306309 ret = ufs_qcom_host_reset(hba);
@@ -641,12 +644,7 @@ static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) · 334 unmodified lines
641644 return err;
642645 }
643646
644− err = ufs_qcom_ice_resume(host);
645− if (err)
646− return err;
647−
648− hba->is_sys_suspended = false;
649− return 0;
647+ return ufs_qcom_ice_resume(host);
650648 }
651649
652650 static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool enable)
@@ -687,8 +685,11 @@ static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool enable) · 34 unmodified lines
687685
688686 writel_relaxed(temp, host->dev_ref_clk_ctrl_mmio);
689687
690− /* ensure that ref_clk is enabled/disabled before we return */
691− wmb();
688+ /*
689+ * Make sure the write to ref_clk reaches the destination and
690+ * not stored in a Write Buffer (WB).
691+ */
692+ readl(host->dev_ref_clk_ctrl_mmio);
692693
693694 /*
694695 * If we call hibern8 exit after this, we need to make sure that
@@ -873,6 +874,7 @@ static void ufs_qcom_set_caps(struct ufs_hba *hba) · 178 unmodified lines
873874 hba->caps |= UFSHCD_CAP_WB_EN;
874875 hba->caps |= UFSHCD_CAP_CRYPTO;
875876 hba->caps |= UFSHCD_CAP_AGGR_POWER_COLLAPSE;
877+ hba->caps |= UFSHCD_CAP_RPM_AUTOSUSPEND;
876878
877879 if (host->hw_ver.major >= 0x2) {
878880 host->caps = UFS_QCOM_CAP_QUNIPRO |
@@ -987,13 +989,12 @@ static int ufs_qcom_init(struct ufs_hba *hba) · 108 unmodified lines
987989 host->hba = hba;
988990 ufshcd_set_variant(hba, host);
989991
990− /* Setup the reset control of HCI */
991− host->core_reset = devm_reset_control_get(hba->dev, "rst");
992+ /* Setup the optional reset control of HCI */
993+ host->core_reset = devm_reset_control_get_optional(hba->dev, "rst");
992994 if (IS_ERR(host->core_reset)) {
993− err = PTR_ERR(host->core_reset);
994− dev_warn(dev, "Failed to get reset control %d\n", err);
995− host->core_reset = NULL;
996− err = 0;
995+ err = dev_err_probe(dev, PTR_ERR(host->core_reset),
996+ "Failed to get reset control\n");
997+ goto out_variant_clear;
997998 }
998999
9991000 /* Fire up the reset controller. Failure here is non-fatal. */
@@ -1007,28 +1008,10 @@ static int ufs_qcom_init(struct ufs_hba *hba) · 7 unmodified lines
10071008 err = 0;
10081009 }
10091010
1010− /*
1011− * voting/devoting device ref_clk source is time consuming hence
1012− * skip devoting it during aggressive clock gating. This clock
1013− * will still be gated off during runtime suspend.
1014− */
1015− host->generic_phy = devm_phy_get(dev, "ufsphy");
1016−
1017− if (host->generic_phy == ERR_PTR(-EPROBE_DEFER)) {
1018− /*
1019− * UFS driver might be probed before the phy driver does.
1020− * In that case we would like to return EPROBE_DEFER code.
1021− */
1022− err = -EPROBE_DEFER;
1023− dev_warn(dev, "%s: required phy device. hasn't probed yet. err = %d\n",
1024− __func__, err);
1025− goto out_variant_clear;
1026− } else if (IS_ERR(host->generic_phy)) {
1027− if (has_acpi_companion(dev)) {
1028− host->generic_phy = NULL;
1029− } else {
1030− err = PTR_ERR(host->generic_phy);
1031− dev_err(dev, "%s: PHY get failed %d\n", __func__, err);
1011+ if (!has_acpi_companion(dev)) {
1012+ host->generic_phy = devm_phy_get(dev, "ufsphy");
1013+ if (IS_ERR(host->generic_phy)) {
1014+ err = dev_err_probe(dev, PTR_ERR(host->generic_phy), "Failed to get PHY\n");
10321015 goto out_variant_clear;
10331016 }
10341017 }
@@ -1449,23 +1432,17 @@ static int ufs_qcom_device_reset(struct ufs_hba *hba) · 414 unmodified lines
14491432
14501433 #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
14511434 static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,
1452− struct devfreq_dev_profile *p,
1453− void *data)
1435+ struct devfreq_dev_profile *p,
1436+ struct devfreq_simple_ondemand_data *d)
14541437 {
1455− static struct devfreq_simple_ondemand_data *d;
1456−
1457− if (!data)
1458− return;
1459−
1460− d = (struct devfreq_simple_ondemand_data *)data;
14611438 p->polling_ms = 60;
14621439 d->upthreshold = 70;
14631440 d->downdifferential = 5;
14641441 }
14651442 #else
14661443 static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,
1467− struct devfreq_dev_profile *p,
1468− void *data)
1444+ struct devfreq_dev_profile *p,
1445+ struct devfreq_simple_ondemand_data *data)
14691446 {
14701447 }
14711448 #endif
drivers/scsi/ufs/ufs-qcom.h+2−4
@@ -7,6 +7,7 @@ · 6 unmodified lines
77
88 #include <linux/reset-controller.h>
99 #include <linux/reset.h>
10+#include "ufshcd.h"
1011
1112 #define MAX_UFS_QCOM_HOSTS 1
1213 #define MAX_U32 (~(u32)0)
@@ -239,10 +240,7 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host); · 226 unmodified lines
239240
240241 static inline bool ufs_qcom_cap_qunipro(struct ufs_qcom_host *host)
241242 {
242− if (host->caps & UFS_QCOM_CAP_QUNIPRO)
243− return true;
244− else
245− return false;
243+ return host->caps & UFS_QCOM_CAP_QUNIPRO;
246244 }
247245
248246 /* ufs-qcom-ice.c */
drivers/scsi/ufs/ufs-sysfs.c+1−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
88
99 #include "ufs.h"
1010 #include "ufs-sysfs.h"
11+#include "ufshcd-priv.h"
1112
1213 static const char *ufshcd_uic_link_state_to_string(
1314 enum uic_link_state state)
drivers/scsi/ufs/ufs-sysfs.h+2−1
@@ -7,11 +7,12 @@ · 6 unmodified lines
77
88 #include <linux/sysfs.h>
99
10−#include "ufshcd.h"
10+struct device;
1111
1212 void ufs_sysfs_add_nodes(struct device *dev);
1313 void ufs_sysfs_remove_nodes(struct device *dev);
1414
1515 extern const struct attribute_group ufs_sysfs_unit_descriptor_group;
1616 extern const struct attribute_group ufs_sysfs_lun_attributes_group;
17+
1718 #endif
drivers/scsi/ufs/ufs.h+0−35
@@ -415,11 +415,6 @@ enum ufs_ref_clk_freq { · 414 unmodified lines
415415 REF_CLK_FREQ_INVAL = -1,
416416 };
417417
418−struct ufs_ref_clk {
419− unsigned long freq_hz;
420− enum ufs_ref_clk_freq val;
421−};
422−
423418 /* Query response result code */
424419 enum {
425420 QUERY_RESULT_SUCCESS = 0x00,
@@ -562,15 +557,6 @@ struct ufs_query_res { · 136 unmodified lines
562557 struct utp_upiu_query upiu_res;
563558 };
564559
565−#define UFS_VREG_VCC_MIN_UV 2700000 /* uV */
566−#define UFS_VREG_VCC_MAX_UV 3600000 /* uV */
567−#define UFS_VREG_VCC_1P8_MIN_UV 1700000 /* uV */
568−#define UFS_VREG_VCC_1P8_MAX_UV 1950000 /* uV */
569−#define UFS_VREG_VCCQ_MIN_UV 1140000 /* uV */
570−#define UFS_VREG_VCCQ_MAX_UV 1260000 /* uV */
571−#define UFS_VREG_VCCQ2_MIN_UV 1700000 /* uV */
572−#define UFS_VREG_VCCQ2_MAX_UV 1950000 /* uV */
573−
574560 /*
575561 * VCCQ & VCCQ2 current requirement when UFS device is in sleep state
576562 * and link is in Hibern8 state.
@@ -582,8 +568,6 @@ struct ufs_vreg { · 5 unmodified lines
582568 const char *name;
583569 bool always_on;
584570 bool enabled;
585− int min_uV;
586− int max_uV;
587571 int max_uA;
588572 };
589573
@@ -636,23 +620,4 @@ enum ufs_trace_tsf_t { · 46 unmodified lines
636620 UFS_TSF_CDB, UFS_TSF_OSF, UFS_TSF_TM_INPUT, UFS_TSF_TM_OUTPUT
637621 };
638622
639−/**
640− * ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit descriptor
641− * @dev_info: pointer of instance of struct ufs_dev_info
642− * @lun: LU number to check
643− * @return: true if the lun has a matching unit descriptor, false otherwise
644− */
645−static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info,
646− u8 lun, u8 param_offset)
647−{
648− if (!dev_info || !dev_info->max_lu_supported) {
649− pr_err("Max General LU supported by UFS isn't initialized\n");
650− return false;
651− }
652− /* WB is available only for the logical unit from 0 to 7 */
653− if (param_offset == UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS)
654− return lun < UFS_UPIU_MAX_WB_LUN_ID;
655− return lun == UFS_UPIU_RPMB_WLUN || (lun < dev_info->max_lu_supported);
656−}
657−
658623 #endif /* End of Header */
drivers/scsi/ufs/ufs_bsg.c+6−0
@@ -4,7 +4,13 @@ · 3 unmodified lines
44 *
55 * Copyright (C) 2018 Western Digital Corporation
66 */
7+
8+#include <linux/bsg-lib.h>
9+#include <scsi/scsi.h>
10+#include <scsi/scsi_host.h>
711 #include "ufs_bsg.h"
12+#include "ufshcd.h"
13+#include "ufshcd-priv.h"
814
915 static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len,
1016 struct utp_upiu_query *qr)
drivers/scsi/ufs/ufs_bsg.h+1−6
@@ -5,12 +5,7 @@ · 4 unmodified lines
55 #ifndef UFS_BSG_H
66 #define UFS_BSG_H
77
8−#include <linux/bsg-lib.h>
9−#include <scsi/scsi.h>
10−#include <scsi/scsi_host.h>
11−
12−#include "ufshcd.h"
13−#include "ufs.h"
8+struct ufs_hba;
149
1510 #ifdef CONFIG_SCSI_UFS_BSG
1611 void ufs_bsg_remove(struct ufs_hba *hba);
drivers/scsi/ufs/ufs_quirks.h+3−12
@@ -19,25 +19,16 @@ · 18 unmodified lines
1919 #define UFS_VENDOR_WDC 0x145
2020
2121 /**
22− * ufs_dev_fix - ufs device quirk info
22+ * ufs_dev_quirk - ufs device quirk info
2323 * @card: ufs card details
2424 * @quirk: device quirk
2525 */
26−struct ufs_dev_fix {
26+struct ufs_dev_quirk {
2727 u16 wmanufacturerid;
28− u8 *model;
28+ const u8 *model;
2929 unsigned int quirk;
3030 };
3131
32−#define END_FIX { }
33−
34−/* add specific device quirk */
35−#define UFS_FIX(_vendor, _model, _quirk) { \
36− .wmanufacturerid = (_vendor),\
37− .model = (_model), \
38− .quirk = (_quirk), \
39−}
40−
4132 /*
4233 * Some vendor's UFS device sends back to back NACs for the DL data frames
4334 * causing the host controller to raise the DFES error status. Sometimes
drivers/scsi/ufs/ufshcd-crypto.h+4−1
@@ -6,10 +6,13 @@ · 5 unmodified lines
66 #ifndef _UFSHCD_CRYPTO_H
77 #define _UFSHCD_CRYPTO_H
88
9−#ifdef CONFIG_SCSI_UFS_CRYPTO
9+#include <scsi/scsi_cmnd.h>
1010 #include "ufshcd.h"
11+#include "ufshcd-priv.h"
1112 #include "ufshci.h"
1213
14+#ifdef CONFIG_SCSI_UFS_CRYPTO
15+
1316 static inline void ufshcd_prepare_lrbp_crypto(struct request *rq,
1417 struct ufshcd_lrb *lrbp)
1518 {
drivers/scsi/ufs/ufshcd-dwc.c+2−0
@@ -7,6 +7,8 @@ · 6 unmodified lines
77 * Authors: Joao Pinto <jpinto@synopsys.com>
88 */
99
10+#include <linux/module.h>
11+
1012 #include "ufshcd.h"
1113 #include "unipro.h"
1214
drivers/scsi/ufs/ufshcd-dwc.h+2−0
@@ -10,6 +10,8 @@ · 9 unmodified lines
1010 #ifndef _UFSHCD_DWC_H
1111 #define _UFSHCD_DWC_H
1212
13+#include "ufshcd.h"
14+
1315 struct ufshcd_dme_attr_val {
1416 u32 attr_sel;
1517 u32 mib_val;
drivers/scsi/ufs/ufshcd-pci.c+2−2
@@ -2,7 +2,6 @@ · 1 unmodified line
22 /*
33 * Universal Flash Storage Host controller PCI glue driver
44 *
5− * This code is based on drivers/scsi/ufs/ufshcd-pci.c
65 * Copyright (C) 2011-2013 Samsung India Software Operations
76 *
87 * Authors:
@@ -11,6 +10,8 @@ · 2 unmodified lines
1110 */
1211
1312 #include "ufshcd.h"
13+#include <linux/delay.h>
14+#include <linux/module.h>
1415 #include <linux/pci.h>
1516 #include <linux/pm_runtime.h>
1617 #include <linux/pm_qos.h>
@@ -618,4 +619,3 @@ MODULE_AUTHOR("Santosh Yaragnavi <santosh.sy@samsung.com>"); · 601 unmodified lines
618619 MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
619620 MODULE_DESCRIPTION("UFS host controller PCI glue driver");
620621 MODULE_LICENSE("GPL");
621−MODULE_VERSION(UFSHCD_DRIVER_VERSION);
drivers/scsi/ufs/ufshcd-pltfrm.c+20−18
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 * Vinayak Holikatti <h.vinayak@samsung.com>
99 */
1010
11+#include <linux/module.h>
1112 #include <linux/platform_device.h>
1213 #include <linux/pm_runtime.h>
1314 #include <linux/of.h>
@@ -297,18 +298,20 @@ EXPORT_SYMBOL_GPL(ufshcd_get_pwr_dev_param); · 283 unmodified lines
297298
298299 void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param)
299300 {
300− dev_param->tx_lanes = 2;
301− dev_param->rx_lanes = 2;
302− dev_param->hs_rx_gear = UFS_HS_G3;
303− dev_param->hs_tx_gear = UFS_HS_G3;
304− dev_param->pwm_rx_gear = UFS_PWM_G4;
305− dev_param->pwm_tx_gear = UFS_PWM_G4;
306− dev_param->rx_pwr_pwm = SLOW_MODE;
307− dev_param->tx_pwr_pwm = SLOW_MODE;
308− dev_param->rx_pwr_hs = FAST_MODE;
309− dev_param->tx_pwr_hs = FAST_MODE;
310− dev_param->hs_rate = PA_HS_MODE_B;
311− dev_param->desired_working_mode = UFS_HS_MODE;
301+ *dev_param = (struct ufs_dev_params){
302+ .tx_lanes = 2,
303+ .rx_lanes = 2,
304+ .hs_rx_gear = UFS_HS_G3,
305+ .hs_tx_gear = UFS_HS_G3,
306+ .pwm_rx_gear = UFS_PWM_G4,
307+ .pwm_tx_gear = UFS_PWM_G4,
308+ .rx_pwr_pwm = SLOW_MODE,
309+ .tx_pwr_pwm = SLOW_MODE,
310+ .rx_pwr_hs = FAST_MODE,
311+ .tx_pwr_hs = FAST_MODE,
312+ .hs_rate = PA_HS_MODE_B,
313+ .desired_working_mode = UFS_HS_MODE,
314+ };
312315 }
313316 EXPORT_SYMBOL_GPL(ufshcd_init_pwr_dev_param);
314317
@@ -341,7 +344,7 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, · 26 unmodified lines
341344
342345 err = ufshcd_alloc_host(dev, &hba);
343346 if (err) {
344− dev_err(&pdev->dev, "Allocation failed\n");
347+ dev_err(dev, "Allocation failed\n");
345348 goto out;
346349 }
347350
@@ -349,13 +352,13 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, · 1 unmodified line
349352
350353 err = ufshcd_parse_clock_info(hba);
351354 if (err) {
352− dev_err(&pdev->dev, "%s: clock parse failed %d\n",
355+ dev_err(dev, "%s: clock parse failed %d\n",
353356 __func__, err);
354357 goto dealloc_host;
355358 }
356359 err = ufshcd_parse_regulator_info(hba);
357360 if (err) {
358− dev_err(&pdev->dev, "%s: regulator init failed %d\n",
361+ dev_err(dev, "%s: regulator init failed %d\n",
359362 __func__, err);
360363 goto dealloc_host;
361364 }
@@ -368,8 +371,8 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, · 6 unmodified lines
368371 goto dealloc_host;
369372 }
370373
371− pm_runtime_set_active(&pdev->dev);
372− pm_runtime_enable(&pdev->dev);
374+ pm_runtime_set_active(dev);
375+ pm_runtime_enable(dev);
373376
374377 return 0;
375378
@@ -384,4 +387,3 @@ MODULE_AUTHOR("Santosh Yaragnavi <santosh.sy@samsung.com>"); · 8 unmodified lines
384387 MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
385388 MODULE_DESCRIPTION("UFS host controller Platform bus based glue driver");
386389 MODULE_LICENSE("GPL");
387−MODULE_VERSION(UFSHCD_DRIVER_VERSION);
drivers/scsi/ufs/ufshcd-priv.h+298−0
@@ -0,0 +1,298 @@
1+/* SPDX-License-Identifier: GPL-2.0-or-later */
2+
3+#ifndef _UFSHCD_PRIV_H_
4+#define _UFSHCD_PRIV_H_
5+
6+#include <linux/pm_runtime.h>
7+#include "ufshcd.h"
8+
9+static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba)
10+{
11+ return !hba->shutting_down;
12+}
13+
14+void ufshcd_schedule_eh_work(struct ufs_hba *hba);
15+
16+static inline bool ufshcd_keep_autobkops_enabled_except_suspend(
17+ struct ufs_hba *hba)
18+{
19+ return hba->caps & UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND;
20+}
21+
22+static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba)
23+{
24+ if (hba->dev_info.wb_buffer_type == WB_BUF_MODE_LU_DEDICATED)
25+ return hba->dev_info.wb_dedicated_lu;
26+ return 0;
27+}
28+
29+#ifdef CONFIG_SCSI_UFS_HWMON
30+void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask);
31+void ufs_hwmon_remove(struct ufs_hba *hba);
32+void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask);
33+#else
34+static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {}
35+static inline void ufs_hwmon_remove(struct ufs_hba *hba) {}
36+static inline void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask) {}
37+#endif
38+
39+int ufshcd_read_desc_param(struct ufs_hba *hba,
40+ enum desc_idn desc_id,
41+ int desc_index,
42+ u8 param_offset,
43+ u8 *param_read_buf,
44+ u8 param_size);
45+int ufshcd_query_attr_retry(struct ufs_hba *hba, enum query_opcode opcode,
46+ enum attr_idn idn, u8 index, u8 selector,
47+ u32 *attr_val);
48+int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
49+ enum attr_idn idn, u8 index, u8 selector, u32 *attr_val);
50+int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
51+ enum flag_idn idn, u8 index, bool *flag_res);
52+void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);
53+
54+#define SD_ASCII_STD true
55+#define SD_RAW false
56+int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
57+ u8 **buf, bool ascii);
58+
59+int ufshcd_hold(struct ufs_hba *hba, bool async);
60+void ufshcd_release(struct ufs_hba *hba);
61+
62+void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
63+ int *desc_length);
64+
65+int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd);
66+
67+int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba,
68+ struct utp_upiu_req *req_upiu,
69+ struct utp_upiu_req *rsp_upiu,
70+ int msgcode,
71+ u8 *desc_buff, int *buff_len,
72+ enum query_opcode desc_op);
73+
74+int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable);
75+
76+/* Wrapper functions for safely calling variant operations */
77+static inline const char *ufshcd_get_var_name(struct ufs_hba *hba)
78+{
79+ if (hba->vops)
80+ return hba->vops->name;
81+ return "";
82+}
83+
84+static inline void ufshcd_vops_exit(struct ufs_hba *hba)
85+{
86+ if (hba->vops && hba->vops->exit)
87+ return hba->vops->exit(hba);
88+}
89+
90+static inline u32 ufshcd_vops_get_ufs_hci_version(struct ufs_hba *hba)
91+{
92+ if (hba->vops && hba->vops->get_ufs_hci_version)
93+ return hba->vops->get_ufs_hci_version(hba);
94+
95+ return ufshcd_readl(hba, REG_UFS_VERSION);
96+}
97+
98+static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba,
99+ bool up, enum ufs_notify_change_status status)
100+{
101+ if (hba->vops && hba->vops->clk_scale_notify)
102+ return hba->vops->clk_scale_notify(hba, up, status);
103+ return 0;
104+}
105+
106+static inline void ufshcd_vops_event_notify(struct ufs_hba *hba,
107+ enum ufs_event_type evt,
108+ void *data)
109+{
110+ if (hba->vops && hba->vops->event_notify)
111+ hba->vops->event_notify(hba, evt, data);
112+}
113+
114+static inline int ufshcd_vops_setup_clocks(struct ufs_hba *hba, bool on,
115+ enum ufs_notify_change_status status)
116+{
117+ if (hba->vops && hba->vops->setup_clocks)
118+ return hba->vops->setup_clocks(hba, on, status);
119+ return 0;
120+}
121+
122+static inline int ufshcd_vops_hce_enable_notify(struct ufs_hba *hba,
123+ bool status)
124+{
125+ if (hba->vops && hba->vops->hce_enable_notify)
126+ return hba->vops->hce_enable_notify(hba, status);
127+
128+ return 0;
129+}
130+static inline int ufshcd_vops_link_startup_notify(struct ufs_hba *hba,
131+ bool status)
132+{
133+ if (hba->vops && hba->vops->link_startup_notify)
134+ return hba->vops->link_startup_notify(hba, status);
135+
136+ return 0;
137+}
138+
139+static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba,
140+ enum ufs_notify_change_status status,
141+ struct ufs_pa_layer_attr *dev_max_params,
142+ struct ufs_pa_layer_attr *dev_req_params)
143+{
144+ if (hba->vops && hba->vops->pwr_change_notify)
145+ return hba->vops->pwr_change_notify(hba, status,
146+ dev_max_params, dev_req_params);
147+
148+ return -ENOTSUPP;
149+}
150+
151+static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba,
152+ int tag, u8 tm_function)
153+{
154+ if (hba->vops && hba->vops->setup_task_mgmt)
155+ return hba->vops->setup_task_mgmt(hba, tag, tm_function);
156+}
157+
158+static inline void ufshcd_vops_hibern8_notify(struct ufs_hba *hba,
159+ enum uic_cmd_dme cmd,
160+ enum ufs_notify_change_status status)
161+{
162+ if (hba->vops && hba->vops->hibern8_notify)
163+ return hba->vops->hibern8_notify(hba, cmd, status);
164+}
165+
166+static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba)
167+{
168+ if (hba->vops && hba->vops->apply_dev_quirks)
169+ return hba->vops->apply_dev_quirks(hba);
170+ return 0;
171+}
172+
173+static inline void ufshcd_vops_fixup_dev_quirks(struct ufs_hba *hba)
174+{
175+ if (hba->vops && hba->vops->fixup_dev_quirks)
176+ hba->vops->fixup_dev_quirks(hba);
177+}
178+
179+static inline int ufshcd_vops_suspend(struct ufs_hba *hba, enum ufs_pm_op op,
180+ enum ufs_notify_change_status status)
181+{
182+ if (hba->vops && hba->vops->suspend)
183+ return hba->vops->suspend(hba, op, status);
184+
185+ return 0;
186+}
187+
188+static inline int ufshcd_vops_resume(struct ufs_hba *hba, enum ufs_pm_op op)
189+{
190+ if (hba->vops && hba->vops->resume)
191+ return hba->vops->resume(hba, op);
192+
193+ return 0;
194+}
195+
196+static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba)
197+{
198+ if (hba->vops && hba->vops->dbg_register_dump)
199+ hba->vops->dbg_register_dump(hba);
200+}
201+
202+static inline int ufshcd_vops_device_reset(struct ufs_hba *hba)
203+{
204+ if (hba->vops && hba->vops->device_reset)
205+ return hba->vops->device_reset(hba);
206+
207+ return -EOPNOTSUPP;
208+}
209+
210+static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba,
211+ struct devfreq_dev_profile *p,
212+ struct devfreq_simple_ondemand_data *data)
213+{
214+ if (hba->vops && hba->vops->config_scaling_param)
215+ hba->vops->config_scaling_param(hba, p, data);
216+}
217+
218+extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];
219+
220+/**
221+ * ufshcd_scsi_to_upiu_lun - maps scsi LUN to UPIU LUN
222+ * @scsi_lun: scsi LUN id
223+ *
224+ * Returns UPIU LUN id
225+ */
226+static inline u8 ufshcd_scsi_to_upiu_lun(unsigned int scsi_lun)
227+{
228+ if (scsi_is_wlun(scsi_lun))
229+ return (scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID)
230+ | UFS_UPIU_WLUN_ID;
231+ else
232+ return scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID;
233+}
234+
235+int __ufshcd_write_ee_control(struct ufs_hba *hba, u32 ee_ctrl_mask);
236+int ufshcd_write_ee_control(struct ufs_hba *hba);
237+int ufshcd_update_ee_control(struct ufs_hba *hba, u16 *mask, u16 *other_mask,
238+ u16 set, u16 clr);
239+
240+static inline int ufshcd_update_ee_drv_mask(struct ufs_hba *hba,
241+ u16 set, u16 clr)
242+{
243+ return ufshcd_update_ee_control(hba, &hba->ee_drv_mask,
244+ &hba->ee_usr_mask, set, clr);
245+}
246+
247+static inline int ufshcd_update_ee_usr_mask(struct ufs_hba *hba,
248+ u16 set, u16 clr)
249+{
250+ return ufshcd_update_ee_control(hba, &hba->ee_usr_mask,
251+ &hba->ee_drv_mask, set, clr);
252+}
253+
254+static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba)
255+{
256+ return pm_runtime_get_sync(&hba->ufs_device_wlun->sdev_gendev);
257+}
258+
259+static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba)
260+{
261+ return pm_runtime_put_sync(&hba->ufs_device_wlun->sdev_gendev);
262+}
263+
264+static inline void ufshcd_rpm_get_noresume(struct ufs_hba *hba)
265+{
266+ pm_runtime_get_noresume(&hba->ufs_device_wlun->sdev_gendev);
267+}
268+
269+static inline int ufshcd_rpm_resume(struct ufs_hba *hba)
270+{
271+ return pm_runtime_resume(&hba->ufs_device_wlun->sdev_gendev);
272+}
273+
274+static inline int ufshcd_rpm_put(struct ufs_hba *hba)
275+{
276+ return pm_runtime_put(&hba->ufs_device_wlun->sdev_gendev);
277+}
278+
279+/**
280+ * ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit descriptor
281+ * @dev_info: pointer of instance of struct ufs_dev_info
282+ * @lun: LU number to check
283+ * @return: true if the lun has a matching unit descriptor, false otherwise
284+ */
285+static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info,
286+ u8 lun, u8 param_offset)
287+{
288+ if (!dev_info || !dev_info->max_lu_supported) {
289+ pr_err("Max General LU supported by UFS isn't initialized\n");
290+ return false;
291+ }
292+ /* WB is available only for the logical unit from 0 to 7 */
293+ if (param_offset == UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS)
294+ return lun < UFS_UPIU_MAX_WB_LUN_ID;
295+ return lun == UFS_UPIU_RPMB_WLUN || (lun < dev_info->max_lu_supported);
296+}
297+
298+#endif /* _UFSHCD_PRIV_H_ */
drivers/scsi/ufs/ufshcd.c+116−131
@@ -16,8 +16,16 @@ · 15 unmodified lines
1616 #include <linux/bitfield.h>
1717 #include <linux/blk-pm.h>
1818 #include <linux/blkdev.h>
19+#include <linux/clk.h>
20+#include <linux/delay.h>
21+#include <linux/interrupt.h>
22+#include <linux/module.h>
23+#include <linux/regulator/consumer.h>
24+#include <scsi/scsi_cmnd.h>
25+#include <scsi/scsi_dbg.h>
1926 #include <scsi/scsi_driver.h>
20−#include "ufshcd.h"
27+#include <scsi/scsi_eh.h>
28+#include "ufshcd-priv.h"
2129 #include "ufs_quirks.h"
2230 #include "unipro.h"
2331 #include "ufs-sysfs.h"
@@ -113,8 +121,13 @@ int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len, · 89 unmodified lines
113121 if (!regs)
114122 return -ENOMEM;
115123
116− for (pos = 0; pos < len; pos += 4)
124+ for (pos = 0; pos < len; pos += 4) {
125+ if (offset == 0 &&
126+ pos >= REG_UIC_ERROR_CODE_PHY_ADAPTER_LAYER &&
127+ pos <= REG_UIC_ERROR_CODE_DME)
128+ continue;
117129 regs[pos / 4] = ufshcd_readl(hba, offset + pos);
130+ }
118131
119132 ufshcd_hex_dump(prefix, regs, len);
120133 kfree(regs);
@@ -204,26 +217,33 @@ ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state, · 83 unmodified lines
204217 return UFS_PM_LVL_0;
205218 }
206219
207−static struct ufs_dev_fix ufs_fixups[] = {
220+static const struct ufs_dev_quirk ufs_fixups[] = {
208221 /* UFS cards deviations table */
209− UFS_FIX(UFS_VENDOR_MICRON, UFS_ANY_MODEL,
210− UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
211− UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ),
212− UFS_FIX(UFS_VENDOR_SAMSUNG, UFS_ANY_MODEL,
213− UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
214− UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE |
215− UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS),
216− UFS_FIX(UFS_VENDOR_SKHYNIX, UFS_ANY_MODEL,
217− UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME),
218− UFS_FIX(UFS_VENDOR_SKHYNIX, "hB8aL1" /*H28U62301AMR*/,
219− UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME),
220− UFS_FIX(UFS_VENDOR_TOSHIBA, UFS_ANY_MODEL,
221− UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM),
222− UFS_FIX(UFS_VENDOR_TOSHIBA, "THGLF2G9C8KBADG",
223− UFS_DEVICE_QUIRK_PA_TACTIVATE),
224− UFS_FIX(UFS_VENDOR_TOSHIBA, "THGLF2G9D8KBADG",
225− UFS_DEVICE_QUIRK_PA_TACTIVATE),
226− END_FIX
222+ { .wmanufacturerid = UFS_VENDOR_MICRON,
223+ .model = UFS_ANY_MODEL,
224+ .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
225+ UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ },
226+ { .wmanufacturerid = UFS_VENDOR_SAMSUNG,
227+ .model = UFS_ANY_MODEL,
228+ .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
229+ UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE |
230+ UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS },
231+ { .wmanufacturerid = UFS_VENDOR_SKHYNIX,
232+ .model = UFS_ANY_MODEL,
233+ .quirk = UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME },
234+ { .wmanufacturerid = UFS_VENDOR_SKHYNIX,
235+ .model = "hB8aL1" /*H28U62301AMR*/,
236+ .quirk = UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME },
237+ { .wmanufacturerid = UFS_VENDOR_TOSHIBA,
238+ .model = UFS_ANY_MODEL,
239+ .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM },
240+ { .wmanufacturerid = UFS_VENDOR_TOSHIBA,
241+ .model = "THGLF2G9C8KBADG",
242+ .quirk = UFS_DEVICE_QUIRK_PA_TACTIVATE },
243+ { .wmanufacturerid = UFS_VENDOR_TOSHIBA,
244+ .model = "THGLF2G9D8KBADG",
245+ .quirk = UFS_DEVICE_QUIRK_PA_TACTIVATE },
246+ {}
227247 };
228248
229249 static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba);
@@ -533,7 +553,7 @@ static void ufshcd_print_tmrs(struct ufs_hba *hba, unsigned long bitmap) · 303 unmodified lines
533553
534554 static void ufshcd_print_host_state(struct ufs_hba *hba)
535555 {
536− struct scsi_device *sdev_ufs = hba->sdev_ufs_device;
556+ struct scsi_device *sdev_ufs = hba->ufs_device_wlun;
537557
538558 dev_err(hba->dev, "UFS Host state=%d\n", hba->ufshcd_state);
539559 dev_err(hba->dev, "outstanding reqs=0x%lx tasks=0x%lx\n",
@@ -639,7 +659,7 @@ EXPORT_SYMBOL_GPL(ufshcd_delay_us); · 99 unmodified lines
639659 * Return:
640660 * -ETIMEDOUT on error, zero on success.
641661 */
642−int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
662+static int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
643663 u32 val, unsigned long interval_us,
644664 unsigned long timeout_ms)
645665 {
@@ -712,8 +732,7 @@ static inline u32 ufshcd_get_ufs_version(struct ufs_hba *hba) · 66 unmodified lines
712732 */
713733 static inline bool ufshcd_is_device_present(struct ufs_hba *hba)
714734 {
715− return (ufshcd_readl(hba, REG_CONTROLLER_STATUS) &
716− DEVICE_PRESENT) ? true : false;
735+ return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & DEVICE_PRESENT;
717736 }
718737
719738 /**
@@ -840,7 +859,7 @@ ufshcd_get_rsp_upiu_data_seg_len(struct utp_upiu_rsp *ucd_rsp_ptr) · 120 unmodified lines
840859 static inline bool ufshcd_is_exception_event(struct utp_upiu_rsp *ucd_rsp_ptr)
841860 {
842861 return be32_to_cpu(ucd_rsp_ptr->header.dword_2) &
843− MASK_RSP_EXCEPTION_EVENT ? true : false;
862+ MASK_RSP_EXCEPTION_EVENT;
844863 }
845864
846865 /**
@@ -911,12 +930,11 @@ static inline void ufshcd_hba_start(struct ufs_hba *hba) · 64 unmodified lines
911930 * ufshcd_is_hba_active - Get controller state
912931 * @hba: per adapter instance
913932 *
914− * Returns false if controller is active, true otherwise
933+ * Returns true if and only if the controller is active.
915934 */
916935 static inline bool ufshcd_is_hba_active(struct ufs_hba *hba)
917936 {
918− return (ufshcd_readl(hba, REG_CONTROLLER_ENABLE) & CONTROLLER_ENABLE)
919− ? false : true;
937+ return ufshcd_readl(hba, REG_CONTROLLER_ENABLE) & CONTROLLER_ENABLE;
920938 }
921939
922940 u32 ufshcd_get_local_unipro_ver(struct ufs_hba *hba)
@@ -940,10 +958,7 @@ static bool ufshcd_is_unipro_pa_params_tuning_req(struct ufs_hba *hba) · 17 unmodified lines
940958 * logic simple, we will only do manual tuning if local unipro version
941959 * doesn't support ver1.6 or later.
942960 */
943− if (ufshcd_get_local_unipro_ver(hba) < UFS_UNIPRO_VER_1_6)
944− return true;
945− else
946− return false;
961+ return ufshcd_get_local_unipro_ver(hba) < UFS_UNIPRO_VER_1_6;
947962 }
948963
949964 /**
@@ -1350,7 +1365,7 @@ static int ufshcd_devfreq_target(struct device *dev, · 400 unmodified lines
13501365 }
13511366
13521367 /* Decide based on the rounded-off frequency and update */
1353− scale_up = (*freq == clki->max_freq) ? true : false;
1368+ scale_up = *freq == clki->max_freq;
13541369 if (!scale_up)
13551370 *freq = clki->min_freq;
13561371 /* Update the frequency */
@@ -1862,18 +1877,26 @@ static ssize_t ufshcd_clkgate_delay_show(struct device *dev, · 505 unmodified lines
18621877 return sysfs_emit(buf, "%lu\n", hba->clk_gating.delay_ms);
18631878 }
18641879
1880+void ufshcd_clkgate_delay_set(struct device *dev, unsigned long value)
1881+{
1882+ struct ufs_hba *hba = dev_get_drvdata(dev);
1883+ unsigned long flags;
1884+
1885+ spin_lock_irqsave(hba->host->host_lock, flags);
1886+ hba->clk_gating.delay_ms = value;
1887+ spin_unlock_irqrestore(hba->host->host_lock, flags);
1888+}
1889+EXPORT_SYMBOL_GPL(ufshcd_clkgate_delay_set);
1890+
18651891 static ssize_t ufshcd_clkgate_delay_store(struct device *dev,
18661892 struct device_attribute *attr, const char *buf, size_t count)
18671893 {
1868− struct ufs_hba *hba = dev_get_drvdata(dev);
1869− unsigned long flags, value;
1894+ unsigned long value;
18701895
18711896 if (kstrtoul(buf, 0, &value))
18721897 return -EINVAL;
18731898
1874− spin_lock_irqsave(hba->host->host_lock, flags);
1875− hba->clk_gating.delay_ms = value;
1876− spin_unlock_irqrestore(hba->host->host_lock, flags);
1899+ ufshcd_clkgate_delay_set(dev, value);
18771900 return count;
18781901 }
18791902
@@ -2120,9 +2143,6 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag) · 240 unmodified lines
21202143 __set_bit(task_tag, &hba->outstanding_reqs);
21212144 ufshcd_writel(hba, 1 << task_tag, REG_UTP_TRANSFER_REQ_DOOR_BELL);
21222145 spin_unlock_irqrestore(&hba->outstanding_lock, flags);
2123−
2124− /* Make sure that doorbell is committed immediately */
2125− wmb();
21262146 }
21272147
21282148 /**
@@ -2131,15 +2151,17 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag) · 2 unmodified lines
21312151 */
21322152 static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp)
21332153 {
2154+ u8 *const sense_buffer = lrbp->cmd->sense_buffer;
21342155 int len;
2135− if (lrbp->sense_buffer &&
2156+
2157+ if (sense_buffer &&
21362158 ufshcd_get_rsp_upiu_data_seg_len(lrbp->ucd_rsp_ptr)) {
21372159 int len_to_copy;
21382160
21392161 len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len);
21402162 len_to_copy = min_t(int, UFS_SENSE_SIZE, len);
21412163
2142− memcpy(lrbp->sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data,
2164+ memcpy(sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data,
21432165 len_to_copy);
21442166 }
21452167 }
@@ -2217,10 +2239,7 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba) · 71 unmodified lines
22172239 */
22182240 static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba)
22192241 {
2220− if (ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY)
2221− return true;
2222− else
2223− return false;
2242+ return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY;
22242243 }
22252244
22262245 /**
@@ -2796,11 +2815,9 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) · 569 unmodified lines
27962815 lrbp = &hba->lrb[tag];
27972816 WARN_ON(lrbp->cmd);
27982817 lrbp->cmd = cmd;
2799− lrbp->sense_bufflen = UFS_SENSE_SIZE;
2800− lrbp->sense_buffer = cmd->sense_buffer;
28012818 lrbp->task_tag = tag;
28022819 lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
2803− lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba) ? true : false;
2820+ lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba);
28042821
28052822 ufshcd_prepare_lrbp_crypto(scsi_cmd_to_rq(cmd), lrbp);
28062823
@@ -2837,8 +2854,6 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba, · 30 unmodified lines
28372854 struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag)
28382855 {
28392856 lrbp->cmd = NULL;
2840− lrbp->sense_bufflen = 0;
2841− lrbp->sense_buffer = NULL;
28422857 lrbp->task_tag = tag;
28432858 lrbp->lun = 0; /* device management cmd is not specific to any LUN */
28442859 lrbp->intr_cmd = true; /* No interrupt aggregation */
@@ -4198,7 +4213,7 @@ void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit) · 1353 unmodified lines
41984213 spin_unlock_irqrestore(hba->host->host_lock, flags);
41994214
42004215 if (update &&
4201− !pm_runtime_suspended(&hba->sdev_ufs_device->sdev_gendev)) {
4216+ !pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) {
42024217 ufshcd_rpm_get_sync(hba);
42034218 ufshcd_hold(hba, false);
42044219 ufshcd_auto_hibern8_enable(hba);
@@ -4210,14 +4225,10 @@ EXPORT_SYMBOL_GPL(ufshcd_auto_hibern8_update); · 5 unmodified lines
42104225
42114226 void ufshcd_auto_hibern8_enable(struct ufs_hba *hba)
42124227 {
4213− unsigned long flags;
4214−
42154228 if (!ufshcd_is_auto_hibern8_supported(hba))
42164229 return;
42174230
4218− spin_lock_irqsave(hba->host->host_lock, flags);
42194231 ufshcd_writel(hba, hba->ahit, REG_AUTO_HIBERNATE_IDLE_TIMER);
4220− spin_unlock_irqrestore(hba->host->host_lock, flags);
42214232 }
42224233
42234234 /**
@@ -4328,18 +4339,18 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba, · 104 unmodified lines
43284339 pwr_mode->lane_rx);
43294340 if (pwr_mode->pwr_rx == FASTAUTO_MODE ||
43304341 pwr_mode->pwr_rx == FAST_MODE)
4331− ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), TRUE);
4342+ ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), true);
43324343 else
4333− ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), FALSE);
4344+ ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), false);
43344345
43354346 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXGEAR), pwr_mode->gear_tx);
43364347 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_ACTIVETXDATALANES),
43374348 pwr_mode->lane_tx);
43384349 if (pwr_mode->pwr_tx == FASTAUTO_MODE ||
43394350 pwr_mode->pwr_tx == FAST_MODE)
4340− ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), TRUE);
4351+ ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), true);
43414352 else
4342− ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), FALSE);
4353+ ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), false);
43434354
43444355 if (pwr_mode->pwr_rx == FASTAUTO_MODE ||
43454356 pwr_mode->pwr_tx == FASTAUTO_MODE ||
@@ -4438,7 +4449,7 @@ static int ufshcd_complete_dev_init(struct ufs_hba *hba) · 92 unmodified lines
44384449 QUERY_FLAG_IDN_FDEVICEINIT, 0, &flag_res);
44394450 if (!flag_res)
44404451 break;
4441− usleep_range(5000, 10000);
4452+ usleep_range(500, 1000);
44424453 } while (ktime_before(ktime_get(), timeout));
44434454
44444455 if (err) {
@@ -4554,7 +4565,7 @@ static int ufshcd_hba_execute_hce(struct ufs_hba *hba) · 109 unmodified lines
45544565 int retry_inner;
45554566
45564567 start:
4557− if (!ufshcd_is_hba_active(hba))
4568+ if (ufshcd_is_hba_active(hba))
45584569 /* change controller state to "reset state" */
45594570 ufshcd_hba_stop(hba);
45604571
@@ -4580,7 +4591,7 @@ start: · 19 unmodified lines
45804591
45814592 /* wait for the host controller to complete initialization */
45824593 retry_inner = 50;
4583− while (ufshcd_is_hba_active(hba)) {
4594+ while (!ufshcd_is_hba_active(hba)) {
45844595 if (retry_inner) {
45854596 retry_inner--;
45864597 } else {
@@ -4914,13 +4925,13 @@ static void ufshcd_setup_links(struct ufs_hba *hba, struct scsi_device *sdev) · 327 unmodified lines
49144925 * Device wlun is the supplier & rest of the luns are consumers.
49154926 * This ensures that device wlun suspends after all other luns.
49164927 */
4917− if (hba->sdev_ufs_device) {
4928+ if (hba->ufs_device_wlun) {
49184929 link = device_link_add(&sdev->sdev_gendev,
4919− &hba->sdev_ufs_device->sdev_gendev,
4930+ &hba->ufs_device_wlun->sdev_gendev,
49204931 DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE);
49214932 if (!link) {
49224933 dev_err(&sdev->sdev_gendev, "Failed establishing link - %s\n",
4923− dev_name(&hba->sdev_ufs_device->sdev_gendev));
4934+ dev_name(&hba->ufs_device_wlun->sdev_gendev));
49244935 return;
49254936 }
49264937 hba->luns_avail--;
@@ -5056,15 +5067,15 @@ static void ufshcd_slave_destroy(struct scsi_device *sdev) · 129 unmodified lines
50565067 /* Drop the reference as it won't be needed anymore */
50575068 if (ufshcd_scsi_to_upiu_lun(sdev->lun) == UFS_UPIU_UFS_DEVICE_WLUN) {
50585069 spin_lock_irqsave(hba->host->host_lock, flags);
5059− hba->sdev_ufs_device = NULL;
5070+ hba->ufs_device_wlun = NULL;
50605071 spin_unlock_irqrestore(hba->host->host_lock, flags);
5061− } else if (hba->sdev_ufs_device) {
5072+ } else if (hba->ufs_device_wlun) {
50625073 struct device *supplier = NULL;
50635074
50645075 /* Ensure UFS Device WLUN exists and does not disappear */
50655076 spin_lock_irqsave(hba->host->host_lock, flags);
5066− if (hba->sdev_ufs_device) {
5067− supplier = &hba->sdev_ufs_device->sdev_gendev;
5077+ if (hba->ufs_device_wlun) {
5078+ supplier = &hba->ufs_device_wlun->sdev_gendev;
50685079 get_device(supplier);
50695080 }
50705081 spin_unlock_irqrestore(hba->host->host_lock, flags);
@@ -5782,10 +5793,7 @@ static bool ufshcd_wb_presrv_usrspc_keep_vcc_on(struct ufs_hba *hba, · 711 unmodified lines
57825793 return false;
57835794 }
57845795 /* Let it continue to flush when available buffer exceeds threshold */
5785− if (avail_buf < hba->vps->wb_flush_threshold)
5786− return true;
5787−
5788− return false;
5796+ return avail_buf < hba->vps->wb_flush_threshold;
57895797 }
57905798
57915799 static void ufshcd_wb_force_disable(struct ufs_hba *hba)
@@ -5864,11 +5872,8 @@ static bool ufshcd_wb_need_flush(struct ufs_hba *hba) · 72 unmodified lines
58645872 return false;
58655873 }
58665874
5867− if (!hba->dev_info.b_presrv_uspc_en) {
5868− if (avail_buf <= UFS_WB_BUF_REMAIN_PERCENT(10))
5869− return true;
5870− return false;
5871− }
5875+ if (!hba->dev_info.b_presrv_uspc_en)
5876+ return avail_buf <= UFS_WB_BUF_REMAIN_PERCENT(10);
58725877
58735878 return ufshcd_wb_presrv_usrspc_keep_vcc_on(hba, avail_buf);
58745879 }
@@ -6046,7 +6051,7 @@ static void ufshcd_clk_scaling_suspend(struct ufs_hba *hba, bool suspend) · 171 unmodified lines
60466051 static void ufshcd_err_handling_prepare(struct ufs_hba *hba)
60476052 {
60486053 ufshcd_rpm_get_sync(hba);
6049− if (pm_runtime_status_suspended(&hba->sdev_ufs_device->sdev_gendev) ||
6054+ if (pm_runtime_status_suspended(&hba->ufs_device_wlun->sdev_gendev) ||
60506055 hba->is_sys_suspended) {
60516056 enum ufs_pm_op pm_op;
60526057
@@ -6091,7 +6096,7 @@ static void ufshcd_err_handling_unprepare(struct ufs_hba *hba) · 38 unmodified lines
60916096 static inline bool ufshcd_err_handling_should_stop(struct ufs_hba *hba)
60926097 {
60936098 return (!hba->is_powered || hba->shutting_down ||
6094− !hba->sdev_ufs_device ||
6099+ !hba->ufs_device_wlun ||
60956100 hba->ufshcd_state == UFSHCD_STATE_ERROR ||
60966101 (!(hba->saved_err || hba->saved_uic_err || hba->force_reset ||
60976102 ufshcd_is_link_broken(hba))));
@@ -6110,7 +6115,7 @@ static void ufshcd_recover_pm_error(struct ufs_hba *hba) · 12 unmodified lines
61106115 * Set RPM status of wlun device to RPM_ACTIVE,
61116116 * this also clears its runtime error.
61126117 */
6113− ret = pm_runtime_set_active(&hba->sdev_ufs_device->sdev_gendev);
6118+ ret = pm_runtime_set_active(&hba->ufs_device_wlun->sdev_gendev);
61146119
61156120 /* hba device might have a runtime error otherwise */
61166121 if (ret)
@@ -6815,8 +6820,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, · 698 unmodified lines
68156820 lrbp = &hba->lrb[tag];
68166821 WARN_ON(lrbp->cmd);
68176822 lrbp->cmd = NULL;
6818− lrbp->sense_bufflen = 0;
6819− lrbp->sense_buffer = NULL;
68206823 lrbp->task_tag = tag;
68216824 lrbp->lun = 0;
68226825 lrbp->intr_cmd = true;
@@ -7223,7 +7226,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) · 400 unmodified lines
72237226 * Stop the host controller and complete the requests
72247227 * cleared by h/w
72257228 */
7226− ufshpb_reset_host(hba);
7229+ ufshpb_toggle_state(hba, HPB_PRESENT, HPB_RESET);
72277230 ufshcd_hba_stop(hba);
72287231 hba->silence_err_logs = true;
72297232 ufshcd_complete_requests(hba);
@@ -7351,7 +7354,7 @@ static u32 ufshcd_get_max_icc_level(int sup_curr_uA, u32 start_scan, char *buff) · 121 unmodified lines
73517354 u16 unit;
73527355
73537356 for (i = start_scan; i >= 0; i--) {
7354− data = be16_to_cpup((__be16 *)&buff[2 * i]);
7357+ data = get_unaligned_be16(&buff[2 * i]);
73557358 unit = (data & ATTR_ICC_LVL_UNIT_MASK) >>
73567359 ATTR_ICC_LVL_UNIT_OFFSET;
73577360 curr_uA = data & ATTR_ICC_LVL_VALUE_MASK;
@@ -7506,20 +7509,20 @@ static int ufshcd_scsi_add_wlus(struct ufs_hba *hba) · 148 unmodified lines
75067509 int ret = 0;
75077510 struct scsi_device *sdev_boot, *sdev_rpmb;
75087511
7509− hba->sdev_ufs_device = __scsi_add_device(hba->host, 0, 0,
7512+ hba->ufs_device_wlun = __scsi_add_device(hba->host, 0, 0,
75107513 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_UFS_DEVICE_WLUN), NULL);
7511− if (IS_ERR(hba->sdev_ufs_device)) {
7512− ret = PTR_ERR(hba->sdev_ufs_device);
7513− hba->sdev_ufs_device = NULL;
7514+ if (IS_ERR(hba->ufs_device_wlun)) {
7515+ ret = PTR_ERR(hba->ufs_device_wlun);
7516+ hba->ufs_device_wlun = NULL;
75147517 goto out;
75157518 }
7516− scsi_device_put(hba->sdev_ufs_device);
7519+ scsi_device_put(hba->ufs_device_wlun);
75177520
75187521 sdev_rpmb = __scsi_add_device(hba->host, 0, 0,
75197522 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_RPMB_WLUN), NULL);
75207523 if (IS_ERR(sdev_rpmb)) {
75217524 ret = PTR_ERR(sdev_rpmb);
7522− goto remove_sdev_ufs_device;
7525+ goto remove_ufs_device_wlun;
75237526 }
75247527 ufshcd_blk_pm_runtime_init(sdev_rpmb);
75257528 scsi_device_put(sdev_rpmb);
@@ -7534,8 +7537,8 @@ static int ufshcd_scsi_add_wlus(struct ufs_hba *hba) · 8 unmodified lines
75347537 }
75357538 goto out;
75367539
7537−remove_sdev_ufs_device:
7538− scsi_remove_device(hba->sdev_ufs_device);
7540+remove_ufs_device_wlun:
7541+ scsi_remove_device(hba->ufs_device_wlun);
75397542 out:
75407543 return ret;
75417544 }
@@ -7634,9 +7637,10 @@ static void ufshcd_temp_notif_probe(struct ufs_hba *hba, u8 *desc_buf) · 92 unmodified lines
76347637 }
76357638 }
76367639
7637−void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_fix *fixups)
7640+void ufshcd_fixup_dev_quirks(struct ufs_hba *hba,
7641+ const struct ufs_dev_quirk *fixups)
76387642 {
7639− struct ufs_dev_fix *f;
7643+ const struct ufs_dev_quirk *f;
76407644 struct ufs_dev_info *dev_info = &hba->dev_info;
76417645
76427646 if (!fixups)
@@ -7956,6 +7960,11 @@ out: · 313 unmodified lines
79567960 return err;
79577961 }
79587962
7963+struct ufs_ref_clk {
7964+ unsigned long freq_hz;
7965+ enum ufs_ref_clk_freq val;
7966+};
7967+
79597968 static struct ufs_ref_clk ufs_ref_clk_freqs[] = {
79607969 {19200000, REF_CLK_FREQ_19_2_MHZ},
79617970 {26000000, REF_CLK_FREQ_26_MHZ},
@@ -8184,7 +8193,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params) · 222 unmodified lines
81848193 /* Enable Auto-Hibernate if configured */
81858194 ufshcd_auto_hibern8_enable(hba);
81868195
8187− ufshpb_reset(hba);
8196+ ufshpb_toggle_state(hba, HPB_RESET, HPB_PRESENT);
81888197 out:
81898198 spin_lock_irqsave(hba->host->host_lock, flags);
81908199 if (ret)
@@ -8319,33 +8328,10 @@ static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba, · 128 unmodified lines
83198328 static int ufshcd_config_vreg(struct device *dev,
83208329 struct ufs_vreg *vreg, bool on)
83218330 {
8322− int ret = 0;
8323− struct regulator *reg;
8324− const char *name;
8325− int min_uV, uA_load;
8326−
8327− BUG_ON(!vreg);
8328−
8329− reg = vreg->reg;
8330− name = vreg->name;
8331−
8332− if (regulator_count_voltages(reg) > 0) {
8333− uA_load = on ? vreg->max_uA : 0;
8334− ret = ufshcd_config_vreg_load(dev, vreg, uA_load);
8335− if (ret)
8336− goto out;
8331+ if (regulator_count_voltages(vreg->reg) <= 0)
8332+ return 0;
83378333
8338− if (vreg->min_uV && vreg->max_uV) {
8339− min_uV = on ? vreg->min_uV : 0;
8340− ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);
8341− if (ret)
8342− dev_err(dev,
8343− "%s: %s set voltage failed, err=%d\n",
8344− __func__, name, ret);
8345− }
8346− }
8347−out:
8348− return ret;
8334+ return ufshcd_config_vreg_load(dev, vreg, on ? vreg->max_uA : 0);
83498335 }
83508336
83518337 static int ufshcd_enable_vreg(struct device *dev, struct ufs_vreg *vreg)
@@ -8693,7 +8679,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, · 341 unmodified lines
86938679 int ret, retries;
86948680
86958681 spin_lock_irqsave(hba->host->host_lock, flags);
8696− sdp = hba->sdev_ufs_device;
8682+ sdp = hba->ufs_device_wlun;
86978683 if (sdp) {
86988684 ret = scsi_device_get(sdp);
86998685 if (!ret && !scsi_device_online(sdp)) {
@@ -9257,7 +9243,7 @@ static void ufshcd_wl_shutdown(struct device *dev) · 557 unmodified lines
92579243 ufshcd_rpm_get_sync(hba);
92589244 scsi_device_quiesce(sdev);
92599245 shost_for_each_device(sdev, hba->host) {
9260− if (sdev == hba->sdev_ufs_device)
9246+ if (sdev == hba->ufs_device_wlun)
92619247 continue;
92629248 scsi_device_quiesce(sdev);
92639249 }
@@ -9478,7 +9464,7 @@ EXPORT_SYMBOL(ufshcd_shutdown); · 214 unmodified lines
94789464 */
94799465 void ufshcd_remove(struct ufs_hba *hba)
94809466 {
9481− if (hba->sdev_ufs_device)
9467+ if (hba->ufs_device_wlun)
94829468 ufshcd_rpm_get_sync(hba);
94839469 ufs_hwmon_remove(hba);
94849470 ufs_bsg_remove(hba);
@@ -9806,7 +9792,7 @@ EXPORT_SYMBOL_GPL(ufshcd_resume_complete); · 321 unmodified lines
98069792
98079793 static bool ufshcd_rpm_ok_for_spm(struct ufs_hba *hba)
98089794 {
9809− struct device *dev = &hba->sdev_ufs_device->sdev_gendev;
9795+ struct device *dev = &hba->ufs_device_wlun->sdev_gendev;
98109796 enum ufs_dev_pwr_mode dev_pwr_mode;
98119797 enum uic_link_state link_state;
98129798 unsigned long flags;
@@ -9835,7 +9821,7 @@ int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm) · 22 unmodified lines
98359821 * if it's runtime suspended. But ufs doesn't follow that.
98369822 * Refer ufshcd_resume_complete()
98379823 */
9838− if (hba->sdev_ufs_device) {
9824+ if (hba->ufs_device_wlun) {
98399825 /* Prevent runtime suspend */
98409826 ufshcd_rpm_get_noresume(hba);
98419827 /*
@@ -9956,4 +9942,3 @@ MODULE_AUTHOR("Santosh Yaragnavi <santosh.sy@samsung.com>"); · 114 unmodified lines
99569942 MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
99579943 MODULE_DESCRIPTION("Generic UFS host controller driver Core");
99589944 MODULE_LICENSE("GPL");
9959−MODULE_VERSION(UFSHCD_DRIVER_VERSION);
drivers/scsi/ufs/ufshcd.h+80−288
@@ -12,44 +12,18 @@ · 11 unmodified lines
1212 #ifndef _UFSHCD_H
1313 #define _UFSHCD_H
1414
15−#include <linux/module.h>
16−#include <linux/kernel.h>
17−#include <linux/init.h>
18−#include <linux/interrupt.h>
19−#include <linux/io.h>
20−#include <linux/delay.h>
21−#include <linux/slab.h>
22−#include <linux/spinlock.h>
23−#include <linux/rwsem.h>
24−#include <linux/workqueue.h>
25−#include <linux/errno.h>
26−#include <linux/types.h>
27−#include <linux/wait.h>
28−#include <linux/bitops.h>
29−#include <linux/pm_runtime.h>
30−#include <linux/clk.h>
31−#include <linux/completion.h>
32−#include <linux/regulator/consumer.h>
3315 #include <linux/bitfield.h>
34−#include <linux/devfreq.h>
3516 #include <linux/blk-crypto-profile.h>
17+#include <linux/blk-mq.h>
18+#include <linux/devfreq.h>
19+#include <linux/pm_runtime.h>
20+#include <scsi/scsi_device.h>
3621 #include "unipro.h"
37−
38−#include <asm/irq.h>
39−#include <asm/byteorder.h>
40−#include <scsi/scsi.h>
41−#include <scsi/scsi_cmnd.h>
42−#include <scsi/scsi_host.h>
43−#include <scsi/scsi_tcq.h>
44−#include <scsi/scsi_dbg.h>
45−#include <scsi/scsi_eh.h>
46−
4722 #include "ufs.h"
4823 #include "ufs_quirks.h"
4924 #include "ufshci.h"
5025
5126 #define UFSHCD "ufshcd"
52−#define UFSHCD_DRIVER_VERSION "0.2"
5327
5428 struct ufs_hba;
5529
@@ -181,8 +155,6 @@ struct ufs_pm_lvl_states { · 125 unmodified lines
181155 * @ucd_rsp_dma_addr: UPIU response dma address for debug
182156 * @ucd_req_dma_addr: UPIU request dma address for debug
183157 * @cmd: pointer to SCSI command
184− * @sense_buffer: pointer to sense buffer address of the SCSI command
185− * @sense_bufflen: Length of the sense buffer
186158 * @scsi_status: SCSI status of the command
187159 * @command_type: SCSI, UFS, Query.
188160 * @task_tag: Task tag of the command
@@ -206,8 +178,6 @@ struct ufshcd_lrb { · 17 unmodified lines
206178 dma_addr_t ucd_prdt_dma_addr;
207179
208180 struct scsi_cmnd *cmd;
209− u8 *sense_buffer;
210− unsigned int sense_bufflen;
211181 int scsi_status;
212182
213183 int command_type;
@@ -241,6 +211,7 @@ struct ufs_query { · 27 unmodified lines
241211 * @type: device management command type - Query, NOP OUT
242212 * @lock: lock to allow one command at a time
243213 * @complete: internal commands completion
214+ * @query: Device management query information
244215 */
245216 struct ufs_dev_cmd {
246217 enum dev_cmd_type type;
@@ -258,7 +229,7 @@ struct ufs_dev_cmd { · 11 unmodified lines
258229 * @min_freq: min frequency that can be used for clock scaling
259230 * @curr_freq: indicates the current frequency that it is set to
260231 * @keep_link_active: indicates that the clk should not be disabled if
261− link is active
232+ * link is active
262233 * @enabled: variable to check against multiple enable/disable
263234 */
264235 struct ufs_clk_info {
@@ -313,11 +284,13 @@ struct ufs_pwr_mode_info { · 48 unmodified lines
313284 * to set some things
314285 * @hibern8_notify: called around hibern8 enter/exit
315286 * @apply_dev_quirks: called to apply device specific quirks
287+ * @fixup_dev_quirks: called to modify device specific quirks
316288 * @suspend: called during host controller PM callback
317289 * @resume: called during host controller PM callback
318290 * @dbg_register_dump: used to dump controller debug information
319291 * @phy_initialization: used to initialize phys
320292 * @device_reset: called to issue a reset pulse on the UFS device
293+ * @config_scaling_param: called to configure clock scaling parameters
321294 * @program_key: program or evict an inline encryption key
322295 * @event_notify: called to notify important events
323296 */
@@ -352,8 +325,8 @@ struct ufs_hba_variant_ops { · 28 unmodified lines
352325 int (*phy_initialization)(struct ufs_hba *);
353326 int (*device_reset)(struct ufs_hba *hba);
354327 void (*config_scaling_param)(struct ufs_hba *hba,
355− struct devfreq_dev_profile *profile,
356− void *data);
328+ struct devfreq_dev_profile *profile,
329+ struct devfreq_simple_ondemand_data *data);
357330 int (*program_key)(struct ufs_hba *hba,
358331 const union ufs_crypto_cfg_entry *cfg, int slot);
359332 void (*event_notify)(struct ufs_hba *hba,
@@ -384,6 +357,7 @@ enum clk_gating_state { · 24 unmodified lines
384357 * @is_initialized: Indicates whether clock gating is initialized or not
385358 * @active_reqs: number of requests that are pending and should be waited for
386359 * completion before gating clocks.
360+ * @clk_gating_workq: workqueue for clock gating work.
387361 */
388362 struct ufs_clk_gating {
389363 struct delayed_work gate_work;
@@ -420,9 +394,9 @@ struct ufs_saved_pwr_info { · 30 unmodified lines
420394 * @resume_work: worker to resume devfreq
421395 * @min_gear: lowest HS gear to scale down to
422396 * @is_enabled: tracks if scaling is currently enabled or not, controlled by
423− clkscale_enable sysfs node
397+ * clkscale_enable sysfs node
424398 * @is_allowed: tracks if scaling is currently allowed or not, used to block
425− clock scaling which is not invoked from devfreq governor
399+ * clock scaling which is not invoked from devfreq governor
426400 * @is_initialized: Indicates whether clock scaling is initialized or not
427401 * @is_busy_started: tracks if busy period has started or not
428402 * @is_suspended: tracks if devfreq is suspended or not
@@ -449,7 +423,7 @@ struct ufs_clk_scaling { · 20 unmodified lines
449423 /**
450424 * struct ufs_event_hist - keeps history of errors
451425 * @pos: index to indicate cyclic buffer position
452− * @reg: cyclic buffer for registers value
426+ * @val: cyclic buffer for registers value
453427 * @tstamp: cyclic buffer for time stamp
454428 * @cnt: error counter
455429 */
@@ -468,6 +442,7 @@ struct ufs_event_hist { · 12 unmodified lines
468442 * reset this after link-startup.
469443 * @last_hibern8_exit_tstamp: Set time after the hibern8 exit.
470444 * Clear after the first successful command completion.
445+ * @event: array with event history.
471446 */
472447 struct ufs_stats {
473448 u32 last_intr_status;
@@ -737,6 +712,14 @@ struct ufs_hba_monitor { · 263 unmodified lines
737712 * @utmrdl_dma_addr: UTMRDL DMA address
738713 * @host: Scsi_Host instance of the driver
739714 * @dev: device handle
715+ * @ufs_device_wlun: WLUN that controls the entire UFS device.
716+ * @hwmon_device: device instance registered with the hwmon core.
717+ * @curr_dev_pwr_mode: active UFS device power mode.
718+ * @uic_link_state: active state of the link to the UFS device.
719+ * @rpm_lvl: desired UFS power management level during runtime PM.
720+ * @spm_lvl: desired UFS power management level during system PM.
721+ * @pm_op_in_progress: whether or not a PM operation is in progress.
722+ * @ahit: value of Auto-Hibernate Idle Timer register.
740723 * @lrb: local reference block
741724 * @outstanding_tasks: Bits representing outstanding task requests
742725 * @outstanding_lock: Protects @outstanding_reqs.
@@ -747,17 +730,26 @@ struct ufs_hba_monitor { · 4 unmodified lines
747730 * @reserved_slot: Used to submit device commands. Protected by @dev_cmd.lock.
748731 * @ufs_version: UFS Version to which controller complies
749732 * @vops: pointer to variant specific operations
733+ * @vps: pointer to variant specific parameters
750734 * @priv: pointer to variant specific private data
751735 * @irq: Irq number of the controller
752− * @active_uic_cmd: handle of active UIC command
753− * @uic_cmd_mutex: mutex for UIC command
736+ * @is_irq_enabled: whether or not the UFS controller interrupt is enabled.
737+ * @dev_ref_clk_freq: reference clock frequency
738+ * @quirks: bitmask with information about deviations from the UFSHCI standard.
739+ * @dev_quirks: bitmask with information about deviations from the UFS standard.
754740 * @tmf_tag_set: TMF tag set.
755741 * @tmf_queue: Used to allocate TMF tags.
756− * @pwr_done: completion for power mode change
742+ * @tmf_rqs: array with pointers to TMF requests while these are in progress.
743+ * @active_uic_cmd: handle of active UIC command
744+ * @uic_cmd_mutex: mutex for UIC command
745+ * @uic_async_done: completion used during UIC processing
757746 * @ufshcd_state: UFSHCD state
758747 * @eh_flags: Error handling flags
759748 * @intr_mask: Interrupt Mask Bits
760749 * @ee_ctrl_mask: Exception event control mask
750+ * @ee_drv_mask: Exception event mask for driver
751+ * @ee_usr_mask: Exception event mask for user (set via debugfs)
752+ * @ee_ctrl_mutex: Used to serialize exception event information.
761753 * @is_powered: flag to check if HBA is powered
762754 * @shutting_down: flag to check if shutdown has been invoked
763755 * @host_sem: semaphore used to serialize concurrent contexts
@@ -768,26 +760,52 @@ struct ufs_hba_monitor { · 4 unmodified lines
768760 * @uic_error: UFS interconnect layer error status
769761 * @saved_err: sticky error mask
770762 * @saved_uic_err: sticky UIC error mask
763+ * @ufs_stats: various error counters
771764 * @force_reset: flag to force eh_work perform a full reset
772765 * @force_pmc: flag to force a power mode change
773766 * @silence_err_logs: flag to silence error logs
774767 * @dev_cmd: ufs device management command information
775768 * @last_dme_cmd_tstamp: time stamp of the last completed DME command
769+ * @nop_out_timeout: NOP OUT timeout value
770+ * @dev_info: information about the UFS device
776771 * @auto_bkops_enabled: to track whether bkops is enabled in device
777772 * @vreg_info: UFS device voltage regulator information
778773 * @clk_list_head: UFS host controller clocks list node head
774+ * @req_abort_count: number of times ufshcd_abort() has been called
775+ * @lanes_per_direction: number of lanes per data direction between the UFS
776+ * controller and the UFS device.
779777 * @pwr_info: holds current power mode
780778 * @max_pwr_info: keeps the device max valid pwm
781− * @clk_scaling_lock: used to serialize device commands and clock scaling
782− * @desc_size: descriptor sizes reported by device
779+ * @clk_gating: information related to clock gating
780+ * @caps: bitmask with information about UFS controller capabilities
781+ * @devfreq: frequency scaling information owned by the devfreq core
782+ * @clk_scaling: frequency scaling information owned by the UFS driver
783+ * @is_sys_suspended: whether or not the entire system has been suspended
783784 * @urgent_bkops_lvl: keeps track of urgent bkops level for device
784785 * @is_urgent_bkops_lvl_checked: keeps track if the urgent bkops level for
785786 * device is known or not.
787+ * @clk_scaling_lock: used to serialize device commands and clock scaling
788+ * @desc_size: descriptor sizes reported by device
786789 * @scsi_block_reqs_cnt: reference counting for scsi block requests
790+ * @bsg_dev: struct device associated with the BSG queue
791+ * @bsg_queue: BSG queue associated with the UFS controller
792+ * @rpm_dev_flush_recheck_work: used to suspend from RPM (runtime power
793+ * management) after the UFS device has finished a WriteBooster buffer
794+ * flush or auto BKOP.
795+ * @ufshpb_dev: information related to HPB (Host Performance Booster).
796+ * @monitor: statistics about UFS commands
787797 * @crypto_capabilities: Content of crypto capabilities register (0x100)
788798 * @crypto_cap_array: Array of crypto capabilities
789799 * @crypto_cfg_register: Start of the crypto cfg array
790800 * @crypto_profile: the crypto profile of this hba (if applicable)
801+ * @debugfs_root: UFS controller debugfs root directory
802+ * @debugfs_ee_work: used to restore ee_ctrl_mask after a delay
803+ * @debugfs_ee_rate_limit_ms: user configurable delay after which to restore
804+ * ee_ctrl_mask
805+ * @luns_avail: number of regular and well known LUNs supported by the UFS
806+ * device
807+ * @complete_put: whether or not to call ufshcd_rpm_put() from inside
808+ * ufshcd_resume_complete()
791809 */
792810 struct ufs_hba {
793811 void __iomem *mmio_base;
@@ -804,11 +822,7 @@ struct ufs_hba { · 10 unmodified lines
804822
805823 struct Scsi_Host *host;
806824 struct device *dev;
807− /*
808− * This field is to keep a reference to "scsi_device" corresponding to
809− * "UFS device" W-LU.
810− */
811− struct scsi_device *sdev_ufs_device;
825+ struct scsi_device *ufs_device_wlun;
812826
813827 #ifdef CONFIG_SCSI_UFS_HWMON
814828 struct device *hwmon_device;
@@ -859,9 +873,9 @@ struct ufs_hba { · 44 unmodified lines
859873 enum ufshcd_state ufshcd_state;
860874 u32 eh_flags;
861875 u32 intr_mask;
862− u16 ee_ctrl_mask; /* Exception event mask */
863− u16 ee_drv_mask; /* Exception event mask for driver */
864− u16 ee_usr_mask; /* Exception event mask for user (via debugfs) */
876+ u16 ee_ctrl_mask;
877+ u16 ee_drv_mask;
878+ u16 ee_usr_mask;
865879 struct mutex ee_ctrl_mutex;
866880 bool is_powered;
867881 bool shutting_down;
@@ -983,7 +997,7 @@ static inline bool ufshcd_is_auto_hibern8_supported(struct ufs_hba *hba) · 115 unmodified lines
983997
984998 static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba)
985999 {
986− return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit) ? true : false;
1000+ return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit);
9871001 }
9881002
9891003 static inline bool ufshcd_is_wb_allowed(struct ufs_hba *hba)
@@ -991,22 +1005,17 @@ static inline bool ufshcd_is_wb_allowed(struct ufs_hba *hba) · 1 unmodified line
9911005 return hba->caps & UFSHCD_CAP_WB_EN;
9921006 }
9931007
994−static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba)
995−{
996− return !hba->shutting_down;
997−}
998−
9991008 #define ufshcd_writel(hba, val, reg) \
10001009 writel((val), (hba)->mmio_base + (reg))
10011010 #define ufshcd_readl(hba, reg) \
10021011 readl((hba)->mmio_base + (reg))
10031012
10041013 /**
1005− * ufshcd_rmwl - read modify write into a register
1006− * @hba - per adapter instance
1007− * @mask - mask to apply on read value
1008− * @val - actual value to write
1009− * @reg - register address
1014+ * ufshcd_rmwl - perform read/modify/write for a controller register
1015+ * @hba: per adapter instance
1016+ * @mask: mask to apply on read value
1017+ * @val: actual value to write
1018+ * @reg: register address
10101019 */
10111020 static inline void ufshcd_rmwl(struct ufs_hba *hba, u32 mask, u32 val, u32 reg)
10121021 {
@@ -1028,9 +1037,6 @@ void ufshcd_remove(struct ufs_hba *); · 15 unmodified lines
10281037 int ufshcd_uic_hibern8_enter(struct ufs_hba *hba);
10291038 int ufshcd_uic_hibern8_exit(struct ufs_hba *hba);
10301039 void ufshcd_delay_us(unsigned long us, unsigned long tolerance);
1031−int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
1032− u32 val, unsigned long interval_us,
1033− unsigned long timeout_ms);
10341040 void ufshcd_parse_dev_ref_clk_freq(struct ufs_hba *hba, struct clk *refclk);
10351041 void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val);
10361042 void ufshcd_hba_stop(struct ufs_hba *hba);
@@ -1044,8 +1050,8 @@ static inline void check_upiu_size(void) · 7 unmodified lines
10441050
10451051 /**
10461052 * ufshcd_set_variant - set variant specific data to the hba
1047− * @hba - per adapter instance
1048− * @variant - pointer to variant specific data
1053+ * @hba: per adapter instance
1054+ * @variant: pointer to variant specific data
10491055 */
10501056 static inline void ufshcd_set_variant(struct ufs_hba *hba, void *variant)
10511057 {
@@ -1055,35 +1061,13 @@ static inline void ufshcd_set_variant(struct ufs_hba *hba, void *variant) · 3 unmodified lines
10551061
10561062 /**
10571063 * ufshcd_get_variant - get variant specific data from the hba
1058− * @hba - per adapter instance
1064+ * @hba: per adapter instance
10591065 */
10601066 static inline void *ufshcd_get_variant(struct ufs_hba *hba)
10611067 {
10621068 BUG_ON(!hba);
10631069 return hba->priv;
10641070 }
1065−static inline bool ufshcd_keep_autobkops_enabled_except_suspend(
1066− struct ufs_hba *hba)
1067−{
1068− return hba->caps & UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND;
1069−}
1070−
1071−static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba)
1072−{
1073− if (hba->dev_info.wb_buffer_type == WB_BUF_MODE_LU_DEDICATED)
1074− return hba->dev_info.wb_dedicated_lu;
1075− return 0;
1076−}
1077−
1078−#ifdef CONFIG_SCSI_UFS_HWMON
1079−void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask);
1080−void ufs_hwmon_remove(struct ufs_hba *hba);
1081−void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask);
1082−#else
1083−static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {}
1084−static inline void ufs_hwmon_remove(struct ufs_hba *hba) {}
1085−static inline void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask) {}
1086−#endif
10871071
10881072 #ifdef CONFIG_PM
10891073 extern int ufshcd_runtime_suspend(struct device *dev);
@@ -1185,7 +1169,8 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, · 95 unmodified lines
11851169
11861170 void ufshcd_auto_hibern8_enable(struct ufs_hba *hba);
11871171 void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);
1188−void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_fix *fixups);
1172+void ufshcd_fixup_dev_quirks(struct ufs_hba *hba,
1173+ const struct ufs_dev_quirk *fixups);
11891174 #define SD_ASCII_STD true
11901175 #define SD_RAW false
11911176 int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
@@ -1194,6 +1179,8 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, · 2 unmodified lines
11941179 int ufshcd_hold(struct ufs_hba *hba, bool async);
11951180 void ufshcd_release(struct ufs_hba *hba);
11961181
1182+void ufshcd_clkgate_delay_set(struct device *dev, unsigned long value);
1183+
11971184 void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
11981185 int *desc_length);
11991186
@@ -1214,13 +1201,6 @@ int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm); · 14 unmodified lines
12141201 void ufshcd_resume_complete(struct device *dev);
12151202
12161203 /* Wrapper functions for safely calling variant operations */
1217−static inline const char *ufshcd_get_var_name(struct ufs_hba *hba)
1218−{
1219− if (hba->vops)
1220− return hba->vops->name;
1221− return "";
1222−}
1223−
12241204 static inline int ufshcd_vops_init(struct ufs_hba *hba)
12251205 {
12261206 if (hba->vops && hba->vops->init)
@@ -1229,61 +1209,6 @@ static inline int ufshcd_vops_init(struct ufs_hba *hba) · 2 unmodified lines
12291209 return 0;
12301210 }
12311211
1232−static inline void ufshcd_vops_exit(struct ufs_hba *hba)
1233−{
1234− if (hba->vops && hba->vops->exit)
1235− return hba->vops->exit(hba);
1236−}
1237−
1238−static inline u32 ufshcd_vops_get_ufs_hci_version(struct ufs_hba *hba)
1239−{
1240− if (hba->vops && hba->vops->get_ufs_hci_version)
1241− return hba->vops->get_ufs_hci_version(hba);
1242−
1243− return ufshcd_readl(hba, REG_UFS_VERSION);
1244−}
1245−
1246−static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba,
1247− bool up, enum ufs_notify_change_status status)
1248−{
1249− if (hba->vops && hba->vops->clk_scale_notify)
1250− return hba->vops->clk_scale_notify(hba, up, status);
1251− return 0;
1252−}
1253−
1254−static inline void ufshcd_vops_event_notify(struct ufs_hba *hba,
1255− enum ufs_event_type evt,
1256− void *data)
1257−{
1258− if (hba->vops && hba->vops->event_notify)
1259− hba->vops->event_notify(hba, evt, data);
1260−}
1261−
1262−static inline int ufshcd_vops_setup_clocks(struct ufs_hba *hba, bool on,
1263− enum ufs_notify_change_status status)
1264−{
1265− if (hba->vops && hba->vops->setup_clocks)
1266− return hba->vops->setup_clocks(hba, on, status);
1267− return 0;
1268−}
1269−
1270−static inline int ufshcd_vops_hce_enable_notify(struct ufs_hba *hba,
1271− bool status)
1272−{
1273− if (hba->vops && hba->vops->hce_enable_notify)
1274− return hba->vops->hce_enable_notify(hba, status);
1275−
1276− return 0;
1277−}
1278−static inline int ufshcd_vops_link_startup_notify(struct ufs_hba *hba,
1279− bool status)
1280−{
1281− if (hba->vops && hba->vops->link_startup_notify)
1282− return hba->vops->link_startup_notify(hba, status);
1283−
1284− return 0;
1285−}
1286−
12871212 static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba)
12881213 {
12891214 if (hba->vops && hba->vops->phy_initialization)
@@ -1292,102 +1217,8 @@ static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba) · 2 unmodified lines
12921217 return 0;
12931218 }
12941219
1295−static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba,
1296− enum ufs_notify_change_status status,
1297− struct ufs_pa_layer_attr *dev_max_params,
1298− struct ufs_pa_layer_attr *dev_req_params)
1299−{
1300− if (hba->vops && hba->vops->pwr_change_notify)
1301− return hba->vops->pwr_change_notify(hba, status,
1302− dev_max_params, dev_req_params);
1303−
1304− return -ENOTSUPP;
1305−}
1306−
1307−static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba,
1308− int tag, u8 tm_function)
1309−{
1310− if (hba->vops && hba->vops->setup_task_mgmt)
1311− return hba->vops->setup_task_mgmt(hba, tag, tm_function);
1312−}
1313−
1314−static inline void ufshcd_vops_hibern8_notify(struct ufs_hba *hba,
1315− enum uic_cmd_dme cmd,
1316− enum ufs_notify_change_status status)
1317−{
1318− if (hba->vops && hba->vops->hibern8_notify)
1319− return hba->vops->hibern8_notify(hba, cmd, status);
1320−}
1321−
1322−static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba)
1323−{
1324− if (hba->vops && hba->vops->apply_dev_quirks)
1325− return hba->vops->apply_dev_quirks(hba);
1326− return 0;
1327−}
1328−
1329−static inline void ufshcd_vops_fixup_dev_quirks(struct ufs_hba *hba)
1330−{
1331− if (hba->vops && hba->vops->fixup_dev_quirks)
1332− hba->vops->fixup_dev_quirks(hba);
1333−}
1334−
1335−static inline int ufshcd_vops_suspend(struct ufs_hba *hba, enum ufs_pm_op op,
1336− enum ufs_notify_change_status status)
1337−{
1338− if (hba->vops && hba->vops->suspend)
1339− return hba->vops->suspend(hba, op, status);
1340−
1341− return 0;
1342−}
1343−
1344−static inline int ufshcd_vops_resume(struct ufs_hba *hba, enum ufs_pm_op op)
1345−{
1346− if (hba->vops && hba->vops->resume)
1347− return hba->vops->resume(hba, op);
1348−
1349− return 0;
1350−}
1351−
1352−static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba)
1353−{
1354− if (hba->vops && hba->vops->dbg_register_dump)
1355− hba->vops->dbg_register_dump(hba);
1356−}
1357−
1358−static inline int ufshcd_vops_device_reset(struct ufs_hba *hba)
1359−{
1360− if (hba->vops && hba->vops->device_reset)
1361− return hba->vops->device_reset(hba);
1362−
1363− return -EOPNOTSUPP;
1364−}
1365−
1366−static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba,
1367− struct devfreq_dev_profile
1368− *profile, void *data)
1369−{
1370− if (hba->vops && hba->vops->config_scaling_param)
1371− hba->vops->config_scaling_param(hba, profile, data);
1372−}
1373−
13741220 extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];
13751221
1376−/*
1377− * ufshcd_scsi_to_upiu_lun - maps scsi LUN to UPIU LUN
1378− * @scsi_lun: scsi LUN id
1379− *
1380− * Returns UPIU LUN id
1381− */
1382−static inline u8 ufshcd_scsi_to_upiu_lun(unsigned int scsi_lun)
1383−{
1384− if (scsi_is_wlun(scsi_lun))
1385− return (scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID)
1386− | UFS_UPIU_WLUN_ID;
1387− else
1388− return scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID;
1389−}
1390−
13911222 int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len,
13921223 const char *prefix);
13931224
@@ -1396,43 +1227,4 @@ int ufshcd_write_ee_control(struct ufs_hba *hba); · 2 unmodified lines
13961227 int ufshcd_update_ee_control(struct ufs_hba *hba, u16 *mask, u16 *other_mask,
13971228 u16 set, u16 clr);
13981229
1399−static inline int ufshcd_update_ee_drv_mask(struct ufs_hba *hba,
1400− u16 set, u16 clr)
1401−{
1402− return ufshcd_update_ee_control(hba, &hba->ee_drv_mask,
1403− &hba->ee_usr_mask, set, clr);
1404−}
1405−
1406−static inline int ufshcd_update_ee_usr_mask(struct ufs_hba *hba,
1407− u16 set, u16 clr)
1408−{
1409− return ufshcd_update_ee_control(hba, &hba->ee_usr_mask,
1410− &hba->ee_drv_mask, set, clr);
1411−}
1412−
1413−static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba)
1414−{
1415− return pm_runtime_get_sync(&hba->sdev_ufs_device->sdev_gendev);
1416−}
1417−
1418−static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba)
1419−{
1420− return pm_runtime_put_sync(&hba->sdev_ufs_device->sdev_gendev);
1421−}
1422−
1423−static inline void ufshcd_rpm_get_noresume(struct ufs_hba *hba)
1424−{
1425− pm_runtime_get_noresume(&hba->sdev_ufs_device->sdev_gendev);
1426−}
1427−
1428−static inline int ufshcd_rpm_resume(struct ufs_hba *hba)
1429−{
1430− return pm_runtime_resume(&hba->sdev_ufs_device->sdev_gendev);
1431−}
1432−
1433−static inline int ufshcd_rpm_put(struct ufs_hba *hba)
1434−{
1435− return pm_runtime_put(&hba->sdev_ufs_device->sdev_gendev);
1436−}
1437−
14381230 #endif /* End of Header */
drivers/scsi/ufs/ufshci.h+2−0
@@ -11,6 +11,8 @@ · 10 unmodified lines
1111 #ifndef _UFSHCI_H
1212 #define _UFSHCI_H
1313
14+#include <scsi/scsi_host.h>
15+
1416 enum {
1517 TASK_REQ_UPIU_SIZE_DWORDS = 8,
1618 TASK_RSP_UPIU_SIZE_DWORDS = 8,
drivers/scsi/ufs/ufshpb.c+112−91
@@ -10,8 +10,12 @@ · 9 unmodified lines
1010 */
1111
1212 #include <asm/unaligned.h>
13+#include <linux/delay.h>
14+#include <linux/device.h>
15+#include <linux/module.h>
16+#include <scsi/scsi_cmnd.h>
1317
14−#include "ufshcd.h"
18+#include "ufshcd-priv.h"
1519 #include "ufshpb.h"
1620 #include "../sd.h"
1721
@@ -90,12 +94,8 @@ static bool ufshpb_is_general_lun(int lun) · 72 unmodified lines
9094
9195 static bool ufshpb_is_pinned_region(struct ufshpb_lu *hpb, int rgn_idx)
9296 {
93− if (hpb->lu_pinned_end != PINNED_NOT_SET &&
94− rgn_idx >= hpb->lu_pinned_start &&
95− rgn_idx <= hpb->lu_pinned_end)
96− return true;
97−
98− return false;
97+ return hpb->lu_pinned_end != PINNED_NOT_SET &&
98+ rgn_idx >= hpb->lu_pinned_start && rgn_idx <= hpb->lu_pinned_end;
9999 }
100100
101101 static void ufshpb_kick_map_work(struct ufshpb_lu *hpb)
@@ -563,7 +563,7 @@ static void ufshpb_update_active_info(struct ufshpb_lu *hpb, int rgn_idx, · 461 unmodified lines
563563 if (list_empty(&srgn->list_act_srgn))
564564 list_add_tail(&srgn->list_act_srgn, &hpb->lh_act_srgn);
565565
566− hpb->stats.rb_active_cnt++;
566+ hpb->stats.rcmd_active_cnt++;
567567 }
568568
569569 static void ufshpb_update_inactive_info(struct ufshpb_lu *hpb, int rgn_idx)
@@ -580,7 +580,7 @@ static void ufshpb_update_inactive_info(struct ufshpb_lu *hpb, int rgn_idx) · 10 unmodified lines
580580 if (list_empty(&rgn->list_inact_rgn))
581581 list_add_tail(&rgn->list_inact_rgn, &hpb->lh_inact_rgn);
582582
583− hpb->stats.rb_inactive_cnt++;
583+ hpb->stats.rcmd_inactive_cnt++;
584584 }
585585
586586 static void ufshpb_activate_subregion(struct ufshpb_lu *hpb,
@@ -930,11 +930,6 @@ static int ufshpb_issue_umap_single_req(struct ufshpb_lu *hpb, · 343 unmodified lines
930930 return ufshpb_issue_umap_req(hpb, rgn, true);
931931 }
932932
933−static int ufshpb_issue_umap_all_req(struct ufshpb_lu *hpb)
934−{
935− return ufshpb_issue_umap_req(hpb, NULL, false);
936−}
937−
938933 static void __ufshpb_evict_region(struct ufshpb_lu *hpb,
939934 struct ufshpb_region *rgn)
940935 {
@@ -1142,6 +1137,39 @@ out: · 201 unmodified lines
11421137 spin_unlock_irqrestore(&hpb->rgn_state_lock, flags);
11431138 return ret;
11441139 }
1140+/**
1141+ *ufshpb_submit_region_inactive() - submit a region to be inactivated later
1142+ *@hpb: per-LU HPB instance
1143+ *@region_index: the index associated with the region that will be inactivated later
1144+ */
1145+static void ufshpb_submit_region_inactive(struct ufshpb_lu *hpb, int region_index)
1146+{
1147+ int subregion_index;
1148+ struct ufshpb_region *rgn;
1149+ struct ufshpb_subregion *srgn;
1150+
1151+ /*
1152+ * Remove this region from active region list and add it to inactive list
1153+ */
1154+ spin_lock(&hpb->rsp_list_lock);
1155+ ufshpb_update_inactive_info(hpb, region_index);
1156+ spin_unlock(&hpb->rsp_list_lock);
1157+
1158+ rgn = hpb->rgn_tbl + region_index;
1159+
1160+ /*
1161+ * Set subregion state to be HPB_SRGN_INVALID, there will no HPB read on this subregion
1162+ */
1163+ spin_lock(&hpb->rgn_state_lock);
1164+ if (rgn->rgn_state != HPB_RGN_INACTIVE) {
1165+ for (subregion_index = 0; subregion_index < rgn->srgn_cnt; subregion_index++) {
1166+ srgn = rgn->srgn_tbl + subregion_index;
1167+ if (srgn->srgn_state == HPB_SRGN_VALID)
1168+ srgn->srgn_state = HPB_SRGN_INVALID;
1169+ }
1170+ }
1171+ spin_unlock(&hpb->rgn_state_lock);
1172+}
11451173
11461174 static void ufshpb_rsp_req_region_update(struct ufshpb_lu *hpb,
11471175 struct utp_hpb_rsp *rsp_field)
@@ -1201,25 +1229,8 @@ static void ufshpb_rsp_req_region_update(struct ufshpb_lu *hpb, · 53 unmodified lines
12011229
12021230 for (i = 0; i < rsp_field->inactive_rgn_cnt; i++) {
12031231 rgn_i = be16_to_cpu(rsp_field->hpb_inactive_field[i]);
1204− dev_dbg(&hpb->sdev_ufs_lu->sdev_dev,
1205− "inactivate(%d) region %d\n", i, rgn_i);
1206−
1207− spin_lock(&hpb->rsp_list_lock);
1208− ufshpb_update_inactive_info(hpb, rgn_i);
1209− spin_unlock(&hpb->rsp_list_lock);
1210−
1211− rgn = hpb->rgn_tbl + rgn_i;
1212−
1213− spin_lock(&hpb->rgn_state_lock);
1214− if (rgn->rgn_state != HPB_RGN_INACTIVE) {
1215− for (srgn_i = 0; srgn_i < rgn->srgn_cnt; srgn_i++) {
1216− srgn = rgn->srgn_tbl + srgn_i;
1217− if (srgn->srgn_state == HPB_SRGN_VALID)
1218− srgn->srgn_state = HPB_SRGN_INVALID;
1219− }
1220− }
1221− spin_unlock(&hpb->rgn_state_lock);
1222−
1232+ dev_dbg(&hpb->sdev_ufs_lu->sdev_dev, "inactivate(%d) region %d\n", i, rgn_i);
1233+ ufshpb_submit_region_inactive(hpb, rgn_i);
12231234 }
12241235
12251236 out:
@@ -1230,7 +1241,10 @@ out: · 4 unmodified lines
12301241 queue_work(ufshpb_wq, &hpb->map_work);
12311242 }
12321243
1233−static void ufshpb_dev_reset_handler(struct ufshpb_lu *hpb)
1244+/*
1245+ * Set the flags of all active regions to RGN_FLAG_UPDATE to let host side reload L2P entries later
1246+ */
1247+static void ufshpb_set_regions_update(struct ufshpb_lu *hpb)
12341248 {
12351249 struct victim_select_info *lru_info = &hpb->lru_info;
12361250 struct ufshpb_region *rgn;
@@ -1244,6 +1258,42 @@ static void ufshpb_dev_reset_handler(struct ufshpb_lu *hpb) · 7 unmodified lines
12441258 spin_unlock_irqrestore(&hpb->rgn_state_lock, flags);
12451259 }
12461260
1261+static void ufshpb_dev_reset_handler(struct ufs_hba *hba)
1262+{
1263+ struct scsi_device *sdev;
1264+ struct ufshpb_lu *hpb;
1265+
1266+ __shost_for_each_device(sdev, hba->host) {
1267+ hpb = ufshpb_get_hpb_data(sdev);
1268+ if (!hpb)
1269+ continue;
1270+
1271+ if (hpb->is_hcm) {
1272+ /*
1273+ * For the HPB host control mode, in case device powered up and lost HPB
1274+ * information, we will set the region flag to be RGN_FLAG_UPDATE, it will
1275+ * let host reload its L2P entries(reactivate region in the UFS device).
1276+ */
1277+ ufshpb_set_regions_update(hpb);
1278+ } else {
1279+ /*
1280+ * For the HPB device control mode, if host side receives 02h:HPB Operation
1281+ * in UPIU response, which means device recommends the host side should
1282+ * inactivate all active regions. Here we add all active regions to inactive
1283+ * list, they will be inactivated later in ufshpb_map_work_handler().
1284+ */
1285+ struct victim_select_info *lru_info = &hpb->lru_info;
1286+ struct ufshpb_region *rgn;
1287+
1288+ list_for_each_entry(rgn, &lru_info->lh_lru_rgn, list_lru_rgn)
1289+ ufshpb_submit_region_inactive(hpb, rgn->rgn_idx);
1290+
1291+ if (ufshpb_get_state(hpb) == HPB_PRESENT)
1292+ queue_work(ufshpb_wq, &hpb->map_work);
1293+ }
1294+ }
1295+}
1296+
12471297 /*
12481298 * This function will parse recommended active subregion information in sense
12491299 * data field of response UPIU with SAM_STAT_GOOD state.
@@ -1300,7 +1350,7 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) · 50 unmodified lines
13001350 if (!ufshpb_is_hpb_rsp_valid(hba, lrbp, rsp_field))
13011351 return;
13021352
1303− hpb->stats.rb_noti_cnt++;
1353+ hpb->stats.rcmd_noti_cnt++;
13041354
13051355 switch (rsp_field->hpb_op) {
13061356 case HPB_RSP_REQ_REGION_UPDATE:
@@ -1313,17 +1363,7 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) · 6 unmodified lines
13131363 case HPB_RSP_DEV_RESET:
13141364 dev_warn(&hpb->sdev_ufs_lu->sdev_dev,
13151365 "UFS device lost HPB information during PM.\n");
1316−
1317− if (hpb->is_hcm) {
1318− struct scsi_device *sdev;
1319−
1320− __shost_for_each_device(sdev, hba->host) {
1321− struct ufshpb_lu *h = sdev->hostdata;
1322−
1323− if (h)
1324− ufshpb_dev_reset_handler(h);
1325− }
1326− }
1366+ ufshpb_dev_reset_handler(hba);
13271367
13281368 break;
13291369 default:
@@ -1713,18 +1753,18 @@ static DEVICE_ATTR_RO(__name) · 383 unmodified lines
17131753
17141754 ufshpb_sysfs_attr_show_func(hit_cnt);
17151755 ufshpb_sysfs_attr_show_func(miss_cnt);
1716−ufshpb_sysfs_attr_show_func(rb_noti_cnt);
1717−ufshpb_sysfs_attr_show_func(rb_active_cnt);
1718−ufshpb_sysfs_attr_show_func(rb_inactive_cnt);
1756+ufshpb_sysfs_attr_show_func(rcmd_noti_cnt);
1757+ufshpb_sysfs_attr_show_func(rcmd_active_cnt);
1758+ufshpb_sysfs_attr_show_func(rcmd_inactive_cnt);
17191759 ufshpb_sysfs_attr_show_func(map_req_cnt);
17201760 ufshpb_sysfs_attr_show_func(umap_req_cnt);
17211761
17221762 static struct attribute *hpb_dev_stat_attrs[] = {
17231763 &dev_attr_hit_cnt.attr,
17241764 &dev_attr_miss_cnt.attr,
1725− &dev_attr_rb_noti_cnt.attr,
1726− &dev_attr_rb_active_cnt.attr,
1727− &dev_attr_rb_inactive_cnt.attr,
1765+ &dev_attr_rcmd_noti_cnt.attr,
1766+ &dev_attr_rcmd_active_cnt.attr,
1767+ &dev_attr_rcmd_inactive_cnt.attr,
17281768 &dev_attr_map_req_cnt.attr,
17291769 &dev_attr_umap_req_cnt.attr,
17301770 NULL,
@@ -2087,9 +2127,9 @@ static void ufshpb_stat_init(struct ufshpb_lu *hpb) · 356 unmodified lines
20872127 {
20882128 hpb->stats.hit_cnt = 0;
20892129 hpb->stats.miss_cnt = 0;
2090− hpb->stats.rb_noti_cnt = 0;
2091− hpb->stats.rb_active_cnt = 0;
2092− hpb->stats.rb_inactive_cnt = 0;
2130+ hpb->stats.rcmd_noti_cnt = 0;
2131+ hpb->stats.rcmd_active_cnt = 0;
2132+ hpb->stats.rcmd_inactive_cnt = 0;
20932133 hpb->stats.map_req_cnt = 0;
20942134 hpb->stats.umap_req_cnt = 0;
20952135 }
@@ -2272,38 +2312,28 @@ out: · 176 unmodified lines
22722312 return flag_res;
22732313 }
22742314
2275−void ufshpb_reset(struct ufs_hba *hba)
2315+/**
2316+ * ufshpb_toggle_state - switch HPB state of all LUs
2317+ * @hba: per-adapter instance
2318+ * @src: expected current HPB state
2319+ * @dest: target HPB state to switch to
2320+ */
2321+void ufshpb_toggle_state(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest)
22762322 {
22772323 struct ufshpb_lu *hpb;
22782324 struct scsi_device *sdev;
22792325
22802326 shost_for_each_device(sdev, hba->host) {
22812327 hpb = ufshpb_get_hpb_data(sdev);
2282− if (!hpb)
2283− continue;
22842328
2285− if (ufshpb_get_state(hpb) != HPB_RESET)
2329+ if (!hpb || ufshpb_get_state(hpb) != src)
22862330 continue;
2331+ ufshpb_set_state(hpb, dest);
22872332
2288− ufshpb_set_state(hpb, HPB_PRESENT);
2289− }
2290−}
2291−
2292−void ufshpb_reset_host(struct ufs_hba *hba)
2293−{
2294− struct ufshpb_lu *hpb;
2295− struct scsi_device *sdev;
2296−
2297− shost_for_each_device(sdev, hba->host) {
2298− hpb = ufshpb_get_hpb_data(sdev);
2299− if (!hpb)
2300− continue;
2301−
2302− if (ufshpb_get_state(hpb) != HPB_PRESENT)
2303− continue;
2304− ufshpb_set_state(hpb, HPB_RESET);
2305− ufshpb_cancel_jobs(hpb);
2306− ufshpb_discard_rsp_lists(hpb);
2333+ if (dest == HPB_RESET) {
2334+ ufshpb_cancel_jobs(hpb);
2335+ ufshpb_discard_rsp_lists(hpb);
2336+ }
23072337 }
23082338 }
23092339
@@ -2314,11 +2344,9 @@ void ufshpb_suspend(struct ufs_hba *hba) · 4 unmodified lines
23142344
23152345 shost_for_each_device(sdev, hba->host) {
23162346 hpb = ufshpb_get_hpb_data(sdev);
2317− if (!hpb)
2347+ if (!hpb || ufshpb_get_state(hpb) != HPB_PRESENT)
23182348 continue;
23192349
2320− if (ufshpb_get_state(hpb) != HPB_PRESENT)
2321− continue;
23222350 ufshpb_set_state(hpb, HPB_SUSPEND);
23232351 ufshpb_cancel_jobs(hpb);
23242352 }
@@ -2331,20 +2359,15 @@ void ufshpb_resume(struct ufs_hba *hba) · 6 unmodified lines
23312359
23322360 shost_for_each_device(sdev, hba->host) {
23332361 hpb = ufshpb_get_hpb_data(sdev);
2334− if (!hpb)
2362+ if (!hpb || ufshpb_get_state(hpb) != HPB_SUSPEND)
23352363 continue;
23362364
2337− if ((ufshpb_get_state(hpb) != HPB_PRESENT) &&
2338− (ufshpb_get_state(hpb) != HPB_SUSPEND))
2339− continue;
23402365 ufshpb_set_state(hpb, HPB_PRESENT);
23412366 ufshpb_kick_map_work(hpb);
23422367 if (hpb->is_hcm) {
2343− unsigned int poll =
2344− hpb->params.timeout_polling_interval_ms;
2368+ unsigned int poll = hpb->params.timeout_polling_interval_ms;
23452369
2346− schedule_delayed_work(&hpb->ufshpb_read_to_work,
2347− msecs_to_jiffies(poll));
2370+ schedule_delayed_work(&hpb->ufshpb_read_to_work, msecs_to_jiffies(poll));
23482371 }
23492372 }
23502373 }
@@ -2450,8 +2473,6 @@ static void ufshpb_hpb_lu_prepared(struct ufs_hba *hba) · 99 unmodified lines
24502473 ufshpb_set_state(hpb, HPB_PRESENT);
24512474 if ((hpb->lu_pinned_end - hpb->lu_pinned_start) > 0)
24522475 queue_work(ufshpb_wq, &hpb->map_work);
2453− if (!hpb->is_hcm)
2454− ufshpb_issue_umap_all_req(hpb);
24552476 } else {
24562477 dev_err(hba->dev, "destroy HPB lu %d\n", hpb->lun);
24572478 ufshpb_destroy_lu(hba, sdev);
drivers/scsi/ufs/ufshpb.h+7−9
@@ -59,8 +59,8 @@ enum UFSHPB_MODE { · 58 unmodified lines
5959 };
6060
6161 enum UFSHPB_STATE {
62− HPB_INIT = 0,
63− HPB_PRESENT = 1,
62+ HPB_INIT,
63+ HPB_PRESENT,
6464 HPB_SUSPEND,
6565 HPB_FAILED,
6666 HPB_RESET,
@@ -211,9 +211,9 @@ struct ufshpb_params { · 144 unmodified lines
211211 struct ufshpb_stats {
212212 u64 hit_cnt;
213213 u64 miss_cnt;
214− u64 rb_noti_cnt;
215− u64 rb_active_cnt;
216− u64 rb_inactive_cnt;
214+ u64 rcmd_noti_cnt;
215+ u64 rcmd_active_cnt;
216+ u64 rcmd_inactive_cnt;
217217 u64 map_req_cnt;
218218 u64 pre_req_cnt;
219219 u64 umap_req_cnt;
@@ -288,8 +288,7 @@ static int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { return 0; · 68 unmodified lines
288288 static void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) {}
289289 static void ufshpb_resume(struct ufs_hba *hba) {}
290290 static void ufshpb_suspend(struct ufs_hba *hba) {}
291−static void ufshpb_reset(struct ufs_hba *hba) {}
292−static void ufshpb_reset_host(struct ufs_hba *hba) {}
291+static void ufshpb_toggle_state(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest) {}
293292 static void ufshpb_init(struct ufs_hba *hba) {}
294293 static void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev) {}
295294 static void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev) {}
@@ -303,8 +302,7 @@ int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp); · 7 unmodified lines
303302 void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp);
304303 void ufshpb_resume(struct ufs_hba *hba);
305304 void ufshpb_suspend(struct ufs_hba *hba);
306−void ufshpb_reset(struct ufs_hba *hba);
307−void ufshpb_reset_host(struct ufs_hba *hba);
305+void ufshpb_toggle_state(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest);
308306 void ufshpb_init(struct ufs_hba *hba);
309307 void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev);
310308 void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev);
drivers/scsi/ufs/unipro.h+1−17
@@ -1,7 +1,5 @@
11 /* SPDX-License-Identifier: GPL-2.0-or-later */
22 /*
3− * drivers/scsi/ufs/unipro.h
4− *
53 * Copyright (C) 2013 Samsung Electronics Co., Ltd.
64 */
75
@@ -103,7 +101,7 @@ · 95 unmodified lines
103101 #define UNIPRO_CB_OFFSET(x) (0x8000 | x)
104102
105103 /*
106− * PHY Adpater attributes
104+ * PHY Adapter attributes
107105 */
108106 #define PA_ACTIVETXDATALANES 0x1560
109107 #define PA_ACTIVERXDATALANES 0x1580
@@ -300,20 +298,6 @@ enum ufs_unipro_ver { · 190 unmodified lines
300298 #define T_TC0TXMAXSDUSIZE 0x4060
301299 #define T_TC1TXMAXSDUSIZE 0x4061
302300
303−#ifdef FALSE
304−#undef FALSE
305−#endif
306−
307−#ifdef TRUE
308−#undef TRUE
309−#endif
310−
311−/* Boolean attribute values */
312−enum {
313− FALSE = 0,
314− TRUE,
315−};
316−
317301 /* CPort setting */
318302 #define E2EFC_ON (1 << 0)
319303 #define E2EFC_OFF (0 << 0)
drivers/scsi/vmw_pvscsi.c+0−1
@@ -1324,7 +1324,6 @@ static u32 pvscsi_get_max_targets(struct pvscsi_adapter *adapter) · 1323 unmodified lines
13241324 * indicate success.
13251325 */
13261326 header = config_page;
1327− memset(header, 0, sizeof *header);
13281327 header->hostStatus = BTSTAT_INVPARAM;
13291328 header->scsiStatus = SDSTAT_CHECK;
13301329
drivers/target/iscsi/cxgbit/cxgbit.h+11−11
@@ -189,7 +189,7 @@ struct cxgbit_np { · 188 unmodified lines
189189 struct cxgbit_sock {
190190 struct cxgbit_sock_common com;
191191 struct cxgbit_np *cnp;
192− struct iscsi_conn *conn;
192+ struct iscsit_conn *conn;
193193 struct l2t_entry *l2t;
194194 struct dst_entry *dst;
195195 struct list_head list;
@@ -316,32 +316,32 @@ typedef void (*cxgbit_cplhandler_func)(struct cxgbit_device *, · 120 unmodified lines
316316
317317 int cxgbit_setup_np(struct iscsi_np *, struct sockaddr_storage *);
318318 int cxgbit_setup_conn_digest(struct cxgbit_sock *);
319−int cxgbit_accept_np(struct iscsi_np *, struct iscsi_conn *);
319+int cxgbit_accept_np(struct iscsi_np *, struct iscsit_conn *);
320320 void cxgbit_free_np(struct iscsi_np *);
321321 void cxgbit_abort_conn(struct cxgbit_sock *csk);
322−void cxgbit_free_conn(struct iscsi_conn *);
322+void cxgbit_free_conn(struct iscsit_conn *);
323323 extern cxgbit_cplhandler_func cxgbit_cplhandlers[NUM_CPL_CMDS];
324−int cxgbit_get_login_rx(struct iscsi_conn *, struct iscsi_login *);
324+int cxgbit_get_login_rx(struct iscsit_conn *, struct iscsi_login *);
325325 int cxgbit_rx_data_ack(struct cxgbit_sock *);
326326 int cxgbit_l2t_send(struct cxgbit_device *, struct sk_buff *,
327327 struct l2t_entry *);
328328 void cxgbit_push_tx_frames(struct cxgbit_sock *);
329−int cxgbit_put_login_tx(struct iscsi_conn *, struct iscsi_login *, u32);
330−int cxgbit_xmit_pdu(struct iscsi_conn *, struct iscsi_cmd *,
329+int cxgbit_put_login_tx(struct iscsit_conn *, struct iscsi_login *, u32);
330+int cxgbit_xmit_pdu(struct iscsit_conn *, struct iscsit_cmd *,
331331 struct iscsi_datain_req *, const void *, u32);
332−void cxgbit_get_r2t_ttt(struct iscsi_conn *, struct iscsi_cmd *,
332+void cxgbit_get_r2t_ttt(struct iscsit_conn *, struct iscsit_cmd *,
333333 struct iscsi_r2t *);
334334 u32 cxgbit_send_tx_flowc_wr(struct cxgbit_sock *);
335335 int cxgbit_ofld_send(struct cxgbit_device *, struct sk_buff *);
336−void cxgbit_get_rx_pdu(struct iscsi_conn *);
337−int cxgbit_validate_params(struct iscsi_conn *);
336+void cxgbit_get_rx_pdu(struct iscsit_conn *);
337+int cxgbit_validate_params(struct iscsit_conn *);
338338 struct cxgbit_device *cxgbit_find_device(struct net_device *, u8 *);
339339
340340 /* DDP */
341341 int cxgbit_ddp_init(struct cxgbit_device *);
342342 int cxgbit_setup_conn_pgidx(struct cxgbit_sock *, u32);
343−int cxgbit_reserve_ttt(struct cxgbit_sock *, struct iscsi_cmd *);
344−void cxgbit_unmap_cmd(struct iscsi_conn *, struct iscsi_cmd *);
343+int cxgbit_reserve_ttt(struct cxgbit_sock *, struct iscsit_cmd *);
344+void cxgbit_unmap_cmd(struct iscsit_conn *, struct iscsit_cmd *);
345345
346346 static inline
347347 struct cxgbi_ppm *cdev2ppm(struct cxgbit_device *cdev)
drivers/target/iscsi/cxgbit/cxgbit_cm.c+4−4
@@ -465,7 +465,7 @@ int cxgbit_setup_np(struct iscsi_np *np, struct sockaddr_storage *ksockaddr) · 464 unmodified lines
465465 }
466466
467467 static void
468−cxgbit_set_conn_info(struct iscsi_np *np, struct iscsi_conn *conn,
468+cxgbit_set_conn_info(struct iscsi_np *np, struct iscsit_conn *conn,
469469 struct cxgbit_sock *csk)
470470 {
471471 conn->login_family = np->np_sockaddr.ss_family;
@@ -473,7 +473,7 @@ cxgbit_set_conn_info(struct iscsi_np *np, struct iscsi_conn *conn, · 1 unmodified line
473473 conn->local_sockaddr = csk->com.local_addr;
474474 }
475475
476−int cxgbit_accept_np(struct iscsi_np *np, struct iscsi_conn *conn)
476+int cxgbit_accept_np(struct iscsi_np *np, struct iscsit_conn *conn)
477477 {
478478 struct cxgbit_np *cnp = np->np_context;
479479 struct cxgbit_sock *csk;
@@ -717,7 +717,7 @@ void cxgbit_abort_conn(struct cxgbit_sock *csk) · 237 unmodified lines
717717
718718 static void __cxgbit_free_conn(struct cxgbit_sock *csk)
719719 {
720− struct iscsi_conn *conn = csk->conn;
720+ struct iscsit_conn *conn = csk->conn;
721721 bool release = false;
722722
723723 pr_debug("%s: state %d\n",
@@ -751,7 +751,7 @@ static void __cxgbit_free_conn(struct cxgbit_sock *csk) · 27 unmodified lines
751751 cxgbit_put_csk(csk);
752752 }
753753
754−void cxgbit_free_conn(struct iscsi_conn *conn)
754+void cxgbit_free_conn(struct iscsit_conn *conn)
755755 {
756756 __cxgbit_free_conn(conn->context);
757757 }
drivers/target/iscsi/cxgbit/cxgbit_ddp.c+2−2
@@ -227,7 +227,7 @@ rel_ppods: · 226 unmodified lines
227227 }
228228
229229 void
230−cxgbit_get_r2t_ttt(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
230+cxgbit_get_r2t_ttt(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
231231 struct iscsi_r2t *r2t)
232232 {
233233 struct cxgbit_sock *csk = conn->context;
@@ -260,7 +260,7 @@ out: · 26 unmodified lines
260260 r2t->targ_xfer_tag = ttinfo->tag;
261261 }
262262
263−void cxgbit_unmap_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
263+void cxgbit_unmap_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd)
264264 {
265265 struct cxgbit_cmd *ccmd = iscsit_priv_cmd(cmd);
266266
drivers/target/iscsi/cxgbit/cxgbit_main.c+1−1
@@ -657,7 +657,7 @@ cxgbit_dcbevent_notify(struct notifier_block *nb, unsigned long action, · 656 unmodified lines
657657 }
658658 #endif
659659
660−static enum target_prot_op cxgbit_get_sup_prot_ops(struct iscsi_conn *conn)
660+static enum target_prot_op cxgbit_get_sup_prot_ops(struct iscsit_conn *conn)
661661 {
662662 return TARGET_PROT_NORMAL;
663663 }
drivers/target/iscsi/cxgbit/cxgbit_target.c+36−36
@@ -337,7 +337,7 @@ unlock: · 336 unmodified lines
337337 }
338338
339339 static int
340−cxgbit_map_skb(struct iscsi_cmd *cmd, struct sk_buff *skb, u32 data_offset,
340+cxgbit_map_skb(struct iscsit_cmd *cmd, struct sk_buff *skb, u32 data_offset,
341341 u32 data_length)
342342 {
343343 u32 i = 0, nr_frags = MAX_SKB_FRAGS;
@@ -390,10 +390,10 @@ cxgbit_map_skb(struct iscsi_cmd *cmd, struct sk_buff *skb, u32 data_offset, · 46 unmodified lines
390390 }
391391
392392 static int
393−cxgbit_tx_datain_iso(struct cxgbit_sock *csk, struct iscsi_cmd *cmd,
393+cxgbit_tx_datain_iso(struct cxgbit_sock *csk, struct iscsit_cmd *cmd,
394394 struct iscsi_datain_req *dr)
395395 {
396− struct iscsi_conn *conn = csk->conn;
396+ struct iscsit_conn *conn = csk->conn;
397397 struct sk_buff *skb;
398398 struct iscsi_datain datain;
399399 struct cxgbit_iso_info iso_info;
@@ -481,7 +481,7 @@ out: · 81 unmodified lines
481481 }
482482
483483 static int
484−cxgbit_tx_datain(struct cxgbit_sock *csk, struct iscsi_cmd *cmd,
484+cxgbit_tx_datain(struct cxgbit_sock *csk, struct iscsit_cmd *cmd,
485485 const struct iscsi_datain *datain)
486486 {
487487 struct sk_buff *skb;
@@ -510,7 +510,7 @@ cxgbit_tx_datain(struct cxgbit_sock *csk, struct iscsi_cmd *cmd, · 22 unmodified lines
510510 }
511511
512512 static int
513−cxgbit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
513+cxgbit_xmit_datain_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
514514 struct iscsi_datain_req *dr,
515515 const struct iscsi_datain *datain)
516516 {
@@ -530,7 +530,7 @@ cxgbit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 13 unmodified lines
530530 }
531531
532532 static int
533−cxgbit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
533+cxgbit_xmit_nondatain_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
534534 const void *data_buf, u32 data_buf_len)
535535 {
536536 struct cxgbit_sock *csk = conn->context;
@@ -560,7 +560,7 @@ cxgbit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 23 unmodified lines
560560 }
561561
562562 int
563−cxgbit_xmit_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
563+cxgbit_xmit_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
564564 struct iscsi_datain_req *dr, const void *buf, u32 buf_len)
565565 {
566566 if (dr)
@@ -569,7 +569,7 @@ cxgbit_xmit_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 2 unmodified lines
569569 return cxgbit_xmit_nondatain_pdu(conn, cmd, buf, buf_len);
570570 }
571571
572−int cxgbit_validate_params(struct iscsi_conn *conn)
572+int cxgbit_validate_params(struct iscsit_conn *conn)
573573 {
574574 struct cxgbit_sock *csk = conn->context;
575575 struct cxgbit_device *cdev = csk->com.cdev;
@@ -595,7 +595,7 @@ int cxgbit_validate_params(struct iscsi_conn *conn) · 19 unmodified lines
595595
596596 static int cxgbit_set_digest(struct cxgbit_sock *csk)
597597 {
598− struct iscsi_conn *conn = csk->conn;
598+ struct iscsit_conn *conn = csk->conn;
599599 struct iscsi_param *param;
600600
601601 param = iscsi_find_param_from_key(HEADERDIGEST, conn->param_list);
@@ -627,7 +627,7 @@ static int cxgbit_set_digest(struct cxgbit_sock *csk) · 25 unmodified lines
627627
628628 static int cxgbit_set_iso_npdu(struct cxgbit_sock *csk)
629629 {
630− struct iscsi_conn *conn = csk->conn;
630+ struct iscsit_conn *conn = csk->conn;
631631 struct iscsi_conn_ops *conn_ops = conn->conn_ops;
632632 struct iscsi_param *param;
633633 u32 mrdsl, mbl;
@@ -678,7 +678,7 @@ static int cxgbit_set_iso_npdu(struct cxgbit_sock *csk) · 44 unmodified lines
678678 */
679679 static int cxgbit_seq_pdu_inorder(struct cxgbit_sock *csk)
680680 {
681− struct iscsi_conn *conn = csk->conn;
681+ struct iscsit_conn *conn = csk->conn;
682682 struct iscsi_param *param;
683683
684684 if (conn->login->leading_connection) {
@@ -712,7 +712,7 @@ static int cxgbit_seq_pdu_inorder(struct cxgbit_sock *csk) · 27 unmodified lines
712712 return 0;
713713 }
714714
715−static int cxgbit_set_params(struct iscsi_conn *conn)
715+static int cxgbit_set_params(struct iscsit_conn *conn)
716716 {
717717 struct cxgbit_sock *csk = conn->context;
718718 struct cxgbit_device *cdev = csk->com.cdev;
@@ -771,7 +771,7 @@ enable_ddp: · 52 unmodified lines
771771 }
772772
773773 int
774−cxgbit_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login,
774+cxgbit_put_login_tx(struct iscsit_conn *conn, struct iscsi_login *login,
775775 u32 length)
776776 {
777777 struct cxgbit_sock *csk = conn->context;
@@ -832,16 +832,16 @@ cxgbit_skb_copy_to_sg(struct sk_buff *skb, struct scatterlist *sg, · 54 unmodified lines
832832 }
833833 }
834834
835−static struct iscsi_cmd *cxgbit_allocate_cmd(struct cxgbit_sock *csk)
835+static struct iscsit_cmd *cxgbit_allocate_cmd(struct cxgbit_sock *csk)
836836 {
837− struct iscsi_conn *conn = csk->conn;
837+ struct iscsit_conn *conn = csk->conn;
838838 struct cxgbi_ppm *ppm = cdev2ppm(csk->com.cdev);
839839 struct cxgbit_cmd *ccmd;
840− struct iscsi_cmd *cmd;
840+ struct iscsit_cmd *cmd;
841841
842842 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);
843843 if (!cmd) {
844− pr_err("Unable to allocate iscsi_cmd + cxgbit_cmd\n");
844+ pr_err("Unable to allocate iscsit_cmd + cxgbit_cmd\n");
845845 return NULL;
846846 }
847847
@@ -853,10 +853,10 @@ static struct iscsi_cmd *cxgbit_allocate_cmd(struct cxgbit_sock *csk) · 5 unmodified lines
853853 }
854854
855855 static int
856−cxgbit_handle_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr,
856+cxgbit_handle_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr,
857857 u32 length)
858858 {
859− struct iscsi_conn *conn = cmd->conn;
859+ struct iscsit_conn *conn = cmd->conn;
860860 struct cxgbit_sock *csk = conn->context;
861861 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
862862
@@ -910,10 +910,10 @@ cxgbit_handle_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr, · 47 unmodified lines
910910 }
911911
912912 static int
913−cxgbit_get_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr,
913+cxgbit_get_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr,
914914 bool dump_payload)
915915 {
916− struct iscsi_conn *conn = cmd->conn;
916+ struct iscsit_conn *conn = cmd->conn;
917917 int cmdsn_ret = 0, immed_ret = IMMEDIATE_DATA_NORMAL_OPERATION;
918918 /*
919919 * Special case for Unsupported SAM WRITE Opcodes and ImmediateData=Yes.
@@ -964,9 +964,9 @@ after_immediate_data: · 44 unmodified lines
964964 }
965965
966966 static int
967−cxgbit_handle_scsi_cmd(struct cxgbit_sock *csk, struct iscsi_cmd *cmd)
967+cxgbit_handle_scsi_cmd(struct cxgbit_sock *csk, struct iscsit_cmd *cmd)
968968 {
969− struct iscsi_conn *conn = csk->conn;
969+ struct iscsit_conn *conn = csk->conn;
970970 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
971971 struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)pdu_cb->hdr;
972972 int rc;
@@ -995,8 +995,8 @@ cxgbit_handle_scsi_cmd(struct cxgbit_sock *csk, struct iscsi_cmd *cmd) · 22 unmodified lines
995995 static int cxgbit_handle_iscsi_dataout(struct cxgbit_sock *csk)
996996 {
997997 struct scatterlist *sg_start;
998− struct iscsi_conn *conn = csk->conn;
999− struct iscsi_cmd *cmd = NULL;
998+ struct iscsit_conn *conn = csk->conn;
999+ struct iscsit_cmd *cmd = NULL;
10001000 struct cxgbit_cmd *ccmd;
10011001 struct cxgbi_task_tag_info *ttinfo;
10021002 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
@@ -1084,9 +1084,9 @@ check_payload: · 81 unmodified lines
10841084 return 0;
10851085 }
10861086
1087−static int cxgbit_handle_nop_out(struct cxgbit_sock *csk, struct iscsi_cmd *cmd)
1087+static int cxgbit_handle_nop_out(struct cxgbit_sock *csk, struct iscsit_cmd *cmd)
10881088 {
1089− struct iscsi_conn *conn = csk->conn;
1089+ struct iscsit_conn *conn = csk->conn;
10901090 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
10911091 struct iscsi_nopout *hdr = (struct iscsi_nopout *)pdu_cb->hdr;
10921092 unsigned char *ping_data = NULL;
@@ -1134,7 +1134,7 @@ static int cxgbit_handle_nop_out(struct cxgbit_sock *csk, struct iscsi_cmd *cmd) · 41 unmodified lines
11341134
11351135 ping_data[payload_length] = '\0';
11361136 /*
1137− * Attach ping data to struct iscsi_cmd->buf_ptr.
1137+ * Attach ping data to struct iscsit_cmd->buf_ptr.
11381138 */
11391139 cmd->buf_ptr = ping_data;
11401140 cmd->buf_ptr_size = payload_length;
@@ -1152,9 +1152,9 @@ out: · 11 unmodified lines
11521152 }
11531153
11541154 static int
1155−cxgbit_handle_text_cmd(struct cxgbit_sock *csk, struct iscsi_cmd *cmd)
1155+cxgbit_handle_text_cmd(struct cxgbit_sock *csk, struct iscsit_cmd *cmd)
11561156 {
1157− struct iscsi_conn *conn = csk->conn;
1157+ struct iscsit_conn *conn = csk->conn;
11581158 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
11591159 struct iscsi_text *hdr = (struct iscsi_text *)pdu_cb->hdr;
11601160 u32 payload_length = pdu_cb->dlen;
@@ -1209,8 +1209,8 @@ static int cxgbit_target_rx_opcode(struct cxgbit_sock *csk) · 48 unmodified lines
12091209 {
12101210 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
12111211 struct iscsi_hdr *hdr = (struct iscsi_hdr *)pdu_cb->hdr;
1212− struct iscsi_conn *conn = csk->conn;
1213− struct iscsi_cmd *cmd = NULL;
1212+ struct iscsit_conn *conn = csk->conn;
1213+ struct iscsit_cmd *cmd = NULL;
12141214 u8 opcode = (hdr->opcode & ISCSI_OPCODE_MASK);
12151215 int ret = -EINVAL;
12161216
@@ -1286,7 +1286,7 @@ reject: · 69 unmodified lines
12861286 static int cxgbit_rx_opcode(struct cxgbit_sock *csk)
12871287 {
12881288 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
1289− struct iscsi_conn *conn = csk->conn;
1289+ struct iscsit_conn *conn = csk->conn;
12901290 struct iscsi_hdr *hdr = pdu_cb->hdr;
12911291 u8 opcode;
12921292
@@ -1321,7 +1321,7 @@ transport_err: · 28 unmodified lines
13211321
13221322 static int cxgbit_rx_login_pdu(struct cxgbit_sock *csk)
13231323 {
1324− struct iscsi_conn *conn = csk->conn;
1324+ struct iscsit_conn *conn = csk->conn;
13251325 struct iscsi_login *login = conn->login;
13261326 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
13271327 struct iscsi_login_req *login_req;
@@ -1626,7 +1626,7 @@ out: · 298 unmodified lines
16261626 return -1;
16271627 }
16281628
1629−int cxgbit_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login)
1629+int cxgbit_get_login_rx(struct iscsit_conn *conn, struct iscsi_login *login)
16301630 {
16311631 struct cxgbit_sock *csk = conn->context;
16321632 int ret = -1;
@@ -1642,7 +1642,7 @@ int cxgbit_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login) · 9 unmodified lines
16421642 return ret;
16431643 }
16441644
1645−void cxgbit_get_rx_pdu(struct iscsi_conn *conn)
1645+void cxgbit_get_rx_pdu(struct iscsit_conn *conn)
16461646 {
16471647 struct cxgbit_sock *csk = conn->context;
16481648
drivers/target/iscsi/iscsi_target.c+136−136
@@ -59,7 +59,7 @@ struct kmem_cache *lio_dr_cache; · 58 unmodified lines
5959 struct kmem_cache *lio_ooo_cache;
6060 struct kmem_cache *lio_r2t_cache;
6161
62−static int iscsit_handle_immediate_data(struct iscsi_cmd *,
62+static int iscsit_handle_immediate_data(struct iscsit_cmd *,
6363 struct iscsi_scsi_req *, u32);
6464
6565 struct iscsi_tiqn *iscsit_get_tiqn_for_login(unsigned char *buf)
@@ -472,15 +472,15 @@ int iscsit_del_np(struct iscsi_np *np) · 406 unmodified lines
472472 return 0;
473473 }
474474
475−static void iscsit_get_rx_pdu(struct iscsi_conn *);
475+static void iscsit_get_rx_pdu(struct iscsit_conn *);
476476
477−int iscsit_queue_rsp(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
477+int iscsit_queue_rsp(struct iscsit_conn *conn, struct iscsit_cmd *cmd)
478478 {
479479 return iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
480480 }
481481 EXPORT_SYMBOL(iscsit_queue_rsp);
482482
483−void iscsit_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
483+void iscsit_aborted_task(struct iscsit_conn *conn, struct iscsit_cmd *cmd)
484484 {
485485 spin_lock_bh(&conn->cmd_lock);
486486 if (!list_empty(&cmd->i_conn_node))
@@ -493,10 +493,10 @@ EXPORT_SYMBOL(iscsit_aborted_task); · 6 unmodified lines
493493
494494 static void iscsit_do_crypto_hash_buf(struct ahash_request *, const void *,
495495 u32, u32, const void *, void *);
496−static void iscsit_tx_thread_wait_for_tcp(struct iscsi_conn *);
496+static void iscsit_tx_thread_wait_for_tcp(struct iscsit_conn *);
497497
498498 static int
499−iscsit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
499+iscsit_xmit_nondatain_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
500500 const void *data_buf, u32 data_buf_len)
501501 {
502502 struct iscsi_hdr *hdr = (struct iscsi_hdr *)cmd->pdu;
@@ -564,13 +564,13 @@ iscsit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 61 unmodified lines
564564 return 0;
565565 }
566566
567−static int iscsit_map_iovec(struct iscsi_cmd *cmd, struct kvec *iov, int nvec,
567+static int iscsit_map_iovec(struct iscsit_cmd *cmd, struct kvec *iov, int nvec,
568568 u32 data_offset, u32 data_length);
569−static void iscsit_unmap_iovec(struct iscsi_cmd *);
570−static u32 iscsit_do_crypto_hash_sg(struct ahash_request *, struct iscsi_cmd *,
569+static void iscsit_unmap_iovec(struct iscsit_cmd *);
570+static u32 iscsit_do_crypto_hash_sg(struct ahash_request *, struct iscsit_cmd *,
571571 u32, u32, u32, u8 *);
572572 static int
573−iscsit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
573+iscsit_xmit_datain_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
574574 const struct iscsi_datain *datain)
575575 {
576576 struct kvec *iov;
@@ -644,7 +644,7 @@ iscsit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 67 unmodified lines
644644 return 0;
645645 }
646646
647−static int iscsit_xmit_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
647+static int iscsit_xmit_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
648648 struct iscsi_datain_req *dr, const void *buf,
649649 u32 buf_len)
650650 {
@@ -654,7 +654,7 @@ static int iscsit_xmit_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 3 unmodified lines
654654 return iscsit_xmit_nondatain_pdu(conn, cmd, buf, buf_len);
655655 }
656656
657−static enum target_prot_op iscsit_get_sup_prot_ops(struct iscsi_conn *conn)
657+static enum target_prot_op iscsit_get_sup_prot_ops(struct iscsit_conn *conn)
658658 {
659659 return TARGET_PROT_NORMAL;
660660 }
@@ -796,11 +796,11 @@ static void __exit iscsi_target_cleanup_module(void) · 135 unmodified lines
796796 }
797797
798798 int iscsit_add_reject(
799− struct iscsi_conn *conn,
799+ struct iscsit_conn *conn,
800800 u8 reason,
801801 unsigned char *buf)
802802 {
803− struct iscsi_cmd *cmd;
803+ struct iscsit_cmd *cmd;
804804
805805 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);
806806 if (!cmd)
@@ -828,12 +828,12 @@ int iscsit_add_reject( · 21 unmodified lines
828828 EXPORT_SYMBOL(iscsit_add_reject);
829829
830830 static int iscsit_add_reject_from_cmd(
831− struct iscsi_cmd *cmd,
831+ struct iscsit_cmd *cmd,
832832 u8 reason,
833833 bool add_to_conn,
834834 unsigned char *buf)
835835 {
836− struct iscsi_conn *conn;
836+ struct iscsit_conn *conn;
837837 const bool do_put = cmd->se_cmd.se_tfo != NULL;
838838
839839 if (!cmd->conn) {
@@ -872,13 +872,13 @@ static int iscsit_add_reject_from_cmd( · 32 unmodified lines
872872 return -1;
873873 }
874874
875−static int iscsit_add_reject_cmd(struct iscsi_cmd *cmd, u8 reason,
875+static int iscsit_add_reject_cmd(struct iscsit_cmd *cmd, u8 reason,
876876 unsigned char *buf)
877877 {
878878 return iscsit_add_reject_from_cmd(cmd, reason, true, buf);
879879 }
880880
881−int iscsit_reject_cmd(struct iscsi_cmd *cmd, u8 reason, unsigned char *buf)
881+int iscsit_reject_cmd(struct iscsit_cmd *cmd, u8 reason, unsigned char *buf)
882882 {
883883 return iscsit_add_reject_from_cmd(cmd, reason, false, buf);
884884 }
@@ -888,7 +888,7 @@ EXPORT_SYMBOL(iscsit_reject_cmd); · 3 unmodified lines
888888 * Map some portion of the allocated scatterlist to an iovec, suitable for
889889 * kernel sockets to copy data in/out.
890890 */
891−static int iscsit_map_iovec(struct iscsi_cmd *cmd, struct kvec *iov, int nvec,
891+static int iscsit_map_iovec(struct iscsit_cmd *cmd, struct kvec *iov, int nvec,
892892 u32 data_offset, u32 data_length)
893893 {
894894 u32 i = 0, orig_data_length = data_length;
@@ -946,7 +946,7 @@ overflow: · 51 unmodified lines
946946 return -1;
947947 }
948948
949−static void iscsit_unmap_iovec(struct iscsi_cmd *cmd)
949+static void iscsit_unmap_iovec(struct iscsit_cmd *cmd)
950950 {
951951 u32 i;
952952 struct scatterlist *sg;
@@ -957,10 +957,10 @@ static void iscsit_unmap_iovec(struct iscsi_cmd *cmd) · 4 unmodified lines
957957 kunmap(sg_page(&sg[i]));
958958 }
959959
960−static void iscsit_ack_from_expstatsn(struct iscsi_conn *conn, u32 exp_statsn)
960+static void iscsit_ack_from_expstatsn(struct iscsit_conn *conn, u32 exp_statsn)
961961 {
962962 LIST_HEAD(ack_list);
963− struct iscsi_cmd *cmd, *cmd_p;
963+ struct iscsit_cmd *cmd, *cmd_p;
964964
965965 conn->exp_statsn = exp_statsn;
966966
@@ -987,7 +987,7 @@ static void iscsit_ack_from_expstatsn(struct iscsi_conn *conn, u32 exp_statsn) · 20 unmodified lines
987987 }
988988 }
989989
990−static int iscsit_allocate_iovecs(struct iscsi_cmd *cmd)
990+static int iscsit_allocate_iovecs(struct iscsit_cmd *cmd)
991991 {
992992 u32 iov_count = max(1UL, DIV_ROUND_UP(cmd->se_cmd.data_length, PAGE_SIZE));
993993
@@ -1000,7 +1000,7 @@ static int iscsit_allocate_iovecs(struct iscsi_cmd *cmd) · 6 unmodified lines
10001000 return 0;
10011001 }
10021002
1003−int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1003+int iscsit_setup_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
10041004 unsigned char *buf)
10051005 {
10061006 int data_direction, payload_length;
@@ -1215,7 +1215,7 @@ attach_cmd: · 208 unmodified lines
12151215 }
12161216 EXPORT_SYMBOL(iscsit_setup_scsi_cmd);
12171217
1218−void iscsit_set_unsolicited_dataout(struct iscsi_cmd *cmd)
1218+void iscsit_set_unsolicited_dataout(struct iscsit_cmd *cmd)
12191219 {
12201220 iscsit_set_dataout_sequence_values(cmd);
12211221
@@ -1225,7 +1225,7 @@ void iscsit_set_unsolicited_dataout(struct iscsi_cmd *cmd) · 3 unmodified lines
12251225 }
12261226 EXPORT_SYMBOL(iscsit_set_unsolicited_dataout);
12271227
1228−int iscsit_process_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1228+int iscsit_process_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
12291229 struct iscsi_scsi_req *hdr)
12301230 {
12311231 int cmdsn_ret = 0;
@@ -1285,7 +1285,7 @@ int iscsit_process_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 53 unmodified lines
12851285 EXPORT_SYMBOL(iscsit_process_scsi_cmd);
12861286
12871287 static int
1288−iscsit_get_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr,
1288+iscsit_get_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr,
12891289 bool dump_payload)
12901290 {
12911291 int cmdsn_ret = 0, immed_ret = IMMEDIATE_DATA_NORMAL_OPERATION;
@@ -1349,7 +1349,7 @@ iscsit_get_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr, · 57 unmodified lines
13491349 }
13501350
13511351 static int
1352−iscsit_handle_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1352+iscsit_handle_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
13531353 unsigned char *buf)
13541354 {
13551355 struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)buf;
@@ -1383,7 +1383,7 @@ iscsit_handle_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 27 unmodified lines
13831383
13841384 static u32 iscsit_do_crypto_hash_sg(
13851385 struct ahash_request *hash,
1386− struct iscsi_cmd *cmd,
1386+ struct iscsit_cmd *cmd,
13871387 u32 data_offset,
13881388 u32 data_length,
13891389 u32 padding,
@@ -1455,8 +1455,8 @@ static void iscsit_do_crypto_hash_buf(struct ahash_request *hash, · 65 unmodified lines
14551455 }
14561456
14571457 int
1458−__iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf,
1459− struct iscsi_cmd *cmd, u32 payload_length,
1458+__iscsit_check_dataout_hdr(struct iscsit_conn *conn, void *buf,
1459+ struct iscsit_cmd *cmd, u32 payload_length,
14601460 bool *success)
14611461 {
14621462 struct iscsi_data *hdr = buf;
@@ -1559,11 +1559,11 @@ __iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf, · 96 unmodified lines
15591559 EXPORT_SYMBOL(__iscsit_check_dataout_hdr);
15601560
15611561 int
1562−iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf,
1563− struct iscsi_cmd **out_cmd)
1562+iscsit_check_dataout_hdr(struct iscsit_conn *conn, void *buf,
1563+ struct iscsit_cmd **out_cmd)
15641564 {
15651565 struct iscsi_data *hdr = buf;
1566− struct iscsi_cmd *cmd;
1566+ struct iscsit_cmd *cmd;
15671567 u32 payload_length = ntoh24(hdr->dlength);
15681568 int rc;
15691569 bool success = false;
@@ -1594,7 +1594,7 @@ iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf, · 24 unmodified lines
15941594 EXPORT_SYMBOL(iscsit_check_dataout_hdr);
15951595
15961596 static int
1597−iscsit_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1597+iscsit_get_dataout(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
15981598 struct iscsi_data *hdr)
15991599 {
16001600 struct kvec *iov;
@@ -1662,10 +1662,10 @@ iscsit_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 61 unmodified lines
16621662 }
16631663
16641664 int
1665−iscsit_check_dataout_payload(struct iscsi_cmd *cmd, struct iscsi_data *hdr,
1665+iscsit_check_dataout_payload(struct iscsit_cmd *cmd, struct iscsi_data *hdr,
16661666 bool data_crc_failed)
16671667 {
1668− struct iscsi_conn *conn = cmd->conn;
1668+ struct iscsit_conn *conn = cmd->conn;
16691669 int rc, ooo_cmdsn;
16701670 /*
16711671 * Increment post receive data and CRC values or perform
@@ -1700,9 +1700,9 @@ iscsit_check_dataout_payload(struct iscsi_cmd *cmd, struct iscsi_data *hdr, · 28 unmodified lines
17001700 }
17011701 EXPORT_SYMBOL(iscsit_check_dataout_payload);
17021702
1703−static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf)
1703+static int iscsit_handle_data_out(struct iscsit_conn *conn, unsigned char *buf)
17041704 {
1705− struct iscsi_cmd *cmd = NULL;
1705+ struct iscsit_cmd *cmd = NULL;
17061706 struct iscsi_data *hdr = (struct iscsi_data *)buf;
17071707 int rc;
17081708 bool data_crc_failed = false;
@@ -1722,7 +1722,7 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf) · 13 unmodified lines
17221722 return iscsit_check_dataout_payload(cmd, hdr, data_crc_failed);
17231723 }
17241724
1725−int iscsit_setup_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1725+int iscsit_setup_nop_out(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
17261726 struct iscsi_nopout *hdr)
17271727 {
17281728 u32 payload_length = ntoh24(hdr->dlength);
@@ -1770,7 +1770,7 @@ int iscsit_setup_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 41 unmodified lines
17701770 * This is not a response to a Unsolicited NopIN, which means
17711771 * it can either be a NOPOUT ping request (with a valid ITT),
17721772 * or a NOPOUT not requesting a NOPIN (with a reserved ITT).
1773− * Either way, make sure we allocate an struct iscsi_cmd, as both
1773+ * Either way, make sure we allocate an struct iscsit_cmd, as both
17741774 * can contain ping data.
17751775 */
17761776 if (hdr->ttt == cpu_to_be32(0xFFFFFFFF)) {
@@ -1789,10 +1789,10 @@ int iscsit_setup_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 12 unmodified lines
17891789 }
17901790 EXPORT_SYMBOL(iscsit_setup_nop_out);
17911791
1792−int iscsit_process_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1792+int iscsit_process_nop_out(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
17931793 struct iscsi_nopout *hdr)
17941794 {
1795− struct iscsi_cmd *cmd_p = NULL;
1795+ struct iscsit_cmd *cmd_p = NULL;
17961796 int cmdsn_ret = 0;
17971797 /*
17981798 * Initiator is expecting a NopIN ping reply..
@@ -1851,7 +1851,7 @@ int iscsit_process_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 52 unmodified lines
18511851 }
18521852 EXPORT_SYMBOL(iscsit_process_nop_out);
18531853
1854−static int iscsit_handle_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1854+static int iscsit_handle_nop_out(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
18551855 unsigned char *buf)
18561856 {
18571857 unsigned char *ping_data = NULL;
@@ -1936,7 +1936,7 @@ static int iscsit_handle_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 78 unmodified lines
19361936
19371937 ping_data[payload_length] = '\0';
19381938 /*
1939− * Attach ping data to struct iscsi_cmd->buf_ptr.
1939+ * Attach ping data to struct iscsit_cmd->buf_ptr.
19401940 */
19411941 cmd->buf_ptr = ping_data;
19421942 cmd->buf_ptr_size = payload_length;
@@ -1978,7 +1978,7 @@ static enum tcm_tmreq_table iscsit_convert_tmf(u8 iscsi_tmf) · 35 unmodified lines
19781978 }
19791979
19801980 int
1981−iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1981+iscsit_handle_task_mgt_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
19821982 unsigned char *buf)
19831983 {
19841984 struct se_tmr_req *se_tmr;
@@ -2159,7 +2159,7 @@ EXPORT_SYMBOL(iscsit_handle_task_mgt_cmd); · 174 unmodified lines
21592159
21602160 /* #warning FIXME: Support Text Command parameters besides SendTargets */
21612161 int
2162−iscsit_setup_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
2162+iscsit_setup_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
21632163 struct iscsi_text *hdr)
21642164 {
21652165 u32 payload_length = ntoh24(hdr->dlength);
@@ -2199,7 +2199,7 @@ iscsit_setup_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 33 unmodified lines
21992199 EXPORT_SYMBOL(iscsit_setup_text_cmd);
22002200
22012201 int
2202−iscsit_process_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
2202+iscsit_process_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
22032203 struct iscsi_text *hdr)
22042204 {
22052205 unsigned char *text_in = cmd->text_in_ptr, *text_ptr;
@@ -2258,7 +2258,7 @@ reject: · 52 unmodified lines
22582258 EXPORT_SYMBOL(iscsit_process_text_cmd);
22592259
22602260 static int
2261−iscsit_handle_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
2261+iscsit_handle_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
22622262 unsigned char *buf)
22632263 {
22642264 struct iscsi_text *hdr = (struct iscsi_text *)buf;
@@ -2347,10 +2347,10 @@ reject: · 82 unmodified lines
23472347 return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR, buf);
23482348 }
23492349
2350−int iscsit_logout_closesession(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
2350+int iscsit_logout_closesession(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
23512351 {
2352− struct iscsi_conn *conn_p;
2353− struct iscsi_session *sess = conn->sess;
2352+ struct iscsit_conn *conn_p;
2353+ struct iscsit_session *sess = conn->sess;
23542354
23552355 pr_debug("Received logout request CLOSESESSION on CID: %hu"
23562356 " for SID: %u.\n", conn->cid, conn->sess->sid);
@@ -2377,10 +2377,10 @@ int iscsit_logout_closesession(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 20 unmodified lines
23772377 return 0;
23782378 }
23792379
2380−int iscsit_logout_closeconnection(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
2380+int iscsit_logout_closeconnection(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
23812381 {
2382− struct iscsi_conn *l_conn;
2383− struct iscsi_session *sess = conn->sess;
2382+ struct iscsit_conn *l_conn;
2383+ struct iscsit_session *sess = conn->sess;
23842384
23852385 pr_debug("Received logout request CLOSECONNECTION for CID:"
23862386 " %hu on CID: %hu.\n", cmd->logout_cid, conn->cid);
@@ -2425,9 +2425,9 @@ int iscsit_logout_closeconnection(struct iscsi_cmd *cmd, struct iscsi_conn *conn · 38 unmodified lines
24252425 return 0;
24262426 }
24272427
2428−int iscsit_logout_removeconnforrecovery(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
2428+int iscsit_logout_removeconnforrecovery(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
24292429 {
2430− struct iscsi_session *sess = conn->sess;
2430+ struct iscsit_session *sess = conn->sess;
24312431
24322432 pr_debug("Received explicit REMOVECONNFORRECOVERY logout for"
24332433 " CID: %hu on CID: %hu.\n", cmd->logout_cid, conn->cid);
@@ -2455,7 +2455,7 @@ int iscsit_logout_removeconnforrecovery(struct iscsi_cmd *cmd, struct iscsi_conn · 21 unmodified lines
24552455 }
24562456
24572457 int
2458−iscsit_handle_logout_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
2458+iscsit_handle_logout_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
24592459 unsigned char *buf)
24602460 {
24612461 int cmdsn_ret, logout_remove = 0;
@@ -2536,7 +2536,7 @@ iscsit_handle_logout_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 74 unmodified lines
25362536 EXPORT_SYMBOL(iscsit_handle_logout_cmd);
25372537
25382538 int iscsit_handle_snack(
2539− struct iscsi_conn *conn,
2539+ struct iscsit_conn *conn,
25402540 unsigned char *buf)
25412541 {
25422542 struct iscsi_snack *hdr;
@@ -2590,7 +2590,7 @@ int iscsit_handle_snack( · 47 unmodified lines
25902590 }
25912591 EXPORT_SYMBOL(iscsit_handle_snack);
25922592
2593−static void iscsit_rx_thread_wait_for_tcp(struct iscsi_conn *conn)
2593+static void iscsit_rx_thread_wait_for_tcp(struct iscsit_conn *conn)
25942594 {
25952595 if ((conn->sock->sk->sk_shutdown & SEND_SHUTDOWN) ||
25962596 (conn->sock->sk->sk_shutdown & RCV_SHUTDOWN)) {
@@ -2601,13 +2601,13 @@ static void iscsit_rx_thread_wait_for_tcp(struct iscsi_conn *conn) · 4 unmodified lines
26012601 }
26022602
26032603 static int iscsit_handle_immediate_data(
2604− struct iscsi_cmd *cmd,
2604+ struct iscsit_cmd *cmd,
26052605 struct iscsi_scsi_req *hdr,
26062606 u32 length)
26072607 {
26082608 int iov_ret, rx_got = 0, rx_size = 0;
26092609 u32 checksum, iov_count = 0, padding = 0;
2610− struct iscsi_conn *conn = cmd->conn;
2610+ struct iscsit_conn *conn = cmd->conn;
26112611 struct kvec *iov;
26122612 void *overflow_buf = NULL;
26132613
@@ -2708,10 +2708,10 @@ static int iscsit_handle_immediate_data( · 94 unmodified lines
27082708
27092709 /* #warning iscsi_build_conn_drop_async_message() only sends out on connections
27102710 with active network interface */
2711−static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn)
2711+static void iscsit_build_conn_drop_async_message(struct iscsit_conn *conn)
27122712 {
2713− struct iscsi_cmd *cmd;
2714− struct iscsi_conn *conn_p;
2713+ struct iscsit_cmd *cmd;
2714+ struct iscsit_conn *conn_p;
27152715 bool found = false;
27162716
27172717 lockdep_assert_held(&conn->sess->conn_lock);
@@ -2750,8 +2750,8 @@ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn) · 32 unmodified lines
27502750 }
27512751
27522752 static int iscsit_send_conn_drop_async_message(
2753− struct iscsi_cmd *cmd,
2754− struct iscsi_conn *conn)
2753+ struct iscsit_cmd *cmd,
2754+ struct iscsit_conn *conn)
27552755 {
27562756 struct iscsi_async *hdr;
27572757
@@ -2779,7 +2779,7 @@ static int iscsit_send_conn_drop_async_message( · 21 unmodified lines
27792779 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, NULL, 0);
27802780 }
27812781
2782−static void iscsit_tx_thread_wait_for_tcp(struct iscsi_conn *conn)
2782+static void iscsit_tx_thread_wait_for_tcp(struct iscsit_conn *conn)
27832783 {
27842784 if ((conn->sock->sk->sk_shutdown & SEND_SHUTDOWN) ||
27852785 (conn->sock->sk->sk_shutdown & RCV_SHUTDOWN)) {
@@ -2790,7 +2790,7 @@ static void iscsit_tx_thread_wait_for_tcp(struct iscsi_conn *conn) · 4 unmodified lines
27902790 }
27912791
27922792 void
2793−iscsit_build_datain_pdu(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
2793+iscsit_build_datain_pdu(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
27942794 struct iscsi_datain *datain, struct iscsi_data_rsp *hdr,
27952795 bool set_statsn)
27962796 {
@@ -2835,7 +2835,7 @@ iscsit_build_datain_pdu(struct iscsi_cmd *cmd, struct iscsi_conn *conn, · 38 unmodified lines
28352835 }
28362836 EXPORT_SYMBOL(iscsit_build_datain_pdu);
28372837
2838−static int iscsit_send_datain(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
2838+static int iscsit_send_datain(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
28392839 {
28402840 struct iscsi_data_rsp *hdr = (struct iscsi_data_rsp *)&cmd->pdu[0];
28412841 struct iscsi_datain datain;
@@ -2896,12 +2896,12 @@ static int iscsit_send_datain(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 54 unmodified lines
28962896 }
28972897
28982898 int
2899−iscsit_build_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
2899+iscsit_build_logout_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
29002900 struct iscsi_logout_rsp *hdr)
29012901 {
2902− struct iscsi_conn *logout_conn = NULL;
2902+ struct iscsit_conn *logout_conn = NULL;
29032903 struct iscsi_conn_recovery *cr = NULL;
2904− struct iscsi_session *sess = conn->sess;
2904+ struct iscsit_session *sess = conn->sess;
29052905 /*
29062906 * The actual shutting down of Sessions and/or Connections
29072907 * for CLOSESESSION and CLOSECONNECTION Logout Requests
@@ -2991,7 +2991,7 @@ iscsit_build_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn, · 83 unmodified lines
29912991 EXPORT_SYMBOL(iscsit_build_logout_rsp);
29922992
29932993 static int
2994−iscsit_send_logout(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
2994+iscsit_send_logout(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
29952995 {
29962996 int rc;
29972997
@@ -3004,7 +3004,7 @@ iscsit_send_logout(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 6 unmodified lines
30043004 }
30053005
30063006 void
3007−iscsit_build_nopin_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
3007+iscsit_build_nopin_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
30083008 struct iscsi_nopin *hdr, bool nopout_response)
30093009 {
30103010 hdr->opcode = ISCSI_OP_NOOP_IN;
@@ -3035,8 +3035,8 @@ EXPORT_SYMBOL(iscsit_build_nopin_rsp); · 24 unmodified lines
30353035 * Unsolicited NOPIN, either requesting a response or not.
30363036 */
30373037 static int iscsit_send_unsolicited_nopin(
3038− struct iscsi_cmd *cmd,
3039− struct iscsi_conn *conn,
3038+ struct iscsit_cmd *cmd,
3039+ struct iscsit_conn *conn,
30403040 int want_response)
30413041 {
30423042 struct iscsi_nopin *hdr = (struct iscsi_nopin *)&cmd->pdu[0];
@@ -3060,15 +3060,15 @@ static int iscsit_send_unsolicited_nopin( · 17 unmodified lines
30603060 }
30613061
30623062 static int
3063−iscsit_send_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
3063+iscsit_send_nopin(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
30643064 {
30653065 struct iscsi_nopin *hdr = (struct iscsi_nopin *)&cmd->pdu[0];
30663066
30673067 iscsit_build_nopin_rsp(cmd, conn, hdr, true);
30683068
30693069 /*
3070− * NOPOUT Ping Data is attached to struct iscsi_cmd->buf_ptr.
3071− * NOPOUT DataSegmentLength is at struct iscsi_cmd->buf_ptr_size.
3070+ * NOPOUT Ping Data is attached to struct iscsit_cmd->buf_ptr.
3071+ * NOPOUT DataSegmentLength is at struct iscsit_cmd->buf_ptr_size.
30723072 */
30733073 pr_debug("Echoing back %u bytes of ping data.\n", cmd->buf_ptr_size);
30743074
@@ -3078,8 +3078,8 @@ iscsit_send_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 3 unmodified lines
30783078 }
30793079
30803080 static int iscsit_send_r2t(
3081− struct iscsi_cmd *cmd,
3082− struct iscsi_conn *conn)
3081+ struct iscsit_cmd *cmd,
3082+ struct iscsit_conn *conn)
30833083 {
30843084 struct iscsi_r2t *r2t;
30853085 struct iscsi_r2t_rsp *hdr;
@@ -3135,8 +3135,8 @@ static int iscsit_send_r2t( · 49 unmodified lines
31353135 * connection recovery.
31363136 */
31373137 int iscsit_build_r2ts_for_cmd(
3138− struct iscsi_conn *conn,
3139− struct iscsi_cmd *cmd,
3138+ struct iscsit_conn *conn,
3139+ struct iscsit_cmd *cmd,
31403140 bool recovery)
31413141 {
31423142 int first_r2t = 1;
@@ -3218,7 +3218,7 @@ int iscsit_build_r2ts_for_cmd( · 75 unmodified lines
32183218 }
32193219 EXPORT_SYMBOL(iscsit_build_r2ts_for_cmd);
32203220
3221−void iscsit_build_rsp_pdu(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
3221+void iscsit_build_rsp_pdu(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
32223222 bool inc_stat_sn, struct iscsi_scsi_rsp *hdr)
32233223 {
32243224 if (inc_stat_sn)
@@ -3252,7 +3252,7 @@ void iscsit_build_rsp_pdu(struct iscsi_cmd *cmd, struct iscsi_conn *conn, · 27 unmodified lines
32523252 }
32533253 EXPORT_SYMBOL(iscsit_build_rsp_pdu);
32543254
3255−static int iscsit_send_response(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
3255+static int iscsit_send_response(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
32563256 {
32573257 struct iscsi_scsi_rsp *hdr = (struct iscsi_scsi_rsp *)&cmd->pdu[0];
32583258 bool inc_stat_sn = (cmd->i_state == ISTATE_SEND_STATUS);
@@ -3309,7 +3309,7 @@ static u8 iscsit_convert_tcm_tmr_rsp(struct se_tmr_req *se_tmr) · 50 unmodified lines
33093309 }
33103310
33113311 void
3312−iscsit_build_task_mgt_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
3312+iscsit_build_task_mgt_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
33133313 struct iscsi_tm_rsp *hdr)
33143314 {
33153315 struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
@@ -3332,7 +3332,7 @@ iscsit_build_task_mgt_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn, · 16 unmodified lines
33323332 EXPORT_SYMBOL(iscsit_build_task_mgt_rsp);
33333333
33343334 static int
3335−iscsit_send_task_mgt_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
3335+iscsit_send_task_mgt_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
33363336 {
33373337 struct iscsi_tm_rsp *hdr = (struct iscsi_tm_rsp *)&cmd->pdu[0];
33383338
@@ -3344,12 +3344,12 @@ iscsit_send_task_mgt_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 5 unmodified lines
33443344 #define SENDTARGETS_BUF_LIMIT 32768U
33453345
33463346 static int
3347−iscsit_build_sendtargets_response(struct iscsi_cmd *cmd,
3347+iscsit_build_sendtargets_response(struct iscsit_cmd *cmd,
33483348 enum iscsit_transport_type network_transport,
33493349 int skip_bytes, bool *completed)
33503350 {
33513351 char *payload = NULL;
3352− struct iscsi_conn *conn = cmd->conn;
3352+ struct iscsit_conn *conn = cmd->conn;
33533353 struct iscsi_portal_group *tpg;
33543354 struct iscsi_tiqn *tiqn;
33553355 struct iscsi_tpg_np *tpg_np;
@@ -3494,7 +3494,7 @@ eob: · 138 unmodified lines
34943494 }
34953495
34963496 int
3497−iscsit_build_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
3497+iscsit_build_text_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
34983498 struct iscsi_text_rsp *hdr,
34993499 enum iscsit_transport_type network_transport)
35003500 {
@@ -3544,8 +3544,8 @@ iscsit_build_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn, · 43 unmodified lines
35443544 EXPORT_SYMBOL(iscsit_build_text_rsp);
35453545
35463546 static int iscsit_send_text_rsp(
3547− struct iscsi_cmd *cmd,
3548− struct iscsi_conn *conn)
3547+ struct iscsit_cmd *cmd,
3548+ struct iscsit_conn *conn)
35493549 {
35503550 struct iscsi_text_rsp *hdr = (struct iscsi_text_rsp *)cmd->pdu;
35513551 int text_length;
@@ -3561,7 +3561,7 @@ static int iscsit_send_text_rsp( · 9 unmodified lines
35613561 }
35623562
35633563 void
3564−iscsit_build_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
3564+iscsit_build_reject(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
35653565 struct iscsi_reject *hdr)
35663566 {
35673567 hdr->opcode = ISCSI_OP_REJECT;
@@ -3578,8 +3578,8 @@ iscsit_build_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn, · 10 unmodified lines
35783578 EXPORT_SYMBOL(iscsit_build_reject);
35793579
35803580 static int iscsit_send_reject(
3581− struct iscsi_cmd *cmd,
3582− struct iscsi_conn *conn)
3581+ struct iscsit_cmd *cmd,
3582+ struct iscsit_conn *conn)
35833583 {
35843584 struct iscsi_reject *hdr = (struct iscsi_reject *)&cmd->pdu[0];
35853585
@@ -3593,7 +3593,7 @@ static int iscsit_send_reject( · 7 unmodified lines
35933593 ISCSI_HDR_LEN);
35943594 }
35953595
3596−void iscsit_thread_get_cpumask(struct iscsi_conn *conn)
3596+void iscsit_thread_get_cpumask(struct iscsit_conn *conn)
35973597 {
35983598 int ord, cpu;
35993599 cpumask_var_t conn_allowed_cpumask;
@@ -3636,7 +3636,7 @@ void iscsit_thread_get_cpumask(struct iscsi_conn *conn) · 36 unmodified lines
36363636 cpumask_setall(conn->conn_cpumask);
36373637 }
36383638
3639−static void iscsit_thread_reschedule(struct iscsi_conn *conn)
3639+static void iscsit_thread_reschedule(struct iscsit_conn *conn)
36403640 {
36413641 /*
36423642 * If iscsit_global->allowed_cpumask modified, reschedule iSCSI
@@ -3653,7 +3653,7 @@ static void iscsit_thread_reschedule(struct iscsi_conn *conn) · 10 unmodified lines
36533653 }
36543654
36553655 void iscsit_thread_check_cpumask(
3656− struct iscsi_conn *conn,
3656+ struct iscsit_conn *conn,
36573657 struct task_struct *p,
36583658 int mode)
36593659 {
@@ -3693,7 +3693,7 @@ void iscsit_thread_check_cpumask( · 33 unmodified lines
36933693 EXPORT_SYMBOL(iscsit_thread_check_cpumask);
36943694
36953695 int
3696−iscsit_immediate_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state)
3696+iscsit_immediate_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state)
36973697 {
36983698 int ret;
36993699
@@ -3737,11 +3737,11 @@ err: · 37 unmodified lines
37373737 EXPORT_SYMBOL(iscsit_immediate_queue);
37383738
37393739 static int
3740−iscsit_handle_immediate_queue(struct iscsi_conn *conn)
3740+iscsit_handle_immediate_queue(struct iscsit_conn *conn)
37413741 {
37423742 struct iscsit_transport *t = conn->conn_transport;
37433743 struct iscsi_queue_req *qr;
3744− struct iscsi_cmd *cmd;
3744+ struct iscsit_cmd *cmd;
37453745 u8 state;
37463746 int ret;
37473747
@@ -3760,7 +3760,7 @@ iscsit_handle_immediate_queue(struct iscsi_conn *conn) · 12 unmodified lines
37603760 }
37613761
37623762 int
3763−iscsit_response_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state)
3763+iscsit_response_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state)
37643764 {
37653765 int ret;
37663766
@@ -3866,11 +3866,11 @@ err: · 99 unmodified lines
38663866 }
38673867 EXPORT_SYMBOL(iscsit_response_queue);
38683868
3869−static int iscsit_handle_response_queue(struct iscsi_conn *conn)
3869+static int iscsit_handle_response_queue(struct iscsit_conn *conn)
38703870 {
38713871 struct iscsit_transport *t = conn->conn_transport;
38723872 struct iscsi_queue_req *qr;
3873− struct iscsi_cmd *cmd;
3873+ struct iscsit_cmd *cmd;
38743874 u8 state;
38753875 int ret;
38763876
@@ -3890,7 +3890,7 @@ static int iscsit_handle_response_queue(struct iscsi_conn *conn) · 13 unmodified lines
38903890 int iscsi_target_tx_thread(void *arg)
38913891 {
38923892 int ret = 0;
3893− struct iscsi_conn *conn = arg;
3893+ struct iscsit_conn *conn = arg;
38943894 bool conn_freed = false;
38953895
38963896 /*
@@ -3945,10 +3945,10 @@ out: · 48 unmodified lines
39453945 return 0;
39463946 }
39473947
3948−static int iscsi_target_rx_opcode(struct iscsi_conn *conn, unsigned char *buf)
3948+static int iscsi_target_rx_opcode(struct iscsit_conn *conn, unsigned char *buf)
39493949 {
39503950 struct iscsi_hdr *hdr = (struct iscsi_hdr *)buf;
3951− struct iscsi_cmd *cmd;
3951+ struct iscsit_cmd *cmd;
39523952 int ret = 0;
39533953
39543954 switch (hdr->opcode & ISCSI_OPCODE_MASK) {
@@ -4022,7 +4022,7 @@ reject: · 67 unmodified lines
40224022 return iscsit_add_reject(conn, ISCSI_REASON_BOOKMARK_NO_RESOURCES, buf);
40234023 }
40244024
4025−static bool iscsi_target_check_conn_state(struct iscsi_conn *conn)
4025+static bool iscsi_target_check_conn_state(struct iscsit_conn *conn)
40264026 {
40274027 bool ret;
40284028
@@ -4033,7 +4033,7 @@ static bool iscsi_target_check_conn_state(struct iscsi_conn *conn) · 4 unmodified lines
40334033 return ret;
40344034 }
40354035
4036−static void iscsit_get_rx_pdu(struct iscsi_conn *conn)
4036+static void iscsit_get_rx_pdu(struct iscsit_conn *conn)
40374037 {
40384038 int ret;
40394039 u8 *buffer, opcode;
@@ -4118,7 +4118,7 @@ static void iscsit_get_rx_pdu(struct iscsi_conn *conn) · 78 unmodified lines
41184118 int iscsi_target_rx_thread(void *arg)
41194119 {
41204120 int rc;
4121− struct iscsi_conn *conn = arg;
4121+ struct iscsit_conn *conn = arg;
41224122 bool conn_freed = false;
41234123
41244124 /*
@@ -4153,11 +4153,11 @@ out: · 28 unmodified lines
41534153 return 0;
41544154 }
41554155
4156−static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)
4156+static void iscsit_release_commands_from_conn(struct iscsit_conn *conn)
41574157 {
41584158 LIST_HEAD(tmp_list);
4159− struct iscsi_cmd *cmd = NULL, *cmd_tmp = NULL;
4160− struct iscsi_session *sess = conn->sess;
4159+ struct iscsit_cmd *cmd = NULL, *cmd_tmp = NULL;
4160+ struct iscsit_session *sess = conn->sess;
41614161 /*
41624162 * We expect this function to only ever be called from either RX or TX
41634163 * thread context via iscsit_close_connection() once the other context
@@ -4197,9 +4197,9 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn) · 33 unmodified lines
41974197 }
41984198
41994199 static void iscsit_stop_timers_for_cmds(
4200− struct iscsi_conn *conn)
4200+ struct iscsit_conn *conn)
42014201 {
4202− struct iscsi_cmd *cmd;
4202+ struct iscsit_cmd *cmd;
42034203
42044204 spin_lock_bh(&conn->cmd_lock);
42054205 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) {
@@ -4210,10 +4210,10 @@ static void iscsit_stop_timers_for_cmds( · 4 unmodified lines
42104210 }
42114211
42124212 int iscsit_close_connection(
4213− struct iscsi_conn *conn)
4213+ struct iscsit_conn *conn)
42144214 {
42154215 int conn_logout = (conn->conn_state == TARG_CONN_STATE_IN_LOGOUT);
4216− struct iscsi_session *sess = conn->sess;
4216+ struct iscsit_session *sess = conn->sess;
42174217
42184218 pr_debug("Closing iSCSI connection CID %hu on SID:"
42194219 " %u\n", conn->cid, sess->sid);
@@ -4226,7 +4226,7 @@ int iscsit_close_connection( · 6 unmodified lines
42264226 * However for iser-target, isert_wait4logout() is using conn_logout_comp
42274227 * to signal logout response TX interrupt completion. Go ahead and skip
42284228 * this for iser since isert_rx_opcode() does not wait on logout failure,
4229− * and to avoid iscsi_conn pointer dereference in iser-target code.
4229+ * and to avoid iscsit_conn pointer dereference in iser-target code.
42304230 */
42314231 if (!conn->conn_transport->rdma_shutdown)
42324232 complete(&conn->conn_logout_comp);
@@ -4264,7 +4264,7 @@ int iscsit_close_connection( · 31 unmodified lines
42644264 *
42654265 * During normal operation clear the out of order commands (but
42664266 * do not free the struct iscsi_ooo_cmdsn's) and release all
4267− * struct iscsi_cmds.
4267+ * struct iscsit_cmds.
42684268 */
42694269 if (atomic_read(&conn->connection_recovery)) {
42704270 iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(conn);
@@ -4450,7 +4450,7 @@ int iscsit_close_connection( · 179 unmodified lines
44504450 * If the iSCSI Session for the iSCSI Initiator Node exists,
44514451 * forcefully shutdown the iSCSI NEXUS.
44524452 */
4453−int iscsit_close_session(struct iscsi_session *sess, bool can_sleep)
4453+int iscsit_close_session(struct iscsit_session *sess, bool can_sleep)
44544454 {
44554455 struct iscsi_portal_group *tpg = sess->tpg;
44564456 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
@@ -4518,9 +4518,9 @@ int iscsit_close_session(struct iscsi_session *sess, bool can_sleep) · 61 unmodified lines
45184518 }
45194519
45204520 static void iscsit_logout_post_handler_closesession(
4521− struct iscsi_conn *conn)
4521+ struct iscsit_conn *conn)
45224522 {
4523− struct iscsi_session *sess = conn->sess;
4523+ struct iscsit_session *sess = conn->sess;
45244524 int sleep = 1;
45254525 /*
45264526 * Traditional iscsi/tcp will invoke this logic from TX thread
@@ -4547,7 +4547,7 @@ static void iscsit_logout_post_handler_closesession( · 20 unmodified lines
45474547 }
45484548
45494549 static void iscsit_logout_post_handler_samecid(
4550− struct iscsi_conn *conn)
4550+ struct iscsit_conn *conn)
45514551 {
45524552 int sleep = 1;
45534553
@@ -4565,11 +4565,11 @@ static void iscsit_logout_post_handler_samecid( · 11 unmodified lines
45654565 }
45664566
45674567 static void iscsit_logout_post_handler_diffcid(
4568− struct iscsi_conn *conn,
4568+ struct iscsit_conn *conn,
45694569 u16 cid)
45704570 {
4571− struct iscsi_conn *l_conn;
4572− struct iscsi_session *sess = conn->sess;
4571+ struct iscsit_conn *l_conn;
4572+ struct iscsit_session *sess = conn->sess;
45734573 bool conn_found = false;
45744574
45754575 if (!sess)
@@ -4604,8 +4604,8 @@ static void iscsit_logout_post_handler_diffcid( · 28 unmodified lines
46044604 * Return of 0 causes the TX thread to restart.
46054605 */
46064606 int iscsit_logout_post_handler(
4607− struct iscsi_cmd *cmd,
4608− struct iscsi_conn *conn)
4607+ struct iscsit_cmd *cmd,
4608+ struct iscsit_conn *conn)
46094609 {
46104610 int ret = 0;
46114611
@@ -4661,9 +4661,9 @@ int iscsit_logout_post_handler( · 49 unmodified lines
46614661 }
46624662 EXPORT_SYMBOL(iscsit_logout_post_handler);
46634663
4664−void iscsit_fail_session(struct iscsi_session *sess)
4664+void iscsit_fail_session(struct iscsit_session *sess)
46654665 {
4666− struct iscsi_conn *conn;
4666+ struct iscsit_conn *conn;
46674667
46684668 spin_lock_bh(&sess->conn_lock);
46694669 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {
@@ -4677,12 +4677,12 @@ void iscsit_fail_session(struct iscsi_session *sess) · 7 unmodified lines
46774677 }
46784678
46794679 void iscsit_stop_session(
4680− struct iscsi_session *sess,
4680+ struct iscsit_session *sess,
46814681 int session_sleep,
46824682 int connection_sleep)
46834683 {
46844684 u16 conn_count = atomic_read(&sess->nconn);
4685− struct iscsi_conn *conn, *conn_tmp = NULL;
4685+ struct iscsit_conn *conn, *conn_tmp = NULL;
46864686 int is_last;
46874687
46884688 spin_lock_bh(&sess->conn_lock);
@@ -4724,7 +4724,7 @@ void iscsit_stop_session( · 35 unmodified lines
47244724
47254725 int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force)
47264726 {
4727− struct iscsi_session *sess;
4727+ struct iscsit_session *sess;
47284728 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
47294729 struct se_session *se_sess, *se_sess_tmp;
47304730 LIST_HEAD(free_list);
@@ -4738,7 +4738,7 @@ int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force) · 7 unmodified lines
47384738
47394739 list_for_each_entry_safe(se_sess, se_sess_tmp, &se_tpg->tpg_sess_list,
47404740 sess_list) {
4741− sess = (struct iscsi_session *)se_sess->fabric_sess_ptr;
4741+ sess = (struct iscsit_session *)se_sess->fabric_sess_ptr;
47424742
47434743 spin_lock(&sess->conn_lock);
47444744 if (atomic_read(&sess->session_fall_back_to_erl0) ||
@@ -4759,7 +4759,7 @@ int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force) · 14 unmodified lines
47594759 spin_unlock_bh(&se_tpg->session_lock);
47604760
47614761 list_for_each_entry_safe(se_sess, se_sess_tmp, &free_list, sess_list) {
4762− sess = (struct iscsi_session *)se_sess->fabric_sess_ptr;
4762+ sess = (struct iscsit_session *)se_sess->fabric_sess_ptr;
47634763
47644764 list_del_init(&se_sess->sess_list);
47654765 iscsit_stop_session(sess, 1, 1);
drivers/target/iscsi/iscsi_target.h+15−15
@@ -5,11 +5,11 @@ · 4 unmodified lines
55 #include <linux/types.h>
66 #include <linux/spinlock.h>
77
8−struct iscsi_cmd;
9−struct iscsi_conn;
8+struct iscsit_cmd;
9+struct iscsit_conn;
1010 struct iscsi_np;
1111 struct iscsi_portal_group;
12−struct iscsi_session;
12+struct iscsit_session;
1313 struct iscsi_tpg_np;
1414 struct kref;
1515 struct sockaddr_storage;
@@ -30,20 +30,20 @@ extern struct iscsi_np *iscsit_add_np(struct sockaddr_storage *, · 14 unmodified lines
3030 extern int iscsit_reset_np_thread(struct iscsi_np *, struct iscsi_tpg_np *,
3131 struct iscsi_portal_group *, bool);
3232 extern int iscsit_del_np(struct iscsi_np *);
33−extern int iscsit_reject_cmd(struct iscsi_cmd *cmd, u8, unsigned char *);
34−extern void iscsit_set_unsolicited_dataout(struct iscsi_cmd *);
35−extern int iscsit_logout_closesession(struct iscsi_cmd *, struct iscsi_conn *);
36−extern int iscsit_logout_closeconnection(struct iscsi_cmd *, struct iscsi_conn *);
37−extern int iscsit_logout_removeconnforrecovery(struct iscsi_cmd *, struct iscsi_conn *);
38−extern int iscsit_send_async_msg(struct iscsi_conn *, u16, u8, u8);
39−extern int iscsit_build_r2ts_for_cmd(struct iscsi_conn *, struct iscsi_cmd *, bool recovery);
40−extern void iscsit_thread_get_cpumask(struct iscsi_conn *);
33+extern int iscsit_reject_cmd(struct iscsit_cmd *cmd, u8, unsigned char *);
34+extern void iscsit_set_unsolicited_dataout(struct iscsit_cmd *);
35+extern int iscsit_logout_closesession(struct iscsit_cmd *, struct iscsit_conn *);
36+extern int iscsit_logout_closeconnection(struct iscsit_cmd *, struct iscsit_conn *);
37+extern int iscsit_logout_removeconnforrecovery(struct iscsit_cmd *, struct iscsit_conn *);
38+extern int iscsit_send_async_msg(struct iscsit_conn *, u16, u8, u8);
39+extern int iscsit_build_r2ts_for_cmd(struct iscsit_conn *, struct iscsit_cmd *, bool recovery);
40+extern void iscsit_thread_get_cpumask(struct iscsit_conn *);
4141 extern int iscsi_target_tx_thread(void *);
4242 extern int iscsi_target_rx_thread(void *);
43−extern int iscsit_close_connection(struct iscsi_conn *);
44−extern int iscsit_close_session(struct iscsi_session *, bool can_sleep);
45−extern void iscsit_fail_session(struct iscsi_session *);
46−extern void iscsit_stop_session(struct iscsi_session *, int, int);
43+extern int iscsit_close_connection(struct iscsit_conn *);
44+extern int iscsit_close_session(struct iscsit_session *, bool can_sleep);
45+extern void iscsit_fail_session(struct iscsit_session *);
46+extern void iscsit_stop_session(struct iscsit_session *, int, int);
4747 extern int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *, int);
4848
4949 extern struct iscsit_global *iscsit_global;
drivers/target/iscsi/iscsi_target_auth.c+5−5
@@ -35,7 +35,7 @@ static char *chap_get_digest_name(const int digest_type) · 34 unmodified lines
3535 }
3636
3737 static int chap_gen_challenge(
38− struct iscsi_conn *conn,
38+ struct iscsit_conn *conn,
3939 int caller,
4040 char *c_str,
4141 unsigned int *c_len)
@@ -128,14 +128,14 @@ out: · 86 unmodified lines
128128 return r;
129129 }
130130
131−static void chap_close(struct iscsi_conn *conn)
131+static void chap_close(struct iscsit_conn *conn)
132132 {
133133 kfree(conn->auth_protocol);
134134 conn->auth_protocol = NULL;
135135 }
136136
137137 static struct iscsi_chap *chap_server_open(
138− struct iscsi_conn *conn,
138+ struct iscsit_conn *conn,
139139 struct iscsi_node_auth *auth,
140140 const char *a_str,
141141 char *aic_str,
@@ -206,7 +206,7 @@ static struct iscsi_chap *chap_server_open( · 64 unmodified lines
206206 }
207207
208208 static int chap_server_compute_hash(
209− struct iscsi_conn *conn,
209+ struct iscsit_conn *conn,
210210 struct iscsi_node_auth *auth,
211211 char *nr_in_ptr,
212212 char *nr_out_ptr,
@@ -497,7 +497,7 @@ out: · 284 unmodified lines
497497 }
498498
499499 u32 chap_main_loop(
500− struct iscsi_conn *conn,
500+ struct iscsit_conn *conn,
501501 struct iscsi_node_auth *auth,
502502 char *in_text,
503503 char *out_text,
drivers/target/iscsi/iscsi_target_auth.h+2−2
@@ -27,9 +27,9 @@ · 26 unmodified lines
2727 #define CHAP_STAGE_SERVER_NR 5
2828
2929 struct iscsi_node_auth;
30−struct iscsi_conn;
30+struct iscsit_conn;
3131
32−extern u32 chap_main_loop(struct iscsi_conn *, struct iscsi_node_auth *, char *, char *,
32+extern u32 chap_main_loop(struct iscsit_conn *, struct iscsi_node_auth *, char *, char *,
3333 int *, int *);
3434
3535 struct iscsi_chap {
drivers/target/iscsi/iscsi_target_configfs.c+17−17
@@ -443,7 +443,7 @@ static ssize_t iscsi_nacl_param_##name##_show(struct config_item *item, \ · 442 unmodified lines
443443 char *page) \
444444 { \
445445 struct se_node_acl *se_nacl = param_to_nacl(item); \
446− struct iscsi_session *sess; \
446+ struct iscsit_session *sess; \
447447 struct se_session *se_sess; \
448448 ssize_t rb; \
449449 \
@@ -498,8 +498,8 @@ static struct configfs_attribute *lio_target_nacl_param_attrs[] = { · 48 unmodified lines
498498 static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page)
499499 {
500500 struct se_node_acl *se_nacl = acl_to_nacl(item);
501− struct iscsi_session *sess;
502− struct iscsi_conn *conn;
501+ struct iscsit_session *sess;
502+ struct iscsit_conn *conn;
503503 struct se_session *se_sess;
504504 ssize_t rb = 0;
505505 u32 max_cmd_sn;
@@ -1344,14 +1344,14 @@ static struct configfs_attribute *lio_target_discovery_auth_attrs[] = { · 838 unmodified lines
13441344
13451345 static int iscsi_get_cmd_state(struct se_cmd *se_cmd)
13461346 {
1347− struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1347+ struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);
13481348
13491349 return cmd->i_state;
13501350 }
13511351
13521352 static u32 lio_sess_get_index(struct se_session *se_sess)
13531353 {
1354− struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1354+ struct iscsit_session *sess = se_sess->fabric_sess_ptr;
13551355
13561356 return sess->session_index;
13571357 }
@@ -1361,7 +1361,7 @@ static u32 lio_sess_get_initiator_sid( · 3 unmodified lines
13611361 unsigned char *buf,
13621362 u32 size)
13631363 {
1364− struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1364+ struct iscsit_session *sess = se_sess->fabric_sess_ptr;
13651365 /*
13661366 * iSCSI Initiator Session Identifier from RFC-3720.
13671367 */
@@ -1370,8 +1370,8 @@ static u32 lio_sess_get_initiator_sid( · 2 unmodified lines
13701370
13711371 static int lio_queue_data_in(struct se_cmd *se_cmd)
13721372 {
1373− struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1374− struct iscsi_conn *conn = cmd->conn;
1373+ struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);
1374+ struct iscsit_conn *conn = cmd->conn;
13751375
13761376 cmd->i_state = ISTATE_SEND_DATAIN;
13771377 return conn->conn_transport->iscsit_queue_data_in(conn, cmd);
@@ -1379,8 +1379,8 @@ static int lio_queue_data_in(struct se_cmd *se_cmd) · 1 unmodified line
13791379
13801380 static int lio_write_pending(struct se_cmd *se_cmd)
13811381 {
1382− struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1383− struct iscsi_conn *conn = cmd->conn;
1382+ struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);
1383+ struct iscsit_conn *conn = cmd->conn;
13841384
13851385 if (!cmd->immediate_data && !cmd->unsolicited_data)
13861386 return conn->conn_transport->iscsit_get_dataout(conn, cmd, false);
@@ -1390,8 +1390,8 @@ static int lio_write_pending(struct se_cmd *se_cmd) · 3 unmodified lines
13901390
13911391 static int lio_queue_status(struct se_cmd *se_cmd)
13921392 {
1393− struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1394− struct iscsi_conn *conn = cmd->conn;
1393+ struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);
1394+ struct iscsit_conn *conn = cmd->conn;
13951395
13961396 cmd->i_state = ISTATE_SEND_STATUS;
13971397
@@ -1403,7 +1403,7 @@ static int lio_queue_status(struct se_cmd *se_cmd) · 5 unmodified lines
14031403
14041404 static void lio_queue_tm_rsp(struct se_cmd *se_cmd)
14051405 {
1406− struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1406+ struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);
14071407
14081408 cmd->i_state = ISTATE_SEND_TASKMGTRSP;
14091409 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
@@ -1411,7 +1411,7 @@ static void lio_queue_tm_rsp(struct se_cmd *se_cmd) · 1 unmodified line
14111411
14121412 static void lio_aborted_task(struct se_cmd *se_cmd)
14131413 {
1414− struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1414+ struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);
14151415
14161416 cmd->conn->conn_transport->iscsit_aborted_task(cmd->conn, cmd);
14171417 }
@@ -1472,11 +1472,11 @@ static int lio_tpg_check_prot_fabric_only( · 54 unmodified lines
14721472
14731473 /*
14741474 * This function calls iscsit_inc_session_usage_count() on the
1475− * struct iscsi_session in question.
1475+ * struct iscsit_session in question.
14761476 */
14771477 static void lio_tpg_close_session(struct se_session *se_sess)
14781478 {
1479− struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1479+ struct iscsit_session *sess = se_sess->fabric_sess_ptr;
14801480 struct se_portal_group *se_tpg = &sess->tpg->tpg_se_tpg;
14811481
14821482 spin_lock_bh(&se_tpg->session_lock);
@@ -1526,7 +1526,7 @@ static int lio_check_stop_free(struct se_cmd *se_cmd) · 43 unmodified lines
15261526
15271527 static void lio_release_cmd(struct se_cmd *se_cmd)
15281528 {
1529− struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1529+ struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);
15301530
15311531 pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd);
15321532 iscsit_release_cmd(cmd);
drivers/target/iscsi/iscsi_target_datain_values.c+14−14
@@ -32,14 +32,14 @@ struct iscsi_datain_req *iscsit_allocate_datain_req(void) · 31 unmodified lines
3232 return dr;
3333 }
3434
35−void iscsit_attach_datain_req(struct iscsi_cmd *cmd, struct iscsi_datain_req *dr)
35+void iscsit_attach_datain_req(struct iscsit_cmd *cmd, struct iscsi_datain_req *dr)
3636 {
3737 spin_lock(&cmd->datain_lock);
3838 list_add_tail(&dr->cmd_datain_node, &cmd->datain_list);
3939 spin_unlock(&cmd->datain_lock);
4040 }
4141
42−void iscsit_free_datain_req(struct iscsi_cmd *cmd, struct iscsi_datain_req *dr)
42+void iscsit_free_datain_req(struct iscsit_cmd *cmd, struct iscsi_datain_req *dr)
4343 {
4444 spin_lock(&cmd->datain_lock);
4545 list_del(&dr->cmd_datain_node);
@@ -48,7 +48,7 @@ void iscsit_free_datain_req(struct iscsi_cmd *cmd, struct iscsi_datain_req *dr) · 2 unmodified lines
4848 kmem_cache_free(lio_dr_cache, dr);
4949 }
5050
51−void iscsit_free_all_datain_reqs(struct iscsi_cmd *cmd)
51+void iscsit_free_all_datain_reqs(struct iscsit_cmd *cmd)
5252 {
5353 struct iscsi_datain_req *dr, *dr_tmp;
5454
@@ -60,7 +60,7 @@ void iscsit_free_all_datain_reqs(struct iscsi_cmd *cmd) · 5 unmodified lines
6060 spin_unlock(&cmd->datain_lock);
6161 }
6262
63−struct iscsi_datain_req *iscsit_get_datain_req(struct iscsi_cmd *cmd)
63+struct iscsi_datain_req *iscsit_get_datain_req(struct iscsit_cmd *cmd)
6464 {
6565 if (list_empty(&cmd->datain_list)) {
6666 pr_err("cmd->datain_list is empty for ITT:"
@@ -76,11 +76,11 @@ struct iscsi_datain_req *iscsit_get_datain_req(struct iscsi_cmd *cmd) · 9 unmodified lines
7676 * For Normal and Recovery DataSequenceInOrder=Yes and DataPDUInOrder=Yes.
7777 */
7878 static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_yes(
79− struct iscsi_cmd *cmd,
79+ struct iscsit_cmd *cmd,
8080 struct iscsi_datain *datain)
8181 {
8282 u32 next_burst_len, read_data_done, read_data_left;
83− struct iscsi_conn *conn = cmd->conn;
83+ struct iscsit_conn *conn = cmd->conn;
8484 struct iscsi_datain_req *dr;
8585
8686 dr = iscsit_get_datain_req(cmd);
@@ -174,11 +174,11 @@ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_yes( · 87 unmodified lines
174174 * For Normal and Recovery DataSequenceInOrder=No and DataPDUInOrder=Yes.
175175 */
176176 static struct iscsi_datain_req *iscsit_set_datain_values_no_and_yes(
177− struct iscsi_cmd *cmd,
177+ struct iscsit_cmd *cmd,
178178 struct iscsi_datain *datain)
179179 {
180180 u32 offset, read_data_done, read_data_left, seq_send_order;
181− struct iscsi_conn *conn = cmd->conn;
181+ struct iscsit_conn *conn = cmd->conn;
182182 struct iscsi_datain_req *dr;
183183 struct iscsi_seq *seq;
184184
@@ -295,11 +295,11 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_yes( · 110 unmodified lines
295295 * For Normal and Recovery DataSequenceInOrder=Yes and DataPDUInOrder=No.
296296 */
297297 static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_no(
298− struct iscsi_cmd *cmd,
298+ struct iscsit_cmd *cmd,
299299 struct iscsi_datain *datain)
300300 {
301301 u32 next_burst_len, read_data_done, read_data_left;
302− struct iscsi_conn *conn = cmd->conn;
302+ struct iscsit_conn *conn = cmd->conn;
303303 struct iscsi_datain_req *dr;
304304 struct iscsi_pdu *pdu;
305305
@@ -394,11 +394,11 @@ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_no( · 88 unmodified lines
394394 * For Normal and Recovery DataSequenceInOrder=No and DataPDUInOrder=No.
395395 */
396396 static struct iscsi_datain_req *iscsit_set_datain_values_no_and_no(
397− struct iscsi_cmd *cmd,
397+ struct iscsit_cmd *cmd,
398398 struct iscsi_datain *datain)
399399 {
400400 u32 read_data_done, read_data_left, seq_send_order;
401− struct iscsi_conn *conn = cmd->conn;
401+ struct iscsit_conn *conn = cmd->conn;
402402 struct iscsi_datain_req *dr;
403403 struct iscsi_pdu *pdu;
404404 struct iscsi_seq *seq = NULL;
@@ -496,10 +496,10 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_no( · 91 unmodified lines
496496 }
497497
498498 struct iscsi_datain_req *iscsit_get_datain_values(
499− struct iscsi_cmd *cmd,
499+ struct iscsit_cmd *cmd,
500500 struct iscsi_datain *datain)
501501 {
502− struct iscsi_conn *conn = cmd->conn;
502+ struct iscsit_conn *conn = cmd->conn;
503503
504504 if (conn->sess->sess_ops->DataSequenceInOrder &&
505505 conn->sess->sess_ops->DataPDUInOrder)
drivers/target/iscsi/iscsi_target_datain_values.h+6−6
@@ -2,15 +2,15 @@ · 1 unmodified line
22 #ifndef ISCSI_TARGET_DATAIN_VALUES_H
33 #define ISCSI_TARGET_DATAIN_VALUES_H
44
5−struct iscsi_cmd;
5+struct iscsit_cmd;
66 struct iscsi_datain;
77
88 extern struct iscsi_datain_req *iscsit_allocate_datain_req(void);
9−extern void iscsit_attach_datain_req(struct iscsi_cmd *, struct iscsi_datain_req *);
10−extern void iscsit_free_datain_req(struct iscsi_cmd *, struct iscsi_datain_req *);
11−extern void iscsit_free_all_datain_reqs(struct iscsi_cmd *);
12−extern struct iscsi_datain_req *iscsit_get_datain_req(struct iscsi_cmd *);
13−extern struct iscsi_datain_req *iscsit_get_datain_values(struct iscsi_cmd *,
9+extern void iscsit_attach_datain_req(struct iscsit_cmd *, struct iscsi_datain_req *);
10+extern void iscsit_free_datain_req(struct iscsit_cmd *, struct iscsi_datain_req *);
11+extern void iscsit_free_all_datain_reqs(struct iscsit_cmd *);
12+extern struct iscsi_datain_req *iscsit_get_datain_req(struct iscsit_cmd *);
13+extern struct iscsi_datain_req *iscsit_get_datain_values(struct iscsit_cmd *,
1414 struct iscsi_datain *);
1515
1616 #endif /*** ISCSI_TARGET_DATAIN_VALUES_H ***/
drivers/target/iscsi/iscsi_target_device.c+2−2
@@ -17,7 +17,7 @@ · 16 unmodified lines
1717 #include "iscsi_target_tpg.h"
1818 #include "iscsi_target_util.h"
1919
20−void iscsit_determine_maxcmdsn(struct iscsi_session *sess)
20+void iscsit_determine_maxcmdsn(struct iscsit_session *sess)
2121 {
2222 struct se_node_acl *se_nacl;
2323
@@ -42,7 +42,7 @@ void iscsit_determine_maxcmdsn(struct iscsi_session *sess) · 18 unmodified lines
4242 atomic_add(se_nacl->queue_depth - 1, &sess->max_cmd_sn);
4343 }
4444
45−void iscsit_increment_maxcmdsn(struct iscsi_cmd *cmd, struct iscsi_session *sess)
45+void iscsit_increment_maxcmdsn(struct iscsit_cmd *cmd, struct iscsit_session *sess)
4646 {
4747 u32 max_cmd_sn;
4848
drivers/target/iscsi/iscsi_target_device.h+4−4
@@ -2,10 +2,10 @@ · 1 unmodified line
22 #ifndef ISCSI_TARGET_DEVICE_H
33 #define ISCSI_TARGET_DEVICE_H
44
5−struct iscsi_cmd;
6−struct iscsi_session;
5+struct iscsit_cmd;
6+struct iscsit_session;
77
8−extern void iscsit_determine_maxcmdsn(struct iscsi_session *);
9−extern void iscsit_increment_maxcmdsn(struct iscsi_cmd *, struct iscsi_session *);
8+extern void iscsit_determine_maxcmdsn(struct iscsit_session *);
9+extern void iscsit_increment_maxcmdsn(struct iscsit_cmd *, struct iscsit_session *);
1010
1111 #endif /* ISCSI_TARGET_DEVICE_H */
drivers/target/iscsi/iscsi_target_erl0.c+34−34
@@ -24,14 +24,14 @@ · 23 unmodified lines
2424 #include "iscsi_target.h"
2525
2626 /*
27− * Used to set values in struct iscsi_cmd that iscsit_dataout_check_sequence()
27+ * Used to set values in struct iscsit_cmd that iscsit_dataout_check_sequence()
2828 * checks against to determine a PDU's Offset+Length is within the current
2929 * DataOUT Sequence. Used for DataSequenceInOrder=Yes only.
3030 */
3131 void iscsit_set_dataout_sequence_values(
32− struct iscsi_cmd *cmd)
32+ struct iscsit_cmd *cmd)
3333 {
34− struct iscsi_conn *conn = cmd->conn;
34+ struct iscsit_conn *conn = cmd->conn;
3535 /*
3636 * Still set seq_start_offset and seq_end_offset for Unsolicited
3737 * DataOUT, even if DataSequenceInOrder=No.
@@ -63,10 +63,10 @@ void iscsit_set_dataout_sequence_values( · 25 unmodified lines
6363 }
6464
6565 static int iscsit_dataout_within_command_recovery_check(
66− struct iscsi_cmd *cmd,
66+ struct iscsit_cmd *cmd,
6767 unsigned char *buf)
6868 {
69− struct iscsi_conn *conn = cmd->conn;
69+ struct iscsit_conn *conn = cmd->conn;
7070 struct iscsi_data *hdr = (struct iscsi_data *) buf;
7171 u32 payload_length = ntoh24(hdr->dlength);
7272
@@ -129,11 +129,11 @@ dump: · 56 unmodified lines
129129 }
130130
131131 static int iscsit_dataout_check_unsolicited_sequence(
132− struct iscsi_cmd *cmd,
132+ struct iscsit_cmd *cmd,
133133 unsigned char *buf)
134134 {
135135 u32 first_burst_len;
136− struct iscsi_conn *conn = cmd->conn;
136+ struct iscsit_conn *conn = cmd->conn;
137137 struct iscsi_data *hdr = (struct iscsi_data *) buf;
138138 u32 payload_length = ntoh24(hdr->dlength);
139139
@@ -204,11 +204,11 @@ out: · 64 unmodified lines
204204 }
205205
206206 static int iscsit_dataout_check_sequence(
207− struct iscsi_cmd *cmd,
207+ struct iscsit_cmd *cmd,
208208 unsigned char *buf)
209209 {
210210 u32 next_burst_len;
211− struct iscsi_conn *conn = cmd->conn;
211+ struct iscsit_conn *conn = cmd->conn;
212212 struct iscsi_seq *seq = NULL;
213213 struct iscsi_data *hdr = (struct iscsi_data *) buf;
214214 u32 payload_length = ntoh24(hdr->dlength);
@@ -333,11 +333,11 @@ out: · 118 unmodified lines
333333 }
334334
335335 static int iscsit_dataout_check_datasn(
336− struct iscsi_cmd *cmd,
336+ struct iscsit_cmd *cmd,
337337 unsigned char *buf)
338338 {
339339 u32 data_sn = 0;
340− struct iscsi_conn *conn = cmd->conn;
340+ struct iscsit_conn *conn = cmd->conn;
341341 struct iscsi_data *hdr = (struct iscsi_data *) buf;
342342 u32 payload_length = ntoh24(hdr->dlength);
343343
@@ -384,17 +384,17 @@ dump: · 40 unmodified lines
384384 }
385385
386386 static int iscsit_dataout_pre_datapduinorder_yes(
387− struct iscsi_cmd *cmd,
387+ struct iscsit_cmd *cmd,
388388 unsigned char *buf)
389389 {
390390 int dump = 0, recovery = 0;
391− struct iscsi_conn *conn = cmd->conn;
391+ struct iscsit_conn *conn = cmd->conn;
392392 struct iscsi_data *hdr = (struct iscsi_data *) buf;
393393 u32 payload_length = ntoh24(hdr->dlength);
394394
395395 /*
396396 * For DataSequenceInOrder=Yes: If the offset is greater than the global
397− * DataPDUInOrder=Yes offset counter in struct iscsi_cmd a protcol error has
397+ * DataPDUInOrder=Yes offset counter in struct iscsit_cmd a protcol error has
398398 * occurred and fail the connection.
399399 *
400400 * For DataSequenceInOrder=No: If the offset is greater than the per
@@ -446,7 +446,7 @@ dump: · 45 unmodified lines
446446 }
447447
448448 static int iscsit_dataout_pre_datapduinorder_no(
449− struct iscsi_cmd *cmd,
449+ struct iscsit_cmd *cmd,
450450 unsigned char *buf)
451451 {
452452 struct iscsi_pdu *pdu;
@@ -477,7 +477,7 @@ static int iscsit_dataout_pre_datapduinorder_no( · 24 unmodified lines
477477 return DATAOUT_NORMAL;
478478 }
479479
480−static int iscsit_dataout_update_r2t(struct iscsi_cmd *cmd, u32 offset, u32 length)
480+static int iscsit_dataout_update_r2t(struct iscsit_cmd *cmd, u32 offset, u32 length)
481481 {
482482 struct iscsi_r2t *r2t;
483483
@@ -497,7 +497,7 @@ static int iscsit_dataout_update_r2t(struct iscsi_cmd *cmd, u32 offset, u32 leng · 13 unmodified lines
497497 }
498498
499499 static int iscsit_dataout_update_datapduinorder_no(
500− struct iscsi_cmd *cmd,
500+ struct iscsit_cmd *cmd,
501501 u32 data_sn,
502502 int f_bit)
503503 {
@@ -530,11 +530,11 @@ static int iscsit_dataout_update_datapduinorder_no( · 26 unmodified lines
530530 }
531531
532532 static int iscsit_dataout_post_crc_passed(
533− struct iscsi_cmd *cmd,
533+ struct iscsit_cmd *cmd,
534534 unsigned char *buf)
535535 {
536536 int ret, send_r2t = 0;
537− struct iscsi_conn *conn = cmd->conn;
537+ struct iscsit_conn *conn = cmd->conn;
538538 struct iscsi_seq *seq = NULL;
539539 struct iscsi_data *hdr = (struct iscsi_data *) buf;
540540 u32 payload_length = ntoh24(hdr->dlength);
@@ -641,10 +641,10 @@ static int iscsit_dataout_post_crc_passed( · 100 unmodified lines
641641 }
642642
643643 static int iscsit_dataout_post_crc_failed(
644− struct iscsi_cmd *cmd,
644+ struct iscsit_cmd *cmd,
645645 unsigned char *buf)
646646 {
647− struct iscsi_conn *conn = cmd->conn;
647+ struct iscsit_conn *conn = cmd->conn;
648648 struct iscsi_pdu *pdu;
649649 struct iscsi_data *hdr = (struct iscsi_data *) buf;
650650 u32 payload_length = ntoh24(hdr->dlength);
@@ -679,11 +679,11 @@ recover: · 28 unmodified lines
679679 * and CRC computed.
680680 */
681681 int iscsit_check_pre_dataout(
682− struct iscsi_cmd *cmd,
682+ struct iscsit_cmd *cmd,
683683 unsigned char *buf)
684684 {
685685 int ret;
686− struct iscsi_conn *conn = cmd->conn;
686+ struct iscsit_conn *conn = cmd->conn;
687687
688688 ret = iscsit_dataout_within_command_recovery_check(cmd, buf);
689689 if ((ret == DATAOUT_WITHIN_COMMAND_RECOVERY) ||
@@ -717,11 +717,11 @@ int iscsit_check_pre_dataout( · 27 unmodified lines
717717 * and CRC computed.
718718 */
719719 int iscsit_check_post_dataout(
720− struct iscsi_cmd *cmd,
720+ struct iscsit_cmd *cmd,
721721 unsigned char *buf,
722722 u8 data_crc_failed)
723723 {
724− struct iscsi_conn *conn = cmd->conn;
724+ struct iscsit_conn *conn = cmd->conn;
725725
726726 cmd->dataout_timeout_retries = 0;
727727
@@ -743,7 +743,7 @@ int iscsit_check_post_dataout( · 15 unmodified lines
743743
744744 void iscsit_handle_time2retain_timeout(struct timer_list *t)
745745 {
746− struct iscsi_session *sess = from_timer(sess, t, time2retain_timer);
746+ struct iscsit_session *sess = from_timer(sess, t, time2retain_timer);
747747 struct iscsi_portal_group *tpg = sess->tpg;
748748 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
749749
@@ -768,7 +768,7 @@ void iscsit_handle_time2retain_timeout(struct timer_list *t) · 18 unmodified lines
768768 iscsit_close_session(sess, false);
769769 }
770770
771−void iscsit_start_time2retain_handler(struct iscsi_session *sess)
771+void iscsit_start_time2retain_handler(struct iscsit_session *sess)
772772 {
773773 int tpg_active;
774774 /*
@@ -794,7 +794,7 @@ void iscsit_start_time2retain_handler(struct iscsi_session *sess) · 19 unmodified lines
794794 jiffies + sess->sess_ops->DefaultTime2Retain * HZ);
795795 }
796796
797−int iscsit_stop_time2retain_timer(struct iscsi_session *sess)
797+int iscsit_stop_time2retain_timer(struct iscsit_session *sess)
798798 {
799799 struct iscsi_portal_group *tpg = sess->tpg;
800800 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
@@ -819,7 +819,7 @@ int iscsit_stop_time2retain_timer(struct iscsi_session *sess) · 18 unmodified lines
819819 return 0;
820820 }
821821
822−void iscsit_connection_reinstatement_rcfr(struct iscsi_conn *conn)
822+void iscsit_connection_reinstatement_rcfr(struct iscsit_conn *conn)
823823 {
824824 spin_lock_bh(&conn->state_lock);
825825 if (atomic_read(&conn->connection_exit)) {
@@ -843,7 +843,7 @@ sleep: · 17 unmodified lines
843843 complete(&conn->conn_post_wait_comp);
844844 }
845845
846−void iscsit_cause_connection_reinstatement(struct iscsi_conn *conn, int sleep)
846+void iscsit_cause_connection_reinstatement(struct iscsit_conn *conn, int sleep)
847847 {
848848 spin_lock_bh(&conn->state_lock);
849849 if (atomic_read(&conn->connection_exit)) {
@@ -880,7 +880,7 @@ void iscsit_cause_connection_reinstatement(struct iscsi_conn *conn, int sleep) · 30 unmodified lines
880880 }
881881 EXPORT_SYMBOL(iscsit_cause_connection_reinstatement);
882882
883−void iscsit_fall_back_to_erl0(struct iscsi_session *sess)
883+void iscsit_fall_back_to_erl0(struct iscsit_session *sess)
884884 {
885885 pr_debug("Falling back to ErrorRecoveryLevel=0 for SID:"
886886 " %u\n", sess->sid);
@@ -888,9 +888,9 @@ void iscsit_fall_back_to_erl0(struct iscsi_session *sess) · 1 unmodified line
888888 atomic_set(&sess->session_fall_back_to_erl0, 1);
889889 }
890890
891−static void iscsit_handle_connection_cleanup(struct iscsi_conn *conn)
891+static void iscsit_handle_connection_cleanup(struct iscsit_conn *conn)
892892 {
893− struct iscsi_session *sess = conn->sess;
893+ struct iscsit_session *sess = conn->sess;
894894
895895 if ((sess->sess_ops->ErrorRecoveryLevel == 2) &&
896896 !atomic_read(&sess->session_reinstatement) &&
@@ -904,7 +904,7 @@ static void iscsit_handle_connection_cleanup(struct iscsi_conn *conn) · 7 unmodified lines
904904 }
905905 }
906906
907−void iscsit_take_action_for_connection_exit(struct iscsi_conn *conn, bool *conn_freed)
907+void iscsit_take_action_for_connection_exit(struct iscsit_conn *conn, bool *conn_freed)
908908 {
909909 *conn_freed = false;
910910
drivers/target/iscsi/iscsi_target_erl0.h+12−12
@@ -4,19 +4,19 @@ · 3 unmodified lines
44
55 #include <linux/types.h>
66
7−struct iscsi_cmd;
8−struct iscsi_conn;
9−struct iscsi_session;
7+struct iscsit_cmd;
8+struct iscsit_conn;
9+struct iscsit_session;
1010
11−extern void iscsit_set_dataout_sequence_values(struct iscsi_cmd *);
12−extern int iscsit_check_pre_dataout(struct iscsi_cmd *, unsigned char *);
13−extern int iscsit_check_post_dataout(struct iscsi_cmd *, unsigned char *, u8);
14−extern void iscsit_start_time2retain_handler(struct iscsi_session *);
11+extern void iscsit_set_dataout_sequence_values(struct iscsit_cmd *);
12+extern int iscsit_check_pre_dataout(struct iscsit_cmd *, unsigned char *);
13+extern int iscsit_check_post_dataout(struct iscsit_cmd *, unsigned char *, u8);
14+extern void iscsit_start_time2retain_handler(struct iscsit_session *);
1515 extern void iscsit_handle_time2retain_timeout(struct timer_list *t);
16−extern int iscsit_stop_time2retain_timer(struct iscsi_session *);
17−extern void iscsit_connection_reinstatement_rcfr(struct iscsi_conn *);
18−extern void iscsit_cause_connection_reinstatement(struct iscsi_conn *, int);
19−extern void iscsit_fall_back_to_erl0(struct iscsi_session *);
20−extern void iscsit_take_action_for_connection_exit(struct iscsi_conn *, bool *);
16+extern int iscsit_stop_time2retain_timer(struct iscsit_session *);
17+extern void iscsit_connection_reinstatement_rcfr(struct iscsit_conn *);
18+extern void iscsit_cause_connection_reinstatement(struct iscsit_conn *, int);
19+extern void iscsit_fall_back_to_erl0(struct iscsit_session *);
20+extern void iscsit_take_action_for_connection_exit(struct iscsit_conn *, bool *);
2121
2222 #endif /*** ISCSI_TARGET_ERL0_H ***/
drivers/target/iscsi/iscsi_target_erl1.c+46−46
@@ -36,7 +36,7 @@ · 35 unmodified lines
3636 * to be dumped.
3737 */
3838 int iscsit_dump_data_payload(
39− struct iscsi_conn *conn,
39+ struct iscsit_conn *conn,
4040 u32 buf_len,
4141 int dump_padding_digest)
4242 {
@@ -87,7 +87,7 @@ int iscsit_dump_data_payload( · 44 unmodified lines
8787 * Used for retransmitting R2Ts from a R2T SNACK request.
8888 */
8989 static int iscsit_send_recovery_r2t_for_snack(
90− struct iscsi_cmd *cmd,
90+ struct iscsit_cmd *cmd,
9191 struct iscsi_r2t *r2t)
9292 {
9393 /*
@@ -109,7 +109,7 @@ static int iscsit_send_recovery_r2t_for_snack( · 15 unmodified lines
109109 }
110110
111111 static int iscsit_handle_r2t_snack(
112− struct iscsi_cmd *cmd,
112+ struct iscsit_cmd *cmd,
113113 unsigned char *buf,
114114 u32 begrun,
115115 u32 runlength)
@@ -167,13 +167,13 @@ static int iscsit_handle_r2t_snack( · 51 unmodified lines
167167 * FIXME: How is this handled for a RData SNACK?
168168 */
169169 int iscsit_create_recovery_datain_values_datasequenceinorder_yes(
170− struct iscsi_cmd *cmd,
170+ struct iscsit_cmd *cmd,
171171 struct iscsi_datain_req *dr)
172172 {
173173 u32 data_sn = 0, data_sn_count = 0;
174174 u32 pdu_start = 0, seq_no = 0;
175175 u32 begrun = dr->begrun;
176− struct iscsi_conn *conn = cmd->conn;
176+ struct iscsit_conn *conn = cmd->conn;
177177
178178 while (begrun > data_sn++) {
179179 data_sn_count++;
@@ -213,18 +213,18 @@ int iscsit_create_recovery_datain_values_datasequenceinorder_yes( · 33 unmodified lines
213213 * FIXME: How is this handled for a RData SNACK?
214214 */
215215 int iscsit_create_recovery_datain_values_datasequenceinorder_no(
216− struct iscsi_cmd *cmd,
216+ struct iscsit_cmd *cmd,
217217 struct iscsi_datain_req *dr)
218218 {
219219 int found_seq = 0, i;
220220 u32 data_sn, read_data_done = 0, seq_send_order = 0;
221221 u32 begrun = dr->begrun;
222222 u32 runlength = dr->runlength;
223− struct iscsi_conn *conn = cmd->conn;
223+ struct iscsit_conn *conn = cmd->conn;
224224 struct iscsi_seq *first_seq = NULL, *seq = NULL;
225225
226226 if (!cmd->seq_list) {
227− pr_err("struct iscsi_cmd->seq_list is NULL!\n");
227+ pr_err("struct iscsit_cmd->seq_list is NULL!\n");
228228 return -1;
229229 }
230230
@@ -371,12 +371,12 @@ done: · 140 unmodified lines
371371 }
372372
373373 static int iscsit_handle_recovery_datain(
374− struct iscsi_cmd *cmd,
374+ struct iscsit_cmd *cmd,
375375 unsigned char *buf,
376376 u32 begrun,
377377 u32 runlength)
378378 {
379− struct iscsi_conn *conn = cmd->conn;
379+ struct iscsit_conn *conn = cmd->conn;
380380 struct iscsi_datain_req *dr;
381381 struct se_cmd *se_cmd = &cmd->se_cmd;
382382
@@ -432,14 +432,14 @@ static int iscsit_handle_recovery_datain( · 49 unmodified lines
432432 }
433433
434434 int iscsit_handle_recovery_datain_or_r2t(
435− struct iscsi_conn *conn,
435+ struct iscsit_conn *conn,
436436 unsigned char *buf,
437437 itt_t init_task_tag,
438438 u32 targ_xfer_tag,
439439 u32 begrun,
440440 u32 runlength)
441441 {
442− struct iscsi_cmd *cmd;
442+ struct iscsit_cmd *cmd;
443443
444444 cmd = iscsit_find_cmd_from_itt(conn, init_task_tag);
445445 if (!cmd)
@@ -465,13 +465,13 @@ int iscsit_handle_recovery_datain_or_r2t( · 19 unmodified lines
465465
466466 /* #warning FIXME: Status SNACK needs to be dependent on OPCODE!!! */
467467 int iscsit_handle_status_snack(
468− struct iscsi_conn *conn,
468+ struct iscsit_conn *conn,
469469 itt_t init_task_tag,
470470 u32 targ_xfer_tag,
471471 u32 begrun,
472472 u32 runlength)
473473 {
474− struct iscsi_cmd *cmd = NULL;
474+ struct iscsit_cmd *cmd = NULL;
475475 u32 last_statsn;
476476 int found_cmd;
477477
@@ -529,12 +529,12 @@ int iscsit_handle_status_snack( · 51 unmodified lines
529529 }
530530
531531 int iscsit_handle_data_ack(
532− struct iscsi_conn *conn,
532+ struct iscsit_conn *conn,
533533 u32 targ_xfer_tag,
534534 u32 begrun,
535535 u32 runlength)
536536 {
537− struct iscsi_cmd *cmd = NULL;
537+ struct iscsit_cmd *cmd = NULL;
538538
539539 cmd = iscsit_find_cmd_from_ttt(conn, targ_xfer_tag);
540540 if (!cmd) {
@@ -565,7 +565,7 @@ int iscsit_handle_data_ack( · 24 unmodified lines
565565 }
566566
567567 static int iscsit_send_recovery_r2t(
568− struct iscsi_cmd *cmd,
568+ struct iscsit_cmd *cmd,
569569 u32 offset,
570570 u32 xfer_len)
571571 {
@@ -579,12 +579,12 @@ static int iscsit_send_recovery_r2t( · 7 unmodified lines
579579 }
580580
581581 int iscsit_dataout_datapduinorder_no_fbit(
582− struct iscsi_cmd *cmd,
582+ struct iscsit_cmd *cmd,
583583 struct iscsi_pdu *pdu)
584584 {
585585 int i, send_recovery_r2t = 0, recovery = 0;
586586 u32 length = 0, offset = 0, pdu_count = 0, xfer_len = 0;
587− struct iscsi_conn *conn = cmd->conn;
587+ struct iscsit_conn *conn = cmd->conn;
588588 struct iscsi_pdu *first_pdu = NULL;
589589
590590 /*
@@ -655,14 +655,14 @@ int iscsit_dataout_datapduinorder_no_fbit( · 64 unmodified lines
655655 }
656656
657657 static int iscsit_recalculate_dataout_values(
658− struct iscsi_cmd *cmd,
658+ struct iscsit_cmd *cmd,
659659 u32 pdu_offset,
660660 u32 pdu_length,
661661 u32 *r2t_offset,
662662 u32 *r2t_length)
663663 {
664664 int i;
665− struct iscsi_conn *conn = cmd->conn;
665+ struct iscsit_conn *conn = cmd->conn;
666666 struct iscsi_pdu *pdu = NULL;
667667
668668 if (conn->sess->sess_ops->DataSequenceInOrder) {
@@ -732,7 +732,7 @@ static int iscsit_recalculate_dataout_values( · 63 unmodified lines
732732 }
733733
734734 int iscsit_recover_dataout_sequence(
735− struct iscsi_cmd *cmd,
735+ struct iscsit_cmd *cmd,
736736 u32 pdu_offset,
737737 u32 pdu_length)
738738 {
@@ -767,7 +767,7 @@ static struct iscsi_ooo_cmdsn *iscsit_allocate_ooo_cmdsn(void) · 28 unmodified lines
767767 }
768768
769769 static int iscsit_attach_ooo_cmdsn(
770− struct iscsi_session *sess,
770+ struct iscsit_session *sess,
771771 struct iscsi_ooo_cmdsn *ooo_cmdsn)
772772 {
773773 struct iscsi_ooo_cmdsn *ooo_tail, *ooo_tmp;
@@ -815,20 +815,20 @@ static int iscsit_attach_ooo_cmdsn( · 41 unmodified lines
815815
816816 /*
817817 * Removes an struct iscsi_ooo_cmdsn from a session's list,
818− * called with struct iscsi_session->cmdsn_mutex held.
818+ * called with struct iscsit_session->cmdsn_mutex held.
819819 */
820820 void iscsit_remove_ooo_cmdsn(
821− struct iscsi_session *sess,
821+ struct iscsit_session *sess,
822822 struct iscsi_ooo_cmdsn *ooo_cmdsn)
823823 {
824824 list_del(&ooo_cmdsn->ooo_list);
825825 kmem_cache_free(lio_ooo_cache, ooo_cmdsn);
826826 }
827827
828−void iscsit_clear_ooo_cmdsns_for_conn(struct iscsi_conn *conn)
828+void iscsit_clear_ooo_cmdsns_for_conn(struct iscsit_conn *conn)
829829 {
830830 struct iscsi_ooo_cmdsn *ooo_cmdsn;
831− struct iscsi_session *sess = conn->sess;
831+ struct iscsit_session *sess = conn->sess;
832832
833833 mutex_lock(&sess->cmdsn_mutex);
834834 list_for_each_entry(ooo_cmdsn, &sess->sess_ooo_cmdsn_list, ooo_list) {
@@ -840,10 +840,10 @@ void iscsit_clear_ooo_cmdsns_for_conn(struct iscsi_conn *conn) · 5 unmodified lines
840840 mutex_unlock(&sess->cmdsn_mutex);
841841 }
842842
843−int iscsit_execute_ooo_cmdsns(struct iscsi_session *sess)
843+int iscsit_execute_ooo_cmdsns(struct iscsit_session *sess)
844844 {
845845 int ooo_count = 0;
846− struct iscsi_cmd *cmd = NULL;
846+ struct iscsit_cmd *cmd = NULL;
847847 struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp;
848848
849849 lockdep_assert_held(&sess->cmdsn_mutex);
@@ -884,10 +884,10 @@ int iscsit_execute_ooo_cmdsns(struct iscsi_session *sess) · 34 unmodified lines
884884 * 2. With no locks held directly from iscsi_handle_XXX_pdu() functions
885885 * for immediate commands.
886886 */
887−int iscsit_execute_cmd(struct iscsi_cmd *cmd, int ooo)
887+int iscsit_execute_cmd(struct iscsit_cmd *cmd, int ooo)
888888 {
889889 struct se_cmd *se_cmd = &cmd->se_cmd;
890− struct iscsi_conn *conn = cmd->conn;
890+ struct iscsit_conn *conn = cmd->conn;
891891 int lr = 0;
892892
893893 spin_lock_bh(&cmd->istate_lock);
@@ -994,7 +994,7 @@ int iscsit_execute_cmd(struct iscsi_cmd *cmd, int ooo) · 100 unmodified lines
994994 return 0;
995995 }
996996
997−void iscsit_free_all_ooo_cmdsns(struct iscsi_session *sess)
997+void iscsit_free_all_ooo_cmdsns(struct iscsit_session *sess)
998998 {
999999 struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp;
10001000
@@ -1009,8 +1009,8 @@ void iscsit_free_all_ooo_cmdsns(struct iscsi_session *sess) · 8 unmodified lines
10091009 }
10101010
10111011 int iscsit_handle_ooo_cmdsn(
1012− struct iscsi_session *sess,
1013− struct iscsi_cmd *cmd,
1012+ struct iscsit_session *sess,
1013+ struct iscsit_cmd *cmd,
10141014 u32 cmdsn)
10151015 {
10161016 int batch = 0;
@@ -1049,11 +1049,11 @@ int iscsit_handle_ooo_cmdsn( · 32 unmodified lines
10491049 }
10501050
10511051 static int iscsit_set_dataout_timeout_values(
1052− struct iscsi_cmd *cmd,
1052+ struct iscsit_cmd *cmd,
10531053 u32 *offset,
10541054 u32 *length)
10551055 {
1056− struct iscsi_conn *conn = cmd->conn;
1056+ struct iscsit_conn *conn = cmd->conn;
10571057 struct iscsi_r2t *r2t;
10581058
10591059 if (cmd->unsolicited_data) {
@@ -1095,9 +1095,9 @@ void iscsit_handle_dataout_timeout(struct timer_list *t) · 35 unmodified lines
10951095 {
10961096 u32 pdu_length = 0, pdu_offset = 0;
10971097 u32 r2t_length = 0, r2t_offset = 0;
1098− struct iscsi_cmd *cmd = from_timer(cmd, t, dataout_timer);
1099− struct iscsi_conn *conn = cmd->conn;
1100− struct iscsi_session *sess = NULL;
1098+ struct iscsit_cmd *cmd = from_timer(cmd, t, dataout_timer);
1099+ struct iscsit_conn *conn = cmd->conn;
1100+ struct iscsit_session *sess = NULL;
11011101 struct iscsi_node_attrib *na;
11021102
11031103 iscsit_inc_conn_usage_count(conn);
@@ -1179,10 +1179,10 @@ failure: · 75 unmodified lines
11791179 iscsit_dec_conn_usage_count(conn);
11801180 }
11811181
1182−void iscsit_mod_dataout_timer(struct iscsi_cmd *cmd)
1182+void iscsit_mod_dataout_timer(struct iscsit_cmd *cmd)
11831183 {
1184− struct iscsi_conn *conn = cmd->conn;
1185− struct iscsi_session *sess = conn->sess;
1184+ struct iscsit_conn *conn = cmd->conn;
1185+ struct iscsit_session *sess = conn->sess;
11861186 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
11871187
11881188 spin_lock_bh(&cmd->dataout_timeout_lock);
@@ -1199,10 +1199,10 @@ void iscsit_mod_dataout_timer(struct iscsi_cmd *cmd) · 10 unmodified lines
11991199 }
12001200
12011201 void iscsit_start_dataout_timer(
1202− struct iscsi_cmd *cmd,
1203− struct iscsi_conn *conn)
1202+ struct iscsit_cmd *cmd,
1203+ struct iscsit_conn *conn)
12041204 {
1205− struct iscsi_session *sess = conn->sess;
1205+ struct iscsit_session *sess = conn->sess;
12061206 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
12071207
12081208 lockdep_assert_held(&cmd->dataout_timeout_lock);
@@ -1218,7 +1218,7 @@ void iscsit_start_dataout_timer( · 9 unmodified lines
12181218 mod_timer(&cmd->dataout_timer, jiffies + na->dataout_timeout * HZ);
12191219 }
12201220
1221−void iscsit_stop_dataout_timer(struct iscsi_cmd *cmd)
1221+void iscsit_stop_dataout_timer(struct iscsit_cmd *cmd)
12221222 {
12231223 spin_lock_bh(&cmd->dataout_timeout_lock);
12241224 if (!(cmd->dataout_timer_flags & ISCSI_TF_RUNNING)) {
drivers/target/iscsi/iscsi_target_erl1.h+20−20
@@ -5,34 +5,34 @@ · 4 unmodified lines
55 #include <linux/types.h>
66 #include <scsi/iscsi_proto.h> /* itt_t */
77
8−struct iscsi_cmd;
9−struct iscsi_conn;
8+struct iscsit_cmd;
9+struct iscsit_conn;
1010 struct iscsi_datain_req;
1111 struct iscsi_ooo_cmdsn;
1212 struct iscsi_pdu;
13−struct iscsi_session;
13+struct iscsit_session;
1414
15−extern int iscsit_dump_data_payload(struct iscsi_conn *, u32, int);
15+extern int iscsit_dump_data_payload(struct iscsit_conn *, u32, int);
1616 extern int iscsit_create_recovery_datain_values_datasequenceinorder_yes(
17− struct iscsi_cmd *, struct iscsi_datain_req *);
17+ struct iscsit_cmd *, struct iscsi_datain_req *);
1818 extern int iscsit_create_recovery_datain_values_datasequenceinorder_no(
19− struct iscsi_cmd *, struct iscsi_datain_req *);
20−extern int iscsit_handle_recovery_datain_or_r2t(struct iscsi_conn *, unsigned char *,
19+ struct iscsit_cmd *, struct iscsi_datain_req *);
20+extern int iscsit_handle_recovery_datain_or_r2t(struct iscsit_conn *, unsigned char *,
2121 itt_t, u32, u32, u32);
22−extern int iscsit_handle_status_snack(struct iscsi_conn *, itt_t, u32,
22+extern int iscsit_handle_status_snack(struct iscsit_conn *, itt_t, u32,
2323 u32, u32);
24−extern int iscsit_handle_data_ack(struct iscsi_conn *, u32, u32, u32);
25−extern int iscsit_dataout_datapduinorder_no_fbit(struct iscsi_cmd *, struct iscsi_pdu *);
26−extern int iscsit_recover_dataout_sequence(struct iscsi_cmd *, u32, u32);
27−extern void iscsit_clear_ooo_cmdsns_for_conn(struct iscsi_conn *);
28−extern void iscsit_free_all_ooo_cmdsns(struct iscsi_session *);
29−extern int iscsit_execute_ooo_cmdsns(struct iscsi_session *);
30−extern int iscsit_execute_cmd(struct iscsi_cmd *, int);
31−extern int iscsit_handle_ooo_cmdsn(struct iscsi_session *, struct iscsi_cmd *, u32);
32−extern void iscsit_remove_ooo_cmdsn(struct iscsi_session *, struct iscsi_ooo_cmdsn *);
24+extern int iscsit_handle_data_ack(struct iscsit_conn *, u32, u32, u32);
25+extern int iscsit_dataout_datapduinorder_no_fbit(struct iscsit_cmd *, struct iscsi_pdu *);
26+extern int iscsit_recover_dataout_sequence(struct iscsit_cmd *, u32, u32);
27+extern void iscsit_clear_ooo_cmdsns_for_conn(struct iscsit_conn *);
28+extern void iscsit_free_all_ooo_cmdsns(struct iscsit_session *);
29+extern int iscsit_execute_ooo_cmdsns(struct iscsit_session *);
30+extern int iscsit_execute_cmd(struct iscsit_cmd *, int);
31+extern int iscsit_handle_ooo_cmdsn(struct iscsit_session *, struct iscsit_cmd *, u32);
32+extern void iscsit_remove_ooo_cmdsn(struct iscsit_session *, struct iscsi_ooo_cmdsn *);
3333 extern void iscsit_handle_dataout_timeout(struct timer_list *t);
34−extern void iscsit_mod_dataout_timer(struct iscsi_cmd *);
35−extern void iscsit_start_dataout_timer(struct iscsi_cmd *, struct iscsi_conn *);
36−extern void iscsit_stop_dataout_timer(struct iscsi_cmd *);
34+extern void iscsit_mod_dataout_timer(struct iscsit_cmd *);
35+extern void iscsit_start_dataout_timer(struct iscsit_cmd *, struct iscsit_conn *);
36+extern void iscsit_stop_dataout_timer(struct iscsit_cmd *);
3737
3838 #endif /* ISCSI_TARGET_ERL1_H */
drivers/target/iscsi/iscsi_target_erl2.c+24−24
@@ -26,11 +26,11 @@ · 25 unmodified lines
2626 * FIXME: Does RData SNACK apply here as well?
2727 */
2828 void iscsit_create_conn_recovery_datain_values(
29− struct iscsi_cmd *cmd,
29+ struct iscsit_cmd *cmd,
3030 __be32 exp_data_sn)
3131 {
3232 u32 data_sn = 0;
33− struct iscsi_conn *conn = cmd->conn;
33+ struct iscsit_conn *conn = cmd->conn;
3434
3535 cmd->next_burst_len = 0;
3636 cmd->read_data_done = 0;
@@ -54,10 +54,10 @@ void iscsit_create_conn_recovery_datain_values( · 17 unmodified lines
5454 }
5555
5656 void iscsit_create_conn_recovery_dataout_values(
57− struct iscsi_cmd *cmd)
57+ struct iscsit_cmd *cmd)
5858 {
5959 u32 write_data_done = 0;
60− struct iscsi_conn *conn = cmd->conn;
60+ struct iscsit_conn *conn = cmd->conn;
6161
6262 cmd->data_sn = 0;
6363 cmd->next_burst_len = 0;
@@ -74,7 +74,7 @@ void iscsit_create_conn_recovery_dataout_values( · 10 unmodified lines
7474 }
7575
7676 static int iscsit_attach_active_connection_recovery_entry(
77− struct iscsi_session *sess,
77+ struct iscsit_session *sess,
7878 struct iscsi_conn_recovery *cr)
7979 {
8080 spin_lock(&sess->cr_a_lock);
@@ -85,7 +85,7 @@ static int iscsit_attach_active_connection_recovery_entry( · 4 unmodified lines
8585 }
8686
8787 static int iscsit_attach_inactive_connection_recovery_entry(
88− struct iscsi_session *sess,
88+ struct iscsit_session *sess,
8989 struct iscsi_conn_recovery *cr)
9090 {
9191 spin_lock(&sess->cr_i_lock);
@@ -100,7 +100,7 @@ static int iscsit_attach_inactive_connection_recovery_entry( · 8 unmodified lines
100100 }
101101
102102 struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry(
103− struct iscsi_session *sess,
103+ struct iscsit_session *sess,
104104 u16 cid)
105105 {
106106 struct iscsi_conn_recovery *cr;
@@ -117,9 +117,9 @@ struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry( · 10 unmodified lines
117117 return NULL;
118118 }
119119
120−void iscsit_free_connection_recovery_entries(struct iscsi_session *sess)
120+void iscsit_free_connection_recovery_entries(struct iscsit_session *sess)
121121 {
122− struct iscsi_cmd *cmd, *cmd_tmp;
122+ struct iscsit_cmd *cmd, *cmd_tmp;
123123 struct iscsi_conn_recovery *cr, *cr_tmp;
124124
125125 spin_lock(&sess->cr_a_lock);
@@ -169,7 +169,7 @@ void iscsit_free_connection_recovery_entries(struct iscsi_session *sess) · 43 unmodified lines
169169
170170 int iscsit_remove_active_connection_recovery_entry(
171171 struct iscsi_conn_recovery *cr,
172− struct iscsi_session *sess)
172+ struct iscsit_session *sess)
173173 {
174174 spin_lock(&sess->cr_a_lock);
175175 list_del(&cr->cr_list);
@@ -186,7 +186,7 @@ int iscsit_remove_active_connection_recovery_entry( · 10 unmodified lines
186186
187187 static void iscsit_remove_inactive_connection_recovery_entry(
188188 struct iscsi_conn_recovery *cr,
189− struct iscsi_session *sess)
189+ struct iscsit_session *sess)
190190 {
191191 spin_lock(&sess->cr_i_lock);
192192 list_del(&cr->cr_list);
@@ -197,8 +197,8 @@ static void iscsit_remove_inactive_connection_recovery_entry( · 4 unmodified lines
197197 * Called with cr->conn_recovery_cmd_lock help.
198198 */
199199 int iscsit_remove_cmd_from_connection_recovery(
200− struct iscsi_cmd *cmd,
201− struct iscsi_session *sess)
200+ struct iscsit_cmd *cmd,
201+ struct iscsit_session *sess)
202202 {
203203 struct iscsi_conn_recovery *cr;
204204
@@ -218,8 +218,8 @@ void iscsit_discard_cr_cmds_by_expstatsn( · 13 unmodified lines
218218 u32 exp_statsn)
219219 {
220220 u32 dropped_count = 0;
221− struct iscsi_cmd *cmd, *cmd_tmp;
222− struct iscsi_session *sess = cr->sess;
221+ struct iscsit_cmd *cmd, *cmd_tmp;
222+ struct iscsit_session *sess = cr->sess;
223223
224224 spin_lock(&cr->conn_recovery_cmd_lock);
225225 list_for_each_entry_safe(cmd, cmd_tmp,
@@ -263,12 +263,12 @@ void iscsit_discard_cr_cmds_by_expstatsn( · 37 unmodified lines
263263 }
264264 }
265265
266−int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *conn)
266+int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsit_conn *conn)
267267 {
268268 u32 dropped_count = 0;
269− struct iscsi_cmd *cmd, *cmd_tmp;
269+ struct iscsit_cmd *cmd, *cmd_tmp;
270270 struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp;
271− struct iscsi_session *sess = conn->sess;
271+ struct iscsit_session *sess = conn->sess;
272272
273273 mutex_lock(&sess->cmdsn_mutex);
274274 list_for_each_entry_safe(ooo_cmdsn, ooo_cmdsn_tmp,
@@ -304,16 +304,16 @@ int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *conn) · 29 unmodified lines
304304 return 0;
305305 }
306306
307−int iscsit_prepare_cmds_for_reallegiance(struct iscsi_conn *conn)
307+int iscsit_prepare_cmds_for_reallegiance(struct iscsit_conn *conn)
308308 {
309309 u32 cmd_count = 0;
310− struct iscsi_cmd *cmd, *cmd_tmp;
310+ struct iscsit_cmd *cmd, *cmd_tmp;
311311 struct iscsi_conn_recovery *cr;
312312
313313 /*
314314 * Allocate an struct iscsi_conn_recovery for this connection.
315− * Each struct iscsi_cmd contains an struct iscsi_conn_recovery pointer
316− * (struct iscsi_cmd->cr) so we need to allocate this before preparing the
315+ * Each struct iscsit_cmd contains an struct iscsi_conn_recovery pointer
316+ * (struct iscsit_cmd->cr) so we need to allocate this before preparing the
317317 * connection's command list for connection recovery.
318318 */
319319 cr = kzalloc(sizeof(struct iscsi_conn_recovery), GFP_KERNEL);
@@ -393,7 +393,7 @@ int iscsit_prepare_cmds_for_reallegiance(struct iscsi_conn *conn) · 73 unmodified lines
393393
394394 transport_wait_for_tasks(&cmd->se_cmd);
395395 /*
396− * Add the struct iscsi_cmd to the connection recovery cmd list
396+ * Add the struct iscsit_cmd to the connection recovery cmd list
397397 */
398398 spin_lock(&cr->conn_recovery_cmd_lock);
399399 list_add_tail(&cmd->i_conn_node, &cr->conn_recovery_cmd_list);
@@ -418,7 +418,7 @@ int iscsit_prepare_cmds_for_reallegiance(struct iscsi_conn *conn) · 18 unmodified lines
418418 return 0;
419419 }
420420
421−int iscsit_connection_recovery_transport_reset(struct iscsi_conn *conn)
421+int iscsit_connection_recovery_transport_reset(struct iscsit_conn *conn)
422422 {
423423 atomic_set(&conn->connection_recovery, 1);
424424
drivers/target/iscsi/iscsi_target_erl2.h+13−13
@@ -4,23 +4,23 @@ · 3 unmodified lines
44
55 #include <linux/types.h>
66
7−struct iscsi_cmd;
8−struct iscsi_conn;
7+struct iscsit_cmd;
8+struct iscsit_conn;
99 struct iscsi_conn_recovery;
10−struct iscsi_session;
10+struct iscsit_session;
1111
12−extern void iscsit_create_conn_recovery_datain_values(struct iscsi_cmd *, __be32);
13−extern void iscsit_create_conn_recovery_dataout_values(struct iscsi_cmd *);
12+extern void iscsit_create_conn_recovery_datain_values(struct iscsit_cmd *, __be32);
13+extern void iscsit_create_conn_recovery_dataout_values(struct iscsit_cmd *);
1414 extern struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry(
15− struct iscsi_session *, u16);
16−extern void iscsit_free_connection_recovery_entries(struct iscsi_session *);
15+ struct iscsit_session *, u16);
16+extern void iscsit_free_connection_recovery_entries(struct iscsit_session *);
1717 extern int iscsit_remove_active_connection_recovery_entry(
18− struct iscsi_conn_recovery *, struct iscsi_session *);
19−extern int iscsit_remove_cmd_from_connection_recovery(struct iscsi_cmd *,
20− struct iscsi_session *);
18+ struct iscsi_conn_recovery *, struct iscsit_session *);
19+extern int iscsit_remove_cmd_from_connection_recovery(struct iscsit_cmd *,
20+ struct iscsit_session *);
2121 extern void iscsit_discard_cr_cmds_by_expstatsn(struct iscsi_conn_recovery *, u32);
22−extern int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *);
23−extern int iscsit_prepare_cmds_for_reallegiance(struct iscsi_conn *);
24−extern int iscsit_connection_recovery_transport_reset(struct iscsi_conn *);
22+extern int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsit_conn *);
23+extern int iscsit_prepare_cmds_for_reallegiance(struct iscsit_conn *);
24+extern int iscsit_connection_recovery_transport_reset(struct iscsit_conn *);
2525
2626 #endif /*** ISCSI_TARGET_ERL2_H ***/
drivers/target/iscsi/iscsi_target_login.c+39−39
@@ -35,7 +35,7 @@ · 34 unmodified lines
3535
3636 #include <target/iscsi/iscsi_transport.h>
3737
38−static struct iscsi_login *iscsi_login_init_conn(struct iscsi_conn *conn)
38+static struct iscsi_login *iscsi_login_init_conn(struct iscsit_conn *conn)
3939 {
4040 struct iscsi_login *login;
4141
@@ -73,9 +73,9 @@ out_login: · 31 unmodified lines
7373
7474 /*
7575 * Used by iscsi_target_nego.c:iscsi_target_locate_portal() to setup
76− * per struct iscsi_conn libcrypto contexts for crc32c and crc32-intel
76+ * per struct iscsit_conn libcrypto contexts for crc32c and crc32-intel
7777 */
78−int iscsi_login_setup_crypto(struct iscsi_conn *conn)
78+int iscsi_login_setup_crypto(struct iscsit_conn *conn)
7979 {
8080 struct crypto_ahash *tfm;
8181
@@ -112,7 +112,7 @@ int iscsi_login_setup_crypto(struct iscsi_conn *conn) · 30 unmodified lines
112112 }
113113
114114 static int iscsi_login_check_initiator_version(
115− struct iscsi_conn *conn,
115+ struct iscsit_conn *conn,
116116 u8 version_max,
117117 u8 version_min)
118118 {
@@ -128,12 +128,12 @@ static int iscsi_login_check_initiator_version( · 9 unmodified lines
128128 return 0;
129129 }
130130
131−int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn)
131+int iscsi_check_for_session_reinstatement(struct iscsit_conn *conn)
132132 {
133133 int sessiontype;
134134 struct iscsi_param *initiatorname_param = NULL, *sessiontype_param = NULL;
135135 struct iscsi_portal_group *tpg = conn->tpg;
136− struct iscsi_session *sess = NULL, *sess_p = NULL;
136+ struct iscsit_session *sess = NULL, *sess_p = NULL;
137137 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
138138 struct se_session *se_sess, *se_sess_tmp;
139139
@@ -204,8 +204,8 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn) · 64 unmodified lines
204204 }
205205
206206 static int iscsi_login_set_conn_values(
207− struct iscsi_session *sess,
208− struct iscsi_conn *conn,
207+ struct iscsit_session *sess,
208+ struct iscsit_conn *conn,
209209 __be16 cid)
210210 {
211211 int ret;
@@ -226,7 +226,7 @@ static int iscsi_login_set_conn_values( · 14 unmodified lines
226226 }
227227
228228 __printf(2, 3) int iscsi_change_param_sprintf(
229− struct iscsi_conn *conn,
229+ struct iscsit_conn *conn,
230230 const char *fmt, ...)
231231 {
232232 va_list args;
@@ -253,14 +253,14 @@ EXPORT_SYMBOL(iscsi_change_param_sprintf); · 20 unmodified lines
253253 * or session reinstatement.
254254 */
255255 static int iscsi_login_zero_tsih_s1(
256− struct iscsi_conn *conn,
256+ struct iscsit_conn *conn,
257257 unsigned char *buf)
258258 {
259− struct iscsi_session *sess = NULL;
259+ struct iscsit_session *sess = NULL;
260260 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;
261261 int ret;
262262
263− sess = kzalloc(sizeof(struct iscsi_session), GFP_KERNEL);
263+ sess = kzalloc(sizeof(struct iscsit_session), GFP_KERNEL);
264264 if (!sess) {
265265 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
266266 ISCSI_LOGIN_STATUS_NO_RESOURCES);
@@ -337,10 +337,10 @@ free_sess: · 70 unmodified lines
337337 }
338338
339339 static int iscsi_login_zero_tsih_s2(
340− struct iscsi_conn *conn)
340+ struct iscsit_conn *conn)
341341 {
342342 struct iscsi_node_attrib *na;
343− struct iscsi_session *sess = conn->sess;
343+ struct iscsit_session *sess = conn->sess;
344344 bool iser = false;
345345
346346 sess->tpg = conn->tpg;
@@ -458,7 +458,7 @@ check_prot: · 111 unmodified lines
458458 }
459459
460460 static int iscsi_login_non_zero_tsih_s1(
461− struct iscsi_conn *conn,
461+ struct iscsit_conn *conn,
462462 unsigned char *buf)
463463 {
464464 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;
@@ -470,11 +470,11 @@ static int iscsi_login_non_zero_tsih_s1( · 5 unmodified lines
470470 * Add a new connection to an existing session.
471471 */
472472 static int iscsi_login_non_zero_tsih_s2(
473− struct iscsi_conn *conn,
473+ struct iscsit_conn *conn,
474474 unsigned char *buf)
475475 {
476476 struct iscsi_portal_group *tpg = conn->tpg;
477− struct iscsi_session *sess = NULL, *sess_p = NULL;
477+ struct iscsit_session *sess = NULL, *sess_p = NULL;
478478 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
479479 struct se_session *se_sess, *se_sess_tmp;
480480 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;
@@ -484,7 +484,7 @@ static int iscsi_login_non_zero_tsih_s2( · 3 unmodified lines
484484 list_for_each_entry_safe(se_sess, se_sess_tmp, &se_tpg->tpg_sess_list,
485485 sess_list) {
486486
487− sess_p = (struct iscsi_session *)se_sess->fabric_sess_ptr;
487+ sess_p = (struct iscsit_session *)se_sess->fabric_sess_ptr;
488488 if (atomic_read(&sess_p->session_fall_back_to_erl0) ||
489489 atomic_read(&sess_p->session_logout) ||
490490 atomic_read(&sess_p->session_close) ||
@@ -546,13 +546,13 @@ static int iscsi_login_non_zero_tsih_s2( · 55 unmodified lines
546546 }
547547
548548 int iscsi_login_post_auth_non_zero_tsih(
549− struct iscsi_conn *conn,
549+ struct iscsit_conn *conn,
550550 u16 cid,
551551 u32 exp_statsn)
552552 {
553− struct iscsi_conn *conn_ptr = NULL;
553+ struct iscsit_conn *conn_ptr = NULL;
554554 struct iscsi_conn_recovery *cr = NULL;
555− struct iscsi_session *sess = conn->sess;
555+ struct iscsit_session *sess = conn->sess;
556556
557557 /*
558558 * By following item 5 in the login table, if we have found
@@ -612,9 +612,9 @@ int iscsi_login_post_auth_non_zero_tsih( · 53 unmodified lines
612612 return 0;
613613 }
614614
615−static void iscsi_post_login_start_timers(struct iscsi_conn *conn)
615+static void iscsi_post_login_start_timers(struct iscsit_conn *conn)
616616 {
617− struct iscsi_session *sess = conn->sess;
617+ struct iscsit_session *sess = conn->sess;
618618 /*
619619 * FIXME: Unsolicited NopIN support for ISER
620620 */
@@ -625,7 +625,7 @@ static void iscsi_post_login_start_timers(struct iscsi_conn *conn) · 4 unmodified lines
625625 iscsit_start_nopin_timer(conn);
626626 }
627627
628−int iscsit_start_kthreads(struct iscsi_conn *conn)
628+int iscsit_start_kthreads(struct iscsit_conn *conn)
629629 {
630630 int ret = 0;
631631
@@ -673,11 +673,11 @@ out_bitmap: · 41 unmodified lines
673673
674674 void iscsi_post_login_handler(
675675 struct iscsi_np *np,
676− struct iscsi_conn *conn,
676+ struct iscsit_conn *conn,
677677 u8 zero_tsih)
678678 {
679679 int stop_timer = 0;
680− struct iscsi_session *sess = conn->sess;
680+ struct iscsit_session *sess = conn->sess;
681681 struct se_session *se_sess = sess->se_sess;
682682 struct iscsi_portal_group *tpg = sess->tpg;
683683 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
@@ -730,7 +730,7 @@ void iscsi_post_login_handler( · 46 unmodified lines
730730 conn->conn_tx_reset_cpumask = 1;
731731 /*
732732 * Wakeup the sleeping iscsi_target_rx_thread() now that
733− * iscsi_conn is in TARG_CONN_STATE_LOGGED_IN state.
733+ * iscsit_conn is in TARG_CONN_STATE_LOGGED_IN state.
734734 */
735735 complete(&conn->rx_login_comp);
736736 iscsit_dec_conn_usage_count(conn);
@@ -792,7 +792,7 @@ void iscsi_post_login_handler( · 55 unmodified lines
792792 conn->conn_tx_reset_cpumask = 1;
793793 /*
794794 * Wakeup the sleeping iscsi_target_rx_thread() now that
795− * iscsi_conn is in TARG_CONN_STATE_LOGGED_IN state.
795+ * iscsit_conn is in TARG_CONN_STATE_LOGGED_IN state.
796796 */
797797 complete(&conn->rx_login_comp);
798798 iscsit_dec_conn_usage_count(conn);
@@ -944,7 +944,7 @@ int iscsi_target_setup_login_socket( · 145 unmodified lines
944944 return 0;
945945 }
946946
947−int iscsit_accept_np(struct iscsi_np *np, struct iscsi_conn *conn)
947+int iscsit_accept_np(struct iscsi_np *np, struct iscsit_conn *conn)
948948 {
949949 struct socket *new_sock, *sock = np->np_socket;
950950 struct sockaddr_in sock_in;
@@ -1005,7 +1005,7 @@ int iscsit_accept_np(struct iscsi_np *np, struct iscsi_conn *conn) · 54 unmodified lines
10051005 return 0;
10061006 }
10071007
1008−int iscsit_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login)
1008+int iscsit_get_login_rx(struct iscsit_conn *conn, struct iscsi_login *login)
10091009 {
10101010 struct iscsi_login_req *login_req;
10111011 u32 padding = 0, payload_length;
@@ -1050,7 +1050,7 @@ int iscsit_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login) · 38 unmodified lines
10501050 return 0;
10511051 }
10521052
1053−int iscsit_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login,
1053+int iscsit_put_login_tx(struct iscsit_conn *conn, struct iscsi_login *login,
10541054 u32 length)
10551055 {
10561056 if (iscsi_login_tx_data(conn, login->rsp, login->rsp_buf, length) < 0)
@@ -1060,7 +1060,7 @@ int iscsit_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login, · 3 unmodified lines
10601060 }
10611061
10621062 static int
1063−iscsit_conn_set_transport(struct iscsi_conn *conn, struct iscsit_transport *t)
1063+iscsit_conn_set_transport(struct iscsit_conn *conn, struct iscsit_transport *t)
10641064 {
10651065 int rc;
10661066
@@ -1079,11 +1079,11 @@ iscsit_conn_set_transport(struct iscsi_conn *conn, struct iscsit_transport *t) · 12 unmodified lines
10791079 return 0;
10801080 }
10811081
1082−static struct iscsi_conn *iscsit_alloc_conn(struct iscsi_np *np)
1082+static struct iscsit_conn *iscsit_alloc_conn(struct iscsi_np *np)
10831083 {
1084− struct iscsi_conn *conn;
1084+ struct iscsit_conn *conn;
10851085
1086− conn = kzalloc(sizeof(struct iscsi_conn), GFP_KERNEL);
1086+ conn = kzalloc(sizeof(struct iscsit_conn), GFP_KERNEL);
10871087 if (!conn) {
10881088 pr_err("Could not allocate memory for new connection\n");
10891089 return NULL;
@@ -1147,7 +1147,7 @@ free_conn: · 57 unmodified lines
11471147 return NULL;
11481148 }
11491149
1150−void iscsit_free_conn(struct iscsi_conn *conn)
1150+void iscsit_free_conn(struct iscsit_conn *conn)
11511151 {
11521152 free_cpumask_var(conn->allowed_cpumask);
11531153 free_cpumask_var(conn->conn_cpumask);
@@ -1156,7 +1156,7 @@ void iscsit_free_conn(struct iscsi_conn *conn) · 2 unmodified lines
11561156 kfree(conn);
11571157 }
11581158
1159−void iscsi_target_login_sess_out(struct iscsi_conn *conn,
1159+void iscsi_target_login_sess_out(struct iscsit_conn *conn,
11601160 bool zero_tsih, bool new_sess)
11611161 {
11621162 if (!new_sess)
@@ -1228,7 +1228,7 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) · 65 unmodified lines
12281228 {
12291229 u8 *buffer, zero_tsih = 0;
12301230 int ret = 0, rc;
1231− struct iscsi_conn *conn = NULL;
1231+ struct iscsit_conn *conn = NULL;
12321232 struct iscsi_login *login;
12331233 struct iscsi_portal_group *tpg = NULL;
12341234 struct iscsi_login_req *pdu;
@@ -1371,7 +1371,7 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) · 136 unmodified lines
13711371
13721372 tpg = conn->tpg;
13731373 if (!tpg) {
1374− pr_err("Unable to locate struct iscsi_conn->tpg\n");
1374+ pr_err("Unable to locate struct iscsit_conn->tpg\n");
13751375 goto new_sess_out;
13761376 }
13771377
drivers/target/iscsi/iscsi_target_login.h+11−11
@@ -4,25 +4,25 @@ · 3 unmodified lines
44
55 #include <linux/types.h>
66
7−struct iscsi_conn;
7+struct iscsit_conn;
88 struct iscsi_login;
99 struct iscsi_np;
1010 struct sockaddr_storage;
1111
12−extern int iscsi_login_setup_crypto(struct iscsi_conn *);
13−extern int iscsi_check_for_session_reinstatement(struct iscsi_conn *);
14−extern int iscsi_login_post_auth_non_zero_tsih(struct iscsi_conn *, u16, u32);
12+extern int iscsi_login_setup_crypto(struct iscsit_conn *);
13+extern int iscsi_check_for_session_reinstatement(struct iscsit_conn *);
14+extern int iscsi_login_post_auth_non_zero_tsih(struct iscsit_conn *, u16, u32);
1515 extern int iscsit_setup_np(struct iscsi_np *,
1616 struct sockaddr_storage *);
1717 extern int iscsi_target_setup_login_socket(struct iscsi_np *,
1818 struct sockaddr_storage *);
19−extern int iscsit_accept_np(struct iscsi_np *, struct iscsi_conn *);
20−extern int iscsit_get_login_rx(struct iscsi_conn *, struct iscsi_login *);
21−extern int iscsit_put_login_tx(struct iscsi_conn *, struct iscsi_login *, u32);
22−extern void iscsit_free_conn(struct iscsi_conn *);
23−extern int iscsit_start_kthreads(struct iscsi_conn *);
24−extern void iscsi_post_login_handler(struct iscsi_np *, struct iscsi_conn *, u8);
25−extern void iscsi_target_login_sess_out(struct iscsi_conn *, bool, bool);
19+extern int iscsit_accept_np(struct iscsi_np *, struct iscsit_conn *);
20+extern int iscsit_get_login_rx(struct iscsit_conn *, struct iscsi_login *);
21+extern int iscsit_put_login_tx(struct iscsit_conn *, struct iscsi_login *, u32);
22+extern void iscsit_free_conn(struct iscsit_conn *);
23+extern int iscsit_start_kthreads(struct iscsit_conn *);
24+extern void iscsi_post_login_handler(struct iscsi_np *, struct iscsit_conn *, u8);
25+extern void iscsi_target_login_sess_out(struct iscsit_conn *, bool, bool);
2626 extern int iscsi_target_login_thread(void *);
2727 extern void iscsi_handle_login_thread_timeout(struct timer_list *t);
2828
drivers/target/iscsi/iscsi_target_nego.c+30−30
@@ -95,14 +95,14 @@ int extract_param( · 94 unmodified lines
9595 }
9696
9797 static u32 iscsi_handle_authentication(
98− struct iscsi_conn *conn,
98+ struct iscsit_conn *conn,
9999 char *in_buf,
100100 char *out_buf,
101101 int in_length,
102102 int *out_length,
103103 unsigned char *authtype)
104104 {
105− struct iscsi_session *sess = conn->sess;
105+ struct iscsit_session *sess = conn->sess;
106106 struct iscsi_node_auth *auth;
107107 struct iscsi_node_acl *iscsi_nacl;
108108 struct iscsi_portal_group *iscsi_tpg;
@@ -151,13 +151,13 @@ static u32 iscsi_handle_authentication( · 42 unmodified lines
151151 return 2;
152152 }
153153
154−static void iscsi_remove_failed_auth_entry(struct iscsi_conn *conn)
154+static void iscsi_remove_failed_auth_entry(struct iscsit_conn *conn)
155155 {
156156 kfree(conn->auth_protocol);
157157 }
158158
159159 int iscsi_target_check_login_request(
160− struct iscsi_conn *conn,
160+ struct iscsit_conn *conn,
161161 struct iscsi_login *login)
162162 {
163163 int req_csg, req_nsg;
@@ -248,7 +248,7 @@ int iscsi_target_check_login_request( · 84 unmodified lines
248248 EXPORT_SYMBOL(iscsi_target_check_login_request);
249249
250250 static int iscsi_target_check_first_request(
251− struct iscsi_conn *conn,
251+ struct iscsit_conn *conn,
252252 struct iscsi_login *login)
253253 {
254254 struct iscsi_param *param = NULL;
@@ -315,7 +315,7 @@ static int iscsi_target_check_first_request( · 60 unmodified lines
315315 return 0;
316316 }
317317
318−static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_login *login)
318+static int iscsi_target_do_tx_login_io(struct iscsit_conn *conn, struct iscsi_login *login)
319319 {
320320 u32 padding = 0;
321321 struct iscsi_login_rsp *login_rsp;
@@ -382,7 +382,7 @@ err: · 60 unmodified lines
382382
383383 static void iscsi_target_sk_data_ready(struct sock *sk)
384384 {
385− struct iscsi_conn *conn = sk->sk_user_data;
385+ struct iscsit_conn *conn = sk->sk_user_data;
386386 bool rc;
387387
388388 pr_debug("Entering iscsi_target_sk_data_ready: conn: %p\n", conn);
@@ -421,7 +421,7 @@ static void iscsi_target_sk_data_ready(struct sock *sk) · 32 unmodified lines
421421
422422 static void iscsi_target_sk_state_change(struct sock *);
423423
424−static void iscsi_target_set_sock_callbacks(struct iscsi_conn *conn)
424+static void iscsi_target_set_sock_callbacks(struct iscsit_conn *conn)
425425 {
426426 struct sock *sk;
427427
@@ -443,7 +443,7 @@ static void iscsi_target_set_sock_callbacks(struct iscsi_conn *conn) · 15 unmodified lines
443443 sk->sk_rcvtimeo = TA_LOGIN_TIMEOUT * HZ;
444444 }
445445
446−static void iscsi_target_restore_sock_callbacks(struct iscsi_conn *conn)
446+static void iscsi_target_restore_sock_callbacks(struct iscsit_conn *conn)
447447 {
448448 struct sock *sk;
449449
@@ -467,7 +467,7 @@ static void iscsi_target_restore_sock_callbacks(struct iscsi_conn *conn) · 17 unmodified lines
467467 sk->sk_rcvtimeo = MAX_SCHEDULE_TIMEOUT;
468468 }
469469
470−static int iscsi_target_do_login(struct iscsi_conn *, struct iscsi_login *);
470+static int iscsi_target_do_login(struct iscsit_conn *, struct iscsi_login *);
471471
472472 static bool __iscsi_target_sk_check_close(struct sock *sk)
473473 {
@@ -479,7 +479,7 @@ static bool __iscsi_target_sk_check_close(struct sock *sk) · 5 unmodified lines
479479 return false;
480480 }
481481
482−static bool iscsi_target_sk_check_close(struct iscsi_conn *conn)
482+static bool iscsi_target_sk_check_close(struct iscsit_conn *conn)
483483 {
484484 bool state = false;
485485
@@ -494,7 +494,7 @@ static bool iscsi_target_sk_check_close(struct iscsi_conn *conn) · 8 unmodified lines
494494 return state;
495495 }
496496
497−static bool iscsi_target_sk_check_flag(struct iscsi_conn *conn, unsigned int flag)
497+static bool iscsi_target_sk_check_flag(struct iscsit_conn *conn, unsigned int flag)
498498 {
499499 bool state = false;
500500
@@ -508,7 +508,7 @@ static bool iscsi_target_sk_check_flag(struct iscsi_conn *conn, unsigned int fla · 7 unmodified lines
508508 return state;
509509 }
510510
511−static bool iscsi_target_sk_check_and_clear(struct iscsi_conn *conn, unsigned int flag)
511+static bool iscsi_target_sk_check_and_clear(struct iscsit_conn *conn, unsigned int flag)
512512 {
513513 bool state = false;
514514
@@ -525,7 +525,7 @@ static bool iscsi_target_sk_check_and_clear(struct iscsi_conn *conn, unsigned in · 10 unmodified lines
525525 return state;
526526 }
527527
528−static void iscsi_target_login_drop(struct iscsi_conn *conn, struct iscsi_login *login)
528+static void iscsi_target_login_drop(struct iscsit_conn *conn, struct iscsi_login *login)
529529 {
530530 bool zero_tsih = login->zero_tsih;
531531
@@ -536,13 +536,13 @@ static void iscsi_target_login_drop(struct iscsi_conn *conn, struct iscsi_login · 4 unmodified lines
536536
537537 struct conn_timeout {
538538 struct timer_list timer;
539− struct iscsi_conn *conn;
539+ struct iscsit_conn *conn;
540540 };
541541
542542 static void iscsi_target_login_timeout(struct timer_list *t)
543543 {
544544 struct conn_timeout *timeout = from_timer(timeout, t, timer);
545− struct iscsi_conn *conn = timeout->conn;
545+ struct iscsit_conn *conn = timeout->conn;
546546
547547 pr_debug("Entering iscsi_target_login_timeout >>>>>>>>>>>>>>>>>>>\n");
548548
@@ -555,8 +555,8 @@ static void iscsi_target_login_timeout(struct timer_list *t) · 6 unmodified lines
555555
556556 static void iscsi_target_do_login_rx(struct work_struct *work)
557557 {
558− struct iscsi_conn *conn = container_of(work,
559− struct iscsi_conn, login_work.work);
558+ struct iscsit_conn *conn = container_of(work,
559+ struct iscsit_conn, login_work.work);
560560 struct iscsi_login *login = conn->login;
561561 struct iscsi_np *np = login->np;
562562 struct iscsi_portal_group *tpg = conn->tpg;
@@ -662,7 +662,7 @@ err: · 99 unmodified lines
662662
663663 static void iscsi_target_sk_state_change(struct sock *sk)
664664 {
665− struct iscsi_conn *conn;
665+ struct iscsit_conn *conn;
666666 void (*orig_state_change)(struct sock *);
667667 bool state;
668668
@@ -741,7 +741,7 @@ static void iscsi_target_sk_state_change(struct sock *sk) · 72 unmodified lines
741741 * ISID/TSIH combinations.
742742 */
743743 static int iscsi_target_check_for_existing_instances(
744− struct iscsi_conn *conn,
744+ struct iscsit_conn *conn,
745745 struct iscsi_login *login)
746746 {
747747 if (login->checked_for_existing)
@@ -757,7 +757,7 @@ static int iscsi_target_check_for_existing_instances( · 9 unmodified lines
757757 }
758758
759759 static int iscsi_target_do_authentication(
760− struct iscsi_conn *conn,
760+ struct iscsit_conn *conn,
761761 struct iscsi_login *login)
762762 {
763763 int authret;
@@ -816,7 +816,7 @@ static int iscsi_target_do_authentication( · 52 unmodified lines
816816 }
817817
818818 static int iscsi_target_handle_csg_zero(
819− struct iscsi_conn *conn,
819+ struct iscsit_conn *conn,
820820 struct iscsi_login *login)
821821 {
822822 int ret;
@@ -906,7 +906,7 @@ do_auth: · 83 unmodified lines
906906 return iscsi_target_do_authentication(conn, login);
907907 }
908908
909−static int iscsi_target_handle_csg_one(struct iscsi_conn *conn, struct iscsi_login *login)
909+static int iscsi_target_handle_csg_one(struct iscsit_conn *conn, struct iscsi_login *login)
910910 {
911911 int ret;
912912 u32 payload_length;
@@ -968,7 +968,7 @@ static int iscsi_target_handle_csg_one(struct iscsi_conn *conn, struct iscsi_log · 55 unmodified lines
968968 return 0;
969969 }
970970
971−static int iscsi_target_do_login(struct iscsi_conn *conn, struct iscsi_login *login)
971+static int iscsi_target_do_login(struct iscsit_conn *conn, struct iscsi_login *login)
972972 {
973973 int pdu_count = 0;
974974 struct iscsi_login_req *login_req;
@@ -1054,12 +1054,12 @@ static void iscsi_initiatorname_tolower( · 79 unmodified lines
10541054 */
10551055 int iscsi_target_locate_portal(
10561056 struct iscsi_np *np,
1057− struct iscsi_conn *conn,
1057+ struct iscsit_conn *conn,
10581058 struct iscsi_login *login)
10591059 {
10601060 char *i_buf = NULL, *s_buf = NULL, *t_buf = NULL;
10611061 char *tmpbuf, *start = NULL, *end = NULL, *key, *value;
1062− struct iscsi_session *sess = conn->sess;
1062+ struct iscsit_session *sess = conn->sess;
10631063 struct iscsi_tiqn *tiqn;
10641064 struct iscsi_tpg_np *tpg_np = NULL;
10651065 struct iscsi_login_req *login_req;
@@ -1232,7 +1232,7 @@ get_target: · 166 unmodified lines
12321232
12331233 /*
12341234 * conn->sess->node_acl will be set when the referenced
1235− * struct iscsi_session is located from received ISID+TSIH in
1235+ * struct iscsit_session is located from received ISID+TSIH in
12361236 * iscsi_login_non_zero_tsih_s2().
12371237 */
12381238 if (!login->leading_connection) {
@@ -1272,7 +1272,7 @@ get_target: · 33 unmodified lines
12721272 alloc_tags:
12731273 tag_num = max_t(u32, ISCSIT_MIN_TAGS, queue_depth);
12741274 tag_num = (tag_num * 2) + ISCSIT_EXTRA_TAGS;
1275− tag_size = sizeof(struct iscsi_cmd) + conn->conn_transport->priv_size;
1275+ tag_size = sizeof(struct iscsit_cmd) + conn->conn_transport->priv_size;
12761276
12771277 ret = transport_alloc_session_tags(sess->se_sess, tag_num, tag_size);
12781278 if (ret < 0) {
@@ -1287,7 +1287,7 @@ out: · 8 unmodified lines
12871287
12881288 int iscsi_target_start_negotiation(
12891289 struct iscsi_login *login,
1290− struct iscsi_conn *conn)
1290+ struct iscsit_conn *conn)
12911291 {
12921292 int ret;
12931293
@@ -1323,7 +1323,7 @@ int iscsi_target_start_negotiation( · 29 unmodified lines
13231323 return ret;
13241324 }
13251325
1326−void iscsi_target_nego_release(struct iscsi_conn *conn)
1326+void iscsi_target_nego_release(struct iscsit_conn *conn)
13271327 {
13281328 struct iscsi_login *login = conn->conn_login;
13291329
drivers/target/iscsi/iscsi_target_nego.h+6−6
@@ -5,21 +5,21 @@ · 4 unmodified lines
55 #define DECIMAL 0
66 #define HEX 1
77
8−struct iscsi_conn;
8+struct iscsit_conn;
99 struct iscsi_login;
1010 struct iscsi_np;
1111
1212 extern void convert_null_to_semi(char *, int);
1313 extern int extract_param(const char *, const char *, unsigned int, char *,
1414 unsigned char *);
15−extern int iscsi_target_check_login_request(struct iscsi_conn *,
15+extern int iscsi_target_check_login_request(struct iscsit_conn *,
1616 struct iscsi_login *);
17−extern int iscsi_target_get_initial_payload(struct iscsi_conn *,
17+extern int iscsi_target_get_initial_payload(struct iscsit_conn *,
1818 struct iscsi_login *);
19−extern int iscsi_target_locate_portal(struct iscsi_np *, struct iscsi_conn *,
19+extern int iscsi_target_locate_portal(struct iscsi_np *, struct iscsit_conn *,
2020 struct iscsi_login *);
2121 extern int iscsi_target_start_negotiation(
22− struct iscsi_login *, struct iscsi_conn *);
23−extern void iscsi_target_nego_release(struct iscsi_conn *);
22+ struct iscsi_login *, struct iscsit_conn *);
23+extern void iscsi_target_nego_release(struct iscsit_conn *);
2424
2525 #endif /* ISCSI_TARGET_NEGO_H */
drivers/target/iscsi/iscsi_target_nodeattrib.c+2−2
@@ -96,8 +96,8 @@ int iscsit_na_nopin_timeout( · 95 unmodified lines
9696 u32 nopin_timeout)
9797 {
9898 struct iscsi_node_attrib *a = &acl->node_attrib;
99− struct iscsi_session *sess;
100− struct iscsi_conn *conn;
99+ struct iscsit_session *sess;
100+ struct iscsit_conn *conn;
101101 struct se_node_acl *se_nacl = &a->nacl->se_node_acl;
102102 struct se_session *se_sess;
103103 u32 orig_nopin_timeout = a->nopin_timeout;
drivers/target/iscsi/iscsi_target_parameters.c+4−4
@@ -15,7 +15,7 @@ · 14 unmodified lines
1515 #include "iscsi_target_parameters.h"
1616
1717 int iscsi_login_rx_data(
18− struct iscsi_conn *conn,
18+ struct iscsit_conn *conn,
1919 char *buf,
2020 int length)
2121 {
@@ -37,7 +37,7 @@ int iscsi_login_rx_data( · 15 unmodified lines
3737 }
3838
3939 int iscsi_login_tx_data(
40− struct iscsi_conn *conn,
40+ struct iscsit_conn *conn,
4141 char *pdu_buf,
4242 char *text_buf,
4343 int text_length)
@@ -955,7 +955,7 @@ out: · 911 unmodified lines
955955 }
956956
957957 static int iscsi_check_acceptor_state(struct iscsi_param *param, char *value,
958− struct iscsi_conn *conn)
958+ struct iscsit_conn *conn)
959959 {
960960 u8 acceptor_boolean_value = 0, proposer_boolean_value = 0;
961961 char *negotiated_value = NULL;
@@ -1352,7 +1352,7 @@ int iscsi_decode_text_input( · 390 unmodified lines
13521352 u8 sender,
13531353 char *textbuf,
13541354 u32 length,
1355− struct iscsi_conn *conn)
1355+ struct iscsit_conn *conn)
13561356 {
13571357 struct iscsi_param_list *param_list = conn->param_list;
13581358 char *tmpbuf, *start = NULL, *end = NULL;
drivers/target/iscsi/iscsi_target_parameters.h+4−4
@@ -25,13 +25,13 @@ struct iscsi_param { · 24 unmodified lines
2525 struct list_head p_list;
2626 } ____cacheline_aligned;
2727
28−struct iscsi_conn;
28+struct iscsit_conn;
2929 struct iscsi_conn_ops;
3030 struct iscsi_param_list;
3131 struct iscsi_sess_ops;
3232
33−extern int iscsi_login_rx_data(struct iscsi_conn *, char *, int);
34−extern int iscsi_login_tx_data(struct iscsi_conn *, char *, char *, int);
33+extern int iscsi_login_rx_data(struct iscsit_conn *, char *, int);
34+extern int iscsi_login_tx_data(struct iscsit_conn *, char *, char *, int);
3535 extern void iscsi_dump_conn_ops(struct iscsi_conn_ops *);
3636 extern void iscsi_dump_sess_ops(struct iscsi_sess_ops *);
3737 extern void iscsi_print_params(struct iscsi_param_list *);
@@ -45,7 +45,7 @@ extern void iscsi_release_param_list(struct iscsi_param_list *); · 7 unmodified lines
4545 extern struct iscsi_param *iscsi_find_param_from_key(char *, struct iscsi_param_list *);
4646 extern int iscsi_extract_key_value(char *, char **, char **);
4747 extern int iscsi_update_param_value(struct iscsi_param *, char *);
48−extern int iscsi_decode_text_input(u8, u8, char *, u32, struct iscsi_conn *);
48+extern int iscsi_decode_text_input(u8, u8, char *, u32, struct iscsit_conn *);
4949 extern int iscsi_encode_text_output(u8, u8, char *, u32 *,
5050 struct iscsi_param_list *, bool);
5151 extern int iscsi_check_negotiated_keys(struct iscsi_param_list *);
drivers/target/iscsi/iscsi_target_seq_pdu_list.c+22−22
@@ -18,7 +18,7 @@ · 17 unmodified lines
1818 #include "iscsi_target_seq_pdu_list.h"
1919
2020 #ifdef DEBUG
21−static void iscsit_dump_seq_list(struct iscsi_cmd *cmd)
21+static void iscsit_dump_seq_list(struct iscsit_cmd *cmd)
2222 {
2323 int i;
2424 struct iscsi_seq *seq;
@@ -36,7 +36,7 @@ static void iscsit_dump_seq_list(struct iscsi_cmd *cmd) · 11 unmodified lines
3636 }
3737 }
3838
39−static void iscsit_dump_pdu_list(struct iscsi_cmd *cmd)
39+static void iscsit_dump_pdu_list(struct iscsit_cmd *cmd)
4040 {
4141 int i;
4242 struct iscsi_pdu *pdu;
@@ -52,12 +52,12 @@ static void iscsit_dump_pdu_list(struct iscsi_cmd *cmd) · 9 unmodified lines
5252 }
5353 }
5454 #else
55−static void iscsit_dump_seq_list(struct iscsi_cmd *cmd) {}
56−static void iscsit_dump_pdu_list(struct iscsi_cmd *cmd) {}
55+static void iscsit_dump_seq_list(struct iscsit_cmd *cmd) {}
56+static void iscsit_dump_pdu_list(struct iscsit_cmd *cmd) {}
5757 #endif
5858
5959 static void iscsit_ordered_seq_lists(
60− struct iscsi_cmd *cmd,
60+ struct iscsit_cmd *cmd,
6161 u8 type)
6262 {
6363 u32 i, seq_count = 0;
@@ -70,7 +70,7 @@ static void iscsit_ordered_seq_lists( · 6 unmodified lines
7070 }
7171
7272 static void iscsit_ordered_pdu_lists(
73− struct iscsi_cmd *cmd,
73+ struct iscsit_cmd *cmd,
7474 u8 type)
7575 {
7676 u32 i, pdu_send_order = 0, seq_no = 0;
@@ -117,7 +117,7 @@ redo: · 40 unmodified lines
117117 }
118118
119119 static int iscsit_randomize_pdu_lists(
120− struct iscsi_cmd *cmd,
120+ struct iscsit_cmd *cmd,
121121 u8 type)
122122 {
123123 int i = 0;
@@ -167,7 +167,7 @@ redo: · 43 unmodified lines
167167 }
168168
169169 static int iscsit_randomize_seq_lists(
170− struct iscsi_cmd *cmd,
170+ struct iscsit_cmd *cmd,
171171 u8 type)
172172 {
173173 int i, j = 0;
@@ -199,7 +199,7 @@ static int iscsit_randomize_seq_lists( · 25 unmodified lines
199199 }
200200
201201 static void iscsit_determine_counts_for_list(
202− struct iscsi_cmd *cmd,
202+ struct iscsit_cmd *cmd,
203203 struct iscsi_build_list *bl,
204204 u32 *seq_count,
205205 u32 *pdu_count)
@@ -208,7 +208,7 @@ static void iscsit_determine_counts_for_list( · 2 unmodified lines
208208 u32 burstlength = 0, offset = 0;
209209 u32 unsolicited_data_length = 0;
210210 u32 mdsl;
211− struct iscsi_conn *conn = cmd->conn;
211+ struct iscsit_conn *conn = cmd->conn;
212212
213213 if (cmd->se_cmd.data_direction == DMA_TO_DEVICE)
214214 mdsl = cmd->conn->conn_ops->MaxXmitDataSegmentLength;
@@ -283,13 +283,13 @@ static void iscsit_determine_counts_for_list( · 68 unmodified lines
283283 * or DataPDUInOrder=No.
284284 */
285285 static int iscsit_do_build_pdu_and_seq_lists(
286− struct iscsi_cmd *cmd,
286+ struct iscsit_cmd *cmd,
287287 struct iscsi_build_list *bl)
288288 {
289289 int check_immediate = 0, datapduinorder, datasequenceinorder;
290290 u32 burstlength = 0, offset = 0, i = 0, mdsl;
291291 u32 pdu_count = 0, seq_no = 0, unsolicited_data_length = 0;
292− struct iscsi_conn *conn = cmd->conn;
292+ struct iscsit_conn *conn = cmd->conn;
293293 struct iscsi_pdu *pdu = cmd->pdu_list;
294294 struct iscsi_seq *seq = cmd->seq_list;
295295
@@ -484,16 +484,16 @@ static int iscsit_do_build_pdu_and_seq_lists( · 188 unmodified lines
484484 }
485485
486486 int iscsit_build_pdu_and_seq_lists(
487− struct iscsi_cmd *cmd,
487+ struct iscsit_cmd *cmd,
488488 u32 immediate_data_length)
489489 {
490490 struct iscsi_build_list bl;
491491 u32 pdu_count = 0, seq_count = 1;
492− struct iscsi_conn *conn = cmd->conn;
492+ struct iscsit_conn *conn = cmd->conn;
493493 struct iscsi_pdu *pdu = NULL;
494494 struct iscsi_seq *seq = NULL;
495495
496− struct iscsi_session *sess = conn->sess;
496+ struct iscsit_session *sess = conn->sess;
497497 struct iscsi_node_attrib *na;
498498
499499 /*
@@ -559,7 +559,7 @@ int iscsit_build_pdu_and_seq_lists( · 59 unmodified lines
559559 }
560560
561561 struct iscsi_pdu *iscsit_get_pdu_holder(
562− struct iscsi_cmd *cmd,
562+ struct iscsit_cmd *cmd,
563563 u32 offset,
564564 u32 length)
565565 {
@@ -567,7 +567,7 @@ struct iscsi_pdu *iscsit_get_pdu_holder( · 1 unmodified line
567567 struct iscsi_pdu *pdu = NULL;
568568
569569 if (!cmd->pdu_list) {
570− pr_err("struct iscsi_cmd->pdu_list is NULL!\n");
570+ pr_err("struct iscsit_cmd->pdu_list is NULL!\n");
571571 return NULL;
572572 }
573573
@@ -583,15 +583,15 @@ struct iscsi_pdu *iscsit_get_pdu_holder( · 9 unmodified lines
583583 }
584584
585585 struct iscsi_pdu *iscsit_get_pdu_holder_for_seq(
586− struct iscsi_cmd *cmd,
586+ struct iscsit_cmd *cmd,
587587 struct iscsi_seq *seq)
588588 {
589589 u32 i;
590− struct iscsi_conn *conn = cmd->conn;
590+ struct iscsit_conn *conn = cmd->conn;
591591 struct iscsi_pdu *pdu = NULL;
592592
593593 if (!cmd->pdu_list) {
594− pr_err("struct iscsi_cmd->pdu_list is NULL!\n");
594+ pr_err("struct iscsit_cmd->pdu_list is NULL!\n");
595595 return NULL;
596596 }
597597
@@ -660,14 +660,14 @@ redo: · 62 unmodified lines
660660 }
661661
662662 struct iscsi_seq *iscsit_get_seq_holder(
663− struct iscsi_cmd *cmd,
663+ struct iscsit_cmd *cmd,
664664 u32 offset,
665665 u32 length)
666666 {
667667 u32 i;
668668
669669 if (!cmd->seq_list) {
670− pr_err("struct iscsi_cmd->seq_list is NULL!\n");
670+ pr_err("struct iscsit_cmd->seq_list is NULL!\n");
671671 return NULL;
672672 }
673673
drivers/target/iscsi/iscsi_target_seq_pdu_list.h+5−5
@@ -82,11 +82,11 @@ struct iscsi_seq { · 81 unmodified lines
8282 u32 xfer_len;
8383 } ____cacheline_aligned;
8484
85−struct iscsi_cmd;
85+struct iscsit_cmd;
8686
87−extern int iscsit_build_pdu_and_seq_lists(struct iscsi_cmd *, u32);
88−extern struct iscsi_pdu *iscsit_get_pdu_holder(struct iscsi_cmd *, u32, u32);
89−extern struct iscsi_pdu *iscsit_get_pdu_holder_for_seq(struct iscsi_cmd *, struct iscsi_seq *);
90−extern struct iscsi_seq *iscsit_get_seq_holder(struct iscsi_cmd *, u32, u32);
87+extern int iscsit_build_pdu_and_seq_lists(struct iscsit_cmd *, u32);
88+extern struct iscsi_pdu *iscsit_get_pdu_holder(struct iscsit_cmd *, u32, u32);
89+extern struct iscsi_pdu *iscsit_get_pdu_holder_for_seq(struct iscsit_cmd *, struct iscsi_seq *);
90+extern struct iscsi_seq *iscsit_get_seq_holder(struct iscsit_cmd *, u32, u32);
9191
9292 #endif /* ISCSI_SEQ_AND_PDU_LIST_H */
drivers/target/iscsi/iscsi_target_stat.c+8−8
@@ -599,7 +599,7 @@ static ssize_t iscsi_stat_sess_node_show(struct config_item *item, char *page) · 598 unmodified lines
599599 {
600600 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
601601 struct se_node_acl *se_nacl = &acl->se_node_acl;
602− struct iscsi_session *sess;
602+ struct iscsit_session *sess;
603603 struct se_session *se_sess;
604604 ssize_t ret = 0;
605605
@@ -620,7 +620,7 @@ static ssize_t iscsi_stat_sess_indx_show(struct config_item *item, char *page) · 14 unmodified lines
620620 {
621621 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
622622 struct se_node_acl *se_nacl = &acl->se_node_acl;
623− struct iscsi_session *sess;
623+ struct iscsit_session *sess;
624624 struct se_session *se_sess;
625625 ssize_t ret = 0;
626626
@@ -642,7 +642,7 @@ static ssize_t iscsi_stat_sess_cmd_pdus_show(struct config_item *item, · 15 unmodified lines
642642 {
643643 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
644644 struct se_node_acl *se_nacl = &acl->se_node_acl;
645− struct iscsi_session *sess;
645+ struct iscsit_session *sess;
646646 struct se_session *se_sess;
647647 ssize_t ret = 0;
648648
@@ -664,7 +664,7 @@ static ssize_t iscsi_stat_sess_rsp_pdus_show(struct config_item *item, · 15 unmodified lines
664664 {
665665 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
666666 struct se_node_acl *se_nacl = &acl->se_node_acl;
667− struct iscsi_session *sess;
667+ struct iscsit_session *sess;
668668 struct se_session *se_sess;
669669 ssize_t ret = 0;
670670
@@ -686,7 +686,7 @@ static ssize_t iscsi_stat_sess_txdata_octs_show(struct config_item *item, · 15 unmodified lines
686686 {
687687 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
688688 struct se_node_acl *se_nacl = &acl->se_node_acl;
689− struct iscsi_session *sess;
689+ struct iscsit_session *sess;
690690 struct se_session *se_sess;
691691 ssize_t ret = 0;
692692
@@ -708,7 +708,7 @@ static ssize_t iscsi_stat_sess_rxdata_octs_show(struct config_item *item, · 15 unmodified lines
708708 {
709709 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
710710 struct se_node_acl *se_nacl = &acl->se_node_acl;
711− struct iscsi_session *sess;
711+ struct iscsit_session *sess;
712712 struct se_session *se_sess;
713713 ssize_t ret = 0;
714714
@@ -730,7 +730,7 @@ static ssize_t iscsi_stat_sess_conn_digest_errors_show(struct config_item *item, · 15 unmodified lines
730730 {
731731 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
732732 struct se_node_acl *se_nacl = &acl->se_node_acl;
733− struct iscsi_session *sess;
733+ struct iscsit_session *sess;
734734 struct se_session *se_sess;
735735 ssize_t ret = 0;
736736
@@ -752,7 +752,7 @@ static ssize_t iscsi_stat_sess_conn_timeout_errors_show( · 15 unmodified lines
752752 {
753753 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
754754 struct se_node_acl *se_nacl = &acl->se_node_acl;
755− struct iscsi_session *sess;
755+ struct iscsit_session *sess;
756756 struct se_session *se_sess;
757757 ssize_t ret = 0;
758758
drivers/target/iscsi/iscsi_target_tmr.c+36−36
@@ -28,11 +28,11 @@ · 27 unmodified lines
2828 #include "iscsi_target.h"
2929
3030 u8 iscsit_tmr_abort_task(
31− struct iscsi_cmd *cmd,
31+ struct iscsit_cmd *cmd,
3232 unsigned char *buf)
3333 {
34− struct iscsi_cmd *ref_cmd;
35− struct iscsi_conn *conn = cmd->conn;
34+ struct iscsit_cmd *ref_cmd;
35+ struct iscsit_conn *conn = cmd->conn;
3636 struct iscsi_tmr_req *tmr_req = cmd->tmr_req;
3737 struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
3838 struct iscsi_tm *hdr = (struct iscsi_tm *) buf;
@@ -63,11 +63,11 @@ u8 iscsit_tmr_abort_task( · 24 unmodified lines
6363 * Called from iscsit_handle_task_mgt_cmd().
6464 */
6565 int iscsit_tmr_task_warm_reset(
66− struct iscsi_conn *conn,
66+ struct iscsit_conn *conn,
6767 struct iscsi_tmr_req *tmr_req,
6868 unsigned char *buf)
6969 {
70− struct iscsi_session *sess = conn->sess;
70+ struct iscsit_session *sess = conn->sess;
7171 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
7272
7373 if (!na->tmr_warm_reset) {
@@ -83,11 +83,11 @@ int iscsit_tmr_task_warm_reset( · 9 unmodified lines
8383 }
8484
8585 int iscsit_tmr_task_cold_reset(
86− struct iscsi_conn *conn,
86+ struct iscsit_conn *conn,
8787 struct iscsi_tmr_req *tmr_req,
8888 unsigned char *buf)
8989 {
90− struct iscsi_session *sess = conn->sess;
90+ struct iscsit_session *sess = conn->sess;
9191 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
9292
9393 if (!na->tmr_cold_reset) {
@@ -103,11 +103,11 @@ int iscsit_tmr_task_cold_reset( · 9 unmodified lines
103103 }
104104
105105 u8 iscsit_tmr_task_reassign(
106− struct iscsi_cmd *cmd,
106+ struct iscsit_cmd *cmd,
107107 unsigned char *buf)
108108 {
109− struct iscsi_cmd *ref_cmd = NULL;
110− struct iscsi_conn *conn = cmd->conn;
109+ struct iscsit_cmd *ref_cmd = NULL;
110+ struct iscsit_conn *conn = cmd->conn;
111111 struct iscsi_conn_recovery *cr = NULL;
112112 struct iscsi_tmr_req *tmr_req = cmd->tmr_req;
113113 struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
@@ -175,9 +175,9 @@ u8 iscsit_tmr_task_reassign( · 61 unmodified lines
175175 }
176176
177177 static void iscsit_task_reassign_remove_cmd(
178− struct iscsi_cmd *cmd,
178+ struct iscsit_cmd *cmd,
179179 struct iscsi_conn_recovery *cr,
180− struct iscsi_session *sess)
180+ struct iscsit_session *sess)
181181 {
182182 int ret;
183183
@@ -193,9 +193,9 @@ static void iscsit_task_reassign_remove_cmd( · 9 unmodified lines
193193
194194 static int iscsit_task_reassign_complete_nop_out(
195195 struct iscsi_tmr_req *tmr_req,
196− struct iscsi_conn *conn)
196+ struct iscsit_conn *conn)
197197 {
198− struct iscsi_cmd *cmd = tmr_req->ref_cmd;
198+ struct iscsit_cmd *cmd = tmr_req->ref_cmd;
199199 struct iscsi_conn_recovery *cr;
200200
201201 if (!cmd->cr) {
@@ -224,12 +224,12 @@ static int iscsit_task_reassign_complete_nop_out( · 22 unmodified lines
224224 }
225225
226226 static int iscsit_task_reassign_complete_write(
227− struct iscsi_cmd *cmd,
227+ struct iscsit_cmd *cmd,
228228 struct iscsi_tmr_req *tmr_req)
229229 {
230230 int no_build_r2ts = 0;
231231 u32 length = 0, offset = 0;
232− struct iscsi_conn *conn = cmd->conn;
232+ struct iscsit_conn *conn = cmd->conn;
233233 struct se_cmd *se_cmd = &cmd->se_cmd;
234234 /*
235235 * The Initiator must not send a R2T SNACK with a Begrun less than
@@ -296,10 +296,10 @@ static int iscsit_task_reassign_complete_write( · 60 unmodified lines
296296 }
297297
298298 static int iscsit_task_reassign_complete_read(
299− struct iscsi_cmd *cmd,
299+ struct iscsit_cmd *cmd,
300300 struct iscsi_tmr_req *tmr_req)
301301 {
302− struct iscsi_conn *conn = cmd->conn;
302+ struct iscsit_conn *conn = cmd->conn;
303303 struct iscsi_datain_req *dr;
304304 struct se_cmd *se_cmd = &cmd->se_cmd;
305305 /*
@@ -349,10 +349,10 @@ static int iscsit_task_reassign_complete_read( · 43 unmodified lines
349349 }
350350
351351 static int iscsit_task_reassign_complete_none(
352− struct iscsi_cmd *cmd,
352+ struct iscsit_cmd *cmd,
353353 struct iscsi_tmr_req *tmr_req)
354354 {
355− struct iscsi_conn *conn = cmd->conn;
355+ struct iscsit_conn *conn = cmd->conn;
356356
357357 cmd->i_state = ISTATE_SEND_STATUS;
358358 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state);
@@ -361,9 +361,9 @@ static int iscsit_task_reassign_complete_none( · 2 unmodified lines
361361
362362 static int iscsit_task_reassign_complete_scsi_cmnd(
363363 struct iscsi_tmr_req *tmr_req,
364− struct iscsi_conn *conn)
364+ struct iscsit_conn *conn)
365365 {
366− struct iscsi_cmd *cmd = tmr_req->ref_cmd;
366+ struct iscsit_cmd *cmd = tmr_req->ref_cmd;
367367 struct iscsi_conn_recovery *cr;
368368
369369 if (!cmd->cr) {
@@ -410,13 +410,13 @@ static int iscsit_task_reassign_complete_scsi_cmnd( · 40 unmodified lines
410410
411411 static int iscsit_task_reassign_complete(
412412 struct iscsi_tmr_req *tmr_req,
413− struct iscsi_conn *conn)
413+ struct iscsit_conn *conn)
414414 {
415− struct iscsi_cmd *cmd;
415+ struct iscsit_cmd *cmd;
416416 int ret = 0;
417417
418418 if (!tmr_req->ref_cmd) {
419− pr_err("TMR Request is missing a RefCmd struct iscsi_cmd.\n");
419+ pr_err("TMR Request is missing a RefCmd struct iscsit_cmd.\n");
420420 return -1;
421421 }
422422 cmd = tmr_req->ref_cmd;
@@ -451,7 +451,7 @@ static int iscsit_task_reassign_complete( · 28 unmodified lines
451451 * Right now the only one that its really needed for is
452452 * connection recovery releated TASK_REASSIGN.
453453 */
454−int iscsit_tmr_post_handler(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
454+int iscsit_tmr_post_handler(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
455455 {
456456 struct iscsi_tmr_req *tmr_req = cmd->tmr_req;
457457 struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
@@ -469,14 +469,14 @@ EXPORT_SYMBOL(iscsit_tmr_post_handler); · 11 unmodified lines
469469 */
470470 static int iscsit_task_reassign_prepare_read(
471471 struct iscsi_tmr_req *tmr_req,
472− struct iscsi_conn *conn)
472+ struct iscsit_conn *conn)
473473 {
474474 return 0;
475475 }
476476
477477 static void iscsit_task_reassign_prepare_unsolicited_dataout(
478− struct iscsi_cmd *cmd,
479− struct iscsi_conn *conn)
478+ struct iscsit_cmd *cmd,
479+ struct iscsit_conn *conn)
480480 {
481481 int i, j;
482482 struct iscsi_pdu *pdu = NULL;
@@ -544,9 +544,9 @@ static void iscsit_task_reassign_prepare_unsolicited_dataout( · 61 unmodified lines
544544
545545 static int iscsit_task_reassign_prepare_write(
546546 struct iscsi_tmr_req *tmr_req,
547− struct iscsi_conn *conn)
547+ struct iscsit_conn *conn)
548548 {
549− struct iscsi_cmd *cmd = tmr_req->ref_cmd;
549+ struct iscsit_cmd *cmd = tmr_req->ref_cmd;
550550 struct iscsi_pdu *pdu = NULL;
551551 struct iscsi_r2t *r2t = NULL, *r2t_tmp;
552552 int first_incomplete_r2t = 1, i = 0;
@@ -575,7 +575,7 @@ static int iscsit_task_reassign_prepare_write( · 22 unmodified lines
575575 *
576576 * If we have not received all DataOUT in question, we must
577577 * make sure to make the appropriate changes to values in
578− * struct iscsi_cmd (and elsewhere depending on session parameters)
578+ * struct iscsit_cmd (and elsewhere depending on session parameters)
579579 * so iscsit_build_r2ts_for_cmd() in iscsit_task_reassign_complete_write()
580580 * will resend a new R2T for the DataOUT sequences in question.
581581 */
@@ -708,7 +708,7 @@ next: · 126 unmodified lines
708708 * to check that the Initiator is not requesting R2Ts for DataOUT
709709 * sequences it has already completed.
710710 *
711− * Free each R2T in question and adjust values in struct iscsi_cmd
711+ * Free each R2T in question and adjust values in struct iscsit_cmd
712712 * accordingly so iscsit_build_r2ts_for_cmd() do the rest of
713713 * the work after the TMR TASK_REASSIGN Response is sent.
714714 */
@@ -773,13 +773,13 @@ drop_unacknowledged_r2ts: · 58 unmodified lines
773773
774774 /*
775775 * Performs sanity checks TMR TASK_REASSIGN's ExpDataSN for
776− * a given struct iscsi_cmd.
776+ * a given struct iscsit_cmd.
777777 */
778778 int iscsit_check_task_reassign_expdatasn(
779779 struct iscsi_tmr_req *tmr_req,
780− struct iscsi_conn *conn)
780+ struct iscsit_conn *conn)
781781 {
782− struct iscsi_cmd *ref_cmd = tmr_req->ref_cmd;
782+ struct iscsit_cmd *ref_cmd = tmr_req->ref_cmd;
783783
784784 if (ref_cmd->iscsi_opcode != ISCSI_OP_SCSI_CMD)
785785 return 0;
drivers/target/iscsi/iscsi_target_tmr.h+8−8
@@ -4,18 +4,18 @@ · 3 unmodified lines
44
55 #include <linux/types.h>
66
7−struct iscsi_cmd;
8−struct iscsi_conn;
7+struct iscsit_cmd;
8+struct iscsit_conn;
99 struct iscsi_tmr_req;
1010
11−extern u8 iscsit_tmr_abort_task(struct iscsi_cmd *, unsigned char *);
12−extern int iscsit_tmr_task_warm_reset(struct iscsi_conn *, struct iscsi_tmr_req *,
11+extern u8 iscsit_tmr_abort_task(struct iscsit_cmd *, unsigned char *);
12+extern int iscsit_tmr_task_warm_reset(struct iscsit_conn *, struct iscsi_tmr_req *,
1313 unsigned char *);
14−extern int iscsit_tmr_task_cold_reset(struct iscsi_conn *, struct iscsi_tmr_req *,
14+extern int iscsit_tmr_task_cold_reset(struct iscsit_conn *, struct iscsi_tmr_req *,
1515 unsigned char *);
16−extern u8 iscsit_tmr_task_reassign(struct iscsi_cmd *, unsigned char *);
17−extern int iscsit_tmr_post_handler(struct iscsi_cmd *, struct iscsi_conn *);
16+extern u8 iscsit_tmr_task_reassign(struct iscsit_cmd *, unsigned char *);
17+extern int iscsit_tmr_post_handler(struct iscsit_cmd *, struct iscsit_conn *);
1818 extern int iscsit_check_task_reassign_expdatasn(struct iscsi_tmr_req *,
19− struct iscsi_conn *);
19+ struct iscsit_conn *);
2020
2121 #endif /* ISCSI_TARGET_TMR_H */
drivers/target/iscsi/iscsi_target_tpg.c+1−1
@@ -390,7 +390,7 @@ int iscsit_tpg_disable_portal_group(struct iscsi_portal_group *tpg, int force) · 389 unmodified lines
390390 }
391391
392392 struct iscsi_node_attrib *iscsit_tpg_get_node_attrib(
393− struct iscsi_session *sess)
393+ struct iscsit_session *sess)
394394 {
395395 struct se_session *se_sess = sess->se_sess;
396396 struct se_node_acl *se_nacl = se_sess->se_node_acl;
drivers/target/iscsi/iscsi_target_tpg.h+2−2
@@ -5,7 +5,7 @@ · 4 unmodified lines
55 #include <linux/types.h>
66
77 struct iscsi_np;
8−struct iscsi_session;
8+struct iscsit_session;
99 struct iscsi_tiqn;
1010 struct iscsi_tpg_np;
1111 struct se_node_acl;
@@ -28,7 +28,7 @@ extern struct iscsi_node_acl *iscsit_tpg_add_initiator_node_acl( · 16 unmodified lines
2828 struct iscsi_portal_group *, const char *, u32);
2929 extern void iscsit_tpg_del_initiator_node_acl(struct iscsi_portal_group *,
3030 struct se_node_acl *);
31−extern struct iscsi_node_attrib *iscsit_tpg_get_node_attrib(struct iscsi_session *);
31+extern struct iscsi_node_attrib *iscsit_tpg_get_node_attrib(struct iscsit_session *);
3232 extern void iscsit_tpg_del_external_nps(struct iscsi_tpg_np *);
3333 extern struct iscsi_tpg_np *iscsit_tpg_locate_child_np(struct iscsi_tpg_np *, int);
3434 extern struct iscsi_tpg_np *iscsit_tpg_add_network_portal(struct iscsi_portal_group *,
drivers/target/iscsi/iscsi_target_util.c+82−82
@@ -32,7 +32,7 @@ extern struct list_head g_tiqn_list; · 31 unmodified lines
3232 extern spinlock_t tiqn_lock;
3333
3434 int iscsit_add_r2t_to_list(
35− struct iscsi_cmd *cmd,
35+ struct iscsit_cmd *cmd,
3636 u32 offset,
3737 u32 xfer_len,
3838 int recovery,
@@ -65,7 +65,7 @@ int iscsit_add_r2t_to_list( · 26 unmodified lines
6565 }
6666
6767 struct iscsi_r2t *iscsit_get_r2t_for_eos(
68− struct iscsi_cmd *cmd,
68+ struct iscsit_cmd *cmd,
6969 u32 offset,
7070 u32 length)
7171 {
@@ -86,7 +86,7 @@ struct iscsi_r2t *iscsit_get_r2t_for_eos( · 14 unmodified lines
8686 return NULL;
8787 }
8888
89−struct iscsi_r2t *iscsit_get_r2t_from_list(struct iscsi_cmd *cmd)
89+struct iscsi_r2t *iscsit_get_r2t_from_list(struct iscsit_cmd *cmd)
9090 {
9191 struct iscsi_r2t *r2t;
9292
@@ -104,7 +104,7 @@ struct iscsi_r2t *iscsit_get_r2t_from_list(struct iscsi_cmd *cmd) · 11 unmodified lines
104104 return NULL;
105105 }
106106
107−void iscsit_free_r2t(struct iscsi_r2t *r2t, struct iscsi_cmd *cmd)
107+void iscsit_free_r2t(struct iscsi_r2t *r2t, struct iscsit_cmd *cmd)
108108 {
109109 lockdep_assert_held(&cmd->r2t_lock);
110110
@@ -112,7 +112,7 @@ void iscsit_free_r2t(struct iscsi_r2t *r2t, struct iscsi_cmd *cmd) · 1 unmodified line
112112 kmem_cache_free(lio_r2t_cache, r2t);
113113 }
114114
115−void iscsit_free_r2ts_from_list(struct iscsi_cmd *cmd)
115+void iscsit_free_r2ts_from_list(struct iscsit_cmd *cmd)
116116 {
117117 struct iscsi_r2t *r2t, *r2t_tmp;
118118
@@ -152,9 +152,9 @@ static int iscsit_wait_for_tag(struct se_session *se_sess, int state, int *cpup) · 33 unmodified lines
152152 * May be called from software interrupt (timer) context for allocating
153153 * iSCSI NopINs.
154154 */
155−struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, int state)
155+struct iscsit_cmd *iscsit_allocate_cmd(struct iscsit_conn *conn, int state)
156156 {
157− struct iscsi_cmd *cmd;
157+ struct iscsit_cmd *cmd;
158158 struct se_session *se_sess = conn->sess->se_sess;
159159 int size, tag, cpu;
160160
@@ -164,8 +164,8 @@ struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, int state) · 3 unmodified lines
164164 if (tag < 0)
165165 return NULL;
166166
167− size = sizeof(struct iscsi_cmd) + conn->conn_transport->priv_size;
168− cmd = (struct iscsi_cmd *)(se_sess->sess_cmd_map + (tag * size));
167+ size = sizeof(struct iscsit_cmd) + conn->conn_transport->priv_size;
168+ cmd = (struct iscsit_cmd *)(se_sess->sess_cmd_map + (tag * size));
169169 memset(cmd, 0, size);
170170
171171 cmd->se_cmd.map_tag = tag;
@@ -187,7 +187,7 @@ struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, int state) · 15 unmodified lines
187187 EXPORT_SYMBOL(iscsit_allocate_cmd);
188188
189189 struct iscsi_seq *iscsit_get_seq_holder_for_datain(
190− struct iscsi_cmd *cmd,
190+ struct iscsit_cmd *cmd,
191191 u32 seq_send_order)
192192 {
193193 u32 i;
@@ -199,12 +199,12 @@ struct iscsi_seq *iscsit_get_seq_holder_for_datain( · 5 unmodified lines
199199 return NULL;
200200 }
201201
202−struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsi_cmd *cmd)
202+struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsit_cmd *cmd)
203203 {
204204 u32 i;
205205
206206 if (!cmd->seq_list) {
207− pr_err("struct iscsi_cmd->seq_list is NULL!\n");
207+ pr_err("struct iscsit_cmd->seq_list is NULL!\n");
208208 return NULL;
209209 }
210210
@@ -221,7 +221,7 @@ struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsi_cmd *cmd) · 10 unmodified lines
221221 }
222222
223223 struct iscsi_r2t *iscsit_get_holder_for_r2tsn(
224− struct iscsi_cmd *cmd,
224+ struct iscsit_cmd *cmd,
225225 u32 r2t_sn)
226226 {
227227 struct iscsi_r2t *r2t;
@@ -238,7 +238,7 @@ struct iscsi_r2t *iscsit_get_holder_for_r2tsn( · 10 unmodified lines
238238 return NULL;
239239 }
240240
241−static inline int iscsit_check_received_cmdsn(struct iscsi_session *sess, u32 cmdsn)
241+static inline int iscsit_check_received_cmdsn(struct iscsit_session *sess, u32 cmdsn)
242242 {
243243 u32 max_cmdsn;
244244 int ret;
@@ -282,7 +282,7 @@ static inline int iscsit_check_received_cmdsn(struct iscsi_session *sess, u32 cm · 37 unmodified lines
282282 * Commands may be received out of order if MC/S is in use.
283283 * Ensure they are executed in CmdSN order.
284284 */
285−int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
285+int iscsit_sequence_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
286286 unsigned char *buf, __be32 cmdsn)
287287 {
288288 int ret, cmdsn_ret;
@@ -333,9 +333,9 @@ int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 44 unmodified lines
333333 }
334334 EXPORT_SYMBOL(iscsit_sequence_cmd);
335335
336−int iscsit_check_unsolicited_dataout(struct iscsi_cmd *cmd, unsigned char *buf)
336+int iscsit_check_unsolicited_dataout(struct iscsit_cmd *cmd, unsigned char *buf)
337337 {
338− struct iscsi_conn *conn = cmd->conn;
338+ struct iscsit_conn *conn = cmd->conn;
339339 struct se_cmd *se_cmd = &cmd->se_cmd;
340340 struct iscsi_data *hdr = (struct iscsi_data *) buf;
341341 u32 payload_length = ntoh24(hdr->dlength);
@@ -377,11 +377,11 @@ int iscsit_check_unsolicited_dataout(struct iscsi_cmd *cmd, unsigned char *buf) · 35 unmodified lines
377377 return 0;
378378 }
379379
380−struct iscsi_cmd *iscsit_find_cmd_from_itt(
381− struct iscsi_conn *conn,
380+struct iscsit_cmd *iscsit_find_cmd_from_itt(
381+ struct iscsit_conn *conn,
382382 itt_t init_task_tag)
383383 {
384− struct iscsi_cmd *cmd;
384+ struct iscsit_cmd *cmd;
385385
386386 spin_lock_bh(&conn->cmd_lock);
387387 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) {
@@ -398,12 +398,12 @@ struct iscsi_cmd *iscsit_find_cmd_from_itt( · 10 unmodified lines
398398 }
399399 EXPORT_SYMBOL(iscsit_find_cmd_from_itt);
400400
401−struct iscsi_cmd *iscsit_find_cmd_from_itt_or_dump(
402− struct iscsi_conn *conn,
401+struct iscsit_cmd *iscsit_find_cmd_from_itt_or_dump(
402+ struct iscsit_conn *conn,
403403 itt_t init_task_tag,
404404 u32 length)
405405 {
406− struct iscsi_cmd *cmd;
406+ struct iscsit_cmd *cmd;
407407
408408 spin_lock_bh(&conn->cmd_lock);
409409 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) {
@@ -425,11 +425,11 @@ struct iscsi_cmd *iscsit_find_cmd_from_itt_or_dump( · 15 unmodified lines
425425 }
426426 EXPORT_SYMBOL(iscsit_find_cmd_from_itt_or_dump);
427427
428−struct iscsi_cmd *iscsit_find_cmd_from_ttt(
429− struct iscsi_conn *conn,
428+struct iscsit_cmd *iscsit_find_cmd_from_ttt(
429+ struct iscsit_conn *conn,
430430 u32 targ_xfer_tag)
431431 {
432− struct iscsi_cmd *cmd = NULL;
432+ struct iscsit_cmd *cmd = NULL;
433433
434434 spin_lock_bh(&conn->cmd_lock);
435435 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) {
@@ -446,12 +446,12 @@ struct iscsi_cmd *iscsit_find_cmd_from_ttt( · 10 unmodified lines
446446 }
447447
448448 int iscsit_find_cmd_for_recovery(
449− struct iscsi_session *sess,
450− struct iscsi_cmd **cmd_ptr,
449+ struct iscsit_session *sess,
450+ struct iscsit_cmd **cmd_ptr,
451451 struct iscsi_conn_recovery **cr_ptr,
452452 itt_t init_task_tag)
453453 {
454− struct iscsi_cmd *cmd = NULL;
454+ struct iscsit_cmd *cmd = NULL;
455455 struct iscsi_conn_recovery *cr;
456456 /*
457457 * Scan through the inactive connection recovery list's command list.
@@ -498,8 +498,8 @@ int iscsit_find_cmd_for_recovery( · 40 unmodified lines
498498 }
499499
500500 void iscsit_add_cmd_to_immediate_queue(
501− struct iscsi_cmd *cmd,
502− struct iscsi_conn *conn,
501+ struct iscsit_cmd *cmd,
502+ struct iscsit_conn *conn,
503503 u8 state)
504504 {
505505 struct iscsi_queue_req *qr;
@@ -524,7 +524,7 @@ void iscsit_add_cmd_to_immediate_queue( · 18 unmodified lines
524524 }
525525 EXPORT_SYMBOL(iscsit_add_cmd_to_immediate_queue);
526526
527−struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *conn)
527+struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsit_conn *conn)
528528 {
529529 struct iscsi_queue_req *qr;
530530
@@ -545,8 +545,8 @@ struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *c · 14 unmodified lines
545545 }
546546
547547 static void iscsit_remove_cmd_from_immediate_queue(
548− struct iscsi_cmd *cmd,
549− struct iscsi_conn *conn)
548+ struct iscsit_cmd *cmd,
549+ struct iscsit_conn *conn)
550550 {
551551 struct iscsi_queue_req *qr, *qr_tmp;
552552
@@ -574,8 +574,8 @@ static void iscsit_remove_cmd_from_immediate_queue( · 21 unmodified lines
574574 }
575575
576576 int iscsit_add_cmd_to_response_queue(
577− struct iscsi_cmd *cmd,
578− struct iscsi_conn *conn,
577+ struct iscsit_cmd *cmd,
578+ struct iscsit_conn *conn,
579579 u8 state)
580580 {
581581 struct iscsi_queue_req *qr;
@@ -599,7 +599,7 @@ int iscsit_add_cmd_to_response_queue( · 17 unmodified lines
599599 return 0;
600600 }
601601
602−struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *conn)
602+struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsit_conn *conn)
603603 {
604604 struct iscsi_queue_req *qr;
605605
@@ -621,8 +621,8 @@ struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *co · 15 unmodified lines
621621 }
622622
623623 static void iscsit_remove_cmd_from_response_queue(
624− struct iscsi_cmd *cmd,
625− struct iscsi_conn *conn)
624+ struct iscsit_cmd *cmd,
625+ struct iscsit_conn *conn)
626626 {
627627 struct iscsi_queue_req *qr, *qr_tmp;
628628
@@ -650,7 +650,7 @@ static void iscsit_remove_cmd_from_response_queue( · 21 unmodified lines
650650 }
651651 }
652652
653−bool iscsit_conn_all_queues_empty(struct iscsi_conn *conn)
653+bool iscsit_conn_all_queues_empty(struct iscsit_conn *conn)
654654 {
655655 bool empty;
656656
@@ -668,7 +668,7 @@ bool iscsit_conn_all_queues_empty(struct iscsi_conn *conn) · 11 unmodified lines
668668 return empty;
669669 }
670670
671−void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *conn)
671+void iscsit_free_queue_reqs_for_conn(struct iscsit_conn *conn)
672672 {
673673 struct iscsi_queue_req *qr, *qr_tmp;
674674
@@ -694,9 +694,9 @@ void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *conn) · 19 unmodified lines
694694 spin_unlock_bh(&conn->response_queue_lock);
695695 }
696696
697−void iscsit_release_cmd(struct iscsi_cmd *cmd)
697+void iscsit_release_cmd(struct iscsit_cmd *cmd)
698698 {
699− struct iscsi_session *sess;
699+ struct iscsit_session *sess;
700700 struct se_cmd *se_cmd = &cmd->se_cmd;
701701
702702 WARN_ON(!list_empty(&cmd->i_conn_node));
@@ -720,9 +720,9 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd) · 17 unmodified lines
720720 }
721721 EXPORT_SYMBOL(iscsit_release_cmd);
722722
723−void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool check_queues)
723+void __iscsit_free_cmd(struct iscsit_cmd *cmd, bool check_queues)
724724 {
725− struct iscsi_conn *conn = cmd->conn;
725+ struct iscsit_conn *conn = cmd->conn;
726726
727727 WARN_ON(!list_empty(&cmd->i_conn_node));
728728
@@ -742,7 +742,7 @@ void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool check_queues) · 13 unmodified lines
742742 conn->conn_transport->iscsit_unmap_cmd(conn, cmd);
743743 }
744744
745−void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown)
745+void iscsit_free_cmd(struct iscsit_cmd *cmd, bool shutdown)
746746 {
747747 struct se_cmd *se_cmd = cmd->se_cmd.se_tfo ? &cmd->se_cmd : NULL;
748748 int rc;
@@ -762,7 +762,7 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown) · 13 unmodified lines
762762 }
763763 EXPORT_SYMBOL(iscsit_free_cmd);
764764
765−bool iscsit_check_session_usage_count(struct iscsi_session *sess,
765+bool iscsit_check_session_usage_count(struct iscsit_session *sess,
766766 bool can_sleep)
767767 {
768768 spin_lock_bh(&sess->session_usage_lock);
@@ -780,7 +780,7 @@ bool iscsit_check_session_usage_count(struct iscsi_session *sess, · 11 unmodified lines
780780 return false;
781781 }
782782
783−void iscsit_dec_session_usage_count(struct iscsi_session *sess)
783+void iscsit_dec_session_usage_count(struct iscsit_session *sess)
784784 {
785785 spin_lock_bh(&sess->session_usage_lock);
786786 sess->session_usage_count--;
@@ -791,16 +791,16 @@ void iscsit_dec_session_usage_count(struct iscsi_session *sess) · 4 unmodified lines
791791 spin_unlock_bh(&sess->session_usage_lock);
792792 }
793793
794−void iscsit_inc_session_usage_count(struct iscsi_session *sess)
794+void iscsit_inc_session_usage_count(struct iscsit_session *sess)
795795 {
796796 spin_lock_bh(&sess->session_usage_lock);
797797 sess->session_usage_count++;
798798 spin_unlock_bh(&sess->session_usage_lock);
799799 }
800800
801−struct iscsi_conn *iscsit_get_conn_from_cid(struct iscsi_session *sess, u16 cid)
801+struct iscsit_conn *iscsit_get_conn_from_cid(struct iscsit_session *sess, u16 cid)
802802 {
803− struct iscsi_conn *conn;
803+ struct iscsit_conn *conn;
804804
805805 spin_lock_bh(&sess->conn_lock);
806806 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {
@@ -816,9 +816,9 @@ struct iscsi_conn *iscsit_get_conn_from_cid(struct iscsi_session *sess, u16 cid) · 9 unmodified lines
816816 return NULL;
817817 }
818818
819−struct iscsi_conn *iscsit_get_conn_from_cid_rcfr(struct iscsi_session *sess, u16 cid)
819+struct iscsit_conn *iscsit_get_conn_from_cid_rcfr(struct iscsit_session *sess, u16 cid)
820820 {
821− struct iscsi_conn *conn;
821+ struct iscsit_conn *conn;
822822
823823 spin_lock_bh(&sess->conn_lock);
824824 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {
@@ -836,7 +836,7 @@ struct iscsi_conn *iscsit_get_conn_from_cid_rcfr(struct iscsi_session *sess, u16 · 11 unmodified lines
836836 return NULL;
837837 }
838838
839−void iscsit_check_conn_usage_count(struct iscsi_conn *conn)
839+void iscsit_check_conn_usage_count(struct iscsit_conn *conn)
840840 {
841841 spin_lock_bh(&conn->conn_usage_lock);
842842 if (conn->conn_usage_count != 0) {
@@ -849,7 +849,7 @@ void iscsit_check_conn_usage_count(struct iscsi_conn *conn) · 6 unmodified lines
849849 spin_unlock_bh(&conn->conn_usage_lock);
850850 }
851851
852−void iscsit_dec_conn_usage_count(struct iscsi_conn *conn)
852+void iscsit_dec_conn_usage_count(struct iscsit_conn *conn)
853853 {
854854 spin_lock_bh(&conn->conn_usage_lock);
855855 conn->conn_usage_count--;
@@ -860,17 +860,17 @@ void iscsit_dec_conn_usage_count(struct iscsi_conn *conn) · 4 unmodified lines
860860 spin_unlock_bh(&conn->conn_usage_lock);
861861 }
862862
863−void iscsit_inc_conn_usage_count(struct iscsi_conn *conn)
863+void iscsit_inc_conn_usage_count(struct iscsit_conn *conn)
864864 {
865865 spin_lock_bh(&conn->conn_usage_lock);
866866 conn->conn_usage_count++;
867867 spin_unlock_bh(&conn->conn_usage_lock);
868868 }
869869
870−static int iscsit_add_nopin(struct iscsi_conn *conn, int want_response)
870+static int iscsit_add_nopin(struct iscsit_conn *conn, int want_response)
871871 {
872872 u8 state;
873− struct iscsi_cmd *cmd;
873+ struct iscsit_cmd *cmd;
874874
875875 cmd = iscsit_allocate_cmd(conn, TASK_RUNNING);
876876 if (!cmd)
@@ -895,8 +895,8 @@ static int iscsit_add_nopin(struct iscsi_conn *conn, int want_response) · 18 unmodified lines
895895
896896 void iscsit_handle_nopin_response_timeout(struct timer_list *t)
897897 {
898− struct iscsi_conn *conn = from_timer(conn, t, nopin_response_timer);
899− struct iscsi_session *sess = conn->sess;
898+ struct iscsit_conn *conn = from_timer(conn, t, nopin_response_timer);
899+ struct iscsit_session *sess = conn->sess;
900900
901901 iscsit_inc_conn_usage_count(conn);
902902
@@ -919,9 +919,9 @@ void iscsit_handle_nopin_response_timeout(struct timer_list *t) · 16 unmodified lines
919919 iscsit_dec_conn_usage_count(conn);
920920 }
921921
922−void iscsit_mod_nopin_response_timer(struct iscsi_conn *conn)
922+void iscsit_mod_nopin_response_timer(struct iscsit_conn *conn)
923923 {
924− struct iscsi_session *sess = conn->sess;
924+ struct iscsit_session *sess = conn->sess;
925925 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
926926
927927 spin_lock_bh(&conn->nopin_timer_lock);
@@ -935,9 +935,9 @@ void iscsit_mod_nopin_response_timer(struct iscsi_conn *conn) · 7 unmodified lines
935935 spin_unlock_bh(&conn->nopin_timer_lock);
936936 }
937937
938−void iscsit_start_nopin_response_timer(struct iscsi_conn *conn)
938+void iscsit_start_nopin_response_timer(struct iscsit_conn *conn)
939939 {
940− struct iscsi_session *sess = conn->sess;
940+ struct iscsit_session *sess = conn->sess;
941941 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
942942
943943 spin_lock_bh(&conn->nopin_timer_lock);
@@ -956,7 +956,7 @@ void iscsit_start_nopin_response_timer(struct iscsi_conn *conn) · 12 unmodified lines
956956 spin_unlock_bh(&conn->nopin_timer_lock);
957957 }
958958
959−void iscsit_stop_nopin_response_timer(struct iscsi_conn *conn)
959+void iscsit_stop_nopin_response_timer(struct iscsit_conn *conn)
960960 {
961961 spin_lock_bh(&conn->nopin_timer_lock);
962962 if (!(conn->nopin_response_timer_flags & ISCSI_TF_RUNNING)) {
@@ -975,7 +975,7 @@ void iscsit_stop_nopin_response_timer(struct iscsi_conn *conn) · 12 unmodified lines
975975
976976 void iscsit_handle_nopin_timeout(struct timer_list *t)
977977 {
978− struct iscsi_conn *conn = from_timer(conn, t, nopin_timer);
978+ struct iscsit_conn *conn = from_timer(conn, t, nopin_timer);
979979
980980 iscsit_inc_conn_usage_count(conn);
981981
@@ -992,9 +992,9 @@ void iscsit_handle_nopin_timeout(struct timer_list *t) · 10 unmodified lines
992992 iscsit_dec_conn_usage_count(conn);
993993 }
994994
995−void __iscsit_start_nopin_timer(struct iscsi_conn *conn)
995+void __iscsit_start_nopin_timer(struct iscsit_conn *conn)
996996 {
997− struct iscsi_session *sess = conn->sess;
997+ struct iscsit_session *sess = conn->sess;
998998 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
999999
10001000 lockdep_assert_held(&conn->nopin_timer_lock);
@@ -1016,14 +1016,14 @@ void __iscsit_start_nopin_timer(struct iscsi_conn *conn) · 15 unmodified lines
10161016 " interval\n", conn->cid, na->nopin_timeout);
10171017 }
10181018
1019−void iscsit_start_nopin_timer(struct iscsi_conn *conn)
1019+void iscsit_start_nopin_timer(struct iscsit_conn *conn)
10201020 {
10211021 spin_lock_bh(&conn->nopin_timer_lock);
10221022 __iscsit_start_nopin_timer(conn);
10231023 spin_unlock_bh(&conn->nopin_timer_lock);
10241024 }
10251025
1026−void iscsit_stop_nopin_timer(struct iscsi_conn *conn)
1026+void iscsit_stop_nopin_timer(struct iscsit_conn *conn)
10271027 {
10281028 spin_lock_bh(&conn->nopin_timer_lock);
10291029 if (!(conn->nopin_timer_flags & ISCSI_TF_RUNNING)) {
@@ -1041,8 +1041,8 @@ void iscsit_stop_nopin_timer(struct iscsi_conn *conn) · 11 unmodified lines
10411041 }
10421042
10431043 int iscsit_send_tx_data(
1044− struct iscsi_cmd *cmd,
1045− struct iscsi_conn *conn,
1044+ struct iscsit_cmd *cmd,
1045+ struct iscsit_conn *conn,
10461046 int use_misc)
10471047 {
10481048 int tx_sent, tx_size;
@@ -1074,8 +1074,8 @@ send_data: · 25 unmodified lines
10741074 }
10751075
10761076 int iscsit_fe_sendpage_sg(
1077− struct iscsi_cmd *cmd,
1078− struct iscsi_conn *conn)
1077+ struct iscsit_cmd *cmd,
1078+ struct iscsit_conn *conn)
10791079 {
10801080 struct scatterlist *sg = cmd->first_data_sg;
10811081 struct kvec iov;
@@ -1179,7 +1179,7 @@ send_datacrc: · 97 unmodified lines
11791179 * Parameters: iSCSI Connection, Status Class, Status Detail.

64 more lines aren’t shown here.

drivers/target/iscsi/iscsi_target_util.h+51−51

This diff is large: its 118 lines aren’t shown here.

drivers/target/target_core_configfs.c+28−19

This diff is large: its 101 lines aren’t shown here.

drivers/target/target_core_spc.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/target/target_core_user.c+42−8

This diff is large: its 105 lines aren’t shown here.

include/scsi/libfcoe.h+2−0

This diff is large: its 16 lines aren’t shown here.

include/scsi/libiscsi.h+3−3

This diff is large: its 13 lines aren’t shown here.

include/scsi/sas_ata.h+7−0

This diff is large: its 21 lines aren’t shown here.

include/scsi/scsi_device.h+8−1

This diff is large: its 27 lines aren’t shown here.

include/scsi/scsi_proto.h+8−1

This diff is large: its 23 lines aren’t shown here.

include/target/iscsi/iscsi_target_core.h+26−26

This diff is large: its 181 lines aren’t shown here.

include/target/iscsi/iscsi_transport.h+63−63

This diff is large: its 200 lines aren’t shown here.

include/uapi/scsi/scsi_bsg_mpi3mr.h+582−0

This diff is large: its 583 lines aren’t shown here.