History

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

Pull SCSI updates from James Bottomley: "This is mostly update of the usual drivers: qla2xxx, ufs, smartpqi, lpfc, hisi_sas, qedf, mpt3sas; plus a whole load of minor updates. The only core change this time around is the addition of request batching for virtio. Since batching requires an additional flag to use, it should be invisible to the rest of the drivers" * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (264 commits) scsi: hisi_sas: Fix the conflict between device gone and host reset scsi: hisi_sas: Add BIST support for phy loopback scsi: hisi_sas: Add hisi_sas_debugfs_alloc() to centralise allocation scsi: hisi_sas: Remove some unused function arguments scsi: hisi_sas: Remove redundant work declaration scsi: hisi_sas: Remove hisi_sas_hw.slot_complete scsi: hisi_sas: Assign NCQ tag for all NCQ commands scsi: hisi_sas: Update all the registers after suspend and resume scsi: hisi_sas: Retry 3 times TMF IO for SAS disks when init device scsi: hisi_sas: Remove sleep after issue phy reset if sas_smp_phy_control() fails scsi: hisi_sas: Directly return when running I_T_nexus reset if phy disabled scsi: hisi_sas: Use true/false as input parameter of sas_phy_reset() scsi: hisi_sas: add debugfs auto-trigger for internal abort time out scsi: virtio_scsi: unplug LUNs when events missed scsi: scsi_dh_rdac: zero cdb in send_mode_select() scsi: fcoe: fix null-ptr-deref Read in fc_release_transport scsi: ufs-hisi: use devm_platform_ioremap_resource() to simplify code scsi: ufshcd: use devm_platform_ioremap_resource() to simplify code scsi: hisi_sas: use devm_platform_ioremap_resource() to simplify code scsi: ufs: Use kmemdup in ufshcd_read_string_desc() ...

Linus Torvalds committed 7 years ago

Commit 10fd7172 parents 3e414b5 e74006e130 files · +5755 −3679Browse files

Unified · Split

130 files
  1. Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +2 −0
  2. arch/arm64/boot/dts/qcom/sdm845-db845c.dts +2 −0
  3. arch/arm64/boot/dts/qcom/sdm845-mtp.dts +2 −0
  4. drivers/scsi/aic94xx/aic94xx_init.c +3 −6
  5. drivers/scsi/bfa/bfad_im.c +1 −1
  6. drivers/scsi/bnx2fc/bnx2fc_fcoe.c +0 −2
  7. drivers/scsi/bnx2fc/bnx2fc_hwi.c +0 −16
  8. drivers/scsi/bnx2fc/bnx2fc_io.c +0 −7
  9. drivers/scsi/csiostor/csio_wr.c +2 −6
  10. drivers/scsi/cxlflash/main.c +10 −2
  11. drivers/scsi/device_handler/scsi_dh_rdac.c +2 −0
  12. drivers/scsi/esas2r/esas2r_init.c +4 −9
  13. drivers/scsi/esas2r/esas2r_ioctl.c +5 −9
  14. drivers/scsi/fcoe/fcoe.c +11 −6
  15. drivers/scsi/fdomain.c +3 −3
  16. drivers/scsi/fdomain_isa.c +2 −3
  17. drivers/scsi/fnic/fnic_debugfs.c +1 −3
  18. drivers/scsi/fnic/fnic_fcs.c +10 −4
  19. drivers/scsi/fnic/fnic_isr.c +2 −2
  20. drivers/scsi/fnic/fnic_trace.c +1 −1
  21. drivers/scsi/hisi_sas/hisi_sas.h +43 −11
  22. drivers/scsi/hisi_sas/hisi_sas_main.c +783 −199
  23. drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +3 −45
  24. drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +22 −70
  25. drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +224 −83
  26. drivers/scsi/ibmvscsi/ibmvfc.c +3 −0
  27. drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +3 −0
  28. drivers/scsi/lpfc/lpfc.h +7 −4
  29. drivers/scsi/lpfc/lpfc_attr.c +55 −21
  30. drivers/scsi/lpfc/lpfc_bsg.c +17 −12
  31. drivers/scsi/lpfc/lpfc_crtn.h +2 −11
  32. drivers/scsi/lpfc/lpfc_ct.c +53 −15
  33. drivers/scsi/lpfc/lpfc_debugfs.c +12 −216
  34. drivers/scsi/lpfc/lpfc_debugfs.h +17 −44
  35. drivers/scsi/lpfc/lpfc_disc.h +3 −0
  36. drivers/scsi/lpfc/lpfc_els.c +99 −17
  37. drivers/scsi/lpfc/lpfc_hbadisc.c +109 −72
  38. drivers/scsi/lpfc/lpfc_hw.h +3 −3
  39. drivers/scsi/lpfc/lpfc_hw4.h +34 −0
  40. drivers/scsi/lpfc/lpfc_init.c +429 −497
  41. drivers/scsi/lpfc/lpfc_mem.c +19 −46
  42. drivers/scsi/lpfc/lpfc_nportdisc.c +36 −7
  43. drivers/scsi/lpfc/lpfc_nvme.c +245 −144
  44. drivers/scsi/lpfc/lpfc_nvmet.c +12 −16
  45. drivers/scsi/lpfc/lpfc_scsi.c +379 −212
  46. drivers/scsi/lpfc/lpfc_sli.c +397 −136
  47. drivers/scsi/lpfc/lpfc_sli.h +10 −1
  48. drivers/scsi/lpfc/lpfc_sli4.h +30 −20
  49. drivers/scsi/lpfc/lpfc_version.h +1 −1
  50. drivers/scsi/lpfc/lpfc_vport.c +5 −3
  51. drivers/scsi/megaraid/megaraid_sas.h +1 −0
  52. drivers/scsi/megaraid/megaraid_sas_base.c +91 −21
  53. drivers/scsi/megaraid/megaraid_sas_fusion.c +14 −15
  54. drivers/scsi/mpt3sas/mpi/mpi2.h +3 −2
  55. drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h +8 −2
  56. drivers/scsi/mpt3sas/mpi/mpi2_image.h +21 −18
  57. drivers/scsi/mpt3sas/mpi/mpi2_pci.h +7 −6
  58. drivers/scsi/mpt3sas/mpi/mpi2_tool.h +7 −6
  59. drivers/scsi/mpt3sas/mpt3sas_base.c +162 −13
  60. drivers/scsi/mpt3sas/mpt3sas_base.h +28 −2
  61. drivers/scsi/mpt3sas/mpt3sas_ctl.c +166 −12
  62. drivers/scsi/mpt3sas/mpt3sas_scsih.c +141 −55
  63. drivers/scsi/ncr53c8xx.c +4 −0
  64. drivers/scsi/pm8001/pm8001_sas.c +3 −10
  65. drivers/scsi/pmcraid.c +1 −1
  66. drivers/scsi/qedf/qedf.h +1 −0
  67. drivers/scsi/qedf/qedf_debugfs.c +8 −8
  68. drivers/scsi/qedf/qedf_els.c +30 −8
  69. drivers/scsi/qedf/qedf_fip.c +21 −12
  70. drivers/scsi/qedf/qedf_io.c +56 −11
  71. drivers/scsi/qedf/qedf_main.c +113 −65
  72. drivers/scsi/qedf/qedf_version.h +4 −4
  73. drivers/scsi/qla2xxx/qla_attr.c +6 −6
  74. drivers/scsi/qla2xxx/qla_bsg.c +11 −12
  75. drivers/scsi/qla2xxx/qla_dbg.c +2 −1
  76. drivers/scsi/qla2xxx/qla_def.h +95 −37
  77. drivers/scsi/qla2xxx/qla_dfs.c +3 −6
  78. drivers/scsi/qla2xxx/qla_dsd.h +2 −0
  79. drivers/scsi/qla2xxx/qla_fw.h +4 −4
  80. drivers/scsi/qla2xxx/qla_gbl.h +20 −13
  81. drivers/scsi/qla2xxx/qla_gs.c +108 −146
  82. drivers/scsi/qla2xxx/qla_init.c +245 −305
  83. drivers/scsi/qla2xxx/qla_inline.h +15 −13
  84. drivers/scsi/qla2xxx/qla_iocb.c +82 −144
  85. drivers/scsi/qla2xxx/qla_isr.c +11 −18
  86. drivers/scsi/qla2xxx/qla_mbx.c +8 −18
  87. drivers/scsi/qla2xxx/qla_mid.c +1 −3
  88. drivers/scsi/qla2xxx/qla_mr.c +30 −37
  89. drivers/scsi/qla2xxx/qla_nvme.c +10 −22
  90. drivers/scsi/qla2xxx/qla_nvme.h +2 −3
  91. drivers/scsi/qla2xxx/qla_nx.c +13 −9
  92. drivers/scsi/qla2xxx/qla_nx.h +7 −7
  93. drivers/scsi/qla2xxx/qla_nx2.c +1 −1
  94. drivers/scsi/qla2xxx/qla_os.c +106 −131
  95. drivers/scsi/qla2xxx/qla_sup.c +9 −7
  96. drivers/scsi/qla2xxx/qla_target.c +82 −130
  97. drivers/scsi/qla2xxx/qla_target.h +12 −23
  98. drivers/scsi/qla2xxx/qla_tmpl.c +4 −3
  99. drivers/scsi/qla2xxx/qla_version.h +1 −1
  100. drivers/scsi/qla2xxx/tcm_qla2xxx.c +10 −17
  101. drivers/scsi/qlogicpti.c +10 −0
  102. drivers/scsi/scsi_debugfs.c +2 −3
  103. drivers/scsi/scsi_lib.c +48 −4
  104. drivers/scsi/scsi_logging.c +3 −45
  105. drivers/scsi/sd.c +1 −0
  106. drivers/scsi/smartpqi/Kconfig +2 −0
  107. drivers/scsi/smartpqi/smartpqi.h +18 −2
  108. drivers/scsi/smartpqi/smartpqi_init.c +205 −31
  109. drivers/scsi/smartpqi/smartpqi_sas_transport.c +100 −2
  110. drivers/scsi/sun3_scsi.c +2 −0
  111. drivers/scsi/sym53c8xx_2/sym_nvram.c +1 −1
  112. drivers/scsi/ufs/cdns-pltfrm.c +33 −7
  113. drivers/scsi/ufs/ufs-hisi.c +1 −3
  114. drivers/scsi/ufs/ufs-qcom.c +37 −4
  115. drivers/scsi/ufs/ufs-qcom.h +4 −0
  116. drivers/scsi/ufs/ufs-sysfs.c +9 −9
  117. drivers/scsi/ufs/ufs.h +1 −1
  118. drivers/scsi/ufs/ufshcd-pltfrm.c +1 −3
  119. drivers/scsi/ufs/ufshcd.c +166 −115
  120. drivers/scsi/ufs/ufshcd.h +45 −12
  121. drivers/scsi/virtio_scsi.c +73 −15
  122. drivers/scsi/wd33c93.c +1 −0
  123. drivers/target/target_core_user.c +20 −0
  124. include/linux/nvme-fc-driver.h +2 −0
  125. include/scsi/scsi_cmnd.h +1 −0
  126. include/scsi/scsi_dbg.h +0 −2
  127. include/scsi/scsi_host.h +14 −2
  128. include/uapi/scsi/scsi_bsg_fc.h +28 −26
  129. include/uapi/scsi/scsi_netlink.h +10 −10
  130. include/uapi/scsi/scsi_netlink_fc.h +9 −8
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt+2−0
@@ -54,6 +54,8 @@ Optional properties: · 53 unmodified lines
5454 PHY reset from the UFS controller.
5555 - resets : reset node register
5656 - reset-names : describe reset node register, the "rst" corresponds to reset the whole UFS IP.
57+- reset-gpios : A phandle and gpio specifier denoting the GPIO connected
58+ to the RESET pin of the UFS memory device.
5759
5860 Note: If above properties are not defined it can be assumed that the supply
5961 regulators or clocks are always on.
arch/arm64/boot/dts/qcom/sdm845-db845c.dts+2−0
@@ -497,6 +497,8 @@ · 496 unmodified lines
497497 &ufs_mem_hc {
498498 status = "okay";
499499
500+ reset-gpios = <&tlmm 150 GPIO_ACTIVE_LOW>;
501+
500502 vcc-supply = <&vreg_l20a_2p95>;
501503 vcc-max-microamp = <800000>;
502504 };
arch/arm64/boot/dts/qcom/sdm845-mtp.dts+2−0
@@ -388,6 +388,8 @@ · 387 unmodified lines
388388 &ufs_mem_hc {
389389 status = "okay";
390390
391+ reset-gpios = <&tlmm 150 GPIO_ACTIVE_LOW>;
392+
391393 vcc-supply = <&vreg_l20a_2p95>;
392394 vcc-max-microamp = <600000>;
393395 };
drivers/scsi/aic94xx/aic94xx_init.c+3−6
@@ -565,8 +565,7 @@ static void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha) · 564 unmodified lines
565565 if (asd_ha->hw_prof.scb_ext)
566566 asd_free_coherent(asd_ha, asd_ha->hw_prof.scb_ext);
567567
568− if (asd_ha->hw_prof.ddb_bitmap)
569− kfree(asd_ha->hw_prof.ddb_bitmap);
568+ kfree(asd_ha->hw_prof.ddb_bitmap);
570569 asd_ha->hw_prof.ddb_bitmap = NULL;
571570
572571 for (i = 0; i < ASD_MAX_PHYS; i++) {
@@ -641,12 +640,10 @@ Err: · 68 unmodified lines
641640
642641 static void asd_destroy_global_caches(void)
643642 {
644− if (asd_dma_token_cache)
645− kmem_cache_destroy(asd_dma_token_cache);
643+ kmem_cache_destroy(asd_dma_token_cache);
646644 asd_dma_token_cache = NULL;
647645
648− if (asd_ascb_cache)
649− kmem_cache_destroy(asd_ascb_cache);
646+ kmem_cache_destroy(asd_ascb_cache);
650647 asd_ascb_cache = NULL;
651648 }
652649
drivers/scsi/bfa/bfad_im.c+1−1
@@ -536,7 +536,7 @@ bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port, · 535 unmodified lines
536536 struct device *dev)
537537 {
538538 struct bfad_im_port_pointer *im_portp;
539− int error = 1;
539+ int error;
540540
541541 mutex_lock(&bfad_mutex);
542542 error = idr_alloc(&bfad_im_port_index, im_port, 0, 0, GFP_KERNEL);
drivers/scsi/bnx2fc/bnx2fc_fcoe.c+0−2
@@ -428,7 +428,6 @@ static int bnx2fc_rcv(struct sk_buff *skb, struct net_device *dev, · 427 unmodified lines
428428 struct fc_lport *lport;
429429 struct bnx2fc_interface *interface;
430430 struct fcoe_ctlr *ctlr;
431− struct fc_frame_header *fh;
432431 struct fcoe_rcv_info *fr;
433432 struct fcoe_percpu_s *bg;
434433 struct sk_buff *tmp_skb;
@@ -463,7 +462,6 @@ static int bnx2fc_rcv(struct sk_buff *skb, struct net_device *dev, · 28 unmodified lines
463462 goto err;
464463
465464 skb_set_transport_header(skb, sizeof(struct fcoe_hdr));
466− fh = (struct fc_frame_header *) skb_transport_header(skb);
467465
468466 fr = fcoe_dev_from_skb(skb);
469467 fr->fr_dev = lport;
drivers/scsi/bnx2fc/bnx2fc_hwi.c+0−16
@@ -633,7 +633,6 @@ static void bnx2fc_process_unsol_compl(struct bnx2fc_rport *tgt, u16 wqe) · 632 unmodified lines
633633 u16 xid;
634634 u32 frame_len, len;
635635 struct bnx2fc_cmd *io_req = NULL;
636− struct fcoe_task_ctx_entry *task, *task_page;
637636 struct bnx2fc_interface *interface = tgt->port->priv;
638637 struct bnx2fc_hba *hba = interface->hba;
639638 int task_idx, index;
@@ -711,9 +710,6 @@ static void bnx2fc_process_unsol_compl(struct bnx2fc_rport *tgt, u16 wqe) · 71 unmodified lines
711710
712711 task_idx = xid / BNX2FC_TASKS_PER_PAGE;
713712 index = xid % BNX2FC_TASKS_PER_PAGE;
714− task_page = (struct fcoe_task_ctx_entry *)
715− hba->task_ctx[task_idx];
716− task = &(task_page[index]);
717713
718714 io_req = (struct bnx2fc_cmd *)hba->cmd_mgr->cmds[xid];
719715 if (!io_req)
@@ -839,9 +835,6 @@ ret_err_rqe: · 119 unmodified lines
839835
840836 task_idx = xid / BNX2FC_TASKS_PER_PAGE;
841837 index = xid % BNX2FC_TASKS_PER_PAGE;
842− task_page = (struct fcoe_task_ctx_entry *)
843− interface->hba->task_ctx[task_idx];
844− task = &(task_page[index]);
845838 io_req = (struct bnx2fc_cmd *)hba->cmd_mgr->cmds[xid];
846839 if (!io_req)
847840 goto ret_warn_rqe;
@@ -1122,7 +1115,6 @@ static void bnx2fc_process_ofld_cmpl(struct bnx2fc_hba *hba, · 274 unmodified lines
11221115 struct fcoe_kcqe *ofld_kcqe)
11231116 {
11241117 struct bnx2fc_rport *tgt;
1125− struct fcoe_port *port;
11261118 struct bnx2fc_interface *interface;
11271119 u32 conn_id;
11281120 u32 context_id;
@@ -1136,7 +1128,6 @@ static void bnx2fc_process_ofld_cmpl(struct bnx2fc_hba *hba, · 7 unmodified lines
11361128 }
11371129 BNX2FC_TGT_DBG(tgt, "Entered ofld compl - context_id = 0x%x\n",
11381130 ofld_kcqe->fcoe_conn_context_id);
1139− port = tgt->port;
11401131 interface = tgt->port->priv;
11411132 if (hba != interface->hba) {
11421133 printk(KERN_ERR PFX "ERROR:ofld_cmpl: HBA mis-match\n");
@@ -1463,10 +1454,7 @@ void bnx2fc_init_seq_cleanup_task(struct bnx2fc_cmd *seq_clnp_req, · 320 unmodified lines
14631454 {
14641455 struct scsi_cmnd *sc_cmd = orig_io_req->sc_cmd;
14651456 struct bnx2fc_rport *tgt = seq_clnp_req->tgt;
1466− struct bnx2fc_interface *interface = tgt->port->priv;
14671457 struct fcoe_bd_ctx *bd = orig_io_req->bd_tbl->bd_tbl;
1468− struct fcoe_task_ctx_entry *orig_task;
1469− struct fcoe_task_ctx_entry *task_page;
14701458 struct fcoe_ext_mul_sges_ctx *sgl;
14711459 u8 task_type = FCOE_TASK_TYPE_SEQUENCE_CLEANUP;
14721460 u8 orig_task_type;
@@ -1528,10 +1516,6 @@ void bnx2fc_init_seq_cleanup_task(struct bnx2fc_cmd *seq_clnp_req, · 55 unmodified lines
15281516 orig_task_idx = orig_xid / BNX2FC_TASKS_PER_PAGE;
15291517 index = orig_xid % BNX2FC_TASKS_PER_PAGE;
15301518
1531− task_page = (struct fcoe_task_ctx_entry *)
1532− interface->hba->task_ctx[orig_task_idx];
1533− orig_task = &(task_page[index]);
1534−
15351519 /* Multiple SGEs were used for this IO */
15361520 sgl = &task->rxwr_only.union_ctx.read_info.sgl_ctx.sgl;
15371521 sgl->mul_sgl.cur_sge_addr.lo = (u32)phys_addr;
drivers/scsi/bnx2fc/bnx2fc_io.c+0−7
@@ -930,7 +930,6 @@ abts_err: · 929 unmodified lines
930930 int bnx2fc_initiate_seq_cleanup(struct bnx2fc_cmd *orig_io_req, u32 offset,
931931 enum fc_rctl r_ctl)
932932 {
933− struct fc_lport *lport;
934933 struct bnx2fc_rport *tgt = orig_io_req->tgt;
935934 struct bnx2fc_interface *interface;
936935 struct fcoe_port *port;
@@ -948,7 +947,6 @@ int bnx2fc_initiate_seq_cleanup(struct bnx2fc_cmd *orig_io_req, u32 offset, · 11 unmodified lines
948947
949948 port = orig_io_req->port;
950949 interface = port->priv;
951− lport = port->lport;
952950
953951 cb_arg = kzalloc(sizeof(struct bnx2fc_els_cb_arg), GFP_ATOMIC);
954952 if (!cb_arg) {
@@ -999,7 +997,6 @@ cleanup_err: · 44 unmodified lines
999997
1000998 int bnx2fc_initiate_cleanup(struct bnx2fc_cmd *io_req)
1001999 {
1002− struct fc_lport *lport;
10031000 struct bnx2fc_rport *tgt = io_req->tgt;
10041001 struct bnx2fc_interface *interface;
10051002 struct fcoe_port *port;
@@ -1015,7 +1012,6 @@ int bnx2fc_initiate_cleanup(struct bnx2fc_cmd *io_req) · 9 unmodified lines
10151012
10161013 port = io_req->port;
10171014 interface = port->priv;
1018− lport = port->lport;
10191015
10201016 cleanup_io_req = bnx2fc_elstm_alloc(tgt, BNX2FC_CLEANUP);
10211017 if (!cleanup_io_req) {
@@ -1927,8 +1923,6 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req, · 905 unmodified lines
19271923 struct fcoe_fcp_rsp_payload *fcp_rsp;
19281924 struct bnx2fc_rport *tgt = io_req->tgt;
19291925 struct scsi_cmnd *sc_cmd;
1930− struct Scsi_Host *host;
1931−
19321926
19331927 /* scsi_cmd_cmpl is called with tgt lock held */
19341928
@@ -1957,7 +1951,6 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req, · 22 unmodified lines
19571951 /* parse fcp_rsp and obtain sense data from RQ if available */
19581952 bnx2fc_parse_fcp_rsp(io_req, fcp_rsp, num_rq);
19591953
1960− host = sc_cmd->device->host;
19611954 if (!sc_cmd->SCp.ptr) {
19621955 printk(KERN_ERR PFX "SCp.ptr is NULL\n");
19631956 return;
drivers/scsi/csiostor/csio_wr.c+2−6
@@ -1316,7 +1316,6 @@ csio_wr_fixup_host_params(struct csio_hw *hw) · 1315 unmodified lines
13161316 u32 fl_align = clsz < 32 ? 32 : clsz;
13171317 u32 pack_align;
13181318 u32 ingpad, ingpack;
1319− int pcie_cap;
13201319
13211320 csio_wr_reg32(hw, HOSTPAGESIZEPF0_V(s_hps) | HOSTPAGESIZEPF1_V(s_hps) |
13221321 HOSTPAGESIZEPF2_V(s_hps) | HOSTPAGESIZEPF3_V(s_hps) |
@@ -1347,8 +1346,7 @@ csio_wr_fixup_host_params(struct csio_hw *hw) · 24 unmodified lines
13471346 * multiple of the Maximum Payload Size.
13481347 */
13491348 pack_align = fl_align;
1350− pcie_cap = pci_find_capability(hw->pdev, PCI_CAP_ID_EXP);
1351− if (pcie_cap) {
1349+ if (pci_is_pcie(hw->pdev)) {
13521350 u32 mps, mps_log;
13531351 u16 devctl;
13541352
@@ -1356,9 +1354,7 @@ csio_wr_fixup_host_params(struct csio_hw *hw) · 1 unmodified line
13561354 * [bits 7:5] encodes sizes as powers of 2 starting at
13571355 * 128 bytes.
13581356 */
1359− pci_read_config_word(hw->pdev,
1360− pcie_cap + PCI_EXP_DEVCTL,
1361− &devctl);
1357+ pcie_capability_read_word(hw->pdev, PCI_EXP_DEVCTL, &devctl);
13621358 mps_log = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5) + 7;
13631359 mps = 1 << mps_log;
13641360 if (mps > pack_align)
drivers/scsi/cxlflash/main.c+10−2
@@ -753,10 +753,13 @@ static void term_intr(struct cxlflash_cfg *cfg, enum undo_level level, · 752 unmodified lines
753753 /* SISL_MSI_ASYNC_ERROR is setup only for the primary HWQ */
754754 if (index == PRIMARY_HWQ)
755755 cfg->ops->unmap_afu_irq(hwq->ctx_cookie, 3, hwq);
756+ /* fall through */
756757 case UNMAP_TWO:
757758 cfg->ops->unmap_afu_irq(hwq->ctx_cookie, 2, hwq);
759+ /* fall through */
758760 case UNMAP_ONE:
759761 cfg->ops->unmap_afu_irq(hwq->ctx_cookie, 1, hwq);
762+ /* fall through */
760763 case FREE_IRQ:
761764 cfg->ops->free_afu_irqs(hwq->ctx_cookie);
762765 /* fall through */
@@ -973,14 +976,18 @@ static void cxlflash_remove(struct pci_dev *pdev) · 210 unmodified lines
973976 switch (cfg->init_state) {
974977 case INIT_STATE_CDEV:
975978 cxlflash_release_chrdev(cfg);
979+ /* fall through */
976980 case INIT_STATE_SCSI:
977981 cxlflash_term_local_luns(cfg);
978982 scsi_remove_host(cfg->host);
983+ /* fall through */
979984 case INIT_STATE_AFU:
980985 term_afu(cfg);
986+ /* fall through */
981987 case INIT_STATE_PCI:
982988 cfg->ops->destroy_afu(cfg->afu_cookie);
983989 pci_disable_device(pdev);
990+ /* fall through */
984991 case INIT_STATE_NONE:
985992 free_mem(cfg);
986993 scsi_host_put(cfg->host);
@@ -2353,11 +2360,11 @@ retry: · 1366 unmodified lines
23532360 cxlflash_schedule_async_reset(cfg);
23542361 break;
23552362 }
2356− /* fall through to retry */
2363+ /* fall through - to retry */
23572364 case -EAGAIN:
23582365 if (++nretry < 2)
23592366 goto retry;
2360− /* fall through to exit */
2367+ /* fall through - to exit */
23612368 default:
23622369 break;
23632370 }
@@ -3017,6 +3024,7 @@ retry: · 653 unmodified lines
30173024 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET);
30183025 if (cfg->state == STATE_NORMAL)
30193026 goto retry;
3027+ /* else, fall through */
30203028 default:
30213029 /* Ideally should not happen */
30223030 dev_err(dev, "%s: Device is not ready, state=%d\n",
drivers/scsi/device_handler/scsi_dh_rdac.c+2−0
@@ -546,6 +546,8 @@ static void send_mode_select(struct work_struct *work) · 545 unmodified lines
546546 spin_unlock(&ctlr->ms_lock);
547547
548548 retry:
549+ memset(cdb, 0, sizeof(cdb));
550+
549551 data_size = rdac_failover_get(ctlr, &list, cdb);
550552
551553 RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, "
drivers/scsi/esas2r/esas2r_init.c+4−9
@@ -762,14 +762,10 @@ u32 esas2r_get_uncached_size(struct esas2r_adapter *a) · 761 unmodified lines
762762
763763 static void esas2r_init_pci_cfg_space(struct esas2r_adapter *a)
764764 {
765− int pcie_cap_reg;
766−
767− pcie_cap_reg = pci_find_capability(a->pcid, PCI_CAP_ID_EXP);
768− if (pcie_cap_reg) {
765+ if (pci_is_pcie(a->pcid)) {
769766 u16 devcontrol;
770767
771− pci_read_config_word(a->pcid, pcie_cap_reg + PCI_EXP_DEVCTL,
772− &devcontrol);
768+ pcie_capability_read_word(a->pcid, PCI_EXP_DEVCTL, &devcontrol);
773769
774770 if ((devcontrol & PCI_EXP_DEVCTL_READRQ) >
775771 PCI_EXP_DEVCTL_READRQ_512B) {
@@ -778,9 +774,8 @@ static void esas2r_init_pci_cfg_space(struct esas2r_adapter *a) · 2 unmodified lines
778774
779775 devcontrol &= ~PCI_EXP_DEVCTL_READRQ;
780776 devcontrol |= PCI_EXP_DEVCTL_READRQ_512B;
781− pci_write_config_word(a->pcid,
782− pcie_cap_reg + PCI_EXP_DEVCTL,
783− devcontrol);
777+ pcie_capability_write_word(a->pcid, PCI_EXP_DEVCTL,
778+ devcontrol);
784779 }
785780 }
786781 }
drivers/scsi/esas2r/esas2r_ioctl.c+5−9
@@ -757,7 +757,6 @@ static int hba_ioctl_callback(struct esas2r_adapter *a, · 756 unmodified lines
757757
758758 struct atto_hba_get_adapter_info *gai =
759759 &hi->data.get_adap_info;
760− int pcie_cap_reg;
761760
762761 if (hi->flags & HBAF_TUNNEL) {
763762 hi->status = ATTO_STS_UNSUPPORTED;
@@ -784,17 +783,14 @@ static int hba_ioctl_callback(struct esas2r_adapter *a, · 20 unmodified lines
784783 gai->pci.dev_num = PCI_SLOT(a->pcid->devfn);
785784 gai->pci.func_num = PCI_FUNC(a->pcid->devfn);
786785
787− pcie_cap_reg = pci_find_capability(a->pcid, PCI_CAP_ID_EXP);
788− if (pcie_cap_reg) {
786+ if (pci_is_pcie(a->pcid)) {
789787 u16 stat;
790788 u32 caps;
791789
792− pci_read_config_word(a->pcid,
793− pcie_cap_reg + PCI_EXP_LNKSTA,
794− &stat);
795− pci_read_config_dword(a->pcid,
796− pcie_cap_reg + PCI_EXP_LNKCAP,
797− &caps);
790+ pcie_capability_read_word(a->pcid, PCI_EXP_LNKSTA,
791+ &stat);
792+ pcie_capability_read_dword(a->pcid, PCI_EXP_LNKCAP,
793+ &caps);
798794
799795 gai->pci.link_speed_curr =
800796 (u8)(stat & PCI_EXP_LNKSTA_CLS);
drivers/scsi/fcoe/fcoe.c+11−6
@@ -1250,15 +1250,21 @@ static int __init fcoe_if_init(void) · 1249 unmodified lines
12501250 /* attach to scsi transport */
12511251 fcoe_nport_scsi_transport =
12521252 fc_attach_transport(&fcoe_nport_fc_functions);
1253+ if (!fcoe_nport_scsi_transport)
1254+ goto err;
1255+
12531256 fcoe_vport_scsi_transport =
12541257 fc_attach_transport(&fcoe_vport_fc_functions);
1255−
1256− if (!fcoe_nport_scsi_transport) {
1257− printk(KERN_ERR "fcoe: Failed to attach to the FC transport\n");
1258− return -ENODEV;
1259− }
1258+ if (!fcoe_vport_scsi_transport)
1259+ goto err_vport;
12601260
12611261 return 0;
1262+
1263+err_vport:
1264+ fc_release_transport(fcoe_nport_scsi_transport);
1265+err:
1266+ printk(KERN_ERR "fcoe: Failed to attach to the FC transport\n");
1267+ return -ENODEV;
12621268 }
12631269
12641270 /**
@@ -1617,7 +1623,6 @@ static inline int fcoe_filter_frames(struct fc_lport *lport, · 352 unmodified lines
16171623 else
16181624 fr_flags(fp) |= FCPHF_CRC_UNCHECKED;
16191625
1620− fh = (struct fc_frame_header *) skb_transport_header(skb);
16211626 fh = fc_frame_header_get(fp);
16221627 if (fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA && fh->fh_type == FC_TYPE_FCP)
16231628 return 0;
drivers/scsi/fdomain.c+3−3
@@ -166,7 +166,7 @@ static int fdomain_test_loopback(int base) · 165 unmodified lines
166166
167167 static void fdomain_reset(int base)
168168 {
169− outb(1, base + REG_BCTL);
169+ outb(BCTL_RST, base + REG_BCTL);
170170 mdelay(20);
171171 outb(0, base + REG_BCTL);
172172 mdelay(1150);
@@ -306,7 +306,7 @@ static void fdomain_work(struct work_struct *work) · 133 unmodified lines
306306 status = inb(fd->base + REG_BSTAT);
307307
308308 if (status & BSTAT_REQ) {
309− switch (status & 0x0e) {
309+ switch (status & (BSTAT_MSG | BSTAT_CMD | BSTAT_IO)) {
310310 case BSTAT_CMD: /* COMMAND OUT */
311311 outb(cmd->cmnd[cmd->SCp.sent_command++],
312312 fd->base + REG_SCSI_DATA);
@@ -331,7 +331,7 @@ static void fdomain_work(struct work_struct *work) · 18 unmodified lines
331331 case BSTAT_MSG | BSTAT_CMD: /* MESSAGE OUT */
332332 outb(MESSAGE_REJECT, fd->base + REG_SCSI_DATA);
333333 break;
334− case BSTAT_MSG | BSTAT_IO | BSTAT_CMD: /* MESSAGE IN */
334+ case BSTAT_MSG | BSTAT_CMD | BSTAT_IO: /* MESSAGE IN */
335335 cmd->SCp.Message = inb(fd->base + REG_SCSI_DATA);
336336 if (!cmd->SCp.Message)
337337 ++done;
drivers/scsi/fdomain_isa.c+2−3
@@ -131,8 +131,7 @@ static int fdomain_isa_match(struct device *dev, unsigned int ndev) · 130 unmodified lines
131131 if (!request_region(base, FDOMAIN_REGION_SIZE, "fdomain_isa"))
132132 return 0;
133133
134− irq = irqs[(inb(base + REG_CFG1) & 0x0e) >> 1];
135−
134+ irq = irqs[(inb(base + REG_CFG1) & CFG1_IRQ_MASK) >> 1];
136135
137136 if (sig)
138137 this_id = sig->this_id;
@@ -164,7 +163,7 @@ static int fdomain_isa_param_match(struct device *dev, unsigned int ndev) · 25 unmodified lines
164163 }
165164
166165 if (irq_ <= 0)
167− irq_ = irqs[(inb(io[ndev] + REG_CFG1) & 0x0e) >> 1];
166+ irq_ = irqs[(inb(io[ndev] + REG_CFG1) & CFG1_IRQ_MASK) >> 1];
168167
169168 sh = fdomain_create(io[ndev], irq_, scsi_id[ndev], dev);
170169 if (!sh) {
drivers/scsi/fnic/fnic_debugfs.c+1−3
@@ -52,7 +52,6 @@ static struct fc_trace_flag_type *fc_trc_flag; · 51 unmodified lines
5252 */
5353 int fnic_debugfs_init(void)
5454 {
55− int rc = -1;
5655 fnic_trace_debugfs_root = debugfs_create_dir("fnic", NULL);
5756
5857 fnic_stats_debugfs_root = debugfs_create_dir("statistics",
@@ -70,8 +69,7 @@ int fnic_debugfs_init(void) · 11 unmodified lines
7069 fc_trc_flag->fc_clear = 4;
7170 }
7271
73− rc = 0;
74− return rc;
72+ return 0;
7573 }
7674
7775 /*
drivers/scsi/fnic/fnic_fcs.c+10−4
@@ -52,6 +52,7 @@ void fnic_handle_link(struct work_struct *work) · 51 unmodified lines
5252 unsigned long flags;
5353 int old_link_status;
5454 u32 old_link_down_cnt;
55+ u64 old_port_speed, new_port_speed;
5556
5657 spin_lock_irqsave(&fnic->fnic_lock, flags);
5758
@@ -62,14 +63,19 @@ void fnic_handle_link(struct work_struct *work) · 4 unmodified lines
6263
6364 old_link_down_cnt = fnic->link_down_cnt;
6465 old_link_status = fnic->link_status;
66+ old_port_speed = atomic64_read(
67+ &fnic->fnic_stats.misc_stats.current_port_speed);
68+
6569 fnic->link_status = vnic_dev_link_status(fnic->vdev);
6670 fnic->link_down_cnt = vnic_dev_link_down_cnt(fnic->vdev);
6771
72+ new_port_speed = vnic_dev_port_speed(fnic->vdev);
6873 atomic64_set(&fnic->fnic_stats.misc_stats.current_port_speed,
69− vnic_dev_port_speed(fnic->vdev));
70− shost_printk(KERN_INFO, fnic->lport->host, "Current vnic speed set to : %llu\n",
71− (u64)atomic64_read(
72− &fnic->fnic_stats.misc_stats.current_port_speed));
74+ new_port_speed);
75+ if (old_port_speed != new_port_speed)
76+ shost_printk(KERN_INFO, fnic->lport->host,
77+ "Current vnic speed set to : %llu\n",
78+ new_port_speed);
7379
7480 switch (vnic_dev_port_speed(fnic->vdev)) {
7581 case DCEM_PORTSPEED_10G:
drivers/scsi/fnic/fnic_isr.c+2−2
@@ -254,7 +254,7 @@ int fnic_set_intr_mode(struct fnic *fnic) · 253 unmodified lines
254254 int vecs = n + m + o + 1;
255255
256256 if (pci_alloc_irq_vectors(fnic->pdev, vecs, vecs,
257− PCI_IRQ_MSIX) < 0) {
257+ PCI_IRQ_MSIX) == vecs) {
258258 fnic->rq_count = n;
259259 fnic->raw_wq_count = m;
260260 fnic->wq_copy_count = o;
@@ -280,7 +280,7 @@ int fnic_set_intr_mode(struct fnic *fnic) · 19 unmodified lines
280280 fnic->wq_copy_count >= 1 &&
281281 fnic->cq_count >= 3 &&
282282 fnic->intr_count >= 1 &&
283− pci_alloc_irq_vectors(fnic->pdev, 1, 1, PCI_IRQ_MSI) < 0) {
283+ pci_alloc_irq_vectors(fnic->pdev, 1, 1, PCI_IRQ_MSI) == 1) {
284284 fnic->rq_count = 1;
285285 fnic->raw_wq_count = 1;
286286 fnic->wq_copy_count = 1;
drivers/scsi/fnic/fnic_trace.c+1−1
@@ -453,7 +453,7 @@ int fnic_get_stats_data(struct stats_debug_info *debug, · 452 unmodified lines
453453 (u64)atomic64_read(&stats->misc_stats.frame_errors));
454454
455455 len += snprintf(debug->debug_buffer + len, buf_size - len,
456− "Firmware reported port seed: %llu\n",
456+ "Firmware reported port speed: %llu\n",
457457 (u64)atomic64_read(
458458 &stats->misc_stats.current_port_speed));
459459
drivers/scsi/hisi_sas/hisi_sas.h+43−11
@@ -31,7 +31,13 @@ · 30 unmodified lines
3131 #define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES
3232 #define HISI_SAS_RESET_BIT 0
3333 #define HISI_SAS_REJECT_CMD_BIT 1
34−#define HISI_SAS_RESERVED_IPTT_CNT 96
34+#define HISI_SAS_MAX_COMMANDS (HISI_SAS_QUEUE_SLOTS)
35+#define HISI_SAS_RESERVED_IPTT 96
36+#define HISI_SAS_UNRESERVED_IPTT \
37+ (HISI_SAS_MAX_COMMANDS - HISI_SAS_RESERVED_IPTT)
38+
39+#define HISI_SAS_IOST_ITCT_CACHE_NUM 64
40+#define HISI_SAS_IOST_ITCT_CACHE_DW_SZ 10
3541
3642 #define HISI_SAS_STATUS_BUF_SZ (sizeof(struct hisi_sas_status_buffer))
3743 #define HISI_SAS_COMMAND_TABLE_SZ (sizeof(union hisi_sas_command_table))
@@ -128,7 +134,6 @@ struct hisi_sas_rst { · 90 unmodified lines
128134
129135 #define HISI_SAS_DECLARE_RST_WORK_ON_STACK(r) \
130136 DECLARE_COMPLETION_ONSTACK(c); \
131− DECLARE_WORK(w, hisi_sas_sync_rst_work_handler); \
132137 struct hisi_sas_rst r = HISI_SAS_RST_WORK_INIT(r, c)
133138
134139 enum hisi_sas_bit_err_type {
@@ -249,6 +254,22 @@ struct hisi_sas_debugfs_reg { · 114 unmodified lines
249254 };
250255 };
251256
257+struct hisi_sas_iost_itct_cache {
258+ u32 data[HISI_SAS_IOST_ITCT_CACHE_DW_SZ];
259+};
260+
261+enum hisi_sas_debugfs_reg_array_member {
262+ DEBUGFS_GLOBAL = 0,
263+ DEBUGFS_AXI,
264+ DEBUGFS_RAS,
265+ DEBUGFS_REGS_NUM
266+};
267+
268+enum hisi_sas_debugfs_cache_type {
269+ HISI_SAS_ITCT_CACHE,
270+ HISI_SAS_IOST_CACHE,
271+};
272+
252273 struct hisi_sas_hw {
253274 int (*hw_init)(struct hisi_hba *hisi_hba);
254275 void (*setup_itct)(struct hisi_hba *hisi_hba,
@@ -257,7 +278,6 @@ struct hisi_sas_hw { · 2 unmodified lines
257278 struct domain_device *device);
258279 struct hisi_sas_device *(*alloc_dev)(struct domain_device *device);
259280 void (*sl_notify_ssp)(struct hisi_hba *hisi_hba, int phy_no);
260− int (*get_free_slot)(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq);
261281 void (*start_delivery)(struct hisi_sas_dq *dq);
262282 void (*prep_ssp)(struct hisi_hba *hisi_hba,
263283 struct hisi_sas_slot *slot);
@@ -268,8 +288,6 @@ struct hisi_sas_hw { · 4 unmodified lines
268288 void (*prep_abort)(struct hisi_hba *hisi_hba,
269289 struct hisi_sas_slot *slot,
270290 int device_id, int abort_flag, int tag_to_abort);
271− int (*slot_complete)(struct hisi_hba *hisi_hba,
272− struct hisi_sas_slot *slot);
273291 void (*phys_init)(struct hisi_hba *hisi_hba);
274292 void (*phy_start)(struct hisi_hba *hisi_hba, int phy_no);
275293 void (*phy_disable)(struct hisi_hba *hisi_hba, int phy_no);
@@ -288,15 +306,18 @@ struct hisi_sas_hw { · 12 unmodified lines
288306 u32 (*get_phys_state)(struct hisi_hba *hisi_hba);
289307 int (*write_gpio)(struct hisi_hba *hisi_hba, u8 reg_type,
290308 u8 reg_index, u8 reg_count, u8 *write_data);
291− int (*wait_cmds_complete_timeout)(struct hisi_hba *hisi_hba,
292− int delay_ms, int timeout_ms);
309+ void (*wait_cmds_complete_timeout)(struct hisi_hba *hisi_hba,
310+ int delay_ms, int timeout_ms);
293311 void (*snapshot_prepare)(struct hisi_hba *hisi_hba);
294312 void (*snapshot_restore)(struct hisi_hba *hisi_hba);
295− int max_command_entries;
313+ int (*set_bist)(struct hisi_hba *hisi_hba, bool enable);
314+ void (*read_iost_itct_cache)(struct hisi_hba *hisi_hba,
315+ enum hisi_sas_debugfs_cache_type type,
316+ u32 *cache);
296317 int complete_hdr_size;
297318 struct scsi_host_template *sht;
298319
299− const struct hisi_sas_debugfs_reg *debugfs_reg_global;
320+ const struct hisi_sas_debugfs_reg *debugfs_reg_array[DEBUGFS_REGS_NUM];
300321 const struct hisi_sas_debugfs_reg *debugfs_reg_port;
301322 };
302323
@@ -371,16 +392,28 @@ struct hisi_hba { · 68 unmodified lines
371392 int cq_nvecs;
372393 unsigned int *reply_map;
373394
395+ /* bist */
396+ enum sas_linkrate debugfs_bist_linkrate;
397+ int debugfs_bist_code_mode;
398+ int debugfs_bist_phy_no;
399+ int debugfs_bist_mode;
400+ u32 debugfs_bist_cnt;
401+ int debugfs_bist_enable;
402+
374403 /* debugfs memories */
375− u32 *debugfs_global_reg;
404+ /* Put Global AXI and RAS Register into register array */
405+ u32 *debugfs_regs[DEBUGFS_REGS_NUM];
376406 u32 *debugfs_port_reg[HISI_SAS_MAX_PHYS];
377407 void *debugfs_complete_hdr[HISI_SAS_MAX_QUEUES];
378408 struct hisi_sas_cmd_hdr *debugfs_cmd_hdr[HISI_SAS_MAX_QUEUES];
379409 struct hisi_sas_iost *debugfs_iost;
380410 struct hisi_sas_itct *debugfs_itct;
411+ u64 *debugfs_iost_cache;
412+ u64 *debugfs_itct_cache;
381413
382414 struct dentry *debugfs_dir;
383415 struct dentry *debugfs_dump_dentry;
416+ struct dentry *debugfs_bist_dentry;
384417 bool debugfs_snapshot;
385418 };
386419
@@ -533,7 +566,6 @@ extern u8 hisi_sas_get_ata_protocol(struct host_to_dev_fis *fis, · 146 unmodified lines
533566 extern struct hisi_sas_port *to_hisi_sas_port(struct asd_sas_port *sas_port);
534567 extern void hisi_sas_sata_done(struct sas_task *task,
535568 struct hisi_sas_slot *slot);
536−extern int hisi_sas_get_ncq_tag(struct sas_task *task, u32 *tag);
537569 extern int hisi_sas_get_fw_info(struct hisi_hba *hisi_hba);
538570 extern int hisi_sas_probe(struct platform_device *pdev,
539571 const struct hisi_sas_hw *ops);
drivers/scsi/hisi_sas/hisi_sas_main.c+783−199
@@ -118,21 +118,6 @@ void hisi_sas_sata_done(struct sas_task *task, · 117 unmodified lines
118118 }
119119 EXPORT_SYMBOL_GPL(hisi_sas_sata_done);
120120
121−int hisi_sas_get_ncq_tag(struct sas_task *task, u32 *tag)
122−{
123− struct ata_queued_cmd *qc = task->uldd_task;
124−
125− if (qc) {
126− if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
127− qc->tf.command == ATA_CMD_FPDMA_READ) {
128− *tag = qc->tag;
129− return 1;
130− }
131− }
132− return 0;
133−}
134−EXPORT_SYMBOL_GPL(hisi_sas_get_ncq_tag);
135−
136121 /*
137122 * This function assumes linkrate mask fits in 8 bits, which it
138123 * does for all HW versions supported.
@@ -180,8 +165,8 @@ static void hisi_sas_slot_index_free(struct hisi_hba *hisi_hba, int slot_idx) · 41 unmodified lines
180165 {
181166 unsigned long flags;
182167
183− if (hisi_hba->hw->slot_index_alloc || (slot_idx >=
184− hisi_hba->hw->max_command_entries - HISI_SAS_RESERVED_IPTT_CNT)) {
168+ if (hisi_hba->hw->slot_index_alloc ||
169+ slot_idx >= HISI_SAS_UNRESERVED_IPTT) {
185170 spin_lock_irqsave(&hisi_hba->lock, flags);
186171 hisi_sas_slot_index_clear(hisi_hba, slot_idx);
187172 spin_unlock_irqrestore(&hisi_hba->lock, flags);
@@ -211,8 +196,7 @@ static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba, · 23 unmodified lines
211196 if (index >= hisi_hba->slot_index_count) {
212197 index = find_next_zero_bit(bitmap,
213198 hisi_hba->slot_index_count,
214− hisi_hba->hw->max_command_entries -
215− HISI_SAS_RESERVED_IPTT_CNT);
199+ HISI_SAS_UNRESERVED_IPTT);
216200 if (index >= hisi_hba->slot_index_count) {
217201 spin_unlock_irqrestore(&hisi_hba->lock, flags);
218202 return -SAS_QUEUE_FULL;
@@ -301,7 +285,7 @@ static void hisi_sas_task_prep_abort(struct hisi_hba *hisi_hba, · 82 unmodified lines
301285
302286 static void hisi_sas_dma_unmap(struct hisi_hba *hisi_hba,
303287 struct sas_task *task, int n_elem,
304− int n_elem_req, int n_elem_resp)
288+ int n_elem_req)
305289 {
306290 struct device *dev = hisi_hba->dev;
307291
@@ -315,16 +299,13 @@ static void hisi_sas_dma_unmap(struct hisi_hba *hisi_hba, · 7 unmodified lines
315299 if (n_elem_req)
316300 dma_unmap_sg(dev, &task->smp_task.smp_req,
317301 1, DMA_TO_DEVICE);
318− if (n_elem_resp)
319− dma_unmap_sg(dev, &task->smp_task.smp_resp,
320− 1, DMA_FROM_DEVICE);
321302 }
322303 }
323304 }
324305
325306 static int hisi_sas_dma_map(struct hisi_hba *hisi_hba,
326307 struct sas_task *task, int *n_elem,
327− int *n_elem_req, int *n_elem_resp)
308+ int *n_elem_req)
328309 {
329310 struct device *dev = hisi_hba->dev;
330311 int rc;
@@ -332,7 +313,7 @@ static int hisi_sas_dma_map(struct hisi_hba *hisi_hba, · 1 unmodified line
332313 if (sas_protocol_ata(task->task_proto)) {
333314 *n_elem = task->num_scatter;
334315 } else {
335− unsigned int req_len, resp_len;
316+ unsigned int req_len;
336317
337318 if (task->num_scatter) {
338319 *n_elem = dma_map_sg(dev, task->scatter,
@@ -353,17 +334,6 @@ static int hisi_sas_dma_map(struct hisi_hba *hisi_hba, · 14 unmodified lines
353334 rc = -EINVAL;
354335 goto err_out_dma_unmap;
355336 }
356− *n_elem_resp = dma_map_sg(dev, &task->smp_task.smp_resp,
357− 1, DMA_FROM_DEVICE);
358− if (!*n_elem_resp) {
359− rc = -ENOMEM;
360− goto err_out_dma_unmap;
361− }
362− resp_len = sg_dma_len(&task->smp_task.smp_resp);
363− if (resp_len & 0x3) {
364− rc = -EINVAL;
365− goto err_out_dma_unmap;
366− }
367337 }
368338 }
369339
@@ -378,7 +348,7 @@ static int hisi_sas_dma_map(struct hisi_hba *hisi_hba, · 8 unmodified lines
378348 err_out_dma_unmap:
379349 /* It would be better to call dma_unmap_sg() here, but it's messy */
380350 hisi_sas_dma_unmap(hisi_hba, task, *n_elem,
381− *n_elem_req, *n_elem_resp);
351+ *n_elem_req);
382352 prep_out:
383353 return rc;
384354 }
@@ -450,7 +420,7 @@ static int hisi_sas_task_prep(struct sas_task *task, · 65 unmodified lines
450420 struct asd_sas_port *sas_port = device->port;
451421 struct device *dev = hisi_hba->dev;
452422 int dlvry_queue_slot, dlvry_queue, rc, slot_idx;
453− int n_elem = 0, n_elem_dif = 0, n_elem_req = 0, n_elem_resp = 0;
423+ int n_elem = 0, n_elem_dif = 0, n_elem_req = 0;
454424 struct hisi_sas_dq *dq;
455425 unsigned long flags;
456426 int wr_q_index;
@@ -486,7 +456,7 @@ static int hisi_sas_task_prep(struct sas_task *task, · 29 unmodified lines
486456 }
487457
488458 rc = hisi_sas_dma_map(hisi_hba, task, &n_elem,
489− &n_elem_req, &n_elem_resp);
459+ &n_elem_req);
490460 if (rc < 0)
491461 goto prep_out;
492462
@@ -520,13 +490,8 @@ static int hisi_sas_task_prep(struct sas_task *task, · 27 unmodified lines
520490 slot = &hisi_hba->slot_info[slot_idx];
521491
522492 spin_lock_irqsave(&dq->lock, flags);
523− wr_q_index = hisi_hba->hw->get_free_slot(hisi_hba, dq);
524− if (wr_q_index < 0) {
525− spin_unlock_irqrestore(&dq->lock, flags);
526− rc = -EAGAIN;
527− goto err_out_tag;
528− }
529−
493+ wr_q_index = dq->wr_point;
494+ dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS;
530495 list_add_tail(&slot->delivery, &dq->list);
531496 spin_unlock_irqrestore(&dq->lock, flags);
532497 spin_lock_irqsave(&sas_dev->lock, flags);
@@ -551,7 +516,8 @@ static int hisi_sas_task_prep(struct sas_task *task, · 18 unmodified lines
551516
552517 memset(slot->cmd_hdr, 0, sizeof(struct hisi_sas_cmd_hdr));
553518 memset(hisi_sas_cmd_hdr_addr_mem(slot), 0, HISI_SAS_COMMAND_TABLE_SZ);
554− memset(hisi_sas_status_buf_addr_mem(slot), 0, HISI_SAS_STATUS_BUF_SZ);
519+ memset(hisi_sas_status_buf_addr_mem(slot), 0,
520+ sizeof(struct hisi_sas_err_record));
555521
556522 switch (task->task_proto) {
557523 case SAS_PROTOCOL_SMP:
@@ -580,14 +546,12 @@ static int hisi_sas_task_prep(struct sas_task *task, · 22 unmodified lines
580546
581547 return 0;
582548
583−err_out_tag:
584− hisi_sas_slot_index_free(hisi_hba, slot_idx);
585549 err_out_dif_dma_unmap:
586550 if (!sas_protocol_ata(task->task_proto))
587551 hisi_sas_dif_dma_unmap(hisi_hba, task, n_elem_dif);
588552 err_out_dma_unmap:
589553 hisi_sas_dma_unmap(hisi_hba, task, n_elem,
590− n_elem_req, n_elem_resp);
554+ n_elem_req);
591555 prep_out:
592556 dev_err(dev, "task prep: failed[%d]!\n", rc);
593557 return rc;
@@ -719,13 +683,13 @@ static struct hisi_sas_device *hisi_sas_alloc_dev(struct domain_device *device) · 125 unmodified lines
719683 return sas_dev;
720684 }
721685
722−#define HISI_SAS_SRST_ATA_DISK_CNT 3
686+#define HISI_SAS_DISK_RECOVER_CNT 3
723687 static int hisi_sas_init_device(struct domain_device *device)
724688 {
725689 int rc = TMF_RESP_FUNC_COMPLETE;
726690 struct scsi_lun lun;
727691 struct hisi_sas_tmf_task tmf_task;
728− int retry = HISI_SAS_SRST_ATA_DISK_CNT;
692+ int retry = HISI_SAS_DISK_RECOVER_CNT;
729693 struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);
730694 struct device *dev = hisi_hba->dev;
731695 struct sas_phy *local_phy;
@@ -735,10 +699,14 @@ static int hisi_sas_init_device(struct domain_device *device) · 3 unmodified lines
735699 int_to_scsilun(0, &lun);
736700
737701 tmf_task.tmf = TMF_CLEAR_TASK_SET;
738− rc = hisi_sas_debug_issue_ssp_tmf(device, lun.scsi_lun,
739− &tmf_task);
740− if (rc == TMF_RESP_FUNC_COMPLETE)
741− hisi_sas_release_task(hisi_hba, device);
702+ while (retry-- > 0) {
703+ rc = hisi_sas_debug_issue_ssp_tmf(device, lun.scsi_lun,
704+ &tmf_task);
705+ if (rc == TMF_RESP_FUNC_COMPLETE) {
706+ hisi_sas_release_task(hisi_hba, device);
707+ break;
708+ }
709+ }
742710 break;
743711 case SAS_SATA_DEV:
744712 case SAS_SATA_PM:
@@ -1081,21 +1049,22 @@ static void hisi_sas_dev_gone(struct domain_device *device) · 336 unmodified lines
10811049 dev_info(dev, "dev[%d:%x] is gone\n",
10821050 sas_dev->device_id, sas_dev->dev_type);
10831051
1052+ down(&hisi_hba->sem);
10841053 if (!test_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags)) {
10851054 hisi_sas_internal_task_abort(hisi_hba, device,
10861055 HISI_SAS_INT_ABT_DEV, 0);
10871056
10881057 hisi_sas_dereg_device(hisi_hba, device);
10891058
1090− down(&hisi_hba->sem);
10911059 hisi_hba->hw->clear_itct(hisi_hba, sas_dev);
1092− up(&hisi_hba->sem);
10931060 device->lldd_dev = NULL;
10941061 }
10951062
10961063 if (hisi_hba->hw->free_device)
10971064 hisi_hba->hw->free_device(sas_dev);
10981065 sas_dev->dev_type = SAS_PHY_UNUSED;
1066+ sas_dev->sas_device = NULL;
1067+ up(&hisi_hba->sem);
10991068 }
11001069
11011070 static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)
@@ -1423,8 +1392,7 @@ static void hisi_sas_refresh_port_id(struct hisi_hba *hisi_hba) · 321 unmodified lines
14231392 }
14241393 }
14251394
1426−static void hisi_sas_rescan_topology(struct hisi_hba *hisi_hba, u32 old_state,
1427− u32 state)
1395+static void hisi_sas_rescan_topology(struct hisi_hba *hisi_hba, u32 state)
14281396 {
14291397 struct sas_ha_struct *sas_ha = &hisi_hba->sha;
14301398 struct asd_sas_port *_sas_port = NULL;
@@ -1576,16 +1544,16 @@ void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba) · 145 unmodified lines
15761544 msleep(1000);
15771545 hisi_sas_refresh_port_id(hisi_hba);
15781546 clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
1579− up(&hisi_hba->sem);
15801547
15811548 if (hisi_hba->reject_stp_links_msk)
15821549 hisi_sas_terminate_stp_reject(hisi_hba);
15831550 hisi_sas_reset_init_all_devices(hisi_hba);
1551+ up(&hisi_hba->sem);
15841552 scsi_unblock_requests(shost);
15851553 clear_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags);
15861554
15871555 state = hisi_hba->hw->get_phys_state(hisi_hba);
1588− hisi_sas_rescan_topology(hisi_hba, hisi_hba->phy_state, state);
1556+ hisi_sas_rescan_topology(hisi_hba, state);
15891557 }
15901558 EXPORT_SYMBOL_GPL(hisi_sas_controller_reset_done);
15911559
@@ -1770,24 +1738,34 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device) · 178 unmodified lines
17701738 struct hisi_sas_device *sas_dev = device->lldd_dev;
17711739 struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);
17721740 struct sas_ha_struct *sas_ha = &hisi_hba->sha;
1773− struct asd_sas_phy *sas_phy = sas_ha->sas_phy[local_phy->number];
1774− struct hisi_sas_phy *phy = container_of(sas_phy,
1775− struct hisi_sas_phy, sas_phy);
17761741 DECLARE_COMPLETION_ONSTACK(phyreset);
17771742 int rc, reset_type;
17781743
1744+ if (!local_phy->enabled) {
1745+ sas_put_local_phy(local_phy);
1746+ return -ENODEV;
1747+ }
1748+
17791749 if (scsi_is_sas_phy_local(local_phy)) {
1750+ struct asd_sas_phy *sas_phy =
1751+ sas_ha->sas_phy[local_phy->number];
1752+ struct hisi_sas_phy *phy =
1753+ container_of(sas_phy, struct hisi_sas_phy, sas_phy);
17801754 phy->in_reset = 1;
17811755 phy->reset_completion = &phyreset;
17821756 }
17831757
17841758 reset_type = (sas_dev->dev_status == HISI_SAS_DEV_INIT ||
1785− !dev_is_sata(device)) ? 1 : 0;
1759+ !dev_is_sata(device)) ? true : false;
17861760
17871761 rc = sas_phy_reset(local_phy, reset_type);
17881762 sas_put_local_phy(local_phy);
17891763
17901764 if (scsi_is_sas_phy_local(local_phy)) {
1765+ struct asd_sas_phy *sas_phy =
1766+ sas_ha->sas_phy[local_phy->number];
1767+ struct hisi_sas_phy *phy =
1768+ container_of(sas_phy, struct hisi_sas_phy, sas_phy);
17911769 int ret = wait_for_completion_timeout(&phyreset, 2 * HZ);
17921770 unsigned long flags;
17931771
@@ -1802,9 +1780,10 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device) · 8 unmodified lines
18021780 } else if (sas_dev->dev_status != HISI_SAS_DEV_INIT) {
18031781 /*
18041782 * If in init state, we rely on caller to wait for link to be
1805− * ready; otherwise, delay.
1783+ * ready; otherwise, except phy reset is fail, delay.
18061784 */
1807− msleep(2000);
1785+ if (!rc)
1786+ msleep(2000);
18081787 }
18091788
18101789 return rc;
@@ -1845,21 +1824,21 @@ static int hisi_sas_lu_reset(struct domain_device *device, u8 *lun) · 34 unmodified lines
18451824 struct device *dev = hisi_hba->dev;
18461825 int rc = TMF_RESP_FUNC_FAILED;
18471826
1827+ /* Clear internal IO and then lu reset */
1828+ rc = hisi_sas_internal_task_abort(hisi_hba, device,
1829+ HISI_SAS_INT_ABT_DEV, 0);
1830+ if (rc < 0) {
1831+ dev_err(dev, "lu_reset: internal abort failed\n");
1832+ goto out;
1833+ }
1834+ hisi_sas_dereg_device(hisi_hba, device);
1835+
18481836 if (dev_is_sata(device)) {
18491837 struct sas_phy *phy;
18501838
1851− /* Clear internal IO and then hardreset */
1852− rc = hisi_sas_internal_task_abort(hisi_hba, device,
1853− HISI_SAS_INT_ABT_DEV, 0);
1854− if (rc < 0) {
1855− dev_err(dev, "lu_reset: internal abort failed\n");
1856− goto out;
1857− }
1858− hisi_sas_dereg_device(hisi_hba, device);
1859−
18601839 phy = sas_get_local_phy(device);
18611840
1862− rc = sas_phy_reset(phy, 1);
1841+ rc = sas_phy_reset(phy, true);
18631842
18641843 if (rc == 0)
18651844 hisi_sas_release_task(hisi_hba, device);
@@ -1867,14 +1846,6 @@ static int hisi_sas_lu_reset(struct domain_device *device, u8 *lun) · 1 unmodified line
18671846 } else {
18681847 struct hisi_sas_tmf_task tmf_task = { .tmf = TMF_LU_RESET };
18691848
1870− rc = hisi_sas_internal_task_abort(hisi_hba, device,
1871− HISI_SAS_INT_ABT_DEV, 0);
1872− if (rc < 0) {
1873− dev_err(dev, "lu_reset: internal abort failed\n");
1874− goto out;
1875− }
1876− hisi_sas_dereg_device(hisi_hba, device);
1877−
18781849 rc = hisi_sas_debug_issue_ssp_tmf(device, lun, &tmf_task);
18791850 if (rc == TMF_RESP_FUNC_COMPLETE)
18801851 hisi_sas_release_task(hisi_hba, device);
@@ -1964,7 +1935,7 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id, · 83 unmodified lines
19641935 struct asd_sas_port *sas_port = device->port;
19651936 struct hisi_sas_cmd_hdr *cmd_hdr_base;
19661937 int dlvry_queue_slot, dlvry_queue, n_elem = 0, rc, slot_idx;
1967− unsigned long flags, flags_dq = 0;
1938+ unsigned long flags;
19681939 int wr_q_index;
19691940
19701941 if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags)))
@@ -1983,15 +1954,11 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id, · 12 unmodified lines
19831954 slot_idx = rc;
19841955 slot = &hisi_hba->slot_info[slot_idx];
19851956
1986− spin_lock_irqsave(&dq->lock, flags_dq);
1987− wr_q_index = hisi_hba->hw->get_free_slot(hisi_hba, dq);
1988− if (wr_q_index < 0) {
1989− spin_unlock_irqrestore(&dq->lock, flags_dq);
1990− rc = -EAGAIN;
1991− goto err_out_tag;
1992− }
1957+ spin_lock_irqsave(&dq->lock, flags);
1958+ wr_q_index = dq->wr_point;
1959+ dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS;
19931960 list_add_tail(&slot->delivery, &dq->list);
1994− spin_unlock_irqrestore(&dq->lock, flags_dq);
1961+ spin_unlock_irqrestore(&dq->lock, flags);
19951962 spin_lock_irqsave(&sas_dev->lock, flags);
19961963 list_add_tail(&slot->entry, &sas_dev->list);
19971964 spin_unlock_irqrestore(&sas_dev->lock, flags);
@@ -2012,7 +1979,8 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id, · 14 unmodified lines
20121979
20131980 memset(slot->cmd_hdr, 0, sizeof(struct hisi_sas_cmd_hdr));
20141981 memset(hisi_sas_cmd_hdr_addr_mem(slot), 0, HISI_SAS_COMMAND_TABLE_SZ);
2015− memset(hisi_sas_status_buf_addr_mem(slot), 0, HISI_SAS_STATUS_BUF_SZ);
1982+ memset(hisi_sas_status_buf_addr_mem(slot), 0,
1983+ sizeof(struct hisi_sas_err_record));
20161984
20171985 hisi_sas_task_prep_abort(hisi_hba, slot, device_id,
20181986 abort_flag, task_tag);
@@ -2028,8 +1996,6 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id, · 9 unmodified lines
20281996
20291997 return 0;
20301998
2031−err_out_tag:
2032− hisi_sas_slot_index_free(hisi_hba, slot_idx);
20331999 err_out:
20342000 dev_err(dev, "internal abort task prep: failed[%d]!\n", rc);
20352001
@@ -2089,6 +2055,9 @@ _hisi_sas_internal_task_abort(struct hisi_hba *hisi_hba, · 53 unmodified lines
20892055
20902056 /* Internal abort timed out */
20912057 if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) {
2058+ if (hisi_sas_debugfs_enable && hisi_hba->debugfs_itct)
2059+ queue_work(hisi_hba->wq, &hisi_hba->debugfs_work);
2060+
20922061 if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
20932062 struct hisi_sas_slot *slot = task->lldd_task;
20942063
@@ -2123,7 +2092,7 @@ _hisi_sas_internal_task_abort(struct hisi_hba *hisi_hba, · 28 unmodified lines
21232092 }
21242093
21252094 exit:
2126− dev_dbg(dev, "internal task abort: task to dev %016llx task=%p resp: 0x%x sts 0x%x\n",
2095+ dev_dbg(dev, "internal task abort: task to dev %016llx task=%pK resp: 0x%x sts 0x%x\n",
21272096 SAS_ADDR(device->sas_addr), task,
21282097 task->task_status.resp, /* 0 is complete, -1 is undelivered */
21292098 task->task_status.stat);
@@ -2291,7 +2260,7 @@ static struct sas_domain_function_template hisi_sas_transport_ops = { · 161 unmodified lines
22912260
22922261 void hisi_sas_init_mem(struct hisi_hba *hisi_hba)
22932262 {
2294− int i, s, j, max_command_entries = hisi_hba->hw->max_command_entries;
2263+ int i, s, j, max_command_entries = HISI_SAS_MAX_COMMANDS;
22952264 struct hisi_sas_breakpoint *sata_breakpoint = hisi_hba->sata_breakpoint;
22962265
22972266 for (i = 0; i < hisi_hba->queue_count; i++) {
@@ -2328,7 +2297,7 @@ EXPORT_SYMBOL_GPL(hisi_sas_init_mem); · 30 unmodified lines
23282297 int hisi_sas_alloc(struct hisi_hba *hisi_hba)
23292298 {
23302299 struct device *dev = hisi_hba->dev;
2331− int i, j, s, max_command_entries = hisi_hba->hw->max_command_entries;
2300+ int i, j, s, max_command_entries = HISI_SAS_MAX_COMMANDS;
23322301 int max_command_entries_ru, sz_slot_buf_ru;
23332302 int blk_cnt, slots_per_blk;
23342303
@@ -2379,7 +2348,7 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba) · 44 unmodified lines
23792348
23802349 s = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_itct);
23812350 hisi_hba->itct = dmam_alloc_coherent(dev, s, &hisi_hba->itct_dma,
2382− GFP_KERNEL | __GFP_ZERO);
2351+ GFP_KERNEL);
23832352 if (!hisi_hba->itct)
23842353 goto err_out;
23852354
@@ -2396,7 +2365,7 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba) · 10 unmodified lines
23962365 else
23972366 sz_slot_buf_ru = sizeof(struct hisi_sas_slot_buf_table);
23982367 sz_slot_buf_ru = roundup(sz_slot_buf_ru, 64);
2399− s = lcm(max_command_entries_ru, sz_slot_buf_ru);
2368+ s = max(lcm(max_command_entries_ru, sz_slot_buf_ru), PAGE_SIZE);
24002369 blk_cnt = (max_command_entries_ru * sz_slot_buf_ru) / s;
24012370 slots_per_blk = s / sz_slot_buf_ru;
24022371
@@ -2406,7 +2375,7 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba) · 3 unmodified lines
24062375 void *buf;
24072376
24082377 buf = dmam_alloc_coherent(dev, s, &buf_dma,
2409− GFP_KERNEL | __GFP_ZERO);
2378+ GFP_KERNEL);
24102379 if (!buf)
24112380 goto err_out;
24122381
@@ -2455,11 +2424,9 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba) · 42 unmodified lines
24552424 GFP_KERNEL);
24562425 if (!hisi_hba->sata_breakpoint)
24572426 goto err_out;
2458− hisi_sas_init_mem(hisi_hba);
24592427
24602428 hisi_sas_slot_index_init(hisi_hba);
2461− hisi_hba->last_slot_index = hisi_hba->hw->max_command_entries -
2462− HISI_SAS_RESERVED_IPTT_CNT;
2429+ hisi_hba->last_slot_index = HISI_SAS_UNRESERVED_IPTT;
24632430
24642431 hisi_hba->wq = create_singlethread_workqueue(dev_name(dev));
24652432 if (!hisi_hba->wq) {
@@ -2610,8 +2577,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev, · 144 unmodified lines
26102577 goto err_out;
26112578 }
26122579
2613− res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2614− hisi_hba->regs = devm_ioremap_resource(dev, res);
2580+ hisi_hba->regs = devm_platform_ioremap_resource(pdev, 0);
26152581 if (IS_ERR(hisi_hba->regs))
26162582 goto err_out;
26172583
@@ -2672,13 +2638,11 @@ int hisi_sas_probe(struct platform_device *pdev, · 54 unmodified lines
26722638 shost->max_channel = 1;
26732639 shost->max_cmd_len = 16;
26742640 if (hisi_hba->hw->slot_index_alloc) {
2675− shost->can_queue = hisi_hba->hw->max_command_entries;
2676− shost->cmd_per_lun = hisi_hba->hw->max_command_entries;
2641+ shost->can_queue = HISI_SAS_MAX_COMMANDS;
2642+ shost->cmd_per_lun = HISI_SAS_MAX_COMMANDS;
26772643 } else {
2678− shost->can_queue = hisi_hba->hw->max_command_entries -
2679− HISI_SAS_RESERVED_IPTT_CNT;
2680− shost->cmd_per_lun = hisi_hba->hw->max_command_entries -
2681− HISI_SAS_RESERVED_IPTT_CNT;
2644+ shost->can_queue = HISI_SAS_UNRESERVED_IPTT;
2645+ shost->cmd_per_lun = HISI_SAS_UNRESERVED_IPTT;
26822646 }
26832647
26842648 sha->sas_ha_name = DRV_NAME;
@@ -2769,21 +2733,52 @@ static void hisi_sas_debugfs_snapshot_port_reg(struct hisi_hba *hisi_hba) · 84 unmodified lines
27692733
27702734 static void hisi_sas_debugfs_snapshot_global_reg(struct hisi_hba *hisi_hba)
27712735 {
2772− u32 *databuf = (u32 *)hisi_hba->debugfs_global_reg;
2736+ u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_GLOBAL];
2737+ const struct hisi_sas_hw *hw = hisi_hba->hw;
27732738 const struct hisi_sas_debugfs_reg *global =
2774− hisi_hba->hw->debugfs_reg_global;
2739+ hw->debugfs_reg_array[DEBUGFS_GLOBAL];
27752740 int i;
27762741
27772742 for (i = 0; i < global->count; i++, databuf++)
27782743 *databuf = global->read_global_reg(hisi_hba, 4 * i);
27792744 }
27802745
2746+static void hisi_sas_debugfs_snapshot_axi_reg(struct hisi_hba *hisi_hba)
2747+{
2748+ u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_AXI];
2749+ const struct hisi_sas_hw *hw = hisi_hba->hw;
2750+ const struct hisi_sas_debugfs_reg *axi =
2751+ hw->debugfs_reg_array[DEBUGFS_AXI];
2752+ int i;
2753+
2754+ for (i = 0; i < axi->count; i++, databuf++)
2755+ *databuf = axi->read_global_reg(hisi_hba,
2756+ 4 * i + axi->base_off);
2757+}
2758+
2759+static void hisi_sas_debugfs_snapshot_ras_reg(struct hisi_hba *hisi_hba)
2760+{
2761+ u32 *databuf = hisi_hba->debugfs_regs[DEBUGFS_RAS];
2762+ const struct hisi_sas_hw *hw = hisi_hba->hw;
2763+ const struct hisi_sas_debugfs_reg *ras =
2764+ hw->debugfs_reg_array[DEBUGFS_RAS];
2765+ int i;
2766+
2767+ for (i = 0; i < ras->count; i++, databuf++)
2768+ *databuf = ras->read_global_reg(hisi_hba,
2769+ 4 * i + ras->base_off);
2770+}
2771+
27812772 static void hisi_sas_debugfs_snapshot_itct_reg(struct hisi_hba *hisi_hba)
27822773 {
2774+ void *cachebuf = hisi_hba->debugfs_itct_cache;
27832775 void *databuf = hisi_hba->debugfs_itct;
27842776 struct hisi_sas_itct *itct;
27852777 int i;
27862778
2779+ hisi_hba->hw->read_iost_itct_cache(hisi_hba, HISI_SAS_ITCT_CACHE,
2780+ cachebuf);
2781+
27872782 itct = hisi_hba->itct;
27882783
27892784 for (i = 0; i < HISI_SAS_MAX_ITCT_ENTRIES; i++, itct++) {
@@ -2794,11 +2789,15 @@ static void hisi_sas_debugfs_snapshot_itct_reg(struct hisi_hba *hisi_hba) · 4 unmodified lines
27942789
27952790 static void hisi_sas_debugfs_snapshot_iost_reg(struct hisi_hba *hisi_hba)
27962791 {
2797− int max_command_entries = hisi_hba->hw->max_command_entries;
2792+ int max_command_entries = HISI_SAS_MAX_COMMANDS;
2793+ void *cachebuf = hisi_hba->debugfs_iost_cache;
27982794 void *databuf = hisi_hba->debugfs_iost;
27992795 struct hisi_sas_iost *iost;
28002796 int i;
28012797
2798+ hisi_hba->hw->read_iost_itct_cache(hisi_hba, HISI_SAS_IOST_CACHE,
2799+ cachebuf);
2800+
28022801 iost = hisi_hba->iost;
28032802
28042803 for (i = 0; i < max_command_entries; i++, iost++) {
@@ -2845,9 +2844,9 @@ static int hisi_sas_debugfs_global_show(struct seq_file *s, void *p) · 40 unmodified lines
28452844 {
28462845 struct hisi_hba *hisi_hba = s->private;
28472846 const struct hisi_sas_hw *hw = hisi_hba->hw;
2848− const struct hisi_sas_debugfs_reg *reg_global = hw->debugfs_reg_global;
2847+ const void *reg_global = hw->debugfs_reg_array[DEBUGFS_GLOBAL];
28492848
2850− hisi_sas_debugfs_print_reg(hisi_hba->debugfs_global_reg,
2849+ hisi_sas_debugfs_print_reg(hisi_hba->debugfs_regs[DEBUGFS_GLOBAL],
28512850 reg_global, s);
28522851
28532852 return 0;
@@ -2867,6 +2866,58 @@ static const struct file_operations hisi_sas_debugfs_global_fops = { · 13 unmodified lines
28672866 .owner = THIS_MODULE,
28682867 };
28692868
2869+static int hisi_sas_debugfs_axi_show(struct seq_file *s, void *p)
2870+{
2871+ struct hisi_hba *hisi_hba = s->private;
2872+ const struct hisi_sas_hw *hw = hisi_hba->hw;
2873+ const void *reg_axi = hw->debugfs_reg_array[DEBUGFS_AXI];
2874+
2875+ hisi_sas_debugfs_print_reg(hisi_hba->debugfs_regs[DEBUGFS_AXI],
2876+ reg_axi, s);
2877+
2878+ return 0;
2879+}
2880+
2881+static int hisi_sas_debugfs_axi_open(struct inode *inode, struct file *filp)
2882+{
2883+ return single_open(filp, hisi_sas_debugfs_axi_show,
2884+ inode->i_private);
2885+}
2886+
2887+static const struct file_operations hisi_sas_debugfs_axi_fops = {
2888+ .open = hisi_sas_debugfs_axi_open,
2889+ .read = seq_read,
2890+ .llseek = seq_lseek,
2891+ .release = single_release,
2892+ .owner = THIS_MODULE,
2893+};
2894+
2895+static int hisi_sas_debugfs_ras_show(struct seq_file *s, void *p)
2896+{
2897+ struct hisi_hba *hisi_hba = s->private;
2898+ const struct hisi_sas_hw *hw = hisi_hba->hw;
2899+ const void *reg_ras = hw->debugfs_reg_array[DEBUGFS_RAS];
2900+
2901+ hisi_sas_debugfs_print_reg(hisi_hba->debugfs_regs[DEBUGFS_RAS],
2902+ reg_ras, s);
2903+
2904+ return 0;
2905+}
2906+
2907+static int hisi_sas_debugfs_ras_open(struct inode *inode, struct file *filp)
2908+{
2909+ return single_open(filp, hisi_sas_debugfs_ras_show,
2910+ inode->i_private);
2911+}
2912+
2913+static const struct file_operations hisi_sas_debugfs_ras_fops = {
2914+ .open = hisi_sas_debugfs_ras_open,
2915+ .read = seq_read,
2916+ .llseek = seq_lseek,
2917+ .release = single_release,
2918+ .owner = THIS_MODULE,
2919+};
2920+
28702921 static int hisi_sas_debugfs_port_show(struct seq_file *s, void *p)
28712922 {
28722923 struct hisi_sas_phy *phy = s->private;
@@ -2893,8 +2944,8 @@ static const struct file_operations hisi_sas_debugfs_port_fops = { · 20 unmodified lines
28932944 .owner = THIS_MODULE,
28942945 };
28952946
2896−static int hisi_sas_show_row_64(struct seq_file *s, int index,
2897− int sz, __le64 *ptr)
2947+static void hisi_sas_show_row_64(struct seq_file *s, int index,
2948+ int sz, __le64 *ptr)
28982949 {
28992950 int i;
29002951
@@ -2907,12 +2958,10 @@ static int hisi_sas_show_row_64(struct seq_file *s, int index, · 6 unmodified lines
29072958 }
29082959
29092960 seq_puts(s, "\n");
2910−
2911− return 0;
29122961 }
29132962
2914−static int hisi_sas_show_row_32(struct seq_file *s, int index,
2915− int sz, __le32 *ptr)
2963+static void hisi_sas_show_row_32(struct seq_file *s, int index,
2964+ int sz, __le32 *ptr)
29162965 {
29172966 int i;
29182967
@@ -2924,11 +2973,9 @@ static int hisi_sas_show_row_32(struct seq_file *s, int index, · 5 unmodified lines
29242973 seq_puts(s, "\n\t");
29252974 }
29262975 seq_puts(s, "\n");
2927−
2928− return 0;
29292976 }
29302977
2931−static int hisi_sas_cq_show_slot(struct seq_file *s, int slot, void *cq_ptr)
2978+static void hisi_sas_cq_show_slot(struct seq_file *s, int slot, void *cq_ptr)
29322979 {
29332980 struct hisi_sas_cq *cq = cq_ptr;
29342981 struct hisi_hba *hisi_hba = cq->hisi_hba;
@@ -2936,20 +2983,18 @@ static int hisi_sas_cq_show_slot(struct seq_file *s, int slot, void *cq_ptr) · 1 unmodified line
29362983 __le32 *complete_hdr = complete_queue +
29372984 (hisi_hba->hw->complete_hdr_size * slot);
29382985
2939− return hisi_sas_show_row_32(s, slot,
2940− hisi_hba->hw->complete_hdr_size,
2941− complete_hdr);
2986+ hisi_sas_show_row_32(s, slot,
2987+ hisi_hba->hw->complete_hdr_size,
2988+ complete_hdr);
29422989 }
29432990
29442991 static int hisi_sas_debugfs_cq_show(struct seq_file *s, void *p)
29452992 {
29462993 struct hisi_sas_cq *cq = s->private;
2947− int slot, ret;
2994+ int slot;
29482995
29492996 for (slot = 0; slot < HISI_SAS_QUEUE_SLOTS; slot++) {
2950− ret = hisi_sas_cq_show_slot(s, slot, cq);
2951− if (ret)
2952− return ret;
2997+ hisi_sas_cq_show_slot(s, slot, cq);
29532998 }
29542999 return 0;
29553000 }
@@ -2967,7 +3012,7 @@ static const struct file_operations hisi_sas_debugfs_cq_fops = { · 11 unmodified lines
29673012 .owner = THIS_MODULE,
29683013 };
29693014
2970−static int hisi_sas_dq_show_slot(struct seq_file *s, int slot, void *dq_ptr)
3015+static void hisi_sas_dq_show_slot(struct seq_file *s, int slot, void *dq_ptr)
29713016 {
29723017 struct hisi_sas_dq *dq = dq_ptr;
29733018 struct hisi_hba *hisi_hba = dq->hisi_hba;
@@ -2975,18 +3020,15 @@ static int hisi_sas_dq_show_slot(struct seq_file *s, int slot, void *dq_ptr) · 1 unmodified line
29753020 __le32 *cmd_hdr = cmd_queue +
29763021 sizeof(struct hisi_sas_cmd_hdr) * slot;
29773022
2978− return hisi_sas_show_row_32(s, slot, sizeof(struct hisi_sas_cmd_hdr),
2979− cmd_hdr);
3023+ hisi_sas_show_row_32(s, slot, sizeof(struct hisi_sas_cmd_hdr), cmd_hdr);
29803024 }
29813025
29823026 static int hisi_sas_debugfs_dq_show(struct seq_file *s, void *p)
29833027 {
2984− int slot, ret;
3028+ int slot;
29853029
29863030 for (slot = 0; slot < HISI_SAS_QUEUE_SLOTS; slot++) {
2987− ret = hisi_sas_dq_show_slot(s, slot, s->private);
2988− if (ret)
2989− return ret;
3031+ hisi_sas_dq_show_slot(s, slot, s->private);
29903032 }
29913033 return 0;
29923034 }
@@ -3008,14 +3050,12 @@ static int hisi_sas_debugfs_iost_show(struct seq_file *s, void *p) · 15 unmodified lines
30083050 {
30093051 struct hisi_hba *hisi_hba = s->private;
30103052 struct hisi_sas_iost *debugfs_iost = hisi_hba->debugfs_iost;
3011− int i, ret, max_command_entries = hisi_hba->hw->max_command_entries;
3012− __le64 *iost = &debugfs_iost->qw0;
3053+ int i, max_command_entries = HISI_SAS_MAX_COMMANDS;
30133054
30143055 for (i = 0; i < max_command_entries; i++, debugfs_iost++) {
3015− ret = hisi_sas_show_row_64(s, i, sizeof(*debugfs_iost),
3016− iost);
3017− if (ret)
3018− return ret;
3056+ __le64 *iost = &debugfs_iost->qw0;
3057+
3058+ hisi_sas_show_row_64(s, i, sizeof(*debugfs_iost), iost);
30193059 }
30203060
30213061 return 0;
@@ -3034,18 +3074,56 @@ static const struct file_operations hisi_sas_debugfs_iost_fops = { · 12 unmodified lines
30343074 .owner = THIS_MODULE,
30353075 };
30363076
3077+static int hisi_sas_debugfs_iost_cache_show(struct seq_file *s, void *p)
3078+{
3079+ struct hisi_hba *hisi_hba = s->private;
3080+ struct hisi_sas_iost_itct_cache *iost_cache =
3081+ (struct hisi_sas_iost_itct_cache *)hisi_hba->debugfs_iost_cache;
3082+ u32 cache_size = HISI_SAS_IOST_ITCT_CACHE_DW_SZ * 4;
3083+ int i, tab_idx;
3084+ __le64 *iost;
3085+
3086+ for (i = 0; i < HISI_SAS_IOST_ITCT_CACHE_NUM; i++, iost_cache++) {
3087+ /*
3088+ * Data struct of IOST cache:
3089+ * Data[1]: BIT0~15: Table index
3090+ * Bit16: Valid mask
3091+ * Data[2]~[9]: IOST table
3092+ */
3093+ tab_idx = (iost_cache->data[1] & 0xffff);
3094+ iost = (__le64 *)iost_cache;
3095+
3096+ hisi_sas_show_row_64(s, tab_idx, cache_size, iost);
3097+ }
3098+
3099+ return 0;
3100+}
3101+
3102+static int hisi_sas_debugfs_iost_cache_open(struct inode *inode,
3103+ struct file *filp)
3104+{
3105+ return single_open(filp, hisi_sas_debugfs_iost_cache_show,
3106+ inode->i_private);
3107+}
3108+
3109+static const struct file_operations hisi_sas_debugfs_iost_cache_fops = {
3110+ .open = hisi_sas_debugfs_iost_cache_open,
3111+ .read = seq_read,
3112+ .llseek = seq_lseek,
3113+ .release = single_release,
3114+ .owner = THIS_MODULE,
3115+};
3116+
30373117 static int hisi_sas_debugfs_itct_show(struct seq_file *s, void *p)
30383118 {
3039− int i, ret;
3119+ int i;
30403120 struct hisi_hba *hisi_hba = s->private;
30413121 struct hisi_sas_itct *debugfs_itct = hisi_hba->debugfs_itct;
3042− __le64 *itct = &debugfs_itct->qw0;
30433122
30443123 for (i = 0; i < HISI_SAS_MAX_ITCT_ENTRIES; i++, debugfs_itct++) {
3045− ret = hisi_sas_show_row_64(s, i, sizeof(*debugfs_itct),
3046− itct);
3047− if (ret)
3048− return ret;
3124+ __le64 *itct = &debugfs_itct->qw0;
3125+
3126+ hisi_sas_show_row_64(s, i, sizeof(*debugfs_itct), itct);
30493127 }
30503128
30513129 return 0;
@@ -3064,6 +3142,46 @@ static const struct file_operations hisi_sas_debugfs_itct_fops = { · 12 unmodified lines
30643142 .owner = THIS_MODULE,
30653143 };
30663144
3145+static int hisi_sas_debugfs_itct_cache_show(struct seq_file *s, void *p)
3146+{
3147+ struct hisi_hba *hisi_hba = s->private;
3148+ struct hisi_sas_iost_itct_cache *itct_cache =
3149+ (struct hisi_sas_iost_itct_cache *)hisi_hba->debugfs_itct_cache;
3150+ u32 cache_size = HISI_SAS_IOST_ITCT_CACHE_DW_SZ * 4;
3151+ int i, tab_idx;
3152+ __le64 *itct;
3153+
3154+ for (i = 0; i < HISI_SAS_IOST_ITCT_CACHE_NUM; i++, itct_cache++) {
3155+ /*
3156+ * Data struct of ITCT cache:
3157+ * Data[1]: BIT0~15: Table index
3158+ * Bit16: Valid mask
3159+ * Data[2]~[9]: ITCT table
3160+ */
3161+ tab_idx = itct_cache->data[1] & 0xffff;
3162+ itct = (__le64 *)itct_cache;
3163+
3164+ hisi_sas_show_row_64(s, tab_idx, cache_size, itct);
3165+ }
3166+
3167+ return 0;
3168+}
3169+
3170+static int hisi_sas_debugfs_itct_cache_open(struct inode *inode,
3171+ struct file *filp)
3172+{
3173+ return single_open(filp, hisi_sas_debugfs_itct_cache_show,
3174+ inode->i_private);
3175+}
3176+
3177+static const struct file_operations hisi_sas_debugfs_itct_cache_fops = {
3178+ .open = hisi_sas_debugfs_itct_cache_open,
3179+ .read = seq_read,
3180+ .llseek = seq_lseek,
3181+ .release = single_release,
3182+ .owner = THIS_MODULE,
3183+};
3184+
30673185 static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba)
30683186 {
30693187 struct dentry *dump_dentry;
@@ -3110,9 +3228,21 @@ static void hisi_sas_debugfs_create_files(struct hisi_hba *hisi_hba) · 40 unmodified lines
31103228 debugfs_create_file("iost", 0400, dump_dentry, hisi_hba,
31113229 &hisi_sas_debugfs_iost_fops);
31123230
3231+ debugfs_create_file("iost_cache", 0400, dump_dentry, hisi_hba,
3232+ &hisi_sas_debugfs_iost_cache_fops);
3233+
31133234 debugfs_create_file("itct", 0400, dump_dentry, hisi_hba,
31143235 &hisi_sas_debugfs_itct_fops);
31153236
3237+ debugfs_create_file("itct_cache", 0400, dump_dentry, hisi_hba,
3238+ &hisi_sas_debugfs_itct_cache_fops);
3239+
3240+ debugfs_create_file("axi", 0400, dump_dentry, hisi_hba,
3241+ &hisi_sas_debugfs_axi_fops);
3242+
3243+ debugfs_create_file("ras", 0400, dump_dentry, hisi_hba,
3244+ &hisi_sas_debugfs_ras_fops);
3245+
31163246 return;
31173247 }
31183248
@@ -3122,6 +3252,8 @@ static void hisi_sas_debugfs_snapshot_regs(struct hisi_hba *hisi_hba) · 3 unmodified lines
31223252
31233253 hisi_sas_debugfs_snapshot_global_reg(hisi_hba);
31243254 hisi_sas_debugfs_snapshot_port_reg(hisi_hba);
3255+ hisi_sas_debugfs_snapshot_axi_reg(hisi_hba);
3256+ hisi_sas_debugfs_snapshot_ras_reg(hisi_hba);
31253257 hisi_sas_debugfs_snapshot_cq_reg(hisi_hba);
31263258 hisi_sas_debugfs_snapshot_dq_reg(hisi_hba);
31273259 hisi_sas_debugfs_snapshot_itct_reg(hisi_hba);
@@ -3162,6 +3294,382 @@ static const struct file_operations hisi_sas_debugfs_trigger_dump_fops = { · 34 unmodified lines
31623294 .owner = THIS_MODULE,
31633295 };
31643296
3297+enum {
3298+ HISI_SAS_BIST_LOOPBACK_MODE_DIGITAL = 0,
3299+ HISI_SAS_BIST_LOOPBACK_MODE_SERDES,
3300+ HISI_SAS_BIST_LOOPBACK_MODE_REMOTE,
3301+};
3302+
3303+enum {
3304+ HISI_SAS_BIST_CODE_MODE_PRBS7 = 0,
3305+ HISI_SAS_BIST_CODE_MODE_PRBS23,
3306+ HISI_SAS_BIST_CODE_MODE_PRBS31,
3307+ HISI_SAS_BIST_CODE_MODE_JTPAT,
3308+ HISI_SAS_BIST_CODE_MODE_CJTPAT,
3309+ HISI_SAS_BIST_CODE_MODE_SCRAMBED_0,
3310+ HISI_SAS_BIST_CODE_MODE_TRAIN,
3311+ HISI_SAS_BIST_CODE_MODE_TRAIN_DONE,
3312+ HISI_SAS_BIST_CODE_MODE_HFTP,
3313+ HISI_SAS_BIST_CODE_MODE_MFTP,
3314+ HISI_SAS_BIST_CODE_MODE_LFTP,
3315+ HISI_SAS_BIST_CODE_MODE_FIXED_DATA,
3316+};
3317+
3318+static const struct {
3319+ int value;
3320+ char *name;
3321+} hisi_sas_debugfs_loop_linkrate[] = {
3322+ { SAS_LINK_RATE_1_5_GBPS, "1.5 Gbit" },
3323+ { SAS_LINK_RATE_3_0_GBPS, "3.0 Gbit" },
3324+ { SAS_LINK_RATE_6_0_GBPS, "6.0 Gbit" },
3325+ { SAS_LINK_RATE_12_0_GBPS, "12.0 Gbit" },
3326+};
3327+
3328+static int hisi_sas_debugfs_bist_linkrate_show(struct seq_file *s, void *p)
3329+{
3330+ struct hisi_hba *hisi_hba = s->private;
3331+ int i;
3332+
3333+ for (i = 0; i < ARRAY_SIZE(hisi_sas_debugfs_loop_linkrate); i++) {
3334+ int match = (hisi_hba->debugfs_bist_linkrate ==
3335+ hisi_sas_debugfs_loop_linkrate[i].value);
3336+
3337+ seq_printf(s, "%s%s%s ", match ? "[" : "",
3338+ hisi_sas_debugfs_loop_linkrate[i].name,
3339+ match ? "]" : "");
3340+ }
3341+ seq_puts(s, "\n");
3342+
3343+ return 0;
3344+}
3345+
3346+static ssize_t hisi_sas_debugfs_bist_linkrate_write(struct file *filp,
3347+ const char __user *buf,
3348+ size_t count, loff_t *ppos)
3349+{
3350+ struct seq_file *m = filp->private_data;
3351+ struct hisi_hba *hisi_hba = m->private;
3352+ char kbuf[16] = {}, *pkbuf;
3353+ bool found = false;
3354+ int i;
3355+
3356+ if (hisi_hba->debugfs_bist_enable)
3357+ return -EPERM;
3358+
3359+ if (count >= sizeof(kbuf))
3360+ return -EOVERFLOW;
3361+
3362+ if (copy_from_user(kbuf, buf, count))
3363+ return -EINVAL;
3364+
3365+ pkbuf = strstrip(kbuf);
3366+
3367+ for (i = 0; i < ARRAY_SIZE(hisi_sas_debugfs_loop_linkrate); i++) {
3368+ if (!strncmp(hisi_sas_debugfs_loop_linkrate[i].name,
3369+ pkbuf, 16)) {
3370+ hisi_hba->debugfs_bist_linkrate =
3371+ hisi_sas_debugfs_loop_linkrate[i].value;
3372+ found = true;
3373+ break;
3374+ }
3375+ }
3376+
3377+ if (!found)
3378+ return -EINVAL;
3379+
3380+ return count;
3381+}
3382+
3383+static int hisi_sas_debugfs_bist_linkrate_open(struct inode *inode,
3384+ struct file *filp)
3385+{
3386+ return single_open(filp, hisi_sas_debugfs_bist_linkrate_show,
3387+ inode->i_private);
3388+}
3389+
3390+static const struct file_operations hisi_sas_debugfs_bist_linkrate_ops = {
3391+ .open = hisi_sas_debugfs_bist_linkrate_open,
3392+ .read = seq_read,
3393+ .write = hisi_sas_debugfs_bist_linkrate_write,
3394+ .llseek = seq_lseek,
3395+ .release = single_release,
3396+ .owner = THIS_MODULE,
3397+};
3398+
3399+static const struct {
3400+ int value;
3401+ char *name;
3402+} hisi_sas_debugfs_loop_code_mode[] = {
3403+ { HISI_SAS_BIST_CODE_MODE_PRBS7, "PRBS7" },
3404+ { HISI_SAS_BIST_CODE_MODE_PRBS23, "PRBS23" },
3405+ { HISI_SAS_BIST_CODE_MODE_PRBS31, "PRBS31" },
3406+ { HISI_SAS_BIST_CODE_MODE_JTPAT, "JTPAT" },
3407+ { HISI_SAS_BIST_CODE_MODE_CJTPAT, "CJTPAT" },
3408+ { HISI_SAS_BIST_CODE_MODE_SCRAMBED_0, "SCRAMBED_0" },
3409+ { HISI_SAS_BIST_CODE_MODE_TRAIN, "TRAIN" },
3410+ { HISI_SAS_BIST_CODE_MODE_TRAIN_DONE, "TRAIN_DONE" },
3411+ { HISI_SAS_BIST_CODE_MODE_HFTP, "HFTP" },
3412+ { HISI_SAS_BIST_CODE_MODE_MFTP, "MFTP" },
3413+ { HISI_SAS_BIST_CODE_MODE_LFTP, "LFTP" },
3414+ { HISI_SAS_BIST_CODE_MODE_FIXED_DATA, "FIXED_DATA" },
3415+};
3416+
3417+static int hisi_sas_debugfs_bist_code_mode_show(struct seq_file *s, void *p)
3418+{
3419+ struct hisi_hba *hisi_hba = s->private;
3420+ int i;
3421+
3422+ for (i = 0; i < ARRAY_SIZE(hisi_sas_debugfs_loop_code_mode); i++) {
3423+ int match = (hisi_hba->debugfs_bist_code_mode ==
3424+ hisi_sas_debugfs_loop_code_mode[i].value);
3425+
3426+ seq_printf(s, "%s%s%s ", match ? "[" : "",
3427+ hisi_sas_debugfs_loop_code_mode[i].name,
3428+ match ? "]" : "");
3429+ }
3430+ seq_puts(s, "\n");
3431+
3432+ return 0;
3433+}
3434+
3435+static ssize_t hisi_sas_debugfs_bist_code_mode_write(struct file *filp,
3436+ const char __user *buf,
3437+ size_t count,
3438+ loff_t *ppos)
3439+{
3440+ struct seq_file *m = filp->private_data;
3441+ struct hisi_hba *hisi_hba = m->private;
3442+ char kbuf[16] = {}, *pkbuf;
3443+ bool found = false;
3444+ int i;
3445+
3446+ if (hisi_hba->debugfs_bist_enable)
3447+ return -EPERM;
3448+
3449+ if (count >= sizeof(kbuf))
3450+ return -EINVAL;
3451+
3452+ if (copy_from_user(kbuf, buf, count))
3453+ return -EOVERFLOW;
3454+
3455+ pkbuf = strstrip(kbuf);
3456+
3457+ for (i = 0; i < ARRAY_SIZE(hisi_sas_debugfs_loop_code_mode); i++) {
3458+ if (!strncmp(hisi_sas_debugfs_loop_code_mode[i].name,
3459+ pkbuf, 16)) {
3460+ hisi_hba->debugfs_bist_code_mode =
3461+ hisi_sas_debugfs_loop_code_mode[i].value;
3462+ found = true;
3463+ break;
3464+ }
3465+ }
3466+
3467+ if (!found)
3468+ return -EINVAL;
3469+
3470+ return count;
3471+}
3472+
3473+static int hisi_sas_debugfs_bist_code_mode_open(struct inode *inode,
3474+ struct file *filp)
3475+{
3476+ return single_open(filp, hisi_sas_debugfs_bist_code_mode_show,
3477+ inode->i_private);
3478+}
3479+
3480+static const struct file_operations hisi_sas_debugfs_bist_code_mode_ops = {
3481+ .open = hisi_sas_debugfs_bist_code_mode_open,
3482+ .read = seq_read,
3483+ .write = hisi_sas_debugfs_bist_code_mode_write,
3484+ .llseek = seq_lseek,
3485+ .release = single_release,
3486+ .owner = THIS_MODULE,
3487+};
3488+
3489+static ssize_t hisi_sas_debugfs_bist_phy_write(struct file *filp,
3490+ const char __user *buf,
3491+ size_t count, loff_t *ppos)
3492+{
3493+ struct seq_file *m = filp->private_data;
3494+ struct hisi_hba *hisi_hba = m->private;
3495+ unsigned int phy_no;
3496+ int val;
3497+
3498+ if (hisi_hba->debugfs_bist_enable)
3499+ return -EPERM;
3500+
3501+ val = kstrtouint_from_user(buf, count, 0, &phy_no);
3502+ if (val)
3503+ return val;
3504+
3505+ if (phy_no >= hisi_hba->n_phy)
3506+ return -EINVAL;
3507+
3508+ hisi_hba->debugfs_bist_phy_no = phy_no;
3509+
3510+ return count;
3511+}
3512+
3513+static int hisi_sas_debugfs_bist_phy_show(struct seq_file *s, void *p)
3514+{
3515+ struct hisi_hba *hisi_hba = s->private;
3516+
3517+ seq_printf(s, "%d\n", hisi_hba->debugfs_bist_phy_no);
3518+
3519+ return 0;
3520+}
3521+
3522+static int hisi_sas_debugfs_bist_phy_open(struct inode *inode,
3523+ struct file *filp)
3524+{
3525+ return single_open(filp, hisi_sas_debugfs_bist_phy_show,
3526+ inode->i_private);
3527+}
3528+
3529+static const struct file_operations hisi_sas_debugfs_bist_phy_ops = {
3530+ .open = hisi_sas_debugfs_bist_phy_open,
3531+ .read = seq_read,
3532+ .write = hisi_sas_debugfs_bist_phy_write,
3533+ .llseek = seq_lseek,
3534+ .release = single_release,
3535+ .owner = THIS_MODULE,
3536+};
3537+
3538+static const struct {
3539+ int value;
3540+ char *name;
3541+} hisi_sas_debugfs_loop_modes[] = {
3542+ { HISI_SAS_BIST_LOOPBACK_MODE_DIGITAL, "digial" },
3543+ { HISI_SAS_BIST_LOOPBACK_MODE_SERDES, "serdes" },
3544+ { HISI_SAS_BIST_LOOPBACK_MODE_REMOTE, "remote" },
3545+};
3546+
3547+static int hisi_sas_debugfs_bist_mode_show(struct seq_file *s, void *p)
3548+{
3549+ struct hisi_hba *hisi_hba = s->private;
3550+ int i;
3551+
3552+ for (i = 0; i < ARRAY_SIZE(hisi_sas_debugfs_loop_modes); i++) {
3553+ int match = (hisi_hba->debugfs_bist_mode ==
3554+ hisi_sas_debugfs_loop_modes[i].value);
3555+
3556+ seq_printf(s, "%s%s%s ", match ? "[" : "",
3557+ hisi_sas_debugfs_loop_modes[i].name,
3558+ match ? "]" : "");
3559+ }
3560+ seq_puts(s, "\n");
3561+
3562+ return 0;
3563+}
3564+
3565+static ssize_t hisi_sas_debugfs_bist_mode_write(struct file *filp,
3566+ const char __user *buf,
3567+ size_t count, loff_t *ppos)
3568+{
3569+ struct seq_file *m = filp->private_data;
3570+ struct hisi_hba *hisi_hba = m->private;
3571+ char kbuf[16] = {}, *pkbuf;
3572+ bool found = false;
3573+ int i;
3574+
3575+ if (hisi_hba->debugfs_bist_enable)
3576+ return -EPERM;
3577+
3578+ if (count >= sizeof(kbuf))
3579+ return -EINVAL;
3580+
3581+ if (copy_from_user(kbuf, buf, count))
3582+ return -EOVERFLOW;
3583+
3584+ pkbuf = strstrip(kbuf);
3585+
3586+ for (i = 0; i < ARRAY_SIZE(hisi_sas_debugfs_loop_modes); i++) {
3587+ if (!strncmp(hisi_sas_debugfs_loop_modes[i].name, pkbuf, 16)) {
3588+ hisi_hba->debugfs_bist_mode =
3589+ hisi_sas_debugfs_loop_modes[i].value;
3590+ found = true;
3591+ break;
3592+ }
3593+ }
3594+
3595+ if (!found)
3596+ return -EINVAL;
3597+
3598+ return count;
3599+}
3600+
3601+static int hisi_sas_debugfs_bist_mode_open(struct inode *inode,
3602+ struct file *filp)
3603+{
3604+ return single_open(filp, hisi_sas_debugfs_bist_mode_show,
3605+ inode->i_private);
3606+}
3607+
3608+static const struct file_operations hisi_sas_debugfs_bist_mode_ops = {
3609+ .open = hisi_sas_debugfs_bist_mode_open,
3610+ .read = seq_read,
3611+ .write = hisi_sas_debugfs_bist_mode_write,
3612+ .llseek = seq_lseek,
3613+ .release = single_release,
3614+ .owner = THIS_MODULE,
3615+};
3616+
3617+static ssize_t hisi_sas_debugfs_bist_enable_write(struct file *filp,
3618+ const char __user *buf,
3619+ size_t count, loff_t *ppos)
3620+{
3621+ struct seq_file *m = filp->private_data;
3622+ struct hisi_hba *hisi_hba = m->private;
3623+ unsigned int enable;
3624+ int val;
3625+
3626+ val = kstrtouint_from_user(buf, count, 0, &enable);
3627+ if (val)
3628+ return val;
3629+
3630+ if (enable > 1)
3631+ return -EINVAL;
3632+
3633+ if (enable == hisi_hba->debugfs_bist_enable)
3634+ return count;
3635+
3636+ if (!hisi_hba->hw->set_bist)
3637+ return -EPERM;
3638+
3639+ val = hisi_hba->hw->set_bist(hisi_hba, enable);
3640+ if (val < 0)
3641+ return val;
3642+
3643+ hisi_hba->debugfs_bist_enable = enable;
3644+
3645+ return count;
3646+}
3647+
3648+static int hisi_sas_debugfs_bist_enable_show(struct seq_file *s, void *p)
3649+{
3650+ struct hisi_hba *hisi_hba = s->private;
3651+
3652+ seq_printf(s, "%d\n", hisi_hba->debugfs_bist_enable);
3653+
3654+ return 0;
3655+}
3656+
3657+static int hisi_sas_debugfs_bist_enable_open(struct inode *inode,
3658+ struct file *filp)
3659+{
3660+ return single_open(filp, hisi_sas_debugfs_bist_enable_show,
3661+ inode->i_private);
3662+}
3663+
3664+static const struct file_operations hisi_sas_debugfs_bist_enable_ops = {
3665+ .open = hisi_sas_debugfs_bist_enable_open,
3666+ .read = seq_read,
3667+ .write = hisi_sas_debugfs_bist_enable_write,
3668+ .llseek = seq_lseek,
3669+ .release = single_release,
3670+ .owner = THIS_MODULE,
3671+};
3672+
31653673 void hisi_sas_debugfs_work_handler(struct work_struct *work)
31663674 {
31673675 struct hisi_hba *hisi_hba =
@@ -3175,89 +3683,165 @@ void hisi_sas_debugfs_work_handler(struct work_struct *work) · 7 unmodified lines
31753683 }
31763684 EXPORT_SYMBOL_GPL(hisi_sas_debugfs_work_handler);
31773685
3178−void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba)
3686+void hisi_sas_debugfs_release(struct hisi_hba *hisi_hba)
31793687 {
3180− int max_command_entries = hisi_hba->hw->max_command_entries;
31813688 struct device *dev = hisi_hba->dev;
3182− int p, i, c, d;
3689+ int i;
3690+
3691+ devm_kfree(dev, hisi_hba->debugfs_iost_cache);
3692+ devm_kfree(dev, hisi_hba->debugfs_itct_cache);
3693+ devm_kfree(dev, hisi_hba->debugfs_iost);
3694+
3695+ for (i = 0; i < hisi_hba->queue_count; i++)
3696+ devm_kfree(dev, hisi_hba->debugfs_cmd_hdr[i]);
3697+
3698+ for (i = 0; i < hisi_hba->queue_count; i++)
3699+ devm_kfree(dev, hisi_hba->debugfs_complete_hdr[i]);
3700+
3701+ for (i = 0; i < DEBUGFS_REGS_NUM; i++)
3702+ devm_kfree(dev, hisi_hba->debugfs_regs[i]);
3703+
3704+ for (i = 0; i < hisi_hba->n_phy; i++)
3705+ devm_kfree(dev, hisi_hba->debugfs_port_reg[i]);
3706+}
3707+
3708+int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba)
3709+{
3710+ const struct hisi_sas_hw *hw = hisi_hba->hw;
3711+ struct device *dev = hisi_hba->dev;
3712+ int p, c, d;
31833713 size_t sz;
31843714
3185− hisi_hba->debugfs_dir = debugfs_create_dir(dev_name(dev),
3186− hisi_sas_debugfs_dir);
3187− debugfs_create_file("trigger_dump", 0600,
3188− hisi_hba->debugfs_dir,
3189− hisi_hba,
3190− &hisi_sas_debugfs_trigger_dump_fops);
3715+ hisi_hba->debugfs_dump_dentry =
3716+ debugfs_create_dir("dump", hisi_hba->debugfs_dir);
31913717
3192− /* Alloc buffer for global */
3193− sz = hisi_hba->hw->debugfs_reg_global->count * 4;
3194− hisi_hba->debugfs_global_reg =
3195− devm_kmalloc(dev, sz, GFP_KERNEL);
3718+ sz = hw->debugfs_reg_array[DEBUGFS_GLOBAL]->count * 4;
3719+ hisi_hba->debugfs_regs[DEBUGFS_GLOBAL] =
3720+ devm_kmalloc(dev, sz, GFP_KERNEL);
31963721
3197− if (!hisi_hba->debugfs_global_reg)
3198− goto fail_global;
3722+ if (!hisi_hba->debugfs_regs[DEBUGFS_GLOBAL])
3723+ goto fail;
31993724
3200− /* Alloc buffer for port */
3201− sz = hisi_hba->hw->debugfs_reg_port->count * 4;
3725+ sz = hw->debugfs_reg_port->count * 4;
32023726 for (p = 0; p < hisi_hba->n_phy; p++) {
32033727 hisi_hba->debugfs_port_reg[p] =
32043728 devm_kmalloc(dev, sz, GFP_KERNEL);
32053729
32063730 if (!hisi_hba->debugfs_port_reg[p])
3207− goto fail_port;
3731+ goto fail;
32083732 }
32093733
3210− /* Alloc buffer for cq */
3211− sz = hisi_hba->hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS;
3734+ sz = hw->debugfs_reg_array[DEBUGFS_AXI]->count * 4;
3735+ hisi_hba->debugfs_regs[DEBUGFS_AXI] =
3736+ devm_kmalloc(dev, sz, GFP_KERNEL);
3737+
3738+ if (!hisi_hba->debugfs_regs[DEBUGFS_AXI])
3739+ goto fail;
3740+
3741+ sz = hw->debugfs_reg_array[DEBUGFS_RAS]->count * 4;
3742+ hisi_hba->debugfs_regs[DEBUGFS_RAS] =
3743+ devm_kmalloc(dev, sz, GFP_KERNEL);
3744+
3745+ if (!hisi_hba->debugfs_regs[DEBUGFS_RAS])
3746+ goto fail;
3747+
3748+ sz = hw->complete_hdr_size * HISI_SAS_QUEUE_SLOTS;
32123749 for (c = 0; c < hisi_hba->queue_count; c++) {
32133750 hisi_hba->debugfs_complete_hdr[c] =
32143751 devm_kmalloc(dev, sz, GFP_KERNEL);
32153752
32163753 if (!hisi_hba->debugfs_complete_hdr[c])
3217− goto fail_cq;
3754+ goto fail;
32183755 }
32193756
3220− /* Alloc buffer for dq */
32213757 sz = sizeof(struct hisi_sas_cmd_hdr) * HISI_SAS_QUEUE_SLOTS;
32223758 for (d = 0; d < hisi_hba->queue_count; d++) {
32233759 hisi_hba->debugfs_cmd_hdr[d] =
32243760 devm_kmalloc(dev, sz, GFP_KERNEL);
32253761
32263762 if (!hisi_hba->debugfs_cmd_hdr[d])
3227− goto fail_iost_dq;
3763+ goto fail;
32283764 }
32293765
3230− /* Alloc buffer for iost */
3231− sz = max_command_entries * sizeof(struct hisi_sas_iost);
3766+ sz = HISI_SAS_MAX_COMMANDS * sizeof(struct hisi_sas_iost);
32323767
32333768 hisi_hba->debugfs_iost = devm_kmalloc(dev, sz, GFP_KERNEL);
32343769 if (!hisi_hba->debugfs_iost)
3235− goto fail_iost_dq;
3770+ goto fail;
3771+
3772+ sz = HISI_SAS_IOST_ITCT_CACHE_NUM *
3773+ sizeof(struct hisi_sas_iost_itct_cache);
3774+
3775+ hisi_hba->debugfs_iost_cache = devm_kmalloc(dev, sz, GFP_KERNEL);
3776+ if (!hisi_hba->debugfs_iost_cache)
3777+ goto fail;
3778+
3779+ sz = HISI_SAS_IOST_ITCT_CACHE_NUM *
3780+ sizeof(struct hisi_sas_iost_itct_cache);
3781+
3782+ hisi_hba->debugfs_itct_cache = devm_kmalloc(dev, sz, GFP_KERNEL);
3783+ if (!hisi_hba->debugfs_itct_cache)
3784+ goto fail;
32363785
3237− /* Alloc buffer for itct */
32383786 /* New memory allocation must be locate before itct */
32393787 sz = HISI_SAS_MAX_ITCT_ENTRIES * sizeof(struct hisi_sas_itct);
32403788
32413789 hisi_hba->debugfs_itct = devm_kmalloc(dev, sz, GFP_KERNEL);
32423790 if (!hisi_hba->debugfs_itct)
3243− goto fail_itct;
3791+ goto fail;
32443792
3245− return;
3246−fail_itct:
3247− devm_kfree(dev, hisi_hba->debugfs_iost);
3248−fail_iost_dq:
3249− for (i = 0; i < d; i++)
3250− devm_kfree(dev, hisi_hba->debugfs_cmd_hdr[i]);
3251−fail_cq:
3252− for (i = 0; i < c; i++)
3253− devm_kfree(dev, hisi_hba->debugfs_complete_hdr[i]);
3254−fail_port:
3255− for (i = 0; i < p; i++)
3256− devm_kfree(dev, hisi_hba->debugfs_port_reg[i]);
3257− devm_kfree(dev, hisi_hba->debugfs_global_reg);
3258−fail_global:
3259− debugfs_remove_recursive(hisi_hba->debugfs_dir);
3260− dev_dbg(dev, "failed to init debugfs!\n");
3793+ return 0;
3794+fail:
3795+ hisi_sas_debugfs_release(hisi_hba);
3796+ return -ENOMEM;
3797+}
3798+
3799+void hisi_sas_debugfs_bist_init(struct hisi_hba *hisi_hba)
3800+{
3801+ hisi_hba->debugfs_bist_dentry =
3802+ debugfs_create_dir("bist", hisi_hba->debugfs_dir);
3803+ debugfs_create_file("link_rate", 0600,
3804+ hisi_hba->debugfs_bist_dentry, hisi_hba,
3805+ &hisi_sas_debugfs_bist_linkrate_ops);
3806+
3807+ debugfs_create_file("code_mode", 0600,
3808+ hisi_hba->debugfs_bist_dentry, hisi_hba,
3809+ &hisi_sas_debugfs_bist_code_mode_ops);
3810+
3811+ debugfs_create_file("phy_id", 0600, hisi_hba->debugfs_bist_dentry,
3812+ hisi_hba, &hisi_sas_debugfs_bist_phy_ops);
3813+
3814+ debugfs_create_u32("cnt", 0600, hisi_hba->debugfs_bist_dentry,
3815+ &hisi_hba->debugfs_bist_cnt);
3816+
3817+ debugfs_create_file("loopback_mode", 0600,
3818+ hisi_hba->debugfs_bist_dentry,
3819+ hisi_hba, &hisi_sas_debugfs_bist_mode_ops);
3820+
3821+ debugfs_create_file("enable", 0600, hisi_hba->debugfs_bist_dentry,
3822+ hisi_hba, &hisi_sas_debugfs_bist_enable_ops);
3823+
3824+ hisi_hba->debugfs_bist_linkrate = SAS_LINK_RATE_1_5_GBPS;
3825+}
3826+
3827+void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba)
3828+{
3829+ struct device *dev = hisi_hba->dev;
3830+
3831+ hisi_hba->debugfs_dir = debugfs_create_dir(dev_name(dev),
3832+ hisi_sas_debugfs_dir);
3833+ debugfs_create_file("trigger_dump", 0600,
3834+ hisi_hba->debugfs_dir,
3835+ hisi_hba,
3836+ &hisi_sas_debugfs_trigger_dump_fops);
3837+
3838+ /* create bist structures */
3839+ hisi_sas_debugfs_bist_init(hisi_hba);
3840+
3841+ if (hisi_sas_debugfs_alloc(hisi_hba)) {
3842+ debugfs_remove_recursive(hisi_hba->debugfs_dir);
3843+ dev_dbg(dev, "failed to init debugfs!\n");
3844+ }
32613845 }
32623846 EXPORT_SYMBOL_GPL(hisi_sas_debugfs_init);
32633847
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c+3−45
@@ -401,8 +401,6 @@ enum { · 400 unmodified lines
401401 TRANS_RX_SMP_RESP_TIMEOUT_ERR, /* 0x31a */
402402 };
403403
404−#define HISI_SAS_COMMAND_ENTRIES_V1_HW 8192
405−
406404 #define HISI_SAS_PHY_MAX_INT_NR (HISI_SAS_PHY_INT_NR * HISI_SAS_MAX_PHYS)
407405 #define HISI_SAS_CQ_MAX_INT_NR (HISI_SAS_MAX_QUEUES)
408406 #define HISI_SAS_FATAL_INT_NR (2)
@@ -418,13 +416,6 @@ static u32 hisi_sas_read32(struct hisi_hba *hisi_hba, u32 off) · 9 unmodified lines
418416 return readl(regs);
419417 }
420418
421−static u32 hisi_sas_read32_relaxed(struct hisi_hba *hisi_hba, u32 off)
422−{
423− void __iomem *regs = hisi_hba->regs + off;
424−
425− return readl_relaxed(regs);
426−}
427−
428419 static void hisi_sas_write32(struct hisi_hba *hisi_hba,
429420 u32 off, u32 val)
430421 {
@@ -866,30 +857,6 @@ static int get_wideport_bitmap_v1_hw(struct hisi_hba *hisi_hba, int port_id) · 435 unmodified lines
866857 return bitmap;
867858 }
868859
869−/*
870− * The callpath to this function and upto writing the write
871− * queue pointer should be safe from interruption.
872− */
873−static int
874−get_free_slot_v1_hw(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq)
875−{
876− struct device *dev = hisi_hba->dev;
877− int queue = dq->id;
878− u32 r, w;
879−
880− w = dq->wr_point;
881− r = hisi_sas_read32_relaxed(hisi_hba,
882− DLVRY_Q_0_RD_PTR + (queue * 0x14));
883− if (r == (w+1) % HISI_SAS_QUEUE_SLOTS) {
884− dev_warn(dev, "could not find free slot\n");
885− return -EAGAIN;
886− }
887−
888− dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS;
889−
890− return w;
891−}
892−
893860 /* DQ lock must be taken here */
894861 static void start_delivery_v1_hw(struct hisi_sas_dq *dq)
895862 {
@@ -1308,21 +1275,17 @@ static int slot_complete_v1_hw(struct hisi_hba *hisi_hba, · 412 unmodified lines
13081275 }
13091276 case SAS_PROTOCOL_SMP:
13101277 {
1311− void *to;
13121278 struct scatterlist *sg_resp = &task->smp_task.smp_resp;
1279+ void *to = page_address(sg_page(sg_resp));
13131280
13141281 ts->stat = SAM_STAT_GOOD;
1315− to = kmap_atomic(sg_page(sg_resp));
13161282
1317− dma_unmap_sg(dev, &task->smp_task.smp_resp, 1,
1318− DMA_FROM_DEVICE);
13191283 dma_unmap_sg(dev, &task->smp_task.smp_req, 1,
13201284 DMA_TO_DEVICE);
13211285 memcpy(to + sg_resp->offset,
13221286 hisi_sas_status_buf_addr_mem(slot) +
13231287 sizeof(struct hisi_sas_err_record),
1324− sg_dma_len(sg_resp));
1325− kunmap_atomic(to);
1288+ sg_resp->length);
13261289 break;
13271290 }
13281291 case SAS_PROTOCOL_SATA:
@@ -1534,11 +1497,9 @@ static irqreturn_t cq_interrupt_v1_hw(int irq, void *p) · 205 unmodified lines
15341497 struct hisi_sas_complete_v1_hdr *complete_queue =
15351498 (struct hisi_sas_complete_v1_hdr *)
15361499 hisi_hba->complete_hdr[queue];
1537− u32 irq_value, rd_point = cq->rd_point, wr_point;
1500+ u32 rd_point = cq->rd_point, wr_point;
15381501
15391502 spin_lock(&hisi_hba->lock);
1540− irq_value = hisi_sas_read32(hisi_hba, OQ_INT_SRC);
1541−
15421503 hisi_sas_write32(hisi_hba, OQ_INT_SRC, 1 << queue);
15431504 wr_point = hisi_sas_read32(hisi_hba,
15441505 COMPL_Q_0_WR_PTR + (0x14 * queue));
@@ -1820,9 +1781,7 @@ static const struct hisi_sas_hw hisi_sas_v1_hw = { · 275 unmodified lines
18201781 .clear_itct = clear_itct_v1_hw,
18211782 .prep_smp = prep_smp_v1_hw,
18221783 .prep_ssp = prep_ssp_v1_hw,
1823− .get_free_slot = get_free_slot_v1_hw,
18241784 .start_delivery = start_delivery_v1_hw,
1825− .slot_complete = slot_complete_v1_hw,
18261785 .phys_init = phys_init_v1_hw,
18271786 .phy_start = start_phy_v1_hw,
18281787 .phy_disable = disable_phy_v1_hw,
@@ -1830,7 +1789,6 @@ static const struct hisi_sas_hw hisi_sas_v1_hw = { · 1 unmodified line
18301789 .phy_set_linkrate = phy_set_linkrate_v1_hw,
18311790 .phy_get_max_linkrate = phy_get_max_linkrate_v1_hw,
18321791 .get_wideport_bitmap = get_wideport_bitmap_v1_hw,
1833− .max_command_entries = HISI_SAS_COMMAND_ENTRIES_V1_HW,
18341792 .complete_hdr_size = sizeof(struct hisi_sas_complete_v1_hdr),
18351793 .sht = &sht_v1_hw,
18361794 };
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c+22−70
@@ -1637,31 +1637,6 @@ static int get_wideport_bitmap_v2_hw(struct hisi_hba *hisi_hba, int port_id) · 1636 unmodified lines
16371637 return bitmap;
16381638 }
16391639
1640−/*
1641− * The callpath to this function and upto writing the write
1642− * queue pointer should be safe from interruption.
1643− */
1644−static int
1645−get_free_slot_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq)
1646−{
1647− struct device *dev = hisi_hba->dev;
1648− int queue = dq->id;
1649− u32 r, w;
1650−
1651− w = dq->wr_point;
1652− r = hisi_sas_read32_relaxed(hisi_hba,
1653− DLVRY_Q_0_RD_PTR + (queue * 0x14));
1654− if (r == (w+1) % HISI_SAS_QUEUE_SLOTS) {
1655− dev_warn(dev, "full queue=%d r=%d w=%d\n",
1656− queue, r, w);
1657− return -EAGAIN;
1658− }
1659−
1660− dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS;
1661−
1662− return w;
1663−}
1664−
16651640 /* DQ lock must be taken here */
16661641 static void start_delivery_v2_hw(struct hisi_sas_dq *dq)
16671642 {
@@ -2418,7 +2393,7 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) · 750 unmodified lines
24182393 slot_err_v2_hw(hisi_hba, task, slot, 2);
24192394
24202395 if (ts->stat != SAS_DATA_UNDERRUN)
2421− dev_info(dev, "erroneous completion iptt=%d task=%p dev id=%d CQ hdr: 0x%x 0x%x 0x%x 0x%x Error info: 0x%x 0x%x 0x%x 0x%x\n",
2396+ dev_info(dev, "erroneous completion iptt=%d task=%pK dev id=%d CQ hdr: 0x%x 0x%x 0x%x 0x%x Error info: 0x%x 0x%x 0x%x 0x%x\n",
24222397 slot->idx, task, sas_dev->device_id,
24232398 complete_hdr->dw0, complete_hdr->dw1,
24242399 complete_hdr->act, complete_hdr->dw3,
@@ -2444,20 +2419,16 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) · 19 unmodified lines
24442419 case SAS_PROTOCOL_SMP:
24452420 {
24462421 struct scatterlist *sg_resp = &task->smp_task.smp_resp;
2447− void *to;
2422+ void *to = page_address(sg_page(sg_resp));
24482423
24492424 ts->stat = SAM_STAT_GOOD;
2450− to = kmap_atomic(sg_page(sg_resp));
24512425
2452− dma_unmap_sg(dev, &task->smp_task.smp_resp, 1,
2453− DMA_FROM_DEVICE);
24542426 dma_unmap_sg(dev, &task->smp_task.smp_req, 1,
24552427 DMA_TO_DEVICE);
24562428 memcpy(to + sg_resp->offset,
24572429 hisi_sas_status_buf_addr_mem(slot) +
24582430 sizeof(struct hisi_sas_err_record),
2459− sg_dma_len(sg_resp));
2460− kunmap_atomic(to);
2431+ sg_resp->length);
24612432 break;
24622433 }
24632434 case SAS_PROTOCOL_SATA:
@@ -2484,7 +2455,7 @@ out: · 20 unmodified lines
24842455 spin_lock_irqsave(&task->task_state_lock, flags);
24852456 if (task->task_state_flags & SAS_TASK_STATE_ABORTED) {
24862457 spin_unlock_irqrestore(&task->task_state_lock, flags);
2487− dev_info(dev, "slot complete: task(%p) aborted\n", task);
2458+ dev_info(dev, "slot complete: task(%pK) aborted\n", task);
24882459 return SAS_ABORTED_TASK;
24892460 }
24902461 task->task_state_flags |= SAS_TASK_STATE_DONE;
@@ -2495,7 +2466,7 @@ out: · 4 unmodified lines
24952466 spin_lock_irqsave(&device->done_lock, flags);
24962467 if (test_bit(SAS_HA_FROZEN, &ha->state)) {
24972468 spin_unlock_irqrestore(&device->done_lock, flags);
2498− dev_info(dev, "slot complete: task(%p) ignored\n",
2469+ dev_info(dev, "slot complete: task(%pK) ignored\n",
24992470 task);
25002471 return sts;
25012472 }
@@ -2563,7 +2534,10 @@ static void prep_ata_v2_hw(struct hisi_hba *hisi_hba, · 61 unmodified lines
25632534 hdr->dw1 = cpu_to_le32(dw1);
25642535
25652536 /* dw2 */
2566− if (task->ata_task.use_ncq && hisi_sas_get_ncq_tag(task, &hdr_tag)) {
2537+ if (task->ata_task.use_ncq) {
2538+ struct ata_queued_cmd *qc = task->uldd_task;
2539+
2540+ hdr_tag = qc->tag;
25672541 task->ata_task.fis.sector_count |= (u8) (hdr_tag << 3);
25682542 dw2 |= hdr_tag << CMD_HDR_NCQ_TAG_OFF;
25692543 }
@@ -3333,8 +3307,8 @@ static int interrupt_init_v2_hw(struct hisi_hba *hisi_hba) · 763 unmodified lines
33333307 {
33343308 struct platform_device *pdev = hisi_hba->platform_dev;
33353309 struct device *dev = &pdev->dev;
3336− int irq, rc, irq_map[128];
3337− int i, phy_no, fatal_no, queue_no, k;
3310+ int irq, rc = 0, irq_map[128];
3311+ int i, phy_no, fatal_no, queue_no;
33383312
33393313 for (i = 0; i < 128; i++)
33403314 irq_map[i] = platform_get_irq(pdev, i);
@@ -3347,7 +3321,7 @@ static int interrupt_init_v2_hw(struct hisi_hba *hisi_hba) · 6 unmodified lines
33473321 dev_err(dev, "irq init: could not request phy interrupt %d, rc=%d\n",
33483322 irq, rc);
33493323 rc = -ENOENT;
3350− goto free_phy_int_irqs;
3324+ goto err_out;
33513325 }
33523326 }
33533327
@@ -3361,7 +3335,7 @@ static int interrupt_init_v2_hw(struct hisi_hba *hisi_hba) · 7 unmodified lines
33613335 dev_err(dev, "irq init: could not request sata interrupt %d, rc=%d\n",
33623336 irq, rc);
33633337 rc = -ENOENT;
3364− goto free_sata_int_irqs;
3338+ goto err_out;
33653339 }
33663340 }
33673341
@@ -3373,7 +3347,7 @@ static int interrupt_init_v2_hw(struct hisi_hba *hisi_hba) · 5 unmodified lines
33733347 dev_err(dev, "irq init: could not request fatal interrupt %d, rc=%d\n",
33743348 irq, rc);
33753349 rc = -ENOENT;
3376− goto free_fatal_int_irqs;
3350+ goto err_out;
33773351 }
33783352 }
33793353
@@ -3388,34 +3362,14 @@ static int interrupt_init_v2_hw(struct hisi_hba *hisi_hba) · 8 unmodified lines
33883362 dev_err(dev, "irq init: could not request cq interrupt %d, rc=%d\n",
33893363 irq, rc);
33903364 rc = -ENOENT;
3391− goto free_cq_int_irqs;
3365+ goto err_out;
33923366 }
33933367 tasklet_init(t, cq_tasklet_v2_hw, (unsigned long)cq);
33943368 }
33953369
33963370 hisi_hba->cq_nvecs = hisi_hba->queue_count;
33973371
3398− return 0;
3399−
3400−free_cq_int_irqs:
3401− for (k = 0; k < queue_no; k++) {
3402− struct hisi_sas_cq *cq = &hisi_hba->cq[k];
3403−
3404− free_irq(irq_map[k + 96], cq);
3405− tasklet_kill(&cq->tasklet);
3406− }
3407−free_fatal_int_irqs:
3408− for (k = 0; k < fatal_no; k++)
3409− free_irq(irq_map[k + 81], hisi_hba);
3410−free_sata_int_irqs:
3411− for (k = 0; k < phy_no; k++) {
3412− struct hisi_sas_phy *phy = &hisi_hba->phy[k];
3413−
3414− free_irq(irq_map[k + 72], phy);
3415− }
3416−free_phy_int_irqs:
3417− for (k = 0; k < i; k++)
3418− free_irq(irq_map[k + 1], hisi_hba);
3372+err_out:
34193373 return rc;
34203374 }
34213375
@@ -3544,8 +3498,8 @@ static int write_gpio_v2_hw(struct hisi_hba *hisi_hba, u8 reg_type, · 122 unmodified lines
35443498 return 0;
35453499 }
35463500
3547−static int wait_cmds_complete_timeout_v2_hw(struct hisi_hba *hisi_hba,
3548− int delay_ms, int timeout_ms)
3501+static void wait_cmds_complete_timeout_v2_hw(struct hisi_hba *hisi_hba,
3502+ int delay_ms, int timeout_ms)
35493503 {
35503504 struct device *dev = hisi_hba->dev;
35513505 int entries, entries_old = 0, time;
@@ -3559,12 +3513,13 @@ static int wait_cmds_complete_timeout_v2_hw(struct hisi_hba *hisi_hba, · 7 unmodified lines
35593513 msleep(delay_ms);
35603514 }
35613515
3562− if (time >= timeout_ms)
3563− return -ETIMEDOUT;
3516+ if (time >= timeout_ms) {
3517+ dev_dbg(dev, "Wait commands complete timeout!\n");
3518+ return;
3519+ }
35643520
35653521 dev_dbg(dev, "wait commands complete %dms\n", time);
35663522
3567− return 0;
35683523 }
35693524
35703525 static struct device_attribute *host_attrs_v2_hw[] = {
@@ -3606,9 +3561,7 @@ static const struct hisi_sas_hw hisi_sas_v2_hw = { · 35 unmodified lines
36063561 .prep_ssp = prep_ssp_v2_hw,
36073562 .prep_stp = prep_ata_v2_hw,
36083563 .prep_abort = prep_abort_v2_hw,
3609− .get_free_slot = get_free_slot_v2_hw,
36103564 .start_delivery = start_delivery_v2_hw,
3611− .slot_complete = slot_complete_v2_hw,
36123565 .phys_init = phys_init_v2_hw,
36133566 .phy_start = start_phy_v2_hw,
36143567 .phy_disable = disable_phy_v2_hw,
@@ -3616,7 +3569,6 @@ static const struct hisi_sas_hw hisi_sas_v2_hw = { · 1 unmodified line
36163569 .get_events = phy_get_events_v2_hw,
36173570 .phy_set_linkrate = phy_set_linkrate_v2_hw,
36183571 .phy_get_max_linkrate = phy_get_max_linkrate_v2_hw,
3619− .max_command_entries = HISI_SAS_COMMAND_ENTRIES_V2_HW,
36203572 .complete_hdr_size = sizeof(struct hisi_sas_complete_v2_hdr),
36213573 .soft_reset = soft_reset_v2_hw,
36223574 .get_phys_state = get_phys_state_v2_hw,
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c+224−83
@@ -71,6 +71,7 @@ · 70 unmodified lines
7171 #define HGC_DQE_ECC_MB_ADDR_OFF 16
7272 #define HGC_DQE_ECC_MB_ADDR_MSK (0xfff << HGC_DQE_ECC_MB_ADDR_OFF)
7373 #define CHNL_INT_STATUS 0x148
74+#define TAB_DFX 0x14c
7475 #define HGC_ITCT_ECC_ADDR 0x150
7576 #define HGC_ITCT_ECC_1B_ADDR_OFF 0
7677 #define HGC_ITCT_ECC_1B_ADDR_MSK (0x3ff << \
@@ -83,6 +84,7 @@ · 6 unmodified lines
8384 #define AXI_ERR_INFO_MSK (0xff << AXI_ERR_INFO_OFF)
8485 #define FIFO_ERR_INFO_OFF 8
8586 #define FIFO_ERR_INFO_MSK (0xff << FIFO_ERR_INFO_OFF)
87+#define TAB_RD_TYPE 0x15c
8688 #define INT_COAL_EN 0x19c
8789 #define OQ_INT_COAL_TIME 0x1a0
8890 #define OQ_INT_COAL_CNT 0x1a4
@@ -189,12 +191,30 @@ · 100 unmodified lines
189191 #define PHY_CFG_PHY_RST_OFF 3
190192 #define PHY_CFG_PHY_RST_MSK (0x1 << PHY_CFG_PHY_RST_OFF)
191193 #define PROG_PHY_LINK_RATE (PORT_BASE + 0x8)
194+#define CFG_PROG_PHY_LINK_RATE_OFF 8
195+#define CFG_PROG_PHY_LINK_RATE_MSK (0xf << CFG_PROG_PHY_LINK_RATE_OFF)
192196 #define PHY_CTRL (PORT_BASE + 0x14)
193197 #define PHY_CTRL_RESET_OFF 0
194198 #define PHY_CTRL_RESET_MSK (0x1 << PHY_CTRL_RESET_OFF)
195199 #define CMD_HDR_PIR_OFF 8
196200 #define CMD_HDR_PIR_MSK (0x1 << CMD_HDR_PIR_OFF)
197201 #define SERDES_CFG (PORT_BASE + 0x1c)
202+#define CFG_ALOS_CHK_DISABLE_OFF 9
203+#define CFG_ALOS_CHK_DISABLE_MSK (0x1 << CFG_ALOS_CHK_DISABLE_OFF)
204+#define SAS_PHY_BIST_CTRL (PORT_BASE + 0x2c)
205+#define CFG_BIST_MODE_SEL_OFF 0
206+#define CFG_BIST_MODE_SEL_MSK (0xf << CFG_BIST_MODE_SEL_OFF)
207+#define CFG_LOOP_TEST_MODE_OFF 14
208+#define CFG_LOOP_TEST_MODE_MSK (0x3 << CFG_LOOP_TEST_MODE_OFF)
209+#define CFG_RX_BIST_EN_OFF 16
210+#define CFG_RX_BIST_EN_MSK (0x1 << CFG_RX_BIST_EN_OFF)
211+#define CFG_TX_BIST_EN_OFF 17
212+#define CFG_TX_BIST_EN_MSK (0x1 << CFG_TX_BIST_EN_OFF)
213+#define CFG_BIST_TEST_OFF 18
214+#define CFG_BIST_TEST_MSK (0x1 << CFG_BIST_TEST_OFF)
215+#define SAS_PHY_BIST_CODE (PORT_BASE + 0x30)
216+#define SAS_PHY_BIST_CODE1 (PORT_BASE + 0x34)
217+#define SAS_BIST_ERR_CNT (PORT_BASE + 0x38)
198218 #define SL_CFG (PORT_BASE + 0x84)
199219 #define AIP_LIMIT (PORT_BASE + 0x90)
200220 #define SL_CONTROL (PORT_BASE + 0x94)
@@ -499,13 +519,6 @@ static u32 hisi_sas_read32(struct hisi_hba *hisi_hba, u32 off) · 298 unmodified lines
499519 return readl(regs);
500520 }
501521
502−static u32 hisi_sas_read32_relaxed(struct hisi_hba *hisi_hba, u32 off)
503−{
504− void __iomem *regs = hisi_hba->regs + off;
505−
506− return readl_relaxed(regs);
507−}
508−
509522 static void hisi_sas_write32(struct hisi_hba *hisi_hba, u32 off, u32 val)
510523 {
511524 void __iomem *regs = hisi_hba->regs + off;
@@ -1006,31 +1019,6 @@ static int get_wideport_bitmap_v3_hw(struct hisi_hba *hisi_hba, int port_id) · 494 unmodified lines
10061019 return bitmap;
10071020 }
10081021
1009−/**
1010− * The callpath to this function and upto writing the write
1011− * queue pointer should be safe from interruption.
1012− */
1013−static int
1014−get_free_slot_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq)
1015−{
1016− struct device *dev = hisi_hba->dev;
1017− int queue = dq->id;
1018− u32 r, w;
1019−
1020− w = dq->wr_point;
1021− r = hisi_sas_read32_relaxed(hisi_hba,
1022− DLVRY_Q_0_RD_PTR + (queue * 0x14));
1023− if (r == (w+1) % HISI_SAS_QUEUE_SLOTS) {
1024− dev_warn(dev, "full queue=%d r=%d w=%d\n",
1025− queue, r, w);
1026− return -EAGAIN;
1027− }
1028−
1029− dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS;
1030−
1031− return w;
1032−}
1033−
10341022 static void start_delivery_v3_hw(struct hisi_sas_dq *dq)
10351023 {
10361024 struct hisi_hba *hisi_hba = dq->hisi_hba;
@@ -1386,7 +1374,10 @@ static void prep_ata_v3_hw(struct hisi_hba *hisi_hba, · 349 unmodified lines
13861374 hdr->dw1 = cpu_to_le32(dw1);
13871375
13881376 /* dw2 */
1389− if (task->ata_task.use_ncq && hisi_sas_get_ncq_tag(task, &hdr_tag)) {
1377+ if (task->ata_task.use_ncq) {
1378+ struct ata_queued_cmd *qc = task->uldd_task;
1379+
1380+ hdr_tag = qc->tag;
13901381 task->ata_task.fis.sector_count |= (u8) (hdr_tag << 3);
13911382 dw2 |= hdr_tag << CMD_HDR_NCQ_TAG_OFF;
13921383 }
@@ -1944,7 +1935,7 @@ static void fatal_ecc_int_v3_hw(struct hisi_hba *hisi_hba) · 551 unmodified lines
19441935 u32 irq_value, irq_msk;
19451936
19461937 irq_msk = hisi_sas_read32(hisi_hba, SAS_ECC_INTR_MSK);
1947− hisi_sas_write32(hisi_hba, SAS_ECC_INTR_MSK, irq_msk | 0xffffffff);
1938+ hisi_sas_write32(hisi_hba, SAS_ECC_INTR_MSK, 0xffffffff);
19481939
19491940 irq_value = hisi_sas_read32(hisi_hba, SAS_ECC_INTR);
19501941 if (irq_value)
@@ -2220,7 +2211,7 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) · 269 unmodified lines
22202211
22212212 slot_err_v3_hw(hisi_hba, task, slot);
22222213 if (ts->stat != SAS_DATA_UNDERRUN)
2223− dev_info(dev, "erroneous completion iptt=%d task=%p dev id=%d CQ hdr: 0x%x 0x%x 0x%x 0x%x Error info: 0x%x 0x%x 0x%x 0x%x\n",
2214+ dev_info(dev, "erroneous completion iptt=%d task=%pK dev id=%d CQ hdr: 0x%x 0x%x 0x%x 0x%x Error info: 0x%x 0x%x 0x%x 0x%x\n",
22242215 slot->idx, task, sas_dev->device_id,
22252216 dw0, dw1, complete_hdr->act, dw3,
22262217 error_info[0], error_info[1],
@@ -2241,20 +2232,16 @@ slot_complete_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) · 14 unmodified lines
22412232 }
22422233 case SAS_PROTOCOL_SMP: {
22432234 struct scatterlist *sg_resp = &task->smp_task.smp_resp;
2244− void *to;
2235+ void *to = page_address(sg_page(sg_resp));
22452236
22462237 ts->stat = SAM_STAT_GOOD;
2247− to = kmap_atomic(sg_page(sg_resp));
22482238
2249− dma_unmap_sg(dev, &task->smp_task.smp_resp, 1,
2250− DMA_FROM_DEVICE);
22512239 dma_unmap_sg(dev, &task->smp_task.smp_req, 1,
22522240 DMA_TO_DEVICE);
22532241 memcpy(to + sg_resp->offset,
22542242 hisi_sas_status_buf_addr_mem(slot) +
22552243 sizeof(struct hisi_sas_err_record),
2256− sg_dma_len(sg_resp));
2257− kunmap_atomic(to);
2244+ sg_resp->length);
22582245 break;
22592246 }
22602247 case SAS_PROTOCOL_SATA:
@@ -2279,7 +2266,7 @@ out: · 18 unmodified lines
22792266 spin_lock_irqsave(&task->task_state_lock, flags);
22802267 if (task->task_state_flags & SAS_TASK_STATE_ABORTED) {
22812268 spin_unlock_irqrestore(&task->task_state_lock, flags);
2282− dev_info(dev, "slot complete: task(%p) aborted\n", task);
2269+ dev_info(dev, "slot complete: task(%pK) aborted\n", task);
22832270 return SAS_ABORTED_TASK;
22842271 }
22852272 task->task_state_flags |= SAS_TASK_STATE_DONE;
@@ -2290,7 +2277,7 @@ out: · 4 unmodified lines
22902277 spin_lock_irqsave(&device->done_lock, flags);
22912278 if (test_bit(SAS_HA_FROZEN, &ha->state)) {
22922279 spin_unlock_irqrestore(&device->done_lock, flags);
2293− dev_info(dev, "slot complete: task(%p) ignored\n ",
2280+ dev_info(dev, "slot complete: task(%pK) ignored\n ",
22942281 task);
22952282 return sts;
22962283 }
@@ -2385,8 +2372,7 @@ static int interrupt_init_v3_hw(struct hisi_hba *hisi_hba) · 88 unmodified lines
23852372 {
23862373 struct device *dev = hisi_hba->dev;
23872374 struct pci_dev *pdev = hisi_hba->pci_dev;
2388− int vectors, rc;
2389− int i, k;
2375+ int vectors, rc, i;
23902376 int max_msi = HISI_SAS_MSI_COUNT_V3_HW, min_msi;
23912377
23922378 if (auto_affine_msi_experimental) {
@@ -2434,7 +2420,7 @@ static int interrupt_init_v3_hw(struct hisi_hba *hisi_hba) · 41 unmodified lines
24342420 if (rc) {
24352421 dev_err(dev, "could not request chnl interrupt, rc=%d\n", rc);
24362422 rc = -ENOENT;
2437− goto free_phy_irq;
2423+ goto free_irq_vectors;
24382424 }
24392425
24402426 rc = devm_request_irq(dev, pci_irq_vector(pdev, 11),
@@ -2443,7 +2429,7 @@ static int interrupt_init_v3_hw(struct hisi_hba *hisi_hba) · 2 unmodified lines
24432429 if (rc) {
24442430 dev_err(dev, "could not request fatal interrupt, rc=%d\n", rc);
24452431 rc = -ENOENT;
2446− goto free_chnl_interrupt;
2432+ goto free_irq_vectors;
24472433 }
24482434
24492435 /* Init tasklets for cq only */
@@ -2460,7 +2446,7 @@ static int interrupt_init_v3_hw(struct hisi_hba *hisi_hba) · 10 unmodified lines
24602446 dev_err(dev, "could not request cq%d interrupt, rc=%d\n",
24612447 i, rc);
24622448 rc = -ENOENT;
2463− goto free_cq_irqs;
2449+ goto free_irq_vectors;
24642450 }
24652451
24662452 tasklet_init(t, cq_tasklet_v3_hw, (unsigned long)cq);
@@ -2468,18 +2454,6 @@ static int interrupt_init_v3_hw(struct hisi_hba *hisi_hba) · 1 unmodified line
24682454
24692455 return 0;
24702456
2471−free_cq_irqs:
2472− for (k = 0; k < i; k++) {
2473− struct hisi_sas_cq *cq = &hisi_hba->cq[k];
2474− int nr = hisi_sas_intr_conv ? 16 : 16 + k;
2475−
2476− free_irq(pci_irq_vector(pdev, nr), cq);
2477− }
2478− free_irq(pci_irq_vector(pdev, 11), hisi_hba);
2479−free_chnl_interrupt:
2480− free_irq(pci_irq_vector(pdev, 2), hisi_hba);
2481−free_phy_irq:
2482− free_irq(pci_irq_vector(pdev, 1), hisi_hba);
24832457 free_irq_vectors:
24842458 pci_free_irq_vectors(pdev);
24852459 return rc;
@@ -2620,8 +2594,8 @@ static int write_gpio_v3_hw(struct hisi_hba *hisi_hba, u8 reg_type, · 134 unmodified lines
26202594 return 0;
26212595 }
26222596
2623−static int wait_cmds_complete_timeout_v3_hw(struct hisi_hba *hisi_hba,
2624− int delay_ms, int timeout_ms)
2597+static void wait_cmds_complete_timeout_v3_hw(struct hisi_hba *hisi_hba,
2598+ int delay_ms, int timeout_ms)
26252599 {
26262600 struct device *dev = hisi_hba->dev;
26272601 int entries, entries_old = 0, time;
@@ -2635,12 +2609,12 @@ static int wait_cmds_complete_timeout_v3_hw(struct hisi_hba *hisi_hba, · 7 unmodified lines
26352609 msleep(delay_ms);
26362610 }
26372611
2638− if (time >= timeout_ms)
2639− return -ETIMEDOUT;
2612+ if (time >= timeout_ms) {
2613+ dev_dbg(dev, "Wait commands complete timeout!\n");
2614+ return;
2615+ }
26402616
26412617 dev_dbg(dev, "wait commands complete %dms\n", time);
2642−
2643− return 0;
26442618 }
26452619
26462620 static ssize_t intr_conv_v3_hw_show(struct device *dev,
@@ -2887,16 +2861,45 @@ static const struct hisi_sas_debugfs_reg debugfs_global_reg = { · 240 unmodified lines
28872861 .read_global_reg = hisi_sas_read32,
28882862 };
28892863
2864+static const struct hisi_sas_debugfs_reg_lu debugfs_axi_reg_lu[] = {
2865+ HISI_SAS_DEBUGFS_REG(AM_CFG_MAX_TRANS),
2866+ HISI_SAS_DEBUGFS_REG(AM_CFG_SINGLE_PORT_MAX_TRANS),
2867+ HISI_SAS_DEBUGFS_REG(AXI_CFG),
2868+ HISI_SAS_DEBUGFS_REG(AM_ROB_ECC_ERR_ADDR),
2869+ {}
2870+};
2871+
2872+static const struct hisi_sas_debugfs_reg debugfs_axi_reg = {
2873+ .lu = debugfs_axi_reg_lu,
2874+ .count = 0x61,
2875+ .base_off = AXI_MASTER_CFG_BASE,
2876+ .read_global_reg = hisi_sas_read32,
2877+};
2878+
2879+static const struct hisi_sas_debugfs_reg_lu debugfs_ras_reg_lu[] = {
2880+ HISI_SAS_DEBUGFS_REG(SAS_RAS_INTR1),
2881+ HISI_SAS_DEBUGFS_REG(SAS_RAS_INTR0_MASK),
2882+ HISI_SAS_DEBUGFS_REG(SAS_RAS_INTR1_MASK),
2883+ HISI_SAS_DEBUGFS_REG(CFG_SAS_RAS_INTR_MASK),
2884+ HISI_SAS_DEBUGFS_REG(SAS_RAS_INTR2),
2885+ HISI_SAS_DEBUGFS_REG(SAS_RAS_INTR2_MASK),
2886+ {}
2887+};
2888+
2889+static const struct hisi_sas_debugfs_reg debugfs_ras_reg = {
2890+ .lu = debugfs_ras_reg_lu,
2891+ .count = 0x10,
2892+ .base_off = RAS_BASE,
2893+ .read_global_reg = hisi_sas_read32,
2894+};
2895+
28902896 static void debugfs_snapshot_prepare_v3_hw(struct hisi_hba *hisi_hba)
28912897 {
2892− struct device *dev = hisi_hba->dev;
2893−
28942898 set_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
28952899
28962900 hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, 0);
28972901
2898− if (wait_cmds_complete_timeout_v3_hw(hisi_hba, 100, 5000) == -ETIMEDOUT)
2899− dev_dbg(dev, "Wait commands complete timeout!\n");
2902+ wait_cmds_complete_timeout_v3_hw(hisi_hba, 100, 5000);
29002903
29012904 hisi_sas_kill_tasklets(hisi_hba);
29022905 }
@@ -2909,6 +2912,142 @@ static void debugfs_snapshot_restore_v3_hw(struct hisi_hba *hisi_hba) · 6 unmodified lines
29092912 clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
29102913 }
29112914
2915+static void read_iost_itct_cache_v3_hw(struct hisi_hba *hisi_hba,
2916+ enum hisi_sas_debugfs_cache_type type,
2917+ u32 *cache)
2918+{
2919+ u32 cache_dw_size = HISI_SAS_IOST_ITCT_CACHE_DW_SZ *
2920+ HISI_SAS_IOST_ITCT_CACHE_NUM;
2921+ u32 *buf = cache;
2922+ u32 i, val;
2923+
2924+ hisi_sas_write32(hisi_hba, TAB_RD_TYPE, type);
2925+
2926+ for (i = 0; i < HISI_SAS_IOST_ITCT_CACHE_DW_SZ; i++) {
2927+ val = hisi_sas_read32(hisi_hba, TAB_DFX);
2928+ if (val == 0xffffffff)
2929+ break;
2930+ }
2931+
2932+ if (val != 0xffffffff) {
2933+ pr_err("Issue occur when reading IOST/ITCT cache!\n");
2934+ return;
2935+ }
2936+
2937+ memset(buf, 0, cache_dw_size * 4);
2938+ buf[0] = val;
2939+
2940+ for (i = 1; i < cache_dw_size; i++)
2941+ buf[i] = hisi_sas_read32(hisi_hba, TAB_DFX);
2942+}
2943+
2944+static void hisi_sas_bist_test_prep_v3_hw(struct hisi_hba *hisi_hba)
2945+{
2946+ u32 reg_val;
2947+ int phy_id = hisi_hba->debugfs_bist_phy_no;
2948+
2949+ /* disable PHY */
2950+ hisi_sas_phy_enable(hisi_hba, phy_id, 0);
2951+
2952+ /* disable ALOS */
2953+ reg_val = hisi_sas_phy_read32(hisi_hba, phy_id, SERDES_CFG);
2954+ reg_val |= CFG_ALOS_CHK_DISABLE_MSK;
2955+ hisi_sas_phy_write32(hisi_hba, phy_id, SERDES_CFG, reg_val);
2956+}
2957+
2958+static void hisi_sas_bist_test_restore_v3_hw(struct hisi_hba *hisi_hba)
2959+{
2960+ u32 reg_val;
2961+ int phy_id = hisi_hba->debugfs_bist_phy_no;
2962+
2963+ /* disable loopback */
2964+ reg_val = hisi_sas_phy_read32(hisi_hba, phy_id, SAS_PHY_BIST_CTRL);
2965+ reg_val &= ~(CFG_RX_BIST_EN_MSK | CFG_TX_BIST_EN_MSK |
2966+ CFG_BIST_TEST_MSK);
2967+ hisi_sas_phy_write32(hisi_hba, phy_id, SAS_PHY_BIST_CTRL, reg_val);
2968+
2969+ /* enable ALOS */
2970+ reg_val = hisi_sas_phy_read32(hisi_hba, phy_id, SERDES_CFG);
2971+ reg_val &= ~CFG_ALOS_CHK_DISABLE_MSK;
2972+ hisi_sas_phy_write32(hisi_hba, phy_id, SERDES_CFG, reg_val);
2973+
2974+ /* restore the linkrate */
2975+ reg_val = hisi_sas_phy_read32(hisi_hba, phy_id, PROG_PHY_LINK_RATE);
2976+ /* init OOB link rate as 1.5 Gbits */
2977+ reg_val &= ~CFG_PROG_PHY_LINK_RATE_MSK;
2978+ reg_val |= (0x8 << CFG_PROG_PHY_LINK_RATE_OFF);
2979+ hisi_sas_phy_write32(hisi_hba, phy_id, PROG_PHY_LINK_RATE, reg_val);
2980+
2981+ /* enable PHY */
2982+ hisi_sas_phy_enable(hisi_hba, phy_id, 1);
2983+}
2984+
2985+#define SAS_PHY_BIST_CODE_INIT 0x1
2986+#define SAS_PHY_BIST_CODE1_INIT 0X80
2987+static int debugfs_set_bist_v3_hw(struct hisi_hba *hisi_hba, bool enable)
2988+{
2989+ u32 reg_val, mode_tmp;
2990+ u32 linkrate = hisi_hba->debugfs_bist_linkrate;
2991+ u32 phy_id = hisi_hba->debugfs_bist_phy_no;
2992+ u32 code_mode = hisi_hba->debugfs_bist_code_mode;
2993+ u32 path_mode = hisi_hba->debugfs_bist_mode;
2994+ struct device *dev = hisi_hba->dev;
2995+
2996+ dev_info(dev, "BIST info:linkrate=%d phy_id=%d code_mode=%d path_mode=%d\n",
2997+ linkrate, phy_id, code_mode, path_mode);
2998+ mode_tmp = path_mode ? 2 : 1;
2999+ if (enable) {
3000+ /* some preparations before bist test */
3001+ hisi_sas_bist_test_prep_v3_hw(hisi_hba);
3002+
3003+ /* set linkrate of bit test*/
3004+ reg_val = hisi_sas_phy_read32(hisi_hba, phy_id,
3005+ PROG_PHY_LINK_RATE);
3006+ reg_val &= ~CFG_PROG_PHY_LINK_RATE_MSK;
3007+ reg_val |= (linkrate << CFG_PROG_PHY_LINK_RATE_OFF);
3008+ hisi_sas_phy_write32(hisi_hba, phy_id,
3009+ PROG_PHY_LINK_RATE, reg_val);
3010+
3011+ /* set code mode of bit test */
3012+ reg_val = hisi_sas_phy_read32(hisi_hba, phy_id,
3013+ SAS_PHY_BIST_CTRL);
3014+ reg_val &= ~(CFG_BIST_MODE_SEL_MSK |
3015+ CFG_LOOP_TEST_MODE_MSK |
3016+ CFG_RX_BIST_EN_MSK |
3017+ CFG_TX_BIST_EN_MSK |
3018+ CFG_BIST_TEST_MSK);
3019+ reg_val |= ((code_mode << CFG_BIST_MODE_SEL_OFF) |
3020+ (mode_tmp << CFG_LOOP_TEST_MODE_OFF) |
3021+ CFG_BIST_TEST_MSK);
3022+ hisi_sas_phy_write32(hisi_hba, phy_id,
3023+ SAS_PHY_BIST_CTRL, reg_val);
3024+
3025+ mdelay(100);
3026+ reg_val |= (CFG_RX_BIST_EN_MSK | CFG_TX_BIST_EN_MSK);
3027+ hisi_sas_phy_write32(hisi_hba, phy_id,
3028+ SAS_PHY_BIST_CTRL, reg_val);
3029+
3030+ /* set the bist init value */
3031+ hisi_sas_phy_write32(hisi_hba, phy_id,
3032+ SAS_PHY_BIST_CODE,
3033+ SAS_PHY_BIST_CODE_INIT);
3034+ hisi_sas_phy_write32(hisi_hba, phy_id,
3035+ SAS_PHY_BIST_CODE1,
3036+ SAS_PHY_BIST_CODE1_INIT);
3037+
3038+ /* clear error bit */
3039+ mdelay(100);
3040+ hisi_sas_phy_read32(hisi_hba, phy_id, SAS_BIST_ERR_CNT);
3041+ } else {
3042+ /* disable bist test and recover it */
3043+ hisi_hba->debugfs_bist_cnt += hisi_sas_phy_read32(hisi_hba,
3044+ phy_id, SAS_BIST_ERR_CNT);
3045+ hisi_sas_bist_test_restore_v3_hw(hisi_hba);
3046+ }
3047+
3048+ return 0;
3049+}
3050+
29123051 static struct scsi_host_template sht_v3_hw = {
29133052 .name = DRV_NAME,
29143053 .module = THIS_MODULE,
@@ -2935,7 +3074,6 @@ static struct scsi_host_template sht_v3_hw = { · 20 unmodified lines
29353074 static const struct hisi_sas_hw hisi_sas_v3_hw = {
29363075 .hw_init = hisi_sas_v3_init,
29373076 .setup_itct = setup_itct_v3_hw,
2938− .max_command_entries = HISI_SAS_COMMAND_ENTRIES_V3_HW,
29393077 .get_wideport_bitmap = get_wideport_bitmap_v3_hw,
29403078 .complete_hdr_size = sizeof(struct hisi_sas_complete_v3_hdr),
29413079 .clear_itct = clear_itct_v3_hw,
@@ -2944,9 +3082,7 @@ static const struct hisi_sas_hw hisi_sas_v3_hw = { · 2 unmodified lines
29443082 .prep_smp = prep_smp_v3_hw,
29453083 .prep_stp = prep_ata_v3_hw,
29463084 .prep_abort = prep_abort_v3_hw,
2947− .get_free_slot = get_free_slot_v3_hw,
29483085 .start_delivery = start_delivery_v3_hw,
2949− .slot_complete = slot_complete_v3_hw,
29503086 .phys_init = phys_init_v3_hw,
29513087 .phy_start = start_phy_v3_hw,
29523088 .phy_disable = disable_phy_v3_hw,
@@ -2959,10 +3095,14 @@ static const struct hisi_sas_hw hisi_sas_v3_hw = { · 6 unmodified lines
29593095 .get_events = phy_get_events_v3_hw,
29603096 .write_gpio = write_gpio_v3_hw,
29613097 .wait_cmds_complete_timeout = wait_cmds_complete_timeout_v3_hw,
2962− .debugfs_reg_global = &debugfs_global_reg,
3098+ .debugfs_reg_array[DEBUGFS_GLOBAL] = &debugfs_global_reg,
3099+ .debugfs_reg_array[DEBUGFS_AXI] = &debugfs_axi_reg,
3100+ .debugfs_reg_array[DEBUGFS_RAS] = &debugfs_ras_reg,
29633101 .debugfs_reg_port = &debugfs_port_reg,
29643102 .snapshot_prepare = debugfs_snapshot_prepare_v3_hw,
29653103 .snapshot_restore = debugfs_snapshot_restore_v3_hw,
3104+ .read_iost_itct_cache = read_iost_itct_cache_v3_hw,
3105+ .set_bist = debugfs_set_bist_v3_hw,
29663106 };
29673107
29683108 static struct Scsi_Host *
@@ -2993,8 +3133,6 @@ hisi_sas_shost_alloc_pci(struct pci_dev *pdev) · 24 unmodified lines
29933133 else
29943134 hisi_hba->prot_mask = prot_mask;
29953135
2996− timer_setup(&hisi_hba->timer, NULL, 0);
2997−
29983136 if (hisi_sas_get_fw_info(hisi_hba) < 0)
29993137 goto err_out;
30003138
@@ -3076,17 +3214,14 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 75 unmodified lines
30763214 shost->max_lun = ~0;
30773215 shost->max_channel = 1;
30783216 shost->max_cmd_len = 16;
3079− shost->can_queue = hisi_hba->hw->max_command_entries -
3080− HISI_SAS_RESERVED_IPTT_CNT;
3081− shost->cmd_per_lun = hisi_hba->hw->max_command_entries -
3082− HISI_SAS_RESERVED_IPTT_CNT;
3217+ shost->can_queue = HISI_SAS_UNRESERVED_IPTT;
3218+ shost->cmd_per_lun = HISI_SAS_UNRESERVED_IPTT;
30833219
30843220 sha->sas_ha_name = DRV_NAME;
30853221 sha->dev = dev;
30863222 sha->lldd_module = THIS_MODULE;
30873223 sha->sas_addr = &hisi_hba->sas_addr[0];
30883224 sha->num_phys = hisi_hba->n_phy;
3089− sha->core.shost = hisi_hba->shost;
30903225
30913226 for (i = 0; i < hisi_hba->n_phy; i++) {
30923227 sha->sas_phy[i] = &hisi_hba->phy[i].sas_phy;
@@ -3273,15 +3408,21 @@ static int hisi_sas_v3_resume(struct pci_dev *pdev) · 180 unmodified lines
32733408 pci_enable_wake(pdev, PCI_D0, 0);
32743409 pci_restore_state(pdev);
32753410 rc = pci_enable_device(pdev);
3276− if (rc)
3411+ if (rc) {
32773412 dev_err(dev, "enable device failed during resume (%d)\n", rc);
3413+ return rc;
3414+ }
32783415
32793416 pci_set_master(pdev);
32803417 scsi_unblock_requests(shost);
32813418 clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
32823419
32833420 sas_prep_resume_ha(sha);
3284− init_reg_v3_hw(hisi_hba);
3421+ rc = hw_init_v3_hw(hisi_hba);
3422+ if (rc) {
3423+ scsi_remove_host(shost);
3424+ pci_disable_device(pdev);
3425+ }
32853426 hisi_hba->hw->phys_init(hisi_hba);
32863427 sas_resume_ha(sha);
32873428 clear_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags);
drivers/scsi/ibmvscsi/ibmvfc.c+3−0
@@ -1830,6 +1830,7 @@ static int ibmvfc_bsg_request(struct bsg_job *job) · 1829 unmodified lines
18301830 port_id = (bsg_request->rqst_data.h_els.port_id[0] << 16) |
18311831 (bsg_request->rqst_data.h_els.port_id[1] << 8) |
18321832 bsg_request->rqst_data.h_els.port_id[2];
1833+ /* fall through */
18331834 case FC_BSG_RPT_ELS:
18341835 fc_flags = IBMVFC_FC_ELS;
18351836 break;
@@ -1838,6 +1839,7 @@ static int ibmvfc_bsg_request(struct bsg_job *job) · 2 unmodified lines
18381839 port_id = (bsg_request->rqst_data.h_ct.port_id[0] << 16) |
18391840 (bsg_request->rqst_data.h_ct.port_id[1] << 8) |
18401841 bsg_request->rqst_data.h_ct.port_id[2];
1842+ /* fall through */
18411843 case FC_BSG_RPT_CT:
18421844 fc_flags = IBMVFC_FC_CT_IU;
18431845 break;
@@ -4020,6 +4022,7 @@ static void ibmvfc_npiv_login_done(struct ibmvfc_event *evt) · 2176 unmodified lines
40204022 return;
40214023 case IBMVFC_MAD_CRQ_ERROR:
40224024 ibmvfc_retry_host_init(vhost);
4025+ /* fall through */
40234026 case IBMVFC_MAD_DRIVER_FAILED:
40244027 ibmvfc_free_event(evt);
40254028 return;
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c+3−0
@@ -1581,6 +1581,7 @@ static long ibmvscsis_adapter_info(struct scsi_info *vscsi, · 1580 unmodified lines
15811581 case H_PERMISSION:
15821582 if (connection_broken(vscsi))
15831583 flag_bits = (RESPONSE_Q_DOWN | CLIENT_FAILED);
1584+ /* Fall through */
15841585 default:
15851586 dev_err(&vscsi->dev, "adapter_info: h_copy_rdma to client failed, rc %ld\n",
15861587 rc);
@@ -2492,8 +2493,10 @@ static long ibmvscsis_ping_response(struct scsi_info *vscsi) · 905 unmodified lines
24922493 break;
24932494 case H_CLOSED:
24942495 vscsi->flags |= CLIENT_FAILED;
2496+ /* Fall through */
24952497 case H_DROPPED:
24962498 vscsi->flags |= RESPONSE_Q_DOWN;
2499+ /* Fall through */
24972500 case H_REMOTE_PARM:
24982501 dev_err(&vscsi->dev, "ping_response: h_send_crq failed, rc %ld\n",
24992502 rc);
drivers/scsi/lpfc/lpfc.h+7−4
@@ -51,6 +51,8 @@ struct lpfc_sli2_slim; · 50 unmodified lines
5151 cmnd for menlo needs nearly twice as for firmware
5252 downloads using bsg */
5353
54+#define LPFC_DEFAULT_XPSGL_SIZE 256
55+#define LPFC_MAX_SG_TABLESIZE 0xffff
5456 #define LPFC_MIN_SG_SLI4_BUF_SZ 0x800 /* based on LPFC_DEFAULT_SG_SEG_CNT */
5557 #define LPFC_MAX_BG_SLI4_SEG_CNT_DIF 128 /* sg element count for BlockGuard */
5658 #define LPFC_MAX_SG_SEG_CNT_DIF 512 /* sg element count per scsi cmnd */
@@ -732,14 +734,13 @@ struct lpfc_hba { · 675 unmodified lines
732734 #define HBA_AER_ENABLED 0x1000 /* AER enabled with HBA */
733735 #define HBA_DEVLOSS_TMO 0x2000 /* HBA in devloss timeout */
734736 #define HBA_RRQ_ACTIVE 0x4000 /* process the rrq active list */
735−#define HBA_FCP_IOQ_FLUSH 0x8000 /* FCP I/O queues being flushed */
737+#define HBA_IOQ_FLUSH 0x8000 /* FCP/NVME I/O queues being flushed */
736738 #define HBA_FW_DUMP_OP 0x10000 /* Skips fn reset before FW dump */
737739 #define HBA_RECOVERABLE_UE 0x20000 /* Firmware supports recoverable UE */
738740 #define HBA_FORCED_LINK_SPEED 0x40000 /*
739741 * Firmware supports Forced Link Speed
740742 * capability
741743 */
742−#define HBA_NVME_IOQ_FLUSH 0x80000 /* NVME IO queues flushed. */
743744 #define HBA_FLOGI_ISSUED 0x100000 /* FLOGI was issued */
744745
745746 uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/
@@ -795,10 +796,12 @@ struct lpfc_hba { · 49 unmodified lines
795796 uint8_t mds_diags_support;
796797 uint8_t bbcredit_support;
797798 uint8_t enab_exp_wqcq_pages;
799+ u8 nsler; /* Firmware supports FC-NVMe-2 SLER */
798800
799801 /* HBA Config Parameters */
800802 uint32_t cfg_ack0;
801803 uint32_t cfg_xri_rebalancing;
804+ uint32_t cfg_xpsgl;
802805 uint32_t cfg_enable_npiv;
803806 uint32_t cfg_enable_rrq;
804807 uint32_t cfg_topology;
@@ -905,6 +908,7 @@ struct lpfc_hba { · 100 unmodified lines
905908 wait_queue_head_t work_waitq;
906909 struct task_struct *worker_thread;
907910 unsigned long data_flags;
911+ uint32_t border_sge_num;
908912
909913 uint32_t hbq_in_use; /* HBQs in use flag */
910914 uint32_t hbq_count; /* Count of configured HBQs */
@@ -987,6 +991,7 @@ struct lpfc_hba { · 76 unmodified lines
987991 struct dma_pool *lpfc_nvmet_drb_pool; /* data receive buffer pool */
988992 struct dma_pool *lpfc_hbq_pool; /* SLI3 hbq buffer pool */
989993 struct dma_pool *txrdy_payload_pool;
994+ struct dma_pool *lpfc_cmd_rsp_buf_pool;
990995 struct lpfc_dma_pool lpfc_mbuf_safety_pool;
991996
992997 mempool_t *mbox_mem_pool;
@@ -1034,8 +1039,6 @@ struct lpfc_hba { · 41 unmodified lines
10341039 struct dentry *debug_hbqinfo;
10351040 struct dentry *debug_dumpHostSlim;
10361041 struct dentry *debug_dumpHBASlim;
1037− struct dentry *debug_dumpData; /* BlockGuard BPL */
1038− struct dentry *debug_dumpDif; /* BlockGuard BPL */
10391042 struct dentry *debug_InjErrLBA; /* LBA to inject errors at */
10401043 struct dentry *debug_InjErrNPortID; /* NPortID to inject errors at */
10411044 struct dentry *debug_InjErrWWPN; /* WWPN to inject errors at */
drivers/scsi/lpfc/lpfc_attr.c+55−21
@@ -841,7 +841,8 @@ lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) · 840 unmodified lines
841841 lpfc_vpd_t *vp = &phba->vpd;
842842
843843 lpfc_jedec_to_ascii(vp->rev.biuRev, hdw);
844− return scnprintf(buf, PAGE_SIZE, "%s\n", hdw);
844+ return scnprintf(buf, PAGE_SIZE, "%s %08x %08x\n", hdw,
845+ vp->rev.smRev, vp->rev.smFwRev);
845846 }
846847
847848 /**
@@ -3682,8 +3683,8 @@ lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) · 2834 unmodified lines
36823683 if (rport)
36833684 remoteport = rport->remoteport;
36843685 spin_unlock(&vport->phba->hbalock);
3685− if (remoteport)
3686− nvme_fc_set_remoteport_devloss(rport->remoteport,
3686+ if (rport && remoteport)
3687+ nvme_fc_set_remoteport_devloss(remoteport,
36873688 vport->cfg_devloss_tmo);
36883689 #endif
36893690 }
@@ -5467,15 +5468,12 @@ LPFC_ATTR_RW(nvmet_fb_size, 0, 0, 65536, · 1777 unmodified lines
54675468 * lpfc_nvme_enable_fb: Enable NVME first burst on I and T functions.
54685469 * For the Initiator (I), enabling this parameter means that an NVMET
54695470 * PRLI response with FBA enabled and an FB_SIZE set to a nonzero value will be
5470− * processed by the initiator for subsequent NVME FCP IO. For the target
5471− * function (T), enabling this parameter qualifies the lpfc_nvmet_fb_size
5472− * driver parameter as the target function's first burst size returned to the
5473− * initiator in the target's NVME PRLI response. Parameter supported on physical
5474− * port only - no NPIV support.
5471+ * processed by the initiator for subsequent NVME FCP IO.
5472+ * Currently, this feature is not supported on the NVME target
54755473 * Value range is [0,1]. Default value is 0 (disabled).
54765474 */
54775475 LPFC_ATTR_RW(nvme_enable_fb, 0, 0, 1,
5478− "Enable First Burst feature on I and T functions.");
5476+ "Enable First Burst feature for NVME Initiator.");
54795477
54805478 /*
54815479 # lpfc_max_scsicmpl_time: Use scsi command completion time to control I/O queue
@@ -5927,7 +5925,7 @@ lpfc_sg_seg_cnt_init(struct lpfc_hba *phba, int val) · 445 unmodified lines
59275925 * 1 = MDS Diagnostics enabled
59285926 * Value range is [0,1]. Default value is 0.
59295927 */
5930−LPFC_ATTR_R(enable_mds_diags, 0, 0, 1, "Enable MDS Diagnostics");
5928+LPFC_ATTR_RW(enable_mds_diags, 0, 0, 1, "Enable MDS Diagnostics");
59315929
59325930 /*
59335931 * lpfc_ras_fwlog_buffsize: Firmware logging host buffer size
@@ -6859,10 +6857,31 @@ lpfc_get_starget_port_name(struct scsi_target *starget) · 925 unmodified lines
68596857 static void
68606858 lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
68616859 {
6860+ struct lpfc_rport_data *rdata = rport->dd_data;
6861+ struct lpfc_nodelist *ndlp = rdata->pnode;
6862+#if (IS_ENABLED(CONFIG_NVME_FC))
6863+ struct lpfc_nvme_rport *nrport = NULL;
6864+#endif
6865+
68626866 if (timeout)
68636867 rport->dev_loss_tmo = timeout;
68646868 else
68656869 rport->dev_loss_tmo = 1;
6870+
6871+ if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) {
6872+ dev_info(&rport->dev, "Cannot find remote node to "
6873+ "set rport dev loss tmo, port_id x%x\n",
6874+ rport->port_id);
6875+ return;
6876+ }
6877+
6878+#if (IS_ENABLED(CONFIG_NVME_FC))
6879+ nrport = lpfc_ndlp_get_nrport(ndlp);
6880+
6881+ if (nrport && nrport->remoteport)
6882+ nvme_fc_set_remoteport_devloss(nrport->remoteport,
6883+ rport->dev_loss_tmo);
6884+#endif
68666885 }
68676886
68686887 /**
@@ -7058,6 +7077,21 @@ struct fc_function_template lpfc_vport_transport_functions = { · 189 unmodified lines
70587077 .set_vport_symbolic_name = lpfc_set_vport_symbolic_name,
70597078 };
70607079
7080+/**
7081+ * lpfc_get_hba_function_mode - Used to determine the HBA function in FCoE
7082+ * Mode
7083+ * @phba: lpfc_hba pointer.
7084+ **/
7085+static void
7086+lpfc_get_hba_function_mode(struct lpfc_hba *phba)
7087+{
7088+ /* If it's a SkyHawk FCoE adapter */
7089+ if (phba->pcidev->device == PCI_DEVICE_ID_SKYHAWK)
7090+ phba->hba_flag |= HBA_FCOE_MODE;
7091+ else
7092+ phba->hba_flag &= ~HBA_FCOE_MODE;
7093+}
7094+
70617095 /**
70627096 * lpfc_get_cfgparam - Used during probe_one to init the adapter structure
70637097 * @phba: lpfc_hba pointer.
@@ -7114,8 +7148,18 @@ lpfc_get_cfgparam(struct lpfc_hba *phba) · 50 unmodified lines
71147148 else
71157149 phba->cfg_poll = lpfc_poll;
71167150
7117− if (phba->cfg_enable_bg)
7151+ /* Get the function mode */
7152+ lpfc_get_hba_function_mode(phba);
7153+
7154+ /* BlockGuard allowed for FC only. */
7155+ if (phba->cfg_enable_bg && phba->hba_flag & HBA_FCOE_MODE) {
7156+ lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
7157+ "0581 BlockGuard feature not supported\n");
7158+ /* If set, clear the BlockGuard support param */
7159+ phba->cfg_enable_bg = 0;
7160+ } else if (phba->cfg_enable_bg) {
71187161 phba->sli3_options |= LPFC_SLI3_BG_ENABLED;
7162+ }
71197163
71207164 lpfc_suppress_rsp_init(phba, lpfc_suppress_rsp);
71217165
@@ -7175,16 +7219,6 @@ lpfc_get_cfgparam(struct lpfc_hba *phba) · 53 unmodified lines
71757219 lpfc_ras_fwlog_level_init(phba, lpfc_ras_fwlog_level);
71767220 lpfc_ras_fwlog_func_init(phba, lpfc_ras_fwlog_func);
71777221
7178−
7179− /* If the NVME FC4 type is enabled, scale the sg_seg_cnt to
7180− * accommodate 512K and 1M IOs in a single nvme buf and supply
7181− * enough NVME LS iocb buffers for larger connectivity counts.
7182− */
7183− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
7184− phba->cfg_sg_seg_cnt = LPFC_MAX_NVME_SEG_CNT;
7185− phba->cfg_iocb_cnt = 5;
7186− }
7187−
71887222 return;
71897223 }
71907224
drivers/scsi/lpfc/lpfc_bsg.c+17−12
@@ -1040,7 +1040,7 @@ lpfc_bsg_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 1039 unmodified lines
10401040 if (!dmabuf) {
10411041 lpfc_printf_log(phba, KERN_ERR,
10421042 LOG_LIBDFC, "2616 No dmabuf "
1043− "found for iocbq 0x%p\n",
1043+ "found for iocbq x%px\n",
10441044 iocbq);
10451045 kfree(evt_dat->data);
10461046 kfree(evt_dat);
@@ -1276,9 +1276,7 @@ lpfc_bsg_hba_set_event(struct bsg_job *job) · 229 unmodified lines
12761276 return 0; /* call job done later */
12771277
12781278 job_error:
1279− if (dd_data != NULL)
1280− kfree(dd_data);
1281−
1279+ kfree(dd_data);
12821280 job->dd_data = NULL;
12831281 return rc;
12841282 }
@@ -1571,7 +1569,6 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct bsg_job *job, uint32_t tag, · 286 unmodified lines
15711569 "2722 Xmit CT response on exchange x%x Data: x%x x%x x%x\n",
15721570 icmd->ulpContext, icmd->ulpIoTag, tag, phba->link_state);
15731571
1574− ctiocb->iocb_cmpl = NULL;
15751572 ctiocb->iocb_flag |= LPFC_IO_LIBDFC;
15761573 ctiocb->vport = phba->pport;
15771574 ctiocb->context1 = dd_data;
@@ -5451,7 +5448,9 @@ ras_job_error: · 3873 unmodified lines
54515448 bsg_reply->result = rc;
54525449
54535450 /* complete the job back to userspace */
5454− bsg_job_done(job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);
5451+ if (!rc)
5452+ bsg_job_done(job, bsg_reply->result,
5453+ bsg_reply->reply_payload_rcv_len);
54555454 return rc;
54565455 }
54575456
@@ -5530,8 +5529,9 @@ ras_job_error: · 72 unmodified lines
55305529 bsg_reply->result = rc;
55315530
55325531 /* complete the job back to userspace */
5533− bsg_job_done(job, bsg_reply->result,
5534− bsg_reply->reply_payload_rcv_len);
5532+ if (!rc)
5533+ bsg_job_done(job, bsg_reply->result,
5534+ bsg_reply->reply_payload_rcv_len);
55355535
55365536 return rc;
55375537 }
@@ -5591,7 +5591,9 @@ ras_job_error: · 53 unmodified lines
55915591 bsg_reply->result = rc;
55925592
55935593 /* complete the job back to userspace */
5594− bsg_job_done(job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);
5594+ if (!rc)
5595+ bsg_job_done(job, bsg_reply->result,
5596+ bsg_reply->reply_payload_rcv_len);
55955597
55965598 return rc;
55975599 }
@@ -5673,7 +5675,9 @@ lpfc_bsg_get_ras_fwlog(struct bsg_job *job) · 75 unmodified lines
56735675
56745676 ras_job_error:
56755677 bsg_reply->result = rc;
5676− bsg_job_done(job, bsg_reply->result, bsg_reply->reply_payload_rcv_len);
5678+ if (!rc)
5679+ bsg_job_done(job, bsg_reply->result,
5680+ bsg_reply->reply_payload_rcv_len);
56775681
56785682 return rc;
56795683 }
@@ -5744,8 +5748,9 @@ lpfc_get_trunk_info(struct bsg_job *job) · 64 unmodified lines
57445748 phba->sli4_hba.link_state.logical_speed / 1000;
57455749 job_error:
57465750 bsg_reply->result = rc;
5747− bsg_job_done(job, bsg_reply->result,
5748− bsg_reply->reply_payload_rcv_len);
5751+ if (!rc)
5752+ bsg_job_done(job, bsg_reply->result,
5753+ bsg_reply->reply_payload_rcv_len);
57495754 return rc;
57505755
57515756 }
drivers/scsi/lpfc/lpfc_crtn.h+2−11
@@ -326,7 +326,7 @@ void lpfc_sli_bemem_bcopy(void *, void *, uint32_t); · 325 unmodified lines
326326 void lpfc_sli_abort_iocb_ring(struct lpfc_hba *, struct lpfc_sli_ring *);
327327 void lpfc_sli_abort_fcp_rings(struct lpfc_hba *phba);
328328 void lpfc_sli_hba_iocb_abort(struct lpfc_hba *);
329−void lpfc_sli_flush_fcp_rings(struct lpfc_hba *);
329+void lpfc_sli_flush_io_rings(struct lpfc_hba *phba);
330330 int lpfc_sli_ringpostbuf_put(struct lpfc_hba *, struct lpfc_sli_ring *,
331331 struct lpfc_dmabuf *);
332332 struct lpfc_dmabuf *lpfc_sli_ringpostbuf_get(struct lpfc_hba *,
@@ -433,16 +433,6 @@ int lpfc_sli4_get_allocated_extnts(struct lpfc_hba *, uint16_t, · 100 unmodified lines
433433 int lpfc_sli4_get_avail_extnt_rsrc(struct lpfc_hba *, uint16_t,
434434 uint16_t *, uint16_t *);
435435
436−/* externs BlockGuard */
437−extern char *_dump_buf_data;
438−extern unsigned long _dump_buf_data_order;
439−extern char *_dump_buf_dif;
440−extern unsigned long _dump_buf_dif_order;
441−extern spinlock_t _dump_buf_lock;
442−extern int _dump_buf_done;
443−extern spinlock_t pgcnt_lock;
444−extern unsigned int pgcnt;
445−
446436 /* Interface exported by fabric iocb scheduler */
447437 void lpfc_fabric_abort_nport(struct lpfc_nodelist *);
448438 void lpfc_fabric_abort_hba(struct lpfc_hba *);
@@ -595,6 +585,7 @@ void lpfc_release_io_buf(struct lpfc_hba *phba, struct lpfc_io_buf *ncmd, · 146 unmodified lines
595585 struct lpfc_sli4_hdw_queue *qp);
596586 void lpfc_nvme_cmd_template(void);
597587 void lpfc_nvmet_cmd_template(void);
588+void lpfc_nvme_cancel_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn);
598589 extern int lpfc_enable_nvmet_cnt;
599590 extern unsigned long long lpfc_enable_nvmet[];
600591 extern int lpfc_no_hba_reset_cnt;
drivers/scsi/lpfc/lpfc_ct.c+53−15
@@ -462,6 +462,7 @@ lpfc_prep_node_fc4type(struct lpfc_vport *vport, uint32_t Did, uint8_t fc4_type) · 461 unmodified lines
462462 struct lpfc_nodelist *ndlp;
463463
464464 if ((vport->port_type != LPFC_NPIV_PORT) ||
465+ (fc4_type == FC_TYPE_FCP) ||
465466 !(vport->ct_flags & FC_CT_RFF_ID) || !vport->cfg_restrict_login) {
466467
467468 ndlp = lpfc_setup_disc_node(vport, Did);
@@ -480,10 +481,20 @@ lpfc_prep_node_fc4type(struct lpfc_vport *vport, uint32_t Did, uint8_t fc4_type) · 12 unmodified lines
480481
481482 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
482483 "0238 Process x%06x NameServer Rsp "
483− "Data: x%x x%x x%x x%x\n", Did,
484+ "Data: x%x x%x x%x x%x x%x\n", Did,
484485 ndlp->nlp_flag, ndlp->nlp_fc4_type,
485− vport->fc_flag,
486+ ndlp->nlp_state, vport->fc_flag,
486487 vport->fc_rscn_id_cnt);
488+
489+ /* if ndlp needs to be discovered and prior
490+ * state of ndlp hit devloss, change state to
491+ * allow rediscovery.
492+ */
493+ if (ndlp->nlp_flag & NLP_NPR_2B_DISC &&
494+ ndlp->nlp_state == NLP_STE_UNUSED_NODE) {
495+ lpfc_nlp_set_state(vport, ndlp,
496+ NLP_STE_NPR_NODE);
497+ }
487498 } else {
488499 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
489500 "Skip1 GID_FTrsp: did:x%x flg:x%x cnt:%d",
@@ -491,9 +502,9 @@ lpfc_prep_node_fc4type(struct lpfc_vport *vport, uint32_t Did, uint8_t fc4_type) · 1 unmodified line
491502
492503 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
493504 "0239 Skip x%06x NameServer Rsp "
494− "Data: x%x x%x\n", Did,
495− vport->fc_flag,
496− vport->fc_rscn_id_cnt);
505+ "Data: x%x x%x %p\n",
506+ Did, vport->fc_flag,
507+ vport->fc_rscn_id_cnt, ndlp);
497508 }
498509 } else {
499510 if (!(vport->fc_flag & FC_RSCN_MODE) ||
@@ -751,9 +762,11 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 251 unmodified lines
751762 if (CTrsp->CommandResponse.bits.CmdRsp ==
752763 cpu_to_be16(SLI_CT_RESPONSE_FS_ACC)) {
753764 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
754− "0208 NameServer Rsp Data: x%x x%x\n",
765+ "0208 NameServer Rsp Data: x%x x%x "
766+ "sz x%x\n",
755767 vport->fc_flag,
756− CTreq->un.gid.Fc4Type);
768+ CTreq->un.gid.Fc4Type,
769+ irsp->un.genreq64.bdl.bdeSize);
757770
758771 lpfc_ns_rsp(vport,
759772 outp,
@@ -814,6 +827,11 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 54 unmodified lines
814827 }
815828 vport->gidft_inp--;
816829 }
830+
831+ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
832+ "4216 GID_FT cmpl inp %d disc %d\n",
833+ vport->gidft_inp, vport->num_disc_nodes);
834+
817835 /* Link up / RSCN discovery */
818836 if ((vport->num_disc_nodes == 0) &&
819837 (vport->gidft_inp == 0)) {
@@ -1209,14 +1227,34 @@ lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 389 unmodified lines
12091227 if (fc4_data_1 & LPFC_FC4_TYPE_BITMASK)
12101228 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
12111229 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1212− "3064 Setting ndlp %p, DID x%06x with "
1213− "FC4 x%08x, Data: x%08x x%08x\n",
1230+ "3064 Setting ndlp x%px, DID x%06x "
1231+ "with FC4 x%08x, Data: x%08x x%08x "
1232+ "%d\n",
12141233 ndlp, did, ndlp->nlp_fc4_type,
1215− FC_TYPE_FCP, FC_TYPE_NVME);
1216− ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1217−
1218− lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
1219− lpfc_issue_els_prli(vport, ndlp, 0);
1234+ FC_TYPE_FCP, FC_TYPE_NVME,
1235+ ndlp->nlp_state);
1236+
1237+ if (ndlp->nlp_state == NLP_STE_REG_LOGIN_ISSUE &&
1238+ ndlp->nlp_fc4_type) {
1239+ ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1240+
1241+ lpfc_nlp_set_state(vport, ndlp,
1242+ NLP_STE_PRLI_ISSUE);
1243+ lpfc_issue_els_prli(vport, ndlp, 0);
1244+ } else if (!ndlp->nlp_fc4_type) {
1245+ /* If fc4 type is still unknown, then LOGO */
1246+ lpfc_printf_vlog(vport, KERN_INFO,
1247+ LOG_DISCOVERY,
1248+ "6443 Sending LOGO ndlp x%px,"
1249+ "DID x%06x with fc4_type: "
1250+ "x%08x, state: %d\n",
1251+ ndlp, did, ndlp->nlp_fc4_type,
1252+ ndlp->nlp_state);
1253+ lpfc_issue_els_logo(vport, ndlp, 0);
1254+ ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1255+ lpfc_nlp_set_state(vport, ndlp,
1256+ NLP_STE_NPR_NODE);
1257+ }
12201258 }
12211259 } else
12221260 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
@@ -2515,7 +2553,7 @@ lpfc_fdmi_port_attr_max_frame(struct lpfc_vport *vport, · 1292 unmodified lines
25152553 ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
25162554
25172555 hsp = (struct serv_parm *)&vport->fc_sparam;
2518− ae->un.AttrInt = (((uint32_t) hsp->cmn.bbRcvSizeMsb) << 8) |
2556+ ae->un.AttrInt = (((uint32_t) hsp->cmn.bbRcvSizeMsb & 0x0F) << 8) |
25192557 (uint32_t) hsp->cmn.bbRcvSizeLsb;
25202558 ae->un.AttrInt = cpu_to_be32(ae->un.AttrInt);
25212559 size = FOURBYTES + sizeof(uint32_t);
drivers/scsi/lpfc/lpfc_debugfs.c+12−216
@@ -361,7 +361,7 @@ lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size) · 360 unmodified lines
361361 phys = ((uint64_t)hbq_buf->dbuf.phys & 0xffffffff);
362362 if (phys == le32_to_cpu(hbqe->bde.addrLow)) {
363363 len += scnprintf(buf+len, size-len,
364− "Buf%d: %p %06x\n", i,
364+ "Buf%d: x%px %06x\n", i,
365365 hbq_buf->dbuf.virt, hbq_buf->tag);
366366 found = 1;
367367 break;
@@ -416,8 +416,7 @@ lpfc_debugfs_commonxripools_data(struct lpfc_hba *phba, char *buf, int size) · 48 unmodified lines
416416 qp = &phba->sli4_hba.hdwq[lpfc_debugfs_last_xripool];
417417
418418 len += scnprintf(buf + len, size - len, "HdwQ %d Info ", i);
419− spin_lock_irqsave(&qp->abts_scsi_buf_list_lock, iflag);
420− spin_lock(&qp->abts_nvme_buf_list_lock);
419+ spin_lock_irqsave(&qp->abts_io_buf_list_lock, iflag);
421420 spin_lock(&qp->io_buf_list_get_lock);
422421 spin_lock(&qp->io_buf_list_put_lock);
423422 out = qp->total_io_bufs - (qp->get_io_bufs + qp->put_io_bufs +
@@ -430,8 +429,7 @@ lpfc_debugfs_commonxripools_data(struct lpfc_hba *phba, char *buf, int size) · 6 unmodified lines
430429 qp->abts_nvme_io_bufs, out);
431430 spin_unlock(&qp->io_buf_list_put_lock);
432431 spin_unlock(&qp->io_buf_list_get_lock);
433− spin_unlock(&qp->abts_nvme_buf_list_lock);
434− spin_unlock_irqrestore(&qp->abts_scsi_buf_list_lock, iflag);
432+ spin_unlock_irqrestore(&qp->abts_io_buf_list_lock, iflag);
435433
436434 lpfc_debugfs_last_xripool++;
437435 if (lpfc_debugfs_last_xripool >= phba->cfg_hdw_queue)
@@ -533,9 +531,7 @@ lpfc_debugfs_multixripools_data(struct lpfc_hba *phba, char *buf, int size) · 95 unmodified lines
533531 continue;
534532 pbl_pool = &multixri_pool->pbl_pool;
535533 pvt_pool = &multixri_pool->pvt_pool;
536− txcmplq_cnt = qp->fcp_wq->pring->txcmplq_cnt;
537− if (qp->nvme_wq)
538− txcmplq_cnt += qp->nvme_wq->pring->txcmplq_cnt;
534+ txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt;
539535
540536 scnprintf(tmp, sizeof(tmp),
541537 "%03d: %4d %4d %4d %4d | %10d %10d ",
@@ -2166,89 +2162,6 @@ out: · 1624 unmodified lines
21662162 return rc;
21672163 }
21682164
2169−static int
2170−lpfc_debugfs_dumpData_open(struct inode *inode, struct file *file)
2171−{
2172− struct lpfc_debug *debug;
2173− int rc = -ENOMEM;
2174−
2175− if (!_dump_buf_data)
2176− return -EBUSY;
2177−
2178− debug = kmalloc(sizeof(*debug), GFP_KERNEL);
2179− if (!debug)
2180− goto out;
2181−
2182− /* Round to page boundary */
2183− pr_err("9059 BLKGRD: %s: _dump_buf_data=0x%p\n",
2184− __func__, _dump_buf_data);
2185− debug->buffer = _dump_buf_data;
2186− if (!debug->buffer) {
2187− kfree(debug);
2188− goto out;
2189− }
2190−
2191− debug->len = (1 << _dump_buf_data_order) << PAGE_SHIFT;
2192− file->private_data = debug;
2193−
2194− rc = 0;
2195−out:
2196− return rc;
2197−}
2198−
2199−static int
2200−lpfc_debugfs_dumpDif_open(struct inode *inode, struct file *file)
2201−{
2202− struct lpfc_debug *debug;
2203− int rc = -ENOMEM;
2204−
2205− if (!_dump_buf_dif)
2206− return -EBUSY;
2207−
2208− debug = kmalloc(sizeof(*debug), GFP_KERNEL);
2209− if (!debug)
2210− goto out;
2211−
2212− /* Round to page boundary */
2213− pr_err("9060 BLKGRD: %s: _dump_buf_dif=0x%p file=%pD\n",
2214− __func__, _dump_buf_dif, file);
2215− debug->buffer = _dump_buf_dif;
2216− if (!debug->buffer) {
2217− kfree(debug);
2218− goto out;
2219− }
2220−
2221− debug->len = (1 << _dump_buf_dif_order) << PAGE_SHIFT;
2222− file->private_data = debug;
2223−
2224− rc = 0;
2225−out:
2226− return rc;
2227−}
2228−
2229−static ssize_t
2230−lpfc_debugfs_dumpDataDif_write(struct file *file, const char __user *buf,
2231− size_t nbytes, loff_t *ppos)
2232−{
2233− /*
2234− * The Data/DIF buffers only save one failing IO
2235− * The write op is used as a reset mechanism after an IO has
2236− * already been saved to the next one can be saved
2237− */
2238− spin_lock(&_dump_buf_lock);
2239−
2240− memset((void *)_dump_buf_data, 0,
2241− ((1 << PAGE_SHIFT) << _dump_buf_data_order));
2242− memset((void *)_dump_buf_dif, 0,
2243− ((1 << PAGE_SHIFT) << _dump_buf_dif_order));
2244−
2245− _dump_buf_done = 0;
2246−
2247− spin_unlock(&_dump_buf_lock);
2248−
2249− return nbytes;
2250−}
2251−
22522165 static ssize_t
22532166 lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
22542167 size_t nbytes, loff_t *ppos)
@@ -2461,17 +2374,6 @@ lpfc_debugfs_release(struct inode *inode, struct file *file) · 206 unmodified lines
24612374 return 0;
24622375 }
24632376
2464−static int
2465−lpfc_debugfs_dumpDataDif_release(struct inode *inode, struct file *file)
2466−{
2467− struct lpfc_debug *debug = file->private_data;
2468−
2469− debug->buffer = NULL;
2470− kfree(debug);
2471−
2472− return 0;
2473−}
2474−
24752377 /**
24762378 * lpfc_debugfs_multixripools_write - Clear multi-XRI pools statistics
24772379 * @file: The file pointer to read from.
@@ -3786,23 +3688,13 @@ lpfc_idiag_wqs_for_cq(struct lpfc_hba *phba, char *wqtype, char *pbuffer, · 1308 unmodified lines
37863688 int qidx;
37873689
37883690 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) {
3789− qp = phba->sli4_hba.hdwq[qidx].fcp_wq;
3691+ qp = phba->sli4_hba.hdwq[qidx].io_wq;
37903692 if (qp->assoc_qid != cq_id)
37913693 continue;
37923694 *len = __lpfc_idiag_print_wq(qp, wqtype, pbuffer, *len);
37933695 if (*len >= max_cnt)
37943696 return 1;
37953697 }
3796− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
3797− for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) {
3798− qp = phba->sli4_hba.hdwq[qidx].nvme_wq;
3799− if (qp->assoc_qid != cq_id)
3800− continue;
3801− *len = __lpfc_idiag_print_wq(qp, wqtype, pbuffer, *len);
3802− if (*len >= max_cnt)
3803− return 1;
3804− }
3805− }
38063698 return 0;
38073699 }
38083700
@@ -3868,9 +3760,9 @@ lpfc_idiag_cqs_for_eq(struct lpfc_hba *phba, char *pbuffer, · 59 unmodified lines
38683760 struct lpfc_queue *qp;
38693761 int rc;
38703762
3871− qp = phba->sli4_hba.hdwq[eqidx].fcp_cq;
3763+ qp = phba->sli4_hba.hdwq[eqidx].io_cq;
38723764
3873− *len = __lpfc_idiag_print_cq(qp, "FCP", pbuffer, *len);
3765+ *len = __lpfc_idiag_print_cq(qp, "IO", pbuffer, *len);
38743766
38753767 /* Reset max counter */
38763768 qp->CQ_max_cqe = 0;
@@ -3878,28 +3770,11 @@ lpfc_idiag_cqs_for_eq(struct lpfc_hba *phba, char *pbuffer, · 1 unmodified line
38783770 if (*len >= max_cnt)
38793771 return 1;
38803772
3881− rc = lpfc_idiag_wqs_for_cq(phba, "FCP", pbuffer, len,
3773+ rc = lpfc_idiag_wqs_for_cq(phba, "IO", pbuffer, len,
38823774 max_cnt, qp->queue_id);
38833775 if (rc)
38843776 return 1;
38853777
3886− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
3887− qp = phba->sli4_hba.hdwq[eqidx].nvme_cq;
3888−
3889− *len = __lpfc_idiag_print_cq(qp, "NVME", pbuffer, *len);
3890−
3891− /* Reset max counter */
3892− qp->CQ_max_cqe = 0;
3893−
3894− if (*len >= max_cnt)
3895− return 1;
3896−
3897− rc = lpfc_idiag_wqs_for_cq(phba, "NVME", pbuffer, len,
3898− max_cnt, qp->queue_id);
3899− if (rc)
3900− return 1;
3901− }
3902−
39033778 if ((eqidx < phba->cfg_nvmet_mrq) && phba->nvmet_support) {
39043779 /* NVMET CQset */
39053780 qp = phba->sli4_hba.nvmet_cqset[eqidx];
@@ -4348,7 +4223,7 @@ lpfc_idiag_queacc_write(struct file *file, const char __user *buf, · 442 unmodified lines
43484223 if (phba->sli4_hba.hdwq) {
43494224 for (qidx = 0; qidx < phba->cfg_hdw_queue;
43504225 qidx++) {
4351− qp = phba->sli4_hba.hdwq[qidx].fcp_cq;
4226+ qp = phba->sli4_hba.hdwq[qidx].io_cq;
43524227 if (qp && qp->queue_id == queid) {
43534228 /* Sanity check */
43544229 rc = lpfc_idiag_que_param_check(
@@ -4360,22 +4235,6 @@ lpfc_idiag_queacc_write(struct file *file, const char __user *buf, · 5 unmodified lines
43604235 }
43614236 }
43624237 }
4363− /* NVME complete queue */
4364− if (phba->sli4_hba.hdwq) {
4365− qidx = 0;
4366− do {
4367− qp = phba->sli4_hba.hdwq[qidx].nvme_cq;
4368− if (qp && qp->queue_id == queid) {
4369− /* Sanity check */
4370− rc = lpfc_idiag_que_param_check(
4371− qp, index, count);
4372− if (rc)
4373− goto error_out;
4374− idiag.ptr_private = qp;
4375− goto pass_check;
4376− }
4377− } while (++qidx < phba->cfg_hdw_queue);
4378− }
43794238 goto error_out;
43804239 break;
43814240 case LPFC_IDIAG_MQ:
@@ -4419,20 +4278,7 @@ lpfc_idiag_queacc_write(struct file *file, const char __user *buf, · 37 unmodified lines
44194278 if (phba->sli4_hba.hdwq) {
44204279 /* FCP/SCSI work queue */
44214280 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) {
4422− qp = phba->sli4_hba.hdwq[qidx].fcp_wq;
4423− if (qp && qp->queue_id == queid) {
4424− /* Sanity check */
4425− rc = lpfc_idiag_que_param_check(
4426− qp, index, count);
4427− if (rc)
4428− goto error_out;
4429− idiag.ptr_private = qp;
4430− goto pass_check;
4431− }
4432− }
4433− /* NVME work queue */
4434− for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) {
4435− qp = phba->sli4_hba.hdwq[qidx].nvme_wq;
4281+ qp = phba->sli4_hba.hdwq[qidx].io_wq;
44364282 if (qp && qp->queue_id == queid) {
44374283 /* Sanity check */
44384284 rc = lpfc_idiag_que_param_check(
@@ -5508,26 +5354,6 @@ static const struct file_operations lpfc_debugfs_op_cpucheck = { · 1069 unmodified lines
55085354 .release = lpfc_debugfs_release,
55095355 };
55105356
5511−#undef lpfc_debugfs_op_dumpData
5512−static const struct file_operations lpfc_debugfs_op_dumpData = {
5513− .owner = THIS_MODULE,
5514− .open = lpfc_debugfs_dumpData_open,
5515− .llseek = lpfc_debugfs_lseek,
5516− .read = lpfc_debugfs_read,
5517− .write = lpfc_debugfs_dumpDataDif_write,
5518− .release = lpfc_debugfs_dumpDataDif_release,
5519−};
5520−
5521−#undef lpfc_debugfs_op_dumpDif
5522−static const struct file_operations lpfc_debugfs_op_dumpDif = {
5523− .owner = THIS_MODULE,
5524− .open = lpfc_debugfs_dumpDif_open,
5525− .llseek = lpfc_debugfs_lseek,
5526− .read = lpfc_debugfs_read,
5527− .write = lpfc_debugfs_dumpDataDif_write,
5528− .release = lpfc_debugfs_dumpDataDif_release,
5529−};
5530−
55315357 #undef lpfc_debugfs_op_dif_err
55325358 static const struct file_operations lpfc_debugfs_op_dif_err = {
55335359 .owner = THIS_MODULE,
@@ -5924,20 +5750,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) · 390 unmodified lines
59245750 } else
59255751 phba->debug_dumpHostSlim = NULL;
59265752
5927− /* Setup dumpData */
5928− snprintf(name, sizeof(name), "dumpData");
5929− phba->debug_dumpData =
5930− debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
5931− phba->hba_debugfs_root,
5932− phba, &lpfc_debugfs_op_dumpData);
5933−
5934− /* Setup dumpDif */
5935− snprintf(name, sizeof(name), "dumpDif");
5936− phba->debug_dumpDif =
5937− debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
5938− phba->hba_debugfs_root,
5939− phba, &lpfc_debugfs_op_dumpDif);
5940−
59415753 /* Setup DIF Error Injections */
59425754 snprintf(name, sizeof(name), "InjErrLBA");
59435755 phba->debug_InjErrLBA =
@@ -6315,12 +6127,6 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport) · 371 unmodified lines
63156127 debugfs_remove(phba->debug_dumpHostSlim); /* HostSlim */
63166128 phba->debug_dumpHostSlim = NULL;
63176129
6318− debugfs_remove(phba->debug_dumpData); /* dumpData */
6319− phba->debug_dumpData = NULL;
6320−
6321− debugfs_remove(phba->debug_dumpDif); /* dumpDif */
6322− phba->debug_dumpDif = NULL;
6323−
63246130 debugfs_remove(phba->debug_InjErrLBA); /* InjErrLBA */
63256131 phba->debug_InjErrLBA = NULL;
63266132
@@ -6442,12 +6248,7 @@ lpfc_debug_dump_all_queues(struct lpfc_hba *phba) · 115 unmodified lines
64426248 lpfc_debug_dump_wq(phba, DUMP_NVMELS, 0);
64436249
64446250 for (idx = 0; idx < phba->cfg_hdw_queue; idx++)
6445− lpfc_debug_dump_wq(phba, DUMP_FCP, idx);
6446−
6447− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
6448− for (idx = 0; idx < phba->cfg_hdw_queue; idx++)
6449− lpfc_debug_dump_wq(phba, DUMP_NVME, idx);
6450− }
6251+ lpfc_debug_dump_wq(phba, DUMP_IO, idx);
64516252
64526253 lpfc_debug_dump_hdr_rq(phba);
64536254 lpfc_debug_dump_dat_rq(phba);
@@ -6459,12 +6260,7 @@ lpfc_debug_dump_all_queues(struct lpfc_hba *phba) · 5 unmodified lines
64596260 lpfc_debug_dump_cq(phba, DUMP_NVMELS, 0);
64606261
64616262 for (idx = 0; idx < phba->cfg_hdw_queue; idx++)
6462− lpfc_debug_dump_cq(phba, DUMP_FCP, idx);
6463−
6464− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
6465− for (idx = 0; idx < phba->cfg_hdw_queue; idx++)
6466− lpfc_debug_dump_cq(phba, DUMP_NVME, idx);
6467− }
6263+ lpfc_debug_dump_cq(phba, DUMP_IO, idx);
64686264
64696265 /*
64706266 * Dump Event Queues (EQs)
drivers/scsi/lpfc/lpfc_debugfs.h+17−44
@@ -291,8 +291,7 @@ struct lpfc_idiag { · 290 unmodified lines
291291 #define LPFC_DUMP_MULTIXRIPOOL_SIZE 8192
292292
293293 enum {
294− DUMP_FCP,
295− DUMP_NVME,
294+ DUMP_IO,
296295 DUMP_MBX,
297296 DUMP_ELS,
298297 DUMP_NVMELS,
@@ -415,12 +414,9 @@ lpfc_debug_dump_wq(struct lpfc_hba *phba, int qtype, int wqidx) · 116 unmodified lines
415414 struct lpfc_queue *wq;
416415 char *qtypestr;
417416
418− if (qtype == DUMP_FCP) {
419− wq = phba->sli4_hba.hdwq[wqidx].fcp_wq;
420− qtypestr = "FCP";
421− } else if (qtype == DUMP_NVME) {
422− wq = phba->sli4_hba.hdwq[wqidx].nvme_wq;
423− qtypestr = "NVME";
417+ if (qtype == DUMP_IO) {
418+ wq = phba->sli4_hba.hdwq[wqidx].io_wq;
419+ qtypestr = "IO";
424420 } else if (qtype == DUMP_MBX) {
425421 wq = phba->sli4_hba.mbx_wq;
426422 qtypestr = "MBX";
@@ -433,7 +429,7 @@ lpfc_debug_dump_wq(struct lpfc_hba *phba, int qtype, int wqidx) · 6 unmodified lines
433429 } else
434430 return;
435431
436− if (qtype == DUMP_FCP || qtype == DUMP_NVME)
432+ if (qtype == DUMP_IO)
437433 pr_err("%s WQ: WQ[Idx:%d|Qid:%d]\n",
438434 qtypestr, wqidx, wq->queue_id);
439435 else
@@ -459,17 +455,13 @@ lpfc_debug_dump_cq(struct lpfc_hba *phba, int qtype, int wqidx) · 19 unmodified lines
459455 char *qtypestr;
460456 int eqidx;
461457
462− /* fcp/nvme wq and cq are 1:1, thus same indexes */
458+ /* io wq and cq are 1:1, thus same indexes */
463459 eq = NULL;
464460
465− if (qtype == DUMP_FCP) {
466− wq = phba->sli4_hba.hdwq[wqidx].fcp_wq;
467− cq = phba->sli4_hba.hdwq[wqidx].fcp_cq;
468− qtypestr = "FCP";
469− } else if (qtype == DUMP_NVME) {
470− wq = phba->sli4_hba.hdwq[wqidx].nvme_wq;
471− cq = phba->sli4_hba.hdwq[wqidx].nvme_cq;
472− qtypestr = "NVME";
461+ if (qtype == DUMP_IO) {
462+ wq = phba->sli4_hba.hdwq[wqidx].io_wq;
463+ cq = phba->sli4_hba.hdwq[wqidx].io_cq;
464+ qtypestr = "IO";
473465 } else if (qtype == DUMP_MBX) {
474466 wq = phba->sli4_hba.mbx_wq;
475467 cq = phba->sli4_hba.mbx_cq;
@@ -496,7 +488,7 @@ lpfc_debug_dump_cq(struct lpfc_hba *phba, int qtype, int wqidx) · 20 unmodified lines
496488 eq = phba->sli4_hba.hdwq[0].hba_eq;
497489 }
498490
499− if (qtype == DUMP_FCP || qtype == DUMP_NVME)
491+ if (qtype == DUMP_IO)
500492 pr_err("%s CQ: WQ[Idx:%d|Qid%d]->CQ[Idx%d|Qid%d]"
501493 "->EQ[Idx:%d|Qid:%d]:\n",
502494 qtypestr, wqidx, wq->queue_id, wqidx, cq->queue_id,
@@ -572,20 +564,11 @@ lpfc_debug_dump_wq_by_id(struct lpfc_hba *phba, int qid) · 69 unmodified lines
572564 int wq_idx;
573565
574566 for (wq_idx = 0; wq_idx < phba->cfg_hdw_queue; wq_idx++)
575− if (phba->sli4_hba.hdwq[wq_idx].fcp_wq->queue_id == qid)
567+ if (phba->sli4_hba.hdwq[wq_idx].io_wq->queue_id == qid)
576568 break;
577569 if (wq_idx < phba->cfg_hdw_queue) {
578− pr_err("FCP WQ[Idx:%d|Qid:%d]\n", wq_idx, qid);
579− lpfc_debug_dump_q(phba->sli4_hba.hdwq[wq_idx].fcp_wq);
580− return;
581− }
582−
583− for (wq_idx = 0; wq_idx < phba->cfg_hdw_queue; wq_idx++)
584− if (phba->sli4_hba.hdwq[wq_idx].nvme_wq->queue_id == qid)
585− break;
586− if (wq_idx < phba->cfg_hdw_queue) {
587− pr_err("NVME WQ[Idx:%d|Qid:%d]\n", wq_idx, qid);
588− lpfc_debug_dump_q(phba->sli4_hba.hdwq[wq_idx].nvme_wq);
570+ pr_err("IO WQ[Idx:%d|Qid:%d]\n", wq_idx, qid);
571+ lpfc_debug_dump_q(phba->sli4_hba.hdwq[wq_idx].io_wq);
589572 return;
590573 }
591574
@@ -654,22 +637,12 @@ lpfc_debug_dump_cq_by_id(struct lpfc_hba *phba, int qid) · 62 unmodified lines
654637 int cq_idx;
655638
656639 for (cq_idx = 0; cq_idx < phba->cfg_hdw_queue; cq_idx++)
657− if (phba->sli4_hba.hdwq[cq_idx].fcp_cq->queue_id == qid)
658− break;
659−
660− if (cq_idx < phba->cfg_hdw_queue) {
661− pr_err("FCP CQ[Idx:%d|Qid:%d]\n", cq_idx, qid);
662− lpfc_debug_dump_q(phba->sli4_hba.hdwq[cq_idx].fcp_cq);
663− return;
664− }
665−
666− for (cq_idx = 0; cq_idx < phba->cfg_hdw_queue; cq_idx++)
667− if (phba->sli4_hba.hdwq[cq_idx].nvme_cq->queue_id == qid)
640+ if (phba->sli4_hba.hdwq[cq_idx].io_cq->queue_id == qid)
668641 break;
669642
670643 if (cq_idx < phba->cfg_hdw_queue) {
671− pr_err("NVME CQ[Idx:%d|Qid:%d]\n", cq_idx, qid);
672− lpfc_debug_dump_q(phba->sli4_hba.hdwq[cq_idx].nvme_cq);
644+ pr_err("IO CQ[Idx:%d|Qid:%d]\n", cq_idx, qid);
645+ lpfc_debug_dump_q(phba->sli4_hba.hdwq[cq_idx].io_cq);
673646 return;
674647 }
675648
drivers/scsi/lpfc/lpfc_disc.h+3−0
@@ -112,6 +112,8 @@ struct lpfc_nodelist { · 111 unmodified lines
112112 uint8_t nlp_retry; /* used for ELS retries */
113113 uint8_t nlp_fcp_info; /* class info, bits 0-3 */
114114 #define NLP_FCP_2_DEVICE 0x10 /* FCP-2 device */
115+ u8 nlp_nvme_info; /* NVME NSLER Support */
116+#define NLP_NVME_NSLER 0x1 /* NVME NSLER device */
115117
116118 uint16_t nlp_usg_map; /* ndlp management usage bitmap */
117119 #define NLP_USG_NODE_ACT_BIT 0x1 /* Indicate ndlp is actively used */
@@ -157,6 +159,7 @@ struct lpfc_node_rrq { · 39 unmodified lines
157159 /* Defines for nlp_flag (uint32) */
158160 #define NLP_IGNR_REG_CMPL 0x00000001 /* Rcvd rscn before we cmpl reg login */
159161 #define NLP_REG_LOGIN_SEND 0x00000002 /* sent reglogin to adapter */
162+#define NLP_RELEASE_RPI 0x00000004 /* Release RPI to free pool */
160163 #define NLP_SUPPRESS_RSP 0x00000010 /* Remote NPort supports suppress rsp */
161164 #define NLP_PLOGI_SND 0x00000020 /* sent PLOGI request for this entry */
162165 #define NLP_PRLI_SND 0x00000040 /* sent PRLI request for this entry */
drivers/scsi/lpfc/lpfc_els.c+99−17
@@ -1052,17 +1052,18 @@ stop_rr_fcf_flogi: · 1051 unmodified lines
10521052 if (lpfc_els_retry(phba, cmdiocb, rspiocb))
10531053 goto out;
10541054
1055+ lpfc_printf_vlog(vport, KERN_WARNING, LOG_ELS,
1056+ "0150 FLOGI failure Status:x%x/x%x "
1057+ "xri x%x TMO:x%x\n",
1058+ irsp->ulpStatus, irsp->un.ulpWord[4],
1059+ cmdiocb->sli4_xritag, irsp->ulpTimeout);
1060+
10551061 /* If this is not a loop open failure, bail out */
10561062 if (!(irsp->ulpStatus == IOSTAT_LOCAL_REJECT &&
10571063 ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) ==
10581064 IOERR_LOOP_OPEN_FAILURE)))
10591065 goto flogifail;
10601066
1061− lpfc_printf_vlog(vport, KERN_WARNING, LOG_ELS,
1062− "0150 FLOGI failure Status:x%x/x%x xri x%x TMO:x%x\n",
1063− irsp->ulpStatus, irsp->un.ulpWord[4],
1064− cmdiocb->sli4_xritag, irsp->ulpTimeout);
1065−
10661067 /* FLOGI failed, so there is no fabric */
10671068 spin_lock_irq(shost->host_lock);
10681069 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
@@ -1206,6 +1207,39 @@ out: · 137 unmodified lines
12061207 lpfc_els_free_iocb(phba, cmdiocb);
12071208 }
12081209
1210+/**
1211+ * lpfc_cmpl_els_link_down - Completion callback function for ELS command
1212+ * aborted during a link down
1213+ * @phba: pointer to lpfc hba data structure.
1214+ * @cmdiocb: pointer to lpfc command iocb data structure.
1215+ * @rspiocb: pointer to lpfc response iocb data structure.
1216+ *
1217+ */
1218+static void
1219+lpfc_cmpl_els_link_down(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1220+ struct lpfc_iocbq *rspiocb)
1221+{
1222+ IOCB_t *irsp;
1223+ uint32_t *pcmd;
1224+ uint32_t cmd;
1225+
1226+ pcmd = (uint32_t *)(((struct lpfc_dmabuf *)cmdiocb->context2)->virt);
1227+ cmd = *pcmd;
1228+ irsp = &rspiocb->iocb;
1229+
1230+ lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
1231+ "6445 ELS completes after LINK_DOWN: "
1232+ " Status %x/%x cmd x%x flg x%x\n",
1233+ irsp->ulpStatus, irsp->un.ulpWord[4], cmd,
1234+ cmdiocb->iocb_flag);
1235+
1236+ if (cmdiocb->iocb_flag & LPFC_IO_FABRIC) {
1237+ cmdiocb->iocb_flag &= ~LPFC_IO_FABRIC;
1238+ atomic_dec(&phba->fabric_iocb_count);
1239+ }
1240+ lpfc_els_free_iocb(phba, cmdiocb);
1241+}
1242+
12091243 /**
12101244 * lpfc_issue_els_flogi - Issue an flogi iocb command for a vport
12111245 * @vport: pointer to a host virtual N_Port data structure.
@@ -2107,7 +2141,7 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) · 895 unmodified lines
21072141 !(vport->fc_flag & FC_OFFLINE_MODE)) {
21082142 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
21092143 "4110 Issue PLOGI x%x deferred "
2110− "on NPort x%x rpi x%x Data: %p\n",
2144+ "on NPort x%x rpi x%x Data: x%px\n",
21112145 ndlp->nlp_defer_did, ndlp->nlp_DID,
21122146 ndlp->nlp_rpi, ndlp);
21132147
@@ -2401,6 +2435,10 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 287 unmodified lines
24012435 npr_nvme = (struct lpfc_nvme_prli *)pcmd;
24022436 bf_set(prli_type_code, npr_nvme, PRLI_NVME_TYPE);
24032437 bf_set(prli_estabImagePair, npr_nvme, 0); /* Should be 0 */
2438+ if (phba->nsler) {
2439+ bf_set(prli_nsler, npr_nvme, 1);
2440+ bf_set(prli_conf, npr_nvme, 1);
2441+ }
24042442
24052443 /* Only initiators request first burst. */
24062444 if ((phba->cfg_nvme_enable_fb) &&
@@ -4203,7 +4241,7 @@ lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 1796 unmodified lines
42034241 mempool_free(pmb, phba->mbox_mem_pool);
42044242 if (ndlp) {
42054243 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE,
4206− "0006 rpi%x DID:%x flg:%x %d map:%x %p\n",
4244+ "0006 rpi%x DID:%x flg:%x %d map:%x x%px\n",
42074245 ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag,
42084246 kref_read(&ndlp->kref),
42094247 ndlp->nlp_usg_map, ndlp);
@@ -5634,16 +5672,16 @@ lpfc_rdp_res_attach_port_names(struct fc_rdp_port_name_desc *desc, · 1424 unmodified lines
56345672 desc->tag = cpu_to_be32(RDP_PORT_NAMES_DESC_TAG);
56355673 if (vport->fc_flag & FC_FABRIC) {
56365674 memcpy(desc->port_names.wwnn, &vport->fabric_nodename,
5637− sizeof(desc->port_names.wwnn));
5675+ sizeof(desc->port_names.wwnn));
56385676
56395677 memcpy(desc->port_names.wwpn, &vport->fabric_portname,
5640− sizeof(desc->port_names.wwpn));
5678+ sizeof(desc->port_names.wwpn));
56415679 } else { /* Point to Point */
56425680 memcpy(desc->port_names.wwnn, &ndlp->nlp_nodename,
5643− sizeof(desc->port_names.wwnn));
5681+ sizeof(desc->port_names.wwnn));
56445682
5645− memcpy(desc->port_names.wwnn, &ndlp->nlp_portname,
5646− sizeof(desc->port_names.wwpn));
5683+ memcpy(desc->port_names.wwpn, &ndlp->nlp_portname,
5684+ sizeof(desc->port_names.wwpn));
56475685 }
56485686
56495687 desc->length = cpu_to_be32(sizeof(desc->port_names));
@@ -6327,7 +6365,11 @@ lpfc_rscn_recovery_check(struct lpfc_vport *vport) · 677 unmodified lines
63276365 continue;
63286366 }
63296367
6330− if (ndlp->nlp_fc4_type & NLP_FC4_NVME)
6368+ /* Check to see if we need to NVME rescan this target
6369+ * remoteport.
6370+ */
6371+ if (ndlp->nlp_fc4_type & NLP_FC4_NVME &&
6372+ ndlp->nlp_type & (NLP_NVME_TARGET | NLP_NVME_DISCOVERY))
63316373 lpfc_nvme_rescan_port(vport, ndlp);
63326374
63336375 lpfc_disc_state_machine(vport, ndlp, NULL,
@@ -6441,7 +6483,11 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 107 unmodified lines
64416483 *lp, vport->fc_flag, payload_len);
64426484 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
64436485
6444− if (ndlp->nlp_fc4_type & NLP_FC4_NVME)
6486+ /* Check to see if we need to NVME rescan this target
6487+ * remoteport.
6488+ */
6489+ if (ndlp->nlp_fc4_type & NLP_FC4_NVME &&
6490+ ndlp->nlp_type & (NLP_NVME_TARGET | NLP_NVME_DISCOVERY))
64456491 lpfc_nvme_rescan_port(vport, ndlp);
64466492 return 0;
64476493 }
@@ -7960,18 +8006,40 @@ lpfc_els_flush_cmd(struct lpfc_vport *vport) · 1512 unmodified lines
79608006 if (phba->sli_rev == LPFC_SLI_REV4)
79618007 spin_lock(&pring->ring_lock);
79628008
8009+ /* First we need to issue aborts to outstanding cmds on txcmpl */
79638010 list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) {
79648011 if (piocb->iocb_flag & LPFC_IO_LIBDFC)
79658012 continue;
79668013
79678014 if (piocb->vport != vport)
79688015 continue;
7969− list_add_tail(&piocb->dlist, &abort_list);
8016+
8017+ /* On the ELS ring we can have ELS_REQUESTs or
8018+ * GEN_REQUESTs waiting for a response.
8019+ */
8020+ cmd = &piocb->iocb;
8021+ if (cmd->ulpCommand == CMD_ELS_REQUEST64_CR) {
8022+ list_add_tail(&piocb->dlist, &abort_list);
8023+
8024+ /* If the link is down when flushing ELS commands
8025+ * the firmware will not complete them till after
8026+ * the link comes back up. This may confuse
8027+ * discovery for the new link up, so we need to
8028+ * change the compl routine to just clean up the iocb
8029+ * and avoid any retry logic.
8030+ */
8031+ if (phba->link_state == LPFC_LINK_DOWN)
8032+ piocb->iocb_cmpl = lpfc_cmpl_els_link_down;
8033+ }
8034+ if (cmd->ulpCommand == CMD_GEN_REQUEST64_CR)
8035+ list_add_tail(&piocb->dlist, &abort_list);
79708036 }
8037+
79718038 if (phba->sli_rev == LPFC_SLI_REV4)
79728039 spin_unlock(&pring->ring_lock);
79738040 spin_unlock_irq(&phba->hbalock);
7974− /* Abort each iocb on the aborted list and remove the dlist links. */
8041+
8042+ /* Abort each txcmpl iocb on aborted list and remove the dlist links. */
79758043 list_for_each_entry_safe(piocb, tmp_iocb, &abort_list, dlist) {
79768044 spin_lock_irq(&phba->hbalock);
79778045 list_del_init(&piocb->dlist);
@@ -7987,6 +8055,9 @@ lpfc_els_flush_cmd(struct lpfc_vport *vport) · 9 unmodified lines
79878055 if (phba->sli_rev == LPFC_SLI_REV4)
79888056 spin_lock(&pring->ring_lock);
79898057
8058+ /* No need to abort the txq list,
8059+ * just queue them up for lpfc_sli_cancel_iocbs
8060+ */
79908061 list_for_each_entry_safe(piocb, tmp_iocb, &pring->txq, list) {
79918062 cmd = &piocb->iocb;
79928063
@@ -8007,11 +8078,22 @@ lpfc_els_flush_cmd(struct lpfc_vport *vport) · 14 unmodified lines
80078078 list_del_init(&piocb->list);
80088079 list_add_tail(&piocb->list, &abort_list);
80098080 }
8081+
8082+ /* The same holds true for any FLOGI/FDISC on the fabric_iocb_list */
8083+ if (vport == phba->pport) {
8084+ list_for_each_entry_safe(piocb, tmp_iocb,
8085+ &phba->fabric_iocb_list, list) {
8086+ cmd = &piocb->iocb;
8087+ list_del_init(&piocb->list);
8088+ list_add_tail(&piocb->list, &abort_list);
8089+ }
8090+ }
8091+
80108092 if (phba->sli_rev == LPFC_SLI_REV4)
80118093 spin_unlock(&pring->ring_lock);
80128094 spin_unlock_irq(&phba->hbalock);
80138095
8014− /* Cancell all the IOCBs from the completions list */
8096+ /* Cancel all the IOCBs from the completions list */
80158097 lpfc_sli_cancel_iocbs(phba, &abort_list,
80168098 IOSTAT_LOCAL_REJECT, IOERR_SLI_ABORTED);
80178099
drivers/scsi/lpfc/lpfc_hbadisc.c+109−72
@@ -118,6 +118,7 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) · 117 unmodified lines
118118 struct lpfc_work_evt *evtp;
119119 int put_node;
120120 int put_rport;
121+ unsigned long iflags;
121122
122123 rdata = rport->dd_data;
123124 ndlp = rdata->pnode;
@@ -132,7 +133,7 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) · 8 unmodified lines
132133 ndlp->nlp_sid, ndlp->nlp_DID, ndlp->nlp_flag);
133134
134135 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE,
135− "3181 dev_loss_callbk x%06x, rport %p flg x%x\n",
136+ "3181 dev_loss_callbk x%06x, rport x%px flg x%x\n",
136137 ndlp->nlp_DID, ndlp->rport, ndlp->nlp_flag);
137138
138139 /* Don't defer this if we are in the process of deleting the vport
@@ -170,22 +171,22 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) · 31 unmodified lines
170171 }
171172
172173 shost = lpfc_shost_from_vport(vport);
173− spin_lock_irq(shost->host_lock);
174+ spin_lock_irqsave(shost->host_lock, iflags);
174175 ndlp->nlp_flag |= NLP_IN_DEV_LOSS;
175− spin_unlock_irq(shost->host_lock);
176+ spin_unlock_irqrestore(shost->host_lock, iflags);
176177
177178 /* We need to hold the node by incrementing the reference
178179 * count until this queued work is done
179180 */
180181 evtp->evt_arg1 = lpfc_nlp_get(ndlp);
181182
182− spin_lock_irq(&phba->hbalock);
183+ spin_lock_irqsave(&phba->hbalock, iflags);
183184 if (evtp->evt_arg1) {
184185 evtp->evt = LPFC_EVT_DEV_LOSS;
185186 list_add_tail(&evtp->evt_listp, &phba->work_list);
186187 lpfc_worker_wake_up(phba);
187188 }
188− spin_unlock_irq(&phba->hbalock);
189+ spin_unlock_irqrestore(&phba->hbalock, iflags);
189190
190191 return;
191192 }
@@ -212,14 +213,15 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) · 20 unmodified lines
212213 int put_node;
213214 int warn_on = 0;
214215 int fcf_inuse = 0;
216+ unsigned long iflags;
215217
216218 rport = ndlp->rport;
217219 vport = ndlp->vport;
218220 shost = lpfc_shost_from_vport(vport);
219221
220− spin_lock_irq(shost->host_lock);
222+ spin_lock_irqsave(shost->host_lock, iflags);
221223 ndlp->nlp_flag &= ~NLP_IN_DEV_LOSS;
222− spin_unlock_irq(shost->host_lock);
224+ spin_unlock_irqrestore(shost->host_lock, iflags);
223225
224226 if (!rport)
225227 return fcf_inuse;
@@ -235,7 +237,7 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) · 9 unmodified lines
235237 ndlp->nlp_DID, ndlp->nlp_type, rport->scsi_target_id);
236238
237239 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE,
238− "3182 dev_loss_tmo_handler x%06x, rport %p flg x%x\n",
240+ "3182 dev_loss_tmo_handler x%06x, rport x%px flg x%x\n",
239241 ndlp->nlp_DID, ndlp->rport, ndlp->nlp_flag);
240242
241243 /*
@@ -903,6 +905,8 @@ lpfc_linkdown(struct lpfc_hba *phba) · 661 unmodified lines
903905 phba->trunk_link.link1.state = 0;
904906 phba->trunk_link.link2.state = 0;
905907 phba->trunk_link.link3.state = 0;
908+ phba->sli4_hba.link_state.logical_speed =
909+ LPFC_LINK_SPEED_UNKNOWN;
906910 }
907911 spin_lock_irq(shost->host_lock);
908912 phba->pport->fc_flag &= ~FC_LBIT;
@@ -3115,8 +3119,9 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la) · 2206 unmodified lines
31153119 int rc;
31163120 struct fcf_record *fcf_record;
31173121 uint32_t fc_flags = 0;
3122+ unsigned long iflags;
31183123
3119− spin_lock_irq(&phba->hbalock);
3124+ spin_lock_irqsave(&phba->hbalock, iflags);
31203125 phba->fc_linkspeed = bf_get(lpfc_mbx_read_top_link_spd, la);
31213126
31223127 if (!(phba->hba_flag & HBA_FCOE_MODE)) {
@@ -3213,12 +3218,12 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la) · 90 unmodified lines
32133218 vport->fc_myDID = phba->fc_pref_DID;
32143219 fc_flags |= FC_LBIT;
32153220 }
3216− spin_unlock_irq(&phba->hbalock);
3221+ spin_unlock_irqrestore(&phba->hbalock, iflags);
32173222
32183223 if (fc_flags) {
3219− spin_lock_irq(shost->host_lock);
3224+ spin_lock_irqsave(shost->host_lock, iflags);
32203225 vport->fc_flag |= fc_flags;
3221− spin_unlock_irq(shost->host_lock);
3226+ spin_unlock_irqrestore(shost->host_lock, iflags);
32223227 }
32233228
32243229 lpfc_linkup(phba);
@@ -3292,22 +3297,22 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la) · 67 unmodified lines
32923297 * The driver is expected to do FIP/FCF. Call the port
32933298 * and get the FCF Table.
32943299 */
3295− spin_lock_irq(&phba->hbalock);
3300+ spin_lock_irqsave(&phba->hbalock, iflags);
32963301 if (phba->hba_flag & FCF_TS_INPROG) {
3297− spin_unlock_irq(&phba->hbalock);
3302+ spin_unlock_irqrestore(&phba->hbalock, iflags);
32983303 return;
32993304 }
33003305 /* This is the initial FCF discovery scan */
33013306 phba->fcf.fcf_flag |= FCF_INIT_DISC;
3302− spin_unlock_irq(&phba->hbalock);
3307+ spin_unlock_irqrestore(&phba->hbalock, iflags);
33033308 lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY,
33043309 "2778 Start FCF table scan at linkup\n");
33053310 rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba,
33063311 LPFC_FCOE_FCF_GET_FIRST);
33073312 if (rc) {
3308− spin_lock_irq(&phba->hbalock);
3313+ spin_lock_irqsave(&phba->hbalock, iflags);
33093314 phba->fcf.fcf_flag &= ~FCF_INIT_DISC;
3310− spin_unlock_irq(&phba->hbalock);
3315+ spin_unlock_irqrestore(&phba->hbalock, iflags);
33113316 goto out;
33123317 }
33133318 /* Reset FCF roundrobin bmask for new discovery */
@@ -3318,7 +3323,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la) · 4 unmodified lines
33183323 out:
33193324 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
33203325 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
3321− "0263 Discovery Mailbox error: state: 0x%x : %p %p\n",
3326+ "0263 Discovery Mailbox error: state: 0x%x : x%px x%px\n",
33223327 vport->port_state, sparam_mbox, cfglink_mbox);
33233328 lpfc_issue_clear_la(phba, vport);
33243329 return;
@@ -3366,6 +3371,7 @@ lpfc_mbx_cmpl_read_topology(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 41 unmodified lines
33663371 MAILBOX_t *mb = &pmb->u.mb;
33673372 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);
33683373 uint8_t attn_type;
3374+ unsigned long iflags;
33693375
33703376 /* Unblock ELS traffic */
33713377 pring = lpfc_phba_elsring(phba);
@@ -3387,12 +3393,12 @@ lpfc_mbx_cmpl_read_topology(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 15 unmodified lines
33873393
33883394 memcpy(&phba->alpa_map[0], mp->virt, 128);
33893395
3390− spin_lock_irq(shost->host_lock);
3396+ spin_lock_irqsave(shost->host_lock, iflags);
33913397 if (bf_get(lpfc_mbx_read_top_pb, la))
33923398 vport->fc_flag |= FC_BYPASSED_MODE;
33933399 else
33943400 vport->fc_flag &= ~FC_BYPASSED_MODE;
3395− spin_unlock_irq(shost->host_lock);
3401+ spin_unlock_irqrestore(shost->host_lock, iflags);
33963402
33973403 if (phba->fc_eventTag <= la->eventTag) {
33983404 phba->fc_stat.LinkMultiEvent++;
@@ -3403,12 +3409,12 @@ lpfc_mbx_cmpl_read_topology(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 4 unmodified lines
34033409
34043410 phba->fc_eventTag = la->eventTag;
34053411 if (phba->sli_rev < LPFC_SLI_REV4) {
3406− spin_lock_irq(&phba->hbalock);
3412+ spin_lock_irqsave(&phba->hbalock, iflags);
34073413 if (bf_get(lpfc_mbx_read_top_mm, la))
34083414 phba->sli.sli_flag |= LPFC_MENLO_MAINT;
34093415 else
34103416 phba->sli.sli_flag &= ~LPFC_MENLO_MAINT;
3411− spin_unlock_irq(&phba->hbalock);
3417+ spin_unlock_irqrestore(&phba->hbalock, iflags);
34123418 }
34133419
34143420 phba->link_events++;
@@ -3529,7 +3535,7 @@ lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 114 unmodified lines
35293535 pmb->ctx_ndlp = NULL;
35303536
35313537 lpfc_printf_vlog(vport, KERN_INFO, LOG_SLI,
3532− "0002 rpi:%x DID:%x flg:%x %d map:%x %p\n",
3538+ "0002 rpi:%x DID:%x flg:%x %d map:%x x%px\n",
35333539 ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag,
35343540 kref_read(&ndlp->kref),
35353541 ndlp->nlp_usg_map, ndlp);
@@ -4041,7 +4047,7 @@ out: · 505 unmodified lines
40414047 ndlp->nlp_type |= NLP_FABRIC;
40424048 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
40434049 lpfc_printf_vlog(vport, KERN_INFO, LOG_SLI,
4044− "0003 rpi:%x DID:%x flg:%x %d map%x %p\n",
4050+ "0003 rpi:%x DID:%x flg:%x %d map%x x%px\n",
40454051 ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag,
40464052 kref_read(&ndlp->kref),
40474053 ndlp->nlp_usg_map, ndlp);
@@ -4160,7 +4166,7 @@ lpfc_register_remote_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 112 unmodified lines
41604166 fc_remote_port_rolechg(rport, rport_ids.roles);
41614167
41624168 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE,
4163− "3183 rport register x%06x, rport %p role x%x\n",
4169+ "3183 rport register x%06x, rport x%px role x%x\n",
41644170 ndlp->nlp_DID, rport, rport_ids.roles);
41654171
41664172 if ((rport->scsi_target_id != -1) &&
@@ -4184,7 +4190,7 @@ lpfc_unregister_remote_port(struct lpfc_nodelist *ndlp) · 17 unmodified lines
41844190 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_type);
41854191
41864192 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
4187− "3184 rport unregister x%06x, rport %p\n",
4193+ "3184 rport unregister x%06x, rport x%px\n",
41884194 ndlp->nlp_DID, rport);
41894195
41904196 fc_remote_port_delete(rport);
@@ -4196,8 +4202,9 @@ static void · 5 unmodified lines
41964202 lpfc_nlp_counters(struct lpfc_vport *vport, int state, int count)
41974203 {
41984204 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
4205+ unsigned long iflags;
41994206
4200− spin_lock_irq(shost->host_lock);
4207+ spin_lock_irqsave(shost->host_lock, iflags);
42014208 switch (state) {
42024209 case NLP_STE_UNUSED_NODE:
42034210 vport->fc_unused_cnt += count;
@@ -4227,7 +4234,7 @@ lpfc_nlp_counters(struct lpfc_vport *vport, int state, int count) · 23 unmodified lines
42274234 vport->fc_npr_cnt += count;
42284235 break;
42294236 }
4230− spin_unlock_irq(shost->host_lock);
4237+ spin_unlock_irqrestore(shost->host_lock, iflags);
42314238 }
42324239
42334240 static void
@@ -4480,9 +4487,21 @@ lpfc_enable_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 246 unmodified lines
44804487 return NULL;
44814488
44824489 if (phba->sli_rev == LPFC_SLI_REV4) {
4483− rpi = lpfc_sli4_alloc_rpi(vport->phba);
4484− if (rpi == LPFC_RPI_ALLOC_ERROR)
4490+ if (ndlp->nlp_rpi == LPFC_RPI_ALLOC_ERROR)
4491+ rpi = lpfc_sli4_alloc_rpi(vport->phba);
4492+ else
4493+ rpi = ndlp->nlp_rpi;
4494+
4495+ if (rpi == LPFC_RPI_ALLOC_ERROR) {
4496+ lpfc_printf_vlog(vport, KERN_WARNING, LOG_NODE,
4497+ "0359 %s: ndlp:x%px "
4498+ "usgmap:x%x refcnt:%d FAILED RPI "
4499+ " ALLOC\n",
4500+ __func__,
4501+ (void *)ndlp, ndlp->nlp_usg_map,
4502+ kref_read(&ndlp->kref));
44854503 return NULL;
4504+ }
44864505 }
44874506
44884507 spin_lock_irqsave(&phba->ndlp_lock, flags);
@@ -4490,9 +4509,9 @@ lpfc_enable_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 1 unmodified line
44904509 if (NLP_CHK_FREE_REQ(ndlp)) {
44914510 spin_unlock_irqrestore(&phba->ndlp_lock, flags);
44924511 lpfc_printf_vlog(vport, KERN_WARNING, LOG_NODE,
4493− "0277 lpfc_enable_node: ndlp:x%p "
4512+ "0277 %s: ndlp:x%px "
44944513 "usgmap:x%x refcnt:%d\n",
4495− (void *)ndlp, ndlp->nlp_usg_map,
4514+ __func__, (void *)ndlp, ndlp->nlp_usg_map,
44964515 kref_read(&ndlp->kref));
44974516 goto free_rpi;
44984517 }
@@ -4500,9 +4519,9 @@ lpfc_enable_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 1 unmodified line
45004519 if (NLP_CHK_NODE_ACT(ndlp)) {
45014520 spin_unlock_irqrestore(&phba->ndlp_lock, flags);
45024521 lpfc_printf_vlog(vport, KERN_WARNING, LOG_NODE,
4503− "0278 lpfc_enable_node: ndlp:x%p "
4522+ "0278 %s: ndlp:x%px "
45044523 "usgmap:x%x refcnt:%d\n",
4505− (void *)ndlp, ndlp->nlp_usg_map,
4524+ __func__, (void *)ndlp, ndlp->nlp_usg_map,
45064525 kref_read(&ndlp->kref));
45074526 goto free_rpi;
45084527 }
@@ -4532,7 +4551,7 @@ lpfc_enable_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 23 unmodified lines
45324551 ndlp->nlp_rpi = rpi;
45334552 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
45344553 "0008 rpi:%x DID:%x flg:%x refcnt:%d "
4535− "map:%x %p\n", ndlp->nlp_rpi, ndlp->nlp_DID,
4554+ "map:%x x%px\n", ndlp->nlp_rpi, ndlp->nlp_DID,
45364555 ndlp->nlp_flag,
45374556 kref_read(&ndlp->kref),
45384557 ndlp->nlp_usg_map, ndlp);
@@ -4541,6 +4560,14 @@ lpfc_enable_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 2 unmodified lines
45414560
45424561 if (state != NLP_STE_UNUSED_NODE)
45434562 lpfc_nlp_set_state(vport, ndlp, state);
4563+ else
4564+ lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
4565+ "0013 rpi:%x DID:%x flg:%x refcnt:%d "
4566+ "map:%x x%px STATE=UNUSED\n",
4567+ ndlp->nlp_rpi, ndlp->nlp_DID,
4568+ ndlp->nlp_flag,
4569+ kref_read(&ndlp->kref),
4570+ ndlp->nlp_usg_map, ndlp);
45444571
45454572 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_NODE,
45464573 "node enable: did:x%x",
@@ -4797,7 +4824,7 @@ lpfc_nlp_logo_unreg(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 250 unmodified lines
47974824 (ndlp->nlp_defer_did != NLP_EVT_NOTHING_PENDING)) {
47984825 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
47994826 "1434 UNREG cmpl deferred logo x%x "
4800− "on NPort x%x Data: x%x %p\n",
4827+ "on NPort x%x Data: x%x x%px\n",
48014828 ndlp->nlp_rpi, ndlp->nlp_DID,
48024829 ndlp->nlp_defer_did, ndlp);
48034830
@@ -4805,6 +4832,10 @@ lpfc_nlp_logo_unreg(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 1 unmodified line
48054832 ndlp->nlp_defer_did = NLP_EVT_NOTHING_PENDING;
48064833 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
48074834 } else {
4835+ if (ndlp->nlp_flag & NLP_RELEASE_RPI) {
4836+ lpfc_sli4_free_rpi(vport->phba, ndlp->nlp_rpi);
4837+ ndlp->nlp_flag &= ~NLP_RELEASE_RPI;
4838+ }
48084839 ndlp->nlp_flag &= ~NLP_UNREG_INP;
48094840 }
48104841 }
@@ -4843,7 +4874,7 @@ lpfc_unreg_rpi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 32 unmodified lines
48434874 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
48444875 "1436 unreg_rpi SKIP UNREG x%x on "
48454876 "NPort x%x deferred x%x flg x%x "
4846− "Data: %p\n",
4877+ "Data: x%px\n",
48474878 ndlp->nlp_rpi, ndlp->nlp_DID,
48484879 ndlp->nlp_defer_did,
48494880 ndlp->nlp_flag, ndlp);
@@ -4893,7 +4924,8 @@ lpfc_unreg_rpi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 43 unmodified lines
48934924
48944925 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
48954926 "1433 unreg_rpi UNREG x%x on "
4896− "NPort x%x deferred flg x%x Data:%p\n",
4927+ "NPort x%x deferred flg x%x "
4928+ "Data:x%px\n",
48974929 ndlp->nlp_rpi, ndlp->nlp_DID,
48984930 ndlp->nlp_flag, ndlp);
48994931
@@ -5034,16 +5066,16 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 134 unmodified lines
50345066 ndlp->nlp_state, ndlp->nlp_rpi);
50355067 if (NLP_CHK_FREE_REQ(ndlp)) {
50365068 lpfc_printf_vlog(vport, KERN_WARNING, LOG_NODE,
5037− "0280 lpfc_cleanup_node: ndlp:x%p "
5069+ "0280 %s: ndlp:x%px "
50385070 "usgmap:x%x refcnt:%d\n",
5039− (void *)ndlp, ndlp->nlp_usg_map,
5071+ __func__, (void *)ndlp, ndlp->nlp_usg_map,
50405072 kref_read(&ndlp->kref));
50415073 lpfc_dequeue_node(vport, ndlp);
50425074 } else {
50435075 lpfc_printf_vlog(vport, KERN_WARNING, LOG_NODE,
5044− "0281 lpfc_cleanup_node: ndlp:x%p "
5076+ "0281 %s: ndlp:x%px "
50455077 "usgmap:x%x refcnt:%d\n",
5046− (void *)ndlp, ndlp->nlp_usg_map,
5078+ __func__, (void *)ndlp, ndlp->nlp_usg_map,
50475079 kref_read(&ndlp->kref));
50485080 lpfc_disable_node(vport, ndlp);
50495081 }
@@ -5104,6 +5136,8 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 54 unmodified lines
51045136 list_del_init(&ndlp->els_retry_evt.evt_listp);
51055137 list_del_init(&ndlp->dev_loss_evt.evt_listp);
51065138 lpfc_cleanup_vports_rrqs(vport, ndlp);
5139+ if (phba->sli_rev == LPFC_SLI_REV4)
5140+ ndlp->nlp_flag |= NLP_RELEASE_RPI;
51075141 lpfc_unreg_rpi(vport, ndlp);
51085142
51095143 return 0;
@@ -5132,7 +5166,7 @@ lpfc_nlp_remove(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 22 unmodified lines
51325166 * allocated by the firmware.
51335167 */
51345168 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
5135− "0005 rpi:%x DID:%x flg:%x %d map:%x %p\n",
5169+ "0005 rpi:%x DID:%x flg:%x %d map:%x x%px\n",
51365170 ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag,
51375171 kref_read(&ndlp->kref),
51385172 ndlp->nlp_usg_map, ndlp);
@@ -5168,8 +5202,8 @@ lpfc_nlp_remove(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 29 unmodified lines
51685202 * for registered rport so need to cleanup rport
51695203 */
51705204 lpfc_printf_vlog(vport, KERN_WARNING, LOG_NODE,
5171− "0940 removed node x%p DID x%x "
5172− " rport not null %p\n",
5205+ "0940 removed node x%px DID x%x "
5206+ " rport not null x%px\n",
51735207 ndlp, ndlp->nlp_DID, ndlp->rport);
51745208 rport = ndlp->rport;
51755209 rdata = rport->dd_data;
@@ -5243,15 +5277,15 @@ __lpfc_findnode_did(struct lpfc_vport *vport, uint32_t did) · 67 unmodified lines
52435277
52445278 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
52455279 if (lpfc_matchdid(vport, ndlp, did)) {
5246− data1 = (((uint32_t) ndlp->nlp_state << 24) |
5247− ((uint32_t) ndlp->nlp_xri << 16) |
5248− ((uint32_t) ndlp->nlp_type << 8) |
5249− ((uint32_t) ndlp->nlp_rpi & 0xff));
5280+ data1 = (((uint32_t)ndlp->nlp_state << 24) |
5281+ ((uint32_t)ndlp->nlp_xri << 16) |
5282+ ((uint32_t)ndlp->nlp_type << 8) |
5283+ ((uint32_t)ndlp->nlp_usg_map & 0xff));
52505284 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
52515285 "0929 FIND node DID "
5252− "Data: x%p x%x x%x x%x %p\n",
5286+ "Data: x%px x%x x%x x%x x%x x%px\n",
52535287 ndlp, ndlp->nlp_DID,
5254− ndlp->nlp_flag, data1,
5288+ ndlp->nlp_flag, data1, ndlp->nlp_rpi,
52555289 ndlp->active_rrqs_xri_bitmap);
52565290 return ndlp;
52575291 }
@@ -5296,7 +5330,7 @@ lpfc_findnode_mapped(struct lpfc_vport *vport) · 38 unmodified lines
52965330 spin_unlock_irqrestore(shost->host_lock, iflags);
52975331 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
52985332 "2025 FIND node DID "
5299− "Data: x%p x%x x%x x%x %p\n",
5333+ "Data: x%px x%x x%x x%x x%px\n",
53005334 ndlp, ndlp->nlp_DID,
53015335 ndlp->nlp_flag, data1,
53025336 ndlp->active_rrqs_xri_bitmap);
@@ -5336,8 +5370,11 @@ lpfc_setup_disc_node(struct lpfc_vport *vport, uint32_t did) · 33 unmodified lines
53365370 if (vport->phba->nvmet_support)
53375371 return NULL;
53385372 ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_NPR_NODE);
5339− if (!ndlp)
5373+ if (!ndlp) {
5374+ lpfc_printf_vlog(vport, KERN_WARNING, LOG_SLI,
5375+ "0014 Could not enable ndlp\n");
53405376 return NULL;
5377+ }
53415378 spin_lock_irq(shost->host_lock);
53425379 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
53435380 spin_unlock_irq(shost->host_lock);
@@ -5960,7 +5997,7 @@ lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 616 unmodified lines
59605997 ndlp->nlp_type |= NLP_FABRIC;
59615998 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
59625999 lpfc_printf_vlog(vport, KERN_INFO, LOG_SLI,
5963− "0004 rpi:%x DID:%x flg:%x %d map:%x %p\n",
6000+ "0004 rpi:%x DID:%x flg:%x %d map:%x x%px\n",
59646001 ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag,
59656002 kref_read(&ndlp->kref),
59666003 ndlp->nlp_usg_map, ndlp);
@@ -6014,8 +6051,8 @@ __lpfc_find_node(struct lpfc_vport *vport, node_filter filter, void *param) · 47 unmodified lines
60146051 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {
60156052 if (filter(ndlp, param)) {
60166053 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
6017− "3185 FIND node filter %p DID "
6018− "ndlp %p did x%x flg x%x st x%x "
6054+ "3185 FIND node filter %ps DID "
6055+ "ndlp x%px did x%x flg x%x st x%x "
60196056 "xri x%x type x%x rpi x%x\n",
60206057 filter, ndlp, ndlp->nlp_DID,
60216058 ndlp->nlp_flag, ndlp->nlp_state,
@@ -6025,7 +6062,7 @@ __lpfc_find_node(struct lpfc_vport *vport, node_filter filter, void *param) · 3 unmodified lines
60256062 }
60266063 }
60276064 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
6028− "3186 FIND node filter %p NOT FOUND.\n", filter);
6065+ "3186 FIND node filter %ps NOT FOUND.\n", filter);
60296066 return NULL;
60306067 }
60316068
@@ -6065,10 +6102,11 @@ lpfc_findnode_rpi(struct lpfc_vport *vport, uint16_t rpi) · 33 unmodified lines
60656102 {
60666103 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
60676104 struct lpfc_nodelist *ndlp;
6105+ unsigned long flags;
60686106
6069− spin_lock_irq(shost->host_lock);
6107+ spin_lock_irqsave(shost->host_lock, flags);
60706108 ndlp = __lpfc_findnode_rpi(vport, rpi);
6071− spin_unlock_irq(shost->host_lock);
6109+ spin_unlock_irqrestore(shost->host_lock, flags);
60726110 return ndlp;
60736111 }
60746112
@@ -6149,7 +6187,7 @@ lpfc_nlp_init(struct lpfc_vport *vport, uint32_t did) · 74 unmodified lines
61496187 ndlp->nlp_rpi = rpi;
61506188 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
61516189 "0007 rpi:%x DID:%x flg:%x refcnt:%d "
6152− "map:%x %p\n", ndlp->nlp_rpi, ndlp->nlp_DID,
6190+ "map:%x x%px\n", ndlp->nlp_rpi, ndlp->nlp_DID,
61536191 ndlp->nlp_flag,
61546192 kref_read(&ndlp->kref),
61556193 ndlp->nlp_usg_map, ndlp);
@@ -6187,8 +6225,9 @@ lpfc_nlp_release(struct kref *kref) · 31 unmodified lines
61876225 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_type);
61886226
61896227 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE,
6190− "0279 lpfc_nlp_release: ndlp:x%p did %x "
6228+ "0279 %s: ndlp:x%px did %x "
61916229 "usgmap:x%x refcnt:%d rpi:%x\n",
6230+ __func__,
61926231 (void *)ndlp, ndlp->nlp_DID, ndlp->nlp_usg_map,
61936232 kref_read(&ndlp->kref), ndlp->nlp_rpi);
61946233
@@ -6200,8 +6239,6 @@ lpfc_nlp_release(struct kref *kref) · 5 unmodified lines
62006239 spin_lock_irqsave(&phba->ndlp_lock, flags);
62016240 NLP_CLR_NODE_ACT(ndlp);
62026241 spin_unlock_irqrestore(&phba->ndlp_lock, flags);
6203− if (phba->sli_rev == LPFC_SLI_REV4)
6204− lpfc_sli4_free_rpi(phba, ndlp->nlp_rpi);
62056242
62066243 /* free ndlp memory for final ndlp release */
62076244 if (NLP_CHK_FREE_REQ(ndlp)) {
@@ -6237,9 +6274,9 @@ lpfc_nlp_get(struct lpfc_nodelist *ndlp) · 29 unmodified lines
62376274 if (!NLP_CHK_NODE_ACT(ndlp) || NLP_CHK_FREE_ACK(ndlp)) {
62386275 spin_unlock_irqrestore(&phba->ndlp_lock, flags);
62396276 lpfc_printf_vlog(ndlp->vport, KERN_WARNING, LOG_NODE,
6240− "0276 lpfc_nlp_get: ndlp:x%p "
6277+ "0276 %s: ndlp:x%px "
62416278 "usgmap:x%x refcnt:%d\n",
6242− (void *)ndlp, ndlp->nlp_usg_map,
6279+ __func__, (void *)ndlp, ndlp->nlp_usg_map,
62436280 kref_read(&ndlp->kref));
62446281 return NULL;
62456282 } else
@@ -6265,9 +6302,9 @@ lpfc_nlp_put(struct lpfc_nodelist *ndlp) · 19 unmodified lines
62656302 return 1;
62666303
62676304 lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_NODE,
6268− "node put: did:x%x flg:x%x refcnt:x%x",
6269− ndlp->nlp_DID, ndlp->nlp_flag,
6270− kref_read(&ndlp->kref));
6305+ "node put: did:x%x flg:x%x refcnt:x%x",
6306+ ndlp->nlp_DID, ndlp->nlp_flag,
6307+ kref_read(&ndlp->kref));
62716308 phba = ndlp->phba;
62726309 spin_lock_irqsave(&phba->ndlp_lock, flags);
62736310 /* Check the ndlp memory free acknowledge flag to avoid the
@@ -6277,9 +6314,9 @@ lpfc_nlp_put(struct lpfc_nodelist *ndlp) · 3 unmodified lines
62776314 if (NLP_CHK_FREE_ACK(ndlp)) {
62786315 spin_unlock_irqrestore(&phba->ndlp_lock, flags);
62796316 lpfc_printf_vlog(ndlp->vport, KERN_WARNING, LOG_NODE,
6280− "0274 lpfc_nlp_put: ndlp:x%p "
6317+ "0274 %s: ndlp:x%px "
62816318 "usgmap:x%x refcnt:%d\n",
6282− (void *)ndlp, ndlp->nlp_usg_map,
6319+ __func__, (void *)ndlp, ndlp->nlp_usg_map,
62836320 kref_read(&ndlp->kref));
62846321 return 1;
62856322 }
@@ -6290,9 +6327,9 @@ lpfc_nlp_put(struct lpfc_nodelist *ndlp) · 4 unmodified lines
62906327 if (NLP_CHK_IACT_REQ(ndlp)) {
62916328 spin_unlock_irqrestore(&phba->ndlp_lock, flags);
62926329 lpfc_printf_vlog(ndlp->vport, KERN_WARNING, LOG_NODE,
6293− "0275 lpfc_nlp_put: ndlp:x%p "
6330+ "0275 %s: ndlp:x%px "
62946331 "usgmap:x%x refcnt:%d\n",
6295− (void *)ndlp, ndlp->nlp_usg_map,
6332+ __func__, (void *)ndlp, ndlp->nlp_usg_map,
62966333 kref_read(&ndlp->kref));
62976334 return 1;
62986335 }
drivers/scsi/lpfc/lpfc_hw.h+3−3
@@ -843,7 +843,7 @@ typedef struct _ADISC { /* Structure is in Big Endian format */ · 842 unmodified lines
843843 struct lpfc_name portName;
844844 struct lpfc_name nodeName;
845845 uint32_t DID;
846−} ADISC;
846+} __packed ADISC;
847847
848848 typedef struct _FARP { /* Structure is in Big Endian format */
849849 uint32_t Mflags:8;
@@ -873,7 +873,7 @@ typedef struct _FAN { /* Structure is in Big Endian format */ · 23 unmodified lines
873873 uint32_t Fdid;
874874 struct lpfc_name FportName;
875875 struct lpfc_name FnodeName;
876−} FAN;
876+} __packed FAN;
877877
878878 typedef struct _SCR { /* Structure is in Big Endian format */
879879 uint8_t resvd1;
@@ -917,7 +917,7 @@ typedef struct _RNID { /* Structure is in Big Endian format */ · 37 unmodified lines
917917 union {
918918 RNID_TOP_DISC topologyDisc; /* topology disc (0xdf) */
919919 } un;
920−} RNID;
920+} __packed RNID;
921921
922922 typedef struct _RPS { /* Structure is in Big Endian format */
923923 union {
drivers/scsi/lpfc/lpfc_hw4.h+34−0
@@ -2050,6 +2050,23 @@ struct sli4_sge { /* SLI-4 */ · 2049 unmodified lines
20502050 uint32_t sge_len;
20512051 };
20522052
2053+struct sli4_hybrid_sgl {
2054+ struct list_head list_node;
2055+ struct sli4_sge *dma_sgl;
2056+ dma_addr_t dma_phys_sgl;
2057+};
2058+
2059+struct fcp_cmd_rsp_buf {
2060+ struct list_head list_node;
2061+
2062+ /* for storing cmd/rsp dma alloc'ed virt_addr */
2063+ struct fcp_cmnd *fcp_cmnd;
2064+ struct fcp_rsp *fcp_rsp;
2065+
2066+ /* for storing this cmd/rsp's dma mapped phys addr from per CPU pool */
2067+ dma_addr_t fcp_cmd_rsp_dma_handle;
2068+};
2069+
20532070 struct sli4_sge_diseed { /* SLI-4 */
20542071 uint32_t ref_tag;
20552072 uint32_t ref_tag_tran;
@@ -3449,6 +3466,9 @@ struct lpfc_sli4_parameters { · 1393 unmodified lines
34493466 #define cfg_xib_SHIFT 4
34503467 #define cfg_xib_MASK 0x00000001
34513468 #define cfg_xib_WORD word19
3469+#define cfg_xpsgl_SHIFT 6
3470+#define cfg_xpsgl_MASK 0x00000001
3471+#define cfg_xpsgl_WORD word19
34523472 #define cfg_eqdr_SHIFT 8
34533473 #define cfg_eqdr_MASK 0x00000001
34543474 #define cfg_eqdr_WORD word19
@@ -3460,6 +3480,10 @@ struct lpfc_sli4_parameters { · 5 unmodified lines
34603480 #define cfg_bv1s_MASK 0x00000001
34613481 #define cfg_bv1s_WORD word19
34623482
3483+#define cfg_nsler_SHIFT 12
3484+#define cfg_nsler_MASK 0x00000001
3485+#define cfg_nsler_WORD word19
3486+
34633487 uint32_t word20;
34643488 #define cfg_max_tow_xri_SHIFT 0
34653489 #define cfg_max_tow_xri_MASK 0x0000ffff
@@ -4314,6 +4338,12 @@ struct wqe_common { · 848 unmodified lines
43144338 #define wqe_rcvoxid_SHIFT 16
43154339 #define wqe_rcvoxid_MASK 0x0000FFFF
43164340 #define wqe_rcvoxid_WORD word9
4341+#define wqe_sof_SHIFT 24
4342+#define wqe_sof_MASK 0x000000FF
4343+#define wqe_sof_WORD word9
4344+#define wqe_eof_SHIFT 16
4345+#define wqe_eof_MASK 0x000000FF
4346+#define wqe_eof_WORD word9
43174347 uint32_t word10;
43184348 #define wqe_ebde_cnt_SHIFT 0
43194349 #define wqe_ebde_cnt_MASK 0x0000000f
@@ -4595,6 +4625,7 @@ struct lpfc_nvme_prli { · 275 unmodified lines
45954625 #define prli_type_code_WORD word1
45964626 uint32_t word_rsvd2;
45974627 uint32_t word_rsvd3;
4628+
45984629 uint32_t word4;
45994630 #define prli_fba_SHIFT 0
46004631 #define prli_fba_MASK 0x00000001
@@ -4611,6 +4642,9 @@ struct lpfc_nvme_prli { · 10 unmodified lines
46114642 #define prli_conf_SHIFT 7
46124643 #define prli_conf_MASK 0x00000001
46134644 #define prli_conf_WORD word4
4645+#define prli_nsler_SHIFT 8
4646+#define prli_nsler_MASK 0x00000001
4647+#define prli_nsler_WORD word4
46144648 uint32_t word5;
46154649 #define prli_fb_sz_SHIFT 0
46164650 #define prli_fb_sz_MASK 0x0000ffff
drivers/scsi/lpfc/lpfc_init.c+429−497
@@ -39,6 +39,7 @@ · 38 unmodified lines
3939 #include <linux/msi.h>
4040 #include <linux/irq.h>
4141 #include <linux/bitops.h>
42+#include <linux/crash_dump.h>
4243
4344 #include <scsi/scsi.h>
4445 #include <scsi/scsi_device.h>
@@ -65,12 +66,6 @@ · 20 unmodified lines
6566 #include "lpfc_version.h"
6667 #include "lpfc_ids.h"
6768
68−char *_dump_buf_data;
69−unsigned long _dump_buf_data_order;
70−char *_dump_buf_dif;
71−unsigned long _dump_buf_dif_order;
72−spinlock_t _dump_buf_lock;
73−
7469 /* Used when mapping IRQ vectors in a driver centric manner */
7570 static uint32_t lpfc_present_cpu;
7671
@@ -1081,8 +1076,8 @@ lpfc_hba_down_post_s4(struct lpfc_hba *phba) · 1004 unmodified lines
10811076 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) {
10821077 qp = &phba->sli4_hba.hdwq[idx];
10831078
1084− spin_lock(&qp->abts_scsi_buf_list_lock);
1085− list_splice_init(&qp->lpfc_abts_scsi_buf_list,
1079+ spin_lock(&qp->abts_io_buf_list_lock);
1080+ list_splice_init(&qp->lpfc_abts_io_buf_list,
10861081 &aborts);
10871082
10881083 list_for_each_entry_safe(psb, psb_next, &aborts, list) {
@@ -1093,29 +1088,11 @@ lpfc_hba_down_post_s4(struct lpfc_hba *phba) · 4 unmodified lines
10931088 spin_lock(&qp->io_buf_list_put_lock);
10941089 list_splice_init(&aborts, &qp->lpfc_io_buf_list_put);
10951090 qp->put_io_bufs += qp->abts_scsi_io_bufs;
1091+ qp->put_io_bufs += qp->abts_nvme_io_bufs;
10961092 qp->abts_scsi_io_bufs = 0;
1093+ qp->abts_nvme_io_bufs = 0;
10971094 spin_unlock(&qp->io_buf_list_put_lock);
1098− spin_unlock(&qp->abts_scsi_buf_list_lock);
1099−
1100− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
1101− spin_lock(&qp->abts_nvme_buf_list_lock);
1102− list_splice_init(&qp->lpfc_abts_nvme_buf_list,
1103− &nvme_aborts);
1104− list_for_each_entry_safe(psb, psb_next, &nvme_aborts,
1105− list) {
1106− psb->pCmd = NULL;
1107− psb->status = IOSTAT_SUCCESS;
1108− cnt++;
1109− }
1110− spin_lock(&qp->io_buf_list_put_lock);
1111− qp->put_io_bufs += qp->abts_nvme_io_bufs;
1112− qp->abts_nvme_io_bufs = 0;
1113− list_splice_init(&nvme_aborts,
1114− &qp->lpfc_io_buf_list_put);
1115− spin_unlock(&qp->io_buf_list_put_lock);
1116− spin_unlock(&qp->abts_nvme_buf_list_lock);
1117−
1118− }
1095+ spin_unlock(&qp->abts_io_buf_list_lock);
11191096 }
11201097 spin_unlock_irq(&phba->hbalock);
11211098
@@ -1261,6 +1238,7 @@ lpfc_hb_eq_delay_work(struct work_struct *work) · 139 unmodified lines
12611238 unsigned char *eqcnt = NULL;
12621239 uint32_t usdelay;
12631240 int i;
1241+ bool update = false;
12641242
12651243 if (!phba->cfg_auto_imax || phba->pport->load_flag & FC_UNLOADING)
12661244 return;
@@ -1274,20 +1252,29 @@ lpfc_hb_eq_delay_work(struct work_struct *work) · 7 unmodified lines
12741252 if (!eqcnt)
12751253 goto requeue;
12761254
1277− /* Loop thru all IRQ vectors */
1278− for (i = 0; i < phba->cfg_irq_chann; i++) {
1279− /* Get the EQ corresponding to the IRQ vector */
1280− eq = phba->sli4_hba.hba_eq_hdl[i].eq;
1281− if (eq && eqcnt[eq->last_cpu] < 2)
1282− eqcnt[eq->last_cpu]++;
1283− continue;
1284− }
1255+ if (phba->cfg_irq_chann > 1) {
1256+ /* Loop thru all IRQ vectors */
1257+ for (i = 0; i < phba->cfg_irq_chann; i++) {
1258+ /* Get the EQ corresponding to the IRQ vector */
1259+ eq = phba->sli4_hba.hba_eq_hdl[i].eq;
1260+ if (!eq)
1261+ continue;
1262+ if (eq->q_mode) {
1263+ update = true;
1264+ break;
1265+ }
1266+ if (eqcnt[eq->last_cpu] < 2)
1267+ eqcnt[eq->last_cpu]++;
1268+ }
1269+ } else
1270+ update = true;
12851271
12861272 for_each_present_cpu(i) {
1287− if (phba->cfg_irq_chann > 1 && eqcnt[i] < 2)
1288− continue;
1289−
12901273 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, i);
1274+ if (!update && eqcnt[i] < 2) {
1275+ eqi->icnt = 0;
1276+ continue;
1277+ }
12911278
12921279 usdelay = (eqi->icnt / LPFC_IMAX_THRESHOLD) *
12931280 LPFC_EQ_DELAY_STEP;
@@ -1535,6 +1522,7 @@ lpfc_sli4_offline_eratt(struct lpfc_hba *phba) · 241 unmodified lines
15351522 spin_unlock_irq(&phba->hbalock);
15361523
15371524 lpfc_offline_prep(phba, LPFC_MBX_NO_WAIT);
1525+ lpfc_sli_flush_io_rings(phba);
15381526 lpfc_offline(phba);
15391527 lpfc_hba_down_post(phba);
15401528 lpfc_unblock_mgmt_io(phba);
@@ -1796,6 +1784,7 @@ lpfc_sli4_port_sta_fn_reset(struct lpfc_hba *phba, int mbx_action, · 255 unmodified lines
17961784 "2887 Reset Needed: Attempting Port "
17971785 "Recovery...\n");
17981786 lpfc_offline_prep(phba, mbx_action);
1787+ lpfc_sli_flush_io_rings(phba);
17991788 lpfc_offline(phba);
18001789 /* release interrupt for possible resource change */
18011790 lpfc_sli4_disable_intr(phba);
@@ -1915,7 +1904,7 @@ lpfc_handle_eratt_s4(struct lpfc_hba *phba) · 113 unmodified lines
19151904 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
19161905 "7624 Firmware not ready: Failing UE recovery,"
19171906 " waited %dSec", i);
1918− lpfc_sli4_offline_eratt(phba);
1907+ phba->link_state = LPFC_HBA_ERROR;
19191908 break;
19201909
19211910 case LPFC_SLI_INTF_IF_TYPE_2:
@@ -1989,9 +1978,8 @@ lpfc_handle_eratt_s4(struct lpfc_hba *phba) · 67 unmodified lines
19891978 }
19901979 /* fall through for not able to recover */
19911980 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1992− "3152 Unrecoverable error, bring the port "
1993− "offline\n");
1994− lpfc_sli4_offline_eratt(phba);
1981+ "3152 Unrecoverable error\n");
1982+ phba->link_state = LPFC_HBA_ERROR;
19951983 break;
19961984 case LPFC_SLI_INTF_IF_TYPE_1:
19971985 default:
@@ -2863,7 +2851,7 @@ lpfc_cleanup(struct lpfc_vport *vport) · 865 unmodified lines
28632851 &vport->fc_nodes, nlp_listp) {
28642852 lpfc_printf_vlog(ndlp->vport, KERN_ERR,
28652853 LOG_NODE,
2866− "0282 did:x%x ndlp:x%p "
2854+ "0282 did:x%x ndlp:x%px "
28672855 "usgmap:x%x refcnt:%d\n",
28682856 ndlp->nlp_DID, (void *)ndlp,
28692857 ndlp->nlp_usg_map,
@@ -3067,7 +3055,7 @@ lpfc_sli4_node_prep(struct lpfc_hba *phba) · 197 unmodified lines
30673055 ndlp->nlp_rpi = rpi;
30683056 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE,
30693057 "0009 rpi:%x DID:%x "
3070− "flg:%x map:%x %p\n", ndlp->nlp_rpi,
3058+ "flg:%x map:%x x%px\n", ndlp->nlp_rpi,
30713059 ndlp->nlp_DID, ndlp->nlp_flag,
30723060 ndlp->nlp_usg_map, ndlp);
30733061 }
@@ -3252,12 +3240,8 @@ static void lpfc_destroy_multixri_pools(struct lpfc_hba *phba) · 178 unmodified lines
32523240 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)
32533241 lpfc_destroy_expedite_pool(phba);
32543242
3255− if (!(phba->pport->load_flag & FC_UNLOADING)) {
3256− lpfc_sli_flush_fcp_rings(phba);
3257−
3258− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)
3259− lpfc_sli_flush_nvme_rings(phba);
3260− }
3243+ if (!(phba->pport->load_flag & FC_UNLOADING))
3244+ lpfc_sli_flush_io_rings(phba);
32613245
32623246 hwq_count = phba->cfg_hdw_queue;
32633247
@@ -3491,7 +3475,7 @@ lpfc_offline_prep(struct lpfc_hba *phba, int mbx_action) · 227 unmodified lines
34913475 lpfc_printf_vlog(ndlp->vport,
34923476 KERN_INFO, LOG_NODE,
34933477 "0011 lpfc_offline: "
3494− "ndlp:x%p did %x "
3478+ "ndlp:x%px did %x "
34953479 "usgmap:x%x rpi:%x\n",
34963480 ndlp, ndlp->nlp_DID,
34973481 ndlp->nlp_usg_map,
@@ -3636,6 +3620,9 @@ lpfc_io_free(struct lpfc_hba *phba) · 138 unmodified lines
36363620 qp->put_io_bufs--;
36373621 dma_pool_free(phba->lpfc_sg_dma_buf_pool,
36383622 lpfc_ncmd->data, lpfc_ncmd->dma_handle);
3623+ if (phba->cfg_xpsgl && !phba->nvmet_support)
3624+ lpfc_put_sgl_per_hdwq(phba, lpfc_ncmd);
3625+ lpfc_put_cmd_rsp_buf_per_hdwq(phba, lpfc_ncmd);
36393626 kfree(lpfc_ncmd);
36403627 qp->total_io_bufs--;
36413628 }
@@ -3649,6 +3636,9 @@ lpfc_io_free(struct lpfc_hba *phba) · 7 unmodified lines
36493636 qp->get_io_bufs--;
36503637 dma_pool_free(phba->lpfc_sg_dma_buf_pool,
36513638 lpfc_ncmd->data, lpfc_ncmd->dma_handle);
3639+ if (phba->cfg_xpsgl && !phba->nvmet_support)
3640+ lpfc_put_sgl_per_hdwq(phba, lpfc_ncmd);
3641+ lpfc_put_cmd_rsp_buf_per_hdwq(phba, lpfc_ncmd);
36523642 kfree(lpfc_ncmd);
36533643 qp->total_io_bufs--;
36543644 }
@@ -4097,18 +4087,9 @@ lpfc_new_io_buf(struct lpfc_hba *phba, int num_to_alloc) · 442 unmodified lines
40974087 LIST_HEAD(post_nblist);
40984088 LIST_HEAD(nvme_nblist);
40994089
4100− /* Sanity check to ensure our sizing is right for both SCSI and NVME */
4101− if (sizeof(struct lpfc_io_buf) > LPFC_COMMON_IO_BUF_SZ) {
4102− lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
4103− "6426 Common buffer size %zd exceeds %d\n",
4104− sizeof(struct lpfc_io_buf),
4105− LPFC_COMMON_IO_BUF_SZ);
4106− return 0;
4107− }
4108−
41094090 phba->sli4_hba.io_xri_cnt = 0;
41104091 for (bcnt = 0; bcnt < num_to_alloc; bcnt++) {
4111− lpfc_ncmd = kzalloc(LPFC_COMMON_IO_BUF_SZ, GFP_KERNEL);
4092+ lpfc_ncmd = kzalloc(sizeof(*lpfc_ncmd), GFP_KERNEL);
41124093 if (!lpfc_ncmd)
41134094 break;
41144095 /*
@@ -4124,22 +4105,30 @@ lpfc_new_io_buf(struct lpfc_hba *phba, int num_to_alloc) · 9 unmodified lines
41244105 break;
41254106 }
41264107
4127− /*
4128− * 4K Page alignment is CRITICAL to BlockGuard, double check
4129− * to be sure.
4130− */
4131− if ((phba->sli3_options & LPFC_SLI3_BG_ENABLED) &&
4132− (((unsigned long)(lpfc_ncmd->data) &
4133− (unsigned long)(SLI4_PAGE_SIZE - 1)) != 0)) {
4134− lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
4135− "3369 Memory alignment err: addr=%lx\n",
4136− (unsigned long)lpfc_ncmd->data);
4137− dma_pool_free(phba->lpfc_sg_dma_buf_pool,
4138− lpfc_ncmd->data, lpfc_ncmd->dma_handle);
4139− kfree(lpfc_ncmd);
4140− break;
4108+ if (phba->cfg_xpsgl && !phba->nvmet_support) {
4109+ INIT_LIST_HEAD(&lpfc_ncmd->dma_sgl_xtra_list);
4110+ } else {
4111+ /*
4112+ * 4K Page alignment is CRITICAL to BlockGuard, double
4113+ * check to be sure.
4114+ */
4115+ if ((phba->sli3_options & LPFC_SLI3_BG_ENABLED) &&
4116+ (((unsigned long)(lpfc_ncmd->data) &
4117+ (unsigned long)(SLI4_PAGE_SIZE - 1)) != 0)) {
4118+ lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
4119+ "3369 Memory alignment err: "
4120+ "addr=%lx\n",
4121+ (unsigned long)lpfc_ncmd->data);
4122+ dma_pool_free(phba->lpfc_sg_dma_buf_pool,
4123+ lpfc_ncmd->data,
4124+ lpfc_ncmd->dma_handle);
4125+ kfree(lpfc_ncmd);
4126+ break;
4127+ }
41414128 }
41424129
4130+ INIT_LIST_HEAD(&lpfc_ncmd->dma_cmd_rsp_list);
4131+
41434132 lxri = lpfc_sli4_next_xritag(phba);
41444133 if (lxri == NO_XRI) {
41454134 dma_pool_free(phba->lpfc_sg_dma_buf_pool,
@@ -4318,7 +4307,11 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev) · 172 unmodified lines
43184307
43194308 shost->dma_boundary =
43204309 phba->sli4_hba.pc_sli4_params.sge_supp_len-1;
4321− shost->sg_tablesize = phba->cfg_scsi_seg_cnt;
4310+
4311+ if (phba->cfg_xpsgl && !phba->nvmet_support)
4312+ shost->sg_tablesize = LPFC_MAX_SG_TABLESIZE;
4313+ else
4314+ shost->sg_tablesize = phba->cfg_scsi_seg_cnt;
43224315 } else
43234316 /* SLI-3 has a limited number of hardware queues (3),
43244317 * thus there is only one for FCP processing.
@@ -6336,6 +6329,24 @@ lpfc_sli_driver_resource_setup(struct lpfc_hba *phba) · 2011 unmodified lines
63366329 if (lpfc_mem_alloc(phba, BPL_ALIGN_SZ))
63376330 return -ENOMEM;
63386331
6332+ phba->lpfc_sg_dma_buf_pool =
6333+ dma_pool_create("lpfc_sg_dma_buf_pool",
6334+ &phba->pcidev->dev, phba->cfg_sg_dma_buf_size,
6335+ BPL_ALIGN_SZ, 0);
6336+
6337+ if (!phba->lpfc_sg_dma_buf_pool)
6338+ goto fail_free_mem;
6339+
6340+ phba->lpfc_cmd_rsp_buf_pool =
6341+ dma_pool_create("lpfc_cmd_rsp_buf_pool",
6342+ &phba->pcidev->dev,
6343+ sizeof(struct fcp_cmnd) +
6344+ sizeof(struct fcp_rsp),
6345+ BPL_ALIGN_SZ, 0);
6346+
6347+ if (!phba->lpfc_cmd_rsp_buf_pool)
6348+ goto fail_free_dma_buf_pool;
6349+
63396350 /*
63406351 * Enable sr-iov virtual functions if supported and configured
63416352 * through the module parameter.
@@ -6354,6 +6365,13 @@ lpfc_sli_driver_resource_setup(struct lpfc_hba *phba) · 12 unmodified lines
63546365 }
63556366
63566367 return 0;
6368+
6369+fail_free_dma_buf_pool:
6370+ dma_pool_destroy(phba->lpfc_sg_dma_buf_pool);
6371+ phba->lpfc_sg_dma_buf_pool = NULL;
6372+fail_free_mem:
6373+ lpfc_mem_free(phba);
6374+ return -ENOMEM;
63576375 }
63586376
63596377 /**
@@ -6414,6 +6432,11 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) · 54 unmodified lines
64146432 if (rc)
64156433 return -ENODEV;
64166434
6435+ /* Allocate all driver workqueues here */
6436+
6437+ /* The lpfc_wq workqueue for deferred irq use */
6438+ phba->wq = alloc_workqueue("lpfc_wq", WQ_MEM_RECLAIM, 0);
6439+
64176440 /*
64186441 * Initialize timers used by driver
64196442 */
@@ -6448,102 +6471,6 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) · 28 unmodified lines
64486471 * The WQ create will allocate the ring.
64496472 */
64506473
6451− /*
6452− * 1 for cmd, 1 for rsp, NVME adds an extra one
6453− * for boundary conditions in its max_sgl_segment template.
6454− */
6455− extra = 2;
6456− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)
6457− extra++;
6458−
6459− /*
6460− * It doesn't matter what family our adapter is in, we are
6461− * limited to 2 Pages, 512 SGEs, for our SGL.
6462− * There are going to be 2 reserved SGEs: 1 FCP cmnd + 1 FCP rsp
6463− */
6464− max_buf_size = (2 * SLI4_PAGE_SIZE);
6465−
6466− /*
6467− * Since lpfc_sg_seg_cnt is module param, the sg_dma_buf_size
6468− * used to create the sg_dma_buf_pool must be calculated.
6469− */
6470− if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) {
6471− /*
6472− * The scsi_buf for a T10-DIF I/O holds the FCP cmnd,
6473− * the FCP rsp, and a SGE. Sice we have no control
6474− * over how many protection segments the SCSI Layer
6475− * will hand us (ie: there could be one for every block
6476− * in the IO), just allocate enough SGEs to accomidate
6477− * our max amount and we need to limit lpfc_sg_seg_cnt
6478− * to minimize the risk of running out.
6479− */
6480− phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) +
6481− sizeof(struct fcp_rsp) + max_buf_size;
6482−
6483− /* Total SGEs for scsi_sg_list and scsi_sg_prot_list */
6484− phba->cfg_total_seg_cnt = LPFC_MAX_SGL_SEG_CNT;
6485−
6486− /*
6487− * If supporting DIF, reduce the seg count for scsi to
6488− * allow room for the DIF sges.
6489− */
6490− if (phba->cfg_enable_bg &&
6491− phba->cfg_sg_seg_cnt > LPFC_MAX_BG_SLI4_SEG_CNT_DIF)
6492− phba->cfg_scsi_seg_cnt = LPFC_MAX_BG_SLI4_SEG_CNT_DIF;
6493− else
6494− phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt;
6495−
6496− } else {
6497− /*
6498− * The scsi_buf for a regular I/O holds the FCP cmnd,
6499− * the FCP rsp, a SGE for each, and a SGE for up to
6500− * cfg_sg_seg_cnt data segments.
6501− */
6502− phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) +
6503− sizeof(struct fcp_rsp) +
6504− ((phba->cfg_sg_seg_cnt + extra) *
6505− sizeof(struct sli4_sge));
6506−
6507− /* Total SGEs for scsi_sg_list */
6508− phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + extra;
6509− phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt;
6510−
6511− /*
6512− * NOTE: if (phba->cfg_sg_seg_cnt + extra) <= 256 we only
6513− * need to post 1 page for the SGL.
6514− */
6515− }
6516−
6517− /* Limit to LPFC_MAX_NVME_SEG_CNT for NVME. */
6518− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
6519− if (phba->cfg_sg_seg_cnt > LPFC_MAX_NVME_SEG_CNT) {
6520− lpfc_printf_log(phba, KERN_INFO, LOG_NVME | LOG_INIT,
6521− "6300 Reducing NVME sg segment "
6522− "cnt to %d\n",
6523− LPFC_MAX_NVME_SEG_CNT);
6524− phba->cfg_nvme_seg_cnt = LPFC_MAX_NVME_SEG_CNT;
6525− } else
6526− phba->cfg_nvme_seg_cnt = phba->cfg_sg_seg_cnt;
6527− }
6528−
6529− /* Initialize the host templates with the updated values. */
6530− lpfc_vport_template.sg_tablesize = phba->cfg_scsi_seg_cnt;
6531− lpfc_template.sg_tablesize = phba->cfg_scsi_seg_cnt;
6532− lpfc_template_no_hr.sg_tablesize = phba->cfg_scsi_seg_cnt;
6533−
6534− if (phba->cfg_sg_dma_buf_size <= LPFC_MIN_SG_SLI4_BUF_SZ)
6535− phba->cfg_sg_dma_buf_size = LPFC_MIN_SG_SLI4_BUF_SZ;
6536− else
6537− phba->cfg_sg_dma_buf_size =
6538− SLI4_PAGE_ALIGN(phba->cfg_sg_dma_buf_size);
6539−
6540− lpfc_printf_log(phba, KERN_INFO, LOG_INIT | LOG_FCP,
6541− "9087 sg_seg_cnt:%d dmabuf_size:%d "
6542− "total:%d scsi:%d nvme:%d\n",
6543− phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size,
6544− phba->cfg_total_seg_cnt, phba->cfg_scsi_seg_cnt,
6545− phba->cfg_nvme_seg_cnt);
6546−
65476474 /* Initialize buffer queue management fields */
65486475 INIT_LIST_HEAD(&phba->hbqs[LPFC_ELS_HBQ].hbq_buffer_list);
65496476 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_sli4_rb_alloc;
@@ -6552,11 +6479,9 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) · 2 unmodified lines
65526479 /*
65536480 * Initialize the SLI Layer to run with lpfc SLI4 HBAs.
65546481 */
6555− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) {
6556− /* Initialize the Abort scsi buffer list used by driver */
6557− spin_lock_init(&phba->sli4_hba.abts_scsi_buf_list_lock);
6558− INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_scsi_buf_list);
6559− }
6482+ /* Initialize the Abort buffer list used by driver */
6483+ spin_lock_init(&phba->sli4_hba.abts_io_buf_list_lock);
6484+ INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_io_buf_list);
65606485
65616486 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
65626487 /* Initialize the Abort nvme buffer list used by driver */
@@ -6764,6 +6689,131 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) · 201 unmodified lines
67646689 }
67656690 }
67666691
6692+ /*
6693+ * 1 for cmd, 1 for rsp, NVME adds an extra one
6694+ * for boundary conditions in its max_sgl_segment template.
6695+ */
6696+ extra = 2;
6697+ if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)
6698+ extra++;
6699+
6700+ /*
6701+ * It doesn't matter what family our adapter is in, we are
6702+ * limited to 2 Pages, 512 SGEs, for our SGL.
6703+ * There are going to be 2 reserved SGEs: 1 FCP cmnd + 1 FCP rsp
6704+ */
6705+ max_buf_size = (2 * SLI4_PAGE_SIZE);
6706+
6707+ /*
6708+ * Since lpfc_sg_seg_cnt is module param, the sg_dma_buf_size
6709+ * used to create the sg_dma_buf_pool must be calculated.
6710+ */
6711+ if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) {
6712+ /* Both cfg_enable_bg and cfg_external_dif code paths */
6713+
6714+ /*
6715+ * The scsi_buf for a T10-DIF I/O holds the FCP cmnd,
6716+ * the FCP rsp, and a SGE. Sice we have no control
6717+ * over how many protection segments the SCSI Layer
6718+ * will hand us (ie: there could be one for every block
6719+ * in the IO), just allocate enough SGEs to accomidate
6720+ * our max amount and we need to limit lpfc_sg_seg_cnt
6721+ * to minimize the risk of running out.
6722+ */
6723+ phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) +
6724+ sizeof(struct fcp_rsp) + max_buf_size;
6725+
6726+ /* Total SGEs for scsi_sg_list and scsi_sg_prot_list */
6727+ phba->cfg_total_seg_cnt = LPFC_MAX_SGL_SEG_CNT;
6728+
6729+ /*
6730+ * If supporting DIF, reduce the seg count for scsi to
6731+ * allow room for the DIF sges.
6732+ */
6733+ if (phba->cfg_enable_bg &&
6734+ phba->cfg_sg_seg_cnt > LPFC_MAX_BG_SLI4_SEG_CNT_DIF)
6735+ phba->cfg_scsi_seg_cnt = LPFC_MAX_BG_SLI4_SEG_CNT_DIF;
6736+ else
6737+ phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt;
6738+
6739+ } else {
6740+ /*
6741+ * The scsi_buf for a regular I/O holds the FCP cmnd,
6742+ * the FCP rsp, a SGE for each, and a SGE for up to
6743+ * cfg_sg_seg_cnt data segments.
6744+ */
6745+ phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) +
6746+ sizeof(struct fcp_rsp) +
6747+ ((phba->cfg_sg_seg_cnt + extra) *
6748+ sizeof(struct sli4_sge));
6749+
6750+ /* Total SGEs for scsi_sg_list */
6751+ phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + extra;
6752+ phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt;
6753+
6754+ /*
6755+ * NOTE: if (phba->cfg_sg_seg_cnt + extra) <= 256 we only
6756+ * need to post 1 page for the SGL.
6757+ */
6758+ }
6759+
6760+ if (phba->cfg_xpsgl && !phba->nvmet_support)
6761+ phba->cfg_sg_dma_buf_size = LPFC_DEFAULT_XPSGL_SIZE;
6762+ else if (phba->cfg_sg_dma_buf_size <= LPFC_MIN_SG_SLI4_BUF_SZ)
6763+ phba->cfg_sg_dma_buf_size = LPFC_MIN_SG_SLI4_BUF_SZ;
6764+ else
6765+ phba->cfg_sg_dma_buf_size =
6766+ SLI4_PAGE_ALIGN(phba->cfg_sg_dma_buf_size);
6767+
6768+ phba->border_sge_num = phba->cfg_sg_dma_buf_size /
6769+ sizeof(struct sli4_sge);
6770+
6771+ /* Limit to LPFC_MAX_NVME_SEG_CNT for NVME. */
6772+ if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
6773+ if (phba->cfg_sg_seg_cnt > LPFC_MAX_NVME_SEG_CNT) {
6774+ lpfc_printf_log(phba, KERN_INFO, LOG_NVME | LOG_INIT,
6775+ "6300 Reducing NVME sg segment "
6776+ "cnt to %d\n",
6777+ LPFC_MAX_NVME_SEG_CNT);
6778+ phba->cfg_nvme_seg_cnt = LPFC_MAX_NVME_SEG_CNT;
6779+ } else
6780+ phba->cfg_nvme_seg_cnt = phba->cfg_sg_seg_cnt;
6781+ }
6782+
6783+ /* Initialize the host templates with the updated values. */
6784+ lpfc_vport_template.sg_tablesize = phba->cfg_scsi_seg_cnt;
6785+ lpfc_template.sg_tablesize = phba->cfg_scsi_seg_cnt;
6786+ lpfc_template_no_hr.sg_tablesize = phba->cfg_scsi_seg_cnt;
6787+
6788+ lpfc_printf_log(phba, KERN_INFO, LOG_INIT | LOG_FCP,
6789+ "9087 sg_seg_cnt:%d dmabuf_size:%d "
6790+ "total:%d scsi:%d nvme:%d\n",
6791+ phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size,
6792+ phba->cfg_total_seg_cnt, phba->cfg_scsi_seg_cnt,
6793+ phba->cfg_nvme_seg_cnt);
6794+
6795+ if (phba->cfg_sg_dma_buf_size < SLI4_PAGE_SIZE)
6796+ i = phba->cfg_sg_dma_buf_size;
6797+ else
6798+ i = SLI4_PAGE_SIZE;
6799+
6800+ phba->lpfc_sg_dma_buf_pool =
6801+ dma_pool_create("lpfc_sg_dma_buf_pool",
6802+ &phba->pcidev->dev,
6803+ phba->cfg_sg_dma_buf_size,
6804+ i, 0);
6805+ if (!phba->lpfc_sg_dma_buf_pool)
6806+ goto out_free_bsmbx;
6807+
6808+ phba->lpfc_cmd_rsp_buf_pool =
6809+ dma_pool_create("lpfc_cmd_rsp_buf_pool",
6810+ &phba->pcidev->dev,
6811+ sizeof(struct fcp_cmnd) +
6812+ sizeof(struct fcp_rsp),
6813+ i, 0);
6814+ if (!phba->lpfc_cmd_rsp_buf_pool)
6815+ goto out_free_sg_dma_buf;
6816+
67676817 mempool_free(mboxq, phba->mbox_mem_pool);
67686818
67696819 /* Verify OAS is supported */
@@ -6775,12 +6825,12 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) · 5 unmodified lines
67756825 /* Verify all the SLI4 queues */
67766826 rc = lpfc_sli4_queue_verify(phba);
67776827 if (rc)
6778− goto out_free_bsmbx;
6828+ goto out_free_cmd_rsp_buf;
67796829
67806830 /* Create driver internal CQE event pool */
67816831 rc = lpfc_sli4_cq_event_pool_create(phba);
67826832 if (rc)
6783− goto out_free_bsmbx;
6833+ goto out_free_cmd_rsp_buf;
67846834
67856835 /* Initialize sgl lists per host */
67866836 lpfc_init_sgl_list(phba);
@@ -6871,6 +6921,12 @@ out_free_active_sgl: · 84 unmodified lines
68716921 lpfc_free_active_sgl(phba);
68726922 out_destroy_cq_event_pool:
68736923 lpfc_sli4_cq_event_pool_destroy(phba);
6924+out_free_cmd_rsp_buf:
6925+ dma_pool_destroy(phba->lpfc_cmd_rsp_buf_pool);
6926+ phba->lpfc_cmd_rsp_buf_pool = NULL;
6927+out_free_sg_dma_buf:
6928+ dma_pool_destroy(phba->lpfc_sg_dma_buf_pool);
6929+ phba->lpfc_sg_dma_buf_pool = NULL;
68746930 out_free_bsmbx:
68756931 lpfc_destroy_bootstrap_mbox(phba);
68766932 out_free_mem:
@@ -6997,12 +7053,6 @@ lpfc_setup_driver_resource_phase2(struct lpfc_hba *phba) · 120 unmodified lines
69977053 return error;
69987054 }
69997055
7000− /* The lpfc_wq workqueue for deferred irq use, is only used for SLI4 */
7001− if (phba->sli_rev == LPFC_SLI_REV4)
7002− phba->wq = alloc_workqueue("lpfc_wq", WQ_MEM_RECLAIM, 0);
7003− else
7004− phba->wq = NULL;
7005−
70067056 return 0;
70077057 }
70087058
@@ -7563,7 +7613,6 @@ lpfc_setup_bg(struct lpfc_hba *phba, struct Scsi_Host *shost) · 554 unmodified lines
75637613 uint32_t old_mask;
75647614 uint32_t old_guard;
75657615
7566− int pagecnt = 10;
75677616 if (phba->cfg_prot_mask && phba->cfg_prot_guard) {
75687617 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
75697618 "1478 Registering BlockGuard with the "
@@ -7600,56 +7649,6 @@ lpfc_setup_bg(struct lpfc_hba *phba, struct Scsi_Host *shost) · 30 unmodified lines
76007649 "layer, Bad protection parameters: %d %d\n",
76017650 old_mask, old_guard);
76027651 }
7603−
7604− if (!_dump_buf_data) {
7605− while (pagecnt) {
7606− spin_lock_init(&_dump_buf_lock);
7607− _dump_buf_data =
7608− (char *) __get_free_pages(GFP_KERNEL, pagecnt);
7609− if (_dump_buf_data) {
7610− lpfc_printf_log(phba, KERN_ERR, LOG_BG,
7611− "9043 BLKGRD: allocated %d pages for "
7612− "_dump_buf_data at 0x%p\n",
7613− (1 << pagecnt), _dump_buf_data);
7614− _dump_buf_data_order = pagecnt;
7615− memset(_dump_buf_data, 0,
7616− ((1 << PAGE_SHIFT) << pagecnt));
7617− break;
7618− } else
7619− --pagecnt;
7620− }
7621− if (!_dump_buf_data_order)
7622− lpfc_printf_log(phba, KERN_ERR, LOG_BG,
7623− "9044 BLKGRD: ERROR unable to allocate "
7624− "memory for hexdump\n");
7625− } else
7626− lpfc_printf_log(phba, KERN_ERR, LOG_BG,
7627− "9045 BLKGRD: already allocated _dump_buf_data=0x%p"
7628− "\n", _dump_buf_data);
7629− if (!_dump_buf_dif) {
7630− while (pagecnt) {
7631− _dump_buf_dif =
7632− (char *) __get_free_pages(GFP_KERNEL, pagecnt);
7633− if (_dump_buf_dif) {
7634− lpfc_printf_log(phba, KERN_ERR, LOG_BG,
7635− "9046 BLKGRD: allocated %d pages for "
7636− "_dump_buf_dif at 0x%p\n",
7637− (1 << pagecnt), _dump_buf_dif);
7638− _dump_buf_dif_order = pagecnt;
7639− memset(_dump_buf_dif, 0,
7640− ((1 << PAGE_SHIFT) << pagecnt));
7641− break;
7642− } else
7643− --pagecnt;
7644− }
7645− if (!_dump_buf_dif_order)
7646− lpfc_printf_log(phba, KERN_ERR, LOG_BG,
7647− "9047 BLKGRD: ERROR unable to allocate "
7648− "memory for hexdump\n");
7649− } else
7650− lpfc_printf_log(phba, KERN_ERR, LOG_BG,
7651− "9048 BLKGRD: already allocated _dump_buf_dif=0x%p\n",
7652− _dump_buf_dif);
76537652 }
76547653
76557654 /**
@@ -8309,6 +8308,10 @@ lpfc_sli4_read_config(struct lpfc_hba *phba) · 653 unmodified lines
83098308 bf_get(lpfc_mbx_rd_conf_extnts_inuse, rd_config);
83108309 phba->sli4_hba.max_cfg_param.max_xri =
83118310 bf_get(lpfc_mbx_rd_conf_xri_count, rd_config);
8311+ /* Reduce resource usage in kdump environment */
8312+ if (is_kdump_kernel() &&
8313+ phba->sli4_hba.max_cfg_param.max_xri > 512)
8314+ phba->sli4_hba.max_cfg_param.max_xri = 512;
83128315 phba->sli4_hba.max_cfg_param.xri_base =
83138316 bf_get(lpfc_mbx_rd_conf_xri_base, rd_config);
83148317 phba->sli4_hba.max_cfg_param.max_vpi =
@@ -8382,11 +8385,6 @@ lpfc_sli4_read_config(struct lpfc_hba *phba) · 67 unmodified lines
83828385 */
83838386 qmin -= 4;
83848387
8385− /* If NVME is configured, double the number of CQ/WQs needed */
8386− if ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) &&
8387− !phba->nvmet_support)
8388− qmin /= 2;
8389−
83908388 /* Check to see if there is enough for NVME */
83918389 if ((phba->cfg_irq_chann > qmin) ||
83928390 (phba->cfg_hdw_queue > qmin)) {
@@ -8643,51 +8641,14 @@ lpfc_sli4_queue_verify(struct lpfc_hba *phba) · 250 unmodified lines
86438641 }
86448642
86458643 static int
8646−lpfc_alloc_nvme_wq_cq(struct lpfc_hba *phba, int wqidx)
8647−{
8648− struct lpfc_queue *qdesc;
8649− int cpu;
8650−
8651− cpu = lpfc_find_cpu_handle(phba, wqidx, LPFC_FIND_BY_HDWQ);
8652− qdesc = lpfc_sli4_queue_alloc(phba, LPFC_EXPANDED_PAGE_SIZE,
8653− phba->sli4_hba.cq_esize,
8654− LPFC_CQE_EXP_COUNT, cpu);
8655− if (!qdesc) {
8656− lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
8657− "0508 Failed allocate fast-path NVME CQ (%d)\n",
8658− wqidx);
8659− return 1;
8660− }
8661− qdesc->qe_valid = 1;
8662− qdesc->hdwq = wqidx;
8663− qdesc->chann = cpu;
8664− phba->sli4_hba.hdwq[wqidx].nvme_cq = qdesc;
8665−
8666− qdesc = lpfc_sli4_queue_alloc(phba, LPFC_EXPANDED_PAGE_SIZE,
8667− LPFC_WQE128_SIZE, LPFC_WQE_EXP_COUNT,
8668− cpu);
8669− if (!qdesc) {
8670− lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
8671− "0509 Failed allocate fast-path NVME WQ (%d)\n",
8672− wqidx);
8673− return 1;
8674− }
8675− qdesc->hdwq = wqidx;
8676− qdesc->chann = wqidx;
8677− phba->sli4_hba.hdwq[wqidx].nvme_wq = qdesc;
8678− list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list);
8679− return 0;
8680−}
8681−
8682−static int
8683−lpfc_alloc_fcp_wq_cq(struct lpfc_hba *phba, int wqidx)
8644+lpfc_alloc_io_wq_cq(struct lpfc_hba *phba, int idx)
86848645 {
86858646 struct lpfc_queue *qdesc;
8686− uint32_t wqesize;
8647+ u32 wqesize;
86878648 int cpu;
86888649
8689− cpu = lpfc_find_cpu_handle(phba, wqidx, LPFC_FIND_BY_HDWQ);
8690− /* Create Fast Path FCP CQs */
8650+ cpu = lpfc_find_cpu_handle(phba, idx, LPFC_FIND_BY_HDWQ);
8651+ /* Create Fast Path IO CQs */
86918652 if (phba->enab_exp_wqcq_pages)
86928653 /* Increase the CQ size when WQEs contain an embedded cdb */
86938654 qdesc = lpfc_sli4_queue_alloc(phba, LPFC_EXPANDED_PAGE_SIZE,
@@ -8700,15 +8661,15 @@ lpfc_alloc_fcp_wq_cq(struct lpfc_hba *phba, int wqidx) · 6 unmodified lines
87008661 phba->sli4_hba.cq_ecount, cpu);
87018662 if (!qdesc) {
87028663 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
8703− "0499 Failed allocate fast-path FCP CQ (%d)\n", wqidx);
8664+ "0499 Failed allocate fast-path IO CQ (%d)\n", idx);
87048665 return 1;
87058666 }
87068667 qdesc->qe_valid = 1;
8707− qdesc->hdwq = wqidx;
8668+ qdesc->hdwq = idx;
87088669 qdesc->chann = cpu;
8709− phba->sli4_hba.hdwq[wqidx].fcp_cq = qdesc;
8670+ phba->sli4_hba.hdwq[idx].io_cq = qdesc;
87108671
8711− /* Create Fast Path FCP WQs */
8672+ /* Create Fast Path IO WQs */
87128673 if (phba->enab_exp_wqcq_pages) {
87138674 /* Increase the WQ size when WQEs contain an embedded cdb */
87148675 wqesize = (phba->fcp_embed_io) ?
@@ -8723,13 +8684,13 @@ lpfc_alloc_fcp_wq_cq(struct lpfc_hba *phba, int wqidx) · 8 unmodified lines
87238684
87248685 if (!qdesc) {
87258686 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
8726− "0503 Failed allocate fast-path FCP WQ (%d)\n",
8727− wqidx);
8687+ "0503 Failed allocate fast-path IO WQ (%d)\n",
8688+ idx);
87288689 return 1;
87298690 }
8730− qdesc->hdwq = wqidx;
8731− qdesc->chann = wqidx;
8732− phba->sli4_hba.hdwq[wqidx].fcp_wq = qdesc;
8691+ qdesc->hdwq = idx;
8692+ qdesc->chann = cpu;
8693+ phba->sli4_hba.hdwq[idx].io_wq = qdesc;
87338694 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list);
87348695 return 0;
87358696 }
@@ -8793,12 +8754,13 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba) · 57 unmodified lines
87938754 qp->get_io_bufs = 0;
87948755 qp->put_io_bufs = 0;
87958756 qp->total_io_bufs = 0;
8796− spin_lock_init(&qp->abts_scsi_buf_list_lock);
8797− INIT_LIST_HEAD(&qp->lpfc_abts_scsi_buf_list);
8757+ spin_lock_init(&qp->abts_io_buf_list_lock);
8758+ INIT_LIST_HEAD(&qp->lpfc_abts_io_buf_list);
87988759 qp->abts_scsi_io_bufs = 0;
8799− spin_lock_init(&qp->abts_nvme_buf_list_lock);
8800− INIT_LIST_HEAD(&qp->lpfc_abts_nvme_buf_list);
88018760 qp->abts_nvme_io_bufs = 0;
8761+ INIT_LIST_HEAD(&qp->sgl_list);
8762+ INIT_LIST_HEAD(&qp->cmd_rsp_buf_list);
8763+ spin_lock_init(&qp->hdwq_lock);
88028764 }
88038765 }
88048766
@@ -8864,7 +8826,7 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba) · 59 unmodified lines
88648826 }
88658827 qdesc->qe_valid = 1;
88668828 qdesc->hdwq = cpup->hdwq;
8867− qdesc->chann = cpu; /* First CPU this EQ is affinitised to */
8829+ qdesc->chann = cpu; /* First CPU this EQ is affinitized to */
88688830 qdesc->last_cpu = qdesc->chann;
88698831
88708832 /* Save the allocated EQ in the Hardware Queue */
@@ -8895,41 +8857,31 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba) · 24 unmodified lines
88958857 qp->hba_eq = phba->sli4_hba.hdwq[eqcpup->hdwq].hba_eq;
88968858 }
88978859
8898− /* Allocate SCSI SLI4 CQ/WQs */
8860+ /* Allocate IO Path SLI4 CQ/WQs */
88998861 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) {
8900− if (lpfc_alloc_fcp_wq_cq(phba, idx))
8862+ if (lpfc_alloc_io_wq_cq(phba, idx))
89018863 goto out_error;
89028864 }
89038865
8904− /* Allocate NVME SLI4 CQ/WQs */
8905− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
8906− for (idx = 0; idx < phba->cfg_hdw_queue; idx++) {
8907− if (lpfc_alloc_nvme_wq_cq(phba, idx))
8908− goto out_error;
8909− }
8910−
8911− if (phba->nvmet_support) {
8912− for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) {
8913− cpu = lpfc_find_cpu_handle(phba, idx,
8914− LPFC_FIND_BY_HDWQ);
8915− qdesc = lpfc_sli4_queue_alloc(
8916− phba,
8866+ if (phba->nvmet_support) {
8867+ for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) {
8868+ cpu = lpfc_find_cpu_handle(phba, idx,
8869+ LPFC_FIND_BY_HDWQ);
8870+ qdesc = lpfc_sli4_queue_alloc(phba,
89178871 LPFC_DEFAULT_PAGE_SIZE,
89188872 phba->sli4_hba.cq_esize,
89198873 phba->sli4_hba.cq_ecount,
89208874 cpu);
8921− if (!qdesc) {
8922− lpfc_printf_log(
8923− phba, KERN_ERR, LOG_INIT,
8875+ if (!qdesc) {
8876+ lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
89248877 "3142 Failed allocate NVME "
89258878 "CQ Set (%d)\n", idx);
8926− goto out_error;
8927− }
8928− qdesc->qe_valid = 1;
8929− qdesc->hdwq = idx;
8930− qdesc->chann = cpu;
8931− phba->sli4_hba.nvmet_cqset[idx] = qdesc;
8879+ goto out_error;
89328880 }
8881+ qdesc->qe_valid = 1;
8882+ qdesc->hdwq = idx;
8883+ qdesc->chann = cpu;
8884+ phba->sli4_hba.nvmet_cqset[idx] = qdesc;
89338885 }
89348886 }
89358887
@@ -8960,7 +8912,7 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba) · 24 unmodified lines
89608912 goto out_error;
89618913 }
89628914 qdesc->qe_valid = 1;
8963− qdesc->chann = 0;
8915+ qdesc->chann = cpu;
89648916 phba->sli4_hba.els_cq = qdesc;
89658917
89668918
@@ -8978,7 +8930,7 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba) · 11 unmodified lines
89788930 "0505 Failed allocate slow-path MQ\n");
89798931 goto out_error;
89808932 }
8981− qdesc->chann = 0;
8933+ qdesc->chann = cpu;
89828934 phba->sli4_hba.mbx_wq = qdesc;
89838935
89848936 /*
@@ -8994,7 +8946,7 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba) · 9 unmodified lines
89948946 "0504 Failed allocate slow-path ELS WQ\n");
89958947 goto out_error;
89968948 }
8997− qdesc->chann = 0;
8949+ qdesc->chann = cpu;
89988950 phba->sli4_hba.els_wq = qdesc;
89998951 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list);
90008952
@@ -9008,7 +8960,7 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba) · 7 unmodified lines
90088960 "6079 Failed allocate NVME LS CQ\n");
90098961 goto out_error;
90108962 }
9011− qdesc->chann = 0;
8963+ qdesc->chann = cpu;
90128964 qdesc->qe_valid = 1;
90138965 phba->sli4_hba.nvmels_cq = qdesc;
90148966
@@ -9021,7 +8973,7 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba) · 6 unmodified lines
90218973 "6080 Failed allocate NVME LS WQ\n");
90228974 goto out_error;
90238975 }
9024− qdesc->chann = 0;
8976+ qdesc->chann = cpu;
90258977 phba->sli4_hba.nvmels_wq = qdesc;
90268978 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list);
90278979 }
@@ -9164,15 +9116,13 @@ lpfc_sli4_release_hdwq(struct lpfc_hba *phba) · 136 unmodified lines
91649116 /* Loop thru all Hardware Queues */
91659117 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) {
91669118 /* Free the CQ/WQ corresponding to the Hardware Queue */
9167− lpfc_sli4_queue_free(hdwq[idx].fcp_cq);
9168− lpfc_sli4_queue_free(hdwq[idx].nvme_cq);
9169− lpfc_sli4_queue_free(hdwq[idx].fcp_wq);
9170− lpfc_sli4_queue_free(hdwq[idx].nvme_wq);
9171− hdwq[idx].hba_eq = NULL;
9172− hdwq[idx].fcp_cq = NULL;
9173− hdwq[idx].nvme_cq = NULL;
9174− hdwq[idx].fcp_wq = NULL;
9175− hdwq[idx].nvme_wq = NULL;
9119+ lpfc_sli4_queue_free(hdwq[idx].io_cq);
9120+ lpfc_sli4_queue_free(hdwq[idx].io_wq);
9121+ hdwq[idx].io_cq = NULL;
9122+ hdwq[idx].io_wq = NULL;
9123+ if (phba->cfg_xpsgl && !phba->nvmet_support)
9124+ lpfc_free_sgl_per_hdwq(phba, &hdwq[idx]);
9125+ lpfc_free_cmd_rsp_buf_per_hdwq(phba, &hdwq[idx]);
91769126 }
91779127 /* Loop thru all IRQ vectors */
91789128 for (idx = 0; idx < phba->cfg_irq_chann; idx++) {
@@ -9372,8 +9322,7 @@ lpfc_setup_cq_lookup(struct lpfc_hba *phba) · 193 unmodified lines
93729322 list_for_each_entry(childq, &eq->child_list, list) {
93739323 if (childq->queue_id > phba->sli4_hba.cq_max)
93749324 continue;
9375− if ((childq->subtype == LPFC_FCP) ||
9376− (childq->subtype == LPFC_NVME))
9325+ if (childq->subtype == LPFC_IO)
93779326 phba->sli4_hba.cq_lookup[childq->queue_id] =
93789327 childq;
93799328 }
@@ -9499,31 +9448,6 @@ lpfc_sli4_queue_setup(struct lpfc_hba *phba) · 119 unmodified lines
94999448 }
95009449
95019450 /* Loop thru all Hardware Queues */
9502− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
9503− for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) {
9504− cpu = lpfc_find_cpu_handle(phba, qidx,
9505− LPFC_FIND_BY_HDWQ);
9506− cpup = &phba->sli4_hba.cpu_map[cpu];
9507−
9508− /* Create the CQ/WQ corresponding to the
9509− * Hardware Queue
9510− */
9511− rc = lpfc_create_wq_cq(phba,
9512− phba->sli4_hba.hdwq[cpup->hdwq].hba_eq,
9513− qp[qidx].nvme_cq,
9514− qp[qidx].nvme_wq,
9515− &phba->sli4_hba.hdwq[qidx].nvme_cq_map,
9516− qidx, LPFC_NVME);
9517− if (rc) {
9518− lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
9519− "6123 Failed to setup fastpath "
9520− "NVME WQ/CQ (%d), rc = 0x%x\n",
9521− qidx, (uint32_t)rc);
9522− goto out_destroy;
9523− }
9524− }
9525− }
9526−
95279451 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) {
95289452 cpu = lpfc_find_cpu_handle(phba, qidx, LPFC_FIND_BY_HDWQ);
95299453 cpup = &phba->sli4_hba.cpu_map[cpu];
@@ -9531,14 +9455,15 @@ lpfc_sli4_queue_setup(struct lpfc_hba *phba) · 1 unmodified line
95319455 /* Create the CQ/WQ corresponding to the Hardware Queue */
95329456 rc = lpfc_create_wq_cq(phba,
95339457 phba->sli4_hba.hdwq[cpup->hdwq].hba_eq,
9534− qp[qidx].fcp_cq,
9535− qp[qidx].fcp_wq,
9536− &phba->sli4_hba.hdwq[qidx].fcp_cq_map,
9537− qidx, LPFC_FCP);
9458+ qp[qidx].io_cq,
9459+ qp[qidx].io_wq,
9460+ &phba->sli4_hba.hdwq[qidx].io_cq_map,
9461+ qidx,
9462+ LPFC_IO);
95389463 if (rc) {
95399464 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
95409465 "0535 Failed to setup fastpath "
9541− "FCP WQ/CQ (%d), rc = 0x%x\n",
9466+ "IO WQ/CQ (%d), rc = 0x%x\n",
95429467 qidx, (uint32_t)rc);
95439468 goto out_destroy;
95449469 }
@@ -9838,10 +9763,8 @@ lpfc_sli4_queue_unset(struct lpfc_hba *phba) · 293 unmodified lines
98389763 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) {
98399764 /* Destroy the CQ/WQ corresponding to Hardware Queue */
98409765 qp = &phba->sli4_hba.hdwq[qidx];
9841− lpfc_wq_destroy(phba, qp->fcp_wq);
9842− lpfc_wq_destroy(phba, qp->nvme_wq);
9843− lpfc_cq_destroy(phba, qp->fcp_cq);
9844− lpfc_cq_destroy(phba, qp->nvme_cq);
9766+ lpfc_wq_destroy(phba, qp->io_wq);
9767+ lpfc_cq_destroy(phba, qp->io_cq);
98459768 }
98469769 /* Loop thru all IRQ vectors */
98479770 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) {
@@ -10711,7 +10634,7 @@ lpfc_find_hyper(struct lpfc_hba *phba, int cpu, · 863 unmodified lines
1071110634 static void
1071210635 lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors)
1071310636 {
10714− int i, cpu, idx, new_cpu, start_cpu, first_cpu;
10637+ int i, cpu, idx, next_idx, new_cpu, start_cpu, first_cpu;
1071510638 int max_phys_id, min_phys_id;
1071610639 int max_core_id, min_core_id;
1071710640 struct lpfc_vector_map_info *cpup;
@@ -10753,8 +10676,8 @@ lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors) · 35 unmodified lines
1075310676 #endif
1075410677
1075510678 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
10756− "3328 CPU physid %d coreid %d\n",
10757− cpup->phys_id, cpup->core_id);
10679+ "3328 CPU %d physid %d coreid %d flag x%x\n",
10680+ cpu, cpup->phys_id, cpup->core_id, cpup->flag);
1075810681
1075910682 if (cpup->phys_id > max_phys_id)
1076010683 max_phys_id = cpup->phys_id;
@@ -10812,17 +10735,17 @@ lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors) · 51 unmodified lines
1081210735 cpup->eq = idx;
1081310736 cpup->irq = pci_irq_vector(phba->pcidev, idx);
1081410737
10815− lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
10816− "3336 Set Affinity: CPU %d "
10817− "irq %d eq %d\n",
10818− cpu, cpup->irq, cpup->eq);
10819−
1082010738 /* If this is the first CPU thats assigned to this
1082110739 * vector, set LPFC_CPU_FIRST_IRQ.
1082210740 */
1082310741 if (!i)
1082410742 cpup->flag |= LPFC_CPU_FIRST_IRQ;
1082510743 i++;
10744+
10745+ lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
10746+ "3336 Set Affinity: CPU %d "
10747+ "irq %d eq %d flag x%x\n",
10748+ cpu, cpup->irq, cpup->eq, cpup->flag);
1082610749 }
1082710750 }
1082810751
@@ -10936,69 +10859,103 @@ found_any: · 107 unmodified lines
1093610859 }
1093710860 }
1093810861
10862+ /* Assign hdwq indices that are unique across all cpus in the map
10863+ * that are also FIRST_CPUs.
10864+ */
10865+ idx = 0;
10866+ for_each_present_cpu(cpu) {
10867+ cpup = &phba->sli4_hba.cpu_map[cpu];
10868+
10869+ /* Only FIRST IRQs get a hdwq index assignment. */
10870+ if (!(cpup->flag & LPFC_CPU_FIRST_IRQ))
10871+ continue;
10872+
10873+ /* 1 to 1, the first LPFC_CPU_FIRST_IRQ cpus to a unique hdwq */
10874+ cpup->hdwq = idx;
10875+ idx++;
10876+ lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
10877+ "3333 Set Affinity: CPU %d (phys %d core %d): "
10878+ "hdwq %d eq %d irq %d flg x%x\n",
10879+ cpu, cpup->phys_id, cpup->core_id,
10880+ cpup->hdwq, cpup->eq, cpup->irq, cpup->flag);
10881+ }
1093910882 /* Finally we need to associate a hdwq with each cpu_map entry
1094010883 * This will be 1 to 1 - hdwq to cpu, unless there are less
1094110884 * hardware queues then CPUs. For that case we will just round-robin
1094210885 * the available hardware queues as they get assigned to CPUs.
10886+ * The next_idx is the idx from the FIRST_CPU loop above to account
10887+ * for irq_chann < hdwq. The idx is used for round-robin assignments
10888+ * and needs to start at 0.
1094310889 */
10944− idx = 0;
10890+ next_idx = idx;
1094510891 start_cpu = 0;
10892+ idx = 0;
1094610893 for_each_present_cpu(cpu) {
1094710894 cpup = &phba->sli4_hba.cpu_map[cpu];
10948− if (idx >= phba->cfg_hdw_queue) {
10949− /* We need to reuse a Hardware Queue for another CPU,
10950− * so be smart about it and pick one that has its
10951− * IRQ/EQ mapped to the same phys_id (CPU package).
10952− * and core_id.
10953− */
10954− new_cpu = start_cpu;
10955− for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) {
10956− new_cpup = &phba->sli4_hba.cpu_map[new_cpu];
10957− if ((new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY) &&
10958− (new_cpup->phys_id == cpup->phys_id) &&
10959− (new_cpup->core_id == cpup->core_id))
10960− goto found_hdwq;
10961− new_cpu = cpumask_next(
10962− new_cpu, cpu_present_mask);
10963− if (new_cpu == nr_cpumask_bits)
10964− new_cpu = first_cpu;
10965− }
1096610895
10967− /* If we can't match both phys_id and core_id,
10968− * settle for just a phys_id match.
10969− */
10970− new_cpu = start_cpu;
10971− for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) {
10972− new_cpup = &phba->sli4_hba.cpu_map[new_cpu];
10973− if ((new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY) &&
10974− (new_cpup->phys_id == cpup->phys_id))
10975− goto found_hdwq;
10976− new_cpu = cpumask_next(
10977− new_cpu, cpu_present_mask);
10978− if (new_cpu == nr_cpumask_bits)
10979− new_cpu = first_cpu;
10896+ /* FIRST cpus are already mapped. */
10897+ if (cpup->flag & LPFC_CPU_FIRST_IRQ)
10898+ continue;
10899+
10900+ /* If the cfg_irq_chann < cfg_hdw_queue, set the hdwq
10901+ * of the unassigned cpus to the next idx so that all
10902+ * hdw queues are fully utilized.
10903+ */
10904+ if (next_idx < phba->cfg_hdw_queue) {
10905+ cpup->hdwq = next_idx;
10906+ next_idx++;
10907+ continue;
10908+ }
10909+
10910+ /* Not a First CPU and all hdw_queues are used. Reuse a
10911+ * Hardware Queue for another CPU, so be smart about it
10912+ * and pick one that has its IRQ/EQ mapped to the same phys_id
10913+ * (CPU package) and core_id.
10914+ */
10915+ new_cpu = start_cpu;
10916+ for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) {
10917+ new_cpup = &phba->sli4_hba.cpu_map[new_cpu];
10918+ if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY &&
10919+ new_cpup->phys_id == cpup->phys_id &&
10920+ new_cpup->core_id == cpup->core_id) {
10921+ goto found_hdwq;
1098010922 }
10923+ new_cpu = cpumask_next(new_cpu, cpu_present_mask);
10924+ if (new_cpu == nr_cpumask_bits)
10925+ new_cpu = first_cpu;
10926+ }
1098110927
10982− /* Otherwise just round robin on cfg_hdw_queue */
10983− cpup->hdwq = idx % phba->cfg_hdw_queue;
10984− goto logit;
10985−found_hdwq:
10986− /* We found an available entry, copy the IRQ info */
10987− start_cpu = cpumask_next(new_cpu, cpu_present_mask);
10988− if (start_cpu == nr_cpumask_bits)
10989− start_cpu = first_cpu;
10990− cpup->hdwq = new_cpup->hdwq;
10991− } else {
10992− /* 1 to 1, CPU to hdwq */
10993− cpup->hdwq = idx;
10928+ /* If we can't match both phys_id and core_id,
10929+ * settle for just a phys_id match.
10930+ */
10931+ new_cpu = start_cpu;
10932+ for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) {
10933+ new_cpup = &phba->sli4_hba.cpu_map[new_cpu];
10934+ if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY &&
10935+ new_cpup->phys_id == cpup->phys_id)
10936+ goto found_hdwq;
10937+
10938+ new_cpu = cpumask_next(new_cpu, cpu_present_mask);
10939+ if (new_cpu == nr_cpumask_bits)
10940+ new_cpu = first_cpu;
1099410941 }
10995−logit:
10942+
10943+ /* Otherwise just round robin on cfg_hdw_queue */
10944+ cpup->hdwq = idx % phba->cfg_hdw_queue;
10945+ idx++;
10946+ goto logit;
10947+ found_hdwq:
10948+ /* We found an available entry, copy the IRQ info */
10949+ start_cpu = cpumask_next(new_cpu, cpu_present_mask);
10950+ if (start_cpu == nr_cpumask_bits)
10951+ start_cpu = first_cpu;
10952+ cpup->hdwq = new_cpup->hdwq;
10953+ logit:
1099610954 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1099710955 "3335 Set Affinity: CPU %d (phys %d core %d): "
1099810956 "hdwq %d eq %d irq %d flg x%x\n",
1099910957 cpu, cpup->phys_id, cpup->core_id,
1100010958 cpup->hdwq, cpup->eq, cpup->irq, cpup->flag);
11001− idx++;
1100210959 }
1100310960
1100410961 /* The cpu_map array will be used later during initialization
@@ -11089,10 +11046,10 @@ vec_fail_out: · 84 unmodified lines
1108911046 * @phba: pointer to lpfc hba data structure.
1109011047 *
1109111048 * This routine is invoked to enable the MSI interrupt mode to device with
11092− * SLI-4 interface spec. The kernel function pci_enable_msi() is called
11093− * to enable the MSI vector. The device driver is responsible for calling
11094− * the request_irq() to register MSI vector with a interrupt the handler,
11095− * which is done in this function.
11049+ * SLI-4 interface spec. The kernel function pci_alloc_irq_vectors() is
11050+ * called to enable the MSI vector. The device driver is responsible for
11051+ * calling the request_irq() to register MSI vector with a interrupt the
11052+ * handler, which is done in this function.
1109611053 *
1109711054 * Return codes
1109811055 * 0 - successful
@@ -11103,20 +11060,21 @@ lpfc_sli4_enable_msi(struct lpfc_hba *phba) · 4 unmodified lines
1110311060 {
1110411061 int rc, index;
1110511062
11106− rc = pci_enable_msi(phba->pcidev);
11107− if (!rc)
11063+ rc = pci_alloc_irq_vectors(phba->pcidev, 1, 1,
11064+ PCI_IRQ_MSI | PCI_IRQ_AFFINITY);
11065+ if (rc > 0)
1110811066 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
1110911067 "0487 PCI enable MSI mode success.\n");
1111011068 else {
1111111069 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
1111211070 "0488 PCI enable MSI mode failed (%d)\n", rc);
11113− return rc;
11071+ return rc ? rc : -1;
1111411072 }
1111511073
1111611074 rc = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler,
1111711075 0, LPFC_DRIVER_NAME, phba);
1111811076 if (rc) {
11119− pci_disable_msi(phba->pcidev);
11077+ pci_free_irq_vectors(phba->pcidev);
1112011078 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
1112111079 "0490 MSI request_irq failed (%d)\n", rc);
1112211080 return rc;
@@ -11282,11 +11240,10 @@ static void · 159 unmodified lines
1128211240 lpfc_sli4_xri_exchange_busy_wait(struct lpfc_hba *phba)
1128311241 {
1128411242 struct lpfc_sli4_hdw_queue *qp;
11285− int idx, ccnt, fcnt;
11243+ int idx, ccnt;
1128611244 int wait_time = 0;
1128711245 int io_xri_cmpl = 1;
1128811246 int nvmet_xri_cmpl = 1;
11289− int fcp_xri_cmpl = 1;
1129011247 int els_xri_cmpl = list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list);
1129111248
1129211249 /* Driver just aborted IOs during the hba_unset process. Pause
@@ -11300,32 +11257,21 @@ lpfc_sli4_xri_exchange_busy_wait(struct lpfc_hba *phba) · 7 unmodified lines
1130011257 lpfc_nvme_wait_for_io_drain(phba);
1130111258
1130211259 ccnt = 0;
11303− fcnt = 0;
1130411260 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) {
1130511261 qp = &phba->sli4_hba.hdwq[idx];
11306− fcp_xri_cmpl = list_empty(
11307− &qp->lpfc_abts_scsi_buf_list);
11308− if (!fcp_xri_cmpl) /* if list is NOT empty */
11309− fcnt++;
11310− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
11311− io_xri_cmpl = list_empty(
11312− &qp->lpfc_abts_nvme_buf_list);
11313− if (!io_xri_cmpl) /* if list is NOT empty */
11314− ccnt++;
11315− }
11262+ io_xri_cmpl = list_empty(&qp->lpfc_abts_io_buf_list);
11263+ if (!io_xri_cmpl) /* if list is NOT empty */
11264+ ccnt++;
1131611265 }
1131711266 if (ccnt)
1131811267 io_xri_cmpl = 0;
11319− if (fcnt)
11320− fcp_xri_cmpl = 0;
1132111268
1132211269 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
1132311270 nvmet_xri_cmpl =
1132411271 list_empty(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list);
1132511272 }
1132611273
11327− while (!fcp_xri_cmpl || !els_xri_cmpl || !io_xri_cmpl ||
11328− !nvmet_xri_cmpl) {
11274+ while (!els_xri_cmpl || !io_xri_cmpl || !nvmet_xri_cmpl) {
1132911275 if (wait_time > LPFC_XRI_EXCH_BUSY_WAIT_TMO) {
1133011276 if (!nvmet_xri_cmpl)
1133111277 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
@@ -11334,12 +11280,7 @@ lpfc_sli4_xri_exchange_busy_wait(struct lpfc_hba *phba) · 2 unmodified lines
1133411280 wait_time/1000);
1133511281 if (!io_xri_cmpl)
1133611282 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
11337− "6100 NVME XRI exchange busy "
11338− "wait time: %d seconds.\n",
11339− wait_time/1000);
11340− if (!fcp_xri_cmpl)
11341− lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
11342− "2877 FCP XRI exchange busy "
11283+ "6100 IO XRI exchange busy "
1134311284 "wait time: %d seconds.\n",
1134411285 wait_time/1000);
1134511286 if (!els_xri_cmpl)
@@ -11355,24 +11296,15 @@ lpfc_sli4_xri_exchange_busy_wait(struct lpfc_hba *phba) · 9 unmodified lines
1135511296 }
1135611297
1135711298 ccnt = 0;
11358− fcnt = 0;
1135911299 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) {
1136011300 qp = &phba->sli4_hba.hdwq[idx];
11361− fcp_xri_cmpl = list_empty(
11362− &qp->lpfc_abts_scsi_buf_list);
11363− if (!fcp_xri_cmpl) /* if list is NOT empty */
11364− fcnt++;
11365− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
11366− io_xri_cmpl = list_empty(
11367− &qp->lpfc_abts_nvme_buf_list);
11368− if (!io_xri_cmpl) /* if list is NOT empty */
11369− ccnt++;
11370− }
11301+ io_xri_cmpl = list_empty(
11302+ &qp->lpfc_abts_io_buf_list);
11303+ if (!io_xri_cmpl) /* if list is NOT empty */
11304+ ccnt++;
1137111305 }
1137211306 if (ccnt)
1137311307 io_xri_cmpl = 0;
11374− if (fcnt)
11375− fcp_xri_cmpl = 0;
1137611308
1137711309 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
1137811310 nvmet_xri_cmpl = list_empty(
@@ -11616,6 +11548,9 @@ lpfc_get_sli4_parameters(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) · 237 unmodified lines
1161611548 phba->sli4_hba.extents_in_use = bf_get(cfg_ext, mbx_sli4_parameters);
1161711549 phba->sli4_hba.rpi_hdrs_in_use = bf_get(cfg_hdrr, mbx_sli4_parameters);
1161811550
11551+ /* Check for Extended Pre-Registered SGL support */
11552+ phba->cfg_xpsgl = bf_get(cfg_xpsgl, mbx_sli4_parameters);
11553+
1161911554 /* Check for firmware nvme support */
1162011555 rc = (bf_get(cfg_nvme, mbx_sli4_parameters) &&
1162111556 bf_get(cfg_xib, mbx_sli4_parameters));
@@ -11646,6 +11581,7 @@ fcponly: · 24 unmodified lines
1164611581 phba->nvme_support = 0;
1164711582 phba->nvmet_support = 0;
1164811583 phba->cfg_nvmet_mrq = 0;
11584+ phba->cfg_nvme_seg_cnt = 0;
1164911585
1165011586 /* If no FC4 type support, move to just SCSI support */
1165111587 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP))
@@ -11654,6 +11590,15 @@ fcponly: · 2 unmodified lines
1165411590 }
1165511591 }
1165611592
11593+ /* If the NVME FC4 type is enabled, scale the sg_seg_cnt to
11594+ * accommodate 512K and 1M IOs in a single nvme buf and supply
11595+ * enough NVME LS iocb buffers for larger connectivity counts.
11596+ */
11597+ if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
11598+ phba->cfg_sg_seg_cnt = LPFC_MAX_NVME_SEG_CNT;
11599+ phba->cfg_iocb_cnt = 5;
11600+ }
11601+
1165711602 /* Only embed PBDE for if_type 6, PBDE support requires xib be set */
1165811603 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) !=
1165911604 LPFC_SLI_INTF_IF_TYPE_6) || (!bf_get(cfg_xib, mbx_sli4_parameters)))
@@ -11718,6 +11663,14 @@ fcponly: · 58 unmodified lines
1171811663 else
1171911664 phba->mds_diags_support = 0;
1172011665
11666+ /*
11667+ * Check if the SLI port supports NSLER
11668+ */
11669+ if (bf_get(cfg_nsler, mbx_sli4_parameters))
11670+ phba->nsler = 1;
11671+ else
11672+ phba->nsler = 0;
11673+
1172111674 return 0;
1172211675 }
1172311676
@@ -12146,7 +12099,7 @@ lpfc_sli_prep_dev_for_reset(struct lpfc_hba *phba) · 422 unmodified lines
1214612099 lpfc_scsi_dev_block(phba);
1214712100
1214812101 /* Flush all driver's outstanding SCSI I/Os as we are to reset */
12149− lpfc_sli_flush_fcp_rings(phba);
12102+ lpfc_sli_flush_io_rings(phba);
1215012103
1215112104 /* stop all timers */
1215212105 lpfc_stop_hba_timers(phba);
@@ -12176,7 +12129,7 @@ lpfc_sli_prep_dev_for_perm_failure(struct lpfc_hba *phba) · 23 unmodified lines
1217612129 lpfc_stop_hba_timers(phba);
1217712130
1217812131 /* Clean up all driver's outstanding SCSI I/Os */
12179− lpfc_sli_flush_fcp_rings(phba);
12132+ lpfc_sli_flush_io_rings(phba);
1218012133 }
1218112134
1218212135 /**
@@ -12948,12 +12901,8 @@ lpfc_sli4_prep_dev_for_reset(struct lpfc_hba *phba) · 765 unmodified lines
1294812901 /* Block all SCSI devices' I/Os on the host */
1294912902 lpfc_scsi_dev_block(phba);
1295012903
12951− /* Flush all driver's outstanding SCSI I/Os as we are to reset */
12952− lpfc_sli_flush_fcp_rings(phba);
12953−
12954− /* Flush the outstanding NVME IOs if fc4 type enabled. */
12955− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)
12956− lpfc_sli_flush_nvme_rings(phba);
12904+ /* Flush all driver's outstanding I/Os as we are to reset */
12905+ lpfc_sli_flush_io_rings(phba);
1295712906
1295812907 /* stop all timers */
1295912908 lpfc_stop_hba_timers(phba);
@@ -12984,12 +12933,8 @@ lpfc_sli4_prep_dev_for_perm_failure(struct lpfc_hba *phba) · 24 unmodified lines
1298412933 /* stop all timers */
1298512934 lpfc_stop_hba_timers(phba);
1298612935
12987− /* Clean up all driver's outstanding SCSI I/Os */
12988− lpfc_sli_flush_fcp_rings(phba);
12989−
12990− /* Flush the outstanding NVME IOs if fc4 type enabled. */
12991− if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)
12992− lpfc_sli_flush_nvme_rings(phba);
12936+ /* Clean up all driver's outstanding I/Os */
12937+ lpfc_sli_flush_io_rings(phba);
1299312938 }
1299412939
1299512940 /**
@@ -13530,19 +13475,6 @@ lpfc_exit(void) · 534 unmodified lines
1353013475 pci_unregister_driver(&lpfc_driver);
1353113476 fc_release_transport(lpfc_transport_template);
1353213477 fc_release_transport(lpfc_vport_transport_template);
13533− if (_dump_buf_data) {
13534− printk(KERN_ERR "9062 BLKGRD: freeing %lu pages for "
13535− "_dump_buf_data at 0x%p\n",
13536− (1L << _dump_buf_data_order), _dump_buf_data);
13537− free_pages((unsigned long)_dump_buf_data, _dump_buf_data_order);
13538− }
13539−
13540− if (_dump_buf_dif) {
13541− printk(KERN_ERR "9049 BLKGRD: freeing %lu pages for "
13542− "_dump_buf_dif at 0x%p\n",
13543− (1L << _dump_buf_dif_order), _dump_buf_dif);
13544− free_pages((unsigned long)_dump_buf_dif, _dump_buf_dif_order);
13545− }
1354613478 idr_destroy(&lpfc_hba_index);
1354713479 }
1354813480
drivers/scsi/lpfc/lpfc_mem.c+19−46
@@ -72,8 +72,8 @@ lpfc_mem_alloc_active_rrq_pool_s4(struct lpfc_hba *phba) { · 71 unmodified lines
7272 * lpfc_mem_alloc - create and allocate all PCI and memory pools
7373 * @phba: HBA to allocate pools for
7474 *
75− * Description: Creates and allocates PCI pools lpfc_sg_dma_buf_pool,
76− * lpfc_mbuf_pool, lpfc_hrb_pool. Creates and allocates kmalloc-backed mempools
75+ * Description: Creates and allocates PCI pools lpfc_mbuf_pool,
76+ * lpfc_hrb_pool. Creates and allocates kmalloc-backed mempools
7777 * for LPFC_MBOXQ_t and lpfc_nodelist. Also allocates the VPI bitmask.
7878 *
7979 * Notes: Not interrupt-safe. Must be called with no locks held. If any
@@ -89,36 +89,12 @@ lpfc_mem_alloc(struct lpfc_hba *phba, int align) · 9 unmodified lines
8989 struct lpfc_dma_pool *pool = &phba->lpfc_mbuf_safety_pool;
9090 int i;
9191
92− if (phba->sli_rev == LPFC_SLI_REV4) {
93− /* Calculate alignment */
94− if (phba->cfg_sg_dma_buf_size < SLI4_PAGE_SIZE)
95− i = phba->cfg_sg_dma_buf_size;
96− else
97− i = SLI4_PAGE_SIZE;
98−
99− phba->lpfc_sg_dma_buf_pool =
100− dma_pool_create("lpfc_sg_dma_buf_pool",
101− &phba->pcidev->dev,
102− phba->cfg_sg_dma_buf_size,
103− i, 0);
104− if (!phba->lpfc_sg_dma_buf_pool)
105− goto fail;
106−
107− } else {
108− phba->lpfc_sg_dma_buf_pool =
109− dma_pool_create("lpfc_sg_dma_buf_pool",
110− &phba->pcidev->dev, phba->cfg_sg_dma_buf_size,
111− align, 0);
112−
113− if (!phba->lpfc_sg_dma_buf_pool)
114− goto fail;
115− }
11692
11793 phba->lpfc_mbuf_pool = dma_pool_create("lpfc_mbuf_pool", &phba->pcidev->dev,
11894 LPFC_BPL_SIZE,
11995 align, 0);
12096 if (!phba->lpfc_mbuf_pool)
121− goto fail_free_dma_buf_pool;
97+ goto fail;
12298
12399 pool->elements = kmalloc_array(LPFC_MBUF_POOL_SIZE,
124100 sizeof(struct lpfc_dmabuf),
@@ -208,9 +184,6 @@ fail_free_drb_pool: · 83 unmodified lines
208184 fail_free_lpfc_mbuf_pool:
209185 dma_pool_destroy(phba->lpfc_mbuf_pool);
210186 phba->lpfc_mbuf_pool = NULL;
211− fail_free_dma_buf_pool:
212− dma_pool_destroy(phba->lpfc_sg_dma_buf_pool);
213− phba->lpfc_sg_dma_buf_pool = NULL;
214187 fail:
215188 return -ENOMEM;
216189 }
@@ -248,25 +221,22 @@ lpfc_mem_free(struct lpfc_hba *phba) · 31 unmodified lines
248221
249222 /* Free HBQ pools */
250223 lpfc_sli_hbqbuf_free_all(phba);
251− if (phba->lpfc_nvmet_drb_pool)
252− dma_pool_destroy(phba->lpfc_nvmet_drb_pool);
224+ dma_pool_destroy(phba->lpfc_nvmet_drb_pool);
253225 phba->lpfc_nvmet_drb_pool = NULL;
254− if (phba->lpfc_drb_pool)
255− dma_pool_destroy(phba->lpfc_drb_pool);
226+
227+ dma_pool_destroy(phba->lpfc_drb_pool);
256228 phba->lpfc_drb_pool = NULL;
257− if (phba->lpfc_hrb_pool)
258− dma_pool_destroy(phba->lpfc_hrb_pool);
229+
230+ dma_pool_destroy(phba->lpfc_hrb_pool);
259231 phba->lpfc_hrb_pool = NULL;
260− if (phba->txrdy_payload_pool)
261− dma_pool_destroy(phba->txrdy_payload_pool);
232+
233+ dma_pool_destroy(phba->txrdy_payload_pool);
262234 phba->txrdy_payload_pool = NULL;
263235
264− if (phba->lpfc_hbq_pool)
265− dma_pool_destroy(phba->lpfc_hbq_pool);
236+ dma_pool_destroy(phba->lpfc_hbq_pool);
266237 phba->lpfc_hbq_pool = NULL;
267238
268− if (phba->rrq_pool)
269− mempool_destroy(phba->rrq_pool);
239+ mempool_destroy(phba->rrq_pool);
270240 phba->rrq_pool = NULL;
271241
272242 /* Free NLP memory pool */
@@ -290,10 +260,6 @@ lpfc_mem_free(struct lpfc_hba *phba) · 17 unmodified lines
290260 dma_pool_destroy(phba->lpfc_mbuf_pool);
291261 phba->lpfc_mbuf_pool = NULL;
292262
293− /* Free DMA buffer memory pool */
294− dma_pool_destroy(phba->lpfc_sg_dma_buf_pool);
295− phba->lpfc_sg_dma_buf_pool = NULL;
296−
297263 /* Free Device Data memory pool */
298264 if (phba->device_data_mem_pool) {
299265 /* Ensure all objects have been returned to the pool */
@@ -366,6 +332,13 @@ lpfc_mem_free_all(struct lpfc_hba *phba) · 66 unmodified lines
366332 /* Free and destroy all the allocated memory pools */
367333 lpfc_mem_free(phba);
368334
335+ /* Free DMA buffer memory pool */
336+ dma_pool_destroy(phba->lpfc_sg_dma_buf_pool);
337+ phba->lpfc_sg_dma_buf_pool = NULL;
338+
339+ dma_pool_destroy(phba->lpfc_cmd_rsp_buf_pool);
340+ phba->lpfc_cmd_rsp_buf_pool = NULL;
341+
369342 /* Free the iocb lookup array */
370343 kfree(psli->iocbq_lookup);
371344 psli->iocbq_lookup = NULL;
drivers/scsi/lpfc/lpfc_nportdisc.c+36−7
@@ -614,7 +614,7 @@ lpfc_rcv_padisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 613 unmodified lines
614614 }
615615 out:
616616 /* If we are authenticated, move to the proper state */
617− if (ndlp->nlp_type & NLP_FCP_TARGET)
617+ if (ndlp->nlp_type & (NLP_FCP_TARGET | NLP_NVME_TARGET))
618618 lpfc_nlp_set_state(vport, ndlp, NLP_STE_MAPPED_NODE);
619619 else
620620 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
@@ -799,9 +799,15 @@ lpfc_rcv_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 178 unmodified lines
799799 if (npr->writeXferRdyDis)
800800 ndlp->nlp_flag |= NLP_FIRSTBURST;
801801 }
802− if (npr->Retry)
802+ if (npr->Retry && ndlp->nlp_type &
803+ (NLP_FCP_INITIATOR | NLP_FCP_TARGET))
803804 ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE;
804805
806+ if (npr->Retry && phba->nsler &&
807+ ndlp->nlp_type & (NLP_NVME_INITIATOR | NLP_NVME_TARGET))
808+ ndlp->nlp_nvme_info |= NLP_NVME_NSLER;
809+
810+
805811 /* If this driver is in nvme target mode, set the ndlp's fc4
806812 * type to NVME provided the PRLI response claims NVME FC4
807813 * type. Target mode does not issue gft_id so doesn't get
@@ -885,7 +891,7 @@ lpfc_release_rpi(struct lpfc_hba *phba, struct lpfc_vport *vport, · 77 unmodified lines
885891 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
886892 "1435 release_rpi SKIP UNREG x%x on "
887893 "NPort x%x deferred x%x flg x%x "
888− "Data: %p\n",
894+ "Data: x%px\n",
889895 ndlp->nlp_rpi, ndlp->nlp_DID,
890896 ndlp->nlp_defer_did,
891897 ndlp->nlp_flag, ndlp);
@@ -1661,6 +1667,7 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport, · 769 unmodified lines
16611667 LPFC_MBOXQ_t *mb;
16621668 LPFC_MBOXQ_t *nextmb;
16631669 struct lpfc_dmabuf *mp;
1670+ struct lpfc_nodelist *ns_ndlp;
16641671
16651672 cmdiocb = (struct lpfc_iocbq *) arg;
16661673
@@ -1693,6 +1700,13 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport, · 26 unmodified lines
16931700 }
16941701 spin_unlock_irq(&phba->hbalock);
16951702
1703+ /* software abort if any GID_FT is outstanding */
1704+ if (vport->cfg_enable_fc4_type != LPFC_ENABLE_FCP) {
1705+ ns_ndlp = lpfc_findnode_did(vport, NameServer_DID);
1706+ if (ns_ndlp && NLP_CHK_NODE_ACT(ns_ndlp))
1707+ lpfc_els_abort(phba, ns_ndlp);
1708+ }
1709+
16961710 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO);
16971711 return ndlp->nlp_state;
16981712 }
@@ -1814,7 +1828,11 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport *vport, · 115 unmodified lines
18141828
18151829 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
18161830 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
1817− lpfc_issue_els_prli(vport, ndlp, 0);
1831+ if (lpfc_issue_els_prli(vport, ndlp, 0)) {
1832+ lpfc_issue_els_logo(vport, ndlp, 0);
1833+ ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1834+ lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
1835+ }
18181836 } else {
18191837 if ((vport->fc_flag & FC_PT2PT) && phba->nvmet_support)
18201838 phba->targetport->port_id = vport->fc_myDID;
@@ -2012,6 +2030,11 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 191 unmodified lines
20122030 if (bf_get_be32(prli_init, nvpr))
20132031 ndlp->nlp_type |= NLP_NVME_INITIATOR;
20142032
2033+ if (phba->nsler && bf_get_be32(prli_nsler, nvpr))
2034+ ndlp->nlp_nvme_info |= NLP_NVME_NSLER;
2035+ else
2036+ ndlp->nlp_nvme_info &= ~NLP_NVME_NSLER;
2037+
20152038 /* Target driver cannot solicit NVME FB. */
20162039 if (bf_get_be32(prli_tgt, nvpr)) {
20172040 /* Complete the nvme target roles. The transport
@@ -2891,18 +2914,21 @@ lpfc_disc_state_machine(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 873 unmodified lines
28912914 uint32_t(*func) (struct lpfc_vport *, struct lpfc_nodelist *, void *,
28922915 uint32_t);
28932916 uint32_t got_ndlp = 0;
2917+ uint32_t data1;
28942918
28952919 if (lpfc_nlp_get(ndlp))
28962920 got_ndlp = 1;
28972921
28982922 cur_state = ndlp->nlp_state;
28992923
2924+ data1 = (((uint32_t)ndlp->nlp_fc4_type << 16) |
2925+ ((uint32_t)ndlp->nlp_type));
29002926 /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */
29012927 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
29022928 "0211 DSM in event x%x on NPort x%x in "
29032929 "state %d rpi x%x Data: x%x x%x\n",
29042930 evt, ndlp->nlp_DID, cur_state, ndlp->nlp_rpi,
2905− ndlp->nlp_flag, ndlp->nlp_fc4_type);
2931+ ndlp->nlp_flag, data1);
29062932
29072933 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
29082934 "DSM in: evt:%d ste:%d did:x%x",
@@ -2913,10 +2939,13 @@ lpfc_disc_state_machine(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 4 unmodified lines
29132939
29142940 /* DSM out state <rc> on NPort <nlp_DID> */
29152941 if (got_ndlp) {
2942+ data1 = (((uint32_t)ndlp->nlp_fc4_type << 16) |
2943+ ((uint32_t)ndlp->nlp_type));
29162944 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
29172945 "0212 DSM out state %d on NPort x%x "
2918− "rpi x%x Data: x%x\n",
2919− rc, ndlp->nlp_DID, ndlp->nlp_rpi, ndlp->nlp_flag);
2946+ "rpi x%x Data: x%x x%x\n",
2947+ rc, ndlp->nlp_DID, ndlp->nlp_rpi, ndlp->nlp_flag,
2948+ data1);
29202949
29212950 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
29222951 "DSM out: ste:%d did:x%x flg:x%x",
drivers/scsi/lpfc/lpfc_nvme.c+245−144
@@ -247,7 +247,7 @@ lpfc_nvme_create_queue(struct nvme_fc_local_port *pnvme_lport, · 246 unmodified lines
247247
248248 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME,
249249 "6073 Binding %s HdwQueue %d (cpu %d) to "
250− "hdw_queue %d qhandle %p\n", str,
250+ "hdw_queue %d qhandle x%px\n", str,
251251 qidx, qhandle->cpu_id, qhandle->index, qhandle);
252252 *handle = (void *)qhandle;
253253 return 0;
@@ -282,7 +282,7 @@ lpfc_nvme_delete_queue(struct nvme_fc_local_port *pnvme_lport, · 28 unmodified lines
282282 vport = lport->vport;
283283
284284 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME,
285− "6001 ENTER. lpfc_pnvme %p, qidx x%x qhandle %p\n",
285+ "6001 ENTER. lpfc_pnvme x%px, qidx x%x qhandle x%px\n",
286286 lport, qidx, handle);
287287 kfree(handle);
288288 }
@@ -293,7 +293,7 @@ lpfc_nvme_localport_delete(struct nvme_fc_local_port *localport) · 4 unmodified lines
293293 struct lpfc_nvme_lport *lport = localport->private;
294294
295295 lpfc_printf_vlog(lport->vport, KERN_INFO, LOG_NVME,
296− "6173 localport %p delete complete\n",
296+ "6173 localport x%px delete complete\n",
297297 lport);
298298
299299 /* release any threads waiting for the unreg to complete */
@@ -332,7 +332,7 @@ lpfc_nvme_remoteport_delete(struct nvme_fc_remote_port *remoteport) · 32 unmodified lines
332332 * calling state machine to remove the node.
333333 */
334334 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
335− "6146 remoteport delete of remoteport %p\n",
335+ "6146 remoteport delete of remoteport x%px\n",
336336 remoteport);
337337 spin_lock_irq(&vport->phba->hbalock);
338338
@@ -383,8 +383,8 @@ lpfc_nvme_cmpl_gen_req(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 44 unmodified lines
383383 ndlp = (struct lpfc_nodelist *)cmdwqe->context1;
384384 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
385385 "6047 nvme cmpl Enter "
386− "Data %p DID %x Xri: %x status %x reason x%x cmd:%p "
387− "lsreg:%p bmp:%p ndlp:%p\n",
386+ "Data %px DID %x Xri: %x status %x reason x%x "
387+ "cmd:x%px lsreg:x%px bmp:x%px ndlp:x%px\n",
388388 pnvme_lsreq, ndlp ? ndlp->nlp_DID : 0,
389389 cmdwqe->sli4_xritag, status,
390390 (wcqe->parameter & 0xffff),
@@ -404,7 +404,7 @@ lpfc_nvme_cmpl_gen_req(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 13 unmodified lines
404404 else
405405 lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_DISC,
406406 "6046 nvme cmpl without done call back? "
407− "Data %p DID %x Xri: %x status %x\n",
407+ "Data %px DID %x Xri: %x status %x\n",
408408 pnvme_lsreq, ndlp ? ndlp->nlp_DID : 0,
409409 cmdwqe->sli4_xritag, status);
410410 if (ndlp) {
@@ -436,6 +436,7 @@ lpfc_nvme_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, · 25 unmodified lines
436436 return 1;
437437
438438 wqe = &genwqe->wqe;
439+ /* Initialize only 64 bytes */
439440 memset(wqe, 0, sizeof(union lpfc_wqe));
440441
441442 genwqe->context3 = (uint8_t *)bmp;
@@ -516,7 +517,8 @@ lpfc_nvme_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, · 74 unmodified lines
516517 /* Issue GEN REQ WQE for NPORT <did> */
517518 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
518519 "6050 Issue GEN REQ WQE to NPORT x%x "
519− "Data: x%x x%x wq:%p lsreq:%p bmp:%p xmit:%d 1st:%d\n",
520+ "Data: x%x x%x wq:x%px lsreq:x%px bmp:x%px "
521+ "xmit:%d 1st:%d\n",
520522 ndlp->nlp_DID, genwqe->iotag,
521523 vport->port_state,
522524 genwqe, pnvme_lsreq, bmp, xmit_len, first_len);
@@ -594,7 +596,7 @@ lpfc_nvme_ls_req(struct nvme_fc_local_port *pnvme_lport, · 71 unmodified lines
594596 ndlp = rport->ndlp;
595597 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) {
596598 lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE | LOG_NVME_IOERR,
597− "6051 Remoteport %p, rport has invalid ndlp. "
599+ "6051 Remoteport x%px, rport has invalid ndlp. "
598600 "Failing LS Req\n", pnvme_rport);
599601 return -ENODEV;
600602 }
@@ -646,10 +648,10 @@ lpfc_nvme_ls_req(struct nvme_fc_local_port *pnvme_lport, · 45 unmodified lines
646648
647649 /* Expand print to include key fields. */
648650 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
649− "6149 Issue LS Req to DID 0x%06x lport %p, rport %p "
650− "lsreq%p rqstlen:%d rsplen:%d %pad %pad\n",
651− ndlp->nlp_DID,
652− pnvme_lport, pnvme_rport,
651+ "6149 Issue LS Req to DID 0x%06x lport x%px, "
652+ "rport x%px lsreq x%px rqstlen:%d rsplen:%d "
653+ "%pad %pad\n",
654+ ndlp->nlp_DID, pnvme_lport, pnvme_rport,
653655 pnvme_lsreq, pnvme_lsreq->rqstlen,
654656 pnvme_lsreq->rsplen, &pnvme_lsreq->rqstdma,
655657 &pnvme_lsreq->rspdma);
@@ -665,8 +667,8 @@ lpfc_nvme_ls_req(struct nvme_fc_local_port *pnvme_lport, · 9 unmodified lines
665667 if (ret != WQE_SUCCESS) {
666668 atomic_inc(&lport->xmt_ls_err);
667669 lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_DISC,
668− "6052 EXIT. issue ls wqe failed lport %p, "
669− "rport %p lsreq%p Status %x DID %x\n",
670+ "6052 EXIT. issue ls wqe failed lport x%px, "
671+ "rport x%px lsreq x%px Status %x DID %x\n",
670672 pnvme_lport, pnvme_rport, pnvme_lsreq,
671673 ret, ndlp->nlp_DID);
672674 lpfc_mbuf_free(vport->phba, bmp->virt, bmp->phys);
@@ -723,7 +725,7 @@ lpfc_nvme_ls_abort(struct nvme_fc_local_port *pnvme_lport, · 50 unmodified lines
723725
724726 /* Expand print to include key fields. */
725727 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_ABTS,
726− "6040 ENTER. lport %p, rport %p lsreq %p rqstlen:%d "
728+ "6040 ENTER. lport x%px, rport x%px lsreq x%px rqstlen:%d "
727729 "rsplen:%d %pad %pad\n",
728730 pnvme_lport, pnvme_rport,
729731 pnvme_lsreq, pnvme_lsreq->rqstlen,
@@ -984,8 +986,8 @@ lpfc_nvme_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, · 254 unmodified lines
984986 if (!lpfc_ncmd->nvmeCmd) {
985987 spin_unlock(&lpfc_ncmd->buf_lock);
986988 lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE | LOG_NVME_IOERR,
987− "6066 Missing cmpl ptrs: lpfc_ncmd %p, "
988− "nvmeCmd %p\n",
989+ "6066 Missing cmpl ptrs: lpfc_ncmd x%px, "
990+ "nvmeCmd x%px\n",
989991 lpfc_ncmd, lpfc_ncmd->nvmeCmd);
990992
991993 /* Release the lpfc_ncmd regardless of the missing elements. */
@@ -998,9 +1000,9 @@ lpfc_nvme_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, · 6 unmodified lines
9981000 idx = lpfc_ncmd->cur_iocbq.hba_wqidx;
9991001 phba->sli4_hba.hdwq[idx].nvme_cstat.io_cmpls++;
10001002
1001− if (vport->localport) {
1003+ if (unlikely(status && vport->localport)) {
10021004 lport = (struct lpfc_nvme_lport *)vport->localport->private;
1003− if (lport && status) {
1005+ if (lport) {
10041006 if (bf_get(lpfc_wcqe_c_xb, wcqe))
10051007 atomic_inc(&lport->cmpl_fcp_xb);
10061008 atomic_inc(&lport->cmpl_fcp_err);
@@ -1100,8 +1102,8 @@ lpfc_nvme_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, · 93 unmodified lines
11001102 if (lpfc_ncmd->result == IOERR_ABORT_REQUESTED)
11011103 lpfc_printf_vlog(vport, KERN_INFO,
11021104 LOG_NVME_IOERR,
1103− "6032 Delay Aborted cmd %p "
1104− "nvme cmd %p, xri x%x, "
1105+ "6032 Delay Aborted cmd x%px "
1106+ "nvme cmd x%px, xri x%x, "
11051107 "xb %d\n",
11061108 lpfc_ncmd, nCmd,
11071109 lpfc_ncmd->cur_iocbq.sli4_xritag,
@@ -1140,7 +1142,7 @@ out_err: · 32 unmodified lines
11401142 phba->ktime_last_cmd = lpfc_ncmd->ts_data_nvme;
11411143 lpfc_nvme_ktime(phba, lpfc_ncmd);
11421144 }
1143− if (phba->cpucheck_on & LPFC_CHECK_NVME_IO) {
1145+ if (unlikely(phba->cpucheck_on & LPFC_CHECK_NVME_IO)) {
11441146 uint32_t cpu;
11451147 idx = lpfc_ncmd->cur_iocbq.hba_wqidx;
11461148 cpu = raw_smp_processor_id();
@@ -1253,6 +1255,9 @@ lpfc_nvme_prep_io_cmd(struct lpfc_vport *vport, · 106 unmodified lines
12531255 sizeof(uint32_t) * 8);
12541256 cstat->control_requests++;
12551257 }
1258+
1259+ if (pnode->nlp_nvme_info & NLP_NVME_NSLER)
1260+ bf_set(wqe_erp, &wqe->generic.wqe_com, 1);
12561261 /*
12571262 * Finish initializing those WQE fields that are independent
12581263 * of the nvme_cmnd request_buffer
@@ -1304,14 +1309,16 @@ lpfc_nvme_prep_io_dma(struct lpfc_vport *vport, · 45 unmodified lines
13041309 struct nvmefc_fcp_req *nCmd = lpfc_ncmd->nvmeCmd;
13051310 union lpfc_wqe128 *wqe = &lpfc_ncmd->cur_iocbq.wqe;
13061311 struct sli4_sge *sgl = lpfc_ncmd->dma_sgl;
1312+ struct sli4_hybrid_sgl *sgl_xtra = NULL;
13071313 struct scatterlist *data_sg;
13081314 struct sli4_sge *first_data_sgl;
13091315 struct ulp_bde64 *bde;
1310− dma_addr_t physaddr;
1316+ dma_addr_t physaddr = 0;
13111317 uint32_t num_bde = 0;
1312− uint32_t dma_len;
1318+ uint32_t dma_len = 0;
13131319 uint32_t dma_offset = 0;
1314− int nseg, i;
1320+ int nseg, i, j;
1321+ bool lsp_just_set = false;
13151322
13161323 /* Fix up the command and response DMA stuff. */
13171324 lpfc_nvme_adj_fcp_sgls(vport, lpfc_ncmd, nCmd);
@@ -1348,6 +1355,9 @@ lpfc_nvme_prep_io_dma(struct lpfc_vport *vport, · 30 unmodified lines
13481355 */
13491356 nseg = nCmd->sg_cnt;
13501357 data_sg = nCmd->first_sgl;
1358+
1359+ /* for tracking the segment boundaries */
1360+ j = 2;
13511361 for (i = 0; i < nseg; i++) {
13521362 if (data_sg == NULL) {
13531363 lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR,
@@ -1356,23 +1366,76 @@ lpfc_nvme_prep_io_dma(struct lpfc_vport *vport, · 2 unmodified lines
13561366 lpfc_ncmd->seg_cnt = 0;
13571367 return 1;
13581368 }
1359− physaddr = data_sg->dma_address;
1360− dma_len = data_sg->length;
1361− sgl->addr_lo = cpu_to_le32(putPaddrLow(physaddr));
1362− sgl->addr_hi = cpu_to_le32(putPaddrHigh(physaddr));
1363− sgl->word2 = le32_to_cpu(sgl->word2);
1364− if ((num_bde + 1) == nseg)
1369+
1370+ sgl->word2 = 0;
1371+ if ((num_bde + 1) == nseg) {
13651372 bf_set(lpfc_sli4_sge_last, sgl, 1);
1366− else
1373+ bf_set(lpfc_sli4_sge_type, sgl,
1374+ LPFC_SGE_TYPE_DATA);
1375+ } else {
13671376 bf_set(lpfc_sli4_sge_last, sgl, 0);
1368− bf_set(lpfc_sli4_sge_offset, sgl, dma_offset);
1369− bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_DATA);
1370− sgl->word2 = cpu_to_le32(sgl->word2);
1371− sgl->sge_len = cpu_to_le32(dma_len);
1372−
1373− dma_offset += dma_len;
1374− data_sg = sg_next(data_sg);
1375− sgl++;
1377+
1378+ /* expand the segment */
1379+ if (!lsp_just_set &&
1380+ !((j + 1) % phba->border_sge_num) &&
1381+ ((nseg - 1) != i)) {
1382+ /* set LSP type */
1383+ bf_set(lpfc_sli4_sge_type, sgl,
1384+ LPFC_SGE_TYPE_LSP);
1385+
1386+ sgl_xtra = lpfc_get_sgl_per_hdwq(
1387+ phba, lpfc_ncmd);
1388+
1389+ if (unlikely(!sgl_xtra)) {
1390+ lpfc_ncmd->seg_cnt = 0;
1391+ return 1;
1392+ }
1393+ sgl->addr_lo = cpu_to_le32(putPaddrLow(
1394+ sgl_xtra->dma_phys_sgl));
1395+ sgl->addr_hi = cpu_to_le32(putPaddrHigh(
1396+ sgl_xtra->dma_phys_sgl));
1397+
1398+ } else {
1399+ bf_set(lpfc_sli4_sge_type, sgl,
1400+ LPFC_SGE_TYPE_DATA);
1401+ }
1402+ }
1403+
1404+ if (!(bf_get(lpfc_sli4_sge_type, sgl) &
1405+ LPFC_SGE_TYPE_LSP)) {
1406+ if ((nseg - 1) == i)
1407+ bf_set(lpfc_sli4_sge_last, sgl, 1);
1408+
1409+ physaddr = data_sg->dma_address;
1410+ dma_len = data_sg->length;
1411+ sgl->addr_lo = cpu_to_le32(
1412+ putPaddrLow(physaddr));
1413+ sgl->addr_hi = cpu_to_le32(
1414+ putPaddrHigh(physaddr));
1415+
1416+ bf_set(lpfc_sli4_sge_offset, sgl, dma_offset);
1417+ sgl->word2 = cpu_to_le32(sgl->word2);
1418+ sgl->sge_len = cpu_to_le32(dma_len);
1419+
1420+ dma_offset += dma_len;
1421+ data_sg = sg_next(data_sg);
1422+
1423+ sgl++;
1424+
1425+ lsp_just_set = false;
1426+ } else {
1427+ sgl->word2 = cpu_to_le32(sgl->word2);
1428+
1429+ sgl->sge_len = cpu_to_le32(
1430+ phba->cfg_sg_dma_buf_size);
1431+
1432+ sgl = (struct sli4_sge *)sgl_xtra->dma_sgl;
1433+ i = i - 1;
1434+
1435+ lsp_just_set = true;
1436+ }
1437+
1438+ j++;
13761439 }
13771440 if (phba->cfg_enable_pbde) {
13781441 /* Use PBDE support for first SGL only, offset == 0 */
@@ -1474,7 +1537,7 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_local_port *pnvme_lport, · 95 unmodified lines
14741537 goto out_fail;
14751538 }
14761539
1477− if (vport->load_flag & FC_UNLOADING) {
1540+ if (unlikely(vport->load_flag & FC_UNLOADING)) {
14781541 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR,
14791542 "6124 Fail IO, Driver unload\n");
14801543 atomic_inc(&lport->xmt_fcp_err);
@@ -1505,8 +1568,8 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_local_port *pnvme_lport, · 24 unmodified lines
15051568 ndlp = rport->ndlp;
15061569 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) {
15071570 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE | LOG_NVME_IOERR,
1508− "6053 Fail IO, ndlp not ready: rport %p "
1509− "ndlp %p, DID x%06x\n",
1571+ "6053 Busy IO, ndlp not ready: rport x%px "
1572+ "ndlp x%px, DID x%06x\n",
15101573 rport, ndlp, pnvme_rport->port_id);
15111574 atomic_inc(&lport->xmt_fcp_err);
15121575 ret = -EBUSY;
@@ -1758,7 +1821,7 @@ lpfc_nvme_fcp_abort(struct nvme_fc_local_port *pnvme_lport, · 245 unmodified lines
17581821 /* Announce entry to new IO submit field. */
17591822 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_ABTS,
17601823 "6002 Abort Request to rport DID x%06x "
1761− "for nvme_fc_req %p\n",
1824+ "for nvme_fc_req x%px\n",
17621825 pnvme_rport->port_id,
17631826 pnvme_fcreq);
17641827
@@ -1767,7 +1830,7 @@ lpfc_nvme_fcp_abort(struct nvme_fc_local_port *pnvme_lport, · 2 unmodified lines
17671830 */
17681831 spin_lock_irqsave(&phba->hbalock, flags);
17691832 /* driver queued commands are in process of being flushed */
1770− if (phba->hba_flag & HBA_NVME_IOQ_FLUSH) {
1833+ if (phba->hba_flag & HBA_IOQ_FLUSH) {
17711834 spin_unlock_irqrestore(&phba->hbalock, flags);
17721835 lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_ABTS,
17731836 "6139 Driver in reset cleanup - flushing "
@@ -1805,8 +1868,8 @@ lpfc_nvme_fcp_abort(struct nvme_fc_local_port *pnvme_lport, · 31 unmodified lines
18051868 if (lpfc_nbuf->nvmeCmd != pnvme_fcreq) {
18061869 lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_ABTS,
18071870 "6143 NVME req mismatch: "
1808− "lpfc_nbuf %p nvmeCmd %p, "
1809− "pnvme_fcreq %p. Skipping Abort xri x%x\n",
1871+ "lpfc_nbuf x%px nvmeCmd x%px, "
1872+ "pnvme_fcreq x%px. Skipping Abort xri x%x\n",
18101873 lpfc_nbuf, lpfc_nbuf->nvmeCmd,
18111874 pnvme_fcreq, nvmereq_wqe->sli4_xritag);
18121875 goto out_unlock;
@@ -1815,7 +1878,7 @@ lpfc_nvme_fcp_abort(struct nvme_fc_local_port *pnvme_lport, · 2 unmodified lines
18151878 /* Don't abort IOs no longer on the pending queue. */
18161879 if (!(nvmereq_wqe->iocb_flag & LPFC_IO_ON_TXCMPLQ)) {
18171880 lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_ABTS,
1818− "6142 NVME IO req %p not queued - skipping "
1881+ "6142 NVME IO req x%px not queued - skipping "
18191882 "abort req xri x%x\n",
18201883 pnvme_fcreq, nvmereq_wqe->sli4_xritag);
18211884 goto out_unlock;
@@ -1830,8 +1893,8 @@ lpfc_nvme_fcp_abort(struct nvme_fc_local_port *pnvme_lport, · 8 unmodified lines
18301893 if (nvmereq_wqe->iocb_flag & LPFC_DRIVER_ABORTED) {
18311894 lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_ABTS,
18321895 "6144 Outstanding NVME I/O Abort Request "
1833− "still pending on nvme_fcreq %p, "
1834− "lpfc_ncmd %p xri x%x\n",
1896+ "still pending on nvme_fcreq x%px, "
1897+ "lpfc_ncmd %px xri x%x\n",
18351898 pnvme_fcreq, lpfc_nbuf,
18361899 nvmereq_wqe->sli4_xritag);
18371900 goto out_unlock;
@@ -1841,7 +1904,7 @@ lpfc_nvme_fcp_abort(struct nvme_fc_local_port *pnvme_lport, · 3 unmodified lines
18411904 if (!abts_buf) {
18421905 lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_ABTS,
18431906 "6136 No available abort wqes. Skipping "
1844− "Abts req for nvme_fcreq %p xri x%x\n",
1907+ "Abts req for nvme_fcreq x%px xri x%x\n",
18451908 pnvme_fcreq, nvmereq_wqe->sli4_xritag);
18461909 goto out_unlock;
18471910 }
@@ -1855,7 +1918,7 @@ lpfc_nvme_fcp_abort(struct nvme_fc_local_port *pnvme_lport, · 7 unmodified lines
18551918 /* WQEs are reused. Clear stale data and set key fields to
18561919 * zero like ia, iaab, iaar, xri_tag, and ctxt_tag.
18571920 */
1858− memset(abts_wqe, 0, sizeof(union lpfc_wqe));
1921+ memset(abts_wqe, 0, sizeof(*abts_wqe));
18591922 bf_set(abort_cmd_criteria, &abts_wqe->abort_cmd, T_XRI_TAG);
18601923
18611924 /* word 7 */
@@ -1892,7 +1955,7 @@ lpfc_nvme_fcp_abort(struct nvme_fc_local_port *pnvme_lport, · 30 unmodified lines
18921955 if (ret_val) {
18931956 lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_ABTS,
18941957 "6137 Failed abts issue_wqe with status x%x "
1895− "for nvme_fcreq %p.\n",
1958+ "for nvme_fcreq x%px.\n",
18961959 ret_val, pnvme_fcreq);
18971960 lpfc_sli_release_iocbq(phba, abts_buf);
18981961 return;
@@ -1982,7 +2045,7 @@ lpfc_get_nvme_buf(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, · 83 unmodified lines
19822045 sgl->word2 = cpu_to_le32(sgl->word2);
19832046 /* Fill in word 3 / sgl_len during cmd submission */
19842047
1985− /* Initialize WQE */
2048+ /* Initialize 64 bytes only */
19862049 memset(wqe, 0, sizeof(union lpfc_wqe));
19872050
19882051 if (lpfc_ndlp_check_qdepth(phba, ndlp)) {
@@ -2028,11 +2091,11 @@ lpfc_release_nvme_buf(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_ncmd) · 39 unmodified lines
20282091 lpfc_ncmd->cur_iocbq.sli4_xritag,
20292092 lpfc_ncmd->cur_iocbq.iotag);
20302093
2031− spin_lock_irqsave(&qp->abts_nvme_buf_list_lock, iflag);
2094+ spin_lock_irqsave(&qp->abts_io_buf_list_lock, iflag);
20322095 list_add_tail(&lpfc_ncmd->list,
2033− &qp->lpfc_abts_nvme_buf_list);
2096+ &qp->lpfc_abts_io_buf_list);
20342097 qp->abts_nvme_io_bufs++;
2035− spin_unlock_irqrestore(&qp->abts_nvme_buf_list_lock, iflag);
2098+ spin_unlock_irqrestore(&qp->abts_io_buf_list_lock, iflag);
20362099 } else
20372100 lpfc_release_io_buf(phba, (struct lpfc_io_buf *)lpfc_ncmd, qp);
20382101 }
@@ -2095,8 +2158,8 @@ lpfc_nvme_create_localport(struct lpfc_vport *vport) · 56 unmodified lines
20952158 if (!ret) {
20962159 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME | LOG_NVME_DISC,
20972160 "6005 Successfully registered local "
2098− "NVME port num %d, localP %p, private %p, "
2099− "sg_seg %d\n",
2161+ "NVME port num %d, localP x%px, private "
2162+ "x%px, sg_seg %d\n",
21002163 localport->port_num, localport,
21012164 localport->private,
21022165 lpfc_nvme_template.max_sgl_segments);
@@ -2157,14 +2220,14 @@ lpfc_nvme_lport_unreg_wait(struct lpfc_vport *vport, · 54 unmodified lines
21572220 if (unlikely(!ret)) {
21582221 pending = 0;
21592222 for (i = 0; i < phba->cfg_hdw_queue; i++) {
2160− pring = phba->sli4_hba.hdwq[i].nvme_wq->pring;
2223+ pring = phba->sli4_hba.hdwq[i].io_wq->pring;
21612224 if (!pring)
21622225 continue;
21632226 if (pring->txcmplq_cnt)
21642227 pending += pring->txcmplq_cnt;
21652228 }
21662229 lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_IOERR,
2167− "6176 Lport %p Localport %p wait "
2230+ "6176 Lport x%px Localport x%px wait "
21682231 "timed out. Pending %d. Renewing.\n",
21692232 lport, vport->localport, pending);
21702233 continue;
@@ -2172,7 +2235,7 @@ lpfc_nvme_lport_unreg_wait(struct lpfc_vport *vport, · 1 unmodified line
21722235 break;
21732236 }
21742237 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR,
2175− "6177 Lport %p Localport %p Complete Success\n",
2238+ "6177 Lport x%px Localport x%px Complete Success\n",
21762239 lport, vport->localport);
21772240 }
21782241 #endif
@@ -2203,7 +2266,7 @@ lpfc_nvme_destroy_localport(struct lpfc_vport *vport) · 24 unmodified lines
22032266 lport = (struct lpfc_nvme_lport *)localport->private;
22042267
22052268 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME,
2206− "6011 Destroying NVME localport %p\n",
2269+ "6011 Destroying NVME localport x%px\n",
22072270 localport);
22082271
22092272 /* lport's rport list is clear. Unregister
@@ -2253,12 +2316,12 @@ lpfc_nvme_update_localport(struct lpfc_vport *vport) · 43 unmodified lines
22532316 lport = (struct lpfc_nvme_lport *)localport->private;
22542317 if (!lport) {
22552318 lpfc_printf_vlog(vport, KERN_WARNING, LOG_NVME,
2256− "6171 Update NVME fail. localP %p, No lport\n",
2319+ "6171 Update NVME fail. localP x%px, No lport\n",
22572320 localport);
22582321 return;
22592322 }
22602323 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME,
2261− "6012 Update NVME lport %p did x%x\n",
2324+ "6012 Update NVME lport x%px did x%x\n",
22622325 localport, vport->fc_myDID);
22632326
22642327 localport->port_id = vport->fc_myDID;
@@ -2268,7 +2331,7 @@ lpfc_nvme_update_localport(struct lpfc_vport *vport) · 3 unmodified lines
22682331 localport->port_role = FC_PORT_ROLE_NVME_INITIATOR;
22692332
22702333 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
2271− "6030 bound lport %p to DID x%06x\n",
2334+ "6030 bound lport x%px to DID x%06x\n",
22722335 lport, localport->port_id);
22732336 #endif
22742337 }
@@ -2317,9 +2380,13 @@ lpfc_nvme_register_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 42 unmodified lines
23172380
23182381 spin_lock_irq(&vport->phba->hbalock);
23192382 oldrport = lpfc_ndlp_get_nrport(ndlp);
2320− spin_unlock_irq(&vport->phba->hbalock);
2321− if (!oldrport)
2383+ if (oldrport) {
2384+ prev_ndlp = oldrport->ndlp;
2385+ spin_unlock_irq(&vport->phba->hbalock);
2386+ } else {
2387+ spin_unlock_irq(&vport->phba->hbalock);
23222388 lpfc_nlp_get(ndlp);
2389+ }
23232390
23242391 ret = nvme_fc_register_remoteport(localport, &rpinfo, &remote_port);
23252392 if (!ret) {
@@ -2338,25 +2405,34 @@ lpfc_nvme_register_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 12 unmodified lines
23382405 /* New remoteport record does not guarantee valid
23392406 * host private memory area.
23402407 */
2341− prev_ndlp = oldrport->ndlp;
23422408 if (oldrport == remote_port->private) {
23432409 /* Same remoteport - ndlp should match.
23442410 * Just reuse.
23452411 */
23462412 lpfc_printf_vlog(ndlp->vport, KERN_INFO,
23472413 LOG_NVME_DISC,
2348− "6014 Rebinding lport to "
2349− "remoteport %p wwpn 0x%llx, "
2350− "Data: x%x x%x %p %p x%x x%06x\n",
2414+ "6014 Rebind lport to current "
2415+ "remoteport x%px wwpn 0x%llx, "
2416+ "Data: x%x x%x x%px x%px x%x "
2417+ " x%06x\n",
23512418 remote_port,
23522419 remote_port->port_name,
23532420 remote_port->port_id,
23542421 remote_port->port_role,
2355− prev_ndlp,
2422+ oldrport->ndlp,
23562423 ndlp,
23572424 ndlp->nlp_type,
23582425 ndlp->nlp_DID);
2359− return 0;
2426+
2427+ /* It's a complete rebind only if the driver
2428+ * is registering with the same ndlp. Otherwise
2429+ * the driver likely executed a node swap
2430+ * prior to this registration and the ndlp to
2431+ * remoteport binding needs to be redone.
2432+ */
2433+ if (prev_ndlp == ndlp)
2434+ return 0;
2435+
23602436 }
23612437
23622438 /* Sever the ndlp<->rport association
@@ -2390,10 +2466,10 @@ lpfc_nvme_register_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 27 unmodified lines
23902466 spin_unlock_irq(&vport->phba->hbalock);
23912467 lpfc_printf_vlog(vport, KERN_INFO,
23922468 LOG_NVME_DISC | LOG_NODE,
2393− "6022 Binding new rport to "
2394− "lport %p Remoteport %p rport %p WWNN 0x%llx, "
2469+ "6022 Bind lport x%px to remoteport x%px "
2470+ "rport x%px WWNN 0x%llx, "
23952471 "Rport WWPN 0x%llx DID "
2396− "x%06x Role x%x, ndlp %p prev_ndlp %p\n",
2472+ "x%06x Role x%x, ndlp %p prev_ndlp x%px\n",
23972473 lport, remote_port, rport,
23982474 rpinfo.node_name, rpinfo.port_name,
23992475 rpinfo.port_id, rpinfo.port_role,
@@ -2423,20 +2499,23 @@ void · 23 unmodified lines
24232499 lpfc_nvme_rescan_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
24242500 {
24252501 #if (IS_ENABLED(CONFIG_NVME_FC))
2426− struct lpfc_nvme_rport *rport;
2427− struct nvme_fc_remote_port *remoteport;
2502+ struct lpfc_nvme_rport *nrport;
2503+ struct nvme_fc_remote_port *remoteport = NULL;
24282504
2429− rport = ndlp->nrport;
2505+ spin_lock_irq(&vport->phba->hbalock);
2506+ nrport = lpfc_ndlp_get_nrport(ndlp);
2507+ if (nrport)
2508+ remoteport = nrport->remoteport;
2509+ spin_unlock_irq(&vport->phba->hbalock);
24302510
24312511 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
24322512 "6170 Rescan NPort DID x%06x type x%x "
2433− "state x%x rport %p\n",
2434− ndlp->nlp_DID, ndlp->nlp_type, ndlp->nlp_state, rport);
2435− if (!rport)
2436− goto input_err;
2437− remoteport = rport->remoteport;
2438− if (!remoteport)
2439− goto input_err;
2513+ "state x%x nrport x%px remoteport x%px\n",
2514+ ndlp->nlp_DID, ndlp->nlp_type, ndlp->nlp_state,
2515+ nrport, remoteport);
2516+
2517+ if (!nrport || !remoteport)
2518+ goto rescan_exit;
24402519
24412520 /* Only rescan if we are an NVME target in the MAPPED state */
24422521 if (remoteport->port_role & FC_PORT_ROLE_NVME_DISCOVERY &&
@@ -2449,10 +2528,10 @@ lpfc_nvme_rescan_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 6 unmodified lines
24492528 ndlp->nlp_DID, remoteport->port_state);
24502529 }
24512530 return;
2452−input_err:
2453− lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_DISC,
2454− "6169 State error: lport %p, rport%p FCID x%06x\n",
2455− vport->localport, ndlp->rport, ndlp->nlp_DID);
2531+ rescan_exit:
2532+ lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
2533+ "6169 Skip NVME Rport Rescan, NVME remoteport "
2534+ "unregistered\n");
24562535 #endif
24572536 }
24582537
@@ -2499,7 +2578,7 @@ lpfc_nvme_unregister_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 40 unmodified lines
24992578 goto input_err;
25002579
25012580 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
2502− "6033 Unreg nvme remoteport %p, portname x%llx, "
2581+ "6033 Unreg nvme remoteport x%px, portname x%llx, "
25032582 "port_id x%06x, portstate x%x port type x%x\n",
25042583 remoteport, remoteport->port_name,
25052584 remoteport->port_id, remoteport->port_state,
@@ -2537,7 +2616,7 @@ lpfc_nvme_unregister_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 31 unmodified lines
25372616 input_err:
25382617 #endif
25392618 lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_DISC,
2540− "6168 State error: lport %p, rport%p FCID x%06x\n",
2619+ "6168 State error: lport x%px, rport x%px FCID x%06x\n",
25412620 vport->localport, ndlp->rport, ndlp->nlp_DID);
25422621 }
25432622
@@ -2545,6 +2624,7 @@ lpfc_nvme_unregister_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 1 unmodified line
25452624 * lpfc_sli4_nvme_xri_aborted - Fast-path process of NVME xri abort
25462625 * @phba: pointer to lpfc hba data structure.
25472626 * @axri: pointer to the fcp xri abort wcqe structure.
2627+ * @lpfc_ncmd: The nvme job structure for the request being aborted.
25482628 *
25492629 * This routine is invoked by the worker thread to process a SLI4 fast-path
25502630 * NVME aborted xri. Aborted NVME IO commands are completed to the transport
@@ -2552,59 +2632,33 @@ lpfc_nvme_unregister_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 1 unmodified line
25522632 **/
25532633 void
25542634 lpfc_sli4_nvme_xri_aborted(struct lpfc_hba *phba,
2555− struct sli4_wcqe_xri_aborted *axri, int idx)
2635+ struct sli4_wcqe_xri_aborted *axri,
2636+ struct lpfc_io_buf *lpfc_ncmd)
25562637 {
25572638 uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri);
2558− struct lpfc_io_buf *lpfc_ncmd, *next_lpfc_ncmd;
25592639 struct nvmefc_fcp_req *nvme_cmd = NULL;
2560− struct lpfc_nodelist *ndlp;
2561− struct lpfc_sli4_hdw_queue *qp;
2562− unsigned long iflag = 0;
2640+ struct lpfc_nodelist *ndlp = lpfc_ncmd->ndlp;
25632641
2564− if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME))
2565− return;
2566− qp = &phba->sli4_hba.hdwq[idx];
2567− spin_lock_irqsave(&phba->hbalock, iflag);
2568− spin_lock(&qp->abts_nvme_buf_list_lock);
2569− list_for_each_entry_safe(lpfc_ncmd, next_lpfc_ncmd,
2570− &qp->lpfc_abts_nvme_buf_list, list) {
2571− if (lpfc_ncmd->cur_iocbq.sli4_xritag == xri) {
2572− list_del_init(&lpfc_ncmd->list);
2573− qp->abts_nvme_io_bufs--;
2574− lpfc_ncmd->flags &= ~LPFC_SBUF_XBUSY;
2575− lpfc_ncmd->status = IOSTAT_SUCCESS;
2576− spin_unlock(&qp->abts_nvme_buf_list_lock);
2577−
2578− spin_unlock_irqrestore(&phba->hbalock, iflag);
2579− ndlp = lpfc_ncmd->ndlp;
2580− if (ndlp)
2581− lpfc_sli4_abts_err_handler(phba, ndlp, axri);
2582−
2583− lpfc_printf_log(phba, KERN_INFO, LOG_NVME_ABTS,
2584− "6311 nvme_cmd %p xri x%x tag x%x "
2585− "abort complete and xri released\n",
2586− lpfc_ncmd->nvmeCmd, xri,
2587− lpfc_ncmd->cur_iocbq.iotag);
2588−
2589− /* Aborted NVME commands are required to not complete
2590− * before the abort exchange command fully completes.
2591− * Once completed, it is available via the put list.
2592− */
2593− if (lpfc_ncmd->nvmeCmd) {
2594− nvme_cmd = lpfc_ncmd->nvmeCmd;
2595− nvme_cmd->done(nvme_cmd);
2596− lpfc_ncmd->nvmeCmd = NULL;
2597− }
2598− lpfc_release_nvme_buf(phba, lpfc_ncmd);
2599− return;
2600− }
2601− }
2602− spin_unlock(&qp->abts_nvme_buf_list_lock);
2603− spin_unlock_irqrestore(&phba->hbalock, iflag);
26042642
2605− lpfc_printf_log(phba, KERN_INFO, LOG_NVME_ABTS,
2606− "6312 XRI Aborted xri x%x not found\n", xri);
2643+ if (ndlp)
2644+ lpfc_sli4_abts_err_handler(phba, ndlp, axri);
26072645
2646+ lpfc_printf_log(phba, KERN_INFO, LOG_NVME_ABTS,
2647+ "6311 nvme_cmd %p xri x%x tag x%x abort complete and "
2648+ "xri released\n",
2649+ lpfc_ncmd->nvmeCmd, xri,
2650+ lpfc_ncmd->cur_iocbq.iotag);
2651+
2652+ /* Aborted NVME commands are required to not complete
2653+ * before the abort exchange command fully completes.
2654+ * Once completed, it is available via the put list.
2655+ */
2656+ if (lpfc_ncmd->nvmeCmd) {
2657+ nvme_cmd = lpfc_ncmd->nvmeCmd;
2658+ nvme_cmd->done(nvme_cmd);
2659+ lpfc_ncmd->nvmeCmd = NULL;
2660+ }
2661+ lpfc_release_nvme_buf(phba, lpfc_ncmd);
26082662 }
26092663
26102664 /**
@@ -2626,13 +2680,13 @@ lpfc_nvme_wait_for_io_drain(struct lpfc_hba *phba) · 15 unmodified lines
26262680 if (phba->sli_rev < LPFC_SLI_REV4 || !phba->sli4_hba.hdwq)
26272681 return;
26282682
2629− /* Cycle through all NVME rings and make sure all outstanding
2683+ /* Cycle through all IO rings and make sure all outstanding
26302684 * WQEs have been removed from the txcmplqs.
26312685 */
26322686 for (i = 0; i < phba->cfg_hdw_queue; i++) {
2633− if (!phba->sli4_hba.hdwq[i].nvme_wq)
2687+ if (!phba->sli4_hba.hdwq[i].io_wq)
26342688 continue;
2635− pring = phba->sli4_hba.hdwq[i].nvme_wq->pring;
2689+ pring = phba->sli4_hba.hdwq[i].io_wq->pring;
26362690
26372691 if (!pring)
26382692 continue;
@@ -2653,3 +2707,50 @@ lpfc_nvme_wait_for_io_drain(struct lpfc_hba *phba) · 14 unmodified lines
26532707 }
26542708 }
26552709 }
2710+
2711+void
2712+lpfc_nvme_cancel_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn)
2713+{
2714+#if (IS_ENABLED(CONFIG_NVME_FC))
2715+ struct lpfc_io_buf *lpfc_ncmd;
2716+ struct nvmefc_fcp_req *nCmd;
2717+ struct lpfc_nvme_fcpreq_priv *freqpriv;
2718+
2719+ if (!pwqeIn->context1) {
2720+ lpfc_sli_release_iocbq(phba, pwqeIn);
2721+ return;
2722+ }
2723+ /* For abort iocb just return, IO iocb will do a done call */
2724+ if (bf_get(wqe_cmnd, &pwqeIn->wqe.gen_req.wqe_com) ==
2725+ CMD_ABORT_XRI_CX) {
2726+ lpfc_sli_release_iocbq(phba, pwqeIn);
2727+ return;
2728+ }
2729+ lpfc_ncmd = (struct lpfc_io_buf *)pwqeIn->context1;
2730+
2731+ spin_lock(&lpfc_ncmd->buf_lock);
2732+ if (!lpfc_ncmd->nvmeCmd) {
2733+ spin_unlock(&lpfc_ncmd->buf_lock);
2734+ lpfc_release_nvme_buf(phba, lpfc_ncmd);
2735+ return;
2736+ }
2737+
2738+ nCmd = lpfc_ncmd->nvmeCmd;
2739+ lpfc_printf_log(phba, KERN_INFO, LOG_NVME_IOERR,
2740+ "6194 NVME Cancel xri %x\n",
2741+ lpfc_ncmd->cur_iocbq.sli4_xritag);
2742+
2743+ nCmd->transferred_length = 0;
2744+ nCmd->rcv_rsplen = 0;
2745+ nCmd->status = NVME_SC_INTERNAL;
2746+ freqpriv = nCmd->private;
2747+ freqpriv->nvme_buf = NULL;
2748+ lpfc_ncmd->nvmeCmd = NULL;
2749+
2750+ spin_unlock(&lpfc_ncmd->buf_lock);
2751+ nCmd->done(nCmd);
2752+
2753+ /* Call release with XB=1 to queue the IO into the abort list. */
2754+ lpfc_release_nvme_buf(phba, lpfc_ncmd);
2755+#endif
2756+}
drivers/scsi/lpfc/lpfc_nvmet.c+12−16
@@ -1026,7 +1026,7 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport, · 1025 unmodified lines
10261026 * WQE release CQE
10271027 */
10281028 ctxp->flag |= LPFC_NVMET_DEFER_WQFULL;
1029− wq = ctxp->hdwq->nvme_wq;
1029+ wq = ctxp->hdwq->io_wq;
10301030 pring = wq->pring;
10311031 spin_lock_irqsave(&pring->ring_lock, iflags);
10321032 list_add_tail(&nvmewqeq->list, &wq->wqfull_list);
@@ -1104,7 +1104,7 @@ lpfc_nvmet_xmt_fcp_abort(struct nvmet_fc_target_port *tgtport, · 71 unmodified lines
11041104 spin_unlock_irqrestore(&ctxp->ctxlock, flags);
11051105 lpfc_nvmet_unsol_fcp_issue_abort(phba, ctxp, ctxp->sid,
11061106 ctxp->oxid);
1107− wq = ctxp->hdwq->nvme_wq;
1107+ wq = ctxp->hdwq->io_wq;
11081108 lpfc_nvmet_wqfull_flush(phba, wq, ctxp);
11091109 return;
11101110 }
@@ -1437,7 +1437,7 @@ lpfc_nvmet_setup_io_context(struct lpfc_hba *phba) · 326 unmodified lines
14371437 infop = lpfc_get_ctx_list(phba, i, j);
14381438 lpfc_printf_log(phba, KERN_INFO, LOG_NVME | LOG_INIT,
14391439 "6408 TOTAL NVMET ctx for CPU %d "
1440− "MRQ %d: cnt %d nextcpu %p\n",
1440+ "MRQ %d: cnt %d nextcpu x%px\n",
14411441 i, j, infop->nvmet_ctx_list_cnt,
14421442 infop->nvmet_ctx_next_cpu);
14431443 }
@@ -1500,7 +1500,7 @@ lpfc_nvmet_create_targetport(struct lpfc_hba *phba) · 56 unmodified lines
15001500
15011501 lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC,
15021502 "6026 Registered NVME "
1503− "targetport: %p, private %p "
1503+ "targetport: x%px, private x%px "
15041504 "portnm %llx nodenm %llx segs %d qs %d\n",
15051505 phba->targetport, tgtp,
15061506 pinfo.port_name, pinfo.node_name,
@@ -1555,7 +1555,7 @@ lpfc_nvmet_update_targetport(struct lpfc_hba *phba) · 48 unmodified lines
15551555 return 0;
15561556
15571557 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME,
1558− "6007 Update NVMET port %p did x%x\n",
1558+ "6007 Update NVMET port x%px did x%x\n",
15591559 phba->targetport, vport->fc_myDID);
15601560
15611561 phba->targetport->port_id = vport->fc_myDID;
@@ -1790,12 +1790,8 @@ lpfc_nvmet_rcv_unsol_abort(struct lpfc_vport *vport, · 228 unmodified lines
17901790 lpfc_nvmet_defer_release(phba, ctxp);
17911791 spin_unlock_irqrestore(&ctxp->ctxlock, iflag);
17921792 }
1793− if (ctxp->state == LPFC_NVMET_STE_RCV)
1794− lpfc_nvmet_unsol_fcp_issue_abort(phba, ctxp, ctxp->sid,
1795− ctxp->oxid);
1796− else
1797− lpfc_nvmet_sol_fcp_issue_abort(phba, ctxp, ctxp->sid,
1798− ctxp->oxid);
1793+ lpfc_nvmet_sol_fcp_issue_abort(phba, ctxp, ctxp->sid,
1794+ ctxp->oxid);
17991795
18001796 lpfc_sli4_seq_abort_rsp(vport, fc_hdr, 1);
18011797 return 0;
@@ -1922,7 +1918,7 @@ lpfc_nvmet_destroy_targetport(struct lpfc_hba *phba) · 120 unmodified lines
19221918 if (phba->targetport) {
19231919 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
19241920 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) {
1925− wq = phba->sli4_hba.hdwq[qidx].nvme_wq;
1921+ wq = phba->sli4_hba.hdwq[qidx].io_wq;
19261922 lpfc_nvmet_wqfull_flush(phba, wq, NULL);
19271923 }
19281924 tgtp->tport_unreg_cmp = &tport_unreg_cmp;
@@ -1930,7 +1926,7 @@ lpfc_nvmet_destroy_targetport(struct lpfc_hba *phba) · 1 unmodified line
19301926 if (!wait_for_completion_timeout(tgtp->tport_unreg_cmp,
19311927 msecs_to_jiffies(LPFC_NVMET_WAIT_TMO)))
19321928 lpfc_printf_log(phba, KERN_ERR, LOG_NVME,
1933− "6179 Unreg targetport %p timeout "
1929+ "6179 Unreg targetport x%px timeout "
19341930 "reached.\n", phba->targetport);
19351931 lpfc_nvmet_cleanup_io_context(phba);
19361932 }
@@ -3113,7 +3109,7 @@ lpfc_nvmet_xmt_ls_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 1176 unmodified lines
31133109 atomic_inc(&tgtp->xmt_ls_abort_cmpl);
31143110
31153111 lpfc_printf_log(phba, KERN_INFO, LOG_NVME_ABTS,
3116− "6083 Abort cmpl: ctx %p WCQE:%08x %08x %08x %08x\n",
3112+ "6083 Abort cmpl: ctx x%px WCQE:%08x %08x %08x %08x\n",
31173113 ctxp, wcqe->word0, wcqe->total_data_placed,
31183114 result, wcqe->word3);
31193115
@@ -3299,7 +3295,7 @@ lpfc_nvmet_sol_fcp_issue_abort(struct lpfc_hba *phba, · 179 unmodified lines
32993295 */
33003296 spin_lock_irqsave(&phba->hbalock, flags);
33013297 /* driver queued commands are in process of being flushed */
3302− if (phba->hba_flag & HBA_NVME_IOQ_FLUSH) {
3298+ if (phba->hba_flag & HBA_IOQ_FLUSH) {
33033299 spin_unlock_irqrestore(&phba->hbalock, flags);
33043300 atomic_inc(&tgtp->xmt_abort_rsp_error);
33053301 lpfc_printf_log(phba, KERN_ERR, LOG_NVME,
@@ -3334,7 +3330,7 @@ lpfc_nvmet_sol_fcp_issue_abort(struct lpfc_hba *phba, · 28 unmodified lines
33343330 /* WQEs are reused. Clear stale data and set key fields to
33353331 * zero like ia, iaab, iaar, xri_tag, and ctxt_tag.
33363332 */
3337− memset(abts_wqe, 0, sizeof(union lpfc_wqe));
3333+ memset(abts_wqe, 0, sizeof(*abts_wqe));
33383334
33393335 /* word 3 */
33403336 bf_set(abort_cmd_criteria, &abts_wqe->abort_cmd, T_XRI_TAG);
drivers/scsi/lpfc/lpfc_scsi.c+379−212
@@ -53,8 +53,6 @@ · 52 unmodified lines
5353 #define LPFC_RESET_WAIT 2
5454 #define LPFC_ABORT_WAIT 2
5555
56−int _dump_buf_done = 1;
57−
5856 static char *dif_op_str[] = {
5957 "PROT_NORMAL",
6058 "PROT_READ_INSERT",
@@ -89,63 +87,6 @@ lpfc_release_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_io_buf *psb); · 28 unmodified lines
8987 static int
9088 lpfc_prot_group_type(struct lpfc_hba *phba, struct scsi_cmnd *sc);
9189
92−static void
93−lpfc_debug_save_data(struct lpfc_hba *phba, struct scsi_cmnd *cmnd)
94−{
95− void *src, *dst;
96− struct scatterlist *sgde = scsi_sglist(cmnd);
97−
98− if (!_dump_buf_data) {
99− lpfc_printf_log(phba, KERN_ERR, LOG_BG,
100− "9050 BLKGRD: ERROR %s _dump_buf_data is NULL\n",
101− __func__);
102− return;
103− }
104−
105−
106− if (!sgde) {
107− lpfc_printf_log(phba, KERN_ERR, LOG_BG,
108− "9051 BLKGRD: ERROR: data scatterlist is null\n");
109− return;
110− }
111−
112− dst = (void *) _dump_buf_data;
113− while (sgde) {
114− src = sg_virt(sgde);
115− memcpy(dst, src, sgde->length);
116− dst += sgde->length;
117− sgde = sg_next(sgde);
118− }
119−}
120−
121−static void
122−lpfc_debug_save_dif(struct lpfc_hba *phba, struct scsi_cmnd *cmnd)
123−{
124− void *src, *dst;
125− struct scatterlist *sgde = scsi_prot_sglist(cmnd);
126−
127− if (!_dump_buf_dif) {
128− lpfc_printf_log(phba, KERN_ERR, LOG_BG,
129− "9052 BLKGRD: ERROR %s _dump_buf_data is NULL\n",
130− __func__);
131− return;
132− }
133−
134− if (!sgde) {
135− lpfc_printf_log(phba, KERN_ERR, LOG_BG,
136− "9053 BLKGRD: ERROR: prot scatterlist is null\n");
137− return;
138− }
139−
140− dst = _dump_buf_dif;
141− while (sgde) {
142− src = sg_virt(sgde);
143− memcpy(dst, src, sgde->length);
144− dst += sgde->length;
145− sgde = sg_next(sgde);
146− }
147−}
148−
14990 static inline unsigned
15091 lpfc_cmd_blksize(struct scsi_cmnd *sc)
15192 {
@@ -537,29 +478,32 @@ lpfc_sli4_vport_delete_fcp_xri_aborted(struct lpfc_vport *vport) · 385 unmodified lines
537478 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) {
538479 qp = &phba->sli4_hba.hdwq[idx];
539480
540− spin_lock(&qp->abts_scsi_buf_list_lock);
481+ spin_lock(&qp->abts_io_buf_list_lock);
541482 list_for_each_entry_safe(psb, next_psb,
542− &qp->lpfc_abts_scsi_buf_list, list) {
483+ &qp->lpfc_abts_io_buf_list, list) {
484+ if (psb->cur_iocbq.iocb_flag == LPFC_IO_NVME)
485+ continue;
486+
543487 if (psb->rdata && psb->rdata->pnode &&
544488 psb->rdata->pnode->vport == vport)
545489 psb->rdata = NULL;
546490 }
547− spin_unlock(&qp->abts_scsi_buf_list_lock);
491+ spin_unlock(&qp->abts_io_buf_list_lock);
548492 }
549493 spin_unlock_irqrestore(&phba->hbalock, iflag);
550494 }
551495
552496 /**
553− * lpfc_sli4_fcp_xri_aborted - Fast-path process of fcp xri abort
497+ * lpfc_sli4_io_xri_aborted - Fast-path process of fcp xri abort
554498 * @phba: pointer to lpfc hba data structure.
555499 * @axri: pointer to the fcp xri abort wcqe structure.
556500 *
557501 * This routine is invoked by the worker thread to process a SLI4 fast-path
558− * FCP aborted xri.
502+ * FCP or NVME aborted xri.
559503 **/
560504 void
561−lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba,
562− struct sli4_wcqe_xri_aborted *axri, int idx)
505+lpfc_sli4_io_xri_aborted(struct lpfc_hba *phba,
506+ struct sli4_wcqe_xri_aborted *axri, int idx)
563507 {
564508 uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri);
565509 uint16_t rxid = bf_get(lpfc_wcqe_xa_remote_xid, axri);
@@ -577,16 +521,25 @@ lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba, · 11 unmodified lines
577521
578522 qp = &phba->sli4_hba.hdwq[idx];
579523 spin_lock_irqsave(&phba->hbalock, iflag);
580− spin_lock(&qp->abts_scsi_buf_list_lock);
524+ spin_lock(&qp->abts_io_buf_list_lock);
581525 list_for_each_entry_safe(psb, next_psb,
582− &qp->lpfc_abts_scsi_buf_list, list) {
526+ &qp->lpfc_abts_io_buf_list, list) {
583527 if (psb->cur_iocbq.sli4_xritag == xri) {
584− list_del(&psb->list);
585− qp->abts_scsi_io_bufs--;
528+ list_del_init(&psb->list);
586529 psb->exch_busy = 0;
587530 psb->status = IOSTAT_SUCCESS;
588− spin_unlock(
589− &qp->abts_scsi_buf_list_lock);
531+#ifdef BUILD_NVME
532+ if (psb->cur_iocbq.iocb_flag == LPFC_IO_NVME) {
533+ qp->abts_nvme_io_bufs--;
534+ spin_unlock(&qp->abts_io_buf_list_lock);
535+ spin_unlock_irqrestore(&phba->hbalock, iflag);
536+ lpfc_sli4_nvme_xri_aborted(phba, axri, psb);
537+ return;
538+ }
539+#endif
540+ qp->abts_scsi_io_bufs--;
541+ spin_unlock(&qp->abts_io_buf_list_lock);
542+
590543 if (psb->rdata && psb->rdata->pnode)
591544 ndlp = psb->rdata->pnode;
592545 else
@@ -605,12 +558,12 @@ lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba, · 12 unmodified lines
605558 return;
606559 }
607560 }
608− spin_unlock(&qp->abts_scsi_buf_list_lock);
561+ spin_unlock(&qp->abts_io_buf_list_lock);
609562 for (i = 1; i <= phba->sli.last_iotag; i++) {
610563 iocbq = phba->sli.iocbq_lookup[i];
611564
612− if (!(iocbq->iocb_flag & LPFC_IO_FCP) ||
613− (iocbq->iocb_flag & LPFC_IO_LIBDFC))
565+ if (!(iocbq->iocb_flag & LPFC_IO_FCP) ||
566+ (iocbq->iocb_flag & LPFC_IO_LIBDFC))
614567 continue;
615568 if (iocbq->sli4_xritag != xri)
616569 continue;
@@ -685,8 +638,9 @@ lpfc_get_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, · 68 unmodified lines
685638 IOCB_t *iocb;
686639 dma_addr_t pdma_phys_fcp_rsp;
687640 dma_addr_t pdma_phys_fcp_cmd;
688− uint32_t sgl_size, cpu, idx;
641+ uint32_t cpu, idx;
689642 int tag;
643+ struct fcp_cmd_rsp_buf *tmp = NULL;
690644
691645 cpu = raw_smp_processor_id();
692646 if (cmnd && phba->cfg_fcp_io_sched == LPFC_FCP_SCHED_BY_HDWQ) {
@@ -704,9 +658,6 @@ lpfc_get_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, · 11 unmodified lines
704658 return NULL;
705659 }
706660
707− sgl_size = phba->cfg_sg_dma_buf_size -
708− (sizeof(struct fcp_cmnd) + sizeof(struct fcp_rsp));
709−
710661 /* Setup key fields in buffer that may have been changed
711662 * if other protocols used this buffer.
712663 */
@@ -721,9 +672,12 @@ lpfc_get_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, · 8 unmodified lines
721672 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
722673 lpfc_cmd->prot_data_type = 0;
723674 #endif
724− lpfc_cmd->fcp_cmnd = (lpfc_cmd->data + sgl_size);
725− lpfc_cmd->fcp_rsp = (struct fcp_rsp *)((uint8_t *)lpfc_cmd->fcp_cmnd +
726− sizeof(struct fcp_cmnd));
675+ tmp = lpfc_get_cmd_rsp_buf_per_hdwq(phba, lpfc_cmd);
676+ if (!tmp)
677+ return NULL;
678+
679+ lpfc_cmd->fcp_cmnd = tmp->fcp_cmnd;
680+ lpfc_cmd->fcp_rsp = tmp->fcp_rsp;
727681
728682 /*
729683 * The first two SGEs are the FCP_CMD and FCP_RSP.
@@ -731,7 +685,7 @@ lpfc_get_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, · 1 unmodified line
731685 * first two and leave the rest for queuecommand.
732686 */
733687 sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl;
734− pdma_phys_fcp_cmd = (lpfc_cmd->dma_handle + sgl_size);
688+ pdma_phys_fcp_cmd = tmp->fcp_cmd_rsp_dma_handle;
735689 sgl->addr_hi = cpu_to_le32(putPaddrHigh(pdma_phys_fcp_cmd));
736690 sgl->addr_lo = cpu_to_le32(putPaddrLow(pdma_phys_fcp_cmd));
737691 sgl->word2 = le32_to_cpu(sgl->word2);
@@ -835,11 +789,11 @@ lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_io_buf *psb) · 97 unmodified lines
835789
836790 qp = psb->hdwq;
837791 if (psb->exch_busy) {
838− spin_lock_irqsave(&qp->abts_scsi_buf_list_lock, iflag);
792+ spin_lock_irqsave(&qp->abts_io_buf_list_lock, iflag);
839793 psb->pCmd = NULL;
840− list_add_tail(&psb->list, &qp->lpfc_abts_scsi_buf_list);
794+ list_add_tail(&psb->list, &qp->lpfc_abts_io_buf_list);
841795 qp->abts_scsi_io_bufs++;
842− spin_unlock_irqrestore(&qp->abts_scsi_buf_list_lock, iflag);
796+ spin_unlock_irqrestore(&qp->abts_io_buf_list_lock, iflag);
843797 } else {
844798 lpfc_release_io_buf(phba, (struct lpfc_io_buf *)psb, qp);
845799 }
@@ -918,9 +872,10 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) · 72 unmodified lines
918872 "dma_map_sg. Config %d, seg_cnt %d\n",
919873 __func__, phba->cfg_sg_seg_cnt,
920874 lpfc_cmd->seg_cnt);
875+ WARN_ON_ONCE(lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt);
921876 lpfc_cmd->seg_cnt = 0;
922877 scsi_dma_unmap(scsi_cmnd);
923− return 1;
878+ return 2;
924879 }
925880
926881 /*
@@ -1774,7 +1729,7 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, · 847 unmodified lines
17741729
17751730 if (!sgpe || !sgde) {
17761731 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
1777− "9020 Invalid s/g entry: data=0x%p prot=0x%p\n",
1732+ "9020 Invalid s/g entry: data=x%px prot=x%px\n",
17781733 sgpe, sgde);
17791734 return 0;
17801735 }
@@ -1989,7 +1944,8 @@ out: · 208 unmodified lines
19891944 **/
19901945 static int
19911946 lpfc_bg_setup_sgl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1992− struct sli4_sge *sgl, int datasegcnt)
1947+ struct sli4_sge *sgl, int datasegcnt,
1948+ struct lpfc_io_buf *lpfc_cmd)
19931949 {
19941950 struct scatterlist *sgde = NULL; /* s/g data entry */
19951951 struct sli4_sge_diseed *diseed = NULL;
@@ -2003,6 +1959,9 @@ lpfc_bg_setup_sgl(struct lpfc_hba *phba, struct scsi_cmnd *sc, · 7 unmodified lines
20031959 uint32_t checking = 1;
20041960 uint32_t dma_len;
20051961 uint32_t dma_offset = 0;
1962+ struct sli4_hybrid_sgl *sgl_xtra = NULL;
1963+ int j;
1964+ bool lsp_just_set = false;
20061965
20071966 status = lpfc_sc_to_bg_opcodes(phba, sc, &txop, &rxop);
20081967 if (status)
@@ -2062,23 +2021,64 @@ lpfc_bg_setup_sgl(struct lpfc_hba *phba, struct scsi_cmnd *sc, · 53 unmodified lines
20622021 sgl++;
20632022
20642023 /* assumption: caller has already run dma_map_sg on command data */
2065− scsi_for_each_sg(sc, sgde, datasegcnt, i) {
2066− physaddr = sg_dma_address(sgde);
2067− dma_len = sg_dma_len(sgde);
2068− sgl->addr_lo = cpu_to_le32(putPaddrLow(physaddr));
2069− sgl->addr_hi = cpu_to_le32(putPaddrHigh(physaddr));
2070− if ((i + 1) == datasegcnt)
2071− bf_set(lpfc_sli4_sge_last, sgl, 1);
2072− else
2073− bf_set(lpfc_sli4_sge_last, sgl, 0);
2074− bf_set(lpfc_sli4_sge_offset, sgl, dma_offset);
2075− bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_DATA);
2024+ sgde = scsi_sglist(sc);
2025+ j = 3;
2026+ for (i = 0; i < datasegcnt; i++) {
2027+ /* clear it */
2028+ sgl->word2 = 0;
20762029
2077− sgl->sge_len = cpu_to_le32(dma_len);
2078− dma_offset += dma_len;
2030+ /* do we need to expand the segment */
2031+ if (!lsp_just_set && !((j + 1) % phba->border_sge_num) &&
2032+ ((datasegcnt - 1) != i)) {
2033+ /* set LSP type */
2034+ bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_LSP);
2035+
2036+ sgl_xtra = lpfc_get_sgl_per_hdwq(phba, lpfc_cmd);
2037+
2038+ if (unlikely(!sgl_xtra)) {
2039+ lpfc_cmd->seg_cnt = 0;
2040+ return 0;
2041+ }
2042+ sgl->addr_lo = cpu_to_le32(putPaddrLow(
2043+ sgl_xtra->dma_phys_sgl));
2044+ sgl->addr_hi = cpu_to_le32(putPaddrHigh(
2045+ sgl_xtra->dma_phys_sgl));
2046+
2047+ } else {
2048+ bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_DATA);
2049+ }
2050+
2051+ if (!(bf_get(lpfc_sli4_sge_type, sgl) & LPFC_SGE_TYPE_LSP)) {
2052+ if ((datasegcnt - 1) == i)
2053+ bf_set(lpfc_sli4_sge_last, sgl, 1);
2054+ physaddr = sg_dma_address(sgde);
2055+ dma_len = sg_dma_len(sgde);
2056+ sgl->addr_lo = cpu_to_le32(putPaddrLow(physaddr));
2057+ sgl->addr_hi = cpu_to_le32(putPaddrHigh(physaddr));
2058+
2059+ bf_set(lpfc_sli4_sge_offset, sgl, dma_offset);
2060+ sgl->word2 = cpu_to_le32(sgl->word2);
2061+ sgl->sge_len = cpu_to_le32(dma_len);
2062+
2063+ dma_offset += dma_len;
2064+ sgde = sg_next(sgde);
2065+
2066+ sgl++;
2067+ num_sge++;
2068+ lsp_just_set = false;
2069+
2070+ } else {
2071+ sgl->word2 = cpu_to_le32(sgl->word2);
2072+ sgl->sge_len = cpu_to_le32(phba->cfg_sg_dma_buf_size);
2073+
2074+ sgl = (struct sli4_sge *)sgl_xtra->dma_sgl;
2075+ i = i - 1;
2076+
2077+ lsp_just_set = true;
2078+ }
2079+
2080+ j++;
20792081
2080− sgl++;
2081− num_sge++;
20822082 }
20832083
20842084 out:
@@ -2124,7 +2124,8 @@ out: · 39 unmodified lines
21242124 **/
21252125 static int
21262126 lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
2127− struct sli4_sge *sgl, int datacnt, int protcnt)
2127+ struct sli4_sge *sgl, int datacnt, int protcnt,
2128+ struct lpfc_io_buf *lpfc_cmd)
21282129 {
21292130 struct scatterlist *sgde = NULL; /* s/g data entry */
21302131 struct scatterlist *sgpe = NULL; /* s/g prot entry */
@@ -2146,14 +2147,15 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, · 15 unmodified lines
21462147 #endif
21472148 uint32_t checking = 1;
21482149 uint32_t dma_offset = 0;
2149− int num_sge = 0;
2150+ int num_sge = 0, j = 2;
2151+ struct sli4_hybrid_sgl *sgl_xtra = NULL;
21502152
21512153 sgpe = scsi_prot_sglist(sc);
21522154 sgde = scsi_sglist(sc);
21532155
21542156 if (!sgpe || !sgde) {
21552157 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
2156− "9082 Invalid s/g entry: data=0x%p prot=0x%p\n",
2158+ "9082 Invalid s/g entry: data=x%px prot=x%px\n",
21572159 sgpe, sgde);
21582160 return 0;
21592161 }
@@ -2179,9 +2181,37 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, · 19 unmodified lines
21792181 split_offset = 0;
21802182 do {
21812183 /* Check to see if we ran out of space */
2182− if (num_sge >= (phba->cfg_total_seg_cnt - 2))
2184+ if ((num_sge >= (phba->cfg_total_seg_cnt - 2)) &&
2185+ !(phba->cfg_xpsgl))
21832186 return num_sge + 3;
21842187
2188+ /* DISEED and DIF have to be together */
2189+ if (!((j + 1) % phba->border_sge_num) ||
2190+ !((j + 2) % phba->border_sge_num) ||
2191+ !((j + 3) % phba->border_sge_num)) {
2192+ sgl->word2 = 0;
2193+
2194+ /* set LSP type */
2195+ bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_LSP);
2196+
2197+ sgl_xtra = lpfc_get_sgl_per_hdwq(phba, lpfc_cmd);
2198+
2199+ if (unlikely(!sgl_xtra)) {
2200+ goto out;
2201+ } else {
2202+ sgl->addr_lo = cpu_to_le32(putPaddrLow(
2203+ sgl_xtra->dma_phys_sgl));
2204+ sgl->addr_hi = cpu_to_le32(putPaddrHigh(
2205+ sgl_xtra->dma_phys_sgl));
2206+ }
2207+
2208+ sgl->word2 = cpu_to_le32(sgl->word2);
2209+ sgl->sge_len = cpu_to_le32(phba->cfg_sg_dma_buf_size);
2210+
2211+ sgl = (struct sli4_sge *)sgl_xtra->dma_sgl;
2212+ j = 0;
2213+ }
2214+
21852215 /* setup DISEED with what we have */
21862216 diseed = (struct sli4_sge_diseed *) sgl;
21872217 memset(diseed, 0, sizeof(struct sli4_sge_diseed));
@@ -2228,7 +2258,9 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, · 40 unmodified lines
22282258
22292259 /* advance sgl and increment bde count */
22302260 num_sge++;
2261+
22312262 sgl++;
2263+ j++;
22322264
22332265 /* setup the first BDE that points to protection buffer */
22342266 protphysaddr = sg_dma_address(sgpe) + protgroup_offset;
@@ -2243,6 +2275,7 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, · 8 unmodified lines
22432275 sgl->addr_hi = le32_to_cpu(putPaddrHigh(protphysaddr));
22442276 sgl->addr_lo = le32_to_cpu(putPaddrLow(protphysaddr));
22452277 sgl->word2 = cpu_to_le32(sgl->word2);
2278+ sgl->sge_len = 0;
22462279
22472280 protgrp_blks = protgroup_len / 8;
22482281 protgrp_bytes = protgrp_blks * blksize;
@@ -2263,9 +2296,14 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, · 14 unmodified lines
22632296 /* setup SGE's for data blocks associated with DIF data */
22642297 pgdone = 0;
22652298 subtotal = 0; /* total bytes processed for current prot grp */
2299+
2300+ sgl++;
2301+ j++;
2302+
22662303 while (!pgdone) {
22672304 /* Check to see if we ran out of space */
2268− if (num_sge >= phba->cfg_total_seg_cnt)
2305+ if ((num_sge >= phba->cfg_total_seg_cnt) &&
2306+ !phba->cfg_xpsgl)
22692307 return num_sge + 1;
22702308
22712309 if (!sgde) {
@@ -2274,60 +2312,101 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, · 2 unmodified lines
22742312 __func__);
22752313 return 0;
22762314 }
2277− sgl++;
2278− dataphysaddr = sg_dma_address(sgde) + split_offset;
22792315
2280− remainder = sg_dma_len(sgde) - split_offset;
2316+ if (!((j + 1) % phba->border_sge_num)) {
2317+ sgl->word2 = 0;
22812318
2282− if ((subtotal + remainder) <= protgrp_bytes) {
2283− /* we can use this whole buffer */
2284− dma_len = remainder;
2285− split_offset = 0;
2319+ /* set LSP type */
2320+ bf_set(lpfc_sli4_sge_type, sgl,
2321+ LPFC_SGE_TYPE_LSP);
22862322
2287− if ((subtotal + remainder) == protgrp_bytes)
2288− pgdone = 1;
2323+ sgl_xtra = lpfc_get_sgl_per_hdwq(phba,
2324+ lpfc_cmd);
2325+
2326+ if (unlikely(!sgl_xtra)) {
2327+ goto out;
2328+ } else {
2329+ sgl->addr_lo = cpu_to_le32(
2330+ putPaddrLow(sgl_xtra->dma_phys_sgl));
2331+ sgl->addr_hi = cpu_to_le32(
2332+ putPaddrHigh(sgl_xtra->dma_phys_sgl));
2333+ }
2334+
2335+ sgl->word2 = cpu_to_le32(sgl->word2);
2336+ sgl->sge_len = cpu_to_le32(
2337+ phba->cfg_sg_dma_buf_size);
2338+
2339+ sgl = (struct sli4_sge *)sgl_xtra->dma_sgl;
22892340 } else {
2290− /* must split this buffer with next prot grp */
2291− dma_len = protgrp_bytes - subtotal;
2292− split_offset += dma_len;
2293− }
2341+ dataphysaddr = sg_dma_address(sgde) +
2342+ split_offset;
22942343
2295− subtotal += dma_len;
2344+ remainder = sg_dma_len(sgde) - split_offset;
22962345
2297− sgl->addr_lo = cpu_to_le32(putPaddrLow(dataphysaddr));
2298− sgl->addr_hi = cpu_to_le32(putPaddrHigh(dataphysaddr));
2299− bf_set(lpfc_sli4_sge_last, sgl, 0);
2300− bf_set(lpfc_sli4_sge_offset, sgl, dma_offset);
2301− bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_DATA);
2346+ if ((subtotal + remainder) <= protgrp_bytes) {
2347+ /* we can use this whole buffer */
2348+ dma_len = remainder;
2349+ split_offset = 0;
23022350
2303− sgl->sge_len = cpu_to_le32(dma_len);
2304− dma_offset += dma_len;
2351+ if ((subtotal + remainder) ==
2352+ protgrp_bytes)
2353+ pgdone = 1;
2354+ } else {
2355+ /* must split this buffer with next
2356+ * prot grp
2357+ */
2358+ dma_len = protgrp_bytes - subtotal;
2359+ split_offset += dma_len;
2360+ }
23052361
2306− num_sge++;
2307− curr_data++;
2362+ subtotal += dma_len;
23082363
2309− if (split_offset)
2310− break;
2364+ sgl->word2 = 0;
2365+ sgl->addr_lo = cpu_to_le32(putPaddrLow(
2366+ dataphysaddr));
2367+ sgl->addr_hi = cpu_to_le32(putPaddrHigh(
2368+ dataphysaddr));
2369+ bf_set(lpfc_sli4_sge_last, sgl, 0);
2370+ bf_set(lpfc_sli4_sge_offset, sgl, dma_offset);
2371+ bf_set(lpfc_sli4_sge_type, sgl,
2372+ LPFC_SGE_TYPE_DATA);
23112373
2312− /* Move to the next s/g segment if possible */
2313− sgde = sg_next(sgde);
2374+ sgl->sge_len = cpu_to_le32(dma_len);
2375+ dma_offset += dma_len;
2376+
2377+ num_sge++;
2378+ curr_data++;
2379+
2380+ if (split_offset) {
2381+ sgl++;
2382+ j++;
2383+ break;
2384+ }
2385+
2386+ /* Move to the next s/g segment if possible */
2387+ sgde = sg_next(sgde);
2388+
2389+ sgl++;
2390+ }
2391+
2392+ j++;
23142393 }
23152394
23162395 if (protgroup_offset) {
23172396 /* update the reference tag */
23182397 reftag += protgrp_blks;
2319− sgl++;
23202398 continue;
23212399 }
23222400
23232401 /* are we done ? */
23242402 if (curr_prot == protcnt) {
2403+ /* mark the last SGL */
2404+ sgl--;
23252405 bf_set(lpfc_sli4_sge_last, sgl, 1);
23262406 alldone = 1;
23272407 } else if (curr_prot < protcnt) {
23282408 /* advance to next prot buffer */
23292409 sgpe = sg_next(sgpe);
2330− sgl++;
23312410
23322411 /* update the reference tag */
23332412 reftag += protgrp_blks;
@@ -2430,7 +2509,10 @@ lpfc_bg_scsi_adjust_dl(struct lpfc_hba *phba, · 96 unmodified lines
24302509 *
24312510 * This is the protection/DIF aware version of
24322511 * lpfc_scsi_prep_dma_buf(). It may be a good idea to combine the
2433− * two functions eventually, but for now, it's here
2512+ * two functions eventually, but for now, it's here.
2513+ * RETURNS 0 - SUCCESS,
2514+ * 1 - Failed DMA map, retry.
2515+ * 2 - Invalid scsi cmd or prot-type. Do not rety.
24342516 **/
24352517 static int
24362518 lpfc_bg_scsi_prep_dma_buf_s3(struct lpfc_hba *phba,
@@ -2444,6 +2526,7 @@ lpfc_bg_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, · 7 unmodified lines
24442526 int datasegcnt, protsegcnt, datadir = scsi_cmnd->sc_data_direction;
24452527 int prot_group_type = 0;
24462528 int fcpdl;
2529+ int ret = 1;
24472530 struct lpfc_vport *vport = phba->pport;
24482531
24492532 /*
@@ -2467,8 +2550,11 @@ lpfc_bg_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, · 17 unmodified lines
24672550 lpfc_cmd->seg_cnt = datasegcnt;
24682551
24692552 /* First check if data segment count from SCSI Layer is good */
2470− if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt)
2553+ if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) {
2554+ WARN_ON_ONCE(lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt);
2555+ ret = 2;
24712556 goto err;
2557+ }
24722558
24732559 prot_group_type = lpfc_prot_group_type(phba, scsi_cmnd);
24742560
@@ -2476,14 +2562,18 @@ lpfc_bg_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, · 1 unmodified line
24762562 case LPFC_PG_TYPE_NO_DIF:
24772563
24782564 /* Here we need to add a PDE5 and PDE6 to the count */
2479− if ((lpfc_cmd->seg_cnt + 2) > phba->cfg_total_seg_cnt)
2565+ if ((lpfc_cmd->seg_cnt + 2) > phba->cfg_total_seg_cnt) {
2566+ ret = 2;
24802567 goto err;
2568+ }
24812569
24822570 num_bde = lpfc_bg_setup_bpl(phba, scsi_cmnd, bpl,
24832571 datasegcnt);
24842572 /* we should have 2 or more entries in buffer list */
2485− if (num_bde < 2)
2573+ if (num_bde < 2) {
2574+ ret = 2;
24862575 goto err;
2576+ }
24872577 break;
24882578
24892579 case LPFC_PG_TYPE_DIF_BUF:
@@ -2507,15 +2597,19 @@ lpfc_bg_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, · 17 unmodified lines
25072597 * protection data segment.
25082598 */
25092599 if ((lpfc_cmd->prot_seg_cnt * 4) >
2510− (phba->cfg_total_seg_cnt - 2))
2600+ (phba->cfg_total_seg_cnt - 2)) {
2601+ ret = 2;
25112602 goto err;
2603+ }
25122604
25132605 num_bde = lpfc_bg_setup_bpl_prot(phba, scsi_cmnd, bpl,
25142606 datasegcnt, protsegcnt);
25152607 /* we should have 3 or more entries in buffer list */
25162608 if ((num_bde < 3) ||
2517− (num_bde > phba->cfg_total_seg_cnt))
2609+ (num_bde > phba->cfg_total_seg_cnt)) {
2610+ ret = 2;
25182611 goto err;
2612+ }
25192613 break;
25202614
25212615 case LPFC_PG_TYPE_INVALID:
@@ -2526,7 +2620,7 @@ lpfc_bg_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, · 4 unmodified lines
25262620 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
25272621 "9022 Unexpected protection group %i\n",
25282622 prot_group_type);
2529− return 1;
2623+ return 2;
25302624 }
25312625 }
25322626
@@ -2576,7 +2670,7 @@ err: · 43 unmodified lines
25762670
25772671 lpfc_cmd->seg_cnt = 0;
25782672 lpfc_cmd->prot_seg_cnt = 0;
2579− return 1;
2673+ return ret;
25802674 }
25812675
25822676 /*
@@ -2809,26 +2903,6 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd, · 226 unmodified lines
28092903 uint32_t bgstat = bgf->bgstat;
28102904 uint64_t failing_sector = 0;
28112905
2812− spin_lock(&_dump_buf_lock);
2813− if (!_dump_buf_done) {
2814− lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9070 BLKGRD: Saving"
2815− " Data for %u blocks to debugfs\n",
2816− (cmd->cmnd[7] << 8 | cmd->cmnd[8]));
2817− lpfc_debug_save_data(phba, cmd);
2818−
2819− /* If we have a prot sgl, save the DIF buffer */
2820− if (lpfc_prot_group_type(phba, cmd) ==
2821− LPFC_PG_TYPE_DIF_BUF) {
2822− lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9071 BLKGRD: "
2823− "Saving DIF for %u blocks to debugfs\n",
2824− (cmd->cmnd[7] << 8 | cmd->cmnd[8]));
2825− lpfc_debug_save_dif(phba, cmd);
2826− }
2827−
2828− _dump_buf_done = 1;
2829− }
2830− spin_unlock(&_dump_buf_lock);
2831−
28322906 if (lpfc_bgs_get_invalid_prof(bgstat)) {
28332907 cmd->result = DID_ERROR << 16;
28342908 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
@@ -2962,7 +3036,8 @@ out: · 127 unmodified lines
29623036 * field of @lpfc_cmd for device with SLI-4 interface spec.
29633037 *
29643038 * Return codes:
2965− * 1 - Error
3039+ * 2 - Error - Do not retry
3040+ * 1 - Error - Retry
29663041 * 0 - Success
29673042 **/
29683043 static int
@@ -2978,8 +3053,10 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) · 9 unmodified lines
29783053 uint32_t num_bde = 0;
29793054 uint32_t dma_len;
29803055 uint32_t dma_offset = 0;
2981− int nseg;
3056+ int nseg, i, j;
29823057 struct ulp_bde64 *bde;
3058+ bool lsp_just_set = false;
3059+ struct sli4_hybrid_sgl *sgl_xtra = NULL;
29833060
29843061 /*
29853062 * There are three possibilities here - use scatter-gather segment, use
@@ -3006,15 +3083,17 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) · 20 unmodified lines
30063083 sgl += 1;
30073084 first_data_sgl = sgl;
30083085 lpfc_cmd->seg_cnt = nseg;
3009− if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) {
3086+ if (!phba->cfg_xpsgl &&
3087+ lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) {
30103088 lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9074 BLKGRD:"
30113089 " %s: Too many sg segments from "
30123090 "dma_map_sg. Config %d, seg_cnt %d\n",
30133091 __func__, phba->cfg_sg_seg_cnt,
30143092 lpfc_cmd->seg_cnt);
3093+ WARN_ON_ONCE(lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt);
30153094 lpfc_cmd->seg_cnt = 0;
30163095 scsi_dma_unmap(scsi_cmnd);
3017− return 1;
3096+ return 2;
30183097 }
30193098
30203099 /*
@@ -3026,22 +3105,80 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) · 5 unmodified lines
30263105 * the IOCB. If it can't then the BDEs get added to a BPL as it
30273106 * does for SLI-2 mode.
30283107 */
3029− scsi_for_each_sg(scsi_cmnd, sgel, nseg, num_bde) {
3030− physaddr = sg_dma_address(sgel);
3031− dma_len = sg_dma_len(sgel);
3032− sgl->addr_lo = cpu_to_le32(putPaddrLow(physaddr));
3033− sgl->addr_hi = cpu_to_le32(putPaddrHigh(physaddr));
3034− sgl->word2 = le32_to_cpu(sgl->word2);
3035− if ((num_bde + 1) == nseg)
3108+
3109+ /* for tracking segment boundaries */
3110+ sgel = scsi_sglist(scsi_cmnd);
3111+ j = 2;
3112+ for (i = 0; i < nseg; i++) {
3113+ sgl->word2 = 0;
3114+ if ((num_bde + 1) == nseg) {
30363115 bf_set(lpfc_sli4_sge_last, sgl, 1);
3037− else
3116+ bf_set(lpfc_sli4_sge_type, sgl,
3117+ LPFC_SGE_TYPE_DATA);
3118+ } else {
30383119 bf_set(lpfc_sli4_sge_last, sgl, 0);
3039− bf_set(lpfc_sli4_sge_offset, sgl, dma_offset);
3040− bf_set(lpfc_sli4_sge_type, sgl, LPFC_SGE_TYPE_DATA);
3041− sgl->word2 = cpu_to_le32(sgl->word2);
3042− sgl->sge_len = cpu_to_le32(dma_len);
3043− dma_offset += dma_len;
3044− sgl++;
3120+
3121+ /* do we need to expand the segment */
3122+ if (!lsp_just_set &&
3123+ !((j + 1) % phba->border_sge_num) &&
3124+ ((nseg - 1) != i)) {
3125+ /* set LSP type */
3126+ bf_set(lpfc_sli4_sge_type, sgl,
3127+ LPFC_SGE_TYPE_LSP);
3128+
3129+ sgl_xtra = lpfc_get_sgl_per_hdwq(
3130+ phba, lpfc_cmd);
3131+
3132+ if (unlikely(!sgl_xtra)) {
3133+ lpfc_cmd->seg_cnt = 0;
3134+ scsi_dma_unmap(scsi_cmnd);
3135+ return 1;
3136+ }
3137+ sgl->addr_lo = cpu_to_le32(putPaddrLow(
3138+ sgl_xtra->dma_phys_sgl));
3139+ sgl->addr_hi = cpu_to_le32(putPaddrHigh(
3140+ sgl_xtra->dma_phys_sgl));
3141+
3142+ } else {
3143+ bf_set(lpfc_sli4_sge_type, sgl,
3144+ LPFC_SGE_TYPE_DATA);
3145+ }
3146+ }
3147+
3148+ if (!(bf_get(lpfc_sli4_sge_type, sgl) &
3149+ LPFC_SGE_TYPE_LSP)) {
3150+ if ((nseg - 1) == i)
3151+ bf_set(lpfc_sli4_sge_last, sgl, 1);
3152+
3153+ physaddr = sg_dma_address(sgel);
3154+ dma_len = sg_dma_len(sgel);
3155+ sgl->addr_lo = cpu_to_le32(putPaddrLow(
3156+ physaddr));
3157+ sgl->addr_hi = cpu_to_le32(putPaddrHigh(
3158+ physaddr));
3159+
3160+ bf_set(lpfc_sli4_sge_offset, sgl, dma_offset);
3161+ sgl->word2 = cpu_to_le32(sgl->word2);
3162+ sgl->sge_len = cpu_to_le32(dma_len);
3163+
3164+ dma_offset += dma_len;
3165+ sgel = sg_next(sgel);
3166+
3167+ sgl++;
3168+ lsp_just_set = false;
3169+
3170+ } else {
3171+ sgl->word2 = cpu_to_le32(sgl->word2);
3172+ sgl->sge_len = cpu_to_le32(
3173+ phba->cfg_sg_dma_buf_size);
3174+
3175+ sgl = (struct sli4_sge *)sgl_xtra->dma_sgl;
3176+ i = i - 1;
3177+
3178+ lsp_just_set = true;
3179+ }
3180+
3181+ j++;
30453182 }
30463183 /*
30473184 * Setup the first Payload BDE. For FCoE we just key off
@@ -3110,6 +3247,10 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) · 62 unmodified lines
31103247 * This is the protection/DIF aware version of
31113248 * lpfc_scsi_prep_dma_buf(). It may be a good idea to combine the
31123249 * two functions eventually, but for now, it's here
3250+ * Return codes:
3251+ * 2 - Error - Do not retry
3252+ * 1 - Error - Retry
3253+ * 0 - Success
31133254 **/
31143255 static int
31153256 lpfc_bg_scsi_prep_dma_buf_s4(struct lpfc_hba *phba,
@@ -3123,6 +3264,7 @@ lpfc_bg_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, · 7 unmodified lines
31233264 int datasegcnt, protsegcnt, datadir = scsi_cmnd->sc_data_direction;
31243265 int prot_group_type = 0;
31253266 int fcpdl;
3267+ int ret = 1;
31263268 struct lpfc_vport *vport = phba->pport;
31273269
31283270 /*
@@ -3152,23 +3294,33 @@ lpfc_bg_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, · 23 unmodified lines
31523294 lpfc_cmd->seg_cnt = datasegcnt;
31533295
31543296 /* First check if data segment count from SCSI Layer is good */
3155− if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt)
3297+ if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt &&
3298+ !phba->cfg_xpsgl) {
3299+ WARN_ON_ONCE(lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt);
3300+ ret = 2;
31563301 goto err;
3302+ }
31573303
31583304 prot_group_type = lpfc_prot_group_type(phba, scsi_cmnd);
31593305
31603306 switch (prot_group_type) {
31613307 case LPFC_PG_TYPE_NO_DIF:
31623308 /* Here we need to add a DISEED to the count */
3163− if ((lpfc_cmd->seg_cnt + 1) > phba->cfg_total_seg_cnt)
3309+ if (((lpfc_cmd->seg_cnt + 1) >
3310+ phba->cfg_total_seg_cnt) &&
3311+ !phba->cfg_xpsgl) {
3312+ ret = 2;
31643313 goto err;
3314+ }
31653315
31663316 num_sge = lpfc_bg_setup_sgl(phba, scsi_cmnd, sgl,
3167− datasegcnt);
3317+ datasegcnt, lpfc_cmd);
31683318
31693319 /* we should have 2 or more entries in buffer list */
3170− if (num_sge < 2)
3320+ if (num_sge < 2) {
3321+ ret = 2;
31713322 goto err;
3323+ }
31723324 break;
31733325
31743326 case LPFC_PG_TYPE_DIF_BUF:
@@ -3190,17 +3342,23 @@ lpfc_bg_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, · 15 unmodified lines
31903342 * There is a minimun of 3 SGEs used for every
31913343 * protection data segment.
31923344 */
3193− if ((lpfc_cmd->prot_seg_cnt * 3) >
3194− (phba->cfg_total_seg_cnt - 2))
3345+ if (((lpfc_cmd->prot_seg_cnt * 3) >
3346+ (phba->cfg_total_seg_cnt - 2)) &&
3347+ !phba->cfg_xpsgl) {
3348+ ret = 2;
31953349 goto err;
3350+ }
31963351
31973352 num_sge = lpfc_bg_setup_sgl_prot(phba, scsi_cmnd, sgl,
3198− datasegcnt, protsegcnt);
3353+ datasegcnt, protsegcnt, lpfc_cmd);
31993354
32003355 /* we should have 3 or more entries in buffer list */
3201− if ((num_sge < 3) ||
3202− (num_sge > phba->cfg_total_seg_cnt))
3356+ if (num_sge < 3 ||
3357+ (num_sge > phba->cfg_total_seg_cnt &&
3358+ !phba->cfg_xpsgl)) {
3359+ ret = 2;
32033360 goto err;
3361+ }
32043362 break;
32053363
32063364 case LPFC_PG_TYPE_INVALID:
@@ -3211,7 +3369,7 @@ lpfc_bg_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, · 4 unmodified lines
32113369 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
32123370 "9083 Unexpected protection group %i\n",
32133371 prot_group_type);
3214− return 1;
3372+ return 2;
32153373 }
32163374 }
32173375
@@ -3273,7 +3431,7 @@ err: · 55 unmodified lines
32733431
32743432 lpfc_cmd->seg_cnt = 0;
32753433 lpfc_cmd->prot_seg_cnt = 0;
3276− return 1;
3434+ return ret;
32773435 }
32783436
32793437 /**
@@ -3839,7 +3997,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, · 559 unmodified lines
38393997 uint32_t *lp = (uint32_t *)cmd->sense_buffer;
38403998
38413999 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
3842− "0710 Iodone <%d/%llu> cmd %p, error "
4000+ "0710 Iodone <%d/%llu> cmd x%px, error "
38434001 "x%x SNS x%x x%x Data: x%x x%x\n",
38444002 cmd->device->id, cmd->device->lun, cmd,
38454003 cmd->result, *lp, *(lp + 3), cmd->retries,
@@ -4454,8 +4612,12 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd) · 608 unmodified lines
44544612 err = lpfc_scsi_prep_dma_buf(phba, lpfc_cmd);
44554613 }
44564614
4457− if (err)
4615+ if (err == 2) {
4616+ cmnd->result = DID_ERROR << 16;
4617+ goto out_fail_command_release_buf;
4618+ } else if (err) {
44584619 goto out_host_busy_free_buf;
4620+ }
44594621
44604622 lpfc_scsi_prep_cmnd(vport, lpfc_cmd, ndlp);
44614623
@@ -4526,6 +4688,9 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd) · 64 unmodified lines
45264688 out_tgt_busy:
45274689 return SCSI_MLQUEUE_TARGET_BUSY;
45284690
4691+ out_fail_command_release_buf:
4692+ lpfc_release_scsi_buf(phba, lpfc_cmd);
4693+
45294694 out_fail_command:
45304695 cmnd->scsi_done(cmnd);
45314696 return 0;
@@ -4568,7 +4733,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) · 36 unmodified lines
45684733
45694734 spin_lock_irqsave(&phba->hbalock, flags);
45704735 /* driver queued commands are in process of being flushed */
4571− if (phba->hba_flag & HBA_FCP_IOQ_FLUSH) {
4736+ if (phba->hba_flag & HBA_IOQ_FLUSH) {
45724737 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
45734738 "3168 SCSI Layer abort requested I/O has been "
45744739 "flushed by LLD.\n");
@@ -4589,7 +4754,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) · 14 unmodified lines
45894754
45904755 iocb = &lpfc_cmd->cur_iocbq;
45914756 if (phba->sli_rev == LPFC_SLI_REV4) {
4592− pring_s4 = phba->sli4_hba.hdwq[iocb->hba_wqidx].fcp_wq->pring;
4757+ pring_s4 = phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring;
45934758 if (!pring_s4) {
45944759 ret = FAILED;
45954760 goto out_unlock_buf;
@@ -4956,7 +5121,7 @@ lpfc_chk_tgt_mapped(struct lpfc_vport *vport, struct scsi_cmnd *cmnd) · 360 unmodified lines
49565121 rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
49575122 if (!rdata) {
49585123 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
4959− "0797 Tgt Map rport failure: rdata x%p\n", rdata);
5124+ "0797 Tgt Map rport failure: rdata x%px\n", rdata);
49605125 return FAILED;
49615126 }
49625127 pnode = rdata->pnode;
@@ -5054,7 +5219,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd) · 91 unmodified lines
50545219 rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
50555220 if (!rdata || !rdata->pnode) {
50565221 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
5057− "0798 Device Reset rdata failure: rdata x%p\n",
5222+ "0798 Device Reset rdata failure: rdata x%px\n",
50585223 rdata);
50595224 return FAILED;
50605225 }
@@ -5066,7 +5231,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd) · 5 unmodified lines
50665231 status = lpfc_chk_tgt_mapped(vport, cmnd);
50675232 if (status == FAILED) {
50685233 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
5069− "0721 Device Reset rport failure: rdata x%p\n", rdata);
5234+ "0721 Device Reset rport failure: rdata x%px\n", rdata);
50705235 return FAILED;
50715236 }
50725237
@@ -5125,7 +5290,7 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd) · 52 unmodified lines
51255290 rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
51265291 if (!rdata || !rdata->pnode) {
51275292 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
5128− "0799 Target Reset rdata failure: rdata x%p\n",
5293+ "0799 Target Reset rdata failure: rdata x%px\n",
51295294 rdata);
51305295 return FAILED;
51315296 }
@@ -5137,7 +5302,7 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd) · 5 unmodified lines
51375302 status = lpfc_chk_tgt_mapped(vport, cmnd);
51385303 if (status == FAILED) {
51395304 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
5140− "0722 Target Reset rport failure: rdata x%p\n", rdata);
5305+ "0722 Target Reset rport failure: rdata x%px\n", rdata);
51415306 if (pnode) {
51425307 spin_lock_irq(shost->host_lock);
51435308 pnode->nlp_flag &= ~NLP_NPR_ADISC;
@@ -5295,18 +5460,20 @@ lpfc_host_reset_handler(struct scsi_cmnd *cmnd) · 151 unmodified lines
52955460 lpfc_offline(phba);
52965461 rc = lpfc_sli_brdrestart(phba);
52975462 if (rc)
5298− ret = FAILED;
5463+ goto error;
5464+
52995465 rc = lpfc_online(phba);
53005466 if (rc)
5301− ret = FAILED;
5467+ goto error;
5468+
53025469 lpfc_unblock_mgmt_io(phba);
53035470
5304− if (ret == FAILED) {
5305− lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
5306− "3323 Failed host reset, bring it offline\n");
5307− lpfc_sli4_offline_eratt(phba);
5308− }
53095471 return ret;
5472+error:
5473+ lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
5474+ "3323 Failed host reset\n");
5475+ lpfc_unblock_mgmt_io(phba);
5476+ return FAILED;
53105477 }
53115478
53125479 /**
@@ -5870,7 +6037,7 @@ struct scsi_host_template lpfc_template_no_hr = { · 557 unmodified lines
58706037 .sg_tablesize = LPFC_DEFAULT_SG_SEG_CNT,
58716038 .cmd_per_lun = LPFC_CMD_PER_LUN,
58726039 .shost_attrs = lpfc_hba_attrs,
5873− .max_sectors = 0xFFFF,
6040+ .max_sectors = 0xFFFFFFFF,
58746041 .vendor_id = LPFC_NL_VENDOR_ID,
58756042 .change_queue_depth = scsi_change_queue_depth,
58766043 .track_queue_depth = 1,
drivers/scsi/lpfc/lpfc_sli.c+397−136
@@ -1391,9 +1391,12 @@ lpfc_sli_cancel_iocbs(struct lpfc_hba *phba, struct list_head *iocblist, · 1390 unmodified lines
13911391
13921392 while (!list_empty(iocblist)) {
13931393 list_remove_head(iocblist, piocb, struct lpfc_iocbq, list);
1394− if (!piocb->iocb_cmpl)
1395− lpfc_sli_release_iocbq(phba, piocb);
1396− else {
1394+ if (!piocb->iocb_cmpl) {
1395+ if (piocb->iocb_flag & LPFC_IO_NVME)
1396+ lpfc_nvme_cancel_iocb(phba, piocb);
1397+ else
1398+ lpfc_sli_release_iocbq(phba, piocb);
1399+ } else {
13971400 piocb->iocb.ulpStatus = ulpstatus;
13981401 piocb->iocb.un.ulpWord[4] = ulpWord4;
13991402 (piocb->iocb_cmpl) (phba, piocb, piocb);
@@ -2426,6 +2429,20 @@ lpfc_sli_wake_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq) · 1026 unmodified lines
24262429 return;
24272430 }
24282431
2432+static void
2433+__lpfc_sli_rpi_release(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
2434+{
2435+ unsigned long iflags;
2436+
2437+ if (ndlp->nlp_flag & NLP_RELEASE_RPI) {
2438+ lpfc_sli4_free_rpi(vport->phba, ndlp->nlp_rpi);
2439+ spin_lock_irqsave(&vport->phba->ndlp_lock, iflags);
2440+ ndlp->nlp_flag &= ~NLP_RELEASE_RPI;
2441+ ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR;
2442+ spin_unlock_irqrestore(&vport->phba->ndlp_lock, iflags);
2443+ }
2444+ ndlp->nlp_flag &= ~NLP_UNREG_INP;
2445+}
24292446
24302447 /**
24312448 * lpfc_sli_def_mbox_cmpl - Default mailbox completion handler
@@ -2497,7 +2514,7 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 65 unmodified lines
24972514 vport,
24982515 KERN_INFO, LOG_MBOX | LOG_DISCOVERY,
24992516 "1438 UNREG cmpl deferred mbox x%x "
2500− "on NPort x%x Data: x%x x%x %p\n",
2517+ "on NPort x%x Data: x%x x%x %px\n",
25012518 ndlp->nlp_rpi, ndlp->nlp_DID,
25022519 ndlp->nlp_flag, ndlp->nlp_defer_did, ndlp);
25032520
@@ -2507,7 +2524,7 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 3 unmodified lines
25072524 ndlp->nlp_defer_did = NLP_EVT_NOTHING_PENDING;
25082525 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
25092526 } else {
2510− ndlp->nlp_flag &= ~NLP_UNREG_INP;
2527+ __lpfc_sli_rpi_release(vport, ndlp);
25112528 }
25122529 pmb->ctx_ndlp = NULL;
25132530 }
@@ -2555,7 +2572,7 @@ lpfc_sli4_unreg_rpi_cmpl_clr(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 41 unmodified lines
25552572 vport, KERN_INFO, LOG_MBOX | LOG_SLI,
25562573 "0010 UNREG_LOGIN vpi:%x "
25572574 "rpi:%x DID:%x defer x%x flg x%x "
2558− "map:%x %p\n",
2575+ "map:%x %px\n",
25592576 vport->vpi, ndlp->nlp_rpi,
25602577 ndlp->nlp_DID, ndlp->nlp_defer_did,
25612578 ndlp->nlp_flag,
@@ -2573,7 +2590,7 @@ lpfc_sli4_unreg_rpi_cmpl_clr(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 11 unmodified lines
25732590 vport, KERN_INFO, LOG_DISCOVERY,
25742591 "4111 UNREG cmpl deferred "
25752592 "clr x%x on "
2576− "NPort x%x Data: x%x %p\n",
2593+ "NPort x%x Data: x%x x%px\n",
25772594 ndlp->nlp_rpi, ndlp->nlp_DID,
25782595 ndlp->nlp_defer_did, ndlp);
25792596 ndlp->nlp_flag &= ~NLP_UNREG_INP;
@@ -2582,7 +2599,7 @@ lpfc_sli4_unreg_rpi_cmpl_clr(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 2 unmodified lines
25822599 lpfc_issue_els_plogi(
25832600 vport, ndlp->nlp_DID, 0);
25842601 } else {
2585− ndlp->nlp_flag &= ~NLP_UNREG_INP;
2602+ __lpfc_sli_rpi_release(vport, ndlp);
25862603 }
25872604 }
25882605 }
@@ -2695,7 +2712,7 @@ lpfc_sli_handle_mb_event(struct lpfc_hba *phba) · 106 unmodified lines
26952712
26962713 /* Mailbox cmd <cmd> Cmpl <cmpl> */
26972714 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI,
2698− "(%d):0307 Mailbox cmd x%x (x%x/x%x) Cmpl x%p "
2715+ "(%d):0307 Mailbox cmd x%x (x%x/x%x) Cmpl %ps "
26992716 "Data: x%x x%x x%x x%x x%x x%x x%x x%x x%x "
27002717 "x%x x%x x%x\n",
27012718 pmb->vport ? pmb->vport->vpi : 0,
@@ -3961,7 +3978,7 @@ lpfc_sli_abort_fcp_rings(struct lpfc_hba *phba) · 1259 unmodified lines
39613978 /* Look on all the FCP Rings for the iotag */
39623979 if (phba->sli_rev >= LPFC_SLI_REV4) {
39633980 for (i = 0; i < phba->cfg_hdw_queue; i++) {
3964− pring = phba->sli4_hba.hdwq[i].fcp_wq->pring;
3981+ pring = phba->sli4_hba.hdwq[i].io_wq->pring;
39653982 lpfc_sli_abort_iocb_ring(phba, pring);
39663983 }
39673984 } else {
@@ -3971,17 +3988,17 @@ lpfc_sli_abort_fcp_rings(struct lpfc_hba *phba) · 3 unmodified lines
39713988 }
39723989
39733990 /**
3974− * lpfc_sli_flush_fcp_rings - flush all iocbs in the fcp ring
3991+ * lpfc_sli_flush_io_rings - flush all iocbs in the IO ring
39753992 * @phba: Pointer to HBA context object.
39763993 *
3977− * This function flushes all iocbs in the fcp ring and frees all the iocb
3994+ * This function flushes all iocbs in the IO ring and frees all the iocb
39783995 * objects in txq and txcmplq. This function will not issue abort iocbs
39793996 * for all the iocb commands in txcmplq, they will just be returned with
39803997 * IOERR_SLI_DOWN. This function is invoked with EEH when device's PCI
39813998 * slot has been permanently disabled.
39823999 **/
39834000 void
3984−lpfc_sli_flush_fcp_rings(struct lpfc_hba *phba)
4001+lpfc_sli_flush_io_rings(struct lpfc_hba *phba)
39854002 {
39864003 LIST_HEAD(txq);
39874004 LIST_HEAD(txcmplq);
@@ -3992,13 +4009,13 @@ lpfc_sli_flush_fcp_rings(struct lpfc_hba *phba) · 4 unmodified lines
39924009
39934010 spin_lock_irq(&phba->hbalock);
39944011 /* Indicate the I/O queues are flushed */
3995− phba->hba_flag |= HBA_FCP_IOQ_FLUSH;
4012+ phba->hba_flag |= HBA_IOQ_FLUSH;
39964013 spin_unlock_irq(&phba->hbalock);
39974014
39984015 /* Look on all the FCP Rings for the iotag */
39994016 if (phba->sli_rev >= LPFC_SLI_REV4) {
40004017 for (i = 0; i < phba->cfg_hdw_queue; i++) {
4001− pring = phba->sli4_hba.hdwq[i].fcp_wq->pring;
4018+ pring = phba->sli4_hba.hdwq[i].io_wq->pring;
40024019
40034020 spin_lock_irq(&pring->ring_lock);
40044021 /* Retrieve everything on txq */
@@ -4045,56 +4062,6 @@ lpfc_sli_flush_fcp_rings(struct lpfc_hba *phba) · 40 unmodified lines
40454062 }
40464063 }
40474064
4048−/**
4049− * lpfc_sli_flush_nvme_rings - flush all wqes in the nvme rings
4050− * @phba: Pointer to HBA context object.
4051− *
4052− * This function flushes all wqes in the nvme rings and frees all resources
4053− * in the txcmplq. This function does not issue abort wqes for the IO
4054− * commands in txcmplq, they will just be returned with
4055− * IOERR_SLI_DOWN. This function is invoked with EEH when device's PCI
4056− * slot has been permanently disabled.
4057− **/
4058−void
4059−lpfc_sli_flush_nvme_rings(struct lpfc_hba *phba)
4060−{
4061− LIST_HEAD(txcmplq);
4062− struct lpfc_sli_ring *pring;
4063− uint32_t i;
4064− struct lpfc_iocbq *piocb, *next_iocb;
4065−
4066− if ((phba->sli_rev < LPFC_SLI_REV4) ||
4067− !(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME))
4068− return;
4069−
4070− /* Hint to other driver operations that a flush is in progress. */
4071− spin_lock_irq(&phba->hbalock);
4072− phba->hba_flag |= HBA_NVME_IOQ_FLUSH;
4073− spin_unlock_irq(&phba->hbalock);
4074−
4075− /* Cycle through all NVME rings and complete each IO with
4076− * a local driver reason code. This is a flush so no
4077− * abort exchange to FW.
4078− */
4079− for (i = 0; i < phba->cfg_hdw_queue; i++) {
4080− pring = phba->sli4_hba.hdwq[i].nvme_wq->pring;
4081−
4082− spin_lock_irq(&pring->ring_lock);
4083− list_for_each_entry_safe(piocb, next_iocb,
4084− &pring->txcmplq, list)
4085− piocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ;
4086− /* Retrieve everything on the txcmplq */
4087− list_splice_init(&pring->txcmplq, &txcmplq);
4088− pring->txcmplq_cnt = 0;
4089− spin_unlock_irq(&pring->ring_lock);
4090−
4091− /* Flush the txcmpq &&&PAE */
4092− lpfc_sli_cancel_iocbs(phba, &txcmplq,
4093− IOSTAT_LOCAL_REJECT,
4094− IOERR_SLI_DOWN);
4095− }
4096−}
4097−
40984065 /**
40994066 * lpfc_sli_brdready_s3 - Check for sli3 host ready status
41004067 * @phba: Pointer to HBA context object.
@@ -4495,7 +4462,7 @@ lpfc_sli_brdreset(struct lpfc_hba *phba) · 394 unmodified lines
44954462 * checking during resets the device. The caller is not required to hold
44964463 * any locks.
44974464 *
4498− * This function returns 0 always.
4465+ * This function returns 0 on success else returns negative error code.
44994466 **/
45004467 int
45014468 lpfc_sli4_brdreset(struct lpfc_hba *phba)
@@ -4652,8 +4619,10 @@ lpfc_sli_brdrestart_s4(struct lpfc_hba *phba) · 150 unmodified lines
46524619 hba_aer_enabled = phba->hba_flag & HBA_AER_ENABLED;
46534620
46544621 rc = lpfc_sli4_brdreset(phba);
4655− if (rc)
4656− return rc;
4622+ if (rc) {
4623+ phba->link_state = LPFC_HBA_ERROR;
4624+ goto hba_down_queue;
4625+ }
46574626
46584627 spin_lock_irq(&phba->hbalock);
46594628 phba->pport->stopped = 0;
@@ -4668,6 +4637,7 @@ lpfc_sli_brdrestart_s4(struct lpfc_hba *phba) · 8 unmodified lines
46684637 if (hba_aer_enabled)
46694638 pci_disable_pcie_error_reporting(phba->pcidev);
46704639
4640+hba_down_queue:
46714641 lpfc_hba_down_post(phba);
46724642 lpfc_sli4_queue_destroy(phba);
46734643
@@ -5584,10 +5554,8 @@ lpfc_sli4_arm_cqeq_intr(struct lpfc_hba *phba) · 910 unmodified lines
55845554 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) {
55855555 qp = &sli4_hba->hdwq[qidx];
55865556 /* ARM the corresponding CQ */
5587− sli4_hba->sli4_write_cq_db(phba, qp->fcp_cq, 0,
5588− LPFC_QUEUE_REARM);
5589− sli4_hba->sli4_write_cq_db(phba, qp->nvme_cq, 0,
5590− LPFC_QUEUE_REARM);
5557+ sli4_hba->sli4_write_cq_db(phba, qp->io_cq, 0,
5558+ LPFC_QUEUE_REARM);
55915559 }
55925560
55935561 /* Loop thru all IRQ vectors */
@@ -7243,7 +7211,7 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba) · 1649 unmodified lines
72437211 else
72447212 phba->hba_flag &= ~HBA_FIP_SUPPORT;
72457213
7246− phba->hba_flag &= ~HBA_FCP_IOQ_FLUSH;
7214+ phba->hba_flag &= ~HBA_IOQ_FLUSH;
72477215
72487216 if (phba->sli_rev != LPFC_SLI_REV4) {
72497217 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,
@@ -7972,7 +7940,7 @@ lpfc_mbox_timeout_handler(struct lpfc_hba *phba) · 722 unmodified lines
79727940
79737941 /* Mbox cmd <mbxCommand> timeout */
79747942 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,
7975− "0310 Mailbox command x%x timeout Data: x%x x%x x%p\n",
7943+ "0310 Mailbox command x%x timeout Data: x%x x%x x%px\n",
79767944 mb->mbxCommand,
79777945 phba->pport->port_state,
79787946 phba->sli.sli_flag,
@@ -9333,11 +9301,9 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq, · 1354 unmodified lines
93339301 memset(wqe, 0, sizeof(union lpfc_wqe128));
93349302 /* Some of the fields are in the right position already */
93359303 memcpy(wqe, &iocbq->iocb, sizeof(union lpfc_wqe));
9336− if (iocbq->iocb.ulpCommand != CMD_SEND_FRAME) {
9337− /* The ct field has moved so reset */
9338− wqe->generic.wqe_com.word7 = 0;
9339− wqe->generic.wqe_com.word10 = 0;
9340− }
9304+ /* The ct field has moved so reset */
9305+ wqe->generic.wqe_com.word7 = 0;
9306+ wqe->generic.wqe_com.word10 = 0;
93419307
93429308 abort_tag = (uint32_t) iocbq->iotag;
93439309 xritag = iocbq->sli4_xritag;
@@ -9796,7 +9762,7 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq, · 452 unmodified lines
97969762 * we re-construct this WQE here based on information in
97979763 * iocbq from scratch.
97989764 */
9799− memset(wqe, 0, sizeof(union lpfc_wqe));
9765+ memset(wqe, 0, sizeof(*wqe));
98009766 /* OX_ID is invariable to who sent ABTS to CT exchange */
98019767 bf_set(xmit_bls_rsp64_oxid, &wqe->xmit_bls_rsp,
98029768 bf_get(lpfc_abts_oxid, &iocbq->iocb.un.bls_rsp));
@@ -9843,6 +9809,15 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq, · 40 unmodified lines
98439809
98449810 break;
98459811 case CMD_SEND_FRAME:
9812+ bf_set(wqe_cmnd, &wqe->generic.wqe_com, CMD_SEND_FRAME);
9813+ bf_set(wqe_sof, &wqe->generic.wqe_com, 0x2E); /* SOF byte */
9814+ bf_set(wqe_eof, &wqe->generic.wqe_com, 0x41); /* EOF byte */
9815+ bf_set(wqe_lenloc, &wqe->generic.wqe_com, 1);
9816+ bf_set(wqe_xbl, &wqe->generic.wqe_com, 1);
9817+ bf_set(wqe_dbde, &wqe->generic.wqe_com, 1);
9818+ bf_set(wqe_xc, &wqe->generic.wqe_com, 1);
9819+ bf_set(wqe_cmd_type, &wqe->generic.wqe_com, 0xA);
9820+ bf_set(wqe_cqid, &wqe->generic.wqe_com, LPFC_WQE_CQ_ID_DEFAULT);
98469821 bf_set(wqe_xri_tag, &wqe->generic.wqe_com, xritag);
98479822 bf_set(wqe_reqtag, &wqe->generic.wqe_com, iocbq->iotag);
98489823 return 0;
@@ -9904,7 +9879,7 @@ __lpfc_sli_issue_iocb_s4(struct lpfc_hba *phba, uint32_t ring_number, · 55 unmodified lines
99049879 /* Get the WQ */
99059880 if ((piocb->iocb_flag & LPFC_IO_FCP) ||
99069881 (piocb->iocb_flag & LPFC_USE_FCPWQIDX)) {
9907− wq = phba->sli4_hba.hdwq[piocb->hba_wqidx].fcp_wq;
9882+ wq = phba->sli4_hba.hdwq[piocb->hba_wqidx].io_wq;
99089883 } else {
99099884 wq = phba->sli4_hba.els_wq;
99109885 }
@@ -10051,7 +10026,7 @@ lpfc_sli4_calc_ring(struct lpfc_hba *phba, struct lpfc_iocbq *piocb) · 140 unmodified lines
1005110026 lpfc_cmd = (struct lpfc_io_buf *)piocb->context1;
1005210027 piocb->hba_wqidx = lpfc_cmd->hdwq_no;
1005310028 }
10054− return phba->sli4_hba.hdwq[piocb->hba_wqidx].fcp_wq->pring;
10029+ return phba->sli4_hba.hdwq[piocb->hba_wqidx].io_wq->pring;
1005510030 } else {
1005610031 if (unlikely(!phba->sli4_hba.els_wq))
1005710032 return NULL;
@@ -10504,7 +10479,7 @@ lpfc_sli4_queue_init(struct lpfc_hba *phba) · 446 unmodified lines
1050410479 INIT_LIST_HEAD(&psli->mboxq_cmpl);
1050510480 /* Initialize list headers for txq and txcmplq as double linked lists */
1050610481 for (i = 0; i < phba->cfg_hdw_queue; i++) {
10507− pring = phba->sli4_hba.hdwq[i].fcp_wq->pring;
10482+ pring = phba->sli4_hba.hdwq[i].io_wq->pring;
1050810483 pring->flag = 0;
1050910484 pring->ringno = LPFC_FCP_RING;
1051010485 pring->txcmplq_cnt = 0;
@@ -10523,16 +10498,6 @@ lpfc_sli4_queue_init(struct lpfc_hba *phba) · 12 unmodified lines
1052310498 spin_lock_init(&pring->ring_lock);
1052410499
1052510500 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
10526− for (i = 0; i < phba->cfg_hdw_queue; i++) {
10527− pring = phba->sli4_hba.hdwq[i].nvme_wq->pring;
10528− pring->flag = 0;
10529− pring->ringno = LPFC_FCP_RING;
10530− pring->txcmplq_cnt = 0;
10531− INIT_LIST_HEAD(&pring->txq);
10532− INIT_LIST_HEAD(&pring->txcmplq);
10533− INIT_LIST_HEAD(&pring->iocb_continueq);
10534− spin_lock_init(&pring->ring_lock);
10535− }
1053610501 pring = phba->sli4_hba.nvmels_wq->pring;
1053710502 pring->flag = 0;
1053810503 pring->ringno = LPFC_ELS_RING;
@@ -10796,9 +10761,9 @@ lpfc_sli_hba_down(struct lpfc_hba *phba) · 257 unmodified lines
1079610761 pring = qp->pring;
1079710762 if (!pring)
1079810763 continue;
10799− spin_lock_irq(&pring->ring_lock);
10764+ spin_lock(&pring->ring_lock);
1080010765 list_splice_init(&pring->txq, &completions);
10801− spin_unlock_irq(&pring->ring_lock);
10766+ spin_unlock(&pring->ring_lock);
1080210767 if (pring == phba->sli4_hba.els_wq->pring) {
1080310768 pring->flag |= LPFC_DEFERRED_RING_EVENT;
1080410769 /* Set the lpfc data pending flag */
@@ -10979,7 +10944,7 @@ lpfc_sli_ring_taggedbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 174 unmodified lines
1097910944 spin_unlock_irq(&phba->hbalock);
1098010945 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1098110946 "0402 Cannot find virtual addr for buffer tag on "
10982− "ring %d Data x%lx x%p x%p x%x\n",
10947+ "ring %d Data x%lx x%px x%px x%x\n",
1098310948 pring->ringno, (unsigned long) tag,
1098410949 slp->next, slp->prev, pring->postbufq_cnt);
1098510950
@@ -11023,7 +10988,7 @@ lpfc_sli_ringpostbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 37 unmodified lines
1102310988 spin_unlock_irq(&phba->hbalock);
1102410989 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1102510990 "0410 Cannot find virtual addr for mapped buf on "
11026− "ring %d Data x%llx x%p x%p x%x\n",
10991+ "ring %d Data x%llx x%px x%px x%x\n",
1102710992 pring->ringno, (unsigned long long)phys,
1102810993 slp->next, slp->prev, pring->postbufq_cnt);
1102910994 return NULL;
@@ -11078,13 +11043,16 @@ lpfc_sli_abort_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 48 unmodified lines
1107811043 abort_iocb = phba->sli.iocbq_lookup[abort_context];
1107911044
1108011045 lpfc_printf_log(phba, KERN_WARNING, LOG_ELS | LOG_SLI,
11081− "0327 Cannot abort els iocb %p "
11046+ "0327 Cannot abort els iocb x%px "
1108211047 "with tag %x context %x, abort status %x, "
1108311048 "abort code %x\n",
1108411049 abort_iocb, abort_iotag, abort_context,
1108511050 irsp->ulpStatus, irsp->un.ulpWord[4]);
1108611051
1108711052 spin_unlock_irq(&phba->hbalock);
11053+ if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT &&
11054+ irsp->un.ulpWord[4] == IOERR_SLI_ABORTED)
11055+ lpfc_sli_release_iocbq(phba, abort_iocb);
1108811056 }
1108911057 release_iocb:
1109011058 lpfc_sli_release_iocbq(phba, cmdiocb);
@@ -11493,7 +11461,7 @@ lpfc_sli_abort_iocb(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, · 402 unmodified lines
1149311461 int i;
1149411462
1149511463 /* all I/Os are in process of being flushed */
11496− if (phba->hba_flag & HBA_FCP_IOQ_FLUSH)
11464+ if (phba->hba_flag & HBA_IOQ_FLUSH)
1149711465 return errcnt;
1149811466
1149911467 for (i = 1; i <= phba->sli.last_iotag; i++) {
@@ -11603,7 +11571,7 @@ lpfc_sli_abort_taskmgmt(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, · 103 unmodified lines
1160311571 spin_lock_irqsave(&phba->hbalock, iflags);
1160411572
1160511573 /* all I/Os are in process of being flushed */
11606− if (phba->hba_flag & HBA_FCP_IOQ_FLUSH) {
11574+ if (phba->hba_flag & HBA_IOQ_FLUSH) {
1160711575 spin_unlock_irqrestore(&phba->hbalock, iflags);
1160811576 return 0;
1160911577 }
@@ -11627,7 +11595,7 @@ lpfc_sli_abort_taskmgmt(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, · 17 unmodified lines
1162711595
1162811596 if (phba->sli_rev == LPFC_SLI_REV4) {
1162911597 pring_s4 =
11630− phba->sli4_hba.hdwq[iocbq->hba_wqidx].fcp_wq->pring;
11598+ phba->sli4_hba.hdwq[iocbq->hba_wqidx].io_wq->pring;
1163111599 if (!pring_s4) {
1163211600 spin_unlock(&lpfc_cmd->buf_lock);
1163311601 continue;
@@ -13336,8 +13304,13 @@ lpfc_sli4_sp_handle_abort_xri_wcqe(struct lpfc_hba *phba, · 1702 unmodified lines
1333613304 unsigned long iflags;
1333713305
1333813306 switch (cq->subtype) {
13339− case LPFC_FCP:
13340− lpfc_sli4_fcp_xri_aborted(phba, wcqe, cq->hdwq);
13307+ case LPFC_IO:
13308+ lpfc_sli4_io_xri_aborted(phba, wcqe, cq->hdwq);
13309+ if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
13310+ /* Notify aborted XRI for NVME work queue */
13311+ if (phba->nvmet_support)
13312+ lpfc_sli4_nvmet_xri_aborted(phba, wcqe);
13313+ }
1334113314 workposted = false;
1334213315 break;
1334313316 case LPFC_NVME_LS: /* NVME LS uses ELS resources */
@@ -13355,15 +13328,6 @@ lpfc_sli4_sp_handle_abort_xri_wcqe(struct lpfc_hba *phba, · 11 unmodified lines
1335513328 spin_unlock_irqrestore(&phba->hbalock, iflags);
1335613329 workposted = true;
1335713330 break;
13358− case LPFC_NVME:
13359− /* Notify aborted XRI for NVME work queue */
13360− if (phba->nvmet_support)
13361− lpfc_sli4_nvmet_xri_aborted(phba, wcqe);
13362− else
13363− lpfc_sli4_nvme_xri_aborted(phba, wcqe, cq->hdwq);
13364−
13365− workposted = false;
13366− break;
1336713331 default:
1336813332 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
1336913333 "0603 Invalid CQ subtype %d: "
@@ -13691,7 +13655,7 @@ __lpfc_sli4_sp_process_cq(struct lpfc_queue *cq) · 321 unmodified lines
1369113655 &delay);
1369213656 break;
1369313657 case LPFC_WCQ:
13694− if (cq->subtype == LPFC_FCP || cq->subtype == LPFC_NVME)
13658+ if (cq->subtype == LPFC_IO)
1369513659 workposted |= __lpfc_sli4_process_cq(phba, cq,
1369613660 lpfc_sli4_fp_handle_cqe,
1369713661 &delay);
@@ -14008,10 +13972,7 @@ lpfc_sli4_fp_handle_cqe(struct lpfc_hba *phba, struct lpfc_queue *cq, · 310 unmodified lines
1400813972 cq->CQ_wq++;
1400913973 /* Process the WQ complete event */
1401013974 phba->last_completion_time = jiffies;
14011− if ((cq->subtype == LPFC_FCP) || (cq->subtype == LPFC_NVME))
14012− lpfc_sli4_fp_handle_fcp_wcqe(phba, cq,
14013− (struct lpfc_wcqe_complete *)&wcqe);
14014− if (cq->subtype == LPFC_NVME_LS)
13975+ if (cq->subtype == LPFC_IO || cq->subtype == LPFC_NVME_LS)
1401513976 lpfc_sli4_fp_handle_fcp_wcqe(phba, cq,
1401613977 (struct lpfc_wcqe_complete *)&wcqe);
1401713978 break;
@@ -16918,6 +16879,8 @@ lpfc_fc_frame_check(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr) · 2900 unmodified lines
1691816879 struct fc_vft_header *fc_vft_hdr;
1691916880 uint32_t *header = (uint32_t *) fc_hdr;
1692016881
16882+#define FC_RCTL_MDS_DIAGS 0xF4
16883+
1692116884 switch (fc_hdr->fh_r_ctl) {
1692216885 case FC_RCTL_DD_UNCAT: /* uncategorized information */
1692316886 case FC_RCTL_DD_SOL_DATA: /* solicited data */
@@ -17445,7 +17408,6 @@ lpfc_sli4_seq_abort_rsp(struct lpfc_vport *vport, · 521 unmodified lines
1744517408 icmd->ulpContext = phba->sli4_hba.rpi_ids[ndlp->nlp_rpi];
1744617409 ctiocb->context1 = lpfc_nlp_get(ndlp);
1744717410
17448− ctiocb->iocb_cmpl = NULL;
1744917411 ctiocb->vport = phba->pport;
1745017412 ctiocb->iocb_cmpl = lpfc_sli4_seq_abort_rsp_cmpl;
1745117413 ctiocb->sli4_lxritag = NO_XRI;
@@ -17928,6 +17890,17 @@ lpfc_sli4_handle_received_buffer(struct lpfc_hba *phba, · 476 unmodified lines
1792817890 fcfi = bf_get(lpfc_rcqe_fcf_id,
1792917891 &dmabuf->cq_event.cqe.rcqe_cmpl);
1793017892
17893+ if (fc_hdr->fh_r_ctl == 0xF4 && fc_hdr->fh_type == 0xFF) {
17894+ vport = phba->pport;
17895+ lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
17896+ "2023 MDS Loopback %d bytes\n",
17897+ bf_get(lpfc_rcqe_length,
17898+ &dmabuf->cq_event.cqe.rcqe_cmpl));
17899+ /* Handle MDS Loopback frames */
17900+ lpfc_sli4_handle_mds_loopback(vport, dmabuf);
17901+ return;
17902+ }
17903+
1793117904 /* d_id this frame is directed to */
1793217905 did = sli4_did_from_fc_hdr(fc_hdr);
1793317906
@@ -18211,6 +18184,10 @@ __lpfc_sli4_free_rpi(struct lpfc_hba *phba, int rpi) · 277 unmodified lines
1821118184 if (test_and_clear_bit(rpi, phba->sli4_hba.rpi_bmask)) {
1821218185 phba->sli4_hba.rpi_count--;
1821318186 phba->sli4_hba.max_cfg_param.rpi_used--;
18187+ } else {
18188+ lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
18189+ "2016 rpi %x not inuse\n",
18190+ rpi);
1821418191 }
1821518192 }
1821618193
@@ -19461,7 +19438,7 @@ lpfc_drain_txq(struct lpfc_hba *phba) · 1244 unmodified lines
1946119438
1946219439 if (phba->link_flag & LS_MDS_LOOPBACK) {
1946319440 /* MDS WQE are posted only to first WQ*/
19464− wq = phba->sli4_hba.hdwq[0].fcp_wq;
19441+ wq = phba->sli4_hba.hdwq[0].io_wq;
1946519442 if (unlikely(!wq))
1946619443 return 0;
1946719444 pring = wq->pring;
@@ -19712,10 +19689,10 @@ lpfc_sli4_issue_wqe(struct lpfc_hba *phba, struct lpfc_sli4_hdw_queue *qp, · 244 unmodified lines
1971219689 /* NVME_FCREQ and NVME_ABTS requests */
1971319690 if (pwqe->iocb_flag & LPFC_IO_NVME) {
1971419691 /* Get the IO distribution (hba_wqidx) for WQ assignment. */
19715− wq = qp->nvme_wq;
19692+ wq = qp->io_wq;
1971619693 pring = wq->pring;
1971719694
19718− bf_set(wqe_cqid, &wqe->generic.wqe_com, qp->nvme_cq_map);
19695+ bf_set(wqe_cqid, &wqe->generic.wqe_com, qp->io_cq_map);
1971919696
1972019697 lpfc_qp_spin_lock_irqsave(&pring->ring_lock, iflags,
1972119698 qp, wq_access);
@@ -19732,7 +19709,7 @@ lpfc_sli4_issue_wqe(struct lpfc_hba *phba, struct lpfc_sli4_hdw_queue *qp, · 10 unmodified lines
1973219709 /* NVMET requests */
1973319710 if (pwqe->iocb_flag & LPFC_IO_NVMET) {
1973419711 /* Get the IO distribution (hba_wqidx) for WQ assignment. */
19735− wq = qp->nvme_wq;
19712+ wq = qp->io_wq;
1973619713 pring = wq->pring;
1973719714
1973819715 ctxp = pwqe->context2;
@@ -19743,7 +19720,7 @@ lpfc_sli4_issue_wqe(struct lpfc_hba *phba, struct lpfc_sli4_hdw_queue *qp, · 4 unmodified lines
1974319720 }
1974419721 bf_set(wqe_xri_tag, &pwqe->wqe.xmit_bls_rsp.wqe_com,
1974519722 pwqe->sli4_xritag);
19746− bf_set(wqe_cqid, &wqe->generic.wqe_com, qp->nvme_cq_map);
19723+ bf_set(wqe_cqid, &wqe->generic.wqe_com, qp->io_cq_map);
1974719724
1974819725 lpfc_qp_spin_lock_irqsave(&pring->ring_lock, iflags,
1974919726 qp, wq_access);
@@ -19790,9 +19767,7 @@ void lpfc_snapshot_mxp(struct lpfc_hba *phba, u32 hwqid) · 40 unmodified lines
1979019767 if (multixri_pool->stat_snapshot_taken == LPFC_MXP_SNAPSHOT_TAKEN) {
1979119768 pvt_pool = &qp->p_multixri_pool->pvt_pool;
1979219769 pbl_pool = &qp->p_multixri_pool->pbl_pool;
19793− txcmplq_cnt = qp->fcp_wq->pring->txcmplq_cnt;
19794− if (qp->nvme_wq)
19795− txcmplq_cnt += qp->nvme_wq->pring->txcmplq_cnt;
19770+ txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt;
1979619771
1979719772 multixri_pool->stat_pbl_count = pbl_pool->count;
1979819773 multixri_pool->stat_pvt_count = pvt_pool->count;
@@ -19862,12 +19837,9 @@ void lpfc_adjust_high_watermark(struct lpfc_hba *phba, u32 hwqid) · 63 unmodified lines
1986219837 watermark_max = xri_limit;
1986319838 watermark_min = xri_limit / 2;
1986419839
19865− txcmplq_cnt = qp->fcp_wq->pring->txcmplq_cnt;
19840+ txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt;
1986619841 abts_io_bufs = qp->abts_scsi_io_bufs;
19867− if (qp->nvme_wq) {
19868− txcmplq_cnt += qp->nvme_wq->pring->txcmplq_cnt;
19869− abts_io_bufs += qp->abts_nvme_io_bufs;
19870− }
19842+ abts_io_bufs += qp->abts_nvme_io_bufs;
1987119843
1987219844 new_watermark = txcmplq_cnt + abts_io_bufs;
1987319845 new_watermark = min(watermark_max, new_watermark);
@@ -20142,12 +20114,9 @@ void lpfc_release_io_buf(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_ncmd, · 268 unmodified lines
2014220114 pbl_pool = &qp->p_multixri_pool->pbl_pool;
2014320115 pvt_pool = &qp->p_multixri_pool->pvt_pool;
2014420116
20145− txcmplq_cnt = qp->fcp_wq->pring->txcmplq_cnt;
20117+ txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt;
2014620118 abts_io_bufs = qp->abts_scsi_io_bufs;
20147− if (qp->nvme_wq) {
20148− txcmplq_cnt += qp->nvme_wq->pring->txcmplq_cnt;
20149− abts_io_bufs += qp->abts_nvme_io_bufs;
20150− }
20119+ abts_io_bufs += qp->abts_nvme_io_bufs;
2015120120
2015220121 xri_owned = pvt_pool->count + txcmplq_cnt + abts_io_bufs;
2015320122 xri_limit = qp->p_multixri_pool->xri_limit;
@@ -20188,6 +20157,13 @@ void lpfc_release_io_buf(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_ncmd, · 34 unmodified lines
2018820157 spin_unlock_irqrestore(&qp->io_buf_list_put_lock,
2018920158 iflag);
2019020159 }
20160+
20161+ if (phba->cfg_xpsgl && !phba->nvmet_support &&
20162+ !list_empty(&lpfc_ncmd->dma_sgl_xtra_list))
20163+ lpfc_put_sgl_per_hdwq(phba, lpfc_ncmd);
20164+
20165+ if (!list_empty(&lpfc_ncmd->dma_cmd_rsp_list))
20166+ lpfc_put_cmd_rsp_buf_per_hdwq(phba, lpfc_ncmd);
2019120167 }
2019220168
2019320169 /**
@@ -20402,3 +20378,288 @@ struct lpfc_io_buf *lpfc_get_io_buf(struct lpfc_hba *phba, · 208 unmodified lines
2040220378
2040320379 return lpfc_cmd;
2040420380 }
20381+
20382+/**
20383+ * lpfc_get_sgl_per_hdwq - Get one SGL chunk from hdwq's pool
20384+ * @phba: The HBA for which this call is being executed.
20385+ * @lpfc_buf: IO buf structure to append the SGL chunk
20386+ *
20387+ * This routine gets one SGL chunk buffer from hdwq's SGL chunk pool,
20388+ * and will allocate an SGL chunk if the pool is empty.
20389+ *
20390+ * Return codes:
20391+ * NULL - Error
20392+ * Pointer to sli4_hybrid_sgl - Success
20393+ **/
20394+struct sli4_hybrid_sgl *
20395+lpfc_get_sgl_per_hdwq(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_buf)
20396+{
20397+ struct sli4_hybrid_sgl *list_entry = NULL;
20398+ struct sli4_hybrid_sgl *tmp = NULL;
20399+ struct sli4_hybrid_sgl *allocated_sgl = NULL;
20400+ struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq;
20401+ struct list_head *buf_list = &hdwq->sgl_list;
20402+
20403+ spin_lock_irq(&hdwq->hdwq_lock);
20404+
20405+ if (likely(!list_empty(buf_list))) {
20406+ /* break off 1 chunk from the sgl_list */
20407+ list_for_each_entry_safe(list_entry, tmp,
20408+ buf_list, list_node) {
20409+ list_move_tail(&list_entry->list_node,
20410+ &lpfc_buf->dma_sgl_xtra_list);
20411+ break;
20412+ }
20413+ } else {
20414+ /* allocate more */
20415+ spin_unlock_irq(&hdwq->hdwq_lock);
20416+ tmp = kmalloc_node(sizeof(*tmp), GFP_ATOMIC,
20417+ cpu_to_node(smp_processor_id()));
20418+ if (!tmp) {
20419+ lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
20420+ "8353 error kmalloc memory for HDWQ "
20421+ "%d %s\n",
20422+ lpfc_buf->hdwq_no, __func__);
20423+ return NULL;
20424+ }
20425+
20426+ tmp->dma_sgl = dma_pool_alloc(phba->lpfc_sg_dma_buf_pool,
20427+ GFP_ATOMIC, &tmp->dma_phys_sgl);
20428+ if (!tmp->dma_sgl) {
20429+ lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
20430+ "8354 error pool_alloc memory for HDWQ "
20431+ "%d %s\n",
20432+ lpfc_buf->hdwq_no, __func__);
20433+ kfree(tmp);
20434+ return NULL;
20435+ }
20436+
20437+ spin_lock_irq(&hdwq->hdwq_lock);
20438+ list_add_tail(&tmp->list_node, &lpfc_buf->dma_sgl_xtra_list);
20439+ }
20440+
20441+ allocated_sgl = list_last_entry(&lpfc_buf->dma_sgl_xtra_list,
20442+ struct sli4_hybrid_sgl,
20443+ list_node);
20444+
20445+ spin_unlock_irq(&hdwq->hdwq_lock);
20446+
20447+ return allocated_sgl;
20448+}
20449+
20450+/**
20451+ * lpfc_put_sgl_per_hdwq - Put one SGL chunk into hdwq pool
20452+ * @phba: The HBA for which this call is being executed.
20453+ * @lpfc_buf: IO buf structure with the SGL chunk
20454+ *
20455+ * This routine puts one SGL chunk buffer into hdwq's SGL chunk pool.
20456+ *
20457+ * Return codes:
20458+ * 0 - Success
20459+ * -EINVAL - Error
20460+ **/
20461+int
20462+lpfc_put_sgl_per_hdwq(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_buf)
20463+{
20464+ int rc = 0;
20465+ struct sli4_hybrid_sgl *list_entry = NULL;
20466+ struct sli4_hybrid_sgl *tmp = NULL;
20467+ struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq;
20468+ struct list_head *buf_list = &hdwq->sgl_list;
20469+
20470+ spin_lock_irq(&hdwq->hdwq_lock);
20471+
20472+ if (likely(!list_empty(&lpfc_buf->dma_sgl_xtra_list))) {
20473+ list_for_each_entry_safe(list_entry, tmp,
20474+ &lpfc_buf->dma_sgl_xtra_list,
20475+ list_node) {
20476+ list_move_tail(&list_entry->list_node,
20477+ buf_list);
20478+ }
20479+ } else {
20480+ rc = -EINVAL;
20481+ }
20482+
20483+ spin_unlock_irq(&hdwq->hdwq_lock);
20484+ return rc;
20485+}
20486+
20487+/**
20488+ * lpfc_free_sgl_per_hdwq - Free all SGL chunks of hdwq pool
20489+ * @phba: phba object
20490+ * @hdwq: hdwq to cleanup sgl buff resources on
20491+ *
20492+ * This routine frees all SGL chunks of hdwq SGL chunk pool.
20493+ *
20494+ * Return codes:
20495+ * None
20496+ **/
20497+void
20498+lpfc_free_sgl_per_hdwq(struct lpfc_hba *phba,
20499+ struct lpfc_sli4_hdw_queue *hdwq)
20500+{
20501+ struct list_head *buf_list = &hdwq->sgl_list;
20502+ struct sli4_hybrid_sgl *list_entry = NULL;
20503+ struct sli4_hybrid_sgl *tmp = NULL;
20504+
20505+ spin_lock_irq(&hdwq->hdwq_lock);
20506+
20507+ /* Free sgl pool */
20508+ list_for_each_entry_safe(list_entry, tmp,
20509+ buf_list, list_node) {
20510+ dma_pool_free(phba->lpfc_sg_dma_buf_pool,
20511+ list_entry->dma_sgl,
20512+ list_entry->dma_phys_sgl);
20513+ list_del(&list_entry->list_node);
20514+ kfree(list_entry);
20515+ }
20516+
20517+ spin_unlock_irq(&hdwq->hdwq_lock);
20518+}
20519+
20520+/**
20521+ * lpfc_get_cmd_rsp_buf_per_hdwq - Get one CMD/RSP buffer from hdwq
20522+ * @phba: The HBA for which this call is being executed.
20523+ * @lpfc_buf: IO buf structure to attach the CMD/RSP buffer
20524+ *
20525+ * This routine gets one CMD/RSP buffer from hdwq's CMD/RSP pool,
20526+ * and will allocate an CMD/RSP buffer if the pool is empty.
20527+ *
20528+ * Return codes:
20529+ * NULL - Error
20530+ * Pointer to fcp_cmd_rsp_buf - Success
20531+ **/
20532+struct fcp_cmd_rsp_buf *
20533+lpfc_get_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba,
20534+ struct lpfc_io_buf *lpfc_buf)
20535+{
20536+ struct fcp_cmd_rsp_buf *list_entry = NULL;
20537+ struct fcp_cmd_rsp_buf *tmp = NULL;
20538+ struct fcp_cmd_rsp_buf *allocated_buf = NULL;
20539+ struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq;
20540+ struct list_head *buf_list = &hdwq->cmd_rsp_buf_list;
20541+
20542+ spin_lock_irq(&hdwq->hdwq_lock);
20543+
20544+ if (likely(!list_empty(buf_list))) {
20545+ /* break off 1 chunk from the list */
20546+ list_for_each_entry_safe(list_entry, tmp,
20547+ buf_list,
20548+ list_node) {
20549+ list_move_tail(&list_entry->list_node,
20550+ &lpfc_buf->dma_cmd_rsp_list);
20551+ break;
20552+ }
20553+ } else {
20554+ /* allocate more */
20555+ spin_unlock_irq(&hdwq->hdwq_lock);
20556+ tmp = kmalloc_node(sizeof(*tmp), GFP_ATOMIC,
20557+ cpu_to_node(smp_processor_id()));
20558+ if (!tmp) {
20559+ lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
20560+ "8355 error kmalloc memory for HDWQ "
20561+ "%d %s\n",
20562+ lpfc_buf->hdwq_no, __func__);
20563+ return NULL;
20564+ }
20565+
20566+ tmp->fcp_cmnd = dma_pool_alloc(phba->lpfc_cmd_rsp_buf_pool,
20567+ GFP_ATOMIC,
20568+ &tmp->fcp_cmd_rsp_dma_handle);
20569+
20570+ if (!tmp->fcp_cmnd) {
20571+ lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
20572+ "8356 error pool_alloc memory for HDWQ "
20573+ "%d %s\n",
20574+ lpfc_buf->hdwq_no, __func__);
20575+ kfree(tmp);
20576+ return NULL;
20577+ }
20578+
20579+ tmp->fcp_rsp = (struct fcp_rsp *)((uint8_t *)tmp->fcp_cmnd +
20580+ sizeof(struct fcp_cmnd));
20581+
20582+ spin_lock_irq(&hdwq->hdwq_lock);
20583+ list_add_tail(&tmp->list_node, &lpfc_buf->dma_cmd_rsp_list);
20584+ }
20585+
20586+ allocated_buf = list_last_entry(&lpfc_buf->dma_cmd_rsp_list,
20587+ struct fcp_cmd_rsp_buf,
20588+ list_node);
20589+
20590+ spin_unlock_irq(&hdwq->hdwq_lock);
20591+
20592+ return allocated_buf;
20593+}
20594+
20595+/**
20596+ * lpfc_put_cmd_rsp_buf_per_hdwq - Put one CMD/RSP buffer into hdwq pool
20597+ * @phba: The HBA for which this call is being executed.
20598+ * @lpfc_buf: IO buf structure with the CMD/RSP buf
20599+ *
20600+ * This routine puts one CMD/RSP buffer into executing CPU's CMD/RSP pool.
20601+ *
20602+ * Return codes:
20603+ * 0 - Success
20604+ * -EINVAL - Error
20605+ **/
20606+int
20607+lpfc_put_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba,
20608+ struct lpfc_io_buf *lpfc_buf)
20609+{
20610+ int rc = 0;
20611+ struct fcp_cmd_rsp_buf *list_entry = NULL;
20612+ struct fcp_cmd_rsp_buf *tmp = NULL;
20613+ struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq;
20614+ struct list_head *buf_list = &hdwq->cmd_rsp_buf_list;
20615+
20616+ spin_lock_irq(&hdwq->hdwq_lock);
20617+
20618+ if (likely(!list_empty(&lpfc_buf->dma_cmd_rsp_list))) {
20619+ list_for_each_entry_safe(list_entry, tmp,
20620+ &lpfc_buf->dma_cmd_rsp_list,
20621+ list_node) {
20622+ list_move_tail(&list_entry->list_node,
20623+ buf_list);
20624+ }
20625+ } else {
20626+ rc = -EINVAL;
20627+ }
20628+
20629+ spin_unlock_irq(&hdwq->hdwq_lock);
20630+ return rc;
20631+}
20632+
20633+/**
20634+ * lpfc_free_cmd_rsp_buf_per_hdwq - Free all CMD/RSP chunks of hdwq pool
20635+ * @phba: phba object
20636+ * @hdwq: hdwq to cleanup cmd rsp buff resources on
20637+ *
20638+ * This routine frees all CMD/RSP buffers of hdwq's CMD/RSP buf pool.
20639+ *
20640+ * Return codes:
20641+ * None
20642+ **/
20643+void
20644+lpfc_free_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba,
20645+ struct lpfc_sli4_hdw_queue *hdwq)
20646+{
20647+ struct list_head *buf_list = &hdwq->cmd_rsp_buf_list;
20648+ struct fcp_cmd_rsp_buf *list_entry = NULL;
20649+ struct fcp_cmd_rsp_buf *tmp = NULL;
20650+
20651+ spin_lock_irq(&hdwq->hdwq_lock);
20652+
20653+ /* Free cmd_rsp buf pool */
20654+ list_for_each_entry_safe(list_entry, tmp,
20655+ buf_list,
20656+ list_node) {
20657+ dma_pool_free(phba->lpfc_cmd_rsp_buf_pool,
20658+ list_entry->fcp_cmnd,
20659+ list_entry->fcp_cmd_rsp_dma_handle);
20660+ list_del(&list_entry->list_node);
20661+ kfree(list_entry);
20662+ }
20663+
20664+ spin_unlock_irq(&hdwq->hdwq_lock);
20665+}
drivers/scsi/lpfc/lpfc_sli.h+10−1
@@ -365,9 +365,18 @@ struct lpfc_io_buf { · 364 unmodified lines
365365 /* Common fields */
366366 struct list_head list;
367367 void *data;
368+
368369 dma_addr_t dma_handle;
369370 dma_addr_t dma_phys_sgl;
370− struct sli4_sge *dma_sgl;
371+
372+ struct sli4_sge *dma_sgl; /* initial segment chunk */
373+
374+ /* linked list of extra sli4_hybrid_sge */
375+ struct list_head dma_sgl_xtra_list;
376+
377+ /* list head for fcp_cmd_rsp buf */
378+ struct list_head dma_cmd_rsp_list;
379+
371380 struct lpfc_iocbq cur_iocbq;
372381 struct lpfc_sli4_hdw_queue *hdwq;
373382 uint16_t hdwq_no;
drivers/scsi/lpfc/lpfc_sli4.h+30−20
@@ -49,9 +49,6 @@ · 48 unmodified lines
4949 #define LPFC_FCP_MQ_THRESHOLD_MAX 256
5050 #define LPFC_FCP_MQ_THRESHOLD_DEF 8
5151
52−/* Common buffer size to accomidate SCSI and NVME IO buffers */
53−#define LPFC_COMMON_IO_BUF_SZ 768
54−
5552 /*
5653 * Provide the default FCF Record attributes used by the driver
5754 * when nonFIP mode is configured and there is no other default
@@ -114,9 +111,8 @@ enum lpfc_sli4_queue_type { · 56 unmodified lines
114111 enum lpfc_sli4_queue_subtype {
115112 LPFC_NONE,
116113 LPFC_MBOX,
117− LPFC_FCP,
114+ LPFC_IO,
118115 LPFC_ELS,
119− LPFC_NVME,
120116 LPFC_NVMET,
121117 LPFC_NVME_LS,
122118 LPFC_USOL
@@ -646,22 +642,17 @@ struct lpfc_eq_intr_info { · 523 unmodified lines
646642 struct lpfc_sli4_hdw_queue {
647643 /* Pointers to the constructed SLI4 queues */
648644 struct lpfc_queue *hba_eq; /* Event queues for HBA */
649− struct lpfc_queue *fcp_cq; /* Fast-path FCP compl queue */
650− struct lpfc_queue *nvme_cq; /* Fast-path NVME compl queue */
651− struct lpfc_queue *fcp_wq; /* Fast-path FCP work queue */
652− struct lpfc_queue *nvme_wq; /* Fast-path NVME work queue */
653− uint16_t fcp_cq_map;
654− uint16_t nvme_cq_map;
645+ struct lpfc_queue *io_cq; /* Fast-path FCP & NVME compl queue */
646+ struct lpfc_queue *io_wq; /* Fast-path FCP & NVME work queue */
647+ uint16_t io_cq_map;
655648
656649 /* Keep track of IO buffers for this hardware queue */
657650 spinlock_t io_buf_list_get_lock; /* Common buf alloc list lock */
658651 struct list_head lpfc_io_buf_list_get;
659652 spinlock_t io_buf_list_put_lock; /* Common buf free list lock */
660653 struct list_head lpfc_io_buf_list_put;
661− spinlock_t abts_scsi_buf_list_lock; /* list of aborted SCSI IOs */
662− struct list_head lpfc_abts_scsi_buf_list;
663− spinlock_t abts_nvme_buf_list_lock; /* list of aborted NVME IOs */
664− struct list_head lpfc_abts_nvme_buf_list;
654+ spinlock_t abts_io_buf_list_lock; /* list of aborted IOs */
655+ struct list_head lpfc_abts_io_buf_list;
665656 uint32_t total_io_bufs;
666657 uint32_t get_io_bufs;
667658 uint32_t put_io_bufs;
@@ -685,6 +676,13 @@ struct lpfc_sli4_hdw_queue { · 17 unmodified lines
685676 uint32_t cpucheck_xmt_io[LPFC_CHECK_CPU_CNT];
686677 uint32_t cpucheck_cmpl_io[LPFC_CHECK_CPU_CNT];
687678 #endif
679+
680+ /* Per HDWQ pool resources */
681+ struct list_head sgl_list;
682+ struct list_head cmd_rsp_buf_list;
683+
684+ /* Lock for syncing Per HDWQ pool resources */
685+ spinlock_t hdwq_lock;
688686 };
689687
690688 #ifdef LPFC_HDWQ_LOCK_STAT
@@ -850,8 +848,8 @@ struct lpfc_sli4_hba { · 159 unmodified lines
850848 struct lpfc_queue **cq_lookup;
851849 struct list_head lpfc_els_sgl_list;
852850 struct list_head lpfc_abts_els_sgl_list;
853− spinlock_t abts_scsi_buf_list_lock; /* list of aborted SCSI IOs */
854− struct list_head lpfc_abts_scsi_buf_list;
851+ spinlock_t abts_io_buf_list_lock; /* list of aborted SCSI IOs */
852+ struct list_head lpfc_abts_io_buf_list;
855853 struct list_head lpfc_nvmet_sgl_list;
856854 spinlock_t abts_nvmet_buf_list_lock; /* list of aborted NVMET IOs */
857855 struct list_head lpfc_abts_nvmet_ctx_list;
@@ -1056,10 +1054,11 @@ int lpfc_sli4_resume_rpi(struct lpfc_nodelist *, · 198 unmodified lines
10561054 void (*)(struct lpfc_hba *, LPFC_MBOXQ_t *), void *);
10571055 void lpfc_sli4_fcp_xri_abort_event_proc(struct lpfc_hba *);
10581056 void lpfc_sli4_els_xri_abort_event_proc(struct lpfc_hba *);
1059−void lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *,
1060− struct sli4_wcqe_xri_aborted *, int);
10611057 void lpfc_sli4_nvme_xri_aborted(struct lpfc_hba *phba,
1062− struct sli4_wcqe_xri_aborted *axri, int idx);
1058+ struct sli4_wcqe_xri_aborted *axri,
1059+ struct lpfc_io_buf *lpfc_ncmd);
1060+void lpfc_sli4_io_xri_aborted(struct lpfc_hba *phba,
1061+ struct sli4_wcqe_xri_aborted *axri, int idx);
10631062 void lpfc_sli4_nvmet_xri_aborted(struct lpfc_hba *phba,
10641063 struct sli4_wcqe_xri_aborted *axri);
10651064 void lpfc_sli4_els_xri_aborted(struct lpfc_hba *,
@@ -1094,6 +1093,17 @@ int lpfc_sli4_post_status_check(struct lpfc_hba *); · 28 unmodified lines
10941093 uint8_t lpfc_sli_config_mbox_subsys_get(struct lpfc_hba *, LPFC_MBOXQ_t *);
10951094 uint8_t lpfc_sli_config_mbox_opcode_get(struct lpfc_hba *, LPFC_MBOXQ_t *);
10961095 void lpfc_sli4_ras_dma_free(struct lpfc_hba *phba);
1096+struct sli4_hybrid_sgl *lpfc_get_sgl_per_hdwq(struct lpfc_hba *phba,
1097+ struct lpfc_io_buf *buf);
1098+struct fcp_cmd_rsp_buf *lpfc_get_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba,
1099+ struct lpfc_io_buf *buf);
1100+int lpfc_put_sgl_per_hdwq(struct lpfc_hba *phba, struct lpfc_io_buf *buf);
1101+int lpfc_put_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba,
1102+ struct lpfc_io_buf *buf);
1103+void lpfc_free_sgl_per_hdwq(struct lpfc_hba *phba,
1104+ struct lpfc_sli4_hdw_queue *hdwq);
1105+void lpfc_free_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba,
1106+ struct lpfc_sli4_hdw_queue *hdwq);
10971107 static inline void *lpfc_sli4_qe(struct lpfc_queue *q, uint16_t idx)
10981108 {
10991109 return q->q_pgs[idx / q->entry_cnt_per_pg] +
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 "12.2.0.3"
23+#define LPFC_DRIVER_VERSION "12.4.0.0"
2424 #define LPFC_DRIVER_NAME "lpfc"
2525
2626 /* Used for SLI 2/3 */
drivers/scsi/lpfc/lpfc_vport.c+5−3
@@ -527,9 +527,11 @@ disable_vport(struct fc_vport *fc_vport) · 526 unmodified lines
527527 * scsi_host_put() to release the vport.
528528 */
529529 lpfc_mbx_unreg_vpi(vport);
530− spin_lock_irq(shost->host_lock);
531− vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI;
532− spin_unlock_irq(shost->host_lock);
530+ if (phba->sli_rev == LPFC_SLI_REV4) {
531+ spin_lock_irq(shost->host_lock);
532+ vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI;
533+ spin_unlock_irq(shost->host_lock);
534+ }
533535
534536 lpfc_vport_set_state(vport, FC_VPORT_DISABLED);
535537 lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT,
drivers/scsi/megaraid/megaraid_sas.h+1−0
@@ -2429,6 +2429,7 @@ struct megasas_instance { · 2428 unmodified lines
24292429 u8 adapter_type;
24302430 bool consistent_mask_64bit;
24312431 bool support_nvme_passthru;
2432+ bool enable_sdev_max_qd;
24322433 u8 task_abort_tmo;
24332434 u8 max_reset_tmo;
24342435 u8 snapdump_wait_time;
drivers/scsi/megaraid/megaraid_sas_base.c+91−21
@@ -109,6 +109,10 @@ int event_log_level = MFI_EVT_CLASS_CRITICAL; · 108 unmodified lines
109109 module_param(event_log_level, int, 0644);
110110 MODULE_PARM_DESC(event_log_level, "Asynchronous event logging level- range is: -2(CLASS_DEBUG) to 4(CLASS_DEAD), Default: 2(CLASS_CRITICAL)");
111111
112+unsigned int enable_sdev_max_qd;
113+module_param(enable_sdev_max_qd, int, 0444);
114+MODULE_PARM_DESC(enable_sdev_max_qd, "Enable sdev max qd as can_queue. Default: 0");
115+
112116 MODULE_LICENSE("GPL");
113117 MODULE_VERSION(MEGASAS_VERSION);
114118 MODULE_AUTHOR("megaraidlinux.pdl@broadcom.com");
@@ -1941,25 +1945,19 @@ megasas_set_nvme_device_properties(struct scsi_device *sdev, u32 max_io_size) · 1826 unmodified lines
19411945 blk_queue_virt_boundary(sdev->request_queue, mr_nvme_pg_size - 1);
19421946 }
19431947
1944−
19451948 /*
1946− * megasas_set_static_target_properties -
1947− * Device property set by driver are static and it is not required to be
1948− * updated after OCR.
1949− *
1950− * set io timeout
1951− * set device queue depth
1952− * set nvme device properties. see - megasas_set_nvme_device_properties
1949+ * megasas_set_fw_assisted_qd -
1950+ * set device queue depth to can_queue
1951+ * set device queue depth to fw assisted qd
19531952 *
19541953 * @sdev: scsi device
19551954 * @is_target_prop true, if fw provided target properties.
19561955 */
1957−static void megasas_set_static_target_properties(struct scsi_device *sdev,
1956+static void megasas_set_fw_assisted_qd(struct scsi_device *sdev,
19581957 bool is_target_prop)
19591958 {
19601959 u8 interface_type;
19611960 u32 device_qd = MEGASAS_DEFAULT_CMD_PER_LUN;
1962− u32 max_io_size_kb = MR_DEFAULT_NVME_MDTS_KB;
19631961 u32 tgt_device_qd;
19641962 struct megasas_instance *instance;
19651963 struct MR_PRIV_DEVICE *mr_device_priv_data;
@@ -1968,11 +1966,6 @@ static void megasas_set_static_target_properties(struct scsi_device *sdev, · 2 unmodified lines
19681966 mr_device_priv_data = sdev->hostdata;
19691967 interface_type = mr_device_priv_data->interface_type;
19701968
1971− /*
1972− * The RAID firmware may require extended timeouts.
1973− */
1974− blk_queue_rq_timeout(sdev->request_queue, scmd_timeout * HZ);
1975−
19761969 switch (interface_type) {
19771970 case SAS_PD:
19781971 device_qd = MEGASAS_SAS_QD;
@@ -1990,18 +1983,49 @@ static void megasas_set_static_target_properties(struct scsi_device *sdev, · 11 unmodified lines
19901983 if (tgt_device_qd &&
19911984 (tgt_device_qd <= instance->host->can_queue))
19921985 device_qd = tgt_device_qd;
1986+ }
19931987
1994− /* max_io_size_kb will be set to non zero for
1995− * nvme based vd and syspd.
1996− */
1988+ if (instance->enable_sdev_max_qd && interface_type != UNKNOWN_DRIVE)
1989+ device_qd = instance->host->can_queue;
1990+
1991+ scsi_change_queue_depth(sdev, device_qd);
1992+}
1993+
1994+/*
1995+ * megasas_set_static_target_properties -
1996+ * Device property set by driver are static and it is not required to be
1997+ * updated after OCR.
1998+ *
1999+ * set io timeout
2000+ * set device queue depth
2001+ * set nvme device properties. see - megasas_set_nvme_device_properties
2002+ *
2003+ * @sdev: scsi device
2004+ * @is_target_prop true, if fw provided target properties.
2005+ */
2006+static void megasas_set_static_target_properties(struct scsi_device *sdev,
2007+ bool is_target_prop)
2008+{
2009+ u32 max_io_size_kb = MR_DEFAULT_NVME_MDTS_KB;
2010+ struct megasas_instance *instance;
2011+
2012+ instance = megasas_lookup_instance(sdev->host->host_no);
2013+
2014+ /*
2015+ * The RAID firmware may require extended timeouts.
2016+ */
2017+ blk_queue_rq_timeout(sdev->request_queue, scmd_timeout * HZ);
2018+
2019+ /* max_io_size_kb will be set to non zero for
2020+ * nvme based vd and syspd.
2021+ */
2022+ if (is_target_prop)
19972023 max_io_size_kb = le32_to_cpu(instance->tgt_prop->max_io_size_kb);
1998− }
19992024
20002025 if (instance->nvme_page_size && max_io_size_kb)
20012026 megasas_set_nvme_device_properties(sdev, (max_io_size_kb << 10));
20022027
2003− scsi_change_queue_depth(sdev, device_qd);
2004−
2028+ megasas_set_fw_assisted_qd(sdev, is_target_prop);
20052029 }
20062030
20072031
@@ -3284,6 +3308,48 @@ fw_cmds_outstanding_show(struct device *cdev, · 1276 unmodified lines
32843308 return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&instance->fw_outstanding));
32853309 }
32863310
3311+static ssize_t
3312+enable_sdev_max_qd_show(struct device *cdev,
3313+ struct device_attribute *attr, char *buf)
3314+{
3315+ struct Scsi_Host *shost = class_to_shost(cdev);
3316+ struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata;
3317+
3318+ return snprintf(buf, PAGE_SIZE, "%d\n", instance->enable_sdev_max_qd);
3319+}
3320+
3321+static ssize_t
3322+enable_sdev_max_qd_store(struct device *cdev,
3323+ struct device_attribute *attr, const char *buf, size_t count)
3324+{
3325+ struct Scsi_Host *shost = class_to_shost(cdev);
3326+ struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata;
3327+ u32 val = 0;
3328+ bool is_target_prop;
3329+ int ret_target_prop = DCMD_FAILED;
3330+ struct scsi_device *sdev;
3331+
3332+ if (kstrtou32(buf, 0, &val) != 0) {
3333+ pr_err("megasas: could not set enable_sdev_max_qd\n");
3334+ return -EINVAL;
3335+ }
3336+
3337+ mutex_lock(&instance->reset_mutex);
3338+ if (val)
3339+ instance->enable_sdev_max_qd = true;
3340+ else
3341+ instance->enable_sdev_max_qd = false;
3342+
3343+ shost_for_each_device(sdev, shost) {
3344+ ret_target_prop = megasas_get_target_prop(instance, sdev);
3345+ is_target_prop = (ret_target_prop == DCMD_SUCCESS) ? true : false;
3346+ megasas_set_fw_assisted_qd(sdev, is_target_prop);
3347+ }
3348+ mutex_unlock(&instance->reset_mutex);
3349+
3350+ return strlen(buf);
3351+}
3352+
32873353 static ssize_t
32883354 dump_system_regs_show(struct device *cdev,
32893355 struct device_attribute *attr, char *buf)
@@ -3313,6 +3379,7 @@ static DEVICE_ATTR_RW(fw_crash_state); · 23 unmodified lines
33133379 static DEVICE_ATTR_RO(page_size);
33143380 static DEVICE_ATTR_RO(ldio_outstanding);
33153381 static DEVICE_ATTR_RO(fw_cmds_outstanding);
3382+static DEVICE_ATTR_RW(enable_sdev_max_qd);
33163383 static DEVICE_ATTR_RO(dump_system_regs);
33173384 static DEVICE_ATTR_RO(raid_map_id);
33183385
@@ -3323,6 +3390,7 @@ static struct device_attribute *megaraid_host_attrs[] = { · 4 unmodified lines
33233390 &dev_attr_page_size,
33243391 &dev_attr_ldio_outstanding,
33253392 &dev_attr_fw_cmds_outstanding,
3393+ &dev_attr_enable_sdev_max_qd,
33263394 &dev_attr_dump_system_regs,
33273395 &dev_attr_raid_map_id,
33283396 NULL,
@@ -5894,6 +5962,8 @@ static int megasas_init_fw(struct megasas_instance *instance) · 2565 unmodified lines
58945962 MR_MAX_RAID_MAP_SIZE_MASK);
58955963 }
58965964
5965+ instance->enable_sdev_max_qd = enable_sdev_max_qd;
5966+
58975967 switch (instance->adapter_type) {
58985968 case VENTURA_SERIES:
58995969 fusion->pcie_bw_limitation = true;
drivers/scsi/megaraid/megaraid_sas_fusion.c+14−15
@@ -323,9 +323,6 @@ megasas_fusion_update_can_queue(struct megasas_instance *instance, int fw_boot_c · 322 unmodified lines
323323 {
324324 u16 cur_max_fw_cmds = 0;
325325 u16 ldio_threshold = 0;
326− struct megasas_register_set __iomem *reg_set;
327−
328− reg_set = instance->reg_set;
329326
330327 /* ventura FW does not fill outbound_scratch_pad_2 with queue depth */
331328 if (instance->adapter_type < VENTURA_SERIES)
@@ -3511,7 +3508,7 @@ megasas_complete_r1_command(struct megasas_instance *instance, · 3179 unmodified lines
35113508 * @instance: Adapter soft state
35123509 * Completes all commands that is in reply descriptor queue
35133510 */
3514−int
3511+static int
35153512 complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex,
35163513 struct megasas_irq_context *irq_context)
35173514 {
@@ -3702,7 +3699,7 @@ static void megasas_enable_irq_poll(struct megasas_instance *instance) · 184 unmodified lines
37023699 * megasas_sync_irqs - Synchronizes all IRQs owned by adapter
37033700 * @instance: Adapter soft state
37043701 */
3705−void megasas_sync_irqs(unsigned long instance_addr)
3702+static void megasas_sync_irqs(unsigned long instance_addr)
37063703 {
37073704 u32 count, i;
37083705 struct megasas_instance *instance =
@@ -3760,7 +3757,7 @@ int megasas_irqpoll(struct irq_poll *irqpoll, int budget) · 51 unmodified lines
37603757 *
37613758 * Tasklet to complete cmds
37623759 */
3763−void
3760+static void
37643761 megasas_complete_cmd_dpc_fusion(unsigned long instance_addr)
37653762 {
37663763 struct megasas_instance *instance =
@@ -3780,7 +3777,7 @@ megasas_complete_cmd_dpc_fusion(unsigned long instance_addr) · 13 unmodified lines
37803777 /**
37813778 * megasas_isr_fusion - isr entry point
37823779 */
3783−irqreturn_t megasas_isr_fusion(int irq, void *devp)
3780+static irqreturn_t megasas_isr_fusion(int irq, void *devp)
37843781 {
37853782 struct megasas_irq_context *irq_context = devp;
37863783 struct megasas_instance *instance = irq_context->instance;
@@ -3816,7 +3813,7 @@ irqreturn_t megasas_isr_fusion(int irq, void *devp) · 29 unmodified lines
38163813 * mfi_cmd: megasas_cmd pointer
38173814 *
38183815 */
3819−void
3816+static void
38203817 build_mpt_mfi_pass_thru(struct megasas_instance *instance,
38213818 struct megasas_cmd *mfi_cmd)
38223819 {
@@ -3874,7 +3871,7 @@ build_mpt_mfi_pass_thru(struct megasas_instance *instance, · 51 unmodified lines
38743871 * @cmd: mfi cmd to build
38753872 *
38763873 */
3877−union MEGASAS_REQUEST_DESCRIPTOR_UNION *
3874+static union MEGASAS_REQUEST_DESCRIPTOR_UNION *
38783875 build_mpt_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd)
38793876 {
38803877 union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc = NULL;
@@ -3900,7 +3897,7 @@ build_mpt_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd) · 19 unmodified lines
39003897 * @cmd: mfi cmd pointer
39013898 *
39023899 */
3903−void
3900+static void
39043901 megasas_issue_dcmd_fusion(struct megasas_instance *instance,
39053902 struct megasas_cmd *cmd)
39063903 {
@@ -4096,8 +4093,9 @@ static inline void megasas_trigger_snap_dump(struct megasas_instance *instance) · 189 unmodified lines
40964093 }
40974094
40984095 /* This function waits for outstanding commands on fusion to complete */
4099−int megasas_wait_for_outstanding_fusion(struct megasas_instance *instance,
4100− int reason, int *convert)
4096+static int
4097+megasas_wait_for_outstanding_fusion(struct megasas_instance *instance,
4098+ int reason, int *convert)
41014099 {
41024100 int i, outstanding, retval = 0, hb_seconds_missed = 0;
41034101 u32 fw_state, abs_state;
@@ -4221,7 +4219,7 @@ void megasas_reset_reply_desc(struct megasas_instance *instance) · 117 unmodified lines
42214219 * megasas_refire_mgmt_cmd : Re-fire management commands
42224220 * @instance: Controller's soft instance
42234221 */
4224−void megasas_refire_mgmt_cmd(struct megasas_instance *instance)
4222+static void megasas_refire_mgmt_cmd(struct megasas_instance *instance)
42254223 {
42264224 int j;
42274225 struct megasas_cmd_fusion *cmd_fusion;
@@ -4747,7 +4745,8 @@ out: · 519 unmodified lines
47474745 }
47484746
47494747 /*SRIOV get other instance in cluster if any*/
4750−struct megasas_instance *megasas_get_peer_instance(struct megasas_instance *instance)
4748+static struct
4749+megasas_instance *megasas_get_peer_instance(struct megasas_instance *instance)
47514750 {
47524751 int i;
47534752
@@ -5053,7 +5052,7 @@ out: · 299 unmodified lines
50535052 }
50545053
50555054 /* Fusion Crash dump collection */
5056−void megasas_fusion_crash_dump(struct megasas_instance *instance)
5055+static void megasas_fusion_crash_dump(struct megasas_instance *instance)
50575056 {
50585057 u32 status_reg;
50595058 u8 partial_copy = 0;
drivers/scsi/mpt3sas/mpi/mpi2.h+3−2
@@ -9,7 +9,7 @@ · 8 unmodified lines
99 * scatter/gather formats.
1010 * Creation Date: June 21, 2006
1111 *
12− * mpi2.h Version: 02.00.53
12+ * mpi2.h Version: 02.00.54
1313 *
1414 * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25
1515 * prefix are for use only on MPI v2.5 products, and must not be used
@@ -121,6 +121,7 @@ · 105 unmodified lines
121121 * 08-15-18 02.00.52 Bumped MPI2_HEADER_VERSION_UNIT.
122122 * 08-28-18 02.00.53 Bumped MPI2_HEADER_VERSION_UNIT.
123123 * Added MPI2_IOCSTATUS_FAILURE
124+ * 12-17-18 02.00.54 Bumped MPI2_HEADER_VERSION_UNIT
124125 * --------------------------------------------------------------------------
125126 */
126127
@@ -161,7 +162,7 @@ · 34 unmodified lines
161162
162163
163164 /* Unit and Dev versioning for this MPI header set */
164−#define MPI2_HEADER_VERSION_UNIT (0x35)
165+#define MPI2_HEADER_VERSION_UNIT (0x36)
165166 #define MPI2_HEADER_VERSION_DEV (0x00)
166167 #define MPI2_HEADER_VERSION_UNIT_MASK (0xFF00)
167168 #define MPI2_HEADER_VERSION_UNIT_SHIFT (8)
drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h+8−2
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Title: MPI Configuration messages and pages
88 * Creation Date: November 10, 2006
99 *
10− * mpi2_cnfg.h Version: 02.00.46
10+ * mpi2_cnfg.h Version: 02.00.47
1111 *
1212 * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25
1313 * prefix are for use only on MPI v2.5 products, and must not be used
@@ -244,6 +244,11 @@ · 230 unmodified lines
244244 * Added DMDReport Delay Time defines to
245245 * PCIeIOUnitPage1
246246 * --------------------------------------------------------------------------
247+ * 08-02-18 02.00.44 Added Slotx2, Slotx4 to ManPage 7.
248+ * 08-15-18 02.00.45 Added ProductSpecific field at end of IOC Page 1
249+ * 08-28-18 02.00.46 Added NVMs Write Cache flag to IOUnitPage1
250+ * Added DMDReport Delay Time defines to PCIeIOUnitPage1
251+ * 12-17-18 02.00.47 Swap locations of Slotx2 and Slotx4 in ManPage 7.
247252 */
248253
249254 #ifndef MPI2_CNFG_H
@@ -810,7 +815,8 @@ typedef struct _MPI2_MANPAGE7_CONNECTOR_INFO { · 560 unmodified lines
810815 U8 Location; /*0x14 */
811816 U8 ReceptacleID; /*0x15 */
812817 U16 Slot; /*0x16 */
813− U32 Reserved2; /*0x18 */
818+ U16 Slotx2; /*0x18 */
819+ U16 Slotx4; /*0x1A */
814820 } MPI2_MANPAGE7_CONNECTOR_INFO,
815821 *PTR_MPI2_MANPAGE7_CONNECTOR_INFO,
816822 Mpi2ManPage7ConnectorInfo_t,
drivers/scsi/mpt3sas/mpi/mpi2_image.h+21−18
@@ -5,7 +5,7 @@ · 4 unmodified lines
55 * Name: mpi2_image.h
66 * Description: Contains definitions for firmware and other component images
77 * Creation Date: 04/02/2018
8− * Version: 02.06.03
8+ * Version: 02.06.04
99 *
1010 *
1111 * Version History
@@ -17,6 +17,8 @@ · 5 unmodified lines
1717 * 08-14-18 02.06.01 Corrected define for MPI26_IMAGE_HEADER_SIGNATURE0_MPI26
1818 * 08-28-18 02.06.02 Added MPI2_EXT_IMAGE_TYPE_RDE
1919 * 09-07-18 02.06.03 Added MPI26_EVENT_PCIE_TOPO_PI_16_LANES
20+ * 12-17-18 02.06.04 Addd MPI2_EXT_IMAGE_TYPE_PBLP
21+ * Shorten some defines to be compatible with DOS
2022 */
2123 #ifndef MPI2_IMAGE_H
2224 #define MPI2_IMAGE_H
@@ -200,17 +202,17 @@ typedef struct _MPI26_COMPONENT_IMAGE_HEADER { · 177 unmodified lines
200202 #define MPI26_IMAGE_HEADER_SIGNATURE0_MPI26 (0xEB000042)
201203
202204 /**** Definitions for Signature1 field ****/
203−#define MPI26_IMAGE_HEADER_SIGNATURE1_APPLICATION (0x20505041)
204−#define MPI26_IMAGE_HEADER_SIGNATURE1_CBB (0x20424243)
205−#define MPI26_IMAGE_HEADER_SIGNATURE1_MFG (0x2047464D)
206−#define MPI26_IMAGE_HEADER_SIGNATURE1_BIOS (0x534F4942)
207−#define MPI26_IMAGE_HEADER_SIGNATURE1_HIIM (0x4D494948)
208−#define MPI26_IMAGE_HEADER_SIGNATURE1_HIIA (0x41494948)
209−#define MPI26_IMAGE_HEADER_SIGNATURE1_CPLD (0x444C5043)
210−#define MPI26_IMAGE_HEADER_SIGNATURE1_SPD (0x20445053)
211−#define MPI26_IMAGE_HEADER_SIGNATURE1_NVDATA (0x5444564E)
212−#define MPI26_IMAGE_HEADER_SIGNATURE1_GAS_GAUGE (0x20534147)
213−#define MPI26_IMAGE_HEADER_SIGNATURE1_PBLP (0x50424C50)
205+#define MPI26_IMAGE_HEADER_SIG1_APPLICATION (0x20505041)
206+#define MPI26_IMAGE_HEADER_SIG1_CBB (0x20424243)
207+#define MPI26_IMAGE_HEADER_SIG1_MFG (0x2047464D)
208+#define MPI26_IMAGE_HEADER_SIG1_BIOS (0x534F4942)
209+#define MPI26_IMAGE_HEADER_SIG1_HIIM (0x4D494948)
210+#define MPI26_IMAGE_HEADER_SIG1_HIIA (0x41494948)
211+#define MPI26_IMAGE_HEADER_SIG1_CPLD (0x444C5043)
212+#define MPI26_IMAGE_HEADER_SIG1_SPD (0x20445053)
213+#define MPI26_IMAGE_HEADER_SIG1_NVDATA (0x5444564E)
214+#define MPI26_IMAGE_HEADER_SIG1_GAS_GAUGE (0x20534147)
215+#define MPI26_IMAGE_HEADER_SIG1_PBLP (0x504C4250)
214216
215217 /**** Definitions for Signature2 field ****/
216218 #define MPI26_IMAGE_HEADER_SIGNATURE2_VALUE (0x50584546)
@@ -278,6 +280,7 @@ typedef struct _MPI2_EXT_IMAGE_HEADER { · 61 unmodified lines
278280 #define MPI2_EXT_IMAGE_TYPE_MEGARAID (0x08)
279281 #define MPI2_EXT_IMAGE_TYPE_ENCRYPTED_HASH (0x09)
280282 #define MPI2_EXT_IMAGE_TYPE_RDE (0x0A)
283+#define MPI2_EXT_IMAGE_TYPE_PBLP (0x0B)
281284 #define MPI2_EXT_IMAGE_TYPE_MIN_PRODUCT_SPECIFIC (0x80)
282285 #define MPI2_EXT_IMAGE_TYPE_MAX_PRODUCT_SPECIFIC (0xFF)
283286
@@ -472,12 +475,12 @@ Mpi25EncryptedHashEntry_t, *pMpi25EncryptedHashEntry_t; · 188 unmodified lines
472475 #define MPI25_HASH_ALGORITHM_UNUSED (0x00)
473476 #define MPI25_HASH_ALGORITHM_SHA256 (0x01)
474477
475−#define MPI26_HASH_ALGORITHM_VERSION_MASK (0xE0)
476−#define MPI26_HASH_ALGORITHM_VERSION_NONE (0x00)
477−#define MPI26_HASH_ALGORITHM_VERSION_SHA1 (0x20)
478−#define MPI26_HASH_ALGORITHM_VERSION_SHA2 (0x40)
479−#define MPI26_HASH_ALGORITHM_VERSION_SHA3 (0x60)
480−#define MPI26_HASH_ALGORITHM_SIZE_MASK (0x1F)
478+#define MPI26_HASH_ALGORITHM_VER_MASK (0xE0)
479+#define MPI26_HASH_ALGORITHM_VER_NONE (0x00)
480+#define MPI26_HASH_ALGORITHM_VER_SHA1 (0x20)
481+#define MPI26_HASH_ALGORITHM_VER_SHA2 (0x40)
482+#define MPI26_HASH_ALGORITHM_VER_SHA3 (0x60)
483+#define MPI26_HASH_ALGORITHM_SIZE_MASK (0x1F)
481484 #define MPI26_HASH_ALGORITHM_SIZE_256 (0x01)
482485 #define MPI26_HASH_ALGORITHM_SIZE_512 (0x02)
483486
drivers/scsi/mpt3sas/mpi/mpi2_pci.h+7−6
@@ -6,7 +6,7 @@ · 5 unmodified lines
66 * Title: MPI PCIe Attached Devices structures and definitions.
77 * Creation Date: October 9, 2012
88 *
9− * mpi2_pci.h Version: 02.00.03
9+ * mpi2_pci.h Version: 02.00.04
1010 *
1111 * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25
1212 * prefix are for use only on MPI v2.5 products, and must not be used
@@ -24,6 +24,8 @@ · 11 unmodified lines
2424 * 07-01-16 02.00.02 Added MPI26_NVME_FLAGS_FORCE_ADMIN_ERR_RESP to
2525 * NVME Encapsulated Request.
2626 * 07-22-18 02.00.03 Updted flags field for NVME Encapsulated req
27+ * 12-17-18 02.00.04 Added MPI26_PCIE_DEVINFO_SCSI
28+ * Shortten some defines to be compatible with DOS
2729 * --------------------------------------------------------------------------
2830 */
2931
@@ -41,7 +43,7 @@ · 11 unmodified lines
4143 #define MPI26_PCIE_DEVINFO_NO_DEVICE (0x00000000)
4244 #define MPI26_PCIE_DEVINFO_PCI_SWITCH (0x00000001)
4345 #define MPI26_PCIE_DEVINFO_NVME (0x00000003)
44−
46+#define MPI26_PCIE_DEVINFO_SCSI (0x00000004)
4547
4648 /****************************************************************************
4749 * NVMe Encapsulated message
@@ -75,10 +77,9 @@ typedef struct _MPI26_NVME_ENCAPSULATED_REQUEST { · 27 unmodified lines
7577 #define MPI26_NVME_FLAGS_SUBMISSIONQ_IO (0x0000)
7678 #define MPI26_NVME_FLAGS_SUBMISSIONQ_ADMIN (0x0010)
7779 /*Error Response Address Space */
78−#define MPI26_NVME_FLAGS_MASK_ERROR_RSP_ADDR (0x000C)
79−#define MPI26_NVME_FLAGS_MASK_ERROR_RSP_ADDR_MASK (0x000C)
80−#define MPI26_NVME_FLAGS_SYSTEM_RSP_ADDR (0x0000)
81−#define MPI26_NVME_FLAGS_IOCCTL_RSP_ADDR (0x0008)
80+#define MPI26_NVME_FLAGS_ERR_RSP_ADDR_MASK (0x000C)
81+#define MPI26_NVME_FLAGS_ERR_RSP_ADDR_SYSTEM (0x0000)
82+#define MPI26_NVME_FLAGS_ERR_RSP_ADDR_IOCTL (0x0008)
8283 /* Data Direction*/
8384 #define MPI26_NVME_FLAGS_DATADIRECTION_MASK (0x0003)
8485 #define MPI26_NVME_FLAGS_NODATATRANSFER (0x0000)
drivers/scsi/mpt3sas/mpi/mpi2_tool.h+7−6
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 * Title: MPI diagnostic tool structures and definitions
88 * Creation Date: March 26, 2007
99 *
10− * mpi2_tool.h Version: 02.00.15
10+ * mpi2_tool.h Version: 02.00.16
1111 *
1212 * Version History
1313 * ---------------
@@ -40,6 +40,7 @@ · 26 unmodified lines
4040 * Tool Request Message.
4141 * 07-22-18 02.00.15 Added defines for new TOOLBOX_PCIE_LANE_MARGINING tool.
4242 * Added option for DeviceInfo field in ISTWI tool.
43+ * 12-17-18 02.00.16 Shorten some defines to be compatible with DOS.
4344 * --------------------------------------------------------------------------
4445 */
4546
@@ -230,11 +231,11 @@ typedef struct _MPI2_TOOLBOX_ISTWI_READ_WRITE_REQUEST { · 184 unmodified lines
230231 #define MPI2_TOOL_ISTWI_FLAG_PAGE_ADDR_MASK (0x07)
231232
232233 /*MPI26 TOOLBOX Request MsgFlags defines */
233−#define MPI26_TOOLBOX_REQ_MSGFLAGS_ADDRESSING_MASK (0x01)
234+#define MPI26_TOOL_ISTWI_MSGFLG_ADDR_MASK (0x01)
234235 /*Request uses Man Page 43 device index addressing */
235−#define MPI26_TOOLBOX_REQ_MSGFLAGS_ADDRESSING_DEVINDEX (0x00)
236+#define MPI26_TOOL_ISTWI_MSGFLG_ADDR_INDEX (0x00)
236237 /*Request uses Man Page 43 device info struct addressing */
237−#define MPI26_TOOLBOX_REQ_MSGFLAGS_ADDRESSING_DEVINFO (0x01)
238+#define MPI26_TOOL_ISTWI_MSGFLG_ADDR_INFO (0x01)
238239
239240 /*Toolbox ISTWI Read Write Tool reply message */
240241 typedef struct _MPI2_TOOLBOX_ISTWI_REPLY {
@@ -403,7 +404,7 @@ Mpi2ToolboxTextDisplayRequest_t, · 162 unmodified lines
403404 */
404405
405406 /*Toolbox Backend Lane Margining Tool request message */
406−typedef struct _MPI26_TOOLBOX_LANE_MARGINING_REQUEST {
407+typedef struct _MPI26_TOOLBOX_LANE_MARGIN_REQUEST {
407408 U8 Tool; /*0x00 */
408409 U8 Reserved1; /*0x01 */
409410 U8 ChainOffset; /*0x02 */
@@ -434,7 +435,7 @@ typedef struct _MPI26_TOOLBOX_LANE_MARGINING_REQUEST { · 24 unmodified lines
434435
435436
436437 /*Toolbox Backend Lane Margining Tool reply message */
437−typedef struct _MPI26_TOOLBOX_LANE_MARGINING_REPLY {
438+typedef struct _MPI26_TOOLBOX_LANE_MARGIN_REPLY {
438439 U8 Tool; /*0x00 */
439440 U8 Reserved1; /*0x01 */
440441 U8 MsgLength; /*0x02 */
drivers/scsi/mpt3sas/mpt3sas_base.c+162−13
@@ -2260,6 +2260,11 @@ base_is_prp_possible(struct MPT3SAS_ADAPTER *ioc, · 2259 unmodified lines
22602260 bool build_prp = true;
22612261
22622262 data_length = scsi_bufflen(scmd);
2263+ if (pcie_device &&
2264+ (mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info))) {
2265+ build_prp = false;
2266+ return build_prp;
2267+ }
22632268
22642269 /* If Datalenth is <= 16K and number of SGE’s entries are <= 2
22652270 * we built IEEE SGL
@@ -3178,6 +3183,37 @@ mpt3sas_base_unmap_resources(struct MPT3SAS_ADAPTER *ioc) · 912 unmodified lines
31783183 }
31793184 }
31803185
3186+static int
3187+_base_diag_reset(struct MPT3SAS_ADAPTER *ioc);
3188+
3189+/**
3190+ * _base_check_for_fault_and_issue_reset - check if IOC is in fault state
3191+ * and if it is in fault state then issue diag reset.
3192+ * @ioc: per adapter object
3193+ *
3194+ * Returns: 0 for success, non-zero for failure.
3195+ */
3196+static int
3197+_base_check_for_fault_and_issue_reset(struct MPT3SAS_ADAPTER *ioc)
3198+{
3199+ u32 ioc_state;
3200+ int rc = -EFAULT;
3201+
3202+ dinitprintk(ioc, pr_info("%s\n", __func__));
3203+ if (ioc->pci_error_recovery)
3204+ return 0;
3205+ ioc_state = mpt3sas_base_get_iocstate(ioc, 0);
3206+ dhsprintk(ioc, pr_info("%s: ioc_state(0x%08x)\n", __func__, ioc_state));
3207+
3208+ if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) {
3209+ mpt3sas_base_fault_info(ioc, ioc_state &
3210+ MPI2_DOORBELL_DATA_MASK);
3211+ rc = _base_diag_reset(ioc);
3212+ }
3213+
3214+ return rc;
3215+}
3216+
31813217 /**
31823218 * mpt3sas_base_map_resources - map in controller resources (io/irq/memap)
31833219 * @ioc: per adapter object
@@ -3190,7 +3226,7 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc) · 6 unmodified lines
31903226 struct pci_dev *pdev = ioc->pdev;
31913227 u32 memap_sz;
31923228 u32 pio_sz;
3193− int i, r = 0;
3229+ int i, r = 0, rc;
31943230 u64 pio_chip = 0;
31953231 phys_addr_t chip_phys = 0;
31963232 struct adapter_reply_queue *reply_q;
@@ -3251,8 +3287,11 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc) · 54 unmodified lines
32513287 _base_mask_interrupts(ioc);
32523288
32533289 r = _base_get_ioc_facts(ioc);
3254− if (r)
3255− goto out_fail;
3290+ if (r) {
3291+ rc = _base_check_for_fault_and_issue_reset(ioc);
3292+ if (rc || (_base_get_ioc_facts(ioc)))
3293+ goto out_fail;
3294+ }
32563295
32573296 if (!ioc->rdpq_array_enable_assigned) {
32583297 ioc->rdpq_array_enable = ioc->rdpq_array_capable;
@@ -5037,6 +5076,7 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc) · 1778 unmodified lines
50375076 _base_release_memory_pools(ioc);
50385077 goto retry_allocation;
50395078 }
5079+ memset(ioc->request, 0, sz);
50405080
50415081 if (retry_sz)
50425082 ioc_err(ioc, "request pool: dma_alloc_coherent succeed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), total(%d kb)\n",
@@ -5410,8 +5450,6 @@ _base_wait_on_iocstate(struct MPT3SAS_ADAPTER *ioc, u32 ioc_state, int timeout) · 367 unmodified lines
54105450 *
54115451 * Notes: MPI2_HIS_IOC2SYS_DB_STATUS - set to one when IOC writes to doorbell.
54125452 */
5413−static int
5414−_base_diag_reset(struct MPT3SAS_ADAPTER *ioc);
54155453
54165454 static int
54175455 _base_wait_for_doorbell_int(struct MPT3SAS_ADAPTER *ioc, int timeout)
@@ -5868,6 +5906,7 @@ mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc, · 450 unmodified lines
58685906 ioc->base_cmds.status = MPT3_CMD_PENDING;
58695907 request = mpt3sas_base_get_msg_frame(ioc, smid);
58705908 ioc->base_cmds.smid = smid;
5909+ memset(request, 0, ioc->request_sz);
58715910 memcpy(request, mpi_request, sizeof(Mpi2SepReply_t));
58725911 init_completion(&ioc->base_cmds.done);
58735912 ioc->put_smid_default(ioc, smid);
@@ -6686,7 +6725,7 @@ _base_make_ioc_ready(struct MPT3SAS_ADAPTER *ioc, enum reset_type type) · 812 unmodified lines
66866725 static int
66876726 _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc)
66886727 {
6689− int r, i, index;
6728+ int r, i, index, rc;
66906729 unsigned long flags;
66916730 u32 reply_address;
66926731 u16 smid;
@@ -6789,8 +6828,19 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc) · 96 unmodified lines
67896828 skip_init_reply_post_free_queue:
67906829
67916830 r = _base_send_ioc_init(ioc);
6792− if (r)
6793− return r;
6831+ if (r) {
6832+ /*
6833+ * No need to check IOC state for fault state & issue
6834+ * diag reset during host reset. This check is need
6835+ * only during driver load time.
6836+ */
6837+ if (!ioc->is_driver_loading)
6838+ return r;
6839+
6840+ rc = _base_check_for_fault_and_issue_reset(ioc);
6841+ if (rc || (_base_send_ioc_init(ioc)))
6842+ return r;
6843+ }
67946844
67956845 /* initialize reply free host index */
67966846 ioc->reply_free_host_index = ioc->reply_free_queue_depth - 1;
@@ -6882,7 +6932,7 @@ mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER *ioc) · 85 unmodified lines
68826932 int
68836933 mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
68846934 {
6885− int r, i;
6935+ int r, i, rc;
68866936 int cpu_id, last_cpu_id = 0;
68876937
68886938 dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
@@ -6926,8 +6976,11 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) · 37 unmodified lines
69266976
69276977 pci_set_drvdata(ioc->pdev, ioc->shost);
69286978 r = _base_get_ioc_facts(ioc);
6929− if (r)
6930− goto out_free_resources;
6979+ if (r) {
6980+ rc = _base_check_for_fault_and_issue_reset(ioc);
6981+ if (rc || (_base_get_ioc_facts(ioc)))
6982+ goto out_free_resources;
6983+ }
69316984
69326985 switch (ioc->hba_mpi_version_belonged) {
69336986 case MPI2_VERSION:
@@ -6995,8 +7048,11 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) · 61 unmodified lines
69957048
69967049 for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) {
69977050 r = _base_get_port_facts(ioc, i);
6998− if (r)
6999− goto out_free_resources;
7051+ if (r) {
7052+ rc = _base_check_for_fault_and_issue_reset(ioc);
7053+ if (rc || (_base_get_port_facts(ioc, i)))
7054+ goto out_free_resources;
7055+ }
70007056 }
70017057
70027058 r = _base_allocate_memory_pools(ioc);
@@ -7118,6 +7174,13 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) · 115 unmodified lines
71187174 if (r)
71197175 goto out_free_resources;
71207176
7177+ /*
7178+ * Copy current copy of IOCFacts in prev_fw_facts
7179+ * and it will be used during online firmware upgrade.
7180+ */
7181+ memcpy(&ioc->prev_fw_facts, &ioc->facts,
7182+ sizeof(struct mpt3sas_facts));
7183+
71217184 ioc->non_operational_loop = 0;
71227185 ioc->got_task_abort_from_ioctl = 0;
71237186 return 0;
@@ -7279,6 +7342,85 @@ mpt3sas_wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc) · 155 unmodified lines
72797342 wait_event_timeout(ioc->reset_wq, ioc->pending_io_count == 0, 10 * HZ);
72807343 }
72817344
7345+/**
7346+ * _base_check_ioc_facts_changes - Look for increase/decrease of IOCFacts
7347+ * attributes during online firmware upgrade and update the corresponding
7348+ * IOC variables accordingly.
7349+ *
7350+ * @ioc: Pointer to MPT_ADAPTER structure
7351+ */
7352+static int
7353+_base_check_ioc_facts_changes(struct MPT3SAS_ADAPTER *ioc)
7354+{
7355+ u16 pd_handles_sz;
7356+ void *pd_handles = NULL, *blocking_handles = NULL;
7357+ void *pend_os_device_add = NULL, *device_remove_in_progress = NULL;
7358+ struct mpt3sas_facts *old_facts = &ioc->prev_fw_facts;
7359+
7360+ if (ioc->facts.MaxDevHandle > old_facts->MaxDevHandle) {
7361+ pd_handles_sz = (ioc->facts.MaxDevHandle / 8);
7362+ if (ioc->facts.MaxDevHandle % 8)
7363+ pd_handles_sz++;
7364+
7365+ pd_handles = krealloc(ioc->pd_handles, pd_handles_sz,
7366+ GFP_KERNEL);
7367+ if (!pd_handles) {
7368+ ioc_info(ioc,
7369+ "Unable to allocate the memory for pd_handles of sz: %d\n",
7370+ pd_handles_sz);
7371+ return -ENOMEM;
7372+ }
7373+ memset(pd_handles + ioc->pd_handles_sz, 0,
7374+ (pd_handles_sz - ioc->pd_handles_sz));
7375+ ioc->pd_handles = pd_handles;
7376+
7377+ blocking_handles = krealloc(ioc->blocking_handles,
7378+ pd_handles_sz, GFP_KERNEL);
7379+ if (!blocking_handles) {
7380+ ioc_info(ioc,
7381+ "Unable to allocate the memory for "
7382+ "blocking_handles of sz: %d\n",
7383+ pd_handles_sz);
7384+ return -ENOMEM;
7385+ }
7386+ memset(blocking_handles + ioc->pd_handles_sz, 0,
7387+ (pd_handles_sz - ioc->pd_handles_sz));
7388+ ioc->blocking_handles = blocking_handles;
7389+ ioc->pd_handles_sz = pd_handles_sz;
7390+
7391+ pend_os_device_add = krealloc(ioc->pend_os_device_add,
7392+ pd_handles_sz, GFP_KERNEL);
7393+ if (!pend_os_device_add) {
7394+ ioc_info(ioc,
7395+ "Unable to allocate the memory for pend_os_device_add of sz: %d\n",
7396+ pd_handles_sz);
7397+ return -ENOMEM;
7398+ }
7399+ memset(pend_os_device_add + ioc->pend_os_device_add_sz, 0,
7400+ (pd_handles_sz - ioc->pend_os_device_add_sz));
7401+ ioc->pend_os_device_add = pend_os_device_add;
7402+ ioc->pend_os_device_add_sz = pd_handles_sz;
7403+
7404+ device_remove_in_progress = krealloc(
7405+ ioc->device_remove_in_progress, pd_handles_sz, GFP_KERNEL);
7406+ if (!device_remove_in_progress) {
7407+ ioc_info(ioc,
7408+ "Unable to allocate the memory for "
7409+ "device_remove_in_progress of sz: %d\n "
7410+ , pd_handles_sz);
7411+ return -ENOMEM;
7412+ }
7413+ memset(device_remove_in_progress +
7414+ ioc->device_remove_in_progress_sz, 0,
7415+ (pd_handles_sz - ioc->device_remove_in_progress_sz));
7416+ ioc->device_remove_in_progress = device_remove_in_progress;
7417+ ioc->device_remove_in_progress_sz = pd_handles_sz;
7418+ }
7419+
7420+ memcpy(&ioc->prev_fw_facts, &ioc->facts, sizeof(struct mpt3sas_facts));
7421+ return 0;
7422+}
7423+
72827424 /**
72837425 * mpt3sas_base_hard_reset_handler - reset controller
72847426 * @ioc: Pointer to MPT_ADAPTER structure
@@ -7342,6 +7484,13 @@ mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc, · 57 unmodified lines
73427484 if (r)
73437485 goto out;
73447486
7487+ r = _base_check_ioc_facts_changes(ioc);
7488+ if (r) {
7489+ ioc_info(ioc,
7490+ "Some of the parameters got changed in this new firmware"
7491+ " image and it requires system reboot\n");
7492+ goto out;
7493+ }
73457494 if (ioc->rdpq_array_enable && !ioc->rdpq_array_capable)
73467495 panic("%s: Issue occurred with flashing controller firmware."
73477496 "Please reboot the system and ensure that the correct"
drivers/scsi/mpt3sas/mpt3sas_base.h+28−2
@@ -76,8 +76,8 @@ · 75 unmodified lines
7676 #define MPT3SAS_DRIVER_NAME "mpt3sas"
7777 #define MPT3SAS_AUTHOR "Avago Technologies <MPT-FusionLinux.pdl@avagotech.com>"
7878 #define MPT3SAS_DESCRIPTION "LSI MPT Fusion SAS 3.0 Device Driver"
79−#define MPT3SAS_DRIVER_VERSION "29.100.00.00"
80−#define MPT3SAS_MAJOR_VERSION 29
79+#define MPT3SAS_DRIVER_VERSION "31.100.00.00"
80+#define MPT3SAS_MAJOR_VERSION 31
8181 #define MPT3SAS_MINOR_VERSION 100
8282 #define MPT3SAS_BUILD_VERSION 0
8383 #define MPT3SAS_RELEASE_VERSION 00
@@ -583,6 +583,7 @@ static inline void sas_device_put(struct _sas_device *s) · 499 unmodified lines
583583 * @enclosure_level: The level of device's enclosure from the controller
584584 * @connector_name: ASCII value of the Connector's name
585585 * @serial_number: pointer of serial number string allocated runtime
586+ * @access_status: Device's Access Status
586587 * @refcount: reference count for deletion
587588 */
588589 struct _pcie_device {
@@ -604,6 +605,7 @@ struct _pcie_device { · 15 unmodified lines
604605 u8 connector_name[4];
605606 u8 *serial_number;
606607 u8 reset_timeout;
608+ u8 access_status;
607609 struct kref refcount;
608610 };
609611 /**
@@ -1045,6 +1047,7 @@ typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct MPT3SAS_ADAPTER *ioc); · 435 unmodified lines
10451047 * @schedule_dead_ioc_flush_running_cmds: callback to flush pending commands
10461048 * @thresh_hold: Max number of reply descriptors processed
10471049 * before updating Host Index
1050+ * @drv_support_bitmap: driver's supported feature bit map
10481051 * @scsi_io_cb_idx: shost generated commands
10491052 * @tm_cb_idx: task management commands
10501053 * @scsih_cb_idx: scsih internal commands
@@ -1066,6 +1069,7 @@ typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct MPT3SAS_ADAPTER *ioc); · 15 unmodified lines
10661069 * @event_log: event log pointer
10671070 * @event_masks: events that are masked
10681071 * @facts: static facts data
1072+ * @prev_fw_facts: previous fw facts data
10691073 * @pfacts: static port facts data
10701074 * @manu_pg0: static manufacturing page 0
10711075 * @manu_pg10: static manufacturing page 10
@@ -1227,6 +1231,8 @@ struct MPT3SAS_ADAPTER { · 155 unmodified lines
12271231 bool msix_load_balance;
12281232 u16 thresh_hold;
12291233 u8 high_iops_queues;
1234+ u32 drv_support_bitmap;
1235+ bool enable_sdev_max_qd;
12301236
12311237 /* internal commands, callback index */
12321238 u8 scsi_io_cb_idx;
@@ -1276,6 +1282,7 @@ struct MPT3SAS_ADAPTER { · 43 unmodified lines
12761282
12771283 /* static config pages */
12781284 struct mpt3sas_facts facts;
1285+ struct mpt3sas_facts prev_fw_facts;
12791286 struct mpt3sas_port_facts *pfacts;
12801287 Mpi2ManufacturingPage0_t manu_pg0;
12811288 struct Mpi2ManufacturingPage10_t manu_pg10;
@@ -1450,6 +1457,8 @@ struct MPT3SAS_ADAPTER { · 168 unmodified lines
14501457 GET_MSIX_INDEX get_msix_index_for_smlio;
14511458 };
14521459
1460+#define MPT_DRV_SUPPORT_BITMAP_MEMMOVE 0x00000001
1461+
14531462 typedef u8 (*MPT_CALLBACK)(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
14541463 u32 reply);
14551464
@@ -1579,6 +1588,7 @@ struct _pcie_device *mpt3sas_get_pdev_by_handle(struct MPT3SAS_ADAPTER *ioc, · 123 unmodified lines
15791588 void mpt3sas_port_enable_complete(struct MPT3SAS_ADAPTER *ioc);
15801589 struct _raid_device *
15811590 mpt3sas_raid_device_find_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle);
1591+void mpt3sas_scsih_change_queue_depth(struct scsi_device *sdev, int qdepth);
15821592
15831593 /* config shared API */
15841594 u8 mpt3sas_config_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
@@ -1733,4 +1743,20 @@ mpt3sas_setup_direct_io(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd, · 148 unmodified lines
17331743 /* NCQ Prio Handling Check */
17341744 bool scsih_ncq_prio_supp(struct scsi_device *sdev);
17351745
1746+/**
1747+ * _scsih_is_pcie_scsi_device - determines if device is an pcie scsi device
1748+ * @device_info: bitfield providing information about the device.
1749+ * Context: none
1750+ *
1751+ * Returns 1 if scsi device.
1752+ */
1753+static inline int
1754+mpt3sas_scsih_is_pcie_scsi_device(u32 device_info)
1755+{
1756+ if ((device_info &
1757+ MPI26_PCIE_DEVINFO_MASK_DEVICE_TYPE) == MPI26_PCIE_DEVINFO_SCSI)
1758+ return 1;
1759+ else
1760+ return 0;
1761+}
17361762 #endif /* MPT3SAS_BASE_H_INCLUDED */
drivers/scsi/mpt3sas/mpt3sas_ctl.c+166−12
@@ -596,8 +596,16 @@ _ctl_set_task_mid(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command *karg, · 595 unmodified lines
596596 if (priv_data->sas_target->handle != handle)
597597 continue;
598598 st = scsi_cmd_priv(scmd);
599− tm_request->TaskMID = cpu_to_le16(st->smid);
600− found = 1;
599+
600+ /*
601+ * If the given TaskMID from the user space is zero, then the
602+ * first outstanding smid will be picked up. Otherwise,
603+ * targeted smid will be the one.
604+ */
605+ if (!tm_request->TaskMID || tm_request->TaskMID == st->smid) {
606+ tm_request->TaskMID = cpu_to_le16(st->smid);
607+ found = 1;
608+ }
601609 }
602610
603611 if (!found) {
@@ -654,7 +662,6 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg, · 50 unmodified lines
654662 size_t data_in_sz = 0;
655663 long ret;
656664 u16 device_handle = MPT3SAS_INVALID_DEVICE_HANDLE;
657− u8 tr_method = MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE;
658665
659666 issue_reset = 0;
660667
@@ -707,6 +714,7 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg, · 46 unmodified lines
707714 ioc->ctl_cmds.status = MPT3_CMD_PENDING;
708715 memset(ioc->ctl_cmds.reply, 0, ioc->reply_sz);
709716 request = mpt3sas_base_get_msg_frame(ioc, smid);
717+ memset(request, 0, ioc->request_sz);
710718 memcpy(request, mpi_request, karg.data_sge_offset*4);
711719 ioc->ctl_cmds.smid = smid;
712720 data_out_sz = karg.data_out_size;
@@ -921,13 +929,37 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg, · 208 unmodified lines
921929 Mpi2ToolboxCleanRequest_t *toolbox_request =
922930 (Mpi2ToolboxCleanRequest_t *)mpi_request;
923931
924− if (toolbox_request->Tool == MPI2_TOOLBOX_DIAGNOSTIC_CLI_TOOL) {
932+ if ((toolbox_request->Tool == MPI2_TOOLBOX_DIAGNOSTIC_CLI_TOOL)
933+ || (toolbox_request->Tool ==
934+ MPI26_TOOLBOX_BACKEND_PCIE_LANE_MARGIN))
925935 ioc->build_sg(ioc, psge, data_out_dma, data_out_sz,
926936 data_in_dma, data_in_sz);
927− } else {
937+ else if (toolbox_request->Tool ==
938+ MPI2_TOOLBOX_MEMORY_MOVE_TOOL) {
939+ Mpi2ToolboxMemMoveRequest_t *mem_move_request =
940+ (Mpi2ToolboxMemMoveRequest_t *)request;
941+ Mpi2SGESimple64_t tmp, *src = NULL, *dst = NULL;
942+
943+ ioc->build_sg_mpi(ioc, psge, data_out_dma,
944+ data_out_sz, data_in_dma, data_in_sz);
945+ if (data_out_sz && !data_in_sz) {
946+ dst =
947+ (Mpi2SGESimple64_t *)&mem_move_request->SGL;
948+ src = (void *)dst + ioc->sge_size;
949+
950+ memcpy(&tmp, src, ioc->sge_size);
951+ memcpy(src, dst, ioc->sge_size);
952+ memcpy(dst, &tmp, ioc->sge_size);
953+ }
954+ if (ioc->logging_level & MPT_DEBUG_TM) {
955+ ioc_info(ioc,
956+ "Mpi2ToolboxMemMoveRequest_t request msg\n");
957+ _debug_dump_mf(mem_move_request,
958+ ioc->request_sz/4);
959+ }
960+ } else
928961 ioc->build_sg_mpi(ioc, psge, data_out_dma, data_out_sz,
929− data_in_dma, data_in_sz);
930− }
962+ data_in_dma, data_in_sz);
931963 ioc->put_smid_default(ioc, smid);
932964 break;
933965 }
@@ -1047,12 +1079,14 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg, · 113 unmodified lines
10471079 mpt3sas_halt_firmware(ioc);
10481080 pcie_device = mpt3sas_get_pdev_by_handle(ioc,
10491081 le16_to_cpu(mpi_request->FunctionDependent1));
1050− if (pcie_device && (!ioc->tm_custom_handling))
1082+ if (pcie_device && (!ioc->tm_custom_handling) &&
1083+ (!(mpt3sas_scsih_is_pcie_scsi_device(
1084+ pcie_device->device_info))))
10511085 mpt3sas_scsih_issue_locked_tm(ioc,
10521086 le16_to_cpu(mpi_request->FunctionDependent1),
10531087 0, MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0,
10541088 0, pcie_device->reset_timeout,
1055− tr_method);
1089+ MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE);
10561090 else
10571091 mpt3sas_scsih_issue_locked_tm(ioc,
10581092 le16_to_cpu(mpi_request->FunctionDependent1),
@@ -3278,9 +3312,8 @@ diag_trigger_scsi_store(struct device *cdev, · 2219 unmodified lines
32783312 ssize_t sz;
32793313
32803314 spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
3281− sz = min(sizeof(struct SL_WH_SCSI_TRIGGERS_T), count);
3282− memset(&ioc->diag_trigger_scsi, 0,
3283− sizeof(struct SL_WH_EVENT_TRIGGERS_T));
3315+ sz = min(sizeof(ioc->diag_trigger_scsi), count);
3316+ memset(&ioc->diag_trigger_scsi, 0, sizeof(ioc->diag_trigger_scsi));
32843317 memcpy(&ioc->diag_trigger_scsi, buf, sz);
32853318 if (ioc->diag_trigger_scsi.ValidEntries > NUM_VALID_ENTRIES)
32863319 ioc->diag_trigger_scsi.ValidEntries = NUM_VALID_ENTRIES;
@@ -3349,6 +3382,125 @@ static DEVICE_ATTR_RW(diag_trigger_mpi); · 62 unmodified lines
33493382
33503383 /*****************************************/
33513384
3385+/**
3386+ * drv_support_bitmap_show - driver supported feature bitmap
3387+ * @cdev - pointer to embedded class device
3388+ * @buf - the buffer returned
3389+ *
3390+ * A sysfs 'read-only' shost attribute.
3391+ */
3392+static ssize_t
3393+drv_support_bitmap_show(struct device *cdev,
3394+ struct device_attribute *attr, char *buf)
3395+{
3396+ struct Scsi_Host *shost = class_to_shost(cdev);
3397+ struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
3398+
3399+ return snprintf(buf, PAGE_SIZE, "0x%08x\n", ioc->drv_support_bitmap);
3400+}
3401+static DEVICE_ATTR_RO(drv_support_bitmap);
3402+
3403+/**
3404+ * enable_sdev_max_qd_show - display whether sdev max qd is enabled/disabled
3405+ * @cdev - pointer to embedded class device
3406+ * @buf - the buffer returned
3407+ *
3408+ * A sysfs read/write shost attribute. This attribute is used to set the
3409+ * targets queue depth to HBA IO queue depth if this attribute is enabled.
3410+ */
3411+static ssize_t
3412+enable_sdev_max_qd_show(struct device *cdev,
3413+ struct device_attribute *attr, char *buf)
3414+{
3415+ struct Scsi_Host *shost = class_to_shost(cdev);
3416+ struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
3417+
3418+ return snprintf(buf, PAGE_SIZE, "%d\n", ioc->enable_sdev_max_qd);
3419+}
3420+
3421+/**
3422+ * enable_sdev_max_qd_store - Enable/disable sdev max qd
3423+ * @cdev - pointer to embedded class device
3424+ * @buf - the buffer returned
3425+ *
3426+ * A sysfs read/write shost attribute. This attribute is used to set the
3427+ * targets queue depth to HBA IO queue depth if this attribute is enabled.
3428+ * If this attribute is disabled then targets will have corresponding default
3429+ * queue depth.
3430+ */
3431+static ssize_t
3432+enable_sdev_max_qd_store(struct device *cdev,
3433+ struct device_attribute *attr, const char *buf, size_t count)
3434+{
3435+ struct Scsi_Host *shost = class_to_shost(cdev);
3436+ struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
3437+ struct MPT3SAS_DEVICE *sas_device_priv_data;
3438+ struct MPT3SAS_TARGET *sas_target_priv_data;
3439+ int val = 0;
3440+ struct scsi_device *sdev;
3441+ struct _raid_device *raid_device;
3442+ int qdepth;
3443+
3444+ if (kstrtoint(buf, 0, &val) != 0)
3445+ return -EINVAL;
3446+
3447+ switch (val) {
3448+ case 0:
3449+ ioc->enable_sdev_max_qd = 0;
3450+ shost_for_each_device(sdev, ioc->shost) {
3451+ sas_device_priv_data = sdev->hostdata;
3452+ if (!sas_device_priv_data)
3453+ continue;
3454+ sas_target_priv_data = sas_device_priv_data->sas_target;
3455+ if (!sas_target_priv_data)
3456+ continue;
3457+
3458+ if (sas_target_priv_data->flags &
3459+ MPT_TARGET_FLAGS_VOLUME) {
3460+ raid_device =
3461+ mpt3sas_raid_device_find_by_handle(ioc,
3462+ sas_target_priv_data->handle);
3463+
3464+ switch (raid_device->volume_type) {
3465+ case MPI2_RAID_VOL_TYPE_RAID0:
3466+ if (raid_device->device_info &
3467+ MPI2_SAS_DEVICE_INFO_SSP_TARGET)
3468+ qdepth =
3469+ MPT3SAS_SAS_QUEUE_DEPTH;
3470+ else
3471+ qdepth =
3472+ MPT3SAS_SATA_QUEUE_DEPTH;
3473+ break;
3474+ case MPI2_RAID_VOL_TYPE_RAID1E:
3475+ case MPI2_RAID_VOL_TYPE_RAID1:
3476+ case MPI2_RAID_VOL_TYPE_RAID10:
3477+ case MPI2_RAID_VOL_TYPE_UNKNOWN:
3478+ default:
3479+ qdepth = MPT3SAS_RAID_QUEUE_DEPTH;
3480+ }
3481+ } else if (sas_target_priv_data->flags &
3482+ MPT_TARGET_FLAGS_PCIE_DEVICE)
3483+ qdepth = MPT3SAS_NVME_QUEUE_DEPTH;
3484+ else
3485+ qdepth = MPT3SAS_SAS_QUEUE_DEPTH;
3486+
3487+ mpt3sas_scsih_change_queue_depth(sdev, qdepth);
3488+ }
3489+ break;
3490+ case 1:
3491+ ioc->enable_sdev_max_qd = 1;
3492+ shost_for_each_device(sdev, ioc->shost)
3493+ mpt3sas_scsih_change_queue_depth(sdev,
3494+ shost->can_queue);
3495+ break;
3496+ default:
3497+ return -EINVAL;
3498+ }
3499+
3500+ return strlen(buf);
3501+}
3502+static DEVICE_ATTR_RW(enable_sdev_max_qd);
3503+
33523504 struct device_attribute *mpt3sas_host_attrs[] = {
33533505 &dev_attr_version_fw,
33543506 &dev_attr_version_bios,
@@ -3374,7 +3526,9 @@ struct device_attribute *mpt3sas_host_attrs[] = { · 19 unmodified lines
33743526 &dev_attr_diag_trigger_event,
33753527 &dev_attr_diag_trigger_scsi,
33763528 &dev_attr_diag_trigger_mpi,
3529+ &dev_attr_drv_support_bitmap,
33773530 &dev_attr_BRM_status,
3531+ &dev_attr_enable_sdev_max_qd,
33783532 NULL,
33793533 };
33803534
drivers/scsi/mpt3sas/mpt3sas_scsih.c+141−55
@@ -155,6 +155,10 @@ static int prot_mask = -1; · 154 unmodified lines
155155 module_param(prot_mask, int, 0444);
156156 MODULE_PARM_DESC(prot_mask, " host protection capabilities mask, def=7 ");
157157
158+static bool enable_sdev_max_qd;
159+module_param(enable_sdev_max_qd, bool, 0444);
160+MODULE_PARM_DESC(enable_sdev_max_qd,
161+ "Enable sdev max qd as can_queue, def=disabled(0)");
158162
159163 /* raid transport support */
160164 static struct raid_template *mpt3sas_raid_template;
@@ -1152,6 +1156,11 @@ _scsih_pcie_device_add(struct MPT3SAS_ADAPTER *ioc, · 991 unmodified lines
11521156 list_add_tail(&pcie_device->list, &ioc->pcie_device_list);
11531157 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
11541158
1159+ if (pcie_device->access_status ==
1160+ MPI26_PCIEDEV0_ASTATUS_DEVICE_BLOCKED) {
1161+ clear_bit(pcie_device->handle, ioc->pend_os_device_add);
1162+ return;
1163+ }
11551164 if (scsi_add_device(ioc->shost, PCIE_CHANNEL, pcie_device->id, 0)) {
11561165 _scsih_pcie_device_remove(ioc, pcie_device);
11571166 } else if (!pcie_device->starget) {
@@ -1196,7 +1205,9 @@ _scsih_pcie_device_init_add(struct MPT3SAS_ADAPTER *ioc, · 38 unmodified lines
11961205 spin_lock_irqsave(&ioc->pcie_device_lock, flags);
11971206 pcie_device_get(pcie_device);
11981207 list_add_tail(&pcie_device->list, &ioc->pcie_device_init_list);
1199− _scsih_determine_boot_device(ioc, pcie_device, PCIE_CHANNEL);
1208+ if (pcie_device->access_status !=
1209+ MPI26_PCIEDEV0_ASTATUS_DEVICE_BLOCKED)
1210+ _scsih_determine_boot_device(ioc, pcie_device, PCIE_CHANNEL);
12001211 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
12011212 }
12021213 /**
@@ -1433,17 +1444,20 @@ _scsih_is_end_device(u32 device_info) · 230 unmodified lines
14331444 }
14341445
14351446 /**
1436− * _scsih_is_nvme_device - determines if device is an nvme device
1447+ * _scsih_is_nvme_pciescsi_device - determines if
1448+ * device is an pcie nvme/scsi device
14371449 * @device_info: bitfield providing information about the device.
14381450 * Context: none
14391451 *
1440− * Return: 1 if nvme device.
1452+ * Returns 1 if device is pcie device type nvme/scsi.
14411453 */
14421454 static int
1443−_scsih_is_nvme_device(u32 device_info)
1455+_scsih_is_nvme_pciescsi_device(u32 device_info)
14441456 {
1445− if ((device_info & MPI26_PCIE_DEVINFO_MASK_DEVICE_TYPE)
1446− == MPI26_PCIE_DEVINFO_NVME)
1457+ if (((device_info & MPI26_PCIE_DEVINFO_MASK_DEVICE_TYPE)
1458+ == MPI26_PCIE_DEVINFO_NVME) ||
1459+ ((device_info & MPI26_PCIE_DEVINFO_MASK_DEVICE_TYPE)
1460+ == MPI26_PCIE_DEVINFO_SCSI))
14471461 return 1;
14481462 else
14491463 return 0;
@@ -1509,7 +1523,13 @@ scsih_change_queue_depth(struct scsi_device *sdev, int qdepth) · 59 unmodified lines
15091523
15101524 max_depth = shost->can_queue;
15111525
1512− /* limit max device queue for SATA to 32 */
1526+ /*
1527+ * limit max device queue for SATA to 32 if enable_sdev_max_qd
1528+ * is disabled.
1529+ */
1530+ if (ioc->enable_sdev_max_qd)
1531+ goto not_sata;
1532+
15131533 sas_device_priv_data = sdev->hostdata;
15141534 if (!sas_device_priv_data)
15151535 goto not_sata;
@@ -1538,6 +1558,25 @@ scsih_change_queue_depth(struct scsi_device *sdev, int qdepth) · 22 unmodified lines
15381558 return scsi_change_queue_depth(sdev, qdepth);
15391559 }
15401560
1561+/**
1562+ * mpt3sas_scsih_change_queue_depth - setting device queue depth
1563+ * @sdev: scsi device struct
1564+ * @qdepth: requested queue depth
1565+ *
1566+ * Returns nothing.
1567+ */
1568+void
1569+mpt3sas_scsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
1570+{
1571+ struct Scsi_Host *shost = sdev->host;
1572+ struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
1573+
1574+ if (ioc->enable_sdev_max_qd)
1575+ qdepth = shost->can_queue;
1576+
1577+ scsih_change_queue_depth(sdev, qdepth);
1578+}
1579+
15411580 /**
15421581 * scsih_target_alloc - target add routine
15431582 * @starget: scsi target struct
@@ -2296,7 +2335,7 @@ scsih_slave_configure(struct scsi_device *sdev) · 752 unmodified lines
22962335 MPT3SAS_RAID_MAX_SECTORS);
22972336 }
22982337
2299− scsih_change_queue_depth(sdev, qdepth);
2338+ mpt3sas_scsih_change_queue_depth(sdev, qdepth);
23002339
23012340 /* raid transport support */
23022341 if (!ioc->is_warpdrive)
@@ -2360,7 +2399,7 @@ scsih_slave_configure(struct scsi_device *sdev) · 57 unmodified lines
23602399
23612400 pcie_device_put(pcie_device);
23622401 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
2363− scsih_change_queue_depth(sdev, qdepth);
2402+ mpt3sas_scsih_change_queue_depth(sdev, qdepth);
23642403 /* Enable QUEUE_FLAG_NOMERGES flag, so that IOs won't be
23652404 ** merged and can eliminate holes created during merging
23662405 ** operation.
@@ -2420,7 +2459,7 @@ scsih_slave_configure(struct scsi_device *sdev) · 53 unmodified lines
24202459 _scsih_display_sata_capabilities(ioc, handle, sdev);
24212460
24222461
2423− scsih_change_queue_depth(sdev, qdepth);
2462+ mpt3sas_scsih_change_queue_depth(sdev, qdepth);
24242463
24252464 if (ssp_target) {
24262465 sas_read_port_mode_page(sdev);
@@ -2872,7 +2911,8 @@ scsih_abort(struct scsi_cmnd *scmd) · 445 unmodified lines
28722911
28732912 handle = sas_device_priv_data->sas_target->handle;
28742913 pcie_device = mpt3sas_get_pdev_by_handle(ioc, handle);
2875− if (pcie_device && (!ioc->tm_custom_handling))
2914+ if (pcie_device && (!ioc->tm_custom_handling) &&
2915+ (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info))))
28762916 timeout = ioc->nvme_abort_timeout;
28772917 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->lun,
28782918 MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK,
@@ -2943,11 +2983,13 @@ scsih_dev_reset(struct scsi_cmnd *scmd) · 64 unmodified lines
29432983
29442984 pcie_device = mpt3sas_get_pdev_by_handle(ioc, handle);
29452985
2946− if (pcie_device && (!ioc->tm_custom_handling)) {
2986+ if (pcie_device && (!ioc->tm_custom_handling) &&
2987+ (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) {
29472988 tr_timeout = pcie_device->reset_timeout;
29482989 tr_method = MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE;
29492990 } else
29502991 tr_method = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET;
2992+
29512993 r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->lun,
29522994 MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, 0, 0,
29532995 tr_timeout, tr_method);
@@ -3020,7 +3062,8 @@ scsih_target_reset(struct scsi_cmnd *scmd) · 66 unmodified lines
30203062
30213063 pcie_device = mpt3sas_get_pdev_by_handle(ioc, handle);
30223064
3023− if (pcie_device && (!ioc->tm_custom_handling)) {
3065+ if (pcie_device && (!ioc->tm_custom_handling) &&
3066+ (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) {
30243067 tr_timeout = pcie_device->reset_timeout;
30253068 tr_method = MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE;
30263069 } else
@@ -3598,7 +3641,9 @@ _scsih_tm_tr_send(struct MPT3SAS_ADAPTER *ioc, u16 handle) · 571 unmodified lines
35983641 sas_address = pcie_device->wwid;
35993642 }
36003643 spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
3601− if (pcie_device && (!ioc->tm_custom_handling))
3644+ if (pcie_device && (!ioc->tm_custom_handling) &&
3645+ (!(mpt3sas_scsih_is_pcie_scsi_device(
3646+ pcie_device->device_info))))
36023647 tr_method =
36033648 MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE;
36043649 else
@@ -4654,11 +4699,8 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) · 1049 unmodified lines
46544699 * since we're lockless at this point
46554700 */
46564701 do {
4657− if (test_bit(0, &sas_device_priv_data->ata_command_pending)) {
4658− scmd->result = SAM_STAT_BUSY;
4659− scmd->scsi_done(scmd);
4660− return 0;
4661− }
4702+ if (test_bit(0, &sas_device_priv_data->ata_command_pending))
4703+ return SCSI_MLQUEUE_DEVICE_BUSY;
46624704 } while (_scsih_set_satl_pending(scmd, true));
46634705
46644706 if (scmd->sc_data_direction == DMA_FROM_DEVICE)
@@ -6456,24 +6498,17 @@ _scsih_sas_device_status_change_event_debug(struct MPT3SAS_ADAPTER *ioc, · 1791 unmodified lines
64566498 /**
64576499 * _scsih_sas_device_status_change_event - handle device status change
64586500 * @ioc: per adapter object
6459− * @fw_event: The fw_event_work object
6501+ * @event_data: The fw event
64606502 * Context: user.
64616503 */
64626504 static void
64636505 _scsih_sas_device_status_change_event(struct MPT3SAS_ADAPTER *ioc,
6464− struct fw_event_work *fw_event)
6506+ Mpi2EventDataSasDeviceStatusChange_t *event_data)
64656507 {
64666508 struct MPT3SAS_TARGET *target_priv_data;
64676509 struct _sas_device *sas_device;
64686510 u64 sas_address;
64696511 unsigned long flags;
6470− Mpi2EventDataSasDeviceStatusChange_t *event_data =
6471− (Mpi2EventDataSasDeviceStatusChange_t *)
6472− fw_event->event_data;
6473−
6474− if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
6475− _scsih_sas_device_status_change_event_debug(ioc,
6476− event_data);
64776512
64786513 /* In MPI Revision K (0xC), the internal device reset complete was
64796514 * implemented, so avoid setting tm_busy flag for older firmware.
@@ -6505,6 +6540,12 @@ _scsih_sas_device_status_change_event(struct MPT3SAS_ADAPTER *ioc, · 25 unmodified lines
65056540 else
65066541 target_priv_data->tm_busy = 0;
65076542
6543+ if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
6544+ ioc_info(ioc,
6545+ "%s tm_busy flag for handle(0x%04x)\n",
6546+ (target_priv_data->tm_busy == 1) ? "Enable" : "Disable",
6547+ target_priv_data->handle);
6548+
65086549 out:
65096550 if (sas_device)
65106551 sas_device_put(sas_device);
@@ -6539,6 +6580,11 @@ _scsih_check_pcie_access_status(struct MPT3SAS_ADAPTER *ioc, u64 wwid, · 28 unmodified lines
65396580 break;
65406581 case MPI26_PCIEDEV0_ASTATUS_DEVICE_BLOCKED:
65416582 desc = "PCIe device blocked";
6583+ ioc_info(ioc,
6584+ "Device with Access Status (%s): wwid(0x%016llx), "
6585+ "handle(0x%04x)\n ll only be added to the internal list",
6586+ desc, (u64)wwid, handle);
6587+ rc = 0;
65426588 break;
65436589 case MPI26_PCIEDEV0_ASTATUS_MEMORY_SPACE_ACCESS_FAILED:
65446590 desc = "PCIe device mem space access failed";
@@ -6643,7 +6689,8 @@ _scsih_pcie_device_remove_from_sml(struct MPT3SAS_ADAPTER *ioc, · 98 unmodified lines
66436689 pcie_device->enclosure_level,
66446690 pcie_device->connector_name);
66456691
6646− if (pcie_device->starget)
6692+ if (pcie_device->starget && (pcie_device->access_status !=
6693+ MPI26_PCIEDEV0_ASTATUS_DEVICE_BLOCKED))
66476694 scsi_remove_target(&pcie_device->starget->dev);
66486695 dewtprintk(ioc,
66496696 ioc_info(ioc, "%s: exit: handle(0x%04x), wwid(0x%016llx)\n",
@@ -6694,7 +6741,7 @@ _scsih_pcie_check_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) · 44 unmodified lines
66946741
66956742 /* check if this is end device */
66966743 device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo);
6697− if (!(_scsih_is_nvme_device(device_info)))
6744+ if (!(_scsih_is_nvme_pciescsi_device(device_info)))
66986745 return;
66996746
67006747 wwid = le64_to_cpu(pcie_device_pg0.WWID);
@@ -6709,6 +6756,7 @@ _scsih_pcie_check_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) · 8 unmodified lines
67096756 if (unlikely(pcie_device->handle != handle)) {
67106757 starget = pcie_device->starget;
67116758 sas_target_priv_data = starget->hostdata;
6759+ pcie_device->access_status = pcie_device_pg0.AccessStatus;
67126760 starget_printk(KERN_INFO, starget,
67136761 "handle changed from(0x%04x) to (0x%04x)!!!\n",
67146762 pcie_device->handle, handle);
@@ -6803,7 +6851,8 @@ _scsih_pcie_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) · 88 unmodified lines
68036851 pcie_device_pg0.AccessStatus))
68046852 return 0;
68056853
6806− if (!(_scsih_is_nvme_device(le32_to_cpu(pcie_device_pg0.DeviceInfo))))
6854+ if (!(_scsih_is_nvme_pciescsi_device(le32_to_cpu
6855+ (pcie_device_pg0.DeviceInfo))))
68076856 return 0;
68086857
68096858 pcie_device = mpt3sas_get_pdev_by_wwid(ioc, wwid);
@@ -6813,6 +6862,31 @@ _scsih_pcie_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) · 3 unmodified lines
68136862 return 0;
68146863 }
68156864
6865+ /* PCIe Device Page 2 contains read-only information about a
6866+ * specific NVMe device; therefore, this page is only
6867+ * valid for NVMe devices and skip for pcie devices of type scsi.
6868+ */
6869+ if (!(mpt3sas_scsih_is_pcie_scsi_device(
6870+ le32_to_cpu(pcie_device_pg0.DeviceInfo)))) {
6871+ if (mpt3sas_config_get_pcie_device_pg2(ioc, &mpi_reply,
6872+ &pcie_device_pg2, MPI2_SAS_DEVICE_PGAD_FORM_HANDLE,
6873+ handle)) {
6874+ ioc_err(ioc,
6875+ "failure at %s:%d/%s()!\n", __FILE__,
6876+ __LINE__, __func__);
6877+ return 0;
6878+ }
6879+
6880+ ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
6881+ MPI2_IOCSTATUS_MASK;
6882+ if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
6883+ ioc_err(ioc,
6884+ "failure at %s:%d/%s()!\n", __FILE__,
6885+ __LINE__, __func__);
6886+ return 0;
6887+ }
6888+ }
6889+
68166890 pcie_device = kzalloc(sizeof(struct _pcie_device), GFP_KERNEL);
68176891 if (!pcie_device) {
68186892 ioc_err(ioc, "failure at %s:%d/%s()!\n",
@@ -6824,6 +6898,7 @@ _scsih_pcie_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) · 5 unmodified lines
68246898 pcie_device->id = ioc->pcie_target_id++;
68256899 pcie_device->channel = PCIE_CHANNEL;
68266900 pcie_device->handle = handle;
6901+ pcie_device->access_status = pcie_device_pg0.AccessStatus;
68276902 pcie_device->device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo);
68286903 pcie_device->wwid = wwid;
68296904 pcie_device->port_num = pcie_device_pg0.PortNum;
@@ -6855,27 +6930,16 @@ _scsih_pcie_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) · 25 unmodified lines
68556930 le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID);
68566931 }
68576932 /* TODO -- Add device name once FW supports it */
6858− if (mpt3sas_config_get_pcie_device_pg2(ioc, &mpi_reply,
6859− &pcie_device_pg2, MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle)) {
6860− ioc_err(ioc, "failure at %s:%d/%s()!\n",
6861− __FILE__, __LINE__, __func__);
6862− kfree(pcie_device);
6863− return 0;
6864− }
6865−
6866− ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK;
6867− if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
6868− ioc_err(ioc, "failure at %s:%d/%s()!\n",
6869− __FILE__, __LINE__, __func__);
6870− kfree(pcie_device);
6871− return 0;
6872− }
6873− pcie_device->nvme_mdts =
6874− le32_to_cpu(pcie_device_pg2.MaximumDataTransferSize);
6875− if (pcie_device_pg2.ControllerResetTO)
6876− pcie_device->reset_timeout =
6877− pcie_device_pg2.ControllerResetTO;
6878− else
6933+ if (!(mpt3sas_scsih_is_pcie_scsi_device(
6934+ le32_to_cpu(pcie_device_pg0.DeviceInfo)))) {
6935+ pcie_device->nvme_mdts =
6936+ le32_to_cpu(pcie_device_pg2.MaximumDataTransferSize);
6937+ if (pcie_device_pg2.ControllerResetTO)
6938+ pcie_device->reset_timeout =
6939+ pcie_device_pg2.ControllerResetTO;
6940+ else
6941+ pcie_device->reset_timeout = 30;
6942+ } else
68796943 pcie_device->reset_timeout = 30;
68806944
68816945 if (ioc->wait_for_discovery_to_complete)
@@ -8507,6 +8571,8 @@ _scsih_mark_responding_pcie_device(struct MPT3SAS_ADAPTER *ioc, · 1625 unmodified lines
85078571 if ((pcie_device->wwid == le64_to_cpu(pcie_device_pg0->WWID))
85088572 && (pcie_device->slot == le16_to_cpu(
85098573 pcie_device_pg0->Slot))) {
8574+ pcie_device->access_status =
8575+ pcie_device_pg0->AccessStatus;
85108576 pcie_device->responding = 1;
85118577 starget = pcie_device->starget;
85128578 if (starget && starget->hostdata) {
@@ -8594,7 +8660,7 @@ _scsih_search_responding_pcie_devices(struct MPT3SAS_ADAPTER *ioc) · 81 unmodified lines
85948660 }
85958661 handle = le16_to_cpu(pcie_device_pg0.DevHandle);
85968662 device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo);
8597− if (!(_scsih_is_nvme_device(device_info)))
8663+ if (!(_scsih_is_nvme_pciescsi_device(device_info)))
85988664 continue;
85998665 _scsih_mark_responding_pcie_device(ioc, &pcie_device_pg0);
86008666 }
@@ -9175,7 +9241,7 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc) · 574 unmodified lines
91759241 break;
91769242 }
91779243 handle = le16_to_cpu(pcie_device_pg0.DevHandle);
9178− if (!(_scsih_is_nvme_device(
9244+ if (!(_scsih_is_nvme_pciescsi_device(
91799245 le32_to_cpu(pcie_device_pg0.DeviceInfo))))
91809246 continue;
91819247 pcie_device = mpt3sas_get_pdev_by_wwid(ioc,
@@ -9308,7 +9374,10 @@ _mpt3sas_fw_work(struct MPT3SAS_ADAPTER *ioc, struct fw_event_work *fw_event) · 126 unmodified lines
93089374 _scsih_sas_topology_change_event(ioc, fw_event);
93099375 break;
93109376 case MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE:
9311− _scsih_sas_device_status_change_event(ioc, fw_event);
9377+ if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
9378+ _scsih_sas_device_status_change_event_debug(ioc,
9379+ (Mpi2EventDataSasDeviceStatusChange_t *)
9380+ fw_event->event_data);
93129381 break;
93139382 case MPI2_EVENT_SAS_DISCOVERY:
93149383 _scsih_sas_discovery_event(ioc, fw_event);
@@ -9481,6 +9550,10 @@ mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index, · 166 unmodified lines
94819550 break;
94829551 }
94839552 case MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE:
9553+ _scsih_sas_device_status_change_event(ioc,
9554+ (Mpi2EventDataSasDeviceStatusChange_t *)
9555+ mpi_reply->EventData);
9556+ break;
94849557 case MPI2_EVENT_IR_OPERATION_STATUS:
94859558 case MPI2_EVENT_SAS_DISCOVERY:
94869559 case MPI2_EVENT_SAS_DEVICE_DISCOVERY_ERROR:
@@ -10039,6 +10112,12 @@ _scsih_probe_pcie(struct MPT3SAS_ADAPTER *ioc) · 552 unmodified lines
1003910112 pcie_device_put(pcie_device);
1004010113 continue;
1004110114 }
10115+ if (pcie_device->access_status ==
10116+ MPI26_PCIEDEV0_ASTATUS_DEVICE_BLOCKED) {
10117+ pcie_device_make_active(ioc, pcie_device);
10118+ pcie_device_put(pcie_device);
10119+ continue;
10120+ }
1004210121 rc = scsi_add_device(ioc->shost, PCIE_CHANNEL,
1004310122 pcie_device->id, 0);
1004410123 if (rc) {
@@ -10453,6 +10532,13 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 408 unmodified lines
1045310532 ioc->tm_sas_control_cb_idx = tm_sas_control_cb_idx;
1045410533 ioc->logging_level = logging_level;
1045510534 ioc->schedule_dead_ioc_flush_running_cmds = &_scsih_flush_running_cmds;
10535+ /*
10536+ * Enable MEMORY MOVE support flag.
10537+ */
10538+ ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_MEMMOVE;
10539+
10540+ ioc->enable_sdev_max_qd = enable_sdev_max_qd;
10541+
1045610542 /* misc semaphores and spin locks */
1045710543 mutex_init(&ioc->reset_in_progress_mutex);
1045810544 /* initializing pci_access_mutex lock */
drivers/scsi/ncr53c8xx.c+4−0
@@ -3910,11 +3910,14 @@ static void __init ncr_prepare_setting(struct ncb *np) · 3909 unmodified lines
39103910 np->scsi_mode = SMODE_HVD;
39113911 break;
39123912 }
3913+ /* fall through */
39133914 case 3: /* SYMBIOS controllers report HVD through GPIO3 */
39143915 if (INB(nc_gpreg) & 0x08)
39153916 break;
3917+ /* fall through */
39163918 case 2: /* Set HVD unconditionally */
39173919 np->scsi_mode = SMODE_HVD;
3920+ /* fall through */
39183921 case 1: /* Trust previous settings for HVD */
39193922 if (np->sv_stest2 & 0x20)
39203923 np->scsi_mode = SMODE_HVD;
@@ -6714,6 +6717,7 @@ void ncr_int_sir (struct ncb *np) · 2793 unmodified lines
67146717 OUTL_DSP (scr_to_cpu(tp->lp[0]->jump_ccb[0]));
67156718 return;
67166719 }
6720+ /* fall through */
67176721 case SIR_RESEL_BAD_TARGET: /* Will send a TARGET RESET message */
67186722 case SIR_RESEL_BAD_LUN: /* Will send a TARGET RESET message */
67196723 case SIR_RESEL_BAD_I_T_L_Q: /* Will send an ABORT TAG message */
drivers/scsi/pm8001/pm8001_sas.c+3−10
@@ -1308,28 +1308,22 @@ out: · 1307 unmodified lines
13081308
13091309 int pm8001_abort_task_set(struct domain_device *dev, u8 *lun)
13101310 {
1311− int rc = TMF_RESP_FUNC_FAILED;
13121311 struct pm8001_tmf_task tmf_task;
13131312
13141313 tmf_task.tmf = TMF_ABORT_TASK_SET;
1315− rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
1316− return rc;
1314+ return pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
13171315 }
13181316
13191317 int pm8001_clear_aca(struct domain_device *dev, u8 *lun)
13201318 {
1321− int rc = TMF_RESP_FUNC_FAILED;
13221319 struct pm8001_tmf_task tmf_task;
13231320
13241321 tmf_task.tmf = TMF_CLEAR_ACA;
1325− rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
1326−
1327− return rc;
1322+ return pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
13281323 }
13291324
13301325 int pm8001_clear_task_set(struct domain_device *dev, u8 *lun)
13311326 {
1332− int rc = TMF_RESP_FUNC_FAILED;
13331327 struct pm8001_tmf_task tmf_task;
13341328 struct pm8001_device *pm8001_dev = dev->lldd_dev;
13351329 struct pm8001_hba_info *pm8001_ha = pm8001_find_ha_by_dev(dev);
@@ -1338,7 +1332,6 @@ int pm8001_clear_task_set(struct domain_device *dev, u8 *lun) · 2 unmodified lines
13381332 pm8001_printk("I_T_L_Q clear task set[%x]\n",
13391333 pm8001_dev->device_id));
13401334 tmf_task.tmf = TMF_CLEAR_TASK_SET;
1341− rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
1342− return rc;
1335+ return pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
13431336 }
13441337
drivers/scsi/pmcraid.c+1−1
@@ -5841,7 +5841,7 @@ out_disable_device: · 5840 unmodified lines
58415841 }
58425842
58435843 /*
5844− * PCI driver structure of pcmraid driver
5844+ * PCI driver structure of pmcraid driver
58455845 */
58465846 static struct pci_driver pmcraid_driver = {
58475847 .name = PMCRAID_DRIVER_NAME,
drivers/scsi/qedf/qedf.h+1−0
@@ -49,6 +49,7 @@ · 48 unmodified lines
4949 #define QEDF_ABORT_TIMEOUT (10 * 1000)
5050 #define QEDF_CLEANUP_TIMEOUT 1
5151 #define QEDF_MAX_CDB_LEN 16
52+#define QEDF_LL2_BUF_SIZE 2500 /* Buffer size required for LL2 Rx */
5253
5354 #define UPSTREAM_REMOVE 1
5455 #define UPSTREAM_KEEP 1
drivers/scsi/qedf/qedf_debugfs.c+8−8
@@ -47,13 +47,13 @@ qedf_dbg_host_init(struct qedf_dbg_ctx *qedf, · 46 unmodified lines
4747 * @pf: the pf that is stopping
4848 **/
4949 void
50−qedf_dbg_host_exit(struct qedf_dbg_ctx *qedf)
50+qedf_dbg_host_exit(struct qedf_dbg_ctx *qedf_dbg)
5151 {
52− QEDF_INFO(qedf, QEDF_LOG_DEBUGFS, "Destroying debugfs host "
52+ QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "Destroying debugfs host "
5353 "entry\n");
5454 /* remove debugfs entries of this PF */
55− debugfs_remove_recursive(qedf->bdf_dentry);
56− qedf->bdf_dentry = NULL;
55+ debugfs_remove_recursive(qedf_dbg->bdf_dentry);
56+ qedf_dbg->bdf_dentry = NULL;
5757 }
5858
5959 /**
@@ -140,10 +140,10 @@ qedf_dbg_debug_cmd_read(struct file *filp, char __user *buffer, size_t count, · 80 unmodified lines
140140 loff_t *ppos)
141141 {
142142 int cnt;
143− struct qedf_dbg_ctx *qedf =
143+ struct qedf_dbg_ctx *qedf_dbg =
144144 (struct qedf_dbg_ctx *)filp->private_data;
145145
146− QEDF_INFO(qedf, QEDF_LOG_DEBUGFS, "entered\n");
146+ QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "debug mask=0x%x\n", qedf_debug);
147147 cnt = sprintf(buffer, "debug mask = 0x%x\n", qedf_debug);
148148
149149 cnt = min_t(int, count, cnt - *ppos);
@@ -158,7 +158,7 @@ qedf_dbg_debug_cmd_write(struct file *filp, const char __user *buffer, · 8 unmodified lines
158158 uint32_t val;
159159 void *kern_buf;
160160 int rval;
161− struct qedf_dbg_ctx *qedf =
161+ struct qedf_dbg_ctx *qedf_dbg =
162162 (struct qedf_dbg_ctx *)filp->private_data;
163163
164164 if (!count || *ppos)
@@ -178,7 +178,7 @@ qedf_dbg_debug_cmd_write(struct file *filp, const char __user *buffer, · 13 unmodified lines
178178 else
179179 qedf_debug = val;
180180
181− QEDF_INFO(qedf, QEDF_LOG_DEBUGFS, "Setting debug=0x%x.\n", val);
181+ QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "Setting debug=0x%x.\n", val);
182182 return count;
183183 }
184184
drivers/scsi/qedf/qedf_els.c+30−8
@@ -179,8 +179,11 @@ static void qedf_rrq_compl(struct qedf_els_cb_arg *cb_arg) · 178 unmodified lines
179179
180180 orig_io_req = cb_arg->aborted_io_req;
181181
182− if (!orig_io_req)
182+ if (!orig_io_req) {
183+ QEDF_ERR(&qedf->dbg_ctx,
184+ "Original io_req is NULL, rrq_req = %p.\n", rrq_req);
183185 goto out_free;
186+ }
184187
185188 if (rrq_req->event != QEDF_IOREQ_EV_ELS_TMO &&
186189 rrq_req->event != QEDF_IOREQ_EV_ELS_ERR_DETECT)
@@ -350,8 +353,10 @@ void qedf_restart_rport(struct qedf_rport *fcport) · 163 unmodified lines
350353 u32 port_id;
351354 unsigned long flags;
352355
353− if (!fcport)
356+ if (!fcport) {
357+ QEDF_ERR(NULL, "fcport is NULL.\n");
354358 return;
359+ }
355360
356361 spin_lock_irqsave(&fcport->rport_lock, flags);
357362 if (test_bit(QEDF_RPORT_IN_RESET, &fcport->flags) ||
@@ -418,8 +423,11 @@ static void qedf_l2_els_compl(struct qedf_els_cb_arg *cb_arg) · 60 unmodified lines
418423 * If we are flushing the command just free the cb_arg as none of the
419424 * response data will be valid.
420425 */
421− if (els_req->event == QEDF_IOREQ_EV_ELS_FLUSH)
426+ if (els_req->event == QEDF_IOREQ_EV_ELS_FLUSH) {
427+ QEDF_ERR(NULL, "els_req xid=0x%x event is flush.\n",
428+ els_req->xid);
422429 goto free_arg;
430+ }
423431
424432 fcport = els_req->fcport;
425433 mp_req = &(els_req->mp_req);
@@ -532,8 +540,10 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg) · 106 unmodified lines
532540
533541 orig_io_req = cb_arg->aborted_io_req;
534542
535− if (!orig_io_req)
543+ if (!orig_io_req) {
544+ QEDF_ERR(NULL, "orig_io_req is NULL.\n");
536545 goto out_free;
546+ }
537547
538548 clear_bit(QEDF_CMD_SRR_SENT, &orig_io_req->flags);
539549
@@ -547,8 +557,11 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg) · 7 unmodified lines
547557 orig_io_req, orig_io_req->xid, srr_req->xid, refcount);
548558
549559 /* If a SRR times out, simply free resources */
550− if (srr_req->event == QEDF_IOREQ_EV_ELS_TMO)
560+ if (srr_req->event == QEDF_IOREQ_EV_ELS_TMO) {
561+ QEDF_ERR(&qedf->dbg_ctx,
562+ "ELS timeout rec_xid=0x%x.\n", srr_req->xid);
551563 goto out_put;
564+ }
552565
553566 /* Normalize response data into struct fc_frame */
554567 mp_req = &(srr_req->mp_req);
@@ -721,8 +734,11 @@ void qedf_process_seq_cleanup_compl(struct qedf_ctx *qedf, · 166 unmodified lines
721734 cb_arg = io_req->cb_arg;
722735
723736 /* If we timed out just free resources */
724− if (io_req->event == QEDF_IOREQ_EV_ELS_TMO || !cqe)
737+ if (io_req->event == QEDF_IOREQ_EV_ELS_TMO || !cqe) {
738+ QEDF_ERR(&qedf->dbg_ctx,
739+ "cqe is NULL or timeout event (0x%x)", io_req->event);
725740 goto free;
741+ }
726742
727743 /* Kill the timer we put on the request */
728744 cancel_delayed_work_sync(&io_req->timeout_work);
@@ -825,8 +841,10 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg) · 96 unmodified lines
825841
826842 orig_io_req = cb_arg->aborted_io_req;
827843
828− if (!orig_io_req)
844+ if (!orig_io_req) {
845+ QEDF_ERR(NULL, "orig_io_req is NULL.\n");
829846 goto out_free;
847+ }
830848
831849 if (rec_req->event != QEDF_IOREQ_EV_ELS_TMO &&
832850 rec_req->event != QEDF_IOREQ_EV_ELS_ERR_DETECT)
@@ -838,8 +856,12 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg) · 5 unmodified lines
838856 orig_io_req, orig_io_req->xid, rec_req->xid, refcount);
839857
840858 /* If a REC times out, free resources */
841− if (rec_req->event == QEDF_IOREQ_EV_ELS_TMO)
859+ if (rec_req->event == QEDF_IOREQ_EV_ELS_TMO) {
860+ QEDF_ERR(&qedf->dbg_ctx,
861+ "Got TMO event, orig_io_req %p orig_io_xid=0x%x.\n",
862+ orig_io_req, orig_io_req->xid);
842863 goto out_put;
864+ }
843865
844866 /* Normalize response data into struct fc_frame */
845867 mp_req = &(rec_req->mp_req);
drivers/scsi/qedf/qedf_fip.c+21−12
@@ -23,8 +23,11 @@ void qedf_fcoe_send_vlan_req(struct qedf_ctx *qedf) · 22 unmodified lines
2323 int rc = -1;
2424
2525 skb = dev_alloc_skb(sizeof(struct fip_vlan));
26− if (!skb)
26+ if (!skb) {
27+ QEDF_ERR(&qedf->dbg_ctx,
28+ "Failed to allocate skb.\n");
2729 return;
30+ }
2831
2932 eth_fr = (char *)skb->data;
3033 vlan = (struct fip_vlan *)eth_fr;
@@ -250,18 +253,24 @@ void qedf_fip_recv(struct qedf_ctx *qedf, struct sk_buff *skb) · 219 unmodified lines
250253 fc_wwpn_valid = true;
251254 break;
252255 case FIP_DT_VN_ID:
256+ fabric_id_valid = false;
253257 vp = (struct fip_vn_desc *)desc;
254− QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_DISC,
255− "vx_port fd_fc_id=%x fd_mac=%pM.\n",
256− ntoh24(vp->fd_fc_id), vp->fd_mac);
257− /* Check vx_port fabric ID */
258− if (ntoh24(vp->fd_fc_id) !=
259− qedf->lport->port_id)
260− fabric_id_valid = false;
261− /* Check vx_port MAC */
262− if (!ether_addr_equal(vp->fd_mac,
263− qedf->data_src_addr))
264− fabric_id_valid = false;
258+
259+ QEDF_ERR(&qedf->dbg_ctx,
260+ "CVL vx_port fd_fc_id=0x%x fd_mac=%pM fd_wwpn=%016llx.\n",
261+ ntoh24(vp->fd_fc_id), vp->fd_mac,
262+ get_unaligned_be64(&vp->fd_wwpn));
263+ /* Check for vx_port wwpn OR Check vx_port
264+ * fabric ID OR Check vx_port MAC
265+ */
266+ if ((get_unaligned_be64(&vp->fd_wwpn) ==
267+ qedf->wwpn) ||
268+ (ntoh24(vp->fd_fc_id) ==
269+ qedf->lport->port_id) ||
270+ (ether_addr_equal(vp->fd_mac,
271+ qedf->data_src_addr))) {
272+ fabric_id_valid = true;
273+ }
265274 break;
266275 default:
267276 /* Ignore anything else */
drivers/scsi/qedf/qedf_io.c+56−11
@@ -104,6 +104,8 @@ static void qedf_cmd_timeout(struct work_struct *work) · 103 unmodified lines
104104 qedf_process_seq_cleanup_compl(qedf, NULL, io_req);
105105 break;
106106 default:
107+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_IO,
108+ "Hit default case, xid=0x%x.\n", io_req->xid);
107109 break;
108110 }
109111 }
@@ -122,8 +124,10 @@ void qedf_cmd_mgr_free(struct qedf_cmd_mgr *cmgr) · 12 unmodified lines
122124 num_ios = max_xid - min_xid + 1;
123125
124126 /* Free fcoe_bdt_ctx structures */
125− if (!cmgr->io_bdt_pool)
127+ if (!cmgr->io_bdt_pool) {
128+ QEDF_ERR(&qedf->dbg_ctx, "io_bdt_pool is NULL.\n");
126129 goto free_cmd_pool;
130+ }
127131
128132 bd_tbl_sz = QEDF_MAX_BDS_PER_CMD * sizeof(struct scsi_sge);
129133 for (i = 0; i < num_ios; i++) {
@@ -226,8 +230,11 @@ struct qedf_cmd_mgr *qedf_cmd_mgr_alloc(struct qedf_ctx *qedf) · 96 unmodified lines
226230 io_req->sense_buffer = dma_alloc_coherent(&qedf->pdev->dev,
227231 QEDF_SCSI_SENSE_BUFFERSIZE, &io_req->sense_buffer_dma,
228232 GFP_KERNEL);
229− if (!io_req->sense_buffer)
233+ if (!io_req->sense_buffer) {
234+ QEDF_ERR(&qedf->dbg_ctx,
235+ "Failed to alloc sense buffer.\n");
230236 goto mem_err;
237+ }
231238
232239 /* Allocate task parameters to pass to f/w init funcions */
233240 io_req->task_params = kzalloc(sizeof(*io_req->task_params),
@@ -437,8 +444,12 @@ void qedf_release_cmd(struct kref *ref) · 203 unmodified lines
437444 struct qedf_rport *fcport = io_req->fcport;
438445 unsigned long flags;
439446
440− if (io_req->cmd_type == QEDF_SCSI_CMD)
447+ if (io_req->cmd_type == QEDF_SCSI_CMD) {
448+ QEDF_WARN(&fcport->qedf->dbg_ctx,
449+ "Cmd released called without scsi_done called, io_req %p xid=0x%x.\n",
450+ io_req, io_req->xid);
441451 WARN_ON(io_req->sc_cmd);
452+ }
442453
443454 if (io_req->cmd_type == QEDF_ELS ||
444455 io_req->cmd_type == QEDF_TASK_MGMT_CMD)
@@ -447,8 +458,10 @@ void qedf_release_cmd(struct kref *ref) · 2 unmodified lines
447458 atomic_inc(&cmd_mgr->free_list_cnt);
448459 atomic_dec(&fcport->num_active_ios);
449460 atomic_set(&io_req->state, QEDF_CMD_ST_INACTIVE);
450− if (atomic_read(&fcport->num_active_ios) < 0)
461+ if (atomic_read(&fcport->num_active_ios) < 0) {
451462 QEDF_WARN(&(fcport->qedf->dbg_ctx), "active_ios < 0.\n");
463+ WARN_ON(1);
464+ }
452465
453466 /* Increment task retry identifier now that the request is released */
454467 io_req->task_retry_identifier++;
@@ -951,6 +964,9 @@ qedf_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc_cmd) · 496 unmodified lines
951964
952965 if (test_bit(QEDF_UNLOADING, &qedf->flags) ||
953966 test_bit(QEDF_DBG_STOP_IO, &qedf->flags)) {
967+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_IO,
968+ "Returning DNC as unloading or stop io, flags 0x%lx.\n",
969+ qedf->flags);
954970 sc_cmd->result = DID_NO_CONNECT << 16;
955971 sc_cmd->scsi_done(sc_cmd);
956972 return 0;
@@ -967,6 +983,9 @@ qedf_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc_cmd) · 10 unmodified lines
967983
968984 rval = fc_remote_port_chkready(rport);
969985 if (rval) {
986+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_IO,
987+ "fc_remote_port_chkready failed=0x%x for port_id=0x%06x.\n",
988+ rval, rport->port_id);
970989 sc_cmd->result = rval;
971990 sc_cmd->scsi_done(sc_cmd);
972991 return 0;
@@ -974,12 +993,14 @@ qedf_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc_cmd) · 1 unmodified line
974993
975994 /* Retry command if we are doing a qed drain operation */
976995 if (test_bit(QEDF_DRAIN_ACTIVE, &qedf->flags)) {
996+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_IO, "Drain active.\n");
977997 rc = SCSI_MLQUEUE_HOST_BUSY;
978998 goto exit_qcmd;
979999 }
9801000
9811001 if (lport->state != LPORT_ST_READY ||
9821002 atomic_read(&qedf->link_state) != QEDF_LINK_UP) {
1003+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_IO, "Link down.\n");
9831004 rc = SCSI_MLQUEUE_HOST_BUSY;
9841005 goto exit_qcmd;
9851006 }
@@ -1297,8 +1318,10 @@ void qedf_scsi_done(struct qedf_ctx *qedf, struct qedf_ioreq *io_req, · 311 unmodified lines
12971318 struct scsi_cmnd *sc_cmd;
12981319 int refcount;
12991320
1300− if (!io_req)
1321+ if (!io_req) {
1322+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_IO, "io_req is NULL\n");
13011323 return;
1324+ }
13021325
13031326 if (test_and_set_bit(QEDF_CMD_ERR_SCSI_DONE, &io_req->flags)) {
13041327 QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_IO,
@@ -1414,8 +1437,12 @@ void qedf_process_warning_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, · 109 unmodified lines
14141437 u64 err_warn_bit_map;
14151438 u8 err_warn = 0xff;
14161439
1417− if (!cqe)
1440+ if (!cqe) {
1441+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_IO,
1442+ "cqe is NULL for io_req %p xid=0x%x\n",
1443+ io_req, io_req->xid);
14181444 return;
1445+ }
14191446
14201447 QEDF_ERR(&(io_req->fcport->qedf->dbg_ctx), "Warning CQE, "
14211448 "xid=0x%x\n", io_req->xid);
@@ -1477,8 +1504,11 @@ void qedf_process_error_detect(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, · 55 unmodified lines
14771504 {
14781505 int rval;
14791506
1480− if (!cqe)
1507+ if (!cqe) {
1508+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_IO,
1509+ "cqe is NULL for io_req %p\n", io_req);
14811510 return;
1511+ }
14821512
14831513 QEDF_ERR(&(io_req->fcport->qedf->dbg_ctx), "Error detection CQE, "
14841514 "xid=0x%x\n", io_req->xid);
@@ -1543,8 +1573,10 @@ void qedf_flush_active_ios(struct qedf_rport *fcport, int lun) · 58 unmodified lines
15431573 int wait_cnt = 100;
15441574 int refcount = 0;
15451575
1546− if (!fcport)
1576+ if (!fcport) {
1577+ QEDF_ERR(NULL, "fcport is NULL\n");
15471578 return;
1579+ }
15481580
15491581 /* Check that fcport is still offloaded */
15501582 if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) {
@@ -1976,6 +2008,10 @@ void qedf_process_abts_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, · 425 unmodified lines
19762008 clear_bit(QEDF_CMD_IN_ABORT, &io_req->flags);
19772009
19782010 if (io_req->sc_cmd) {
2011+ if (!io_req->return_scsi_cmd_on_abts)
2012+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_SCSI_TM,
2013+ "Not call scsi_done for xid=0x%x.\n",
2014+ io_req->xid);
19792015 if (io_req->return_scsi_cmd_on_abts)
19802016 qedf_scsi_done(qedf, io_req, DID_ERROR);
19812017 }
@@ -2201,6 +2237,10 @@ int qedf_initiate_cleanup(struct qedf_ioreq *io_req, · 219 unmodified lines
22012237 }
22022238
22032239 if (io_req->sc_cmd) {
2240+ if (!io_req->return_scsi_cmd_on_abts)
2241+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_SCSI_TM,
2242+ "Not call scsi_done for xid=0x%x.\n",
2243+ io_req->xid);
22042244 if (io_req->return_scsi_cmd_on_abts)
22052245 qedf_scsi_done(qedf, io_req, DID_ERROR);
22062246 }
@@ -2241,7 +2281,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, · 34 unmodified lines
22412281 u16 sqe_idx;
22422282
22432283 if (!sc_cmd) {
2244− QEDF_ERR(&(qedf->dbg_ctx), "invalid arg\n");
2284+ QEDF_ERR(&qedf->dbg_ctx, "sc_cmd is NULL\n");
22452285 return FAILED;
22462286 }
22472287
@@ -2363,8 +2403,8 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) · 115 unmodified lines
23632403
23642404 QEDF_ERR(NULL,
23652405 "tm_flags 0x%x sc_cmd %p op = 0x%02x target_id = 0x%x lun=%d\n",
2366− tm_flags, sc_cmd, sc_cmd->cmnd[0], rport->scsi_target_id,
2367− (int)sc_cmd->device->lun);
2406+ tm_flags, sc_cmd, sc_cmd->cmd_len ? sc_cmd->cmnd[0] : 0xff,
2407+ rport->scsi_target_id, (int)sc_cmd->device->lun);
23682408
23692409 if (!rdata || !kref_get_unless_zero(&rdata->kref)) {
23702410 QEDF_ERR(NULL, "stale rport\n");
@@ -2515,6 +2555,11 @@ void qedf_process_unsol_compl(struct qedf_ctx *qedf, uint16_t que_idx, · 144 unmodified lines
25152555 fh = (struct fc_frame_header *)fc_frame_header_get(fp);
25162556 memcpy(fh, (void *)bdq_addr, pktlen);
25172557
2558+ QEDF_WARN(&qedf->dbg_ctx,
2559+ "Processing Unsolicated frame, src=%06x dest=%06x r_ctl=0x%x type=0x%x cmd=%02x\n",
2560+ ntoh24(fh->fh_s_id), ntoh24(fh->fh_d_id), fh->fh_r_ctl,
2561+ fh->fh_type, fc_frame_payload_op(fp));
2562+
25182563 /* Initialize the frame so libfc sees it as a valid frame */
25192564 crc = fcoe_fc_crc(fp);
25202565 fc_frame_init(fp);
drivers/scsi/qedf/qedf_main.c+113−65
@@ -27,6 +27,7 @@ const struct qed_fcoe_ops *qed_ops; · 26 unmodified lines
2727
2828 static int qedf_probe(struct pci_dev *pdev, const struct pci_device_id *id);
2929 static void qedf_remove(struct pci_dev *pdev);
30+static void qedf_shutdown(struct pci_dev *pdev);
3031
3132 /*
3233 * Driver module parameters.
@@ -110,16 +111,18 @@ static struct kmem_cache *qedf_io_work_cache; · 77 unmodified lines
110111
111112 void qedf_set_vlan_id(struct qedf_ctx *qedf, int vlan_id)
112113 {
113− qedf->vlan_id = vlan_id;
114− qedf->vlan_id |= qedf->prio << VLAN_PRIO_SHIFT;
115− QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, "Setting vlan_id=%04x "
116− "prio=%d.\n", vlan_id, qedf->prio);
114+ int vlan_id_tmp = 0;
115+
116+ vlan_id_tmp = vlan_id | (qedf->prio << VLAN_PRIO_SHIFT);
117+ qedf->vlan_id = vlan_id_tmp;
118+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_DISC,
119+ "Setting vlan_id=0x%04x prio=%d.\n",
120+ vlan_id_tmp, qedf->prio);
117121 }
118122
119123 /* Returns true if we have a valid vlan, false otherwise */
120124 static bool qedf_initiate_fipvlan_req(struct qedf_ctx *qedf)
121125 {
122− int rc;
123126
124127 while (qedf->fipvlan_retries--) {
125128 /* This is to catch if link goes down during fipvlan retries */
@@ -128,20 +131,25 @@ static bool qedf_initiate_fipvlan_req(struct qedf_ctx *qedf) · 2 unmodified lines
128131 return false;
129132 }
130133
131− if (qedf->vlan_id > 0)
134+ if (test_bit(QEDF_UNLOADING, &qedf->flags)) {
135+ QEDF_ERR(&qedf->dbg_ctx, "Driver unloading.\n");
136+ return false;
137+ }
138+
139+ if (qedf->vlan_id > 0) {
140+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_DISC,
141+ "vlan = 0x%x already set, calling ctlr_link_up.\n",
142+ qedf->vlan_id);
143+ if (atomic_read(&qedf->link_state) == QEDF_LINK_UP)
144+ fcoe_ctlr_link_up(&qedf->ctlr);
132145 return true;
146+ }
133147
134148 QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC,
135149 "Retry %d.\n", qedf->fipvlan_retries);
136150 init_completion(&qedf->fipvlan_compl);
137151 qedf_fcoe_send_vlan_req(qedf);
138− rc = wait_for_completion_timeout(&qedf->fipvlan_compl,
139− 1 * HZ);
140− if (rc > 0 &&
141− (atomic_read(&qedf->link_state) == QEDF_LINK_UP)) {
142− fcoe_ctlr_link_up(&qedf->ctlr);
143− return true;
144− }
152+ wait_for_completion_timeout(&qedf->fipvlan_compl, 1 * HZ);
145153 }
146154
147155 return false;
@@ -162,6 +170,8 @@ static void qedf_handle_link_update(struct work_struct *work) · 14 unmodified lines
162170 return;
163171
164172 if (atomic_read(&qedf->link_state) != QEDF_LINK_UP) {
173+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_DISC,
174+ "Link is down, resetting vlan_id.\n");
165175 qedf->vlan_id = 0;
166176 return;
167177 }
@@ -311,8 +321,10 @@ int qedf_send_flogi(struct qedf_ctx *qedf) · 143 unmodified lines
311321
312322 lport = qedf->lport;
313323
314− if (!lport->tt.elsct_send)
324+ if (!lport->tt.elsct_send) {
325+ QEDF_ERR(&qedf->dbg_ctx, "tt.elsct_send not set.\n");
315326 return -EINVAL;
327+ }
316328
317329 fp = fc_frame_alloc(lport, sizeof(struct fc_els_flogi));
318330 if (!fp) {
@@ -330,11 +342,6 @@ int qedf_send_flogi(struct qedf_ctx *qedf) · 11 unmodified lines
330342 return 0;
331343 }
332344
333−struct qedf_tmp_rdata_item {
334− struct fc_rport_priv *rdata;
335− struct list_head list;
336−};
337−
338345 /*
339346 * This function is called if link_down_tmo is in use. If we get a link up and
340347 * link_down_tmo has not expired then use just FLOGI/ADISC to recover our
@@ -344,9 +351,8 @@ static void qedf_link_recovery(struct work_struct *work) · 3 unmodified lines
344351 {
345352 struct qedf_ctx *qedf =
346353 container_of(work, struct qedf_ctx, link_recovery.work);
347− struct qedf_rport *fcport;
354+ struct fc_lport *lport = qedf->lport;
348355 struct fc_rport_priv *rdata;
349− struct qedf_tmp_rdata_item *rdata_item, *tmp_rdata_item;
350356 bool rc;
351357 int retries = 30;
352358 int rval, i;
@@ -413,33 +419,14 @@ static void qedf_link_recovery(struct work_struct *work) · 60 unmodified lines
413419 * Call lport->tt.rport_login which will cause libfc to send an
414420 * ADISC since the rport is in state ready.
415421 */
416− rcu_read_lock();
417− list_for_each_entry_rcu(fcport, &qedf->fcports, peers) {
418− rdata = fcport->rdata;
419− if (rdata == NULL)
420− continue;
421− rdata_item = kzalloc(sizeof(struct qedf_tmp_rdata_item),
422− GFP_ATOMIC);
423− if (!rdata_item)
424− continue;
422+ mutex_lock(&lport->disc.disc_mutex);
423+ list_for_each_entry_rcu(rdata, &lport->disc.rports, peers) {
425424 if (kref_get_unless_zero(&rdata->kref)) {
426− rdata_item->rdata = rdata;
427− list_add(&rdata_item->list, &rdata_login_list);
428− } else
429− kfree(rdata_item);
430− }
431− rcu_read_unlock();
432− /*
433− * Do the fc_rport_login outside of the rcu lock so we don't take a
434− * mutex in an atomic context.
435− */
436− list_for_each_entry_safe(rdata_item, tmp_rdata_item, &rdata_login_list,
437− list) {
438− list_del(&rdata_item->list);
439− fc_rport_login(rdata_item->rdata);
440− kref_put(&rdata_item->rdata->kref, fc_rport_destroy);
441− kfree(rdata_item);
425+ fc_rport_login(rdata);
426+ kref_put(&rdata->kref, fc_rport_destroy);
427+ }
442428 }
429+ mutex_unlock(&lport->disc.disc_mutex);
443430 }
444431
445432 static void qedf_update_link_speed(struct qedf_ctx *qedf,
@@ -467,6 +454,9 @@ static void qedf_update_link_speed(struct qedf_ctx *qedf, · 21 unmodified lines
467454 case 100000:
468455 lport->link_speed = FC_PORTSPEED_100GBIT;
469456 break;
457+ case 20000:
458+ lport->link_speed = FC_PORTSPEED_20GBIT;
459+ break;
470460 default:
471461 lport->link_speed = FC_PORTSPEED_UNKNOWN;
472462 break;
@@ -476,16 +466,40 @@ static void qedf_update_link_speed(struct qedf_ctx *qedf, · 3 unmodified lines
476466 * Set supported link speed by querying the supported
477467 * capabilities of the link.
478468 */
479− if (link->supported_caps & SUPPORTED_10000baseKR_Full)
469+ if ((link->supported_caps & QED_LM_10000baseT_Full_BIT) ||
470+ (link->supported_caps & QED_LM_10000baseKX4_Full_BIT) ||
471+ (link->supported_caps & QED_LM_10000baseR_FEC_BIT) ||
472+ (link->supported_caps & QED_LM_10000baseCR_Full_BIT) ||
473+ (link->supported_caps & QED_LM_10000baseSR_Full_BIT) ||
474+ (link->supported_caps & QED_LM_10000baseLR_Full_BIT) ||
475+ (link->supported_caps & QED_LM_10000baseLRM_Full_BIT) ||
476+ (link->supported_caps & QED_LM_10000baseKR_Full_BIT)) {
480477 lport->link_supported_speeds |= FC_PORTSPEED_10GBIT;
481− if (link->supported_caps & SUPPORTED_25000baseKR_Full)
478+ }
479+ if ((link->supported_caps & QED_LM_25000baseKR_Full_BIT) ||
480+ (link->supported_caps & QED_LM_25000baseCR_Full_BIT) ||
481+ (link->supported_caps & QED_LM_25000baseSR_Full_BIT)) {
482482 lport->link_supported_speeds |= FC_PORTSPEED_25GBIT;
483− if (link->supported_caps & SUPPORTED_40000baseLR4_Full)
483+ }
484+ if ((link->supported_caps & QED_LM_40000baseLR4_Full_BIT) ||
485+ (link->supported_caps & QED_LM_40000baseKR4_Full_BIT) ||
486+ (link->supported_caps & QED_LM_40000baseCR4_Full_BIT) ||
487+ (link->supported_caps & QED_LM_40000baseSR4_Full_BIT)) {
484488 lport->link_supported_speeds |= FC_PORTSPEED_40GBIT;
485− if (link->supported_caps & SUPPORTED_50000baseKR2_Full)
489+ }
490+ if ((link->supported_caps & QED_LM_50000baseKR2_Full_BIT) ||
491+ (link->supported_caps & QED_LM_50000baseCR2_Full_BIT) ||
492+ (link->supported_caps & QED_LM_50000baseSR2_Full_BIT)) {
486493 lport->link_supported_speeds |= FC_PORTSPEED_50GBIT;
487− if (link->supported_caps & SUPPORTED_100000baseKR4_Full)
494+ }
495+ if ((link->supported_caps & QED_LM_100000baseKR4_Full_BIT) ||
496+ (link->supported_caps & QED_LM_100000baseSR4_Full_BIT) ||
497+ (link->supported_caps & QED_LM_100000baseCR4_Full_BIT) ||
498+ (link->supported_caps & QED_LM_100000baseLR4_ER4_Full_BIT)) {
488499 lport->link_supported_speeds |= FC_PORTSPEED_100GBIT;
500+ }
501+ if (link->supported_caps & QED_LM_20000baseKR2_Full_BIT)
502+ lport->link_supported_speeds |= FC_PORTSPEED_20GBIT;
489503 fc_host_supported_speeds(lport->host) = lport->link_supported_speeds;
490504 }
491505
@@ -493,6 +507,16 @@ static void qedf_link_update(void *dev, struct qed_link_output *link) · 1 unmodified line
493507 {
494508 struct qedf_ctx *qedf = (struct qedf_ctx *)dev;
495509
510+ /*
511+ * Prevent race where we're removing the module and we get link update
512+ * for qed.
513+ */
514+ if (test_bit(QEDF_UNLOADING, &qedf->flags)) {
515+ QEDF_ERR(&qedf->dbg_ctx,
516+ "Ignore link update, driver getting unload.\n");
517+ return;
518+ }
519+
496520 if (link->link_up) {
497521 if (atomic_read(&qedf->link_state) == QEDF_LINK_UP) {
498522 QEDF_INFO((&qedf->dbg_ctx), QEDF_LOG_DISC,
@@ -2340,12 +2364,14 @@ static void qedf_recv_frame(struct qedf_ctx *qedf, · 1841 unmodified lines
23402364 fr_dev(fp) = lport;
23412365 fr_sof(fp) = hp->fcoe_sof;
23422366 if (skb_copy_bits(skb, fr_len, &crc_eof, sizeof(crc_eof))) {
2367+ QEDF_INFO(NULL, QEDF_LOG_LL2, "skb_copy_bits failed.\n");
23432368 kfree_skb(skb);
23442369 return;
23452370 }
23462371 fr_eof(fp) = crc_eof.fcoe_eof;
23472372 fr_crc(fp) = crc_eof.fcoe_crc32;
23482373 if (pskb_trim(skb, fr_len)) {
2374+ QEDF_INFO(NULL, QEDF_LOG_LL2, "pskb_trim failed.\n");
23492375 kfree_skb(skb);
23502376 return;
23512377 }
@@ -2406,9 +2432,9 @@ static void qedf_recv_frame(struct qedf_ctx *qedf, · 54 unmodified lines
24062432 * empty then this is not addressed to our port so simply drop it.
24072433 */
24082434 if (lport->port_id != ntoh24(fh->fh_d_id) && !vn_port) {
2409− QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_LL2,
2410− "Dropping frame due to destination mismatch: lport->port_id=%x fh->d_id=%x.\n",
2411− lport->port_id, ntoh24(fh->fh_d_id));
2435+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_LL2,
2436+ "Dropping frame due to destination mismatch: lport->port_id=0x%x fh->d_id=0x%x.\n",
2437+ lport->port_id, ntoh24(fh->fh_d_id));
24122438 kfree_skb(skb);
24132439 return;
24142440 }
@@ -2417,6 +2443,8 @@ static void qedf_recv_frame(struct qedf_ctx *qedf, · 2 unmodified lines
24172443 if ((fh->fh_type == FC_TYPE_BLS) && (f_ctl & FC_FC_SEQ_CTX) &&
24182444 (f_ctl & FC_FC_EX_CTX)) {
24192445 /* Drop incoming ABTS response that has both SEQ/EX CTX set */
2446+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_LL2,
2447+ "Dropping ABTS response as both SEQ/EX CTX set.\n");
24202448 kfree_skb(skb);
24212449 return;
24222450 }
@@ -2560,8 +2588,9 @@ static int qedf_alloc_and_init_sb(struct qedf_ctx *qedf, · 137 unmodified lines
25602588 sizeof(struct status_block_e4), &sb_phys, GFP_KERNEL);
25612589
25622590 if (!sb_virt) {
2563− QEDF_ERR(&(qedf->dbg_ctx), "Status block allocation failed "
2564− "for id = %d.\n", sb_id);
2591+ QEDF_ERR(&qedf->dbg_ctx,
2592+ "Status block allocation failed for id = %d.\n",
2593+ sb_id);
25652594 return -ENOMEM;
25662595 }
25672596
@@ -2569,8 +2598,9 @@ static int qedf_alloc_and_init_sb(struct qedf_ctx *qedf, · 1 unmodified line
25692598 sb_id, QED_SB_TYPE_STORAGE);
25702599
25712600 if (ret) {
2572− QEDF_ERR(&(qedf->dbg_ctx), "Status block initialization "
2573− "failed for id = %d.\n", sb_id);
2601+ QEDF_ERR(&qedf->dbg_ctx,
2602+ "Status block initialization failed (0x%x) for id = %d.\n",
2603+ ret, sb_id);
25742604 return ret;
25752605 }
25762606
@@ -2654,13 +2684,18 @@ void qedf_process_cqe(struct qedf_ctx *qedf, struct fcoe_cqe *cqe) · 77 unmodified lines
26542684 io_req = &qedf->cmd_mgr->cmds[xid];
26552685
26562686 /* Completion not for a valid I/O anymore so just return */
2657− if (!io_req)
2687+ if (!io_req) {
2688+ QEDF_ERR(&qedf->dbg_ctx,
2689+ "io_req is NULL for xid=0x%x.\n", xid);
26582690 return;
2691+ }
26592692
26602693 fcport = io_req->fcport;
26612694
26622695 if (fcport == NULL) {
2663− QEDF_ERR(&(qedf->dbg_ctx), "fcport is NULL.\n");
2696+ QEDF_ERR(&qedf->dbg_ctx,
2697+ "fcport is NULL for xid=0x%x io_req=%p.\n",
2698+ xid, io_req);
26642699 return;
26652700 }
26662701
@@ -2669,7 +2704,8 @@ void qedf_process_cqe(struct qedf_ctx *qedf, struct fcoe_cqe *cqe) · 2 unmodified lines
26692704 * isn't valid and shouldn't be taken. We should just return.
26702705 */
26712706 if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) {
2672− QEDF_ERR(&(qedf->dbg_ctx), "Session not offloaded yet.\n");
2707+ QEDF_ERR(&qedf->dbg_ctx,
2708+ "Session not offloaded yet, fcport = %p.\n", fcport);
26732709 return;
26742710 }
26752711
@@ -2881,6 +2917,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf) · 205 unmodified lines
28812917 */
28822918 if (!qedf->p_cpuq) {
28832919 status = 1;
2920+ QEDF_ERR(&qedf->dbg_ctx, "p_cpuq is NULL.\n");
28842921 goto mem_alloc_failure;
28852922 }
28862923
@@ -2896,8 +2933,10 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf) · 9 unmodified lines
28962933
28972934 /* Allocate DMA coherent buffers for BDQ */
28982935 rc = qedf_alloc_bdq(qedf);
2899− if (rc)
2936+ if (rc) {
2937+ QEDF_ERR(&qedf->dbg_ctx, "Unable to allocate bdq.\n");
29002938 goto mem_alloc_failure;
2939+ }
29012940
29022941 /* Allocate a CQ and an associated PBL for each MSI-X vector */
29032942 for (i = 0; i < qedf->num_queues; i++) {
@@ -3107,6 +3146,7 @@ static struct pci_driver qedf_pci_driver = { · 203 unmodified lines
31073146 .id_table = qedf_pci_tbl,
31083147 .probe = qedf_probe,
31093148 .remove = qedf_remove,
3149+ .shutdown = qedf_shutdown,
31103150 };
31113151
31123152 static int __qedf_probe(struct pci_dev *pdev, int mode)
@@ -3209,6 +3249,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode) · 96 unmodified lines
32093249 qed_params.is_vf = is_vf;
32103250 qedf->cdev = qed_ops->common->probe(pdev, &qed_params);
32113251 if (!qedf->cdev) {
3252+ QEDF_ERR(&qedf->dbg_ctx, "common probe failed.\n");
32123253 rc = -ENODEV;
32133254 goto err1;
32143255 }
@@ -3277,8 +3318,10 @@ static int __qedf_probe(struct pci_dev *pdev, int mode) · 62 unmodified lines
32773318
32783319 /* Setup interrupts */
32793320 rc = qedf_setup_int(qedf);
3280− if (rc)
3321+ if (rc) {
3322+ QEDF_ERR(&qedf->dbg_ctx, "Setup interrupts failed.\n");
32813323 goto err3;
3324+ }
32823325
32833326 rc = qed_ops->start(qedf->cdev, &qedf->tasks);
32843327 if (rc) {
@@ -3360,7 +3403,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode) · 75 unmodified lines
33603403 }
33613404
33623405 memset(&params, 0, sizeof(params));
3363− params.mtu = 9000;
3406+ params.mtu = QEDF_LL2_BUF_SIZE;
33643407 ether_addr_copy(params.ll2_mac_address, qedf->mac);
33653408
33663409 /* Start LL2 processing thread */
@@ -3719,6 +3762,11 @@ void qedf_get_protocol_tlv_data(void *dev, void *data) · 352 unmodified lines
37193762 fcoe->scsi_tsk_full = qedf->task_set_fulls;
37203763 }
37213764
3765+static void qedf_shutdown(struct pci_dev *pdev)
3766+{
3767+ __qedf_remove(pdev, QEDF_MODE_NORMAL);
3768+}
3769+
37223770 /* Generic TLV data callback */
37233771 void qedf_get_generic_tlv_data(void *dev, struct qed_generic_tlvs *data)
37243772 {
@@ -3845,7 +3893,7 @@ static void __exit qedf_cleanup(void) · 120 unmodified lines
38453893 }
38463894
38473895 MODULE_LICENSE("GPL");
3848−MODULE_DESCRIPTION("QLogic QEDF 25/40/50/100Gb FCoE Driver");
3896+MODULE_DESCRIPTION("QLogic FastLinQ 4xxxx FCoE Module");
38493897 MODULE_AUTHOR("QLogic Corporation");
38503898 MODULE_VERSION(QEDF_VERSION);
38513899 module_init(qedf_init);
drivers/scsi/qedf/qedf_version.h+4−4
@@ -4,9 +4,9 @@ · 3 unmodified lines
44 * Copyright (c) 2016-2018 Cavium Inc.
55 */
66
7−#define QEDF_VERSION "8.37.25.20"
7+#define QEDF_VERSION "8.42.3.0"
88 #define QEDF_DRIVER_MAJOR_VER 8
9−#define QEDF_DRIVER_MINOR_VER 37
10−#define QEDF_DRIVER_REV_VER 25
11−#define QEDF_DRIVER_ENG_VER 20
9+#define QEDF_DRIVER_MINOR_VER 42
10+#define QEDF_DRIVER_REV_VER 3
11+#define QEDF_DRIVER_ENG_VER 0
1212
drivers/scsi/qla2xxx/qla_attr.c+6−6
@@ -382,7 +382,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, · 381 unmodified lines
382382 ha->optrom_region_size = size;
383383
384384 ha->optrom_state = QLA_SREADING;
385− ha->optrom_buffer = vmalloc(ha->optrom_region_size);
385+ ha->optrom_buffer = vzalloc(ha->optrom_region_size);
386386 if (ha->optrom_buffer == NULL) {
387387 ql_log(ql_log_warn, vha, 0x7062,
388388 "Unable to allocate memory for optrom retrieval "
@@ -404,7 +404,6 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, · 15 unmodified lines
404404 "Reading flash region -- 0x%x/0x%x.\n",
405405 ha->optrom_region_start, ha->optrom_region_size);
406406
407− memset(ha->optrom_buffer, 0, ha->optrom_region_size);
408407 ha->isp_ops->read_optrom(vha, ha->optrom_buffer,
409408 ha->optrom_region_start, ha->optrom_region_size);
410409 break;
@@ -457,7 +456,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, · 46 unmodified lines
457456 ha->optrom_region_size = size;
458457
459458 ha->optrom_state = QLA_SWRITING;
460− ha->optrom_buffer = vmalloc(ha->optrom_region_size);
459+ ha->optrom_buffer = vzalloc(ha->optrom_region_size);
461460 if (ha->optrom_buffer == NULL) {
462461 ql_log(ql_log_warn, vha, 0x7066,
463462 "Unable to allocate memory for optrom update "
@@ -472,7 +471,6 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, · 8 unmodified lines
472471 "Staging flash region write -- 0x%x/0x%x.\n",
473472 ha->optrom_region_start, ha->optrom_region_size);
474473
475− memset(ha->optrom_buffer, 0, ha->optrom_region_size);
476474 break;
477475 case 3:
478476 if (ha->optrom_state != QLA_SWRITING) {
@@ -726,7 +724,8 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj, · 247 unmodified lines
726724 break;
727725 } else {
728726 /* Make sure FC side is not in reset */
729− qla2x00_wait_for_hba_online(vha);
727+ WARN_ON_ONCE(qla2x00_wait_for_hba_online(vha) !=
728+ QLA_SUCCESS);
730729
731730 /* Issue MPI reset */
732731 scsi_block_requests(vha->host);
@@ -1126,7 +1125,8 @@ qla2x00_pci_info_show(struct device *dev, struct device_attribute *attr, · 393 unmodified lines
11261125 char pci_info[30];
11271126
11281127 return scnprintf(buf, PAGE_SIZE, "%s\n",
1129− vha->hw->isp_ops->pci_info_str(vha, pci_info));
1128+ vha->hw->isp_ops->pci_info_str(vha, pci_info,
1129+ sizeof(pci_info)));
11301130 }
11311131
11321132 static ssize_t
drivers/scsi/qla2xxx/qla_bsg.c+11−12
@@ -12,10 +12,8 @@ · 11 unmodified lines
1212 #include <linux/bsg-lib.h>
1313
1414 /* BSG support for ELS/CT pass through */
15−void
16−qla2x00_bsg_job_done(void *ptr, int res)
15+void qla2x00_bsg_job_done(srb_t *sp, int res)
1716 {
18− srb_t *sp = ptr;
1917 struct bsg_job *bsg_job = sp->u.bsg_job;
2018 struct fc_bsg_reply *bsg_reply = bsg_job->reply;
2119
@@ -25,10 +23,8 @@ qla2x00_bsg_job_done(void *ptr, int res) · 3 unmodified lines
2523 sp->free(sp);
2624 }
2725
28−void
29−qla2x00_bsg_sp_free(void *ptr)
26+void qla2x00_bsg_sp_free(srb_t *sp)
3027 {
31− srb_t *sp = ptr;
3228 struct qla_hw_data *ha = sp->vha->hw;
3329 struct bsg_job *bsg_job = sp->u.bsg_job;
3430 struct fc_bsg_request *bsg_request = bsg_job->request;
@@ -341,6 +337,8 @@ qla2x00_process_els(struct bsg_job *bsg_job) · 306 unmodified lines
341337 dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
342338 bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
343339 if (!req_sg_cnt) {
340+ dma_unmap_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
341+ bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
344342 rval = -ENOMEM;
345343 goto done_free_fcport;
346344 }
@@ -348,6 +346,8 @@ qla2x00_process_els(struct bsg_job *bsg_job) · 1 unmodified line
348346 rsp_sg_cnt = dma_map_sg(&ha->pdev->dev, bsg_job->reply_payload.sg_list,
349347 bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE);
350348 if (!rsp_sg_cnt) {
349+ dma_unmap_sg(&ha->pdev->dev, bsg_job->reply_payload.sg_list,
350+ bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE);
351351 rval = -ENOMEM;
352352 goto done_free_fcport;
353353 }
@@ -1778,8 +1778,8 @@ qla24xx_process_bidir_cmd(struct bsg_job *bsg_job) · 1424 unmodified lines
17781778 uint16_t nextlid = 0;
17791779 uint32_t tot_dsds;
17801780 srb_t *sp = NULL;
1781− uint32_t req_data_len = 0;
1782− uint32_t rsp_data_len = 0;
1781+ uint32_t req_data_len;
1782+ uint32_t rsp_data_len;
17831783
17841784 /* Check the type of the adapter */
17851785 if (!IS_BIDI_CAPABLE(ha)) {
@@ -1884,6 +1884,9 @@ qla24xx_process_bidir_cmd(struct bsg_job *bsg_job) · 98 unmodified lines
18841884 goto done_unmap_sg;
18851885 }
18861886
1887+ req_data_len = bsg_job->request_payload.payload_len;
1888+ rsp_data_len = bsg_job->reply_payload.payload_len;
1889+
18871890 if (req_data_len != rsp_data_len) {
18881891 rval = EXT_STATUS_BUSY;
18891892 ql_log(ql_log_warn, vha, 0x70aa,
@@ -1891,10 +1894,6 @@ qla24xx_process_bidir_cmd(struct bsg_job *bsg_job) · 1 unmodified line
18911894 goto done_unmap_sg;
18921895 }
18931896
1894− req_data_len = bsg_job->request_payload.payload_len;
1895− rsp_data_len = bsg_job->reply_payload.payload_len;
1896−
1897−
18981897 /* Alloc SRB structure */
18991898 sp = qla2x00_get_sp(vha, &(vha->bidir_fcport), GFP_KERNEL);
19001899 if (!sp) {
drivers/scsi/qla2xxx/qla_dbg.c+2−1
@@ -2743,7 +2743,8 @@ ql_dump_regs(uint level, scsi_qla_host_t *vha, uint id) · 2742 unmodified lines
27432743
27442744
27452745 void
2746−ql_dump_buffer(uint level, scsi_qla_host_t *vha, uint id, void *buf, uint size)
2746+ql_dump_buffer(uint level, scsi_qla_host_t *vha, uint id, const void *buf,
2747+ uint size)
27472748 {
27482749 uint cnt;
27492750
drivers/scsi/qla2xxx/qla_def.h+95−37
@@ -34,6 +34,20 @@ · 33 unmodified lines
3434 #include <scsi/scsi_transport_fc.h>
3535 #include <scsi/scsi_bsg_fc.h>
3636
37+/* Big endian Fibre Channel S_ID (source ID) or D_ID (destination ID). */
38+typedef struct {
39+ uint8_t domain;
40+ uint8_t area;
41+ uint8_t al_pa;
42+} be_id_t;
43+
44+/* Little endian Fibre Channel S_ID (source ID) or D_ID (destination ID). */
45+typedef struct {
46+ uint8_t al_pa;
47+ uint8_t area;
48+ uint8_t domain;
49+} le_id_t;
50+
3751 #include "qla_bsg.h"
3852 #include "qla_dsd.h"
3953 #include "qla_nx.h"
@@ -117,9 +131,9 @@ · 77 unmodified lines
117131 #define RD_REG_BYTE_RELAXED(addr) readb_relaxed(addr)
118132 #define RD_REG_WORD_RELAXED(addr) readw_relaxed(addr)
119133 #define RD_REG_DWORD_RELAXED(addr) readl_relaxed(addr)
120−#define WRT_REG_BYTE(addr, data) writeb(data,addr)
121−#define WRT_REG_WORD(addr, data) writew(data,addr)
122−#define WRT_REG_DWORD(addr, data) writel(data,addr)
134+#define WRT_REG_BYTE(addr, data) writeb(data, addr)
135+#define WRT_REG_WORD(addr, data) writew(data, addr)
136+#define WRT_REG_DWORD(addr, data) writel(data, addr)
123137
124138 /*
125139 * ISP83XX specific remote register addresses
@@ -207,7 +221,7 @@ · 81 unmodified lines
207221 * 133Mhz slot.
208222 */
209223 #define RD_REG_WORD_PIO(addr) (inw((unsigned long)addr))
210−#define WRT_REG_WORD_PIO(addr, data) (outw(data,(unsigned long)addr))
224+#define WRT_REG_WORD_PIO(addr, data) (outw(data, (unsigned long)addr))
211225
212226 /*
213227 * Fibre Channel device definitions.
@@ -303,7 +317,8 @@ struct srb_cmd { · 89 unmodified lines
303317 uint32_t request_sense_length;
304318 uint32_t fw_sense_length;
305319 uint8_t *request_sense_ptr;
306− void *ctx;
320+ struct ct6_dsd *ct6_ctx;
321+ struct crc_context *crc_ctx;
307322 };
308323
309324 /*
@@ -343,6 +358,51 @@ typedef union { · 33 unmodified lines
343358 } port_id_t;
344359 #define INVALID_PORT_ID 0xFFFFFF
345360
361+static inline le_id_t be_id_to_le(be_id_t id)
362+{
363+ le_id_t res;
364+
365+ res.domain = id.domain;
366+ res.area = id.area;
367+ res.al_pa = id.al_pa;
368+
369+ return res;
370+}
371+
372+static inline be_id_t le_id_to_be(le_id_t id)
373+{
374+ be_id_t res;
375+
376+ res.domain = id.domain;
377+ res.area = id.area;
378+ res.al_pa = id.al_pa;
379+
380+ return res;
381+}
382+
383+static inline port_id_t be_to_port_id(be_id_t id)
384+{
385+ port_id_t res;
386+
387+ res.b.domain = id.domain;
388+ res.b.area = id.area;
389+ res.b.al_pa = id.al_pa;
390+ res.b.rsvd_1 = 0;
391+
392+ return res;
393+}
394+
395+static inline be_id_t port_id_to_be_id(port_id_t port_id)
396+{
397+ be_id_t res;
398+
399+ res.domain = port_id.b.domain;
400+ res.area = port_id.b.area;
401+ res.al_pa = port_id.b.al_pa;
402+
403+ return res;
404+}
405+
346406 struct els_logo_payload {
347407 uint8_t opcode;
348408 uint8_t rsvd[3];
@@ -395,7 +455,7 @@ struct srb_iocb { · 46 unmodified lines
395455 struct els_logo_payload *els_logo_pyld;
396456 dma_addr_t els_logo_pyld_dma;
397457 } els_logo;
398− struct {
458+ struct els_plogi {
399459 #define ELS_DCMD_PLOGI 0x3
400460 uint32_t flags;
401461 uint32_t els_cmd;
@@ -537,6 +597,7 @@ typedef struct srb { · 135 unmodified lines
537597 wait_queue_head_t nvme_ls_waitq;
538598 struct fc_port *fcport;
539599 struct scsi_qla_host *vha;
600+ unsigned int start_timer:1;
540601 uint32_t handle;
541602 uint16_t flags;
542603 uint16_t type;
@@ -554,14 +615,22 @@ typedef struct srb { · 11 unmodified lines
554615 struct bsg_job *bsg_job;
555616 struct srb_cmd scmd;
556617 } u;
557− void (*done)(void *, int);
558− void (*free)(void *);
618+ /*
619+ * Report completion status @res and call sp_put(@sp). @res is
620+ * an NVMe status code, a SCSI result (e.g. DID_OK << 16) or a
621+ * QLA_* status value.
622+ */
623+ void (*done)(struct srb *sp, int res);
624+ /* Stop the timer and free @sp. Only used by the FCP code. */
625+ void (*free)(struct srb *sp);
626+ /*
627+ * Call nvme_private->fd->done() and free @sp. Only used by the NVMe
628+ * code.
629+ */
559630 void (*put_fn)(struct kref *kref);
560631 } srb_t;
561632
562633 #define GET_CMD_SP(sp) (sp->u.scmd.cmd)
563−#define SET_CMD_SP(sp, cmd) (sp->u.scmd.cmd = cmd)
564−#define GET_CMD_CTX_SP(sp) (sp->u.scmd.ctx)
565634
566635 #define GET_CMD_SENSE_LEN(sp) \
567636 (sp->u.scmd.request_sense_length)
@@ -921,6 +990,11 @@ struct mbx_cmd_32 { · 353 unmodified lines
921990 #define MBS_LINK_DOWN_ERROR 0x400B
922991 #define MBS_DIAG_ECHO_TEST_ERROR 0x400C
923992
993+static inline bool qla2xxx_is_valid_mbs(unsigned int mbs)
994+{
995+ return MBS_COMMAND_COMPLETE <= mbs && mbs <= MBS_DIAG_ECHO_TEST_ERROR;
996+}
997+
924998 /*
925999 * ISP mailbox asynchronous event status codes
9261000 */
@@ -1851,7 +1925,7 @@ struct crc_context { · 924 unmodified lines
18511925 uint16_t reserved_2;
18521926 uint16_t reserved_3;
18531927 uint32_t reserved_4;
1854− struct dsd64 data_dsd;
1928+ struct dsd64 data_dsd[1];
18551929 uint32_t reserved_5[2];
18561930 uint32_t reserved_6;
18571931 } nobundling;
@@ -1861,7 +1935,7 @@ struct crc_context { · 3 unmodified lines
18611935 uint16_t reserved_1;
18621936 __le16 dseg_count; /* Data segment count */
18631937 uint32_t reserved_2;
1864− struct dsd64 data_dsd;
1938+ struct dsd64 data_dsd[1];
18651939 struct dsd64 dif_dsd;
18661940 } bundling;
18671941 } u;
@@ -2289,22 +2363,6 @@ enum login_state { /* FW control Target side */ · 421 unmodified lines
22892363 DSC_LS_LOGO_PEND,
22902364 };
22912365
2292−enum fcport_mgt_event {
2293− FCME_RELOGIN = 1,
2294− FCME_RSCN,
2295− FCME_PLOGI_DONE, /* Initiator side sent LLIOCB */
2296− FCME_PRLI_DONE,
2297− FCME_GNL_DONE,
2298− FCME_GPSC_DONE,
2299− FCME_GPDB_DONE,
2300− FCME_GPNID_DONE,
2301− FCME_GFFID_DONE,
2302− FCME_ADISC_DONE,
2303− FCME_GNNID_DONE,
2304− FCME_GFPNID_DONE,
2305− FCME_ELS_PLOGI_DONE,
2306−};
2307−
23082366 enum rscn_addr_format {
23092367 RSCN_PORT_ADDR,
23102368 RSCN_AREA_ADDR,
@@ -2422,7 +2480,6 @@ typedef struct fc_port { · 111 unmodified lines
24222480 #define QLA_FCPORT_FOUND 2
24232481
24242482 struct event_arg {
2425− enum fcport_mgt_event event;
24262483 fc_port_t *fcport;
24272484 srb_t *sp;
24282485 port_id_t id;
@@ -2745,7 +2802,7 @@ struct ct_sns_req { · 316 unmodified lines
27452802 /* GA_NXT, GPN_ID, GNN_ID, GFT_ID, GFPN_ID */
27462803 struct {
27472804 uint8_t reserved;
2748− uint8_t port_id[3];
2805+ be_id_t port_id;
27492806 } port_id;
27502807
27512808 struct {
@@ -2764,13 +2821,13 @@ struct ct_sns_req { · 12 unmodified lines
27642821
27652822 struct {
27662823 uint8_t reserved;
2767− uint8_t port_id[3];
2824+ be_id_t port_id;
27682825 uint8_t fc4_types[32];
27692826 } rft_id;
27702827
27712828 struct {
27722829 uint8_t reserved;
2773− uint8_t port_id[3];
2830+ be_id_t port_id;
27742831 uint16_t reserved2;
27752832 uint8_t fc4_feature;
27762833 uint8_t fc4_type;
@@ -2778,7 +2835,7 @@ struct ct_sns_req { · 1 unmodified line
27782835
27792836 struct {
27802837 uint8_t reserved;
2781− uint8_t port_id[3];
2838+ be_id_t port_id;
27822839 uint8_t node_name[8];
27832840 } rnn_id;
27842841
@@ -2865,7 +2922,7 @@ struct ct_rsp_hdr { · 80 unmodified lines
28652922
28662923 struct ct_sns_gid_pt_data {
28672924 uint8_t control_byte;
2868− uint8_t port_id[3];
2925+ be_id_t port_id;
28692926 };
28702927
28712928 /* It's the same for both GPN_FT and GNN_FT */
@@ -2895,7 +2952,7 @@ struct ct_sns_rsp { · 23 unmodified lines
28952952 union {
28962953 struct {
28972954 uint8_t port_type;
2898− uint8_t port_id[3];
2955+ be_id_t port_id;
28992956 uint8_t port_name[8];
29002957 uint8_t sym_port_name_len;
29012958 uint8_t sym_port_name[255];
@@ -3111,7 +3168,7 @@ struct isp_operations { · 209 unmodified lines
31113168 void (*update_fw_options) (struct scsi_qla_host *);
31123169 int (*load_risc) (struct scsi_qla_host *, uint32_t *);
31133170
3114− char * (*pci_info_str) (struct scsi_qla_host *, char *);
3171+ char * (*pci_info_str)(struct scsi_qla_host *, char *, size_t);
31153172 char * (*fw_version_str)(struct scsi_qla_host *, char *, size_t);
31163173
31173174 irq_handler_t intr_handler;
@@ -3850,7 +3907,7 @@ struct qla_hw_data { · 732 unmodified lines
38503907
38513908 /* NVRAM configuration data */
38523909 #define MAX_NVRAM_SIZE 4096
3853−#define VPD_OFFSET MAX_NVRAM_SIZE / 2
3910+#define VPD_OFFSET (MAX_NVRAM_SIZE / 2)
38543911 uint16_t nvram_size;
38553912 uint16_t nvram_base;
38563913 void *nvram;
@@ -4628,6 +4685,7 @@ struct secure_flash_update_block_pk { · 771 unmodified lines
46284685 #define QLA_SUSPENDED 0x106
46294686 #define QLA_BUSY 0x107
46304687 #define QLA_ALREADY_REGISTERED 0x109
4688+#define QLA_OS_TIMER_EXPIRED 0x10a
46314689
46324690 #define NVRAM_DELAY() udelay(10)
46334691
drivers/scsi/qla2xxx/qla_dfs.c+3−6
@@ -57,10 +57,9 @@ qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused) · 56 unmodified lines
5757 {
5858 scsi_qla_host_t *vha = s->private;
5959 struct qla_hw_data *ha = vha->hw;
60− struct gid_list_info *gid_list;
60+ struct gid_list_info *gid_list, *gid;
6161 dma_addr_t gid_list_dma;
6262 fc_port_t fc_port;
63− char *id_iter;
6463 int rc, i;
6564 uint16_t entries, loop_id;
6665 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt;
@@ -82,13 +81,11 @@ qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused) · 15 unmodified lines
8281 if (rc != QLA_SUCCESS)
8382 goto out_free_id_list;
8483
85− id_iter = (char *)gid_list;
84+ gid = gid_list;
8685
8786 seq_puts(s, "Port Name Port ID Loop ID\n");
8887
8988 for (i = 0; i < entries; i++) {
90− struct gid_list_info *gid =
91− (struct gid_list_info *)id_iter;
9289 loop_id = le16_to_cpu(gid->loop_id);
9390 memset(&fc_port, 0, sizeof(fc_port_t));
9491
@@ -99,7 +96,7 @@ qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused) · 4 unmodified lines
9996 fc_port.port_name, fc_port.d_id.b.domain,
10097 fc_port.d_id.b.area, fc_port.d_id.b.al_pa,
10198 fc_port.loop_id);
102− id_iter += ha->gid_list_info_size;
99+ gid = (void *)gid + ha->gid_list_info_size;
103100 }
104101 out_free_id_list:
105102 dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha),
drivers/scsi/qla2xxx/qla_dsd.h+2−0
@@ -1,6 +1,8 @@
11 #ifndef _QLA_DSD_H_
22 #define _QLA_DSD_H_
33
4+#include <asm/unaligned.h>
5+
46 /* 32-bit data segment descriptor (8 bytes) */
57 struct dsd32 {
68 __le32 address;
drivers/scsi/qla2xxx/qla_fw.h+4−4
@@ -761,13 +761,13 @@ struct els_entry_24xx { · 760 unmodified lines
761761 #define ECF_CLR_PASSTHRU_PEND BIT_12
762762 #define ECF_INCL_FRAME_HDR BIT_11
763763
764− uint32_t rx_byte_count;
765− uint32_t tx_byte_count;
764+ __le32 rx_byte_count;
765+ __le32 tx_byte_count;
766766
767767 __le64 tx_address __packed; /* Data segment 0 address. */
768− uint32_t tx_len; /* Data segment 0 length. */
768+ __le32 tx_len; /* Data segment 0 length. */
769769 __le64 rx_address __packed; /* Data segment 1 address. */
770− uint32_t rx_len; /* Data segment 1 length. */
770+ __le32 rx_len; /* Data segment 1 length. */
771771 };
772772
773773 struct els_sts_entry_24xx {
drivers/scsi/qla2xxx/qla_gbl.h+20−13
@@ -45,6 +45,8 @@ extern int qla2x00_local_device_login(scsi_qla_host_t *, fc_port_t *); · 44 unmodified lines
4545
4646 extern int qla24xx_els_dcmd_iocb(scsi_qla_host_t *, int, port_id_t);
4747 extern int qla24xx_els_dcmd2_iocb(scsi_qla_host_t *, int, fc_port_t *, bool);
48+extern void qla2x00_els_dcmd2_free(scsi_qla_host_t *vha,
49+ struct els_plogi *els_plogi);
4850
4951 extern void qla2x00_update_fcports(scsi_qla_host_t *);
5052
@@ -96,7 +98,11 @@ extern int qla2x00_init_rings(scsi_qla_host_t *); · 45 unmodified lines
9698 extern struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *,
9799 int, int, bool);
98100 extern int qla2xxx_delete_qpair(struct scsi_qla_host *, struct qla_qpair *);
99−void qla2x00_fcport_event_handler(scsi_qla_host_t *, struct event_arg *);
101+void qla2x00_handle_rscn(scsi_qla_host_t *vha, struct event_arg *ea);
102+void qla24xx_handle_plogi_done_event(struct scsi_qla_host *vha,
103+ struct event_arg *ea);
104+void qla24xx_handle_relogin_event(scsi_qla_host_t *vha,
105+ struct event_arg *ea);
100106 int qla24xx_async_gpdb(struct scsi_qla_host *, fc_port_t *, u8);
101107 int qla24xx_async_prli(struct scsi_qla_host *, fc_port_t *);
102108 int qla24xx_async_notify_ack(scsi_qla_host_t *, fc_port_t *,
@@ -213,9 +219,9 @@ extern int qla2x00_post_uevent_work(struct scsi_qla_host *, u32); · 110 unmodified lines
213219
214220 extern int qla2x00_post_uevent_work(struct scsi_qla_host *, u32);
215221 extern void qla2x00_disable_board_on_pci_error(struct work_struct *);
216−extern void qla2x00_sp_compl(void *, int);
217−extern void qla2xxx_qpair_sp_free_dma(void *);
218−extern void qla2xxx_qpair_sp_compl(void *, int);
222+extern void qla2x00_sp_compl(srb_t *sp, int);
223+extern void qla2xxx_qpair_sp_free_dma(srb_t *sp);
224+extern void qla2xxx_qpair_sp_compl(srb_t *sp, int);
219225 extern void qla24xx_sched_upd_fcport(fc_port_t *);
220226 void qla2x00_handle_login_done_event(struct scsi_qla_host *, fc_port_t *,
221227 uint16_t *);
@@ -244,7 +250,7 @@ extern void qla2x00_do_dpc_all_vps(scsi_qla_host_t *); · 22 unmodified lines
244250 extern int qla24xx_vport_create_req_sanity_check(struct fc_vport *);
245251 extern scsi_qla_host_t *qla24xx_create_vhost(struct fc_vport *);
246252
247−extern void qla2x00_sp_free_dma(void *);
253+extern void qla2x00_sp_free_dma(srb_t *sp);
248254 extern char *qla2x00_get_fw_version_str(struct scsi_qla_host *, char *);
249255
250256 extern void qla2x00_mark_device_lost(scsi_qla_host_t *, fc_port_t *, int, int);
@@ -272,6 +278,7 @@ extern void qla2x00_build_scsi_iocbs_32(srb_t *, cmd_entry_t *, uint16_t); · 21 unmodified lines
272278 extern void qla2x00_build_scsi_iocbs_64(srb_t *, cmd_entry_t *, uint16_t);
273279 extern void qla24xx_build_scsi_iocbs(srb_t *, struct cmd_type_7 *,
274280 uint16_t, struct req_que *);
281+extern uint32_t qla2xxx_get_next_handle(struct req_que *req);
275282 extern int qla2x00_start_scsi(srb_t *sp);
276283 extern int qla24xx_start_scsi(srb_t *sp);
277284 int qla2x00_marker(struct scsi_qla_host *, struct qla_qpair *,
@@ -554,7 +561,7 @@ fc_port_t *qla2x00_find_fcport_by_nportid(scsi_qla_host_t *, port_id_t *, u8); · 276 unmodified lines
554561 * Global Function Prototypes in qla_sup.c source file.
555562 */
556563 extern void qla2x00_release_nvram_protection(scsi_qla_host_t *);
557−extern uint32_t *qla24xx_read_flash_data(scsi_qla_host_t *, uint32_t *,
564+extern int qla24xx_read_flash_data(scsi_qla_host_t *, uint32_t *,
558565 uint32_t, uint32_t);
559566 extern uint8_t *qla2x00_read_nvram_data(scsi_qla_host_t *, void *, uint32_t,
560567 uint32_t);
@@ -630,7 +637,7 @@ extern ulong qla27xx_fwdt_template_size(void *); · 69 unmodified lines
630637
631638 extern void qla2xxx_dump_post_process(scsi_qla_host_t *, int);
632639 extern void ql_dump_regs(uint, scsi_qla_host_t *, uint);
633−extern void ql_dump_buffer(uint, scsi_qla_host_t *, uint, void *, uint);
640+extern void ql_dump_buffer(uint, scsi_qla_host_t *, uint, const void *, uint);
634641 /*
635642 * Global Function Prototypes in qla_gs.c source file.
636643 */
@@ -732,7 +739,7 @@ extern int qlafx00_initialize_adapter(struct scsi_qla_host *); · 95 unmodified lines
732739 extern int qlafx00_soft_reset(scsi_qla_host_t *);
733740 extern int qlafx00_chip_diag(scsi_qla_host_t *);
734741 extern void qlafx00_config_rings(struct scsi_qla_host *);
735−extern char *qlafx00_pci_info_str(struct scsi_qla_host *, char *);
742+extern char *qlafx00_pci_info_str(struct scsi_qla_host *, char *, size_t);
736743 extern char *qlafx00_fw_version_str(struct scsi_qla_host *, char *, size_t);
737744 extern irqreturn_t qlafx00_intr_handler(int, void *);
738745 extern void qlafx00_enable_intrs(struct qla_hw_data *);
@@ -790,10 +797,10 @@ extern int qla82xx_restart_isp(scsi_qla_host_t *); · 51 unmodified lines
790797
791798 /* IOCB related functions */
792799 extern int qla82xx_start_scsi(srb_t *);
793−extern void qla2x00_sp_free(void *);
800+extern void qla2x00_sp_free(srb_t *sp);
794801 extern void qla2x00_sp_timeout(struct timer_list *);
795−extern void qla2x00_bsg_job_done(void *, int);
796−extern void qla2x00_bsg_sp_free(void *);
802+extern void qla2x00_bsg_job_done(srb_t *sp, int);
803+extern void qla2x00_bsg_sp_free(srb_t *sp);
797804 extern void qla2x00_start_iocbs(struct scsi_qla_host *, struct req_que *);
798805
799806 /* Interrupt related */
@@ -822,8 +829,8 @@ extern int qla82xx_device_state_handler(scsi_qla_host_t *); · 22 unmodified lines
822829 extern void qla8xxx_dev_failed_handler(scsi_qla_host_t *);
823830 extern void qla82xx_clear_qsnt_ready(scsi_qla_host_t *);
824831
825−extern void qla2x00_set_model_info(scsi_qla_host_t *, uint8_t *,
826− size_t, char *);
832+extern void qla2x00_set_model_info(scsi_qla_host_t *, uint8_t *, size_t,
833+ const char *);
827834 extern int qla82xx_mbx_intr_enable(scsi_qla_host_t *);
828835 extern int qla82xx_mbx_intr_disable(scsi_qla_host_t *);
829836 extern void qla82xx_start_iocbs(scsi_qla_host_t *);
drivers/scsi/qla2xxx/qla_gs.c+108−146
@@ -226,9 +226,7 @@ qla2x00_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport) · 225 unmodified lines
226226 ct_rsp = &ha->ct_sns->p.rsp;
227227
228228 /* Prepare CT arguments -- port_id */
229− ct_req->req.port_id.port_id[0] = fcport->d_id.b.domain;
230− ct_req->req.port_id.port_id[1] = fcport->d_id.b.area;
231− ct_req->req.port_id.port_id[2] = fcport->d_id.b.al_pa;
229+ ct_req->req.port_id.port_id = port_id_to_be_id(fcport->d_id);
232230
233231 /* Execute MS IOCB */
234232 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
@@ -242,9 +240,7 @@ qla2x00_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport) · 7 unmodified lines
242240 rval = QLA_FUNCTION_FAILED;
243241 } else {
244242 /* Populate fc_port_t entry. */
245− fcport->d_id.b.domain = ct_rsp->rsp.ga_nxt.port_id[0];
246− fcport->d_id.b.area = ct_rsp->rsp.ga_nxt.port_id[1];
247− fcport->d_id.b.al_pa = ct_rsp->rsp.ga_nxt.port_id[2];
243+ fcport->d_id = be_to_port_id(ct_rsp->rsp.ga_nxt.port_id);
248244
249245 memcpy(fcport->node_name, ct_rsp->rsp.ga_nxt.node_name,
250246 WWN_SIZE);
@@ -337,9 +333,7 @@ qla2x00_gid_pt(scsi_qla_host_t *vha, sw_info_t *list) · 86 unmodified lines
337333 /* Set port IDs in switch info list. */
338334 for (i = 0; i < ha->max_fibre_devices; i++) {
339335 gid_data = &ct_rsp->rsp.gid_pt.entries[i];
340− list[i].d_id.b.domain = gid_data->port_id[0];
341− list[i].d_id.b.area = gid_data->port_id[1];
342− list[i].d_id.b.al_pa = gid_data->port_id[2];
336+ list[i].d_id = be_to_port_id(gid_data->port_id);
343337 memset(list[i].fabric_port_name, 0, WWN_SIZE);
344338 list[i].fp_speed = PORT_SPEED_UNKNOWN;
345339
@@ -403,9 +397,7 @@ qla2x00_gpn_id(scsi_qla_host_t *vha, sw_info_t *list) · 57 unmodified lines
403397 ct_rsp = &ha->ct_sns->p.rsp;
404398
405399 /* Prepare CT arguments -- port_id */
406− ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
407− ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
408− ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
400+ ct_req->req.port_id.port_id = port_id_to_be_id(list[i].d_id);
409401
410402 /* Execute MS IOCB */
411403 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
@@ -472,9 +464,7 @@ qla2x00_gnn_id(scsi_qla_host_t *vha, sw_info_t *list) · 60 unmodified lines
472464 ct_rsp = &ha->ct_sns->p.rsp;
473465
474466 /* Prepare CT arguments -- port_id */
475− ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
476− ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
477− ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
467+ ct_req->req.port_id.port_id = port_id_to_be_id(list[i].d_id);
478468
479469 /* Execute MS IOCB */
480470 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
@@ -509,9 +499,8 @@ qla2x00_gnn_id(scsi_qla_host_t *vha, sw_info_t *list) · 28 unmodified lines
509499 return (rval);
510500 }
511501
512−static void qla2x00_async_sns_sp_done(void *s, int rc)
502+static void qla2x00_async_sns_sp_done(srb_t *sp, int rc)
513503 {
514− struct srb *sp = s;
515504 struct scsi_qla_host *vha = sp->vha;
516505 struct ct_sns_pkt *ct_sns;
517506 struct qla_work_evt *e;
@@ -639,9 +628,7 @@ static int qla_async_rftid(scsi_qla_host_t *vha, port_id_t *d_id) · 121 unmodified lines
639628 ct_req = qla2x00_prep_ct_req(ct_sns, RFT_ID_CMD, RFT_ID_RSP_SIZE);
640629
641630 /* Prepare CT arguments -- port_id, FC-4 types */
642− ct_req->req.rft_id.port_id[0] = vha->d_id.b.domain;
643− ct_req->req.rft_id.port_id[1] = vha->d_id.b.area;
644− ct_req->req.rft_id.port_id[2] = vha->d_id.b.al_pa;
631+ ct_req->req.rft_id.port_id = port_id_to_be_id(vha->d_id);
645632 ct_req->req.rft_id.fc4_types[2] = 0x01; /* FCP-3 */
646633
647634 if (vha->flags.nvme_enabled)
@@ -737,9 +724,7 @@ static int qla_async_rffid(scsi_qla_host_t *vha, port_id_t *d_id, · 89 unmodified lines
737724 ct_req = qla2x00_prep_ct_req(ct_sns, RFF_ID_CMD, RFF_ID_RSP_SIZE);
738725
739726 /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */
740− ct_req->req.rff_id.port_id[0] = d_id->b.domain;
741− ct_req->req.rff_id.port_id[1] = d_id->b.area;
742− ct_req->req.rff_id.port_id[2] = d_id->b.al_pa;
727+ ct_req->req.rff_id.port_id = port_id_to_be_id(*d_id);
743728 ct_req->req.rff_id.fc4_feature = fc4feature;
744729 ct_req->req.rff_id.fc4_type = fc4type; /* SCSI - FCP */
745730
@@ -830,9 +815,7 @@ static int qla_async_rnnid(scsi_qla_host_t *vha, port_id_t *d_id, · 84 unmodified lines
830815 ct_req = qla2x00_prep_ct_req(ct_sns, RNN_ID_CMD, RNN_ID_RSP_SIZE);
831816
832817 /* Prepare CT arguments -- port_id, node_name */
833− ct_req->req.rnn_id.port_id[0] = vha->d_id.b.domain;
834− ct_req->req.rnn_id.port_id[1] = vha->d_id.b.area;
835− ct_req->req.rnn_id.port_id[2] = vha->d_id.b.al_pa;
818+ ct_req->req.rnn_id.port_id = port_id_to_be_id(vha->d_id);
836819 memcpy(ct_req->req.rnn_id.node_name, vha->node_name, WWN_SIZE);
837820
838821 sp->u.iocb_cmd.u.ctarg.req_size = RNN_ID_REQ_SIZE;
@@ -1479,7 +1462,7 @@ qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size, · 640 unmodified lines
14791462 return ct_pkt;
14801463 }
14811464
1482−static inline ms_iocb_entry_t *
1465+static void
14831466 qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size)
14841467 {
14851468 struct qla_hw_data *ha = vha->hw;
@@ -1493,8 +1476,6 @@ qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size) · 7 unmodified lines
14931476 ms_pkt->req_bytecount = cpu_to_le32(req_size);
14941477 ms_pkt->req_dsd.length = ms_pkt->req_bytecount;
14951478 }
1496−
1497− return ms_pkt;
14981479 }
14991480
15001481 /**
@@ -1557,7 +1538,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *vha) · 56 unmodified lines
15571538 /* Attributes */
15581539 ct_req->req.rhba.attrs.count =
15591540 cpu_to_be32(FDMI_HBA_ATTR_COUNT);
1560− entries = ct_req->req.rhba.hba_identifier;
1541+ entries = &ct_req->req;
15611542
15621543 /* Nodename. */
15631544 eiter = entries + size;
@@ -1766,7 +1747,7 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *vha) · 202 unmodified lines
17661747
17671748 /* Attributes */
17681749 ct_req->req.rpa.attrs.count = cpu_to_be32(FDMI_PORT_ATTR_COUNT);
1769− entries = ct_req->req.rpa.port_name;
1750+ entries = &ct_req->req;
17701751
17711752 /* FC4 types. */
17721753 eiter = entries + size;
@@ -1979,7 +1960,7 @@ qla2x00_fdmiv2_rhba(scsi_qla_host_t *vha) · 206 unmodified lines
19791960
19801961 /* Attributes */
19811962 ct_req->req.rhba2.attrs.count = cpu_to_be32(FDMIV2_HBA_ATTR_COUNT);
1982− entries = ct_req->req.rhba2.hba_identifier;
1963+ entries = &ct_req->req;
19831964
19841965 /* Nodename. */
19851966 eiter = entries + size;
@@ -2338,7 +2319,7 @@ qla2x00_fdmiv2_rpa(scsi_qla_host_t *vha) · 352 unmodified lines
23382319
23392320 /* Attributes */
23402321 ct_req->req.rpa2.attrs.count = cpu_to_be32(FDMIV2_PORT_ATTR_COUNT);
2341− entries = ct_req->req.rpa2.port_name;
2322+ entries = &ct_req->req;
23422323
23432324 /* FC4 types. */
23442325 eiter = entries + size;
@@ -2730,9 +2711,7 @@ qla2x00_gfpn_id(scsi_qla_host_t *vha, sw_info_t *list) · 385 unmodified lines
27302711 ct_rsp = &ha->ct_sns->p.rsp;
27312712
27322713 /* Prepare CT arguments -- port_id */
2733− ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
2734− ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
2735− ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
2714+ ct_req->req.port_id.port_id = port_id_to_be_id(list[i].d_id);
27362715
27372716 /* Execute MS IOCB */
27382717 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
@@ -2936,9 +2915,7 @@ qla2x00_gff_id(scsi_qla_host_t *vha, sw_info_t *list) · 197 unmodified lines
29362915 ct_rsp = &ha->ct_sns->p.rsp;
29372916
29382917 /* Prepare CT arguments -- port_id */
2939− ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
2940− ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
2941− ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
2918+ ct_req->req.port_id.port_id = port_id_to_be_id(list[i].d_id);
29422919
29432920 /* Execute MS IOCB */
29442921 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
@@ -3011,9 +2988,8 @@ void qla24xx_handle_gpsc_event(scsi_qla_host_t *vha, struct event_arg *ea) · 66 unmodified lines
30112988 qla_post_iidma_work(vha, fcport);
30122989 }
30132990
3014−static void qla24xx_async_gpsc_sp_done(void *s, int res)
2991+static void qla24xx_async_gpsc_sp_done(srb_t *sp, int res)
30152992 {
3016− struct srb *sp = s;
30172993 struct scsi_qla_host *vha = sp->vha;
30182994 struct qla_hw_data *ha = vha->hw;
30192995 fc_port_t *fcport = sp->fcport;
@@ -3055,11 +3031,10 @@ static void qla24xx_async_gpsc_sp_done(void *s, int res) · 35 unmodified lines
30553031 be16_to_cpu(ct_rsp->rsp.gpsc.speed));
30563032 }
30573033 memset(&ea, 0, sizeof(ea));
3058− ea.event = FCME_GPSC_DONE;
30593034 ea.rc = res;
30603035 ea.fcport = fcport;
30613036 ea.sp = sp;
3062− qla2x00_fcport_event_handler(vha, &ea);
3037+ qla24xx_handle_gpsc_event(vha, &ea);
30633038
30643039 done:
30653040 sp->free(sp);
@@ -3144,17 +3119,7 @@ void qla24xx_sp_unmap(scsi_qla_host_t *vha, srb_t *sp) · 78 unmodified lines
31443119
31453120 switch (sp->type) {
31463121 case SRB_ELS_DCMD:
3147− if (c->u.els_plogi.els_plogi_pyld)
3148− dma_free_coherent(&vha->hw->pdev->dev,
3149− c->u.els_plogi.tx_size,
3150− c->u.els_plogi.els_plogi_pyld,
3151− c->u.els_plogi.els_plogi_pyld_dma);
3152−
3153− if (c->u.els_plogi.els_resp_pyld)
3154− dma_free_coherent(&vha->hw->pdev->dev,
3155− c->u.els_plogi.rx_size,
3156− c->u.els_plogi.els_resp_pyld,
3157− c->u.els_plogi.els_resp_pyld_dma);
3122+ qla2x00_els_dcmd2_free(vha, &c->u.els_plogi);
31583123 break;
31593124 case SRB_CT_PTHRU_CMD:
31603125 default:
@@ -3280,9 +3245,8 @@ void qla24xx_handle_gpnid_event(scsi_qla_host_t *vha, struct event_arg *ea) · 119 unmodified lines
32803245 }
32813246 }
32823247
3283−static void qla2x00_async_gpnid_sp_done(void *s, int res)
3248+static void qla2x00_async_gpnid_sp_done(srb_t *sp, int res)
32843249 {
3285− struct srb *sp = s;
32863250 struct scsi_qla_host *vha = sp->vha;
32873251 struct ct_sns_req *ct_req =
32883252 (struct ct_sns_req *)sp->u.iocb_cmd.u.ctarg.req;
@@ -3295,22 +3259,19 @@ static void qla2x00_async_gpnid_sp_done(void *s, int res) · 6 unmodified lines
32953259 if (res)
32963260 ql_dbg(ql_dbg_disc, vha, 0x2066,
32973261 "Async done-%s fail res %x rscn gen %d ID %3phC. %8phC\n",
3298− sp->name, res, sp->gen1, ct_req->req.port_id.port_id,
3262+ sp->name, res, sp->gen1, &ct_req->req.port_id.port_id,
32993263 ct_rsp->rsp.gpn_id.port_name);
33003264 else
33013265 ql_dbg(ql_dbg_disc, vha, 0x2066,
33023266 "Async done-%s good rscn gen %d ID %3phC. %8phC\n",
3303− sp->name, sp->gen1, ct_req->req.port_id.port_id,
3267+ sp->name, sp->gen1, &ct_req->req.port_id.port_id,
33043268 ct_rsp->rsp.gpn_id.port_name);
33053269
33063270 memset(&ea, 0, sizeof(ea));
33073271 memcpy(ea.port_name, ct_rsp->rsp.gpn_id.port_name, WWN_SIZE);
33083272 ea.sp = sp;
3309− ea.id.b.domain = ct_req->req.port_id.port_id[0];
3310− ea.id.b.area = ct_req->req.port_id.port_id[1];
3311− ea.id.b.al_pa = ct_req->req.port_id.port_id[2];
3273+ ea.id = be_to_port_id(ct_req->req.port_id.port_id);
33123274 ea.rc = res;
3313− ea.event = FCME_GPNID_DONE;
33143275
33153276 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags);
33163277 list_del(&sp->elem);
@@ -3329,25 +3290,22 @@ static void qla2x00_async_gpnid_sp_done(void *s, int res) · 12 unmodified lines
33293290 return;
33303291 }
33313292
3332− qla2x00_fcport_event_handler(vha, &ea);
3293+ qla24xx_handle_gpnid_event(vha, &ea);
33333294
33343295 e = qla2x00_alloc_work(vha, QLA_EVT_UNMAP);
33353296 if (!e) {
33363297 /* please ignore kernel warning. otherwise, we have mem leak. */
3337− if (sp->u.iocb_cmd.u.ctarg.req) {
3338− dma_free_coherent(&vha->hw->pdev->dev,
3339− sp->u.iocb_cmd.u.ctarg.req_allocated_size,
3340− sp->u.iocb_cmd.u.ctarg.req,
3341− sp->u.iocb_cmd.u.ctarg.req_dma);
3342− sp->u.iocb_cmd.u.ctarg.req = NULL;
3343− }
3344− if (sp->u.iocb_cmd.u.ctarg.rsp) {
3345− dma_free_coherent(&vha->hw->pdev->dev,
3346− sp->u.iocb_cmd.u.ctarg.rsp_allocated_size,
3347− sp->u.iocb_cmd.u.ctarg.rsp,
3348− sp->u.iocb_cmd.u.ctarg.rsp_dma);
3349− sp->u.iocb_cmd.u.ctarg.rsp = NULL;
3350− }
3298+ dma_free_coherent(&vha->hw->pdev->dev,
3299+ sp->u.iocb_cmd.u.ctarg.req_allocated_size,
3300+ sp->u.iocb_cmd.u.ctarg.req,
3301+ sp->u.iocb_cmd.u.ctarg.req_dma);
3302+ sp->u.iocb_cmd.u.ctarg.req = NULL;
3303+
3304+ dma_free_coherent(&vha->hw->pdev->dev,
3305+ sp->u.iocb_cmd.u.ctarg.rsp_allocated_size,
3306+ sp->u.iocb_cmd.u.ctarg.rsp,
3307+ sp->u.iocb_cmd.u.ctarg.rsp_dma);
3308+ sp->u.iocb_cmd.u.ctarg.rsp = NULL;
33513309
33523310 sp->free(sp);
33533311 return;
@@ -3419,9 +3377,7 @@ int qla24xx_async_gpnid(scsi_qla_host_t *vha, port_id_t *id) · 65 unmodified lines
34193377 ct_req = qla2x00_prep_ct_req(ct_sns, GPN_ID_CMD, GPN_ID_RSP_SIZE);
34203378
34213379 /* GPN_ID req */
3422− ct_req->req.port_id.port_id[0] = id->b.domain;
3423− ct_req->req.port_id.port_id[1] = id->b.area;
3424− ct_req->req.port_id.port_id[2] = id->b.al_pa;
3380+ ct_req->req.port_id.port_id = port_id_to_be_id(*id);
34253381
34263382 sp->u.iocb_cmd.u.ctarg.req_size = GPN_ID_REQ_SIZE;
34273383 sp->u.iocb_cmd.u.ctarg.rsp_size = GPN_ID_RSP_SIZE;
@@ -3432,7 +3388,7 @@ int qla24xx_async_gpnid(scsi_qla_host_t *vha, port_id_t *id) · 4 unmodified lines
34323388
34333389 ql_dbg(ql_dbg_disc, vha, 0x2067,
34343390 "Async-%s hdl=%x ID %3phC.\n", sp->name,
3435− sp->handle, ct_req->req.port_id.port_id);
3391+ sp->handle, &ct_req->req.port_id.port_id);
34363392
34373393 rval = qla2x00_start_sp(sp);
34383394 if (rval != QLA_SUCCESS)
@@ -3467,54 +3423,52 @@ done: · 28 unmodified lines
34673423
34683424 void qla24xx_handle_gffid_event(scsi_qla_host_t *vha, struct event_arg *ea)
34693425 {
3470− fc_port_t *fcport = ea->fcport;
3426+ fc_port_t *fcport = ea->fcport;
34713427
3472− qla24xx_post_gnl_work(vha, fcport);
3428+ qla24xx_post_gnl_work(vha, fcport);
34733429 }
34743430
3475−void qla24xx_async_gffid_sp_done(void *s, int res)
3431+void qla24xx_async_gffid_sp_done(srb_t *sp, int res)
34763432 {
3477− struct srb *sp = s;
3478− struct scsi_qla_host *vha = sp->vha;
3479− fc_port_t *fcport = sp->fcport;
3480− struct ct_sns_rsp *ct_rsp;
3481− struct event_arg ea;
3482−
3483− ql_dbg(ql_dbg_disc, vha, 0x2133,
3484− "Async done-%s res %x ID %x. %8phC\n",
3485− sp->name, res, fcport->d_id.b24, fcport->port_name);
3486−
3487− fcport->flags &= ~FCF_ASYNC_SENT;
3488− ct_rsp = &fcport->ct_desc.ct_sns->p.rsp;
3489− /*
3490− * FC-GS-7, 5.2.3.12 FC-4 Features - format
3491− * The format of the FC-4 Features object, as defined by the FC-4,
3492− * Shall be an array of 4-bit values, one for each type code value
3493− */
3494− if (!res) {
3495− if (ct_rsp->rsp.gff_id.fc4_features[GFF_FCP_SCSI_OFFSET] & 0xf) {
3496− /* w1 b00:03 */
3497− fcport->fc4_type =
3498− ct_rsp->rsp.gff_id.fc4_features[GFF_FCP_SCSI_OFFSET];
3499− fcport->fc4_type &= 0xf;
3500− }
3433+ struct scsi_qla_host *vha = sp->vha;
3434+ fc_port_t *fcport = sp->fcport;
3435+ struct ct_sns_rsp *ct_rsp;
3436+ struct event_arg ea;
35013437
3502− if (ct_rsp->rsp.gff_id.fc4_features[GFF_NVME_OFFSET] & 0xf) {
3503− /* w5 [00:03]/28h */
3504− fcport->fc4f_nvme =
3505− ct_rsp->rsp.gff_id.fc4_features[GFF_NVME_OFFSET];
3506− fcport->fc4f_nvme &= 0xf;
3438+ ql_dbg(ql_dbg_disc, vha, 0x2133,
3439+ "Async done-%s res %x ID %x. %8phC\n",
3440+ sp->name, res, fcport->d_id.b24, fcport->port_name);
3441+
3442+ fcport->flags &= ~FCF_ASYNC_SENT;
3443+ ct_rsp = &fcport->ct_desc.ct_sns->p.rsp;
3444+ /*
3445+ * FC-GS-7, 5.2.3.12 FC-4 Features - format
3446+ * The format of the FC-4 Features object, as defined by the FC-4,
3447+ * Shall be an array of 4-bit values, one for each type code value
3448+ */
3449+ if (!res) {
3450+ if (ct_rsp->rsp.gff_id.fc4_features[GFF_FCP_SCSI_OFFSET] & 0xf) {
3451+ /* w1 b00:03 */
3452+ fcport->fc4_type =
3453+ ct_rsp->rsp.gff_id.fc4_features[GFF_FCP_SCSI_OFFSET];
3454+ fcport->fc4_type &= 0xf;
35073455 }
3508− }
35093456
3510− memset(&ea, 0, sizeof(ea));
3511− ea.sp = sp;
3512− ea.fcport = sp->fcport;
3513− ea.rc = res;
3514− ea.event = FCME_GFFID_DONE;
3457+ if (ct_rsp->rsp.gff_id.fc4_features[GFF_NVME_OFFSET] & 0xf) {
3458+ /* w5 [00:03]/28h */
3459+ fcport->fc4f_nvme =
3460+ ct_rsp->rsp.gff_id.fc4_features[GFF_NVME_OFFSET];
3461+ fcport->fc4f_nvme &= 0xf;
3462+ }
3463+ }
3464+
3465+ memset(&ea, 0, sizeof(ea));
3466+ ea.sp = sp;
3467+ ea.fcport = sp->fcport;
3468+ ea.rc = res;
35153469
3516− qla2x00_fcport_event_handler(vha, &ea);
3517− sp->free(sp);
3470+ qla24xx_handle_gffid_event(vha, &ea);
3471+ sp->free(sp);
35183472 }
35193473
35203474 /* Get FC4 Feature with Nport ID. */
@@ -3674,7 +3628,6 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t *sp) · 153 unmodified lines
36743628 list_for_each_entry(fcport, &vha->vp_fcports, list) {
36753629 if (memcmp(rp->port_name, fcport->port_name, WWN_SIZE))
36763630 continue;
3677− fcport->scan_needed = 0;
36783631 fcport->scan_state = QLA_FCPORT_FOUND;
36793632 found = true;
36803633 /*
@@ -3683,10 +3636,12 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t *sp) · 2 unmodified lines
36833636 if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) {
36843637 qla2x00_clear_loop_id(fcport);
36853638 fcport->flags |= FCF_FABRIC_DEVICE;
3686− } else if (fcport->d_id.b24 != rp->id.b24) {
3639+ } else if (fcport->d_id.b24 != rp->id.b24 ||
3640+ fcport->scan_needed) {
36873641 qlt_schedule_sess_for_deletion(fcport);
36883642 }
36893643 fcport->d_id.b24 = rp->id.b24;
3644+ fcport->scan_needed = 0;
36903645 break;
36913646 }
36923647
@@ -3898,9 +3853,8 @@ static void qla2x00_find_free_fcp_nvme_slot(struct scsi_qla_host *vha, · 205 unmodified lines
38983853 }
38993854 }
39003855
3901−static void qla2x00_async_gpnft_gnnft_sp_done(void *s, int res)
3856+static void qla2x00_async_gpnft_gnnft_sp_done(srb_t *sp, int res)
39023857 {
3903− struct srb *sp = s;
39043858 struct scsi_qla_host *vha = sp->vha;
39053859 struct ct_sns_req *ct_req =
39063860 (struct ct_sns_req *)sp->u.iocb_cmd.u.ctarg.req;
@@ -4053,9 +4007,6 @@ static int qla24xx_async_gnnft(scsi_qla_host_t *vha, struct srb *sp, · 146 unmodified lines
40534007
40544008 rval = qla2x00_start_sp(sp);
40554009 if (rval != QLA_SUCCESS) {
4056− spin_lock_irqsave(&vha->work_lock, flags);
4057− vha->scan.scan_flags &= ~SF_SCANNING;
4058− spin_unlock_irqrestore(&vha->work_lock, flags);
40594010 goto done_free_sp;
40604011 }
40614012
@@ -4079,6 +4030,17 @@ done_free_sp: · 17 unmodified lines
40794030
40804031 sp->free(sp);
40814032
4033+ spin_lock_irqsave(&vha->work_lock, flags);
4034+ vha->scan.scan_flags &= ~SF_SCANNING;
4035+ if (vha->scan.scan_flags == 0) {
4036+ ql_dbg(ql_dbg_disc, vha, 0xffff,
4037+ "%s: schedule\n", __func__);
4038+ vha->scan.scan_flags |= SF_QUEUED;
4039+ schedule_delayed_work(&vha->scan.scan_work, 5);
4040+ }
4041+ spin_unlock_irqrestore(&vha->work_lock, flags);
4042+
4043+
40824044 return rval;
40834045 } /* GNNFT */
40844046
@@ -4152,7 +4114,7 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type, srb_t *sp) · 67 unmodified lines
41524114 rspsz,
41534115 &sp->u.iocb_cmd.u.ctarg.rsp_dma,
41544116 GFP_KERNEL);
4155− sp->u.iocb_cmd.u.ctarg.rsp_allocated_size = sizeof(struct ct_sns_pkt);
4117+ sp->u.iocb_cmd.u.ctarg.rsp_allocated_size = rspsz;
41564118 if (!sp->u.iocb_cmd.u.ctarg.rsp) {
41574119 ql_log(ql_log_warn, vha, 0xffff,
41584120 "Failed to allocate ct_sns request.\n");
@@ -4208,9 +4170,6 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type, srb_t *sp) · 49 unmodified lines
42084170
42094171 rval = qla2x00_start_sp(sp);
42104172 if (rval != QLA_SUCCESS) {
4211− spin_lock_irqsave(&vha->work_lock, flags);
4212− vha->scan.scan_flags &= ~SF_SCANNING;
4213− spin_unlock_irqrestore(&vha->work_lock, flags);
42144173 goto done_free_sp;
42154174 }
42164175
@@ -4234,6 +4193,17 @@ done_free_sp: · 17 unmodified lines
42344193
42354194 sp->free(sp);
42364195
4196+ spin_lock_irqsave(&vha->work_lock, flags);
4197+ vha->scan.scan_flags &= ~SF_SCANNING;
4198+ if (vha->scan.scan_flags == 0) {
4199+ ql_dbg(ql_dbg_disc, vha, 0xffff,
4200+ "%s: schedule\n", __func__);
4201+ vha->scan.scan_flags |= SF_QUEUED;
4202+ schedule_delayed_work(&vha->scan.scan_work, 5);
4203+ }
4204+ spin_unlock_irqrestore(&vha->work_lock, flags);
4205+
4206+
42374207 return rval;
42384208 }
42394209
@@ -4261,9 +4231,8 @@ void qla24xx_handle_gnnid_event(scsi_qla_host_t *vha, struct event_arg *ea) · 21 unmodified lines
42614231 qla24xx_post_gnl_work(vha, ea->fcport);
42624232 }
42634233
4264−static void qla2x00_async_gnnid_sp_done(void *s, int res)
4234+static void qla2x00_async_gnnid_sp_done(srb_t *sp, int res)
42654235 {
4266− struct srb *sp = s;
42674236 struct scsi_qla_host *vha = sp->vha;
42684237 fc_port_t *fcport = sp->fcport;
42694238 u8 *node_name = fcport->ct_desc.ct_sns->p.rsp.rsp.gnn_id.node_name;
@@ -4279,13 +4248,12 @@ static void qla2x00_async_gnnid_sp_done(void *s, int res) · 9 unmodified lines
42794248 ea.fcport = fcport;
42804249 ea.sp = sp;
42814250 ea.rc = res;
4282− ea.event = FCME_GNNID_DONE;
42834251
42844252 ql_dbg(ql_dbg_disc, vha, 0x204f,
42854253 "Async done-%s res %x, WWPN %8phC %8phC\n",
42864254 sp->name, res, fcport->port_name, fcport->node_name);
42874255
4288− qla2x00_fcport_event_handler(vha, &ea);
4256+ qla24xx_handle_gnnid_event(vha, &ea);
42894257
42904258 sp->free(sp);
42914259 }
@@ -4318,9 +4286,7 @@ int qla24xx_async_gnnid(scsi_qla_host_t *vha, fc_port_t *fcport) · 26 unmodified lines
43184286 GNN_ID_RSP_SIZE);
43194287
43204288 /* GNN_ID req */
4321− ct_req->req.port_id.port_id[0] = fcport->d_id.b.domain;
4322− ct_req->req.port_id.port_id[1] = fcport->d_id.b.area;
4323− ct_req->req.port_id.port_id[2] = fcport->d_id.b.al_pa;
4289+ ct_req->req.port_id.port_id = port_id_to_be_id(fcport->d_id);
43244290
43254291
43264292 /* req & rsp use the same buffer */
@@ -4396,9 +4362,8 @@ void qla24xx_handle_gfpnid_event(scsi_qla_host_t *vha, struct event_arg *ea) · 69 unmodified lines
43964362 qla24xx_post_gpsc_work(vha, fcport);
43974363 }
43984364
4399−static void qla2x00_async_gfpnid_sp_done(void *s, int res)
4365+static void qla2x00_async_gfpnid_sp_done(srb_t *sp, int res)
44004366 {
4401− struct srb *sp = s;
44024367 struct scsi_qla_host *vha = sp->vha;
44034368 fc_port_t *fcport = sp->fcport;
44044369 u8 *fpn = fcport->ct_desc.ct_sns->p.rsp.rsp.gfpn_id.port_name;
@@ -4413,13 +4378,12 @@ static void qla2x00_async_gfpnid_sp_done(void *s, int res) · 8 unmodified lines
44134378 ea.fcport = fcport;
44144379 ea.sp = sp;
44154380 ea.rc = res;
4416− ea.event = FCME_GFPNID_DONE;
44174381
44184382 ql_dbg(ql_dbg_disc, vha, 0x204f,
44194383 "Async done-%s res %x, WWPN %8phC %8phC\n",
44204384 sp->name, res, fcport->port_name, fcport->fabric_port_name);
44214385
4422− qla2x00_fcport_event_handler(vha, &ea);
4386+ qla24xx_handle_gfpnid_event(vha, &ea);
44234387
44244388 sp->free(sp);
44254389 }
@@ -4450,9 +4414,7 @@ int qla24xx_async_gfpnid(scsi_qla_host_t *vha, fc_port_t *fcport) · 24 unmodified lines
44504414 GFPN_ID_RSP_SIZE);
44514415
44524416 /* GFPN_ID req */
4453− ct_req->req.port_id.port_id[0] = fcport->d_id.b.domain;
4454− ct_req->req.port_id.port_id[1] = fcport->d_id.b.area;
4455− ct_req->req.port_id.port_id[2] = fcport->d_id.b.al_pa;
4417+ ct_req->req.port_id.port_id = port_id_to_be_id(fcport->d_id);
44564418
44574419
44584420 /* req & rsp use the same buffer */
drivers/scsi/qla2xxx/qla_init.c+245−305
@@ -37,8 +37,8 @@ static struct qla_chip_state_84xx *qla84xx_get_chip(struct scsi_qla_host *); · 36 unmodified lines
3737 static int qla84xx_init_chip(scsi_qla_host_t *);
3838 static int qla25xx_init_queues(struct qla_hw_data *);
3939 static int qla24xx_post_prli_work(struct scsi_qla_host*, fc_port_t *);
40−static void qla24xx_handle_plogi_done_event(struct scsi_qla_host *,
41− struct event_arg *);
40+static void qla24xx_handle_gpdb_event(scsi_qla_host_t *vha,
41+ struct event_arg *ea);
4242 static void qla24xx_handle_prli_done_event(struct scsi_qla_host *,
4343 struct event_arg *);
4444 static void __qla24xx_handle_gpdb_event(scsi_qla_host_t *, struct event_arg *);
@@ -63,10 +63,8 @@ qla2x00_sp_timeout(struct timer_list *t) · 18 unmodified lines
6363 iocb->timeout(sp);
6464 }
6565
66−void
67−qla2x00_sp_free(void *ptr)
66+void qla2x00_sp_free(srb_t *sp)
6867 {
69− srb_t *sp = ptr;
7068 struct srb_iocb *iocb = &sp->u.iocb_cmd;
7169
7270 del_timer(&iocb->timer);
@@ -99,22 +97,33 @@ static void qla24xx_abort_iocb_timeout(void *data) · 26 unmodified lines
9997 {
10098 srb_t *sp = data;
10199 struct srb_iocb *abt = &sp->u.iocb_cmd;
100+ struct qla_qpair *qpair = sp->qpair;
101+ u32 handle;
102+ unsigned long flags;
103+
104+ spin_lock_irqsave(qpair->qp_lock_ptr, flags);
105+ for (handle = 1; handle < qpair->req->num_outstanding_cmds; handle++) {
106+ /* removing the abort */
107+ if (qpair->req->outstanding_cmds[handle] == sp) {
108+ qpair->req->outstanding_cmds[handle] = NULL;
109+ break;
110+ }
111+ }
112+ spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
102113
103114 abt->u.abt.comp_status = CS_TIMEOUT;
104− sp->done(sp, QLA_FUNCTION_TIMEOUT);
115+ sp->done(sp, QLA_OS_TIMER_EXPIRED);
105116 }
106117
107−static void qla24xx_abort_sp_done(void *ptr, int res)
118+static void qla24xx_abort_sp_done(srb_t *sp, int res)
108119 {
109− srb_t *sp = ptr;
110120 struct srb_iocb *abt = &sp->u.iocb_cmd;
111121
112− if (del_timer(&sp->u.iocb_cmd.timer)) {
113− if (sp->flags & SRB_WAKEUP_ON_COMP)
114− complete(&abt->u.abt.comp);
115− else
116− sp->free(sp);
117− }
122+ del_timer(&sp->u.iocb_cmd.timer);
123+ if (sp->flags & SRB_WAKEUP_ON_COMP)
124+ complete(&abt->u.abt.comp);
125+ else
126+ sp->free(sp);
118127 }
119128
120129 static int qla24xx_async_abort_cmd(srb_t *cmd_sp, bool wait)
@@ -127,7 +136,7 @@ static int qla24xx_async_abort_cmd(srb_t *cmd_sp, bool wait) · 6 unmodified lines
127136 sp = qla2xxx_get_qpair_sp(cmd_sp->vha, cmd_sp->qpair, cmd_sp->fcport,
128137 GFP_ATOMIC);
129138 if (!sp)
130− goto done;
139+ return rval;
131140
132141 abt_iocb = &sp->u.iocb_cmd;
133142 sp->type = SRB_ABT_CMD;
@@ -151,20 +160,18 @@ static int qla24xx_async_abort_cmd(srb_t *cmd_sp, bool wait) · 17 unmodified lines
151160 cmd_sp->type);
152161
153162 rval = qla2x00_start_sp(sp);
154− if (rval != QLA_SUCCESS)
155− goto done_free_sp;
163+ if (rval != QLA_SUCCESS) {
164+ sp->free(sp);
165+ return rval;
166+ }
156167
157168 if (wait) {
158169 wait_for_completion(&abt_iocb->u.abt.comp);
159170 rval = abt_iocb->u.abt.comp_status == CS_COMPLETE ?
160171 QLA_SUCCESS : QLA_FUNCTION_FAILED;
161− } else {
162− goto done;
172+ sp->free(sp);
163173 }
164174
165−done_free_sp:
166− sp->free(sp);
167−done:
168175 return rval;
169176 }
170177
@@ -234,13 +241,15 @@ qla2x00_async_iocb_timeout(void *data) · 63 unmodified lines
234241 sp->done(sp, QLA_FUNCTION_TIMEOUT);
235242 }
236243 break;
244+ default:
245+ WARN_ON_ONCE(true);
246+ sp->done(sp, QLA_FUNCTION_TIMEOUT);
247+ break;
237248 }
238249 }
239250
240−static void
241−qla2x00_async_login_sp_done(void *ptr, int res)
251+static void qla2x00_async_login_sp_done(srb_t *sp, int res)
242252 {
243− srb_t *sp = ptr;
244253 struct scsi_qla_host *vha = sp->vha;
245254 struct srb_iocb *lio = &sp->u.iocb_cmd;
246255 struct event_arg ea;
@@ -252,14 +261,13 @@ qla2x00_async_login_sp_done(void *ptr, int res) · 5 unmodified lines
252261
253262 if (!test_bit(UNLOADING, &vha->dpc_flags)) {
254263 memset(&ea, 0, sizeof(ea));
255− ea.event = FCME_PLOGI_DONE;
256264 ea.fcport = sp->fcport;
257265 ea.data[0] = lio->u.logio.data[0];
258266 ea.data[1] = lio->u.logio.data[1];
259267 ea.iop[0] = lio->u.logio.iop[0];
260268 ea.iop[1] = lio->u.logio.iop[1];
261269 ea.sp = sp;
262− qla2x00_fcport_event_handler(vha, &ea);
270+ qla24xx_handle_plogi_done_event(vha, &ea);
263271 }
264272
265273 sp->free(sp);
@@ -289,8 +297,13 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport, · 23 unmodified lines
289297 struct srb_iocb *lio;
290298 int rval = QLA_FUNCTION_FAILED;
291299
292− if (!vha->flags.online)
293− goto done;
300+ if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT) ||
301+ fcport->loop_id == FC_NO_LOOP_ID) {
302+ ql_log(ql_log_warn, vha, 0xffff,
303+ "%s: %8phC - not sending command.\n",
304+ __func__, fcport->port_name);
305+ return rval;
306+ }
294307
295308 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
296309 if (!sp)
@@ -341,11 +354,8 @@ done: · 44 unmodified lines
341354 return rval;
342355 }
343356
344−static void
345−qla2x00_async_logout_sp_done(void *ptr, int res)
357+static void qla2x00_async_logout_sp_done(srb_t *sp, int res)
346358 {
347− srb_t *sp = ptr;
348−
349359 sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
350360 sp->fcport->login_gen++;
351361 qlt_logo_completion_handler(sp->fcport, res);
@@ -359,9 +369,6 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport) · 7 unmodified lines
359369 struct srb_iocb *lio;
360370 int rval = QLA_FUNCTION_FAILED;
361371
362− if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
363− return rval;
364−
365372 fcport->flags |= FCF_ASYNC_SENT;
366373 sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
367374 if (!sp)
@@ -405,10 +412,8 @@ qla2x00_async_prlo_done(struct scsi_qla_host *vha, fc_port_t *fcport, · 37 unmodified lines
405412 qlt_logo_completion_handler(fcport, data[0]);
406413 }
407414
408−static void
409−qla2x00_async_prlo_sp_done(void *s, int res)
415+static void qla2x00_async_prlo_sp_done(srb_t *sp, int res)
410416 {
411− srb_t *sp = (srb_t *)s;
412417 struct srb_iocb *lio = &sp->u.iocb_cmd;
413418 struct scsi_qla_host *vha = sp->vha;
414419
@@ -469,6 +474,9 @@ void qla24xx_handle_adisc_event(scsi_qla_host_t *vha, struct event_arg *ea) · 54 unmodified lines
469474 fcport->fw_login_state, ea->rc, fcport->login_gen, ea->sp->gen2,
470475 fcport->rscn_gen, ea->sp->gen1, fcport->loop_id);
471476
477+ WARN_ONCE(!qla2xxx_is_valid_mbs(ea->data[0]), "mbs: %#x\n",
478+ ea->data[0]);
479+
472480 if (ea->data[0] != MBS_COMMAND_COMPLETE) {
473481 ql_dbg(ql_dbg_disc, vha, 0x2066,
474482 "%s %8phC: adisc fail: post delete\n",
@@ -511,10 +519,8 @@ static int qla_post_els_plogi_work(struct scsi_qla_host *vha, fc_port_t *fcport) · 36 unmodified lines
511519 return qla2x00_post_work(vha, e);
512520 }
513521
514−static void
515−qla2x00_async_adisc_sp_done(void *ptr, int res)
522+static void qla2x00_async_adisc_sp_done(srb_t *sp, int res)
516523 {
517− srb_t *sp = ptr;
518524 struct scsi_qla_host *vha = sp->vha;
519525 struct event_arg ea;
520526 struct srb_iocb *lio = &sp->u.iocb_cmd;
@@ -526,7 +532,6 @@ qla2x00_async_adisc_sp_done(void *ptr, int res) · 5 unmodified lines
526532 sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
527533
528534 memset(&ea, 0, sizeof(ea));
529− ea.event = FCME_ADISC_DONE;
530535 ea.rc = res;
531536 ea.data[0] = lio->u.logio.data[0];
532537 ea.data[1] = lio->u.logio.data[1];
@@ -535,7 +540,7 @@ qla2x00_async_adisc_sp_done(void *ptr, int res) · 2 unmodified lines
535540 ea.fcport = sp->fcport;
536541 ea.sp = sp;
537542
538− qla2x00_fcport_event_handler(vha, &ea);
543+ qla24xx_handle_adisc_event(vha, &ea);
539544
540545 sp->free(sp);
541546 }
@@ -803,6 +808,15 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha, · 261 unmodified lines
803808 fcport->fw_login_state = current_login_state;
804809 fcport->d_id = id;
805810 switch (current_login_state) {
811+ case DSC_LS_PRLI_PEND:
812+ /*
813+ * In the middle of PRLI. Let it finish.
814+ * Allow relogin code to recheck state again
815+ * with GNL. Push disc_state back to DELETED
816+ * so GNL can go out again
817+ */
818+ fcport->disc_state = DSC_DELETED;
819+ break;
806820 case DSC_LS_PRLI_COMP:
807821 if ((e->prli_svc_param_word_3[0] & BIT_4) == 0)
808822 fcport->port_type = FCT_INITIATOR;
@@ -917,10 +931,8 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha, · 108 unmodified lines
917931 }
918932 } /* gnl_event */
919933
920−static void
921−qla24xx_async_gnl_sp_done(void *s, int res)
934+static void qla24xx_async_gnl_sp_done(srb_t *sp, int res)
922935 {
923− struct srb *sp = s;
924936 struct scsi_qla_host *vha = sp->vha;
925937 unsigned long flags;
926938 struct fc_port *fcport = NULL, *tf;
@@ -943,7 +955,6 @@ qla24xx_async_gnl_sp_done(void *s, int res) · 16 unmodified lines
943955 memset(&ea, 0, sizeof(ea));
944956 ea.sp = sp;
945957 ea.rc = res;
946− ea.event = FCME_GNL_DONE;
947958
948959 if (sp->u.iocb_cmd.u.mbx.in_mb[1] >=
949960 sizeof(struct get_name_list_extended)) {
@@ -982,7 +993,7 @@ qla24xx_async_gnl_sp_done(void *s, int res) · 32 unmodified lines
982993 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
983994 ea.fcport = fcport;
984995
985− qla2x00_fcport_event_handler(vha, &ea);
996+ qla24xx_handle_gnl_done_event(vha, &ea);
986997 }
987998
988999 /* create new fcport if fw has knowledge of new sessions */
@@ -1107,10 +1118,8 @@ int qla24xx_post_gnl_work(struct scsi_qla_host *vha, fc_port_t *fcport) · 118 unmodified lines
11071118 return qla2x00_post_work(vha, e);
11081119 }
11091120
1110−static
1111−void qla24xx_async_gpdb_sp_done(void *s, int res)
1121+static void qla24xx_async_gpdb_sp_done(srb_t *sp, int res)
11121122 {
1113− struct srb *sp = s;
11141123 struct scsi_qla_host *vha = sp->vha;
11151124 struct qla_hw_data *ha = vha->hw;
11161125 fc_port_t *fcport = sp->fcport;
@@ -1129,11 +1138,10 @@ void qla24xx_async_gpdb_sp_done(void *s, int res) · 12 unmodified lines
11291138
11301139 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
11311140 memset(&ea, 0, sizeof(ea));
1132− ea.event = FCME_GPDB_DONE;
11331141 ea.fcport = fcport;
11341142 ea.sp = sp;
11351143
1136− qla2x00_fcport_event_handler(vha, &ea);
1144+ qla24xx_handle_gpdb_event(vha, &ea);
11371145
11381146 dma_pool_free(ha->s_dma_pool, sp->u.iocb_cmd.u.mbx.in,
11391147 sp->u.iocb_cmd.u.mbx.in_dma);
@@ -1154,10 +1162,8 @@ static int qla24xx_post_prli_work(struct scsi_qla_host *vha, fc_port_t *fcport) · 14 unmodified lines
11541162 return qla2x00_post_work(vha, e);
11551163 }
11561164
1157−static void
1158−qla2x00_async_prli_sp_done(void *ptr, int res)
1165+static void qla2x00_async_prli_sp_done(srb_t *sp, int res)
11591166 {
1160− srb_t *sp = ptr;
11611167 struct scsi_qla_host *vha = sp->vha;
11621168 struct srb_iocb *lio = &sp->u.iocb_cmd;
11631169 struct event_arg ea;
@@ -1170,7 +1176,6 @@ qla2x00_async_prli_sp_done(void *ptr, int res) · 6 unmodified lines
11701176
11711177 if (!test_bit(UNLOADING, &vha->dpc_flags)) {
11721178 memset(&ea, 0, sizeof(ea));
1173− ea.event = FCME_PRLI_DONE;
11741179 ea.fcport = sp->fcport;
11751180 ea.data[0] = lio->u.logio.data[0];
11761181 ea.data[1] = lio->u.logio.data[1];
@@ -1178,7 +1183,7 @@ qla2x00_async_prli_sp_done(void *ptr, int res) · 1 unmodified line
11781183 ea.iop[1] = lio->u.logio.iop[1];
11791184 ea.sp = sp;
11801185
1181− qla2x00_fcport_event_handler(vha, &ea);
1186+ qla24xx_handle_prli_done_event(vha, &ea);
11821187 }
11831188
11841189 sp->free(sp);
@@ -1262,8 +1267,13 @@ int qla24xx_async_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt) · 77 unmodified lines
12621267 struct port_database_24xx *pd;
12631268 struct qla_hw_data *ha = vha->hw;
12641269
1265− if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
1270+ if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT) ||
1271+ fcport->loop_id == FC_NO_LOOP_ID) {
1272+ ql_log(ql_log_warn, vha, 0xffff,
1273+ "%s: %8phC - not sending command.\n",
1274+ __func__, fcport->port_name);
12661275 return rval;
1276+ }
12671277
12681278 fcport->disc_state = DSC_GPDB;
12691279
@@ -1473,7 +1483,7 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host *vha, fc_port_t *fcport) · 203 unmodified lines
14731483 u64 wwn;
14741484 u16 sec;
14751485
1476− ql_dbg(ql_dbg_disc + ql_dbg_verbose, vha, 0x20d8,
1486+ ql_dbg(ql_dbg_disc, vha, 0x20d8,
14771487 "%s %8phC DS %d LS %d P %d fl %x confl %p rscn %d|%d login %d lid %d scan %d\n",
14781488 __func__, fcport->port_name, fcport->disc_state,
14791489 fcport->fw_login_state, fcport->login_pause, fcport->flags,
@@ -1484,6 +1494,7 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host *vha, fc_port_t *fcport) · 4 unmodified lines
14841494 return 0;
14851495
14861496 if ((fcport->loop_id != FC_NO_LOOP_ID) &&
1497+ qla_dual_mode_enabled(vha) &&
14871498 ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) ||
14881499 (fcport->fw_login_state == DSC_LS_PRLI_PEND)))
14891500 return 0;
@@ -1636,12 +1647,34 @@ int qla24xx_post_newsess_work(struct scsi_qla_host *vha, port_id_t *id, · 146 unmodified lines
16361647 return qla2x00_post_work(vha, e);
16371648 }
16381649
1639−static
1650+void qla2x00_handle_rscn(scsi_qla_host_t *vha, struct event_arg *ea)
1651+{
1652+ fc_port_t *fcport;
1653+ unsigned long flags;
1654+
1655+ fcport = qla2x00_find_fcport_by_nportid(vha, &ea->id, 1);
1656+ if (fcport) {
1657+ fcport->scan_needed = 1;
1658+ fcport->rscn_gen++;
1659+ }
1660+
1661+ spin_lock_irqsave(&vha->work_lock, flags);
1662+ if (vha->scan.scan_flags == 0) {
1663+ ql_dbg(ql_dbg_disc, vha, 0xffff, "%s: schedule\n", __func__);
1664+ vha->scan.scan_flags |= SF_QUEUED;
1665+ schedule_delayed_work(&vha->scan.scan_work, 5);
1666+ }
1667+ spin_unlock_irqrestore(&vha->work_lock, flags);
1668+}
1669+
16401670 void qla24xx_handle_relogin_event(scsi_qla_host_t *vha,
16411671 struct event_arg *ea)
16421672 {
16431673 fc_port_t *fcport = ea->fcport;
16441674
1675+ if (test_bit(UNLOADING, &vha->dpc_flags))
1676+ return;
1677+
16451678 ql_dbg(ql_dbg_disc, vha, 0x2102,
16461679 "%s %8phC DS %d LS %d P %d del %d cnfl %p rscn %d|%d login %d|%d fl %x\n",
16471680 __func__, fcport->port_name, fcport->disc_state,
@@ -1651,110 +1684,16 @@ void qla24xx_handle_relogin_event(scsi_qla_host_t *vha, · 3 unmodified lines
16511684 fcport->last_login_gen, fcport->login_gen,
16521685 fcport->flags);
16531686
1654− if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) ||
1655− (fcport->fw_login_state == DSC_LS_PRLI_PEND))
1656− return;
1657−
1658− if (fcport->fw_login_state == DSC_LS_PLOGI_COMP) {
1659− if (time_before_eq(jiffies, fcport->plogi_nack_done_deadline)) {
1660− set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
1661− return;
1662− }
1663− }
1664−
16651687 if (fcport->last_rscn_gen != fcport->rscn_gen) {
1666− ql_dbg(ql_dbg_disc, vha, 0x20e9, "%s %d %8phC post gidpn\n",
1688+ ql_dbg(ql_dbg_disc, vha, 0x20e9, "%s %d %8phC post gnl\n",
16671689 __func__, __LINE__, fcport->port_name);
1668−
1690+ qla24xx_post_gnl_work(vha, fcport);
16691691 return;
16701692 }
16711693
16721694 qla24xx_fcport_handle_login(vha, fcport);
16731695 }
16741696
1675−
1676−static void qla_handle_els_plogi_done(scsi_qla_host_t *vha,
1677− struct event_arg *ea)
1678−{
1679− ql_dbg(ql_dbg_disc, vha, 0x2118,
1680− "%s %d %8phC post PRLI\n",
1681− __func__, __LINE__, ea->fcport->port_name);
1682− qla24xx_post_prli_work(vha, ea->fcport);
1683−}
1684−
1685−void qla2x00_fcport_event_handler(scsi_qla_host_t *vha, struct event_arg *ea)
1686−{
1687− fc_port_t *fcport;
1688−
1689− switch (ea->event) {
1690− case FCME_RELOGIN:
1691− if (test_bit(UNLOADING, &vha->dpc_flags))
1692− return;
1693−
1694− qla24xx_handle_relogin_event(vha, ea);
1695− break;
1696− case FCME_RSCN:
1697− if (test_bit(UNLOADING, &vha->dpc_flags))
1698− return;
1699− {
1700− unsigned long flags;
1701−
1702− fcport = qla2x00_find_fcport_by_nportid
1703− (vha, &ea->id, 1);
1704− if (fcport) {
1705− fcport->scan_needed = 1;
1706− fcport->rscn_gen++;
1707− }
1708−
1709− spin_lock_irqsave(&vha->work_lock, flags);
1710− if (vha->scan.scan_flags == 0) {
1711− ql_dbg(ql_dbg_disc, vha, 0xffff,
1712− "%s: schedule\n", __func__);
1713− vha->scan.scan_flags |= SF_QUEUED;
1714− schedule_delayed_work(&vha->scan.scan_work, 5);
1715− }
1716− spin_unlock_irqrestore(&vha->work_lock, flags);
1717− }
1718− break;
1719− case FCME_GNL_DONE:
1720− qla24xx_handle_gnl_done_event(vha, ea);
1721− break;
1722− case FCME_GPSC_DONE:
1723− qla24xx_handle_gpsc_event(vha, ea);
1724− break;
1725− case FCME_PLOGI_DONE: /* Initiator side sent LLIOCB */
1726− qla24xx_handle_plogi_done_event(vha, ea);
1727− break;
1728− case FCME_PRLI_DONE:
1729− qla24xx_handle_prli_done_event(vha, ea);
1730− break;
1731− case FCME_GPDB_DONE:
1732− qla24xx_handle_gpdb_event(vha, ea);
1733− break;
1734− case FCME_GPNID_DONE:
1735− qla24xx_handle_gpnid_event(vha, ea);
1736− break;
1737− case FCME_GFFID_DONE:
1738− qla24xx_handle_gffid_event(vha, ea);
1739− break;
1740− case FCME_ADISC_DONE:
1741− qla24xx_handle_adisc_event(vha, ea);
1742− break;
1743− case FCME_GNNID_DONE:
1744− qla24xx_handle_gnnid_event(vha, ea);
1745− break;
1746− case FCME_GFPNID_DONE:
1747− qla24xx_handle_gfpnid_event(vha, ea);
1748− break;
1749− case FCME_ELS_PLOGI_DONE:
1750− qla_handle_els_plogi_done(vha, ea);
1751− break;
1752− default:
1753− BUG_ON(1);
1754− break;
1755− }
1756−}
1757−
17581697 /*
17591698 * RSCN(s) came in for this fcport, but the RSCN(s) was not able
17601699 * to be consumed by the fcport
@@ -1772,10 +1711,9 @@ void qla_rscn_replay(fc_port_t *fcport) · 11 unmodified lines
17721711
17731712 if (fcport->scan_needed) {
17741713 memset(&ea, 0, sizeof(ea));
1775− ea.event = FCME_RSCN;
17761714 ea.id = fcport->d_id;
17771715 ea.id.b.rsvd_1 = RSCN_PORT_ADDR;
1778− qla2x00_fcport_event_handler(fcport->vha, &ea);
1716+ qla2x00_handle_rscn(fcport->vha, &ea);
17791717 }
17801718 }
17811719
@@ -1789,10 +1727,8 @@ qla2x00_tmf_iocb_timeout(void *data) · 7 unmodified lines
17891727 complete(&tmf->u.tmf.comp);
17901728 }
17911729
1792−static void
1793−qla2x00_tmf_sp_done(void *ptr, int res)
1730+static void qla2x00_tmf_sp_done(srb_t *sp, int res)
17941731 {
1795− srb_t *sp = ptr;
17961732 struct srb_iocb *tmf = &sp->u.iocb_cmd;
17971733
17981734 complete(&tmf->u.tmf.comp);
@@ -1890,6 +1826,9 @@ qla24xx_async_abort_command(srb_t *sp) · 91 unmodified lines
18901826 static void
18911827 qla24xx_handle_prli_done_event(struct scsi_qla_host *vha, struct event_arg *ea)
18921828 {
1829+ WARN_ONCE(!qla2xxx_is_valid_mbs(ea->data[0]), "mbs: %#x\n",
1830+ ea->data[0]);
1831+
18931832 switch (ea->data[0]) {
18941833 case MBS_COMMAND_COMPLETE:
18951834 ql_dbg(ql_dbg_disc, vha, 0x2118,
@@ -1929,7 +1868,7 @@ qla24xx_handle_prli_done_event(struct scsi_qla_host *vha, struct event_arg *ea) · 33 unmodified lines
19291868 }
19301869 }
19311870
1932−static void
1871+void
19331872 qla24xx_handle_plogi_done_event(struct scsi_qla_host *vha, struct event_arg *ea)
19341873 {
19351874 port_id_t cid; /* conflict Nport id */
@@ -1953,8 +1892,11 @@ qla24xx_handle_plogi_done_event(struct scsi_qla_host *vha, struct event_arg *ea) · 17 unmodified lines
19531892 return;
19541893 }
19551894
1956− if (fcport->disc_state == DSC_DELETE_PEND)
1895+ if ((fcport->disc_state == DSC_DELETE_PEND) ||
1896+ (fcport->disc_state == DSC_DELETED)) {
1897+ set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
19571898 return;
1899+ }
19581900
19591901 if (ea->sp->gen2 != fcport->login_gen) {
19601902 /* target side must have changed it. */
@@ -1972,6 +1914,9 @@ qla24xx_handle_plogi_done_event(struct scsi_qla_host *vha, struct event_arg *ea) · 11 unmodified lines
19721914 return;
19731915 }
19741916
1917+ WARN_ONCE(!qla2xxx_is_valid_mbs(ea->data[0]), "mbs: %#x\n",
1918+ ea->data[0]);
1919+
19751920 switch (ea->data[0]) {
19761921 case MBS_COMMAND_COMPLETE:
19771922 /*
@@ -2266,6 +2211,10 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha) · 288 unmodified lines
22662211 if (qla_ini_mode_enabled(vha) || qla_dual_mode_enabled(vha))
22672212 rval = qla2x00_init_rings(vha);
22682213
2214+ /* No point in continuing if firmware initialization failed. */
2215+ if (rval != QLA_SUCCESS)
2216+ return rval;
2217+
22692218 ha->flags.chip_reset_done = 1;
22702219
22712220 if (rval == QLA_SUCCESS && IS_QLA84XX(ha)) {
@@ -3082,103 +3031,113 @@ qla24xx_chip_diag(scsi_qla_host_t *vha) · 810 unmodified lines
30823031 }
30833032
30843033 static void
3085−qla2x00_alloc_offload_mem(scsi_qla_host_t *vha)
3034+qla2x00_init_fce_trace(scsi_qla_host_t *vha)
30863035 {
30873036 int rval;
30883037 dma_addr_t tc_dma;
30893038 void *tc;
30903039 struct qla_hw_data *ha = vha->hw;
30913040
3092− if (ha->eft) {
3041+ if (!IS_FWI2_CAPABLE(ha))
3042+ return;
3043+
3044+ if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha) &&
3045+ !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
3046+ return;
3047+
3048+ if (ha->fce) {
30933049 ql_dbg(ql_dbg_init, vha, 0x00bd,
3094− "%s: Offload Mem is already allocated.\n",
3095− __func__);
3050+ "%s: FCE Mem is already allocated.\n",
3051+ __func__);
30963052 return;
30973053 }
30983054
3099− if (IS_FWI2_CAPABLE(ha)) {
3100− /* Allocate memory for Fibre Channel Event Buffer. */
3101− if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha) &&
3102− !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
3103− goto try_eft;
3055+ /* Allocate memory for Fibre Channel Event Buffer. */
3056+ tc = dma_alloc_coherent(&ha->pdev->dev, FCE_SIZE, &tc_dma,
3057+ GFP_KERNEL);
3058+ if (!tc) {
3059+ ql_log(ql_log_warn, vha, 0x00be,
3060+ "Unable to allocate (%d KB) for FCE.\n",
3061+ FCE_SIZE / 1024);
3062+ return;
3063+ }
31043064
3105− if (ha->fce)
3106− dma_free_coherent(&ha->pdev->dev,
3107− FCE_SIZE, ha->fce, ha->fce_dma);
3065+ rval = qla2x00_enable_fce_trace(vha, tc_dma, FCE_NUM_BUFFERS,
3066+ ha->fce_mb, &ha->fce_bufs);
3067+ if (rval) {
3068+ ql_log(ql_log_warn, vha, 0x00bf,
3069+ "Unable to initialize FCE (%d).\n", rval);
3070+ dma_free_coherent(&ha->pdev->dev, FCE_SIZE, tc, tc_dma);
3071+ return;
3072+ }
31083073
3109− /* Allocate memory for Fibre Channel Event Buffer. */
3110− tc = dma_alloc_coherent(&ha->pdev->dev, FCE_SIZE, &tc_dma,
3111− GFP_KERNEL);
3112− if (!tc) {
3113− ql_log(ql_log_warn, vha, 0x00be,
3114− "Unable to allocate (%d KB) for FCE.\n",
3115− FCE_SIZE / 1024);
3116− goto try_eft;
3117− }
3118−
3119− rval = qla2x00_enable_fce_trace(vha, tc_dma, FCE_NUM_BUFFERS,
3120− ha->fce_mb, &ha->fce_bufs);
3121− if (rval) {
3122− ql_log(ql_log_warn, vha, 0x00bf,
3123− "Unable to initialize FCE (%d).\n", rval);
3124− dma_free_coherent(&ha->pdev->dev, FCE_SIZE, tc,
3125− tc_dma);
3126− ha->flags.fce_enabled = 0;
3127− goto try_eft;
3128− }
3129− ql_dbg(ql_dbg_init, vha, 0x00c0,
3130− "Allocate (%d KB) for FCE...\n", FCE_SIZE / 1024);
3131−
3132− ha->flags.fce_enabled = 1;
3133− ha->fce_dma = tc_dma;
3134− ha->fce = tc;
3135−
3136−try_eft:
3137− if (ha->eft)
3138− dma_free_coherent(&ha->pdev->dev,
3139− EFT_SIZE, ha->eft, ha->eft_dma);
3074+ ql_dbg(ql_dbg_init, vha, 0x00c0,
3075+ "Allocated (%d KB) for FCE...\n", FCE_SIZE / 1024);
31403076
3141− /* Allocate memory for Extended Trace Buffer. */
3142− tc = dma_alloc_coherent(&ha->pdev->dev, EFT_SIZE, &tc_dma,
3143− GFP_KERNEL);
3144− if (!tc) {
3145− ql_log(ql_log_warn, vha, 0x00c1,
3146− "Unable to allocate (%d KB) for EFT.\n",
3147− EFT_SIZE / 1024);
3148− goto eft_err;
3149− }
3077+ ha->flags.fce_enabled = 1;
3078+ ha->fce_dma = tc_dma;
3079+ ha->fce = tc;
3080+}
31503081
3151− rval = qla2x00_enable_eft_trace(vha, tc_dma, EFT_NUM_BUFFERS);
3152− if (rval) {
3153− ql_log(ql_log_warn, vha, 0x00c2,
3154− "Unable to initialize EFT (%d).\n", rval);
3155− dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc,
3156− tc_dma);
3157− goto eft_err;
3158− }
3159− ql_dbg(ql_dbg_init, vha, 0x00c3,
3160− "Allocated (%d KB) EFT ...\n", EFT_SIZE / 1024);
3082+static void
3083+qla2x00_init_eft_trace(scsi_qla_host_t *vha)
3084+{
3085+ int rval;
3086+ dma_addr_t tc_dma;
3087+ void *tc;
3088+ struct qla_hw_data *ha = vha->hw;
3089+
3090+ if (!IS_FWI2_CAPABLE(ha))
3091+ return;
31613092
3162− ha->eft_dma = tc_dma;
3163− ha->eft = tc;
3093+ if (ha->eft) {
3094+ ql_dbg(ql_dbg_init, vha, 0x00bd,
3095+ "%s: EFT Mem is already allocated.\n",
3096+ __func__);
3097+ return;
31643098 }
31653099
3166−eft_err:
3167− return;
3100+ /* Allocate memory for Extended Trace Buffer. */
3101+ tc = dma_alloc_coherent(&ha->pdev->dev, EFT_SIZE, &tc_dma,
3102+ GFP_KERNEL);
3103+ if (!tc) {
3104+ ql_log(ql_log_warn, vha, 0x00c1,
3105+ "Unable to allocate (%d KB) for EFT.\n",
3106+ EFT_SIZE / 1024);
3107+ return;
3108+ }
3109+
3110+ rval = qla2x00_enable_eft_trace(vha, tc_dma, EFT_NUM_BUFFERS);
3111+ if (rval) {
3112+ ql_log(ql_log_warn, vha, 0x00c2,
3113+ "Unable to initialize EFT (%d).\n", rval);
3114+ dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc, tc_dma);
3115+ return;
3116+ }
3117+
3118+ ql_dbg(ql_dbg_init, vha, 0x00c3,
3119+ "Allocated (%d KB) EFT ...\n", EFT_SIZE / 1024);
3120+
3121+ ha->eft_dma = tc_dma;
3122+ ha->eft = tc;
3123+}
3124+
3125+static void
3126+qla2x00_alloc_offload_mem(scsi_qla_host_t *vha)
3127+{
3128+ qla2x00_init_fce_trace(vha);
3129+ qla2x00_init_eft_trace(vha);
31683130 }
31693131
31703132 void
31713133 qla2x00_alloc_fw_dump(scsi_qla_host_t *vha)
31723134 {
3173− int rval;
31743135 uint32_t dump_size, fixed_size, mem_size, req_q_size, rsp_q_size,
31753136 eft_size, fce_size, mq_size;
31763137 struct qla_hw_data *ha = vha->hw;
31773138 struct req_que *req = ha->req_q_map[0];
31783139 struct rsp_que *rsp = ha->rsp_q_map[0];
31793140 struct qla2xxx_fw_dump *fw_dump;
3180− dma_addr_t tc_dma;
3181− void *tc;
31823141
31833142 dump_size = fixed_size = mem_size = eft_size = fce_size = mq_size = 0;
31843143 req_q_size = rsp_q_size = 0;
@@ -3216,37 +3175,13 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) · 31 unmodified lines
32163175 }
32173176 if (ha->tgt.atio_ring)
32183177 mq_size += ha->tgt.atio_q_length * sizeof(request_t);
3219− /* Allocate memory for Fibre Channel Event Buffer. */
3220− if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha) &&
3221− !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
3222− goto try_eft;
32233178
3224− fce_size = sizeof(struct qla2xxx_fce_chain) + FCE_SIZE;
3225−try_eft:
3179+ qla2x00_init_fce_trace(vha);
3180+ if (ha->fce)
3181+ fce_size = sizeof(struct qla2xxx_fce_chain) + FCE_SIZE;
3182+ qla2x00_init_eft_trace(vha);
32263183 if (ha->eft)
3227− dma_free_coherent(&ha->pdev->dev,
3228− EFT_SIZE, ha->eft, ha->eft_dma);
3229−
3230− /* Allocate memory for Extended Trace Buffer. */
3231− tc = dma_alloc_coherent(&ha->pdev->dev, EFT_SIZE, &tc_dma,
3232− GFP_KERNEL);
3233− if (!tc) {
3234− ql_log(ql_log_warn, vha, 0x00c1,
3235− "Unable to allocate (%d KB) for EFT.\n",
3236− EFT_SIZE / 1024);
3237− goto allocate;
3238− }
3239−
3240− rval = qla2x00_enable_eft_trace(vha, tc_dma, EFT_NUM_BUFFERS);
3241− if (rval) {
3242− ql_log(ql_log_warn, vha, 0x00c2,
3243− "Unable to initialize EFT (%d).\n", rval);
3244− dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc,
3245− tc_dma);
3246− }
3247− ql_dbg(ql_dbg_init, vha, 0x00c3,
3248− "Allocated (%d KB) EFT ...\n", EFT_SIZE / 1024);
3249− eft_size = EFT_SIZE;
3184+ eft_size = EFT_SIZE;
32503185 }
32513186
32523187 if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
@@ -3268,24 +3203,22 @@ try_eft: · 15 unmodified lines
32683203 j, fwdt->dump_size);
32693204 dump_size += fwdt->dump_size;
32703205 }
3271− goto allocate;
3206+ } else {
3207+ req_q_size = req->length * sizeof(request_t);
3208+ rsp_q_size = rsp->length * sizeof(response_t);
3209+ dump_size = offsetof(struct qla2xxx_fw_dump, isp);
3210+ dump_size += fixed_size + mem_size + req_q_size + rsp_q_size
3211+ + eft_size;
3212+ ha->chain_offset = dump_size;
3213+ dump_size += mq_size + fce_size;
3214+ if (ha->exchoffld_buf)
3215+ dump_size += sizeof(struct qla2xxx_offld_chain) +
3216+ ha->exchoffld_size;
3217+ if (ha->exlogin_buf)
3218+ dump_size += sizeof(struct qla2xxx_offld_chain) +
3219+ ha->exlogin_size;
32723220 }
32733221
3274− req_q_size = req->length * sizeof(request_t);
3275− rsp_q_size = rsp->length * sizeof(response_t);
3276− dump_size = offsetof(struct qla2xxx_fw_dump, isp);
3277− dump_size += fixed_size + mem_size + req_q_size + rsp_q_size + eft_size;
3278− ha->chain_offset = dump_size;
3279− dump_size += mq_size + fce_size;
3280−
3281− if (ha->exchoffld_buf)
3282− dump_size += sizeof(struct qla2xxx_offld_chain) +
3283− ha->exchoffld_size;
3284− if (ha->exlogin_buf)
3285− dump_size += sizeof(struct qla2xxx_offld_chain) +
3286− ha->exlogin_size;
3287−
3288−allocate:
32893222 if (!ha->fw_dump_len || dump_size > ha->fw_dump_alloc_len) {
32903223
32913224 ql_dbg(ql_dbg_init, vha, 0x00c5,
@@ -4400,7 +4333,7 @@ qla2x00_configure_hba(scsi_qla_host_t *vha) · 1108 unmodified lines
44004333
44014334 inline void
44024335 qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len,
4403− char *def)
4336+ const char *def)
44044337 {
44054338 char *st, *en;
44064339 uint16_t index;
@@ -4412,7 +4345,7 @@ qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len, · 5 unmodified lines
44124345 if (len > sizeof(zero))
44134346 len = sizeof(zero);
44144347 if (memcmp(model, &zero, len) != 0) {
4415− strncpy(ha->model_number, model, len);
4348+ memcpy(ha->model_number, model, len);
44164349 st = en = ha->model_number;
44174350 en += len - 1;
44184351 while (en > st) {
@@ -4425,21 +4358,23 @@ qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len, · 6 unmodified lines
44254358 if (use_tbl &&
44264359 ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC &&
44274360 index < QLA_MODEL_NAMES)
4428− strncpy(ha->model_desc,
4361+ strlcpy(ha->model_desc,
44294362 qla2x00_model_name[index * 2 + 1],
4430− sizeof(ha->model_desc) - 1);
4363+ sizeof(ha->model_desc));
44314364 } else {
44324365 index = (ha->pdev->subsystem_device & 0xff);
44334366 if (use_tbl &&
44344367 ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC &&
44354368 index < QLA_MODEL_NAMES) {
4436− strcpy(ha->model_number,
4437− qla2x00_model_name[index * 2]);
4438− strncpy(ha->model_desc,
4369+ strlcpy(ha->model_number,
4370+ qla2x00_model_name[index * 2],
4371+ sizeof(ha->model_number));
4372+ strlcpy(ha->model_desc,
44394373 qla2x00_model_name[index * 2 + 1],
4440− sizeof(ha->model_desc) - 1);
4374+ sizeof(ha->model_desc));
44414375 } else {
4442− strcpy(ha->model_number, def);
4376+ strlcpy(ha->model_number, def,
4377+ sizeof(ha->model_number));
44434378 }
44444379 }
44454380 if (IS_FWI2_CAPABLE(ha))
@@ -5044,7 +4979,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha) · 598 unmodified lines
50444979
50454980 uint16_t index;
50464981 uint16_t entries;
5047− char *id_iter;
4982+ struct gid_list_info *gid;
50484983 uint16_t loop_id;
50494984 uint8_t domain, area, al_pa;
50504985 struct qla_hw_data *ha = vha->hw;
@@ -5119,18 +5054,16 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha) · 68 unmodified lines
51195054 new_fcport->flags &= ~FCF_FABRIC_DEVICE;
51205055
51215056 /* Add devices to port list. */
5122− id_iter = (char *)ha->gid_list;
5057+ gid = ha->gid_list;
51235058 for (index = 0; index < entries; index++) {
5124− domain = ((struct gid_list_info *)id_iter)->domain;
5125− area = ((struct gid_list_info *)id_iter)->area;
5126− al_pa = ((struct gid_list_info *)id_iter)->al_pa;
5059+ domain = gid->domain;
5060+ area = gid->area;
5061+ al_pa = gid->al_pa;
51275062 if (IS_QLA2100(ha) || IS_QLA2200(ha))
5128− loop_id = (uint16_t)
5129− ((struct gid_list_info *)id_iter)->loop_id_2100;
5063+ loop_id = gid->loop_id_2100;
51305064 else
5131− loop_id = le16_to_cpu(
5132− ((struct gid_list_info *)id_iter)->loop_id);
5133− id_iter += ha->gid_list_info_size;
5065+ loop_id = le16_to_cpu(gid->loop_id);
5066+ gid = (void *)gid + ha->gid_list_info_size;
51345067
51355068 /* Bypass reserved domain fields. */
51365069 if ((domain & 0xf0) == 0xf0)
@@ -5355,7 +5288,7 @@ qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t *fcport) · 218 unmodified lines
53555288 "%s %8phN. rport %p is %s mode\n",
53565289 __func__, fcport->port_name, rport,
53575290 (fcport->port_type == FCT_TARGET) ? "tgt" :
5358− ((fcport->port_type & FCT_NVME) ? "nvme" :"ini"));
5291+ ((fcport->port_type & FCT_NVME) ? "nvme" : "ini"));
53595292
53605293 fc_remote_port_rolechg(rport, rport_ids.roles);
53615294 }
@@ -6596,7 +6529,8 @@ qla2x00_quiesce_io(scsi_qla_host_t *vha) · 1234 unmodified lines
65966529 LOOP_DOWN_TIME);
65976530 }
65986531 /* Wait for pending cmds to complete */
6599− qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST);
6532+ WARN_ON_ONCE(qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST)
6533+ != QLA_SUCCESS);
66006534 }
66016535
66026536 void
@@ -6684,8 +6618,10 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha) · 81 unmodified lines
66846618 }
66856619
66866620 /* Clear all async request states across all VPs. */
6687− list_for_each_entry(fcport, &vha->vp_fcports, list)
6621+ list_for_each_entry(fcport, &vha->vp_fcports, list) {
66886622 fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
6623+ fcport->scan_state = 0;
6624+ }
66896625 spin_lock_irqsave(&ha->vport_slock, flags);
66906626 list_for_each_entry(vp, &ha->vp_list, list) {
66916627 atomic_inc(&vp->vref_count);
@@ -7519,8 +7455,12 @@ qla27xx_get_active_image(struct scsi_qla_host *vha, · 827 unmodified lines
75197455 goto check_sec_image;
75207456 }
75217457
7522− qla24xx_read_flash_data(vha, (void *)(&pri_image_status),
7523− ha->flt_region_img_status_pri, sizeof(pri_image_status) >> 2);
7458+ if (qla24xx_read_flash_data(vha, (void *)(&pri_image_status),
7459+ ha->flt_region_img_status_pri, sizeof(pri_image_status) >> 2) !=
7460+ QLA_SUCCESS) {
7461+ WARN_ON_ONCE(true);
7462+ goto check_sec_image;
7463+ }
75247464 qla27xx_print_image(vha, "Primary image", &pri_image_status);
75257465
75267466 if (qla27xx_check_image_status_signature(&pri_image_status)) {
@@ -8274,7 +8214,7 @@ qla81xx_nvram_config(scsi_qla_host_t *vha) · 747 unmodified lines
82748214 active_regions.aux.vpd_nvram == QLA27XX_PRIMARY_IMAGE ?
82758215 "primary" : "secondary");
82768216 }
8277− qla24xx_read_flash_data(vha, ha->vpd, faddr, ha->vpd_size >> 2);
8217+ ha->isp_ops->read_optrom(vha, ha->vpd, faddr << 2, ha->vpd_size);
82788218
82798219 /* Get NVRAM data into cache and calculate checksum. */
82808220 faddr = ha->flt_region_nvram;
@@ -8286,7 +8226,7 @@ qla81xx_nvram_config(scsi_qla_host_t *vha) · 5 unmodified lines
82868226 "Loading %s nvram image.\n",
82878227 active_regions.aux.vpd_nvram == QLA27XX_PRIMARY_IMAGE ?
82888228 "primary" : "secondary");
8289− qla24xx_read_flash_data(vha, ha->nvram, faddr, ha->nvram_size >> 2);
8229+ ha->isp_ops->read_optrom(vha, ha->nvram, faddr << 2, ha->nvram_size);
82908230
82918231 dptr = (uint32_t *)nv;
82928232 for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++, dptr++)
drivers/scsi/qla2xxx/qla_inline.h+15−13
@@ -152,6 +152,18 @@ qla2x00_chip_is_down(scsi_qla_host_t *vha) · 151 unmodified lines
152152 return (qla2x00_reset_active(vha) || !vha->hw->flags.fw_started);
153153 }
154154
155+static void qla2xxx_init_sp(srb_t *sp, scsi_qla_host_t *vha,
156+ struct qla_qpair *qpair, fc_port_t *fcport)
157+{
158+ memset(sp, 0, sizeof(*sp));
159+ sp->fcport = fcport;
160+ sp->iocbs = 1;
161+ sp->vha = vha;
162+ sp->qpair = qpair;
163+ sp->cmd_type = TYPE_SRB;
164+ INIT_LIST_HEAD(&sp->elem);
165+}
166+
155167 static inline srb_t *
156168 qla2xxx_get_qpair_sp(scsi_qla_host_t *vha, struct qla_qpair *qpair,
157169 fc_port_t *fcport, gfp_t flag)
@@ -164,19 +176,9 @@ qla2xxx_get_qpair_sp(scsi_qla_host_t *vha, struct qla_qpair *qpair, · 6 unmodified lines
164176 return NULL;
165177
166178 sp = mempool_alloc(qpair->srb_mempool, flag);
167− if (!sp)
168− goto done;
169−
170− memset(sp, 0, sizeof(*sp));
171− sp->fcport = fcport;
172− sp->iocbs = 1;
173− sp->vha = vha;
174− sp->qpair = qpair;
175− sp->cmd_type = TYPE_SRB;
176− INIT_LIST_HEAD(&sp->elem);
177−
178−done:
179− if (!sp)
179+ if (sp)
180+ qla2xxx_init_sp(sp, vha, qpair, fcport);
181+ else
180182 QLA_QPAIR_MARK_NOT_BUSY(qpair);
181183 return sp;
182184 }
drivers/scsi/qla2xxx/qla_iocb.c+82−144
@@ -292,6 +292,26 @@ void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt, · 291 unmodified lines
292292 }
293293 }
294294
295+/*
296+ * Find the first handle that is not in use, starting from
297+ * req->current_outstanding_cmd + 1. The caller must hold the lock that is
298+ * associated with @req.
299+ */
300+uint32_t qla2xxx_get_next_handle(struct req_que *req)
301+{
302+ uint32_t index, handle = req->current_outstanding_cmd;
303+
304+ for (index = 1; index < req->num_outstanding_cmds; index++) {
305+ handle++;
306+ if (handle == req->num_outstanding_cmds)
307+ handle = 1;
308+ if (!req->outstanding_cmds[handle])
309+ return handle;
310+ }
311+
312+ return 0;
313+}
314+
295315 /**
296316 * qla2x00_start_scsi() - Send a SCSI command to the ISP
297317 * @sp: command to send to the ISP
@@ -306,7 +326,6 @@ qla2x00_start_scsi(srb_t *sp) · 8 unmodified lines
306326 scsi_qla_host_t *vha;
307327 struct scsi_cmnd *cmd;
308328 uint32_t *clr_ptr;
309− uint32_t index;
310329 uint32_t handle;
311330 cmd_entry_t *cmd_pkt;
312331 uint16_t cnt;
@@ -339,16 +358,8 @@ qla2x00_start_scsi(srb_t *sp) · 26 unmodified lines
339358 /* Acquire ring specific lock */
340359 spin_lock_irqsave(&ha->hardware_lock, flags);
341360
342− /* Check for room in outstanding command list. */
343− handle = req->current_outstanding_cmd;
344− for (index = 1; index < req->num_outstanding_cmds; index++) {
345− handle++;
346− if (handle == req->num_outstanding_cmds)
347− handle = 1;
348− if (!req->outstanding_cmds[handle])
349− break;
350− }
351− if (index == req->num_outstanding_cmds)
361+ handle = qla2xxx_get_next_handle(req);
362+ if (handle == 0)
352363 goto queuing_error;
353364
354365 /* Map the sg table so we have an accurate count of sg entries needed */
@@ -610,7 +621,7 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt, · 255 unmodified lines
610621 }
611622
612623 cur_seg = scsi_sglist(cmd);
613− ctx = GET_CMD_CTX_SP(sp);
624+ ctx = sp->u.scmd.ct6_ctx;
614625
615626 while (tot_dsds) {
616627 avail_dsds = (tot_dsds > QLA_DSDS_PER_IOCB) ?
@@ -943,8 +954,7 @@ alloc_and_fill: · 326 unmodified lines
943954
944955 if (sp) {
945956 list_add_tail(&dsd_ptr->list,
946− &((struct crc_context *)
947− sp->u.scmd.ctx)->dsd_list);
957+ &sp->u.scmd.crc_ctx->dsd_list);
948958
949959 sp->flags |= SRB_CRC_CTX_DSD_VALID;
950960 } else {
@@ -1041,8 +1051,7 @@ qla24xx_walk_and_build_sglist(struct qla_hw_data *ha, srb_t *sp, · 90 unmodified lines
10411051
10421052 if (sp) {
10431053 list_add_tail(&dsd_ptr->list,
1044− &((struct crc_context *)
1045− sp->u.scmd.ctx)->dsd_list);
1054+ &sp->u.scmd.crc_ctx->dsd_list);
10461055
10471056 sp->flags |= SRB_CRC_CTX_DSD_VALID;
10481057 } else {
@@ -1088,7 +1097,7 @@ qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp, · 39 unmodified lines
10881097
10891098 sgl = scsi_prot_sglist(cmd);
10901099 vha = sp->vha;
1091− difctx = sp->u.scmd.ctx;
1100+ difctx = sp->u.scmd.crc_ctx;
10921101 direction_to_device = cmd->sc_data_direction == DMA_TO_DEVICE;
10931102 ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe021,
10941103 "%s: scsi_cmnd: %p, crc_ctx: %p, sp: %p\n",
@@ -1364,6 +1373,7 @@ qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp, · 269 unmodified lines
13641373 cur_dsd++;
13651374 return 0;
13661375 }
1376+
13671377 /**
13681378 * qla24xx_build_scsi_crc_2_iocbs() - Build IOCB command utilizing Command
13691379 * Type 6 IOCB types.
@@ -1427,7 +1437,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, · 57 unmodified lines
14271437 bundling = 0;
14281438
14291439 /* Allocate CRC context from global pool */
1430− crc_ctx_pkt = sp->u.scmd.ctx =
1440+ crc_ctx_pkt = sp->u.scmd.crc_ctx =
14311441 dma_pool_zalloc(ha->dl_dma_pool, GFP_ATOMIC, &crc_ctx_dma);
14321442
14331443 if (!crc_ctx_pkt)
@@ -1515,7 +1525,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, · 81 unmodified lines
15151525 }
15161526
15171527 if (!bundling) {
1518− cur_dsd = &crc_ctx_pkt->u.nobundling.data_dsd;
1528+ cur_dsd = &crc_ctx_pkt->u.nobundling.data_dsd[0];
15191529 } else {
15201530 /*
15211531 * Configure Bundling if we need to fetch interlaving
@@ -1525,7 +1535,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, · 3 unmodified lines
15251535 crc_ctx_pkt->u.bundling.dif_byte_count = cpu_to_le32(dif_bytes);
15261536 crc_ctx_pkt->u.bundling.dseg_count = cpu_to_le16(tot_dsds -
15271537 tot_prot_dsds);
1528− cur_dsd = &crc_ctx_pkt->u.bundling.data_dsd;
1538+ cur_dsd = &crc_ctx_pkt->u.bundling.data_dsd[0];
15291539 }
15301540
15311541 /* Finish the common fields of CRC pkt */
@@ -1583,7 +1593,6 @@ qla24xx_start_scsi(srb_t *sp) · 51 unmodified lines
15831593 int nseg;
15841594 unsigned long flags;
15851595 uint32_t *clr_ptr;
1586− uint32_t index;
15871596 uint32_t handle;
15881597 struct cmd_type_7 *cmd_pkt;
15891598 uint16_t cnt;
@@ -1611,16 +1620,8 @@ qla24xx_start_scsi(srb_t *sp) · 21 unmodified lines
16111620 /* Acquire ring specific lock */
16121621 spin_lock_irqsave(&ha->hardware_lock, flags);
16131622
1614− /* Check for room in outstanding command list. */
1615− handle = req->current_outstanding_cmd;
1616− for (index = 1; index < req->num_outstanding_cmds; index++) {
1617− handle++;
1618− if (handle == req->num_outstanding_cmds)
1619− handle = 1;
1620− if (!req->outstanding_cmds[handle])
1621− break;
1622− }
1623− if (index == req->num_outstanding_cmds)
1623+ handle = qla2xxx_get_next_handle(req);
1624+ if (handle == 0)
16241625 goto queuing_error;
16251626
16261627 /* Map the sg table so we have an accurate count of sg entries needed */
@@ -1723,7 +1724,6 @@ qla24xx_dif_start_scsi(srb_t *sp) · 96 unmodified lines
17231724 int nseg;
17241725 unsigned long flags;
17251726 uint32_t *clr_ptr;
1726− uint32_t index;
17271727 uint32_t handle;
17281728 uint16_t cnt;
17291729 uint16_t req_cnt = 0;
@@ -1764,17 +1764,8 @@ qla24xx_dif_start_scsi(srb_t *sp) · 34 unmodified lines
17641764 /* Acquire ring specific lock */
17651765 spin_lock_irqsave(&ha->hardware_lock, flags);
17661766
1767− /* Check for room in outstanding command list. */
1768− handle = req->current_outstanding_cmd;
1769− for (index = 1; index < req->num_outstanding_cmds; index++) {
1770− handle++;
1771− if (handle == req->num_outstanding_cmds)
1772− handle = 1;
1773− if (!req->outstanding_cmds[handle])
1774− break;
1775− }
1776−
1777− if (index == req->num_outstanding_cmds)
1767+ handle = qla2xxx_get_next_handle(req);
1768+ if (handle == 0)
17781769 goto queuing_error;
17791770
17801771 /* Compute number of required data segments */
@@ -1919,7 +1910,6 @@ qla2xxx_start_scsi_mq(srb_t *sp) · 138 unmodified lines
19191910 int nseg;
19201911 unsigned long flags;
19211912 uint32_t *clr_ptr;
1922− uint32_t index;
19231913 uint32_t handle;
19241914 struct cmd_type_7 *cmd_pkt;
19251915 uint16_t cnt;
@@ -1950,16 +1940,8 @@ qla2xxx_start_scsi_mq(srb_t *sp) · 24 unmodified lines
19501940 vha->marker_needed = 0;
19511941 }
19521942
1953− /* Check for room in outstanding command list. */
1954− handle = req->current_outstanding_cmd;
1955− for (index = 1; index < req->num_outstanding_cmds; index++) {
1956− handle++;
1957− if (handle == req->num_outstanding_cmds)
1958− handle = 1;
1959− if (!req->outstanding_cmds[handle])
1960− break;
1961− }
1962− if (index == req->num_outstanding_cmds)
1943+ handle = qla2xxx_get_next_handle(req);
1944+ if (handle == 0)
19631945 goto queuing_error;
19641946
19651947 /* Map the sg table so we have an accurate count of sg entries needed */
@@ -2063,7 +2045,6 @@ qla2xxx_dif_start_scsi_mq(srb_t *sp) · 97 unmodified lines
20632045 int nseg;
20642046 unsigned long flags;
20652047 uint32_t *clr_ptr;
2066− uint32_t index;
20672048 uint32_t handle;
20682049 uint16_t cnt;
20692050 uint16_t req_cnt = 0;
@@ -2118,17 +2099,8 @@ qla2xxx_dif_start_scsi_mq(srb_t *sp) · 48 unmodified lines
21182099 vha->marker_needed = 0;
21192100 }
21202101
2121− /* Check for room in outstanding command list. */
2122− handle = req->current_outstanding_cmd;
2123− for (index = 1; index < req->num_outstanding_cmds; index++) {
2124− handle++;
2125− if (handle == req->num_outstanding_cmds)
2126− handle = 1;
2127− if (!req->outstanding_cmds[handle])
2128− break;
2129− }
2130−
2131− if (index == req->num_outstanding_cmds)
2102+ handle = qla2xxx_get_next_handle(req);
2103+ if (handle == 0)
21322104 goto queuing_error;
21332105
21342106 /* Compute number of required data segments */
@@ -2275,7 +2247,7 @@ __qla2x00_alloc_iocbs(struct qla_qpair *qpair, srb_t *sp) · 140 unmodified lines
22752247 struct qla_hw_data *ha = vha->hw;
22762248 struct req_que *req = qpair->req;
22772249 device_reg_t *reg = ISP_QUE_REG(ha, req->id);
2278− uint32_t index, handle;
2250+ uint32_t handle;
22792251 request_t *pkt;
22802252 uint16_t cnt, req_cnt;
22812253
@@ -2315,16 +2287,8 @@ __qla2x00_alloc_iocbs(struct qla_qpair *qpair, srb_t *sp) · 33 unmodified lines
23152287 goto queuing_error;
23162288
23172289 if (sp) {
2318− /* Check for room in outstanding command list. */
2319− handle = req->current_outstanding_cmd;
2320− for (index = 1; index < req->num_outstanding_cmds; index++) {
2321− handle++;
2322− if (handle == req->num_outstanding_cmds)
2323− handle = 1;
2324− if (!req->outstanding_cmds[handle])
2325− break;
2326− }
2327− if (index == req->num_outstanding_cmds) {
2290+ handle = qla2xxx_get_next_handle(req);
2291+ if (handle == 0) {
23282292 ql_log(ql_log_warn, vha, 0x700b,
23292293 "No room on outstanding cmd array.\n");
23302294 goto queuing_error;
@@ -2540,13 +2504,11 @@ void qla2x00_init_timer(srb_t *sp, unsigned long tmo) · 209 unmodified lines
25402504 sp->free = qla2x00_sp_free;
25412505 if (IS_QLAFX00(sp->vha->hw) && sp->type == SRB_FXIOCB_DCMD)
25422506 init_completion(&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp);
2543− add_timer(&sp->u.iocb_cmd.timer);
2507+ sp->start_timer = 1;
25442508 }
25452509
2546−static void
2547−qla2x00_els_dcmd_sp_free(void *data)
2510+static void qla2x00_els_dcmd_sp_free(srb_t *sp)
25482511 {
2549− srb_t *sp = data;
25502512 struct srb_iocb *elsio = &sp->u.iocb_cmd;
25512513
25522514 kfree(sp->fcport);
@@ -2576,10 +2538,8 @@ qla2x00_els_dcmd_iocb_timeout(void *data) · 23 unmodified lines
25762538 complete(&lio->u.els_logo.comp);
25772539 }
25782540
2579−static void
2580−qla2x00_els_dcmd_sp_done(void *ptr, int res)
2541+static void qla2x00_els_dcmd_sp_done(srb_t *sp, int res)
25812542 {
2582− srb_t *sp = ptr;
25832543 fc_port_t *fcport = sp->fcport;
25842544 struct srb_iocb *lio = &sp->u.iocb_cmd;
25852545 struct scsi_qla_host *vha = sp->vha;
@@ -2699,16 +2659,16 @@ qla24xx_els_logo_iocb(srb_t *sp, struct els_entry_24xx *els_iocb) · 113 unmodified lines
26992659 els_iocb->s_id[0] = vha->d_id.b.al_pa;
27002660 els_iocb->s_id[1] = vha->d_id.b.area;
27012661 els_iocb->s_id[2] = vha->d_id.b.domain;
2702− els_iocb->control_flags = 0;
27032662
27042663 if (elsio->u.els_logo.els_cmd == ELS_DCMD_PLOGI) {
2664+ els_iocb->control_flags = 0;
27052665 els_iocb->tx_byte_count = els_iocb->tx_len =
2706− sizeof(struct els_plogi_payload);
2666+ cpu_to_le32(sizeof(struct els_plogi_payload));
27072667 put_unaligned_le64(elsio->u.els_plogi.els_plogi_pyld_dma,
27082668 &els_iocb->tx_address);
27092669 els_iocb->rx_dsd_count = 1;
27102670 els_iocb->rx_byte_count = els_iocb->rx_len =
2711− sizeof(struct els_plogi_payload);
2671+ cpu_to_le32(sizeof(struct els_plogi_payload));
27122672 put_unaligned_le64(elsio->u.els_plogi.els_resp_pyld_dma,
27132673 &els_iocb->rx_address);
27142674
@@ -2717,7 +2677,9 @@ qla24xx_els_logo_iocb(srb_t *sp, struct els_entry_24xx *els_iocb) · 2 unmodified lines
27172677 ql_dump_buffer(ql_log_info, vha, 0x0109,
27182678 (uint8_t *)els_iocb, 0x70);
27192679 } else {
2720− els_iocb->tx_byte_count = sizeof(struct els_logo_payload);
2680+ els_iocb->control_flags = 1 << 13;
2681+ els_iocb->tx_byte_count =
2682+ cpu_to_le32(sizeof(struct els_logo_payload));
27212683 put_unaligned_le64(elsio->u.els_logo.els_logo_pyld_dma,
27222684 &els_iocb->tx_address);
27232685 els_iocb->tx_len = cpu_to_le32(sizeof(struct els_logo_payload));
@@ -2755,10 +2717,23 @@ qla2x00_els_dcmd2_iocb_timeout(void *data) · 31 unmodified lines
27552717 sp->done(sp, QLA_FUNCTION_TIMEOUT);
27562718 }
27572719
2758−static void
2759−qla2x00_els_dcmd2_sp_done(void *ptr, int res)
2720+void qla2x00_els_dcmd2_free(scsi_qla_host_t *vha, struct els_plogi *els_plogi)
2721+{
2722+ if (els_plogi->els_plogi_pyld)
2723+ dma_free_coherent(&vha->hw->pdev->dev,
2724+ els_plogi->tx_size,
2725+ els_plogi->els_plogi_pyld,
2726+ els_plogi->els_plogi_pyld_dma);
2727+
2728+ if (els_plogi->els_resp_pyld)
2729+ dma_free_coherent(&vha->hw->pdev->dev,
2730+ els_plogi->rx_size,
2731+ els_plogi->els_resp_pyld,
2732+ els_plogi->els_resp_pyld_dma);
2733+}
2734+
2735+static void qla2x00_els_dcmd2_sp_done(srb_t *sp, int res)
27602736 {
2761− srb_t *sp = ptr;
27622737 fc_port_t *fcport = sp->fcport;
27632738 struct srb_iocb *lio = &sp->u.iocb_cmd;
27642739 struct scsi_qla_host *vha = sp->vha;
@@ -2780,26 +2755,16 @@ qla2x00_els_dcmd2_sp_done(void *ptr, int res) · 15 unmodified lines
27802755 } else {
27812756 memset(&ea, 0, sizeof(ea));
27822757 ea.fcport = fcport;
2783− ea.rc = res;
2784− ea.event = FCME_ELS_PLOGI_DONE;
2785− qla2x00_fcport_event_handler(vha, &ea);
2758+ ea.data[0] = MBS_COMMAND_COMPLETE;
2759+ ea.sp = sp;
2760+ qla24xx_handle_plogi_done_event(vha, &ea);
27862761 }
27872762
27882763 e = qla2x00_alloc_work(vha, QLA_EVT_UNMAP);
27892764 if (!e) {
27902765 struct srb_iocb *elsio = &sp->u.iocb_cmd;
27912766
2792− if (elsio->u.els_plogi.els_plogi_pyld)
2793− dma_free_coherent(&sp->vha->hw->pdev->dev,
2794− elsio->u.els_plogi.tx_size,
2795− elsio->u.els_plogi.els_plogi_pyld,
2796− elsio->u.els_plogi.els_plogi_pyld_dma);
2797−
2798− if (elsio->u.els_plogi.els_resp_pyld)
2799− dma_free_coherent(&sp->vha->hw->pdev->dev,
2800− elsio->u.els_plogi.rx_size,
2801− elsio->u.els_plogi.els_resp_pyld,
2802− elsio->u.els_plogi.els_resp_pyld_dma);
2767+ qla2x00_els_dcmd2_free(vha, &elsio->u.els_plogi);
28032768 sp->free(sp);
28042769 return;
28052770 }
@@ -2899,18 +2864,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode, · 93 unmodified lines
28992864
29002865 out:
29012866 fcport->flags &= ~(FCF_ASYNC_SENT);
2902− if (elsio->u.els_plogi.els_plogi_pyld)
2903− dma_free_coherent(&sp->vha->hw->pdev->dev,
2904− elsio->u.els_plogi.tx_size,
2905− elsio->u.els_plogi.els_plogi_pyld,
2906− elsio->u.els_plogi.els_plogi_pyld_dma);
2907−
2908− if (elsio->u.els_plogi.els_resp_pyld)
2909− dma_free_coherent(&sp->vha->hw->pdev->dev,
2910− elsio->u.els_plogi.rx_size,
2911− elsio->u.els_plogi.els_resp_pyld,
2912− elsio->u.els_plogi.els_resp_pyld_dma);
2913−
2867+ qla2x00_els_dcmd2_free(vha, &elsio->u.els_plogi);
29142868 sp->free(sp);
29152869 done:
29162870 return rval;
@@ -3115,7 +3069,6 @@ qla82xx_start_scsi(srb_t *sp) · 198 unmodified lines
31153069 unsigned long flags;
31163070 struct scsi_cmnd *cmd;
31173071 uint32_t *clr_ptr;
3118− uint32_t index;
31193072 uint32_t handle;
31203073 uint16_t cnt;
31213074 uint16_t req_cnt;
@@ -3155,16 +3108,8 @@ qla82xx_start_scsi(srb_t *sp) · 33 unmodified lines
31553108 /* Acquire ring specific lock */
31563109 spin_lock_irqsave(&ha->hardware_lock, flags);
31573110
3158− /* Check for room in outstanding command list. */
3159− handle = req->current_outstanding_cmd;
3160− for (index = 1; index < req->num_outstanding_cmds; index++) {
3161− handle++;
3162− if (handle == req->num_outstanding_cmds)
3163− handle = 1;
3164− if (!req->outstanding_cmds[handle])
3165− break;
3166− }
3167− if (index == req->num_outstanding_cmds)
3111+ handle = qla2xxx_get_next_handle(req);
3112+ if (handle == 0)
31683113 goto queuing_error;
31693114
31703115 /* Map the sg table so we have an accurate count of sg entries needed */
@@ -3235,7 +3180,7 @@ sufficient_dsds: · 64 unmodified lines
32353180 goto queuing_error;
32363181 }
32373182
3238− ctx = sp->u.scmd.ctx =
3183+ ctx = sp->u.scmd.ct6_ctx =
32393184 mempool_alloc(ha->ctx_mempool, GFP_ATOMIC);
32403185 if (!ctx) {
32413186 ql_log(ql_log_fatal, vha, 0x3010,
@@ -3431,9 +3376,9 @@ queuing_error: · 189 unmodified lines
34313376 if (tot_dsds)
34323377 scsi_dma_unmap(cmd);
34333378
3434− if (sp->u.scmd.ctx) {
3435− mempool_free(sp->u.scmd.ctx, ha->ctx_mempool);
3436− sp->u.scmd.ctx = NULL;
3379+ if (sp->u.scmd.crc_ctx) {
3380+ mempool_free(sp->u.scmd.crc_ctx, ha->ctx_mempool);
3381+ sp->u.scmd.crc_ctx = NULL;
34373382 }
34383383 spin_unlock_irqrestore(&ha->hardware_lock, flags);
34393384
@@ -3668,6 +3613,9 @@ qla2x00_start_sp(srb_t *sp) · 228 unmodified lines
36683613 break;
36693614 }
36703615
3616+ if (sp->start_timer)
3617+ add_timer(&sp->u.iocb_cmd.timer);
3618+
36713619 wmb();
36723620 qla2x00_start_iocbs(vha, qp->req);
36733621 done:
@@ -3769,7 +3717,6 @@ qla2x00_start_bidir(srb_t *sp, struct scsi_qla_host *vha, uint32_t tot_dsds) · 95 unmodified lines
37693717 struct qla_hw_data *ha = vha->hw;
37703718 unsigned long flags;
37713719 uint32_t handle;
3772− uint32_t index;
37733720 uint16_t req_cnt;
37743721 uint16_t cnt;
37753722 uint32_t *clr_ptr;
@@ -3794,17 +3741,8 @@ qla2x00_start_bidir(srb_t *sp, struct scsi_qla_host *vha, uint32_t tot_dsds) · 18 unmodified lines
37943741 /* Acquire ring specific lock */
37953742 spin_lock_irqsave(&ha->hardware_lock, flags);
37963743
3797− /* Check for room in outstanding command list. */
3798− handle = req->current_outstanding_cmd;
3799− for (index = 1; index < req->num_outstanding_cmds; index++) {
3800− handle++;
3801− if (handle == req->num_outstanding_cmds)
3802− handle = 1;
3803− if (!req->outstanding_cmds[handle])
3804− break;
3805− }
3806−
3807− if (index == req->num_outstanding_cmds) {
3744+ handle = qla2xxx_get_next_handle(req);
3745+ if (handle == 0) {
38083746 rval = EXT_STATUS_BUSY;
38093747 goto queuing_error;
38103748 }
drivers/scsi/qla2xxx/qla_isr.c+11−18
@@ -776,7 +776,6 @@ skip_rio: · 775 unmodified lines
776776 case MBA_LOOP_INIT_ERR:
777777 ql_log(ql_log_warn, vha, 0x5090,
778778 "LOOP INIT ERROR (%x).\n", mb[1]);
779− ha->isp_ops->fw_dump(vha, 1);
780779 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
781780 break;
782781
@@ -1119,10 +1118,9 @@ global_port_update: · 336 unmodified lines
11191118 struct event_arg ea;
11201119
11211120 memset(&ea, 0, sizeof(ea));
1122− ea.event = FCME_RSCN;
11231121 ea.id.b24 = rscn_entry;
11241122 ea.id.b.rsvd_1 = rscn_entry >> 24;
1125− qla2x00_fcport_event_handler(vha, &ea);
1123+ qla2x00_handle_rscn(vha, &ea);
11261124 qla2x00_post_aen_work(vha, FCH_EVT_RSCN, rscn_entry);
11271125 }
11281126 break;
@@ -1514,7 +1512,7 @@ qla2x00_ct_entry(scsi_qla_host_t *vha, struct req_que *req, · 385 unmodified lines
15141512 if (comp_status == CS_DATA_UNDERRUN) {
15151513 res = DID_OK << 16;
15161514 bsg_reply->reply_payload_rcv_len =
1517− le16_to_cpu(((sts_entry_t *)pkt)->rsp_info_len);
1515+ le16_to_cpu(pkt->rsp_info_len);
15181516
15191517 ql_log(ql_log_warn, vha, 0x5048,
15201518 "CT pass-through-%s error comp_status=0x%x total_byte=0x%x.\n",
@@ -2257,11 +2255,8 @@ qla25xx_process_bidir_status_iocb(scsi_qla_host_t *vha, void *pkt, · 736 unmodified lines
22572255 struct bsg_job *bsg_job = NULL;
22582256 struct fc_bsg_request *bsg_request;
22592257 struct fc_bsg_reply *bsg_reply;
2260− sts_entry_t *sts;
2261− struct sts_entry_24xx *sts24;
2262−
2263− sts = (sts_entry_t *) pkt;
2264− sts24 = (struct sts_entry_24xx *) pkt;
2258+ sts_entry_t *sts = pkt;
2259+ struct sts_entry_24xx *sts24 = pkt;
22652260
22662261 /* Validate handle. */
22672262 if (index >= req->num_outstanding_cmds) {
@@ -2407,8 +2402,8 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) · 139 unmodified lines
24072402 srb_t *sp;
24082403 fc_port_t *fcport;
24092404 struct scsi_cmnd *cp;
2410− sts_entry_t *sts;
2411− struct sts_entry_24xx *sts24;
2405+ sts_entry_t *sts = pkt;
2406+ struct sts_entry_24xx *sts24 = pkt;
24122407 uint16_t comp_status;
24132408 uint16_t scsi_status;
24142409 uint16_t ox_id;
@@ -2426,8 +2421,6 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) · 11 unmodified lines
24262421 uint16_t state_flags = 0;
24272422 uint16_t retry_delay = 0;
24282423
2429− sts = (sts_entry_t *) pkt;
2430− sts24 = (struct sts_entry_24xx *) pkt;
24312424 if (IS_FWI2_CAPABLE(ha)) {
24322425 comp_status = le16_to_cpu(sts24->comp_status);
24332426 scsi_status = le16_to_cpu(sts24->scsi_status) & SS_MASK;
@@ -2727,7 +2720,7 @@ check_scsi_status: · 293 unmodified lines
27272720 "Port to be marked lost on fcport=%02x%02x%02x, current "
27282721 "port state= %s comp_status %x.\n", fcport->d_id.b.domain,
27292722 fcport->d_id.b.area, fcport->d_id.b.al_pa,
2730− port_state_str[atomic_read(&fcport->state)],
2723+ port_state_str[FCS_ONLINE],
27312724 comp_status);
27322725
27332726 qla2x00_mark_device_lost(fcport->vha, fcport, 1, 1);
@@ -2844,6 +2837,8 @@ qla2x00_status_cont_entry(struct rsp_que *rsp, sts_cont_entry_t *pkt) · 110 unmodified lines
28442837 if (sense_len == 0) {
28452838 rsp->status_srb = NULL;
28462839 sp->done(sp, cp->result);
2840+ } else {
2841+ WARN_ON_ONCE(true);
28472842 }
28482843 }
28492844
@@ -3471,10 +3466,8 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) · 621 unmodified lines
34713466 ha->msix_count, ret);
34723467 goto msix_out;
34733468 } else if (ret < ha->msix_count) {
3474− ql_log(ql_log_warn, vha, 0x00c6,
3475− "MSI-X: Failed to enable support "
3476− "with %d vectors, using %d vectors.\n",
3477− ha->msix_count, ret);
3469+ ql_log(ql_log_info, vha, 0x00c6,
3470+ "MSI-X: Using %d vectors\n", ret);
34783471 ha->msix_count = ret;
34793472 /* Recalculate queue values */
34803473 if (ha->mqiobase && (ql2xmqsupport || ql2xnvmeenable)) {
drivers/scsi/qla2xxx/qla_mbx.c+8−18
@@ -253,21 +253,9 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) · 252 unmodified lines
253253 if ((!abort_active && io_lock_on) || IS_NOPOLLING_TYPE(ha)) {
254254 set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
255255
256− if (IS_P3P_TYPE(ha)) {
257− if (RD_REG_DWORD(&reg->isp82.hint) &
258− HINT_MBX_INT_PENDING) {
259− ha->flags.mbox_busy = 0;
260− spin_unlock_irqrestore(&ha->hardware_lock,
261− flags);
262−
263− atomic_dec(&ha->num_pend_mbx_stage2);
264− ql_dbg(ql_dbg_mbx, vha, 0x1010,
265− "Pending mailbox timeout, exiting.\n");
266− rval = QLA_FUNCTION_TIMEOUT;
267− goto premature_exit;
268− }
256+ if (IS_P3P_TYPE(ha))
269257 WRT_REG_DWORD(&reg->isp82.hint, HINT_MBX_INT_PENDING);
270− } else if (IS_FWI2_CAPABLE(ha))
258+ else if (IS_FWI2_CAPABLE(ha))
271259 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT);
272260 else
273261 WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT);
@@ -394,8 +382,12 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) · 120 unmodified lines
394382 goto premature_exit;
395383 }
396384
397− if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE)
385+ if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE) {
386+ ql_dbg(ql_dbg_mbx, vha, 0x11ff,
387+ "mb_out[0] = %#x <> %#x\n", ha->mailbox_out[0],
388+ MBS_COMMAND_COMPLETE);
398389 rval = QLA_FUNCTION_FAILED;
390+ }
399391
400392 /* Load return mailbox registers. */
401393 iptr2 = mcp->mb;
@@ -6213,10 +6205,8 @@ qla26xx_dport_diagnostics(scsi_qla_host_t *vha, · 5811 unmodified lines
62136205 return rval;
62146206 }
62156207
6216−static void qla2x00_async_mb_sp_done(void *s, int res)
6208+static void qla2x00_async_mb_sp_done(srb_t *sp, int res)
62176209 {
6218− struct srb *sp = s;
6219−
62206210 sp->u.iocb_cmd.u.mbx.rc = res;
62216211
62226212 complete(&sp->u.iocb_cmd.u.mbx.comp);
drivers/scsi/qla2xxx/qla_mid.c+1−3
@@ -901,10 +901,8 @@ failed: · 900 unmodified lines
901901 return 0;
902902 }
903903
904−static void qla_ctrlvp_sp_done(void *s, int res)
904+static void qla_ctrlvp_sp_done(srb_t *sp, int res)
905905 {
906− struct srb *sp = s;
907−
908906 if (sp->comp)
909907 complete(sp->comp);
910908 /* don't free sp here. Let the caller do the free */
drivers/scsi/qla2xxx/qla_mr.c+30−37
@@ -10,7 +10,6 @@ · 9 unmodified lines
1010 #include <linux/pci.h>
1111 #include <linux/ratelimit.h>
1212 #include <linux/vmalloc.h>
13−#include <linux/bsg-lib.h>
1413 #include <scsi/scsi_tcq.h>
1514 #include <linux/utsname.h>
1615
@@ -149,7 +148,8 @@ qlafx00_mailbox_command(scsi_qla_host_t *vha, struct mbx_cmd_32 *mcp) · 132 unmodified lines
149148 QLAFX00_SET_HST_INTR(ha, ha->mbx_intr_code);
150149 spin_unlock_irqrestore(&ha->hardware_lock, flags);
151150
152− wait_for_completion_timeout(&ha->mbx_intr_comp, mcp->tov * HZ);
151+ WARN_ON_ONCE(wait_for_completion_timeout(&ha->mbx_intr_comp,
152+ mcp->tov * HZ) != 0);
153153 } else {
154154 ql_dbg(ql_dbg_mbx, vha, 0x112c,
155155 "Cmd=%x Polling Mode.\n", command);
@@ -688,14 +688,12 @@ qlafx00_config_rings(struct scsi_qla_host *vha) · 532 unmodified lines
688688 }
689689
690690 char *
691−qlafx00_pci_info_str(struct scsi_qla_host *vha, char *str)
691+qlafx00_pci_info_str(struct scsi_qla_host *vha, char *str, size_t str_len)
692692 {
693693 struct qla_hw_data *ha = vha->hw;
694694
695− if (pci_is_pcie(ha->pdev)) {
696− strcpy(str, "PCIe iSA");
697− return str;
698− }
695+ if (pci_is_pcie(ha->pdev))
696+ strlcpy(str, "PCIe iSA", str_len);
699697 return str;
700698 }
701699
@@ -1799,10 +1797,8 @@ qla2x00_fxdisc_iocb_timeout(void *data) · 1097 unmodified lines
17991797 complete(&lio->u.fxiocb.fxiocb_comp);
18001798 }
18011799
1802−static void
1803−qla2x00_fxdisc_sp_done(void *ptr, int res)
1800+static void qla2x00_fxdisc_sp_done(srb_t *sp, int res)
18041801 {
1805− srb_t *sp = ptr;
18061802 struct srb_iocb *lio = &sp->u.iocb_cmd;
18071803
18081804 complete(&lio->u.fxiocb.fxiocb_comp);
@@ -1881,22 +1877,22 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint16_t fx_type) · 72 unmodified lines
18811877 phost_info = &preg_hsi->hsi;
18821878 memset(preg_hsi, 0, sizeof(struct register_host_info));
18831879 phost_info->os_type = OS_TYPE_LINUX;
1884− strncpy(phost_info->sysname,
1885− p_sysid->sysname, SYSNAME_LENGTH);
1886− strncpy(phost_info->nodename,
1887− p_sysid->nodename, NODENAME_LENGTH);
1880+ strlcpy(phost_info->sysname, p_sysid->sysname,
1881+ sizeof(phost_info->sysname));
1882+ strlcpy(phost_info->nodename, p_sysid->nodename,
1883+ sizeof(phost_info->nodename));
18881884 if (!strcmp(phost_info->nodename, "(none)"))
18891885 ha->mr.host_info_resend = true;
1890− strncpy(phost_info->release,
1891− p_sysid->release, RELEASE_LENGTH);
1892− strncpy(phost_info->version,
1893− p_sysid->version, VERSION_LENGTH);
1894− strncpy(phost_info->machine,
1895− p_sysid->machine, MACHINE_LENGTH);
1896− strncpy(phost_info->domainname,
1897− p_sysid->domainname, DOMNAME_LENGTH);
1898− strncpy(phost_info->hostdriver,
1899− QLA2XXX_VERSION, VERSION_LENGTH);
1886+ strlcpy(phost_info->release, p_sysid->release,
1887+ sizeof(phost_info->release));
1888+ strlcpy(phost_info->version, p_sysid->version,
1889+ sizeof(phost_info->version));
1890+ strlcpy(phost_info->machine, p_sysid->machine,
1891+ sizeof(phost_info->machine));
1892+ strlcpy(phost_info->domainname, p_sysid->domainname,
1893+ sizeof(phost_info->domainname));
1894+ strlcpy(phost_info->hostdriver, QLA2XXX_VERSION,
1895+ sizeof(phost_info->hostdriver));
19001896 preg_hsi->utc = (uint64_t)ktime_get_real_seconds();
19011897 ql_dbg(ql_dbg_init, vha, 0x0149,
19021898 "ISP%04X: Host registration with firmware\n",
@@ -1941,8 +1937,10 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint16_t fx_type) · 38 unmodified lines
19411937 if (fx_type == FXDISC_GET_CONFIG_INFO) {
19421938 struct config_info_data *pinfo =
19431939 (struct config_info_data *) fdisc->u.fxiocb.rsp_addr;
1944− strcpy(vha->hw->model_number, pinfo->model_num);
1945− strcpy(vha->hw->model_desc, pinfo->model_description);
1940+ strlcpy(vha->hw->model_number, pinfo->model_num,
1941+ ARRAY_SIZE(vha->hw->model_number));
1942+ strlcpy(vha->hw->model_desc, pinfo->model_description,
1943+ ARRAY_SIZE(vha->hw->model_desc));
19461944 memcpy(&vha->hw->mr.symbolic_name, pinfo->symbolic_name,
19471945 sizeof(vha->hw->mr.symbolic_name));
19481946 memcpy(&vha->hw->mr.serial_num, pinfo->serial_num,
@@ -2541,6 +2539,8 @@ check_scsi_status: · 592 unmodified lines
25412539
25422540 if (rsp->status_srb == NULL)
25432541 sp->done(sp, res);
2542+ else
2543+ WARN_ON_ONCE(true);
25442544 }
25452545
25462546 /**
@@ -2618,6 +2618,8 @@ qlafx00_status_cont_entry(struct rsp_que *rsp, sts_cont_entry_t *pkt) · 71 unmodified lines
26182618 if (sense_len == 0) {
26192619 rsp->status_srb = NULL;
26202620 sp->done(sp, cp->result);
2621+ } else {
2622+ WARN_ON_ONCE(true);
26212623 }
26222624 }
26232625
@@ -3073,7 +3075,6 @@ qlafx00_start_scsi(srb_t *sp) · 449 unmodified lines
30733075 {
30743076 int nseg;
30753077 unsigned long flags;
3076− uint32_t index;
30773078 uint32_t handle;
30783079 uint16_t cnt;
30793080 uint16_t req_cnt;
@@ -3097,16 +3098,8 @@ qlafx00_start_scsi(srb_t *sp) · 17 unmodified lines
30973098 /* Acquire ring specific lock */
30983099 spin_lock_irqsave(&ha->hardware_lock, flags);
30993100
3100− /* Check for room in outstanding command list. */
3101− handle = req->current_outstanding_cmd;
3102− for (index = 1; index < req->num_outstanding_cmds; index++) {
3103− handle++;
3104− if (handle == req->num_outstanding_cmds)
3105− handle = 1;
3106− if (!req->outstanding_cmds[handle])
3107− break;
3108− }
3109− if (index == req->num_outstanding_cmds)
3101+ handle = qla2xxx_get_next_handle(req);
3102+ if (handle == 0)
31103103 goto queuing_error;
31113104
31123105 /* Map the sg table so we have an accurate count of sg entries needed */
drivers/scsi/qla2xxx/qla_nvme.c+10−22
@@ -180,10 +180,9 @@ static void qla_nvme_ls_complete(struct work_struct *work) · 179 unmodified lines
180180 kref_put(&priv->sp->cmd_kref, qla_nvme_release_ls_cmd_kref);
181181 }
182182
183−static void qla_nvme_sp_ls_done(void *ptr, int res)
183+static void qla_nvme_sp_ls_done(srb_t *sp, int res)
184184 {
185− srb_t *sp = ptr;
186− struct nvme_private *priv;
185+ struct nvme_private *priv = sp->priv;
187186
188187 if (WARN_ON_ONCE(kref_read(&sp->cmd_kref) == 0))
189188 return;
@@ -191,17 +190,15 @@ static void qla_nvme_sp_ls_done(void *ptr, int res) · 1 unmodified line
191190 if (res)
192191 res = -EINVAL;
193192
194− priv = (struct nvme_private *)sp->priv;
195193 priv->comp_status = res;
196194 INIT_WORK(&priv->ls_work, qla_nvme_ls_complete);
197195 schedule_work(&priv->ls_work);
198196 }
199197
200198 /* it assumed that QPair lock is held. */
201−static void qla_nvme_sp_done(void *ptr, int res)
199+static void qla_nvme_sp_done(srb_t *sp, int res)
202200 {
203− srb_t *sp = ptr;
204− struct nvme_private *priv = (struct nvme_private *)sp->priv;
201+ struct nvme_private *priv = sp->priv;
205202
206203 priv->comp_status = res;
207204 kref_put(&sp->cmd_kref, qla_nvme_release_fcp_cmd_kref);
@@ -222,7 +219,7 @@ static void qla_nvme_abort_work(struct work_struct *work) · 14 unmodified lines
222219 "%s called for sp=%p, hndl=%x on fcport=%p deleted=%d\n",
223220 __func__, sp, sp->handle, fcport, fcport->deleted);
224221
225− if (!ha->flags.fw_started && (fcport && fcport->deleted))
222+ if (!ha->flags.fw_started && fcport->deleted)
226223 goto out;
227224
228225 if (ha->flags.host_shutting_down) {
@@ -267,7 +264,6 @@ static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport, · 38 unmodified lines
267264 schedule_work(&priv->abort_work);
268265 }
269266
270−
271267 static int qla_nvme_ls_req(struct nvme_fc_local_port *lport,
272268 struct nvme_fc_remote_port *rport, struct nvmefc_ls_req *fd)
273269 {
@@ -357,7 +353,6 @@ static inline int qla2x00_start_nvme_mq(srb_t *sp) · 83 unmodified lines
357353 {
358354 unsigned long flags;
359355 uint32_t *clr_ptr;
360− uint32_t index;
361356 uint32_t handle;
362357 struct cmd_nvme *cmd_pkt;
363358 uint16_t cnt, i;
@@ -381,17 +376,8 @@ static inline int qla2x00_start_nvme_mq(srb_t *sp) · 17 unmodified lines
381376 /* Acquire qpair specific lock */
382377 spin_lock_irqsave(&qpair->qp_lock, flags);
383378
384− /* Check for room in outstanding command list. */
385− handle = req->current_outstanding_cmd;
386− for (index = 1; index < req->num_outstanding_cmds; index++) {
387− handle++;
388− if (handle == req->num_outstanding_cmds)
389− handle = 1;
390− if (!req->outstanding_cmds[handle])
391− break;
392− }
393−
394− if (index == req->num_outstanding_cmds) {
379+ handle = qla2xxx_get_next_handle(req);
380+ if (handle == 0) {
395381 rval = -EBUSY;
396382 goto queuing_error;
397383 }
@@ -653,7 +639,9 @@ void qla_nvme_unregister_remote_port(struct fc_port *fcport) · 255 unmodified lines
653639 "%s: unregister remoteport on %p %8phN\n",
654640 __func__, fcport, fcport->port_name);
655641
656− nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port, 0);
642+ if (test_bit(PFLG_DRIVER_REMOVING, &fcport->vha->pci_flags))
643+ nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port, 0);
644+
657645 init_completion(&fcport->nvme_del_done);
658646 ret = nvme_fc_unregister_remoteport(fcport->nvme_remote_port);
659647 if (ret)
drivers/scsi/qla2xxx/qla_nvme.h+2−3
@@ -7,7 +7,6 @@ · 6 unmodified lines
77 #ifndef __QLA_NVME_H
88 #define __QLA_NVME_H
99
10−#include <linux/blk-mq.h>
1110 #include <uapi/scsi/fc/fc_fs.h>
1211 #include <uapi/scsi/fc/fc_els.h>
1312 #include <linux/nvme-fc-driver.h>
@@ -119,7 +118,7 @@ struct pt_ls4_rx_unsol { · 105 unmodified lines
119118 uint32_t exchange_address;
120119 uint8_t d_id[3];
121120 uint8_t r_ctl;
122− uint8_t s_id[3];
121+ be_id_t s_id;
123122 uint8_t cs_ctl;
124123 uint8_t f_ctl[3];
125124 uint8_t type;
@@ -144,5 +143,5 @@ int qla_nvme_register_remote(struct scsi_qla_host *, struct fc_port *); · 18 unmodified lines
144143 void qla_nvme_delete(struct scsi_qla_host *);
145144 void qla24xx_nvme_ls4_iocb(struct scsi_qla_host *, struct pt_ls4_request *,
146145 struct req_que *);
147−void qla24xx_async_gffid_sp_done(void *, int);
146+void qla24xx_async_gffid_sp_done(struct srb *sp, int);
148147 #endif
drivers/scsi/qla2xxx/qla_nx.c+13−9
@@ -1977,7 +1977,7 @@ qla82xx_check_rcvpeg_state(struct qla_hw_data *ha) · 1976 unmodified lines
19771977 } while (--retries);
19781978
19791979 ql_log(ql_log_fatal, vha, 0x00ac,
1980− "Rcv Peg initializatin failed: 0x%x.\n", val);
1980+ "Rcv Peg initialization failed: 0x%x.\n", val);
19811981 read_lock(&ha->hw_lock);
19821982 qla82xx_wr_32(ha, CRB_RCVPEG_STATE, PHAN_INITIALIZE_FAILED);
19831983 read_unlock(&ha->hw_lock);
@@ -1985,7 +1985,7 @@ qla82xx_check_rcvpeg_state(struct qla_hw_data *ha) · 1 unmodified line
19851985 }
19861986
19871987 /* ISR related functions */
1988−static struct qla82xx_legacy_intr_set legacy_intr[] = \
1988+static struct qla82xx_legacy_intr_set legacy_intr[] =
19891989 QLA82XX_LEGACY_INTR_CONFIG;
19901990
19911991 /*
@@ -2287,7 +2287,9 @@ qla82xx_disable_intrs(struct qla_hw_data *ha) · 295 unmodified lines
22872287 {
22882288 scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
22892289
2290− qla82xx_mbx_intr_disable(vha);
2290+ if (ha->interrupts_on)
2291+ qla82xx_mbx_intr_disable(vha);
2292+
22912293 spin_lock_irq(&ha->hardware_lock);
22922294 if (IS_QLA8044(ha))
22932295 qla8044_wr_reg(ha, LEG_INTR_MASK_OFFSET, 1);
@@ -3286,7 +3288,7 @@ qla82xx_device_state_handler(scsi_qla_host_t *vha) · 992 unmodified lines
32863288 case QLA8XXX_DEV_NEED_QUIESCENT:
32873289 qla82xx_need_qsnt_handler(vha);
32883290 /* Reset timeout value after quiescence handler */
3289− dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout\
3291+ dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout
32903292 * HZ);
32913293 break;
32923294 case QLA8XXX_DEV_QUIESCENT:
@@ -3301,7 +3303,7 @@ qla82xx_device_state_handler(scsi_qla_host_t *vha) · 8 unmodified lines
33013303 qla82xx_idc_lock(ha);
33023304
33033305 /* Reset timeout value after quiescence handler */
3304− dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout\
3306+ dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout
33053307 * HZ);
33063308 break;
33073309 case QLA8XXX_DEV_FAILED:
@@ -3686,7 +3688,7 @@ qla82xx_chip_reset_cleanup(scsi_qla_host_t *vha) · 378 unmodified lines
36863688 for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) {
36873689 sp = req->outstanding_cmds[cnt];
36883690 if (sp) {
3689− if ((!sp->u.scmd.ctx ||
3691+ if ((!sp->u.scmd.crc_ctx ||
36903692 (sp->flags &
36913693 SRB_FCP_CMND_DMA_VALID)) &&
36923694 !ha->flags.isp82xx_fw_hung) {
@@ -3710,10 +3712,12 @@ qla82xx_chip_reset_cleanup(scsi_qla_host_t *vha) · 17 unmodified lines
37103712
37113713 /* Wait for pending cmds (physical and virtual) to complete */
37123714 if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0,
3713− WAIT_HOST)) {
3715+ WAIT_HOST) == QLA_SUCCESS) {
37143716 ql_dbg(ql_dbg_init, vha, 0x00b3,
37153717 "Done wait for "
37163718 "pending commands.\n");
3719+ } else {
3720+ WARN_ON_ONCE(true);
37173721 }
37183722 }
37193723 }
@@ -4232,7 +4236,7 @@ qla82xx_md_collect(scsi_qla_host_t *vha) · 512 unmodified lines
42324236 goto md_failed;
42334237 }
42344238
4235− entry_hdr = (qla82xx_md_entry_hdr_t *) \
4239+ entry_hdr = (qla82xx_md_entry_hdr_t *)
42364240 (((uint8_t *)ha->md_tmplt_hdr) + tmplt_hdr->first_entry_offset);
42374241
42384242 /* Walk through the entry headers */
@@ -4339,7 +4343,7 @@ qla82xx_md_collect(scsi_qla_host_t *vha) · 100 unmodified lines
43394343 data_collected = (uint8_t *)data_ptr -
43404344 (uint8_t *)ha->md_dump;
43414345 skip_nxt_entry:
4342− entry_hdr = (qla82xx_md_entry_hdr_t *) \
4346+ entry_hdr = (qla82xx_md_entry_hdr_t *)
43434347 (((uint8_t *)entry_hdr) + entry_hdr->entry_size);
43444348 }
43454349
drivers/scsi/qla2xxx/qla_nx.h+7−7
@@ -486,13 +486,13 @@ · 485 unmodified lines
486486 #define QLA82XX_ADDR_QDR_NET (0x0000000300000000ULL)
487487 #define QLA82XX_P3_ADDR_QDR_NET_MAX (0x0000000303ffffffULL)
488488
489−#define QLA82XX_PCI_CRBSPACE (unsigned long)0x06000000
490−#define QLA82XX_PCI_DIRECT_CRB (unsigned long)0x04400000
491−#define QLA82XX_PCI_CAMQM (unsigned long)0x04800000
492−#define QLA82XX_PCI_CAMQM_MAX (unsigned long)0x04ffffff
493−#define QLA82XX_PCI_DDR_NET (unsigned long)0x00000000
494−#define QLA82XX_PCI_QDR_NET (unsigned long)0x04000000
495−#define QLA82XX_PCI_QDR_NET_MAX (unsigned long)0x043fffff
489+#define QLA82XX_PCI_CRBSPACE 0x06000000UL
490+#define QLA82XX_PCI_DIRECT_CRB 0x04400000UL
491+#define QLA82XX_PCI_CAMQM 0x04800000UL
492+#define QLA82XX_PCI_CAMQM_MAX 0x04ffffffUL
493+#define QLA82XX_PCI_DDR_NET 0x00000000UL
494+#define QLA82XX_PCI_QDR_NET 0x04000000UL
495+#define QLA82XX_PCI_QDR_NET_MAX 0x043fffffUL
496496
497497 /*
498498 * Register offsets for MN
drivers/scsi/qla2xxx/qla_nx2.c+1−1
@@ -2810,7 +2810,7 @@ error: · 2809 unmodified lines
28102810
28112811 #define ISP8044_PEX_DMA_ENGINE_INDEX 8
28122812 #define ISP8044_PEX_DMA_BASE_ADDRESS 0x77320000
2813−#define ISP8044_PEX_DMA_NUM_OFFSET 0x10000
2813+#define ISP8044_PEX_DMA_NUM_OFFSET 0x10000UL
28142814 #define ISP8044_PEX_DMA_CMD_ADDR_LOW 0x0
28152815 #define ISP8044_PEX_DMA_CMD_ADDR_HIGH 0x04
28162816 #define ISP8044_PEX_DMA_CMD_STS_AND_CNTRL 0x08
drivers/scsi/qla2xxx/qla_os.c+106−131
@@ -69,7 +69,7 @@ MODULE_PARM_DESC(ql2xplogiabsentdevice, · 68 unmodified lines
6969 "a Fabric scan. This is needed for several broken switches. "
7070 "Default is 0 - no PLOGI. 1 - perform PLOGI.");
7171
72−int ql2xloginretrycount = 0;
72+int ql2xloginretrycount;
7373 module_param(ql2xloginretrycount, int, S_IRUGO);
7474 MODULE_PARM_DESC(ql2xloginretrycount,
7575 "Specify an alternate value for the NVRAM login retry count.");
@@ -234,7 +234,7 @@ MODULE_PARM_DESC(ql2xmdenable, · 158 unmodified lines
234234 "0 - MiniDump disabled. "
235235 "1 (Default) - MiniDump enabled.");
236236
237−int ql2xexlogins = 0;
237+int ql2xexlogins;
238238 module_param(ql2xexlogins, uint, S_IRUGO|S_IWUSR);
239239 MODULE_PARM_DESC(ql2xexlogins,
240240 "Number of extended Logins. "
@@ -250,7 +250,7 @@ module_param(ql2xiniexchg, uint, 0644); · 9 unmodified lines
250250 MODULE_PARM_DESC(ql2xiniexchg,
251251 "Number of initiator exchanges.");
252252
253−int ql2xfwholdabts = 0;
253+int ql2xfwholdabts;
254254 module_param(ql2xfwholdabts, int, S_IRUGO);
255255 MODULE_PARM_DESC(ql2xfwholdabts,
256256 "Allow FW to hold status IOCB until ABTS rsp received. "
@@ -536,80 +536,70 @@ static void qla2x00_free_queues(struct qla_hw_data *ha) · 279 unmodified lines
536536 }
537537
538538 static char *
539−qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str)
539+qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str, size_t str_len)
540540 {
541541 struct qla_hw_data *ha = vha->hw;
542− static char *pci_bus_modes[] = {
542+ static const char *const pci_bus_modes[] = {
543543 "33", "66", "100", "133",
544544 };
545545 uint16_t pci_bus;
546546
547− strcpy(str, "PCI");
548547 pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9;
549548 if (pci_bus) {
550− strcat(str, "-X (");
551− strcat(str, pci_bus_modes[pci_bus]);
549+ snprintf(str, str_len, "PCI-X (%s MHz)",
550+ pci_bus_modes[pci_bus]);
552551 } else {
553552 pci_bus = (ha->pci_attr & BIT_8) >> 8;
554− strcat(str, " (");
555− strcat(str, pci_bus_modes[pci_bus]);
553+ snprintf(str, str_len, "PCI (%s MHz)", pci_bus_modes[pci_bus]);
556554 }
557− strcat(str, " MHz)");
558555
559− return (str);
556+ return str;
560557 }
561558
562559 static char *
563−qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str)
560+qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str, size_t str_len)
564561 {
565− static char *pci_bus_modes[] = { "33", "66", "100", "133", };
562+ static const char *const pci_bus_modes[] = {
563+ "33", "66", "100", "133",
564+ };
566565 struct qla_hw_data *ha = vha->hw;
567566 uint32_t pci_bus;
568567
569568 if (pci_is_pcie(ha->pdev)) {
570− char lwstr[6];
571569 uint32_t lstat, lspeed, lwidth;
570+ const char *speed_str;
572571
573572 pcie_capability_read_dword(ha->pdev, PCI_EXP_LNKCAP, &lstat);
574573 lspeed = lstat & PCI_EXP_LNKCAP_SLS;
575574 lwidth = (lstat & PCI_EXP_LNKCAP_MLW) >> 4;
576575
577− strcpy(str, "PCIe (");
578576 switch (lspeed) {
579577 case 1:
580− strcat(str, "2.5GT/s ");
578+ speed_str = "2.5GT/s";
581579 break;
582580 case 2:
583− strcat(str, "5.0GT/s ");
581+ speed_str = "5.0GT/s";
584582 break;
585583 case 3:
586− strcat(str, "8.0GT/s ");
584+ speed_str = "8.0GT/s";
587585 break;
588586 default:
589− strcat(str, "<unknown> ");
587+ speed_str = "<unknown>";
590588 break;
591589 }
592− snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth);
593− strcat(str, lwstr);
590+ snprintf(str, str_len, "PCIe (%s x%d)", speed_str, lwidth);
594591
595592 return str;
596593 }
597594
598− strcpy(str, "PCI");
599595 pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8;
600− if (pci_bus == 0 || pci_bus == 8) {
601− strcat(str, " (");
602− strcat(str, pci_bus_modes[pci_bus >> 3]);
603− } else {
604− strcat(str, "-X ");
605− if (pci_bus & BIT_2)
606− strcat(str, "Mode 2");
607− else
608− strcat(str, "Mode 1");
609− strcat(str, " (");
610− strcat(str, pci_bus_modes[pci_bus & ~BIT_2]);
611− }
612− strcat(str, " MHz)");
596+ if (pci_bus == 0 || pci_bus == 8)
597+ snprintf(str, str_len, "PCI (%s MHz)",
598+ pci_bus_modes[pci_bus >> 3]);
599+ else
600+ snprintf(str, str_len, "PCI-X Mode %d (%s MHz)",
601+ pci_bus & 4 ? 2 : 1,
602+ pci_bus_modes[pci_bus & 3]);
613603
614604 return str;
615605 }
@@ -662,13 +652,10 @@ qla24xx_fw_version_str(struct scsi_qla_host *vha, char *str, size_t size) · 46 unmodified lines
662652 return str;
663653 }
664654
665−void
666−qla2x00_sp_free_dma(void *ptr)
655+void qla2x00_sp_free_dma(srb_t *sp)
667656 {
668− srb_t *sp = ptr;
669657 struct qla_hw_data *ha = sp->vha->hw;
670658 struct scsi_cmnd *cmd = GET_CMD_SP(sp);
671− void *ctx = GET_CMD_CTX_SP(sp);
672659
673660 if (sp->flags & SRB_DMA_VALID) {
674661 scsi_dma_unmap(cmd);
@@ -681,24 +668,21 @@ qla2x00_sp_free_dma(void *ptr) · 6 unmodified lines
681668 sp->flags &= ~SRB_CRC_PROT_DMA_VALID;
682669 }
683670
684− if (!ctx)
685− return;
686−
687671 if (sp->flags & SRB_CRC_CTX_DSD_VALID) {
688672 /* List assured to be having elements */
689− qla2x00_clean_dsd_pool(ha, ctx);
673+ qla2x00_clean_dsd_pool(ha, sp->u.scmd.crc_ctx);
690674 sp->flags &= ~SRB_CRC_CTX_DSD_VALID;
691675 }
692676
693677 if (sp->flags & SRB_CRC_CTX_DMA_VALID) {
694− struct crc_context *ctx0 = ctx;
678+ struct crc_context *ctx0 = sp->u.scmd.crc_ctx;
695679
696680 dma_pool_free(ha->dl_dma_pool, ctx0, ctx0->crc_ctx_dma);
697681 sp->flags &= ~SRB_CRC_CTX_DMA_VALID;
698682 }
699683
700684 if (sp->flags & SRB_FCP_CMND_DMA_VALID) {
701− struct ct6_dsd *ctx1 = ctx;
685+ struct ct6_dsd *ctx1 = sp->u.scmd.ct6_ctx;
702686
703687 dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd,
704688 ctx1->fcp_cmnd_dma);
@@ -709,10 +693,8 @@ qla2x00_sp_free_dma(void *ptr) · 4 unmodified lines
709693 }
710694 }
711695
712−void
713−qla2x00_sp_compl(void *ptr, int res)
696+void qla2x00_sp_compl(srb_t *sp, int res)
714697 {
715− srb_t *sp = ptr;
716698 struct scsi_cmnd *cmd = GET_CMD_SP(sp);
717699 struct completion *comp = sp->comp;
718700
@@ -727,16 +709,12 @@ qla2x00_sp_compl(void *ptr, int res) · 8 unmodified lines
727709 cmd->scsi_done(cmd);
728710 if (comp)
729711 complete(comp);
730− qla2x00_rel_sp(sp);
731712 }
732713
733−void
734−qla2xxx_qpair_sp_free_dma(void *ptr)
714+void qla2xxx_qpair_sp_free_dma(srb_t *sp)
735715 {
736− srb_t *sp = (srb_t *)ptr;
737716 struct scsi_cmnd *cmd = GET_CMD_SP(sp);
738717 struct qla_hw_data *ha = sp->fcport->vha->hw;
739− void *ctx = GET_CMD_CTX_SP(sp);
740718
741719 if (sp->flags & SRB_DMA_VALID) {
742720 scsi_dma_unmap(cmd);
@@ -749,17 +727,14 @@ qla2xxx_qpair_sp_free_dma(void *ptr) · 6 unmodified lines
749727 sp->flags &= ~SRB_CRC_PROT_DMA_VALID;
750728 }
751729
752− if (!ctx)
753− return;
754−
755730 if (sp->flags & SRB_CRC_CTX_DSD_VALID) {
756731 /* List assured to be having elements */
757− qla2x00_clean_dsd_pool(ha, ctx);
732+ qla2x00_clean_dsd_pool(ha, sp->u.scmd.crc_ctx);
758733 sp->flags &= ~SRB_CRC_CTX_DSD_VALID;
759734 }
760735
761736 if (sp->flags & SRB_DIF_BUNDL_DMA_VALID) {
762− struct crc_context *difctx = ctx;
737+ struct crc_context *difctx = sp->u.scmd.crc_ctx;
763738 struct dsd_dma *dif_dsd, *nxt_dsd;
764739
765740 list_for_each_entry_safe(dif_dsd, nxt_dsd,
@@ -795,7 +770,7 @@ qla2xxx_qpair_sp_free_dma(void *ptr) · 29 unmodified lines
795770 }
796771
797772 if (sp->flags & SRB_FCP_CMND_DMA_VALID) {
798− struct ct6_dsd *ctx1 = ctx;
773+ struct ct6_dsd *ctx1 = sp->u.scmd.ct6_ctx;
799774
800775 dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd,
801776 ctx1->fcp_cmnd_dma);
@@ -807,17 +782,15 @@ qla2xxx_qpair_sp_free_dma(void *ptr) · 5 unmodified lines
807782 }
808783
809784 if (sp->flags & SRB_CRC_CTX_DMA_VALID) {
810− struct crc_context *ctx0 = ctx;
785+ struct crc_context *ctx0 = sp->u.scmd.crc_ctx;
811786
812− dma_pool_free(ha->dl_dma_pool, ctx, ctx0->crc_ctx_dma);
787+ dma_pool_free(ha->dl_dma_pool, ctx0, ctx0->crc_ctx_dma);
813788 sp->flags &= ~SRB_CRC_CTX_DMA_VALID;
814789 }
815790 }
816791
817−void
818−qla2xxx_qpair_sp_compl(void *ptr, int res)
792+void qla2xxx_qpair_sp_compl(srb_t *sp, int res)
819793 {
820− srb_t *sp = ptr;
821794 struct scsi_cmnd *cmd = GET_CMD_SP(sp);
822795 struct completion *comp = sp->comp;
823796
@@ -832,7 +805,6 @@ qla2xxx_qpair_sp_compl(void *ptr, int res) · 8 unmodified lines
832805 cmd->scsi_done(cmd);
833806 if (comp)
834807 complete(comp);
835− qla2xxx_rel_qpair_sp(sp->qpair, sp);
836808 }
837809
838810 static int
@@ -845,9 +817,6 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) · 6 unmodified lines
845817 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
846818 srb_t *sp;
847819 int rval;
848− struct qla_qpair *qpair = NULL;
849− uint32_t tag;
850− uint16_t hwq;
851820
852821 if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags)) ||
853822 WARN_ON_ONCE(!rport)) {
@@ -856,6 +825,10 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) · 2 unmodified lines
856825 }
857826
858827 if (ha->mqenable) {
828+ uint32_t tag;
829+ uint16_t hwq;
830+ struct qla_qpair *qpair = NULL;
831+
859832 tag = blk_mq_unique_tag(cmd->request);
860833 hwq = blk_mq_unique_tag_to_hwq(tag);
861834 qpair = ha->queue_pair_map[hwq];
@@ -925,9 +898,8 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) · 63 unmodified lines
925898 else
926899 goto qc24_target_busy;
927900
928− sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC);
929− if (!sp)
930− goto qc24_host_busy;
901+ sp = scsi_cmd_priv(cmd);
902+ qla2xxx_init_sp(sp, vha, vha->hw->base_qpair, fcport);
931903
932904 sp->u.scmd.cmd = cmd;
933905 sp->type = SRB_SCSI_CMD;
@@ -948,9 +920,6 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) · 14 unmodified lines
948920 qc24_host_busy_free_sp:
949921 sp->free(sp);
950922
951−qc24_host_busy:
952− return SCSI_MLQUEUE_HOST_BUSY;
953−
954923 qc24_target_busy:
955924 return SCSI_MLQUEUE_TARGET_BUSY;
956925
@@ -1011,9 +980,8 @@ qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, · 54 unmodified lines
1011980 else
1012981 goto qc24_target_busy;
1013982
1014− sp = qla2xxx_get_qpair_sp(vha, qpair, fcport, GFP_ATOMIC);
1015− if (!sp)
1016− goto qc24_host_busy;
983+ sp = scsi_cmd_priv(cmd);
984+ qla2xxx_init_sp(sp, vha, qpair, fcport);
1017985
1018986 sp->u.scmd.cmd = cmd;
1019987 sp->type = SRB_SCSI_CMD;
@@ -1037,9 +1005,6 @@ qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, · 17 unmodified lines
10371005 qc24_host_busy_free_sp:
10381006 sp->free(sp);
10391007
1040−qc24_host_busy:
1041− return SCSI_MLQUEUE_HOST_BUSY;
1042−
10431008 qc24_target_busy:
10441009 return SCSI_MLQUEUE_TARGET_BUSY;
10451010
@@ -1058,8 +1023,8 @@ qc24_fail_command: · 12 unmodified lines
10581023 * cmd = Scsi Command to wait on.
10591024 *
10601025 * Return:
1061− * Not Found : 0
1062− * Found : 1
1026+ * Completed in time : QLA_SUCCESS
1027+ * Did not complete in time : QLA_FUNCTION_FAILED
10631028 */
10641029 static int
10651030 qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd)
@@ -1269,14 +1234,13 @@ static int · 203 unmodified lines
12691234 qla2xxx_eh_abort(struct scsi_cmnd *cmd)
12701235 {
12711236 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
1237+ DECLARE_COMPLETION_ONSTACK(comp);
12721238 srb_t *sp;
12731239 int ret;
12741240 unsigned int id;
12751241 uint64_t lun;
1276− unsigned long flags;
12771242 int rval;
12781243 struct qla_hw_data *ha = vha->hw;
1279− struct qla_qpair *qpair;
12801244
12811245 if (qla2x00_isp_reg_stat(ha)) {
12821246 ql_log(ql_log_info, vha, 0x8042,
@@ -1288,28 +1252,14 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) · 5 unmodified lines
12881252 if (ret != 0)
12891253 return ret;
12901254
1291− sp = (srb_t *) CMD_SP(cmd);
1292− if (!sp)
1293− return SUCCESS;
1294−
1295− qpair = sp->qpair;
1296− if (!qpair)
1297− return SUCCESS;
1255+ sp = scsi_cmd_priv(cmd);
12981256
1299− spin_lock_irqsave(qpair->qp_lock_ptr, flags);
1300− if (sp->type != SRB_SCSI_CMD || GET_CMD_SP(sp) != cmd) {
1301− /* there's a chance an interrupt could clear
1302− the ptr as part of done & free */
1303− spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
1257+ if (sp->fcport && sp->fcport->deleted)
13041258 return SUCCESS;
1305− }
13061259
1307− if (sp_get(sp)){
1308− /* ref_count is already 0 */
1309− spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
1260+ /* Return if the command has already finished. */
1261+ if (sp_get(sp))
13101262 return SUCCESS;
1311− }
1312− spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
13131263
13141264 id = cmd->device->id;
13151265 lun = cmd->device->lun;
@@ -1331,6 +1281,23 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) · 15 unmodified lines
13311281 sp->done(sp, DID_ABORT << 16);
13321282 ret = SUCCESS;
13331283 break;
1284+ case QLA_FUNCTION_PARAMETER_ERROR: {
1285+ /* Wait for the command completion. */
1286+ uint32_t ratov = ha->r_a_tov/10;
1287+ uint32_t ratov_j = msecs_to_jiffies(4 * ratov * 1000);
1288+
1289+ WARN_ON_ONCE(sp->comp);
1290+ sp->comp = &comp;
1291+ if (!wait_for_completion_timeout(&comp, ratov_j)) {
1292+ ql_dbg(ql_dbg_taskm, vha, 0xffff,
1293+ "%s: Abort wait timer (4 * R_A_TOV[%d]) expired\n",
1294+ __func__, ha->r_a_tov);
1295+ ret = FAILED;
1296+ } else {
1297+ ret = SUCCESS;
1298+ }
1299+ break;
1300+ }
13341301 default:
13351302 /*
13361303 * Either abort failed or abort and completion raced. Let
@@ -1340,6 +1307,8 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) · 3 unmodified lines
13401307 break;
13411308 }
13421309
1310+ sp->comp = NULL;
1311+ atomic_dec(&sp->ref_count);
13431312 ql_log(ql_log_info, vha, 0x801c,
13441313 "Abort command issued nexus=%ld:%d:%llu -- %x.\n",
13451314 vha->host_no, id, lun, ret);
@@ -1347,6 +1316,9 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) · 1 unmodified line
13471316 return ret;
13481317 }
13491318
1319+/*
1320+ * Returns: QLA_SUCCESS or QLA_FUNCTION_FAILED.
1321+ */
13501322 int
13511323 qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t,
13521324 uint64_t l, enum nexus_wait_type type)
@@ -1420,6 +1392,9 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, · 67 unmodified lines
14201392 if (err != 0)
14211393 return err;
14221394
1395+ if (fcport->deleted)
1396+ return SUCCESS;
1397+
14231398 ql_log(ql_log_info, vha, 0x8009,
14241399 "%s RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", name, vha->host_no,
14251400 cmd->device->id, cmd->device->lun, cmd);
@@ -1534,6 +1509,9 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) · 108 unmodified lines
15341509 return ret;
15351510 ret = FAILED;
15361511
1512+ if (qla2x00_chip_is_down(vha))
1513+ return ret;
1514+
15371515 ql_log(ql_log_info, vha, 0x8012,
15381516 "BUS RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun);
15391517
@@ -1746,6 +1724,8 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res, · 206 unmodified lines
17461724 spin_lock_irqsave(qp->qp_lock_ptr, *flags);
17471725 sp->comp = NULL;
17481726 }
1727+
1728+ atomic_dec(&sp->ref_count);
17491729 }
17501730
17511731 static void
@@ -1800,8 +1780,13 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) · 48 unmodified lines
18001780 int que;
18011781 struct qla_hw_data *ha = vha->hw;
18021782
1783+ /* Continue only if initialization complete. */
1784+ if (!ha->base_qpair)
1785+ return;
18031786 __qla2x00_abort_all_cmds(ha->base_qpair, res);
18041787
1788+ if (!ha->queue_pair_map)
1789+ return;
18051790 for (que = 0; que < ha->max_qpairs; que++) {
18061791 if (!ha->queue_pair_map[que])
18071792 continue;
@@ -2477,7 +2462,7 @@ static struct isp_operations qla27xx_isp_ops = { · 669 unmodified lines
24772462 .config_rings = qla24xx_config_rings,
24782463 .reset_adapter = qla24xx_reset_adapter,
24792464 .nvram_config = qla81xx_nvram_config,
2480− .update_fw_options = qla81xx_update_fw_options,
2465+ .update_fw_options = qla24xx_update_fw_options,
24812466 .load_risc = qla81xx_load_risc,
24822467 .pci_info_str = qla24xx_pci_info_str,
24832468 .fw_version_str = qla24xx_fw_version_str,
@@ -3154,6 +3139,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) · 670 unmodified lines
31543139 ql_log(ql_log_fatal, base_vha, 0x003d,
31553140 "Failed to allocate memory for queue pointers..."
31563141 "aborting.\n");
3142+ ret = -ENODEV;
31573143 goto probe_failed;
31583144 }
31593145
@@ -3418,7 +3404,8 @@ skip_dpc: · 258 unmodified lines
34183404 "QLogic %s - %s.\n", ha->model_number, ha->model_desc);
34193405 ql_log(ql_log_info, base_vha, 0x00fc,
34203406 "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n",
3421− pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info),
3407+ pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info,
3408+ sizeof(pci_info)),
34223409 pci_name(pdev), ha->flags.enable_64bit_addressing ? '+' : '-',
34233410 base_vha->host_no,
34243411 ha->isp_ops->fw_version_str(base_vha, fw_str, sizeof(fw_str)));
@@ -4598,6 +4585,7 @@ qla2x00_free_fw_dump(struct qla_hw_data *ha) · 1173 unmodified lines
45984585
45994586 ha->fce = NULL;
46004587 ha->fce_dma = 0;
4588+ ha->flags.fce_enabled = 0;
46014589 ha->eft = NULL;
46024590 ha->eft_dma = 0;
46034591 ha->fw_dumped = 0;
@@ -4716,7 +4704,7 @@ qla2x00_mem_free(struct qla_hw_data *ha) · 112 unmodified lines
47164704 mempool_destroy(ha->ctx_mempool);
47174705 ha->ctx_mempool = NULL;
47184706
4719− if (ql2xenabledif) {
4707+ if (ql2xenabledif && ha->dif_bundl_pool) {
47204708 struct dsd_dma *dsd, *nxt;
47214709
47224710 list_for_each_entry_safe(dsd, nxt, &ha->pool.unusable.head,
@@ -4739,8 +4727,7 @@ qla2x00_mem_free(struct qla_hw_data *ha) · 16 unmodified lines
47394727 }
47404728 }
47414729
4742− if (ha->dif_bundl_pool)
4743− dma_pool_destroy(ha->dif_bundl_pool);
4730+ dma_pool_destroy(ha->dif_bundl_pool);
47444731 ha->dif_bundl_pool = NULL;
47454732
47464733 qlt_mem_free(ha);
@@ -4812,7 +4799,7 @@ struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, · 65 unmodified lines
48124799 if (!vha->gnl.l) {
48134800 ql_log(ql_log_fatal, vha, 0xd04a,
48144801 "Alloc failed for name list.\n");
4815− scsi_remove_host(vha->host);
4802+ scsi_host_put(vha->host);
48164803 return NULL;
48174804 }
48184805
@@ -4825,7 +4812,7 @@ struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, · 6 unmodified lines
48254812 dma_free_coherent(&ha->pdev->dev, vha->gnl.size,
48264813 vha->gnl.l, vha->gnl.ldma);
48274814 vha->gnl.l = NULL;
4828− scsi_remove_host(vha->host);
4815+ scsi_host_put(vha->host);
48294816 return NULL;
48304817 }
48314818 INIT_DELAYED_WORK(&vha->scan.scan_work, qla_scan_work_fn);
@@ -5054,8 +5041,10 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e) · 222 unmodified lines
50545041 "%s %8phC mem alloc fail.\n",
50555042 __func__, e->u.new_sess.port_name);
50565043
5057− if (pla)
5044+ if (pla) {
5045+ list_del(&pla->list);
50585046 kmem_cache_free(qla_tgt_plogi_cachep, pla);
5047+ }
50595048 return;
50605049 }
50615050
@@ -5086,6 +5075,7 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e) · 24 unmodified lines
50865075 if (fcport) {
50875076 fcport->id_changed = 1;
50885077 fcport->scan_state = QLA_FCPORT_FOUND;
5078+ fcport->chip_reset = vha->hw->base_qpair->chip_reset;
50895079 memcpy(fcport->node_name, e->u.new_sess.node_name, WWN_SIZE);
50905080
50915081 if (pla) {
@@ -5165,8 +5155,10 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e) · 73 unmodified lines
51655155
51665156 if (free_fcport) {
51675157 qla2x00_free_fcport(fcport);
5168− if (pla)
5158+ if (pla) {
5159+ list_del(&pla->list);
51695160 kmem_cache_free(qla_tgt_plogi_cachep, pla);
5161+ }
51705162 }
51715163 }
51725164
@@ -5346,9 +5338,8 @@ void qla2x00_relogin(struct scsi_qla_host *vha) · 173 unmodified lines
53465338 } else {
53475339 if (vha->hw->current_topology != ISP_CFG_NL) {
53485340 memset(&ea, 0, sizeof(ea));
5349− ea.event = FCME_RELOGIN;
53505341 ea.fcport = fcport;
5351− qla2x00_fcport_event_handler(vha, &ea);
5342+ qla24xx_handle_relogin_event(vha, &ea);
53525343 } else if (vha->hw->current_topology ==
53535344 ISP_CFG_NL) {
53545345 fcport->login_retry--;
@@ -5686,7 +5677,6 @@ exit: · 331 unmodified lines
56865677 void
56875678 qla83xx_idc_lock(scsi_qla_host_t *base_vha, uint16_t requester_id)
56885679 {
5689− uint16_t options = (requester_id << 15) | BIT_6;
56905680 uint32_t data;
56915681 uint32_t lock_owner;
56925682 struct qla_hw_data *ha = base_vha->hw;
@@ -5719,22 +5709,6 @@ retry_lock: · 26 unmodified lines
57195709 }
57205710
57215711 return;
5722−
5723− /* XXX: IDC-lock implementation using access-control mbx */
5724−retry_lock2:
5725− if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) {
5726− ql_dbg(ql_dbg_p3p, base_vha, 0xb072,
5727− "Failed to acquire IDC lock. retrying...\n");
5728− /* Retry/Perform IDC-Lock recovery */
5729− if (qla83xx_idc_lock_recovery(base_vha) == QLA_SUCCESS) {
5730− qla83xx_wait_logic();
5731− goto retry_lock2;
5732− } else
5733− ql_log(ql_log_warn, base_vha, 0xb076,
5734− "IDC Lock recovery FAILED.\n");
5735− }
5736−
5737− return;
57385712 }
57395713
57405714 void
@@ -7156,6 +7130,7 @@ struct scsi_host_template qla2xxx_driver_template = { · 1415 unmodified lines
71567130
71577131 .supported_mode = MODE_INITIATOR,
71587132 .track_queue_depth = 1,
7133+ .cmd_size = sizeof(srb_t),
71597134 };
71607135
71617136 static const struct pci_error_handlers qla2xxx_err_handler = {
drivers/scsi/qla2xxx/qla_sup.c+9−7
@@ -473,22 +473,24 @@ qla24xx_read_flash_dword(struct qla_hw_data *ha, uint32_t addr, uint32_t *data) · 472 unmodified lines
473473 return QLA_FUNCTION_TIMEOUT;
474474 }
475475
476−uint32_t *
476+int
477477 qla24xx_read_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
478478 uint32_t dwords)
479479 {
480480 ulong i;
481+ int ret = QLA_SUCCESS;
481482 struct qla_hw_data *ha = vha->hw;
482483
483484 /* Dword reads to flash. */
484485 faddr = flash_data_addr(ha, faddr);
485486 for (i = 0; i < dwords; i++, faddr++, dwptr++) {
486− if (qla24xx_read_flash_dword(ha, faddr, dwptr))
487+ ret = qla24xx_read_flash_dword(ha, faddr, dwptr);
488+ if (ret != QLA_SUCCESS)
487489 break;
488490 cpu_to_le32s(dwptr);
489491 }
490492
491− return dwptr;
493+ return ret;
492494 }
493495
494496 static int
@@ -680,8 +682,8 @@ qla2xxx_get_flt_info(scsi_qla_host_t *vha, uint32_t flt_addr) · 185 unmodified lines
680682
681683 ha->flt_region_flt = flt_addr;
682684 wptr = (uint16_t *)ha->flt;
683− qla24xx_read_flash_data(vha, (void *)flt, flt_addr,
684− (sizeof(struct qla_flt_header) + FLT_REGIONS_SIZE) >> 2);
685+ ha->isp_ops->read_optrom(vha, (void *)flt, flt_addr << 2,
686+ (sizeof(struct qla_flt_header) + FLT_REGIONS_SIZE));
685687
686688 if (le16_to_cpu(*wptr) == 0xffff)
687689 goto no_flash_data;
@@ -948,11 +950,11 @@ qla2xxx_get_fdt_info(scsi_qla_host_t *vha) · 260 unmodified lines
948950 struct req_que *req = ha->req_q_map[0];
949951 uint16_t cnt, chksum;
950952 uint16_t *wptr = (void *)req->ring;
951− struct qla_fdt_layout *fdt = (void *)req->ring;
953+ struct qla_fdt_layout *fdt = (struct qla_fdt_layout *)req->ring;
952954 uint8_t man_id, flash_id;
953955 uint16_t mid = 0, fid = 0;
954956
955− qla24xx_read_flash_data(vha, (void *)fdt, ha->flt_region_fdt,
957+ ha->isp_ops->read_optrom(vha, fdt, ha->flt_region_fdt << 2,
956958 OPTROM_BURST_DWORDS);
957959 if (le16_to_cpu(*wptr) == 0xffff)
958960 goto no_flash_data;
drivers/scsi/qla2xxx/qla_target.c+82−130
@@ -188,18 +188,17 @@ static inline int qlt_issue_marker(struct scsi_qla_host *vha, int vha_locked) · 187 unmodified lines
188188
189189 static inline
190190 struct scsi_qla_host *qlt_find_host_by_d_id(struct scsi_qla_host *vha,
191− uint8_t *d_id)
191+ be_id_t d_id)
192192 {
193193 struct scsi_qla_host *host;
194− uint32_t key = 0;
194+ uint32_t key;
195195
196− if ((vha->d_id.b.area == d_id[1]) && (vha->d_id.b.domain == d_id[0]) &&
197− (vha->d_id.b.al_pa == d_id[2]))
196+ if (vha->d_id.b.area == d_id.area &&
197+ vha->d_id.b.domain == d_id.domain &&
198+ vha->d_id.b.al_pa == d_id.al_pa)
198199 return vha;
199200
200− key = (uint32_t)d_id[0] << 16;
201− key |= (uint32_t)d_id[1] << 8;
202− key |= (uint32_t)d_id[2];
201+ key = be_to_port_id(d_id).b24;
203202
204203 host = btree_lookup32(&vha->hw->tgt.host_map, key);
205204 if (!host)
@@ -357,9 +356,9 @@ static bool qlt_24xx_atio_pkt_all_vps(struct scsi_qla_host *vha, · 151 unmodified lines
357356 ql_dbg(ql_dbg_tgt, vha, 0xe03e,
358357 "qla_target(%d): Received ATIO_TYPE7 "
359358 "with unknown d_id %x:%x:%x\n", vha->vp_idx,
360− atio->u.isp24.fcp_hdr.d_id[0],
361− atio->u.isp24.fcp_hdr.d_id[1],
362− atio->u.isp24.fcp_hdr.d_id[2]);
359+ atio->u.isp24.fcp_hdr.d_id.domain,
360+ atio->u.isp24.fcp_hdr.d_id.area,
361+ atio->u.isp24.fcp_hdr.d_id.al_pa);
363362
364363
365364 qlt_queue_unknown_atio(vha, atio, ha_locked);
@@ -560,10 +559,8 @@ static int qla24xx_post_nack_work(struct scsi_qla_host *vha, fc_port_t *fcport, · 194 unmodified lines
560559 return qla2x00_post_work(vha, e);
561560 }
562561
563−static
564−void qla2x00_async_nack_sp_done(void *s, int res)
562+static void qla2x00_async_nack_sp_done(srb_t *sp, int res)
565563 {
566− struct srb *sp = (struct srb *)s;
567564 struct scsi_qla_host *vha = sp->vha;
568565 unsigned long flags;
569566
@@ -789,6 +786,8 @@ qlt_plogi_ack_find_add(struct scsi_qla_host *vha, port_id_t *id, · 219 unmodified lines
789786 {
790787 struct qlt_plogi_ack_t *pla;
791788
789+ lockdep_assert_held(&vha->hw->hardware_lock);
790+
792791 list_for_each_entry(pla, &vha->plogi_ack_list, list) {
793792 if (pla->id.b24 == id->b24) {
794793 ql_dbg(ql_dbg_disc + ql_dbg_verbose, vha, 0x210d,
@@ -1209,7 +1208,6 @@ static void qla24xx_chk_fcp_state(struct fc_port *sess) · 414 unmodified lines
12091208 sess->logout_on_delete = 0;
12101209 sess->logo_ack_needed = 0;
12111210 sess->fw_login_state = DSC_LS_PORT_UNAVAIL;
1212− sess->scan_state = 0;
12131211 }
12141212 }
12151213
@@ -1284,13 +1282,12 @@ static void qlt_clear_tgt_db(struct qla_tgt *tgt) · 68 unmodified lines
12841282 /* At this point tgt could be already dead */
12851283 }
12861284
1287−static int qla24xx_get_loop_id(struct scsi_qla_host *vha, const uint8_t *s_id,
1285+static int qla24xx_get_loop_id(struct scsi_qla_host *vha, be_id_t s_id,
12881286 uint16_t *loop_id)
12891287 {
12901288 struct qla_hw_data *ha = vha->hw;
12911289 dma_addr_t gid_list_dma;
1292− struct gid_list_info *gid_list;
1293− char *id_iter;
1290+ struct gid_list_info *gid_list, *gid;
12941291 int res, rc, i;
12951292 uint16_t entries;
12961293
@@ -1313,19 +1310,17 @@ static int qla24xx_get_loop_id(struct scsi_qla_host *vha, const uint8_t *s_id, · 16 unmodified lines
13131310 goto out_free_id_list;
13141311 }
13151312
1316− id_iter = (char *)gid_list;
1313+ gid = gid_list;
13171314 res = -ENOENT;
13181315 for (i = 0; i < entries; i++) {
1319− struct gid_list_info *gid = (struct gid_list_info *)id_iter;
1320−
1321− if ((gid->al_pa == s_id[2]) &&
1322− (gid->area == s_id[1]) &&
1323− (gid->domain == s_id[0])) {
1316+ if (gid->al_pa == s_id.al_pa &&
1317+ gid->area == s_id.area &&
1318+ gid->domain == s_id.domain) {
13241319 *loop_id = le16_to_cpu(gid->loop_id);
13251320 res = 0;
13261321 break;
13271322 }
1328− id_iter += ha->gid_list_info_size;
1323+ gid = (void *)gid + ha->gid_list_info_size;
13291324 }
13301325
13311326 out_free_id_list:
@@ -1582,11 +1577,10 @@ static void qlt_release(struct qla_tgt *tgt) · 250 unmodified lines
15821577 struct qla_qpair_hint *h;
15831578 struct qla_hw_data *ha = vha->hw;
15841579
1585− if ((vha->vha_tgt.qla_tgt != NULL) && !tgt->tgt_stop &&
1586− !tgt->tgt_stopped)
1580+ if (!tgt->tgt_stop && !tgt->tgt_stopped)
15871581 qlt_stop_phase1(tgt);
15881582
1589− if ((vha->vha_tgt.qla_tgt != NULL) && !tgt->tgt_stopped)
1583+ if (!tgt->tgt_stopped)
15901584 qlt_stop_phase2(tgt);
15911585
15921586 for (i = 0; i < vha->hw->max_qpairs + 1; i++) {
@@ -1772,12 +1766,8 @@ static int qlt_build_abts_resp_iocb(struct qla_tgt_mgmt_cmd *mcmd) · 179 unmodified lines
17721766 resp->fcp_hdr_le.f_ctl[1] = *p++;
17731767 resp->fcp_hdr_le.f_ctl[2] = *p;
17741768
1775− resp->fcp_hdr_le.d_id[0] = abts->fcp_hdr_le.s_id[0];
1776− resp->fcp_hdr_le.d_id[1] = abts->fcp_hdr_le.s_id[1];
1777− resp->fcp_hdr_le.d_id[2] = abts->fcp_hdr_le.s_id[2];
1778− resp->fcp_hdr_le.s_id[0] = abts->fcp_hdr_le.d_id[0];
1779− resp->fcp_hdr_le.s_id[1] = abts->fcp_hdr_le.d_id[1];
1780− resp->fcp_hdr_le.s_id[2] = abts->fcp_hdr_le.d_id[2];
1769+ resp->fcp_hdr_le.d_id = abts->fcp_hdr_le.s_id;
1770+ resp->fcp_hdr_le.s_id = abts->fcp_hdr_le.d_id;
17811771
17821772 resp->exchange_addr_to_abort = abts->exchange_addr_to_abort;
17831773 if (mcmd->fc_tm_rsp == FCP_TMF_CMPL) {
@@ -1848,19 +1838,11 @@ static void qlt_24xx_send_abts_resp(struct qla_qpair *qpair, · 64 unmodified lines
18481838 resp->fcp_hdr_le.f_ctl[1] = *p++;
18491839 resp->fcp_hdr_le.f_ctl[2] = *p;
18501840 if (ids_reversed) {
1851− resp->fcp_hdr_le.d_id[0] = abts->fcp_hdr_le.d_id[0];
1852− resp->fcp_hdr_le.d_id[1] = abts->fcp_hdr_le.d_id[1];
1853− resp->fcp_hdr_le.d_id[2] = abts->fcp_hdr_le.d_id[2];
1854− resp->fcp_hdr_le.s_id[0] = abts->fcp_hdr_le.s_id[0];
1855− resp->fcp_hdr_le.s_id[1] = abts->fcp_hdr_le.s_id[1];
1856− resp->fcp_hdr_le.s_id[2] = abts->fcp_hdr_le.s_id[2];
1841+ resp->fcp_hdr_le.d_id = abts->fcp_hdr_le.d_id;
1842+ resp->fcp_hdr_le.s_id = abts->fcp_hdr_le.s_id;
18571843 } else {
1858− resp->fcp_hdr_le.d_id[0] = abts->fcp_hdr_le.s_id[0];
1859− resp->fcp_hdr_le.d_id[1] = abts->fcp_hdr_le.s_id[1];
1860− resp->fcp_hdr_le.d_id[2] = abts->fcp_hdr_le.s_id[2];
1861− resp->fcp_hdr_le.s_id[0] = abts->fcp_hdr_le.d_id[0];
1862− resp->fcp_hdr_le.s_id[1] = abts->fcp_hdr_le.d_id[1];
1863− resp->fcp_hdr_le.s_id[2] = abts->fcp_hdr_le.d_id[2];
1844+ resp->fcp_hdr_le.d_id = abts->fcp_hdr_le.s_id;
1845+ resp->fcp_hdr_le.s_id = abts->fcp_hdr_le.d_id;
18641846 }
18651847 resp->exchange_addr_to_abort = abts->exchange_addr_to_abort;
18661848 if (status == FCP_TMF_CMPL) {
@@ -1927,18 +1909,14 @@ static void qlt_24xx_retry_term_exchange(struct scsi_qla_host *vha, · 60 unmodified lines
19271909 tmp = (CTIO7_FLAGS_STATUS_MODE_1 | CTIO7_FLAGS_TERMINATE);
19281910
19291911 if (mcmd) {
1930− ctio->initiator_id[0] = entry->fcp_hdr_le.s_id[0];
1931− ctio->initiator_id[1] = entry->fcp_hdr_le.s_id[1];
1932− ctio->initiator_id[2] = entry->fcp_hdr_le.s_id[2];
1912+ ctio->initiator_id = entry->fcp_hdr_le.s_id;
19331913
19341914 if (mcmd->flags & QLA24XX_MGMT_ABORT_IO_ATTR_VALID)
19351915 tmp |= (mcmd->abort_io_attr << 9);
19361916 else if (qpair->retry_term_cnt & 1)
19371917 tmp |= (0x4 << 9);
19381918 } else {
1939− ctio->initiator_id[0] = entry->fcp_hdr_le.d_id[0];
1940− ctio->initiator_id[1] = entry->fcp_hdr_le.d_id[1];
1941− ctio->initiator_id[2] = entry->fcp_hdr_le.d_id[2];
1919+ ctio->initiator_id = entry->fcp_hdr_le.d_id;
19421920
19431921 if (qpair->retry_term_cnt & 1)
19441922 tmp |= (0x4 << 9);
@@ -1972,8 +1950,7 @@ static void qlt_24xx_retry_term_exchange(struct scsi_qla_host *vha, · 27 unmodified lines
19721950 * XXX does not go through the list of other port (which may have cmds
19731951 * for the same lun)
19741952 */
1975−static void abort_cmds_for_lun(struct scsi_qla_host *vha,
1976− u64 lun, uint8_t *s_id)
1953+static void abort_cmds_for_lun(struct scsi_qla_host *vha, u64 lun, be_id_t s_id)
19771954 {
19781955 struct qla_tgt_sess_op *op;
19791956 struct qla_tgt_cmd *cmd;
@@ -2149,7 +2126,7 @@ static void qlt_24xx_handle_abts(struct scsi_qla_host *vha, · 169 unmodified lines
21492126 struct qla_hw_data *ha = vha->hw;
21502127 struct fc_port *sess;
21512128 uint32_t tag = abts->exchange_addr_to_abort;
2152− uint8_t s_id[3];
2129+ be_id_t s_id;
21532130 int rc;
21542131 unsigned long flags;
21552132
@@ -2173,13 +2150,11 @@ static void qlt_24xx_handle_abts(struct scsi_qla_host *vha, · 17 unmodified lines
21732150
21742151 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf011,
21752152 "qla_target(%d): task abort (s_id=%x:%x:%x, "
2176− "tag=%d, param=%x)\n", vha->vp_idx, abts->fcp_hdr_le.s_id[2],
2177− abts->fcp_hdr_le.s_id[1], abts->fcp_hdr_le.s_id[0], tag,
2153+ "tag=%d, param=%x)\n", vha->vp_idx, abts->fcp_hdr_le.s_id.domain,
2154+ abts->fcp_hdr_le.s_id.area, abts->fcp_hdr_le.s_id.al_pa, tag,
21782155 le32_to_cpu(abts->fcp_hdr_le.parameter));
21792156
2180− s_id[0] = abts->fcp_hdr_le.s_id[2];
2181− s_id[1] = abts->fcp_hdr_le.s_id[1];
2182− s_id[2] = abts->fcp_hdr_le.s_id[0];
2157+ s_id = le_id_to_be(abts->fcp_hdr_le.s_id);
21832158
21842159 spin_lock_irqsave(&ha->tgt.sess_lock, flags);
21852160 sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, s_id);
@@ -2243,9 +2218,7 @@ static void qlt_24xx_send_task_mgmt_ctio(struct qla_qpair *qpair, · 57 unmodified lines
22432218 ctio->nport_handle = mcmd->sess->loop_id;
22442219 ctio->timeout = cpu_to_le16(QLA_TGT_TIMEOUT);
22452220 ctio->vp_index = ha->vp_idx;
2246− ctio->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2];
2247− ctio->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
2248− ctio->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
2221+ ctio->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id);
22492222 ctio->exchange_addr = atio->u.isp24.exchange_addr;
22502223 temp = (atio->u.isp24.attr << 9)|
22512224 CTIO7_FLAGS_STATUS_MODE_1 | CTIO7_FLAGS_SEND_STATUS;
@@ -2302,9 +2275,7 @@ void qlt_send_resp_ctio(struct qla_qpair *qpair, struct qla_tgt_cmd *cmd, · 50 unmodified lines
23022275 ctio->nport_handle = cmd->sess->loop_id;
23032276 ctio->timeout = cpu_to_le16(QLA_TGT_TIMEOUT);
23042277 ctio->vp_index = vha->vp_idx;
2305− ctio->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2];
2306− ctio->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
2307− ctio->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
2278+ ctio->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id);
23082279 ctio->exchange_addr = atio->u.isp24.exchange_addr;
23092280 temp = (atio->u.isp24.attr << 9) |
23102281 CTIO7_FLAGS_STATUS_MODE_1 | CTIO7_FLAGS_SEND_STATUS;
@@ -2605,9 +2576,7 @@ static int qlt_24xx_build_ctio_pkt(struct qla_qpair *qpair, · 294 unmodified lines
26052576 pkt->handle |= CTIO_COMPLETION_HANDLE_MARK;
26062577 pkt->nport_handle = cpu_to_le16(prm->cmd->loop_id);
26072578 pkt->timeout = cpu_to_le16(QLA_TGT_TIMEOUT);
2608− pkt->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2];
2609− pkt->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
2610− pkt->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
2579+ pkt->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id);
26112580 pkt->exchange_addr = atio->u.isp24.exchange_addr;
26122581 temp = atio->u.isp24.attr << 9;
26132582 pkt->u.status0.flags |= cpu_to_le16(temp);
@@ -3120,9 +3089,7 @@ qlt_build_ctio_crc2_pkt(struct qla_qpair *qpair, struct qla_tgt_prm *prm) · 506 unmodified lines
31203089 pkt->handle |= CTIO_COMPLETION_HANDLE_MARK;
31213090 pkt->nport_handle = cpu_to_le16(prm->cmd->loop_id);
31223091 pkt->timeout = cpu_to_le16(QLA_TGT_TIMEOUT);
3123− pkt->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2];
3124− pkt->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
3125− pkt->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
3092+ pkt->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id);
31263093 pkt->exchange_addr = atio->u.isp24.exchange_addr;
31273094
31283095 /* silence compile warning */
@@ -3164,7 +3131,7 @@ qlt_build_ctio_crc2_pkt(struct qla_qpair *qpair, struct qla_tgt_prm *prm) · 35 unmodified lines
31643131 pkt->crc_context_len = CRC_CONTEXT_LEN_FW;
31653132
31663133 if (!bundling) {
3167− cur_dsd = &crc_ctx_pkt->u.nobundling.data_dsd;
3134+ cur_dsd = &crc_ctx_pkt->u.nobundling.data_dsd[0];
31683135 } else {
31693136 /*
31703137 * Configure Bundling if we need to fetch interlaving
@@ -3174,7 +3141,7 @@ qlt_build_ctio_crc2_pkt(struct qla_qpair *qpair, struct qla_tgt_prm *prm) · 3 unmodified lines
31743141 crc_ctx_pkt->u.bundling.dif_byte_count = cpu_to_le32(dif_bytes);
31753142 crc_ctx_pkt->u.bundling.dseg_count =
31763143 cpu_to_le16(prm->tot_dsds - prm->prot_seg_cnt);
3177− cur_dsd = &crc_ctx_pkt->u.bundling.data_dsd;
3144+ cur_dsd = &crc_ctx_pkt->u.bundling.data_dsd[0];
31783145 }
31793146
31803147 /* Finish the common fields of CRC pkt */
@@ -3239,7 +3206,8 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, · 58 unmodified lines
32393206 if (!qpair->fw_started || (cmd->reset_count != qpair->chip_reset) ||
32403207 (cmd->sess && cmd->sess->deleted)) {
32413208 cmd->state = QLA_TGT_STATE_PROCESSED;
3242− return 0;
3209+ res = 0;
3210+ goto free;
32433211 }
32443212
32453213 ql_dbg_qp(ql_dbg_tgt, qpair, 0xe018,
@@ -3250,9 +3218,8 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, · 4 unmodified lines
32503218
32513219 res = qlt_pre_xmit_response(cmd, &prm, xmit_type, scsi_status,
32523220 &full_req_cnt);
3253− if (unlikely(res != 0)) {
3254− return res;
3255− }
3221+ if (unlikely(res != 0))
3222+ goto free;
32563223
32573224 spin_lock_irqsave(qpair->qp_lock_ptr, flags);
32583225
@@ -3272,7 +3239,8 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, · 13 unmodified lines
32723239 vha->flags.online, qla2x00_reset_active(vha),
32733240 cmd->reset_count, qpair->chip_reset);
32743241 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
3275− return 0;
3242+ res = 0;
3243+ goto free;
32763244 }
32773245
32783246 /* Does F/W have an IOCBs for this request */
@@ -3375,6 +3343,8 @@ out_unmap_unlock: · 96 unmodified lines
33753343 qlt_unmap_sg(vha, cmd);
33763344 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
33773345
3346+free:
3347+ vha->hw->tgt.tgt_ops->free_cmd(cmd);
33783348 return res;
33793349 }
33803350 EXPORT_SYMBOL(qlt_xmit_response);
@@ -3672,9 +3642,7 @@ static int __qlt_send_term_exchange(struct qla_qpair *qpair, · 291 unmodified lines
36723642 ctio24->nport_handle = CTIO7_NHANDLE_UNRECOGNIZED;
36733643 ctio24->timeout = cpu_to_le16(QLA_TGT_TIMEOUT);
36743644 ctio24->vp_index = vha->vp_idx;
3675− ctio24->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2];
3676− ctio24->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
3677− ctio24->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
3645+ ctio24->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id);
36783646 ctio24->exchange_addr = atio->u.isp24.exchange_addr;
36793647 temp = (atio->u.isp24.attr << 9) | CTIO7_FLAGS_STATUS_MODE_1 |
36803648 CTIO7_FLAGS_TERMINATE;
@@ -4107,8 +4075,6 @@ static inline int qlt_get_fcp_task_attr(struct scsi_qla_host *vha, · 426 unmodified lines
41074075 return fcp_task_attr;
41084076 }
41094077
4110−static struct fc_port *qlt_make_local_sess(struct scsi_qla_host *,
4111− uint8_t *);
41124078 /*
41134079 * Process context for I/O path into tcm_qla2xxx code
41144080 */
@@ -4352,9 +4318,7 @@ static int qlt_handle_cmd_for_atio(struct scsi_qla_host *vha, · 237 unmodified lines
43524318 return -ENODEV;
43534319 }
43544320
4355− id.b.al_pa = atio->u.isp24.fcp_hdr.s_id[2];
4356− id.b.area = atio->u.isp24.fcp_hdr.s_id[1];
4357− id.b.domain = atio->u.isp24.fcp_hdr.s_id[0];
4321+ id = be_to_port_id(atio->u.isp24.fcp_hdr.s_id);
43584322 if (IS_SW_RESV_ADDR(id))
43594323 return -EBUSY;
43604324
@@ -4716,6 +4680,8 @@ static int qlt_handle_login(struct scsi_qla_host *vha, · 355 unmodified lines
47164680 struct qlt_plogi_ack_t *pla;
47174681 unsigned long flags;
47184682
4683+ lockdep_assert_held(&vha->hw->hardware_lock);
4684+
47194685 wwn = wwn_to_u64(iocb->u.isp24.port_name);
47204686
47214687 port_id.b.domain = iocb->u.isp24.port_id[2];
@@ -4799,8 +4765,10 @@ static int qlt_handle_login(struct scsi_qla_host *vha, · 77 unmodified lines
47994765 __func__, sess->port_name, sec);
48004766 }
48014767
4802− if (!conflict_sess)
4768+ if (!conflict_sess) {
4769+ list_del(&pla->list);
48034770 kmem_cache_free(qla_tgt_plogi_cachep, pla);
4771+ }
48044772
48054773 qlt_send_term_imm_notif(vha, iocb, 1);
48064774 goto out;
@@ -4889,6 +4857,8 @@ static int qlt_24xx_handle_els(struct scsi_qla_host *vha, · 82 unmodified lines
48894857 int res = 0;
48904858 unsigned long flags;
48914859
4860+ lockdep_assert_held(&ha->hardware_lock);
4861+
48924862 wwn = wwn_to_u64(iocb->u.isp24.port_name);
48934863
48944864 port_id.b.domain = iocb->u.isp24.port_id[2];
@@ -5165,6 +5135,8 @@ static void qlt_handle_imm_notify(struct scsi_qla_host *vha, · 270 unmodified lines
51655135 int send_notify_ack = 1;
51665136 uint16_t status;
51675137
5138+ lockdep_assert_held(&ha->hardware_lock);
5139+
51685140 status = le16_to_cpu(iocb->u.isp2x.status);
51695141 switch (status) {
51705142 case IMM_NTFY_LIP_RESET:
@@ -5302,10 +5274,7 @@ static int __qlt_send_busy(struct qla_qpair *qpair, · 131 unmodified lines
53025274 u16 temp;
53035275 port_id_t id;
53045276
5305− id.b.al_pa = atio->u.isp24.fcp_hdr.s_id[2];
5306− id.b.area = atio->u.isp24.fcp_hdr.s_id[1];
5307− id.b.domain = atio->u.isp24.fcp_hdr.s_id[0];
5308− id.b.rsvd_1 = 0;
5277+ id = be_to_port_id(atio->u.isp24.fcp_hdr.s_id);
53095278
53105279 spin_lock_irqsave(&ha->tgt.sess_lock, flags);
53115280 sess = qla2x00_find_fcport_by_nportid(vha, &id, 1);
@@ -5333,9 +5302,7 @@ static int __qlt_send_busy(struct qla_qpair *qpair, · 21 unmodified lines
53335302 ctio24->nport_handle = sess->loop_id;
53345303 ctio24->timeout = cpu_to_le16(QLA_TGT_TIMEOUT);
53355304 ctio24->vp_index = vha->vp_idx;
5336− ctio24->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2];
5337− ctio24->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
5338− ctio24->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
5305+ ctio24->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id);
53395306 ctio24->exchange_addr = atio->u.isp24.exchange_addr;
53405307 temp = (atio->u.isp24.attr << 9) |
53415308 CTIO7_FLAGS_STATUS_MODE_1 | CTIO7_FLAGS_SEND_STATUS |
@@ -5767,7 +5734,7 @@ static void qlt_handle_abts_completion(struct scsi_qla_host *vha, · 425 unmodified lines
57675734 entry->error_subcode2);
57685735 ha->tgt.tgt_ops->free_mcmd(mcmd);
57695736 }
5770− } else {
5737+ } else if (mcmd) {
57715738 ha->tgt.tgt_ops->free_mcmd(mcmd);
57725739 }
57735740 }
@@ -6121,21 +6088,21 @@ static fc_port_t *qlt_get_port_database(struct scsi_qla_host *vha, · 347 unmodified lines
61216088
61226089 /* Must be called under tgt_mutex */
61236090 static struct fc_port *qlt_make_local_sess(struct scsi_qla_host *vha,
6124− uint8_t *s_id)
6091+ be_id_t s_id)
61256092 {
61266093 struct fc_port *sess = NULL;
61276094 fc_port_t *fcport = NULL;
61286095 int rc, global_resets;
61296096 uint16_t loop_id = 0;
61306097
6131− if ((s_id[0] == 0xFF) && (s_id[1] == 0xFC)) {
6098+ if (s_id.domain == 0xFF && s_id.area == 0xFC) {
61326099 /*
61336100 * This is Domain Controller, so it should be
61346101 * OK to drop SCSI commands from it.
61356102 */
61366103 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf042,
61376104 "Unable to find initiator with S_ID %x:%x:%x",
6138− s_id[0], s_id[1], s_id[2]);
6105+ s_id.domain, s_id.area, s_id.al_pa);
61396106 return NULL;
61406107 }
61416108
@@ -6152,13 +6119,12 @@ retry: · 10 unmodified lines
61526119 ql_log(ql_log_info, vha, 0xf071,
61536120 "qla_target(%d): Unable to find "
61546121 "initiator with S_ID %x:%x:%x",
6155− vha->vp_idx, s_id[0], s_id[1],
6156− s_id[2]);
6122+ vha->vp_idx, s_id.domain, s_id.area, s_id.al_pa);
61576123
61586124 if (rc == -ENOENT) {
61596125 qlt_port_logo_t logo;
61606126
6161− sid_to_portid(s_id, &logo.id);
6127+ logo.id = be_to_port_id(s_id);
61626128 logo.cmd_count = 1;
61636129 qlt_send_first_logo(vha, &logo);
61646130 }
@@ -6197,8 +6163,7 @@ static void qlt_abort_work(struct qla_tgt *tgt, · 32 unmodified lines
61976163 struct qla_hw_data *ha = vha->hw;
61986164 struct fc_port *sess = NULL;
61996165 unsigned long flags = 0, flags2 = 0;
6200− uint32_t be_s_id;
6201− uint8_t s_id[3];
6166+ be_id_t s_id;
62026167 int rc;
62036168
62046169 spin_lock_irqsave(&ha->tgt.sess_lock, flags2);
@@ -6206,12 +6171,9 @@ static void qlt_abort_work(struct qla_tgt *tgt, · 1 unmodified line
62066171 if (tgt->tgt_stop)
62076172 goto out_term2;
62086173
6209− s_id[0] = prm->abts.fcp_hdr_le.s_id[2];
6210− s_id[1] = prm->abts.fcp_hdr_le.s_id[1];
6211− s_id[2] = prm->abts.fcp_hdr_le.s_id[0];
6174+ s_id = le_id_to_be(prm->abts.fcp_hdr_le.s_id);
62126175
6213− sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha,
6214− (unsigned char *)&be_s_id);
6176+ sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, s_id);
62156177 if (!sess) {
62166178 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2);
62176179
@@ -6248,9 +6210,6 @@ static void qlt_abort_work(struct qla_tgt *tgt, · 30 unmodified lines
62486210 out_term2:
62496211 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2);
62506212
6251− if (sess)
6252− ha->tgt.tgt_ops->put_sess(sess);
6253−
62546213 out_term:
62556214 spin_lock_irqsave(&ha->hardware_lock, flags);
62566215 qlt_24xx_send_abts_resp(ha->base_qpair, &prm->abts,
@@ -6266,7 +6225,7 @@ static void qlt_tmr_work(struct qla_tgt *tgt, · 9 unmodified lines
62666225 struct qla_hw_data *ha = vha->hw;
62676226 struct fc_port *sess;
62686227 unsigned long flags;
6269− uint8_t *s_id = NULL; /* to hide compiler warnings */
6228+ be_id_t s_id;
62706229 int rc;
62716230 u64 unpacked_lun;
62726231 int fn;
@@ -6495,22 +6454,10 @@ void qlt_remove_target_resources(struct qla_hw_data *ha) · 222 unmodified lines
64956454 static void qlt_lport_dump(struct scsi_qla_host *vha, u64 wwpn,
64966455 unsigned char *b)
64976456 {
6498− int i;
6499−
6500− pr_debug("qla2xxx HW vha->node_name: ");
6501− for (i = 0; i < WWN_SIZE; i++)
6502− pr_debug("%02x ", vha->node_name[i]);
6503− pr_debug("\n");
6504− pr_debug("qla2xxx HW vha->port_name: ");
6505− for (i = 0; i < WWN_SIZE; i++)
6506− pr_debug("%02x ", vha->port_name[i]);
6507− pr_debug("\n");
6508−
6509− pr_debug("qla2xxx passed configfs WWPN: ");
6457+ pr_debug("qla2xxx HW vha->node_name: %8phC\n", vha->node_name);
6458+ pr_debug("qla2xxx HW vha->port_name: %8phC\n", vha->port_name);
65106459 put_unaligned_be64(wwpn, b);
6511− for (i = 0; i < WWN_SIZE; i++)
6512− pr_debug("%02x ", b[i]);
6513− pr_debug("\n");
6460+ pr_debug("qla2xxx passed configfs WWPN: %8phC\n", b);
65146461 }
65156462
65166463 /**
@@ -6671,6 +6618,8 @@ qlt_enable_vha(struct scsi_qla_host *vha) · 154 unmodified lines
66716618 if (vha->qlini_mode == QLA2XXX_INI_MODE_ENABLED)
66726619 return;
66736620
6621+ if (ha->tgt.num_act_qpairs > ha->max_qpairs)
6622+ ha->tgt.num_act_qpairs = ha->max_qpairs;
66746623 spin_lock_irqsave(&ha->hardware_lock, flags);
66756624 tgt->tgt_stopped = 0;
66766625 qlt_set_mode(vha);
@@ -6685,7 +6634,8 @@ qlt_enable_vha(struct scsi_qla_host *vha) · 8 unmodified lines
66856634 } else {
66866635 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
66876636 qla2xxx_wake_dpc(base_vha);
6688− qla2x00_wait_for_hba_online(base_vha);
6637+ WARN_ON_ONCE(qla2x00_wait_for_hba_online(base_vha) !=
6638+ QLA_SUCCESS);
66896639 }
66906640 mutex_unlock(&ha->optrom_mutex);
66916641 }
@@ -6716,7 +6666,9 @@ static void qlt_disable_vha(struct scsi_qla_host *vha) · 24 unmodified lines
67166666
67176667 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
67186668 qla2xxx_wake_dpc(vha);
6719− qla2x00_wait_for_hba_online(vha);
6669+ if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS)
6670+ ql_dbg(ql_dbg_tgt, vha, 0xe081,
6671+ "qla2x00_wait_for_hba_online() failed\n");
67206672 }
67216673
67226674 /*
@@ -6815,7 +6767,7 @@ qlt_24xx_process_atio_queue(struct scsi_qla_host *vha, uint8_t ha_locked) · 92 unmodified lines
68156767 */
68166768 ql_log(ql_log_warn, vha, 0xd03c,
68176769 "corrupted fcp frame SID[%3phN] OXID[%04x] EXCG[%x] %64phN\n",
6818− pkt->u.isp24.fcp_hdr.s_id,
6770+ &pkt->u.isp24.fcp_hdr.s_id,
68196771 be16_to_cpu(pkt->u.isp24.fcp_hdr.ox_id),
68206772 le32_to_cpu(pkt->u.isp24.exchange_addr), pkt);
68216773
drivers/scsi/qla2xxx/qla_target.h+12−23
@@ -247,9 +247,9 @@ struct ctio_to_2xxx { · 246 unmodified lines
247247
248248 struct fcp_hdr {
249249 uint8_t r_ctl;
250− uint8_t d_id[3];
250+ be_id_t d_id;
251251 uint8_t cs_ctl;
252− uint8_t s_id[3];
252+ be_id_t s_id;
253253 uint8_t type;
254254 uint8_t f_ctl[3];
255255 uint8_t seq_id;
@@ -261,9 +261,9 @@ struct fcp_hdr { · 5 unmodified lines
261261 } __packed;
262262
263263 struct fcp_hdr_le {
264− uint8_t d_id[3];
264+ le_id_t d_id;
265265 uint8_t r_ctl;
266− uint8_t s_id[3];
266+ le_id_t s_id;
267267 uint8_t cs_ctl;
268268 uint8_t f_ctl[3];
269269 uint8_t type;
@@ -402,7 +402,7 @@ struct ctio7_to_24xx { · 132 unmodified lines
402402 uint16_t dseg_count; /* Data segment count. */
403403 uint8_t vp_index;
404404 uint8_t add_flags;
405− uint8_t initiator_id[3];
405+ le_id_t initiator_id;
406406 uint8_t reserved;
407407 uint32_t exchange_addr;
408408 union {
@@ -498,7 +498,7 @@ struct ctio_crc2_to_fw { · 89 unmodified lines
498498 uint8_t add_flags; /* additional flags */
499499 #define CTIO_CRC2_AF_DIF_DSD_ENA BIT_3
500500
501− uint8_t initiator_id[3]; /* initiator ID */
501+ le_id_t initiator_id; /* initiator ID */
502502 uint8_t reserved1;
503503 uint32_t exchange_addr; /* rcv exchange address */
504504 uint16_t reserved2;
@@ -682,7 +682,7 @@ struct qla_tgt_func_tmpl { · 177 unmodified lines
682682 struct fc_port *(*find_sess_by_loop_id)(struct scsi_qla_host *,
683683 const uint16_t);
684684 struct fc_port *(*find_sess_by_s_id)(struct scsi_qla_host *,
685− const uint8_t *);
685+ const be_id_t);
686686 void (*clear_nacl_from_fcport_map)(struct fc_port *);
687687 void (*put_sess)(struct fc_port *);
688688 void (*shutdown_sess)(struct fc_port *);
@@ -912,7 +912,7 @@ struct qla_tgt_cmd { · 223 unmodified lines
912912 uint8_t scsi_status, sense_key, asc, ascq;
913913
914914 struct crc_context *ctx;
915− uint8_t *cdb;
915+ const uint8_t *cdb;
916916 uint64_t lba;
917917 uint16_t a_guard, e_guard, a_app_tag, e_app_tag;
918918 uint32_t a_ref_tag, e_ref_tag;
@@ -1030,22 +1030,11 @@ static inline bool qla_dual_mode_enabled(struct scsi_qla_host *ha) · 111 unmodified lines
10301030 return (ha->host->active_mode == MODE_DUAL);
10311031 }
10321032
1033−static inline uint32_t sid_to_key(const uint8_t *s_id)
1033+static inline uint32_t sid_to_key(const be_id_t s_id)
10341034 {
1035− uint32_t key;
1036−
1037− key = (((unsigned long)s_id[0] << 16) |
1038− ((unsigned long)s_id[1] << 8) |
1039− (unsigned long)s_id[2]);
1040− return key;
1041−}
1042−
1043−static inline void sid_to_portid(const uint8_t *s_id, port_id_t *p)
1044−{
1045− memset(p, 0, sizeof(*p));
1046− p->b.domain = s_id[0];
1047− p->b.area = s_id[1];
1048− p->b.al_pa = s_id[2];
1035+ return s_id.domain << 16 |
1036+ s_id.area << 8 |
1037+ s_id.al_pa;
10491038 }
10501039
10511040 /*
drivers/scsi/qla2xxx/qla_tmpl.c+4−3
@@ -429,7 +429,7 @@ qla27xx_fwdt_entry_t266(struct scsi_qla_host *vha, · 428 unmodified lines
429429 ql_dbg(ql_dbg_misc, vha, 0xd20a,
430430 "%s: reset risc [%lx]\n", __func__, *len);
431431 if (buf)
432− qla24xx_soft_reset(vha->hw);
432+ WARN_ON_ONCE(qla24xx_soft_reset(vha->hw) != QLA_SUCCESS);
433433
434434 return qla27xx_next_entry(ent);
435435 }
@@ -860,8 +860,9 @@ qla27xx_driver_info(struct qla27xx_fwdt_template *tmp) · 424 unmodified lines
860860 {
861861 uint8_t v[] = { 0, 0, 0, 0, 0, 0 };
862862
863− sscanf(qla2x00_version_str, "%hhu.%hhu.%hhu.%hhu.%hhu.%hhu",
864− v+0, v+1, v+2, v+3, v+4, v+5);
863+ WARN_ON_ONCE(sscanf(qla2x00_version_str,
864+ "%hhu.%hhu.%hhu.%hhu.%hhu.%hhu",
865+ v+0, v+1, v+2, v+3, v+4, v+5) != 6);
865866
866867 tmp->driver_info[0] = v[3] << 24 | v[2] << 16 | v[1] << 8 | v[0];
867868 tmp->driver_info[1] = v[5] << 8 | v[4];
drivers/scsi/qla2xxx/qla_version.h+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 /*
88 * Driver version
99 */
10−#define QLA2XXX_VERSION "10.01.00.16-k"
10+#define QLA2XXX_VERSION "10.01.00.19-k"
1111
1212 #define QLA_DRIVER_MAJOR_VER 10
1313 #define QLA_DRIVER_MINOR_VER 1
drivers/scsi/qla2xxx/tcm_qla2xxx.c+10−17
@@ -620,6 +620,7 @@ static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd) · 619 unmodified lines
620620 {
621621 struct qla_tgt_cmd *cmd = container_of(se_cmd,
622622 struct qla_tgt_cmd, se_cmd);
623+ struct scsi_qla_host *vha = cmd->vha;
623624
624625 if (cmd->aborted) {
625626 /* Cmd can loop during Q-full. tcm_qla2xxx_aborted_task
@@ -632,6 +633,7 @@ static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd) · 6 unmodified lines
632633 cmd->se_cmd.transport_state,
633634 cmd->se_cmd.t_state,
634635 cmd->se_cmd.se_cmd_flags);
636+ vha->hw->tgt.tgt_ops->free_cmd(cmd);
635637 return 0;
636638 }
637639
@@ -659,6 +661,7 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd) · 21 unmodified lines
659661 {
660662 struct qla_tgt_cmd *cmd = container_of(se_cmd,
661663 struct qla_tgt_cmd, se_cmd);
664+ struct scsi_qla_host *vha = cmd->vha;
662665 int xmit_type = QLA_TGT_XMIT_STATUS;
663666
664667 if (cmd->aborted) {
@@ -672,6 +675,7 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd) · 7 unmodified lines
672675 cmd, kref_read(&cmd->se_cmd.cmd_kref),
673676 cmd->se_cmd.transport_state, cmd->se_cmd.t_state,
674677 cmd->se_cmd.se_cmd_flags);
678+ vha->hw->tgt.tgt_ops->free_cmd(cmd);
675679 return 0;
676680 }
677681 cmd->bufflen = se_cmd->data_length;
@@ -1136,9 +1140,8 @@ static struct se_portal_group *tcm_qla2xxx_npiv_make_tpg(struct se_wwn *wwn, · 458 unmodified lines
11361140 /*
11371141 * Expected to be called with struct qla_hw_data->tgt.sess_lock held
11381142 */
1139−static struct fc_port *tcm_qla2xxx_find_sess_by_s_id(
1140− scsi_qla_host_t *vha,
1141− const uint8_t *s_id)
1143+static struct fc_port *tcm_qla2xxx_find_sess_by_s_id(scsi_qla_host_t *vha,
1144+ const be_id_t s_id)
11421145 {
11431146 struct tcm_qla2xxx_lport *lport;
11441147 struct se_node_acl *se_nacl;
@@ -1181,7 +1184,7 @@ static void tcm_qla2xxx_set_sess_by_s_id( · 36 unmodified lines
11811184 struct tcm_qla2xxx_nacl *nacl,
11821185 struct se_session *se_sess,
11831186 struct fc_port *fc_port,
1184− uint8_t *s_id)
1187+ be_id_t s_id)
11851188 {
11861189 u32 key;
11871190 void *slot;
@@ -1348,14 +1351,9 @@ static void tcm_qla2xxx_clear_sess_lookup(struct tcm_qla2xxx_lport *lport, · 160 unmodified lines
13481351 struct tcm_qla2xxx_nacl *nacl, struct fc_port *sess)
13491352 {
13501353 struct se_session *se_sess = sess->se_sess;
1351− unsigned char be_sid[3];
1352−
1353− be_sid[0] = sess->d_id.b.domain;
1354− be_sid[1] = sess->d_id.b.area;
1355− be_sid[2] = sess->d_id.b.al_pa;
13561354
13571355 tcm_qla2xxx_set_sess_by_s_id(lport, NULL, nacl, se_sess,
1358− sess, be_sid);
1356+ sess, port_id_to_be_id(sess->d_id));
13591357 tcm_qla2xxx_set_sess_by_loop_id(lport, NULL, nacl, se_sess,
13601358 sess, sess->loop_id);
13611359 }
@@ -1401,19 +1399,14 @@ static int tcm_qla2xxx_session_cb(struct se_portal_group *se_tpg, · 39 unmodified lines
14011399 struct fc_port *qlat_sess = p;
14021400 uint16_t loop_id = qlat_sess->loop_id;
14031401 unsigned long flags;
1404− unsigned char be_sid[3];
1405−
1406− be_sid[0] = qlat_sess->d_id.b.domain;
1407− be_sid[1] = qlat_sess->d_id.b.area;
1408− be_sid[2] = qlat_sess->d_id.b.al_pa;
14091402
14101403 /*
14111404 * And now setup se_nacl and session pointers into HW lport internal
14121405 * mappings for fabric S_ID and LOOP_ID.
14131406 */
14141407 spin_lock_irqsave(&ha->tgt.sess_lock, flags);
1415− tcm_qla2xxx_set_sess_by_s_id(lport, se_nacl, nacl,
1416− se_sess, qlat_sess, be_sid);
1408+ tcm_qla2xxx_set_sess_by_s_id(lport, se_nacl, nacl, se_sess, qlat_sess,
1409+ port_id_to_be_id(qlat_sess->d_id));
14171410 tcm_qla2xxx_set_sess_by_loop_id(lport, se_nacl, nacl,
14181411 se_sess, qlat_sess, loop_id);
14191412 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
drivers/scsi/qlogicpti.c+10−0
@@ -200,10 +200,15 @@ static int qlogicpti_mbox_command(struct qlogicpti *qpti, u_short param[], int f · 199 unmodified lines
200200 /* Write mailbox command registers. */
201201 switch (mbox_param[param[0]] >> 4) {
202202 case 6: sbus_writew(param[5], qpti->qregs + MBOX5);
203+ /* Fall through */
203204 case 5: sbus_writew(param[4], qpti->qregs + MBOX4);
205+ /* Fall through */
204206 case 4: sbus_writew(param[3], qpti->qregs + MBOX3);
207+ /* Fall through */
205208 case 3: sbus_writew(param[2], qpti->qregs + MBOX2);
209+ /* Fall through */
206210 case 2: sbus_writew(param[1], qpti->qregs + MBOX1);
211+ /* Fall through */
207212 case 1: sbus_writew(param[0], qpti->qregs + MBOX0);
208213 }
209214
@@ -254,10 +259,15 @@ static int qlogicpti_mbox_command(struct qlogicpti *qpti, u_short param[], int f · 44 unmodified lines
254259 /* Read back output parameters. */
255260 switch (mbox_param[param[0]] & 0xf) {
256261 case 6: param[5] = sbus_readw(qpti->qregs + MBOX5);
262+ /* Fall through */
257263 case 5: param[4] = sbus_readw(qpti->qregs + MBOX4);
264+ /* Fall through */
258265 case 4: param[3] = sbus_readw(qpti->qregs + MBOX3);
266+ /* Fall through */
259267 case 3: param[2] = sbus_readw(qpti->qregs + MBOX2);
268+ /* Fall through */
260269 case 2: param[1] = sbus_readw(qpti->qregs + MBOX1);
270+ /* Fall through */
261271 case 1: param[0] = sbus_readw(qpti->qregs + MBOX0);
262272 }
263273
drivers/scsi/scsi_debugfs.c+2−3
@@ -1,4 +1,5 @@
11 // SPDX-License-Identifier: GPL-2.0
2+#include <linux/bitops.h>
23 #include <linux/seq_file.h>
34 #include <scsi/scsi_cmnd.h>
45 #include <scsi/scsi_dbg.h>
@@ -18,9 +19,7 @@ static int scsi_flags_show(struct seq_file *m, const unsigned long flags, · 13 unmodified lines
1819 bool sep = false;
1920 int i;
2021
21− for (i = 0; i < sizeof(flags) * BITS_PER_BYTE; i++) {
22− if (!(flags & BIT(i)))
23− continue;
22+ for_each_set_bit(i, &flags, BITS_PER_LONG) {
2423 if (sep)
2524 seq_puts(m, "|");
2625 sep = true;
drivers/scsi/scsi_lib.c+48−4
@@ -1678,10 +1678,11 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, · 1677 unmodified lines
16781678 blk_mq_start_request(req);
16791679 }
16801680
1681+ cmd->flags &= SCMD_PRESERVED_FLAGS;
16811682 if (sdev->simple_tags)
16821683 cmd->flags |= SCMD_TAGGED;
1683− else
1684− cmd->flags &= ~SCMD_TAGGED;
1684+ if (bd->last)
1685+ cmd->flags |= SCMD_LAST;
16851686
16861687 scsi_init_cmd_errh(cmd);
16871688 cmd->scsi_done = scsi_mq_done;
@@ -1821,10 +1822,37 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q) · 133 unmodified lines
18211822 }
18221823 EXPORT_SYMBOL_GPL(__scsi_init_queue);
18231824
1825+static const struct blk_mq_ops scsi_mq_ops_no_commit = {
1826+ .get_budget = scsi_mq_get_budget,
1827+ .put_budget = scsi_mq_put_budget,
1828+ .queue_rq = scsi_queue_rq,
1829+ .complete = scsi_softirq_done,
1830+ .timeout = scsi_timeout,
1831+#ifdef CONFIG_BLK_DEBUG_FS
1832+ .show_rq = scsi_show_rq,
1833+#endif
1834+ .init_request = scsi_mq_init_request,
1835+ .exit_request = scsi_mq_exit_request,
1836+ .initialize_rq_fn = scsi_initialize_rq,
1837+ .busy = scsi_mq_lld_busy,
1838+ .map_queues = scsi_map_queues,
1839+};
1840+
1841+
1842+static void scsi_commit_rqs(struct blk_mq_hw_ctx *hctx)
1843+{
1844+ struct request_queue *q = hctx->queue;
1845+ struct scsi_device *sdev = q->queuedata;
1846+ struct Scsi_Host *shost = sdev->host;
1847+
1848+ shost->hostt->commit_rqs(shost, hctx->queue_num);
1849+}
1850+
18241851 static const struct blk_mq_ops scsi_mq_ops = {
18251852 .get_budget = scsi_mq_get_budget,
18261853 .put_budget = scsi_mq_put_budget,
18271854 .queue_rq = scsi_queue_rq,
1855+ .commit_rqs = scsi_commit_rqs,
18281856 .complete = scsi_softirq_done,
18291857 .timeout = scsi_timeout,
18301858 #ifdef CONFIG_BLK_DEBUG_FS
@@ -1861,7 +1889,10 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost) · 30 unmodified lines
18611889 sizeof(struct scatterlist) * SCSI_INLINE_PROT_SG_CNT;
18621890
18631891 memset(&shost->tag_set, 0, sizeof(shost->tag_set));
1864− shost->tag_set.ops = &scsi_mq_ops;
1892+ if (shost->hostt->commit_rqs)
1893+ shost->tag_set.ops = &scsi_mq_ops;
1894+ else
1895+ shost->tag_set.ops = &scsi_mq_ops_no_commit;
18651896 shost->tag_set.nr_hw_queues = shost->nr_hw_queues ? : 1;
18661897 shost->tag_set.queue_depth = shost->can_queue;
18671898 shost->tag_set.cmd_size = cmd_size;
@@ -2691,6 +2722,14 @@ void scsi_start_queue(struct scsi_device *sdev) · 823 unmodified lines
26912722 int scsi_internal_device_unblock_nowait(struct scsi_device *sdev,
26922723 enum scsi_device_state new_state)
26932724 {
2725+ switch (new_state) {
2726+ case SDEV_RUNNING:
2727+ case SDEV_TRANSPORT_OFFLINE:
2728+ break;
2729+ default:
2730+ return -EINVAL;
2731+ }
2732+
26942733 /*
26952734 * Try to transition the scsi device to SDEV_RUNNING or one of the
26962735 * offlined states and goose the device queue if successful.
@@ -2748,7 +2787,12 @@ static int scsi_internal_device_unblock(struct scsi_device *sdev, · 51 unmodified lines
27482787 static void
27492788 device_block(struct scsi_device *sdev, void *data)
27502789 {
2751− scsi_internal_device_block(sdev);
2790+ int ret;
2791+
2792+ ret = scsi_internal_device_block(sdev);
2793+
2794+ WARN_ONCE(ret, "scsi_internal_device_block(%s) failed: ret = %d\n",
2795+ dev_name(&sdev->sdev_gendev), ret);
27522796 }
27532797
27542798 static int
drivers/scsi/scsi_logging.c+3−45
@@ -15,57 +15,15 @@ · 14 unmodified lines
1515 #include <scsi/scsi_eh.h>
1616 #include <scsi/scsi_dbg.h>
1717
18−#define SCSI_LOG_SPOOLSIZE 4096
19−
20−#if (SCSI_LOG_SPOOLSIZE / SCSI_LOG_BUFSIZE) > BITS_PER_LONG
21−#warning SCSI logging bitmask too large
22−#endif
23−
24−struct scsi_log_buf {
25− char buffer[SCSI_LOG_SPOOLSIZE];
26− unsigned long map;
27−};
28−
29−static DEFINE_PER_CPU(struct scsi_log_buf, scsi_format_log);
30−
3118 static char *scsi_log_reserve_buffer(size_t *len)
3219 {
33− struct scsi_log_buf *buf;
34− unsigned long map_bits = sizeof(buf->buffer) / SCSI_LOG_BUFSIZE;
35− unsigned long idx = 0;
36−
37− preempt_disable();
38− buf = this_cpu_ptr(&scsi_format_log);
39− idx = find_first_zero_bit(&buf->map, map_bits);
40− if (likely(idx < map_bits)) {
41− while (test_and_set_bit(idx, &buf->map)) {
42− idx = find_next_zero_bit(&buf->map, map_bits, idx);
43− if (idx >= map_bits)
44− break;
45− }
46− }
47− if (WARN_ON(idx >= map_bits)) {
48− preempt_enable();
49− return NULL;
50− }
51− *len = SCSI_LOG_BUFSIZE;
52− return buf->buffer + idx * SCSI_LOG_BUFSIZE;
20+ *len = 128;
21+ return kmalloc(*len, GFP_ATOMIC);
5322 }
5423
5524 static void scsi_log_release_buffer(char *bufptr)
5625 {
57− struct scsi_log_buf *buf;
58− unsigned long idx;
59− int ret;
60−
61− buf = this_cpu_ptr(&scsi_format_log);
62− if (bufptr >= buf->buffer &&
63− bufptr < buf->buffer + SCSI_LOG_SPOOLSIZE) {
64− idx = (bufptr - buf->buffer) / SCSI_LOG_BUFSIZE;
65− ret = test_and_clear_bit(idx, &buf->map);
66− WARN_ON(!ret);
67− }
68− preempt_enable();
26+ kfree(bufptr);
6927 }
7028
7129 static inline const char *scmd_name(const struct scsi_cmnd *scmd)
drivers/scsi/sd.c+1−0
@@ -1981,6 +1981,7 @@ static int sd_done(struct scsi_cmnd *SCpnt) · 1980 unmodified lines
19811981 sd_printk(KERN_INFO, sdkp,
19821982 "Unaligned partial completion (resid=%u, sector_sz=%u)\n",
19831983 resid, sector_size);
1984+ scsi_print_command(SCpnt);
19841985 resid = min(scsi_bufflen(SCpnt),
19851986 round_up(resid, sector_size));
19861987 scsi_set_resid(SCpnt, resid);
drivers/scsi/smartpqi/Kconfig+2−0
@@ -1,6 +1,8 @@
11 #
22 # Kernel configuration file for the SMARTPQI
33 #
4+# Copyright (c) 2019 Microchip Technology Inc. and its subsidiaries
5+# Copyright (c) 2017-2018 Microsemi Corporation
46 # Copyright (c) 2016 Microsemi Corporation
57 # Copyright (c) 2016 PMC-Sierra, Inc.
68 # (mailto:esc.storagedev@microsemi.com)
drivers/scsi/smartpqi/smartpqi.h+18−2
@@ -822,6 +822,7 @@ union pqi_reset_register { · 821 unmodified lines
822822 #define PQI_HBA_BUS 2
823823 #define PQI_EXTERNAL_RAID_VOLUME_BUS 3
824824 #define PQI_MAX_BUS PQI_EXTERNAL_RAID_VOLUME_BUS
825+#define PQI_VSEP_CISS_BTL 379
825826
826827 struct report_lun_header {
827828 __be32 list_length;
@@ -930,6 +931,9 @@ struct pqi_scsi_dev { · 102 unmodified lines
930931 u8 active_path_index;
931932 u8 path_map;
932933 u8 bay;
934+ u8 box_index;
935+ u8 phys_box_on_bus;
936+ u8 phy_connected_dev_type;
933937 u8 box[8];
934938 u16 phys_connector[8];
935939 bool raid_bypass_configured; /* RAID bypass configured */
@@ -1073,6 +1077,9 @@ struct pqi_ctrl_info { · 137 unmodified lines
10731077 unsigned int ctrl_id;
10741078 struct pci_dev *pci_dev;
10751079 char firmware_version[11];
1080+ char serial_number[17];
1081+ char model[17];
1082+ char vendor[9];
10761083 void __iomem *iomem_base;
10771084 struct pqi_ctrl_registers __iomem *registers;
10781085 struct pqi_device_registers __iomem *pqi_registers;
@@ -1224,12 +1231,21 @@ struct bmic_identify_controller { · 145 unmodified lines
12241231 __le16 extended_logical_unit_count;
12251232 u8 reserved1[34];
12261233 __le16 firmware_build_number;
1227− u8 reserved2[100];
1234+ u8 reserved2[8];
1235+ u8 vendor_id[8];
1236+ u8 product_id[16];
1237+ u8 reserved3[68];
12281238 u8 controller_mode;
1229− u8 reserved3[32];
1239+ u8 reserved4[32];
1240+};
1241+
1242+struct bmic_sense_subsystem_info {
1243+ u8 reserved[44];
1244+ u8 ctrl_serial_number[16];
12301245 };
12311246
12321247 #define SA_EXPANDER_SMP_DEVICE 0x05
1248+#define SA_CONTROLLER_DEVICE 0x07
12331249 /*SCSI Invalid Device Type for SAS devices*/
12341250 #define PQI_SAS_SCSI_INVALID_DEVTYPE 0xff
12351251
drivers/scsi/smartpqi/smartpqi_init.c+205−31
@@ -33,11 +33,11 @@ · 32 unmodified lines
3333 #define BUILD_TIMESTAMP
3434 #endif
3535
36−#define DRIVER_VERSION "1.2.6-015"
36+#define DRIVER_VERSION "1.2.8-026"
3737 #define DRIVER_MAJOR 1
3838 #define DRIVER_MINOR 2
39−#define DRIVER_RELEASE 6
40−#define DRIVER_REVISION 15
39+#define DRIVER_RELEASE 8
40+#define DRIVER_REVISION 26
4141
4242 #define DRIVER_NAME "Microsemi PQI Driver (v" \
4343 DRIVER_VERSION BUILD_TIMESTAMP ")"
@@ -145,6 +145,18 @@ MODULE_PARM_DESC(lockup_action, "Action to take when controller locked up.\n" · 101 unmodified lines
145145 "\t\tSupported: none, reboot, panic\n"
146146 "\t\tDefault: none");
147147
148+static int pqi_expose_ld_first;
149+module_param_named(expose_ld_first,
150+ pqi_expose_ld_first, int, 0644);
151+MODULE_PARM_DESC(expose_ld_first,
152+ "Expose logical drives before physical drives.");
153+
154+static int pqi_hide_vsep;
155+module_param_named(hide_vsep,
156+ pqi_hide_vsep, int, 0644);
157+MODULE_PARM_DESC(hide_vsep,
158+ "Hide the virtual SEP for direct attached drives.");
159+
148160 static char *raid_levels[] = {
149161 "RAID-0",
150162 "RAID-4",
@@ -472,6 +484,7 @@ static int pqi_build_raid_path_request(struct pqi_ctrl_info *ctrl_info, · 321 unmodified lines
472484 /* fall through */
473485 case BMIC_IDENTIFY_CONTROLLER:
474486 case BMIC_IDENTIFY_PHYSICAL_DEVICE:
487+ case BMIC_SENSE_SUBSYSTEM_INFORMATION:
475488 request->data_direction = SOP_READ_FLAG;
476489 cdb[0] = BMIC_READ;
477490 cdb[6] = cmd;
@@ -600,6 +613,14 @@ static inline int pqi_identify_controller(struct pqi_ctrl_info *ctrl_info, · 122 unmodified lines
600613 buffer, sizeof(*buffer));
601614 }
602615
616+static inline int pqi_sense_subsystem_info(struct pqi_ctrl_info *ctrl_info,
617+ struct bmic_sense_subsystem_info *sense_info)
618+{
619+ return pqi_send_ctrl_raid_request(ctrl_info,
620+ BMIC_SENSE_SUBSYSTEM_INFORMATION,
621+ sense_info, sizeof(*sense_info));
622+}
623+
603624 static inline int pqi_scsi_inquiry(struct pqi_ctrl_info *ctrl_info,
604625 u8 *scsi3addr, u16 vpd_page, void *buffer, size_t buffer_length)
605626 {
@@ -1392,7 +1413,9 @@ static void pqi_get_physical_disk_info(struct pqi_ctrl_info *ctrl_info, · 786 unmodified lines
13921413 device->queue_depth = PQI_PHYSICAL_DISK_DEFAULT_MAX_QUEUE_DEPTH;
13931414 return;
13941415 }
1395−
1416+ device->box_index = id_phys->box_index;
1417+ device->phys_box_on_bus = id_phys->phys_box_on_bus;
1418+ device->phy_connected_dev_type = id_phys->phy_connected_dev_type[0];
13961419 device->queue_depth =
13971420 get_unaligned_le16(&id_phys->current_queue_depth_limit);
13981421 device->device_type = id_phys->device_type;
@@ -1719,6 +1742,10 @@ static void pqi_scsi_update_device(struct pqi_scsi_dev *existing_device, · 320 unmodified lines
17191742 existing_device->active_path_index = new_device->active_path_index;
17201743 existing_device->path_map = new_device->path_map;
17211744 existing_device->bay = new_device->bay;
1745+ existing_device->box_index = new_device->box_index;
1746+ existing_device->phys_box_on_bus = new_device->phys_box_on_bus;
1747+ existing_device->phy_connected_dev_type =
1748+ new_device->phy_connected_dev_type;
17221749 memcpy(existing_device->box, new_device->box,
17231750 sizeof(existing_device->box));
17241751 memcpy(existing_device->phys_connector, new_device->phys_connector,
@@ -1945,6 +1972,11 @@ static inline bool pqi_skip_device(u8 *scsi3addr) · 220 unmodified lines
19451972 return false;
19461973 }
19471974
1975+static inline void pqi_mask_device(u8 *scsi3addr)
1976+{
1977+ scsi3addr[3] |= 0xc0;
1978+}
1979+
19481980 static inline bool pqi_is_device_with_sas_address(struct pqi_scsi_dev *device)
19491981 {
19501982 if (!device->is_physical_device)
@@ -1988,6 +2020,8 @@ static int pqi_update_scsi_devices(struct pqi_ctrl_info *ctrl_info) · 37 unmodified lines
19882020 unsigned int num_valid_devices;
19892021 bool is_physical_device;
19902022 u8 *scsi3addr;
2023+ unsigned int physical_index;
2024+ unsigned int logical_index;
19912025 static char *out_of_memory_msg =
19922026 "failed to allocate memory, device discovery stopped";
19932027
@@ -2023,6 +2057,21 @@ static int pqi_update_scsi_devices(struct pqi_ctrl_info *ctrl_info) · 29 unmodified lines
20232057 rc = -ENOMEM;
20242058 goto out;
20252059 }
2060+ if (pqi_hide_vsep) {
2061+ int i;
2062+
2063+ for (i = num_physicals - 1; i >= 0; i--) {
2064+ phys_lun_ext_entry =
2065+ &physdev_list->lun_entries[i];
2066+ if (CISS_GET_DRIVE_NUMBER(
2067+ phys_lun_ext_entry->lunid) ==
2068+ PQI_VSEP_CISS_BTL) {
2069+ pqi_mask_device(
2070+ phys_lun_ext_entry->lunid);
2071+ break;
2072+ }
2073+ }
2074+ }
20262075 }
20272076
20282077 num_new_devices = num_physicals + num_logicals;
@@ -2050,19 +2099,23 @@ static int pqi_update_scsi_devices(struct pqi_ctrl_info *ctrl_info) · 21 unmodified lines
20502099
20512100 device = NULL;
20522101 num_valid_devices = 0;
2102+ physical_index = 0;
2103+ logical_index = 0;
20532104
20542105 for (i = 0; i < num_new_devices; i++) {
20552106
2056− if (i < num_physicals) {
2107+ if ((!pqi_expose_ld_first && i < num_physicals) ||
2108+ (pqi_expose_ld_first && i >= num_logicals)) {
20572109 is_physical_device = true;
2058− phys_lun_ext_entry = &physdev_list->lun_entries[i];
2110+ phys_lun_ext_entry =
2111+ &physdev_list->lun_entries[physical_index++];
20592112 log_lun_ext_entry = NULL;
20602113 scsi3addr = phys_lun_ext_entry->lunid;
20612114 } else {
20622115 is_physical_device = false;
20632116 phys_lun_ext_entry = NULL;
20642117 log_lun_ext_entry =
2065− &logdev_list->lun_entries[i - num_physicals];
2118+ &logdev_list->lun_entries[logical_index++];
20662119 scsi3addr = log_lun_ext_entry->lunid;
20672120 }
20682121
@@ -2122,11 +2175,10 @@ static int pqi_update_scsi_devices(struct pqi_ctrl_info *ctrl_info) · 53 unmodified lines
21222175 device->aio_handle =
21232176 phys_lun_ext_entry->aio_handle;
21242177 }
2125− if (device->devtype == TYPE_DISK ||
2126− device->devtype == TYPE_ZBC) {
2178+
21272179 pqi_get_physical_disk_info(ctrl_info,
21282180 device, id_phys);
2129− }
2181+
21302182 } else {
21312183 memcpy(device->volume_id, log_lun_ext_entry->volume_id,
21322184 sizeof(device->volume_id));
@@ -2184,18 +2236,20 @@ static void pqi_remove_all_scsi_devices(struct pqi_ctrl_info *ctrl_info) · 51 unmodified lines
21842236
21852237 static int pqi_scan_scsi_devices(struct pqi_ctrl_info *ctrl_info)
21862238 {
2187− int rc;
2239+ int rc = 0;
21882240
21892241 if (pqi_ctrl_offline(ctrl_info))
21902242 return -ENXIO;
21912243
2192− mutex_lock(&ctrl_info->scan_mutex);
2193−
2194− rc = pqi_update_scsi_devices(ctrl_info);
2195− if (rc)
2244+ if (!mutex_trylock(&ctrl_info->scan_mutex)) {
21962245 pqi_schedule_rescan_worker_delayed(ctrl_info);
2197−
2198− mutex_unlock(&ctrl_info->scan_mutex);
2246+ rc = -EINPROGRESS;
2247+ } else {
2248+ rc = pqi_update_scsi_devices(ctrl_info);
2249+ if (rc)
2250+ pqi_schedule_rescan_worker_delayed(ctrl_info);
2251+ mutex_unlock(&ctrl_info->scan_mutex);
2252+ }
21992253
22002254 return rc;
22012255 }
@@ -6091,23 +6145,65 @@ static int pqi_ioctl(struct scsi_device *sdev, unsigned int cmd, · 3889 unmodified lines
60916145 return rc;
60926146 }
60936147
6094−static ssize_t pqi_version_show(struct device *dev,
6148+static ssize_t pqi_firmware_version_show(struct device *dev,
6149+ struct device_attribute *attr, char *buffer)
6150+{
6151+ struct Scsi_Host *shost;
6152+ struct pqi_ctrl_info *ctrl_info;
6153+
6154+ shost = class_to_shost(dev);
6155+ ctrl_info = shost_to_hba(shost);
6156+
6157+ return snprintf(buffer, PAGE_SIZE, "%s\n", ctrl_info->firmware_version);
6158+}
6159+
6160+static ssize_t pqi_driver_version_show(struct device *dev,
6161+ struct device_attribute *attr, char *buffer)
6162+{
6163+ struct Scsi_Host *shost;
6164+ struct pqi_ctrl_info *ctrl_info;
6165+
6166+ shost = class_to_shost(dev);
6167+ ctrl_info = shost_to_hba(shost);
6168+
6169+ return snprintf(buffer, PAGE_SIZE,
6170+ "%s\n", DRIVER_VERSION BUILD_TIMESTAMP);
6171+}
6172+
6173+static ssize_t pqi_serial_number_show(struct device *dev,
60956174 struct device_attribute *attr, char *buffer)
60966175 {
6097− ssize_t count = 0;
60986176 struct Scsi_Host *shost;
60996177 struct pqi_ctrl_info *ctrl_info;
61006178
61016179 shost = class_to_shost(dev);
61026180 ctrl_info = shost_to_hba(shost);
61036181
6104− count += snprintf(buffer + count, PAGE_SIZE - count,
6105− " driver: %s\n", DRIVER_VERSION BUILD_TIMESTAMP);
6182+ return snprintf(buffer, PAGE_SIZE, "%s\n", ctrl_info->serial_number);
6183+}
6184+
6185+static ssize_t pqi_model_show(struct device *dev,
6186+ struct device_attribute *attr, char *buffer)
6187+{
6188+ struct Scsi_Host *shost;
6189+ struct pqi_ctrl_info *ctrl_info;
61066190
6107− count += snprintf(buffer + count, PAGE_SIZE - count,
6108− "firmware: %s\n", ctrl_info->firmware_version);
6191+ shost = class_to_shost(dev);
6192+ ctrl_info = shost_to_hba(shost);
61096193
6110− return count;
6194+ return snprintf(buffer, PAGE_SIZE, "%s\n", ctrl_info->model);
6195+}
6196+
6197+static ssize_t pqi_vendor_show(struct device *dev,
6198+ struct device_attribute *attr, char *buffer)
6199+{
6200+ struct Scsi_Host *shost;
6201+ struct pqi_ctrl_info *ctrl_info;
6202+
6203+ shost = class_to_shost(dev);
6204+ ctrl_info = shost_to_hba(shost);
6205+
6206+ return snprintf(buffer, PAGE_SIZE, "%s\n", ctrl_info->vendor);
61116207 }
61126208
61136209 static ssize_t pqi_host_rescan_store(struct device *dev,
@@ -6160,13 +6256,21 @@ static ssize_t pqi_lockup_action_store(struct device *dev, · 46 unmodified lines
61606256 return -EINVAL;
61616257 }
61626258
6163−static DEVICE_ATTR(version, 0444, pqi_version_show, NULL);
6259+static DEVICE_ATTR(driver_version, 0444, pqi_driver_version_show, NULL);
6260+static DEVICE_ATTR(firmware_version, 0444, pqi_firmware_version_show, NULL);
6261+static DEVICE_ATTR(model, 0444, pqi_model_show, NULL);
6262+static DEVICE_ATTR(serial_number, 0444, pqi_serial_number_show, NULL);
6263+static DEVICE_ATTR(vendor, 0444, pqi_vendor_show, NULL);
61646264 static DEVICE_ATTR(rescan, 0200, NULL, pqi_host_rescan_store);
61656265 static DEVICE_ATTR(lockup_action, 0644,
61666266 pqi_lockup_action_show, pqi_lockup_action_store);
61676267
61686268 static struct device_attribute *pqi_shost_attrs[] = {
6169− &dev_attr_version,
6269+ &dev_attr_driver_version,
6270+ &dev_attr_firmware_version,
6271+ &dev_attr_model,
6272+ &dev_attr_serial_number,
6273+ &dev_attr_vendor,
61706274 &dev_attr_rescan,
61716275 &dev_attr_lockup_action,
61726276 NULL
@@ -6558,7 +6662,30 @@ static int pqi_reset(struct pqi_ctrl_info *ctrl_info) · 385 unmodified lines
65586662 return rc;
65596663 }
65606664
6561−static int pqi_get_ctrl_firmware_version(struct pqi_ctrl_info *ctrl_info)
6665+static int pqi_get_ctrl_serial_number(struct pqi_ctrl_info *ctrl_info)
6666+{
6667+ int rc;
6668+ struct bmic_sense_subsystem_info *sense_info;
6669+
6670+ sense_info = kzalloc(sizeof(*sense_info), GFP_KERNEL);
6671+ if (!sense_info)
6672+ return -ENOMEM;
6673+
6674+ rc = pqi_sense_subsystem_info(ctrl_info, sense_info);
6675+ if (rc)
6676+ goto out;
6677+
6678+ memcpy(ctrl_info->serial_number, sense_info->ctrl_serial_number,
6679+ sizeof(sense_info->ctrl_serial_number));
6680+ ctrl_info->serial_number[sizeof(sense_info->ctrl_serial_number)] = '\0';
6681+
6682+out:
6683+ kfree(sense_info);
6684+
6685+ return rc;
6686+}
6687+
6688+static int pqi_get_ctrl_product_details(struct pqi_ctrl_info *ctrl_info)
65626689 {
65636690 int rc;
65646691 struct bmic_identify_controller *identify;
@@ -6579,6 +6706,14 @@ static int pqi_get_ctrl_firmware_version(struct pqi_ctrl_info *ctrl_info) · 14 unmodified lines
65796706 sizeof(ctrl_info->firmware_version),
65806707 "-%u", get_unaligned_le16(&identify->firmware_build_number));
65816708
6709+ memcpy(ctrl_info->model, identify->product_id,
6710+ sizeof(identify->product_id));
6711+ ctrl_info->model[sizeof(identify->product_id)] = '\0';
6712+
6713+ memcpy(ctrl_info->vendor, identify->vendor_id,
6714+ sizeof(identify->vendor_id));
6715+ ctrl_info->vendor[sizeof(identify->vendor_id)] = '\0';
6716+
65826717 out:
65836718 kfree(identify);
65846719
@@ -7098,10 +7233,17 @@ static int pqi_ctrl_init(struct pqi_ctrl_info *ctrl_info) · 513 unmodified lines
70987233 if (rc)
70997234 return rc;
71007235
7101− rc = pqi_get_ctrl_firmware_version(ctrl_info);
7236+ rc = pqi_get_ctrl_product_details(ctrl_info);
71027237 if (rc) {
71037238 dev_err(&ctrl_info->pci_dev->dev,
7104− "error obtaining firmware version\n");
7239+ "error obtaining product details\n");
7240+ return rc;
7241+ }
7242+
7243+ rc = pqi_get_ctrl_serial_number(ctrl_info);
7244+ if (rc) {
7245+ dev_err(&ctrl_info->pci_dev->dev,
7246+ "error obtaining ctrl serial number\n");
71057247 return rc;
71067248 }
71077249
@@ -7241,10 +7383,10 @@ static int pqi_ctrl_init_resume(struct pqi_ctrl_info *ctrl_info) · 133 unmodified lines
72417383 return rc;
72427384 }
72437385
7244− rc = pqi_get_ctrl_firmware_version(ctrl_info);
7386+ rc = pqi_get_ctrl_product_details(ctrl_info);
72457387 if (rc) {
72467388 dev_err(&ctrl_info->pci_dev->dev,
7247− "error obtaining firmware version\n");
7389+ "error obtaining product detail\n");
72487390 return rc;
72497391 }
72507392
@@ -8022,6 +8164,10 @@ static const struct pci_device_id pqi_pci_id_table[] = { · 771 unmodified lines
80228164 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
80238165 0x1bd4, 0x004c)
80248166 },
8167+ {
8168+ PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
8169+ 0x1bd4, 0x004f)
8170+ },
80258171 {
80268172 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
80278173 0x19e5, 0xd227)
@@ -8086,6 +8232,14 @@ static const struct pci_device_id pqi_pci_id_table[] = { · 58 unmodified lines
80868232 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
80878233 PCI_VENDOR_ID_ADAPTEC2, 0x0807)
80888234 },
8235+ {
8236+ PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
8237+ PCI_VENDOR_ID_ADAPTEC2, 0x0808)
8238+ },
8239+ {
8240+ PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
8241+ PCI_VENDOR_ID_ADAPTEC2, 0x0809)
8242+ },
80898243 {
80908244 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
80918245 PCI_VENDOR_ID_ADAPTEC2, 0x0900)
@@ -8242,6 +8396,26 @@ static const struct pci_device_id pqi_pci_id_table[] = { · 150 unmodified lines
82428396 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
82438397 PCI_VENDOR_ID_HP, 0x1101)
82448398 },
8399+ {
8400+ PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
8401+ 0x1d8d, 0x0800)
8402+ },
8403+ {
8404+ PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
8405+ 0x1d8d, 0x0908)
8406+ },
8407+ {
8408+ PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
8409+ 0x1d8d, 0x0806)
8410+ },
8411+ {
8412+ PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
8413+ 0x1d8d, 0x0916)
8414+ },
8415+ {
8416+ PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
8417+ PCI_VENDOR_ID_GIGABYTE, 0x1000)
8418+ },
82458419 {
82468420 PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
82478421 PCI_ANY_ID, PCI_ANY_ID)
drivers/scsi/smartpqi/smartpqi_sas_transport.c+100−2
@@ -312,12 +312,110 @@ static int pqi_sas_get_linkerrors(struct sas_phy *phy) · 311 unmodified lines
312312 static int pqi_sas_get_enclosure_identifier(struct sas_rphy *rphy,
313313 u64 *identifier)
314314 {
315− return 0;
315+
316+ int rc;
317+ unsigned long flags;
318+ struct Scsi_Host *shost;
319+ struct pqi_ctrl_info *ctrl_info;
320+ struct pqi_scsi_dev *found_device;
321+ struct pqi_scsi_dev *device;
322+
323+ if (!rphy)
324+ return -ENODEV;
325+
326+ shost = rphy_to_shost(rphy);
327+ ctrl_info = shost_to_hba(shost);
328+ spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags);
329+ found_device = pqi_find_device_by_sas_rphy(ctrl_info, rphy);
330+
331+ if (!found_device) {
332+ rc = -ENODEV;
333+ goto out;
334+ }
335+
336+ if (found_device->devtype == TYPE_ENCLOSURE) {
337+ *identifier = get_unaligned_be64(&found_device->wwid);
338+ rc = 0;
339+ goto out;
340+ }
341+
342+ if (found_device->box_index == 0xff ||
343+ found_device->phys_box_on_bus == 0 ||
344+ found_device->bay == 0xff) {
345+ rc = -EINVAL;
346+ goto out;
347+ }
348+
349+ list_for_each_entry(device, &ctrl_info->scsi_device_list,
350+ scsi_device_list_entry) {
351+ if (device->devtype == TYPE_ENCLOSURE &&
352+ device->box_index == found_device->box_index &&
353+ device->phys_box_on_bus ==
354+ found_device->phys_box_on_bus &&
355+ memcmp(device->phys_connector,
356+ found_device->phys_connector, 2) == 0) {
357+ *identifier =
358+ get_unaligned_be64(&device->wwid);
359+ rc = 0;
360+ goto out;
361+ }
362+ }
363+
364+ if (found_device->phy_connected_dev_type != SA_CONTROLLER_DEVICE) {
365+ rc = -EINVAL;
366+ goto out;
367+ }
368+
369+ list_for_each_entry(device, &ctrl_info->scsi_device_list,
370+ scsi_device_list_entry) {
371+ if (device->devtype == TYPE_ENCLOSURE &&
372+ CISS_GET_DRIVE_NUMBER(device->scsi3addr) ==
373+ PQI_VSEP_CISS_BTL) {
374+ *identifier = get_unaligned_be64(&device->wwid);
375+ rc = 0;
376+ goto out;
377+ }
378+ }
379+
380+ rc = -EINVAL;
381+out:
382+ spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
383+
384+ return rc;
385+
316386 }
317387
318388 static int pqi_sas_get_bay_identifier(struct sas_rphy *rphy)
319389 {
320− return -ENXIO;
390+
391+ int rc;
392+ unsigned long flags;
393+ struct pqi_ctrl_info *ctrl_info;
394+ struct pqi_scsi_dev *device;
395+ struct Scsi_Host *shost;
396+
397+ if (!rphy)
398+ return -ENODEV;
399+
400+ shost = rphy_to_shost(rphy);
401+ ctrl_info = shost_to_hba(shost);
402+ spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags);
403+ device = pqi_find_device_by_sas_rphy(ctrl_info, rphy);
404+
405+ if (!device) {
406+ rc = -ENODEV;
407+ goto out;
408+ }
409+
410+ if (device->bay == 0xff)
411+ rc = -EINVAL;
412+ else
413+ rc = device->bay;
414+
415+out:
416+ spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
417+
418+ return rc;
321419 }
322420
323421 static int pqi_sas_phy_reset(struct sas_phy *phy, int hard_reset)
drivers/scsi/sun3_scsi.c+2−0
@@ -397,10 +397,12 @@ static int sun3scsi_dma_finish(int write_flag) · 396 unmodified lines
397397 case CSR_LEFT_3:
398398 *vaddr = (dregs->bpack_lo & 0xff00) >> 8;
399399 vaddr--;
400+ /* Fall through */
400401
401402 case CSR_LEFT_2:
402403 *vaddr = (dregs->bpack_hi & 0x00ff);
403404 vaddr--;
405+ /* Fall through */
404406
405407 case CSR_LEFT_1:
406408 *vaddr = (dregs->bpack_hi & 0xff00) >> 8;
drivers/scsi/sym53c8xx_2/sym_nvram.c+1−1
@@ -648,7 +648,7 @@ static int sym_read_T93C46_nvram(struct sym_device *np, Tekram_nvram *nvram) · 647 unmodified lines
648648 {
649649 u_char gpcntl, gpreg;
650650 u_char old_gpcntl, old_gpreg;
651− int retv = 1;
651+ int retv;
652652
653653 /* save current state of GPCNTL and GPREG */
654654 old_gpreg = INB(np, nc_gpreg);
drivers/scsi/ufs/cdns-pltfrm.c+33−7
@@ -62,22 +62,46 @@ static int cdns_ufs_set_hclkdiv(struct ufs_hba *hba) · 61 unmodified lines
6262 }
6363
6464 /**
65− * Sets clocks used by the controller
65+ * Called before and after HCE enable bit is set.
6666 * @hba: host controller instance
67− * @on: if true, enable clocks, otherwise disable
6867 * @status: notify stage (pre, post change)
6968 *
7069 * Return zero for success and non-zero for failure
7170 */
72−static int cdns_ufs_setup_clocks(struct ufs_hba *hba, bool on,
73− enum ufs_notify_change_status status)
71+static int cdns_ufs_hce_enable_notify(struct ufs_hba *hba,
72+ enum ufs_notify_change_status status)
7473 {
75− if ((!on) || (status == PRE_CHANGE))
74+ if (status != PRE_CHANGE)
7675 return 0;
7776
7877 return cdns_ufs_set_hclkdiv(hba);
7978 }
8079
80+/**
81+ * Called before and after Link startup is carried out.
82+ * @hba: host controller instance
83+ * @status: notify stage (pre, post change)
84+ *
85+ * Return zero for success and non-zero for failure
86+ */
87+static int cdns_ufs_link_startup_notify(struct ufs_hba *hba,
88+ enum ufs_notify_change_status status)
89+{
90+ if (status != PRE_CHANGE)
91+ return 0;
92+
93+ /*
94+ * Some UFS devices have issues if LCC is enabled.
95+ * So we are setting PA_Local_TX_LCC_Enable to 0
96+ * before link startup which will make sure that both host
97+ * and device TX LCC are disabled once link startup is
98+ * completed.
99+ */
100+ ufshcd_dme_set(hba, UIC_ARG_MIB(PA_LOCAL_TX_LCC_ENABLE), 0);
101+
102+ return 0;
103+}
104+
81105 /**
82106 * cdns_ufs_init - performs additional ufs initialization
83107 * @hba: host controller instance
@@ -114,13 +138,15 @@ static int cdns_ufs_m31_16nm_phy_initialization(struct ufs_hba *hba) · 30 unmodified lines
114138
115139 static const struct ufs_hba_variant_ops cdns_ufs_pltfm_hba_vops = {
116140 .name = "cdns-ufs-pltfm",
117− .setup_clocks = cdns_ufs_setup_clocks,
141+ .hce_enable_notify = cdns_ufs_hce_enable_notify,
142+ .link_startup_notify = cdns_ufs_link_startup_notify,
118143 };
119144
120145 static const struct ufs_hba_variant_ops cdns_ufs_m31_16nm_pltfm_hba_vops = {
121146 .name = "cdns-ufs-pltfm",
122147 .init = cdns_ufs_init,
123− .setup_clocks = cdns_ufs_setup_clocks,
148+ .hce_enable_notify = cdns_ufs_hce_enable_notify,
149+ .link_startup_notify = cdns_ufs_link_startup_notify,
124150 .phy_initialization = cdns_ufs_m31_16nm_phy_initialization,
125151 };
126152
drivers/scsi/ufs/ufs-hisi.c+1−3
@@ -447,13 +447,11 @@ static int ufs_hisi_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) · 446 unmodified lines
447447
448448 static int ufs_hisi_get_resource(struct ufs_hisi_host *host)
449449 {
450− struct resource *mem_res;
451450 struct device *dev = host->hba->dev;
452451 struct platform_device *pdev = to_platform_device(dev);
453452
454453 /* get resource of ufs sys ctrl */
455− mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
456− host->ufs_sys_ctrl = devm_ioremap_resource(dev, mem_res);
454+ host->ufs_sys_ctrl = devm_platform_ioremap_resource(pdev, 1);
457455 if (IS_ERR(host->ufs_sys_ctrl))
458456 return PTR_ERR(host->ufs_sys_ctrl);
459457
drivers/scsi/ufs/ufs-qcom.c+37−4
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 #include <linux/of.h>
99 #include <linux/platform_device.h>
1010 #include <linux/phy/phy.h>
11+#include <linux/gpio/consumer.h>
1112 #include <linux/reset-controller.h>
1213
1314 #include "ufshcd.h"
@@ -800,7 +801,6 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba, · 786 unmodified lines
800801 struct ufs_pa_layer_attr *dev_max_params,
801802 struct ufs_pa_layer_attr *dev_req_params)
802803 {
803− u32 val;
804804 struct ufs_qcom_host *host = ufshcd_get_variant(hba);
805805 struct ufs_dev_params ufs_qcom_cap;
806806 int ret = 0;
@@ -869,8 +869,6 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba, · 62 unmodified lines
869869 ret = -EINVAL;
870870 }
871871
872− val = ~(MAX_U32 << dev_req_params->lane_tx);
873−
874872 /* cache the power mode parameters to use internally */
875873 memcpy(&host->dev_req_params,
876874 dev_req_params, sizeof(*dev_req_params));
@@ -1140,6 +1138,15 @@ static int ufs_qcom_init(struct ufs_hba *hba) · 263 unmodified lines
11401138 }
11411139 }
11421140
1141+ host->device_reset = devm_gpiod_get_optional(dev, "reset",
1142+ GPIOD_OUT_HIGH);
1143+ if (IS_ERR(host->device_reset)) {
1144+ err = PTR_ERR(host->device_reset);
1145+ if (err != -EPROBE_DEFER)
1146+ dev_err(dev, "failed to acquire reset gpio: %d\n", err);
1147+ goto out_variant_clear;
1148+ }
1149+
11431150 err = ufs_qcom_bus_register(host);
11441151 if (err)
11451152 goto out_variant_clear;
@@ -1545,13 +1552,38 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba) · 399 unmodified lines
15451552 usleep_range(1000, 1100);
15461553 }
15471554
1555+/**
1556+ * ufs_qcom_device_reset() - toggle the (optional) device reset line
1557+ * @hba: per-adapter instance
1558+ *
1559+ * Toggles the (optional) reset line to reset the attached device.
1560+ */
1561+static void ufs_qcom_device_reset(struct ufs_hba *hba)
1562+{
1563+ struct ufs_qcom_host *host = ufshcd_get_variant(hba);
1564+
1565+ /* reset gpio is optional */
1566+ if (!host->device_reset)
1567+ return;
1568+
1569+ /*
1570+ * The UFS device shall detect reset pulses of 1us, sleep for 10us to
1571+ * be on the safe side.
1572+ */
1573+ gpiod_set_value_cansleep(host->device_reset, 1);
1574+ usleep_range(10, 15);
1575+
1576+ gpiod_set_value_cansleep(host->device_reset, 0);
1577+ usleep_range(10, 15);
1578+}
1579+
15481580 /**
15491581 * struct ufs_hba_qcom_vops - UFS QCOM specific variant operations
15501582 *
15511583 * The variant operations configure the necessary controller and PHY
15521584 * handshake during initialization.
15531585 */
1554−static struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
1586+static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
15551587 .name = "qcom",
15561588 .init = ufs_qcom_init,
15571589 .exit = ufs_qcom_exit,
@@ -1565,6 +1597,7 @@ static struct ufs_hba_variant_ops ufs_hba_qcom_vops = { · 7 unmodified lines
15651597 .suspend = ufs_qcom_suspend,
15661598 .resume = ufs_qcom_resume,
15671599 .dbg_register_dump = ufs_qcom_dump_dbg_regs,
1600+ .device_reset = ufs_qcom_device_reset,
15681601 };
15691602
15701603 /**
drivers/scsi/ufs/ufs-qcom.h+4−0
@@ -195,6 +195,8 @@ struct ufs_qcom_testbus { · 194 unmodified lines
195195 u8 select_minor;
196196 };
197197
198+struct gpio_desc;
199+
198200 struct ufs_qcom_host {
199201 /*
200202 * Set this capability if host controller supports the QUniPro mode
@@ -232,6 +234,8 @@ struct ufs_qcom_host { · 31 unmodified lines
232234 struct ufs_qcom_testbus testbus;
233235
234236 struct reset_controller_dev rcdev;
237+
238+ struct gpio_desc *device_reset;
235239 };
236240
237241 static inline u32
drivers/scsi/ufs/ufs-sysfs.c+9−9
@@ -571,9 +571,10 @@ static ssize_t _name##_show(struct device *dev, \ · 570 unmodified lines
571571 int ret; \
572572 int desc_len = QUERY_DESC_MAX_SIZE; \
573573 u8 *desc_buf; \
574+ \
574575 desc_buf = kzalloc(QUERY_DESC_MAX_SIZE, GFP_ATOMIC); \
575− if (!desc_buf) \
576− return -ENOMEM; \
576+ if (!desc_buf) \
577+ return -ENOMEM; \
577578 ret = ufshcd_query_descriptor_retry(hba, \
578579 UPIU_QUERY_OPCODE_READ_DESC, QUERY_DESC_IDN_DEVICE, \
579580 0, 0, desc_buf, &desc_len); \
@@ -582,14 +583,13 @@ static ssize_t _name##_show(struct device *dev, \ · 2 unmodified lines
582583 goto out; \
583584 } \
584585 index = desc_buf[DEVICE_DESC_PARAM##_pname]; \
585− memset(desc_buf, 0, QUERY_DESC_MAX_SIZE); \
586− if (ufshcd_read_string_desc(hba, index, desc_buf, \
587− QUERY_DESC_MAX_SIZE, true)) { \
588− ret = -EINVAL; \
586+ kfree(desc_buf); \
587+ desc_buf = NULL; \
588+ ret = ufshcd_read_string_desc(hba, index, &desc_buf, \
589+ SD_ASCII_STD); \
590+ if (ret < 0) \
589591 goto out; \
590− } \
591− ret = snprintf(buf, PAGE_SIZE, "%s\n", \
592− desc_buf + QUERY_DESC_HDR_SIZE); \
592+ ret = snprintf(buf, PAGE_SIZE, "%s\n", desc_buf); \
593593 out: \
594594 kfree(desc_buf); \
595595 return ret; \
drivers/scsi/ufs/ufs.h+1−1
@@ -541,7 +541,7 @@ struct ufs_dev_info { · 540 unmodified lines
541541 */
542542 struct ufs_dev_desc {
543543 u16 wmanufacturerid;
544− char model[MAX_MODEL_LEN + 1];
544+ u8 *model;
545545 };
546546
547547 /**
drivers/scsi/ufs/ufshcd-pltfrm.c+1−3
@@ -391,12 +391,10 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, · 390 unmodified lines
391391 {
392392 struct ufs_hba *hba;
393393 void __iomem *mmio_base;
394− struct resource *mem_res;
395394 int irq, err;
396395 struct device *dev = &pdev->dev;
397396
398− mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
399− mmio_base = devm_ioremap_resource(dev, mem_res);
397+ mmio_base = devm_platform_ioremap_resource(pdev, 0);
400398 if (IS_ERR(mmio_base)) {
401399 err = PTR_ERR(mmio_base);
402400 goto out;
drivers/scsi/ufs/ufshcd.c+166−115
@@ -299,16 +299,6 @@ static void ufshcd_scsi_block_requests(struct ufs_hba *hba) · 298 unmodified lines
299299 scsi_block_requests(hba->host);
300300 }
301301
302−/* replace non-printable or non-ASCII characters with spaces */
303−static inline void ufshcd_remove_non_printable(char *val)
304−{
305− if (!val)
306− return;
307−
308− if (*val < 0x20 || *val > 0x7e)
309− *val = ' ';
310−}
311−
312302 static void ufshcd_add_cmd_upiu_trace(struct ufs_hba *hba, unsigned int tag,
313303 const char *str)
314304 {
@@ -390,24 +380,25 @@ static void ufshcd_print_clk_freqs(struct ufs_hba *hba) · 75 unmodified lines
390380 }
391381 }
392382
393−static void ufshcd_print_uic_err_hist(struct ufs_hba *hba,
394− struct ufs_uic_err_reg_hist *err_hist, char *err_name)
383+static void ufshcd_print_err_hist(struct ufs_hba *hba,
384+ struct ufs_err_reg_hist *err_hist,
385+ char *err_name)
395386 {
396387 int i;
397388 bool found = false;
398389
399− for (i = 0; i < UIC_ERR_REG_HIST_LENGTH; i++) {
400− int p = (i + err_hist->pos) % UIC_ERR_REG_HIST_LENGTH;
390+ for (i = 0; i < UFS_ERR_REG_HIST_LENGTH; i++) {
391+ int p = (i + err_hist->pos) % UFS_ERR_REG_HIST_LENGTH;
401392
402393 if (err_hist->reg[p] == 0)
403394 continue;
404− dev_err(hba->dev, "%s[%d] = 0x%x at %lld us\n", err_name, i,
395+ dev_err(hba->dev, "%s[%d] = 0x%x at %lld us\n", err_name, p,
405396 err_hist->reg[p], ktime_to_us(err_hist->tstamp[p]));
406397 found = true;
407398 }
408399
409400 if (!found)
410− dev_err(hba->dev, "No record of %s uic errors\n", err_name);
401+ dev_err(hba->dev, "No record of %s errors\n", err_name);
411402 }
412403
413404 static void ufshcd_print_host_regs(struct ufs_hba *hba)
@@ -423,11 +414,22 @@ static void ufshcd_print_host_regs(struct ufs_hba *hba) · 9 unmodified lines
423414 ktime_to_us(hba->ufs_stats.last_hibern8_exit_tstamp),
424415 hba->ufs_stats.hibern8_exit_cnt);
425416
426− ufshcd_print_uic_err_hist(hba, &hba->ufs_stats.pa_err, "pa_err");
427− ufshcd_print_uic_err_hist(hba, &hba->ufs_stats.dl_err, "dl_err");
428− ufshcd_print_uic_err_hist(hba, &hba->ufs_stats.nl_err, "nl_err");
429− ufshcd_print_uic_err_hist(hba, &hba->ufs_stats.tl_err, "tl_err");
430− ufshcd_print_uic_err_hist(hba, &hba->ufs_stats.dme_err, "dme_err");
417+ ufshcd_print_err_hist(hba, &hba->ufs_stats.pa_err, "pa_err");
418+ ufshcd_print_err_hist(hba, &hba->ufs_stats.dl_err, "dl_err");
419+ ufshcd_print_err_hist(hba, &hba->ufs_stats.nl_err, "nl_err");
420+ ufshcd_print_err_hist(hba, &hba->ufs_stats.tl_err, "tl_err");
421+ ufshcd_print_err_hist(hba, &hba->ufs_stats.dme_err, "dme_err");
422+ ufshcd_print_err_hist(hba, &hba->ufs_stats.auto_hibern8_err,
423+ "auto_hibern8_err");
424+ ufshcd_print_err_hist(hba, &hba->ufs_stats.fatal_err, "fatal_err");
425+ ufshcd_print_err_hist(hba, &hba->ufs_stats.link_startup_err,
426+ "link_startup_fail");
427+ ufshcd_print_err_hist(hba, &hba->ufs_stats.resume_err, "resume_fail");
428+ ufshcd_print_err_hist(hba, &hba->ufs_stats.suspend_err,
429+ "suspend_fail");
430+ ufshcd_print_err_hist(hba, &hba->ufs_stats.dev_reset, "dev_reset");
431+ ufshcd_print_err_hist(hba, &hba->ufs_stats.host_reset, "host_reset");
432+ ufshcd_print_err_hist(hba, &hba->ufs_stats.task_abort, "task_abort");
431433
432434 ufshcd_print_clk_freqs(hba);
433435
@@ -3199,7 +3201,7 @@ out: · 2765 unmodified lines
31993201 static inline int ufshcd_read_desc(struct ufs_hba *hba,
32003202 enum desc_idn desc_id,
32013203 int desc_index,
3202− u8 *buf,
3204+ void *buf,
32033205 u32 size)
32043206 {
32053207 return ufshcd_read_desc_param(hba, desc_id, desc_index, 0, buf, size);
@@ -3217,49 +3219,78 @@ static int ufshcd_read_device_desc(struct ufs_hba *hba, u8 *buf, u32 size) · 11 unmodified lines
32173219 return ufshcd_read_desc(hba, QUERY_DESC_IDN_DEVICE, 0, buf, size);
32183220 }
32193221
3222+/**
3223+ * struct uc_string_id - unicode string
3224+ *
3225+ * @len: size of this descriptor inclusive
3226+ * @type: descriptor type
3227+ * @uc: unicode string character
3228+ */
3229+struct uc_string_id {
3230+ u8 len;
3231+ u8 type;
3232+ wchar_t uc[0];
3233+} __packed;
3234+
3235+/* replace non-printable or non-ASCII characters with spaces */
3236+static inline char ufshcd_remove_non_printable(u8 ch)
3237+{
3238+ return (ch >= 0x20 && ch <= 0x7e) ? ch : ' ';
3239+}
3240+
32203241 /**
32213242 * ufshcd_read_string_desc - read string descriptor
32223243 * @hba: pointer to adapter instance
32233244 * @desc_index: descriptor index
3224− * @buf: pointer to buffer where descriptor would be read
3225− * @size: size of buf
3245+ * @buf: pointer to buffer where descriptor would be read,
3246+ * the caller should free the memory.
32263247 * @ascii: if true convert from unicode to ascii characters
3248+ * null terminated string.
32273249 *
3228− * Return 0 in case of success, non-zero otherwise
3250+ * Return:
3251+ * * string size on success.
3252+ * * -ENOMEM: on allocation failure
3253+ * * -EINVAL: on a wrong parameter
32293254 */
3230−int ufshcd_read_string_desc(struct ufs_hba *hba, int desc_index,
3231− u8 *buf, u32 size, bool ascii)
3255+int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
3256+ u8 **buf, bool ascii)
32323257 {
3233− int err = 0;
3258+ struct uc_string_id *uc_str;
3259+ u8 *str;
3260+ int ret;
32343261
3235− err = ufshcd_read_desc(hba,
3236− QUERY_DESC_IDN_STRING, desc_index, buf, size);
3262+ if (!buf)
3263+ return -EINVAL;
32373264
3238− if (err) {
3239− dev_err(hba->dev, "%s: reading String Desc failed after %d retries. err = %d\n",
3240− __func__, QUERY_REQ_RETRIES, err);
3265+ uc_str = kzalloc(QUERY_DESC_MAX_SIZE, GFP_KERNEL);
3266+ if (!uc_str)
3267+ return -ENOMEM;
3268+
3269+ ret = ufshcd_read_desc(hba, QUERY_DESC_IDN_STRING,
3270+ desc_index, uc_str,
3271+ QUERY_DESC_MAX_SIZE);
3272+ if (ret < 0) {
3273+ dev_err(hba->dev, "Reading String Desc failed after %d retries. err = %d\n",
3274+ QUERY_REQ_RETRIES, ret);
3275+ str = NULL;
3276+ goto out;
3277+ }
3278+
3279+ if (uc_str->len <= QUERY_DESC_HDR_SIZE) {
3280+ dev_dbg(hba->dev, "String Desc is of zero length\n");
3281+ str = NULL;
3282+ ret = 0;
32413283 goto out;
32423284 }
32433285
32443286 if (ascii) {
3245− int desc_len;
3246− int ascii_len;
3287+ ssize_t ascii_len;
32473288 int i;
3248− char *buff_ascii;
3249−
3250− desc_len = buf[0];
32513289 /* remove header and divide by 2 to move from UTF16 to UTF8 */
3252− ascii_len = (desc_len - QUERY_DESC_HDR_SIZE) / 2 + 1;
3253− if (size < ascii_len + QUERY_DESC_HDR_SIZE) {
3254− dev_err(hba->dev, "%s: buffer allocated size is too small\n",
3255− __func__);
3256− err = -ENOMEM;
3257− goto out;
3258− }
3259−
3260− buff_ascii = kmalloc(ascii_len, GFP_KERNEL);
3261− if (!buff_ascii) {
3262− err = -ENOMEM;
3290+ ascii_len = (uc_str->len - QUERY_DESC_HDR_SIZE) / 2 + 1;
3291+ str = kzalloc(ascii_len, GFP_KERNEL);
3292+ if (!str) {
3293+ ret = -ENOMEM;
32633294 goto out;
32643295 }
32653296
@@ -3267,22 +3298,28 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, int desc_index, · 1 unmodified line
32673298 * the descriptor contains string in UTF16 format
32683299 * we need to convert to utf-8 so it can be displayed
32693300 */
3270− utf16s_to_utf8s((wchar_t *)&buf[QUERY_DESC_HDR_SIZE],
3271− desc_len - QUERY_DESC_HDR_SIZE,
3272− UTF16_BIG_ENDIAN, buff_ascii, ascii_len);
3301+ ret = utf16s_to_utf8s(uc_str->uc,
3302+ uc_str->len - QUERY_DESC_HDR_SIZE,
3303+ UTF16_BIG_ENDIAN, str, ascii_len);
32733304
32743305 /* replace non-printable or non-ASCII characters with spaces */
3275− for (i = 0; i < ascii_len; i++)
3276− ufshcd_remove_non_printable(&buff_ascii[i]);
3306+ for (i = 0; i < ret; i++)
3307+ str[i] = ufshcd_remove_non_printable(str[i]);
32773308
3278− memset(buf + QUERY_DESC_HDR_SIZE, 0,
3279− size - QUERY_DESC_HDR_SIZE);
3280− memcpy(buf + QUERY_DESC_HDR_SIZE, buff_ascii, ascii_len);
3281− buf[QUERY_DESC_LENGTH_OFFSET] = ascii_len + QUERY_DESC_HDR_SIZE;
3282− kfree(buff_ascii);
3309+ str[ret++] = '\0';
3310+
3311+ } else {
3312+ str = kmemdup(uc_str, uc_str->len, GFP_KERNEL);
3313+ if (!str) {
3314+ ret = -ENOMEM;
3315+ goto out;
3316+ }
3317+ ret = uc_str->len;
32833318 }
32843319 out:
3285− return err;
3320+ *buf = str;
3321+ kfree(uc_str);
3322+ return ret;
32863323 }
32873324
32883325 /**
@@ -4214,12 +4251,6 @@ static int ufshcd_hba_execute_hce(struct ufs_hba *hba) · 925 unmodified lines
42144251 {
42154252 int retry;
42164253
4217− /*
4218− * msleep of 1 and 5 used in this function might result in msleep(20),
4219− * but it was necessary to send the UFS FPGA to reset mode during
4220− * development and testing of this driver. msleep can be changed to
4221− * mdelay and retry count can be reduced based on the controller.
4222− */
42234254 if (!ufshcd_is_hba_active(hba))
42244255 /* change controller state to "reset state" */
42254256 ufshcd_hba_stop(hba, true);
@@ -4242,7 +4273,7 @@ static int ufshcd_hba_execute_hce(struct ufs_hba *hba) · 16 unmodified lines
42424273 * instruction might be read back.
42434274 * This delay can be changed based on the controller.
42444275 */
4245− msleep(1);
4276+ usleep_range(1000, 1100);
42464277
42474278 /* wait for the host controller to complete initialization */
42484279 retry = 10;
@@ -4254,7 +4285,7 @@ static int ufshcd_hba_execute_hce(struct ufs_hba *hba) · 5 unmodified lines
42544285 "Controller enable failed\n");
42554286 return -EIO;
42564287 }
4257− msleep(5);
4288+ usleep_range(5000, 5100);
42584289 }
42594290
42604291 /* enable UIC related interrupts */
@@ -4326,6 +4357,14 @@ static inline int ufshcd_disable_device_tx_lcc(struct ufs_hba *hba) · 65 unmodified lines
43264357 return ufshcd_disable_tx_lcc(hba, true);
43274358 }
43284359
4360+static void ufshcd_update_reg_hist(struct ufs_err_reg_hist *reg_hist,
4361+ u32 reg)
4362+{
4363+ reg_hist->reg[reg_hist->pos] = reg;
4364+ reg_hist->tstamp[reg_hist->pos] = ktime_get();
4365+ reg_hist->pos = (reg_hist->pos + 1) % UFS_ERR_REG_HIST_LENGTH;
4366+}
4367+
43294368 /**
43304369 * ufshcd_link_startup - Initialize unipro link startup
43314370 * @hba: per adapter instance
@@ -4353,6 +4392,8 @@ link_startup: · 21 unmodified lines
43534392
43544393 /* check if device is detected by inter-connect layer */
43554394 if (!ret && !ufshcd_is_device_present(hba)) {
4395+ ufshcd_update_reg_hist(&hba->ufs_stats.link_startup_err,
4396+ 0);
43564397 dev_err(hba->dev, "%s: Device not present\n", __func__);
43574398 ret = -ENXIO;
43584399 goto out;
@@ -4363,13 +4404,19 @@ link_startup: · 4 unmodified lines
43634404 * but we can't be sure if the link is up until link startup
43644405 * succeeds. So reset the local Uni-Pro and try again.
43654406 */
4366− if (ret && ufshcd_hba_enable(hba))
4407+ if (ret && ufshcd_hba_enable(hba)) {
4408+ ufshcd_update_reg_hist(&hba->ufs_stats.link_startup_err,
4409+ (u32)ret);
43674410 goto out;
4411+ }
43684412 } while (ret && retries--);
43694413
4370− if (ret)
4414+ if (ret) {
43714415 /* failed to get the link up... retire */
4416+ ufshcd_update_reg_hist(&hba->ufs_stats.link_startup_err,
4417+ (u32)ret);
43724418 goto out;
4419+ }
43734420
43744421 if (link_startup_again) {
43754422 link_startup_again = false;
@@ -5345,14 +5392,6 @@ out: · 969 unmodified lines
53455392 pm_runtime_put_sync(hba->dev);
53465393 }
53475394
5348−static void ufshcd_update_uic_reg_hist(struct ufs_uic_err_reg_hist *reg_hist,
5349− u32 reg)
5350−{
5351− reg_hist->reg[reg_hist->pos] = reg;
5352− reg_hist->tstamp[reg_hist->pos] = ktime_get();
5353− reg_hist->pos = (reg_hist->pos + 1) % UIC_ERR_REG_HIST_LENGTH;
5354−}
5355−
53565395 /**
53575396 * ufshcd_update_uic_error - check and set fatal UIC error flags.
53585397 * @hba: per-adapter instance
@@ -5371,13 +5410,13 @@ static void ufshcd_update_uic_error(struct ufs_hba *hba) · 12 unmodified lines
53715410 * must be checked but this error is handled separately.
53725411 */
53735412 dev_dbg(hba->dev, "%s: UIC Lane error reported\n", __func__);
5374− ufshcd_update_uic_reg_hist(&hba->ufs_stats.pa_err, reg);
5413+ ufshcd_update_reg_hist(&hba->ufs_stats.pa_err, reg);
53755414 }
53765415
53775416 /* PA_INIT_ERROR is fatal and needs UIC reset */
53785417 reg = ufshcd_readl(hba, REG_UIC_ERROR_CODE_DATA_LINK_LAYER);
53795418 if (reg)
5380− ufshcd_update_uic_reg_hist(&hba->ufs_stats.dl_err, reg);
5419+ ufshcd_update_reg_hist(&hba->ufs_stats.dl_err, reg);
53815420
53825421 if (reg & UIC_DATA_LINK_LAYER_ERROR_PA_INIT)
53835422 hba->uic_error |= UFSHCD_UIC_DL_PA_INIT_ERROR;
@@ -5393,19 +5432,19 @@ static void ufshcd_update_uic_error(struct ufs_hba *hba) · 9 unmodified lines
53935432 /* UIC NL/TL/DME errors needs software retry */
53945433 reg = ufshcd_readl(hba, REG_UIC_ERROR_CODE_NETWORK_LAYER);
53955434 if (reg) {
5396− ufshcd_update_uic_reg_hist(&hba->ufs_stats.nl_err, reg);
5435+ ufshcd_update_reg_hist(&hba->ufs_stats.nl_err, reg);
53975436 hba->uic_error |= UFSHCD_UIC_NL_ERROR;
53985437 }
53995438
54005439 reg = ufshcd_readl(hba, REG_UIC_ERROR_CODE_TRANSPORT_LAYER);
54015440 if (reg) {
5402− ufshcd_update_uic_reg_hist(&hba->ufs_stats.tl_err, reg);
5441+ ufshcd_update_reg_hist(&hba->ufs_stats.tl_err, reg);
54035442 hba->uic_error |= UFSHCD_UIC_TL_ERROR;
54045443 }
54055444
54065445 reg = ufshcd_readl(hba, REG_UIC_ERROR_CODE_DME);
54075446 if (reg) {
5408− ufshcd_update_uic_reg_hist(&hba->ufs_stats.dme_err, reg);
5447+ ufshcd_update_reg_hist(&hba->ufs_stats.dme_err, reg);
54095448 hba->uic_error |= UFSHCD_UIC_DME_ERROR;
54105449 }
54115450
@@ -5438,8 +5477,10 @@ static void ufshcd_check_errors(struct ufs_hba *hba) · 26 unmodified lines
54385477 {
54395478 bool queue_eh_work = false;
54405479
5441− if (hba->errors & INT_FATAL_ERRORS)
5480+ if (hba->errors & INT_FATAL_ERRORS) {
5481+ ufshcd_update_reg_hist(&hba->ufs_stats.fatal_err, hba->errors);
54425482 queue_eh_work = true;
5483+ }
54435484
54445485 if (hba->errors & UIC_ERROR) {
54455486 hba->uic_error = 0;
@@ -5454,6 +5495,8 @@ static void ufshcd_check_errors(struct ufs_hba *hba) · 8 unmodified lines
54545495 __func__, (hba->errors & UIC_HIBERNATE_ENTER) ?
54555496 "Enter" : "Exit",
54565497 hba->errors, ufshcd_get_upmcrs(hba));
5498+ ufshcd_update_reg_hist(&hba->ufs_stats.auto_hibern8_err,
5499+ hba->errors);
54575500 queue_eh_work = true;
54585501 }
54595502
@@ -5652,13 +5695,12 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba, · 192 unmodified lines
56525695 memcpy(treq, hba->utmrdl_base_addr + free_slot, sizeof(*treq));
56535696
56545697 ufshcd_add_tm_upiu_trace(hba, task_tag, "tm_complete");
5655−
5656− spin_lock_irqsave(hba->host->host_lock, flags);
5657− __clear_bit(free_slot, &hba->outstanding_tasks);
5658− spin_unlock_irqrestore(hba->host->host_lock, flags);
5659−
56605698 }
56615699
5700+ spin_lock_irqsave(hba->host->host_lock, flags);
5701+ __clear_bit(free_slot, &hba->outstanding_tasks);
5702+ spin_unlock_irqrestore(hba->host->host_lock, flags);
5703+
56625704 clear_bit(free_slot, &hba->tm_condition);
56635705 ufshcd_put_tm_slot(hba, free_slot);
56645706 wake_up(&hba->tm_tag_wq);
@@ -5941,6 +5983,7 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd) · 276 unmodified lines
59415983
59425984 out:
59435985 hba->req_abort_count = 0;
5986+ ufshcd_update_reg_hist(&hba->ufs_stats.dev_reset, (u32)err);
59445987 if (!err) {
59455988 err = SUCCESS;
59465989 } else {
@@ -6034,6 +6077,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) · 87 unmodified lines
60346077 */
60356078 scsi_print_command(hba->lrb[tag].cmd);
60366079 if (!hba->req_abort_count) {
6080+ ufshcd_update_reg_hist(&hba->ufs_stats.task_abort, 0);
60376081 ufshcd_print_host_regs(hba);
60386082 ufshcd_print_host_state(hba);
60396083 ufshcd_print_pwr_info(hba);
@@ -6169,7 +6213,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) · 129 unmodified lines
61696213 out:
61706214 if (err)
61716215 dev_err(hba->dev, "%s: Host init failed %d\n", __func__, err);
6172−
6216+ ufshcd_update_reg_hist(&hba->ufs_stats.host_reset, (u32)err);
61736217 return err;
61746218 }
61756219
@@ -6189,6 +6233,9 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba) · 13 unmodified lines
61896233 int retries = MAX_HOST_RESET_RETRIES;
61906234
61916235 do {
6236+ /* Reset the attached device */
6237+ ufshcd_vops_device_reset(hba);
6238+
61926239 err = ufshcd_host_reset_and_restore(hba);
61936240 } while (err && --retries);
61946241
@@ -6453,6 +6500,9 @@ static int ufs_get_device_desc(struct ufs_hba *hba, · 258 unmodified lines
64536500 u8 model_index;
64546501 u8 *desc_buf;
64556502
6503+ if (!dev_desc)
6504+ return -EINVAL;
6505+
64566506 buff_len = max_t(size_t, hba->desc_size.dev_desc,
64576507 QUERY_DESC_MAX_SIZE + 1);
64586508 desc_buf = kmalloc(buff_len, GFP_KERNEL);
@@ -6476,31 +6526,31 @@ static int ufs_get_device_desc(struct ufs_hba *hba, · 17 unmodified lines
64766526 desc_buf[DEVICE_DESC_PARAM_MANF_ID + 1];
64776527
64786528 model_index = desc_buf[DEVICE_DESC_PARAM_PRDCT_NAME];
6479−
6480− /* Zero-pad entire buffer for string termination. */
6481− memset(desc_buf, 0, buff_len);
6482−
6483− err = ufshcd_read_string_desc(hba, model_index, desc_buf,
6484− QUERY_DESC_MAX_SIZE, true/*ASCII*/);
6485− if (err) {
6529+ err = ufshcd_read_string_desc(hba, model_index,
6530+ &dev_desc->model, SD_ASCII_STD);
6531+ if (err < 0) {
64866532 dev_err(hba->dev, "%s: Failed reading Product Name. err = %d\n",
64876533 __func__, err);
64886534 goto out;
64896535 }
64906536
6491− desc_buf[QUERY_DESC_MAX_SIZE] = '\0';
6492− strlcpy(dev_desc->model, (desc_buf + QUERY_DESC_HDR_SIZE),
6493− min_t(u8, desc_buf[QUERY_DESC_LENGTH_OFFSET],
6494− MAX_MODEL_LEN));
6495−
6496− /* Null terminate the model string */
6497− dev_desc->model[MAX_MODEL_LEN] = '\0';
6537+ /*
6538+ * ufshcd_read_string_desc returns size of the string
6539+ * reset the error value
6540+ */
6541+ err = 0;
64986542
64996543 out:
65006544 kfree(desc_buf);
65016545 return err;
65026546 }
65036547
6548+static void ufs_put_device_desc(struct ufs_dev_desc *dev_desc)
6549+{
6550+ kfree(dev_desc->model);
6551+ dev_desc->model = NULL;
6552+}
6553+
65046554 static void ufs_fixup_device_setup(struct ufs_hba *hba,
65056555 struct ufs_dev_desc *dev_desc)
65066556 {
@@ -6509,8 +6559,9 @@ static void ufs_fixup_device_setup(struct ufs_hba *hba, · 2 unmodified lines
65096559 for (f = ufs_fixups; f->quirk; f++) {
65106560 if ((f->card.wmanufacturerid == dev_desc->wmanufacturerid ||
65116561 f->card.wmanufacturerid == UFS_ANY_VENDOR) &&
6512− (STR_PRFX_EQUAL(f->card.model, dev_desc->model) ||
6513− !strcmp(f->card.model, UFS_ANY_MODEL)))
6562+ ((dev_desc->model &&
6563+ STR_PRFX_EQUAL(f->card.model, dev_desc->model)) ||
6564+ !strcmp(f->card.model, UFS_ANY_MODEL)))
65146565 hba->dev_quirks |= f->quirk;
65156566 }
65166567 }
@@ -6681,17 +6732,8 @@ static void ufshcd_tune_unipro_params(struct ufs_hba *hba) · 164 unmodified lines
66816732
66826733 static void ufshcd_clear_dbg_ufs_stats(struct ufs_hba *hba)
66836734 {
6684− int err_reg_hist_size = sizeof(struct ufs_uic_err_reg_hist);
6685−
66866735 hba->ufs_stats.hibern8_exit_cnt = 0;
66876736 hba->ufs_stats.last_hibern8_exit_tstamp = ktime_set(0, 0);
6688−
6689− memset(&hba->ufs_stats.pa_err, 0, err_reg_hist_size);
6690− memset(&hba->ufs_stats.dl_err, 0, err_reg_hist_size);
6691− memset(&hba->ufs_stats.nl_err, 0, err_reg_hist_size);
6692− memset(&hba->ufs_stats.tl_err, 0, err_reg_hist_size);
6693− memset(&hba->ufs_stats.dme_err, 0, err_reg_hist_size);
6694−
66956737 hba->req_abort_count = 0;
66966738 }
66976739
@@ -6861,6 +6903,8 @@ static int ufshcd_probe_hba(struct ufs_hba *hba) · 163 unmodified lines
68616903 }
68626904
68636905 ufs_fixup_device_setup(hba, &card);
6906+ ufs_put_device_desc(&card);
6907+
68646908 ufshcd_tune_unipro_params(hba);
68656909
68666910 /* UFS device is also active now */
@@ -7823,6 +7867,8 @@ enable_gating: · 956 unmodified lines
78237867 ufshcd_release(hba);
78247868 out:
78257869 hba->pm_op_in_progress = 0;
7870+ if (ret)
7871+ ufshcd_update_reg_hist(&hba->ufs_stats.suspend_err, (u32)ret);
78267872 return ret;
78277873 }
78287874
@@ -7925,6 +7971,8 @@ disable_irq_and_vops_clks: · 96 unmodified lines
79257971 ufshcd_setup_clocks(hba, false);
79267972 out:
79277973 hba->pm_op_in_progress = 0;
7974+ if (ret)
7975+ ufshcd_update_reg_hist(&hba->ufs_stats.resume_err, (u32)ret);
79287976 return ret;
79297977 }
79307978
@@ -8324,6 +8372,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) · 393 unmodified lines
83248372 goto exit_gating;
83258373 }
83268374
8375+ /* Reset the attached device */
8376+ ufshcd_vops_device_reset(hba);
8377+
83278378 /* Host controller enable */
83288379 err = ufshcd_hba_enable(hba);
83298380 if (err) {
drivers/scsi/ufs/ufshcd.h+45−12
@@ -298,6 +298,7 @@ struct ufs_pwr_mode_info { · 297 unmodified lines
298298 * @resume: called during host controller PM callback
299299 * @dbg_register_dump: used to dump controller debug information
300300 * @phy_initialization: used to initialize phys
301+ * @device_reset: called to issue a reset pulse on the UFS device
301302 */
302303 struct ufs_hba_variant_ops {
303304 const char *name;
@@ -326,6 +327,7 @@ struct ufs_hba_variant_ops { · 22 unmodified lines
326327 int (*resume)(struct ufs_hba *, enum ufs_pm_op);
327328 void (*dbg_register_dump)(struct ufs_hba *hba);
328329 int (*phy_initialization)(struct ufs_hba *);
330+ void (*device_reset)(struct ufs_hba *hba);
329331 };
330332
331333 /* clock gating state */
@@ -412,17 +414,17 @@ struct ufs_init_prefetch { · 80 unmodified lines
412414 u32 icc_level;
413415 };
414416
415−#define UIC_ERR_REG_HIST_LENGTH 8
417+#define UFS_ERR_REG_HIST_LENGTH 8
416418 /**
417− * struct ufs_uic_err_reg_hist - keeps history of uic errors
419+ * struct ufs_err_reg_hist - keeps history of errors
418420 * @pos: index to indicate cyclic buffer position
419421 * @reg: cyclic buffer for registers value
420422 * @tstamp: cyclic buffer for time stamp
421423 */
422−struct ufs_uic_err_reg_hist {
424+struct ufs_err_reg_hist {
423425 int pos;
424− u32 reg[UIC_ERR_REG_HIST_LENGTH];
425− ktime_t tstamp[UIC_ERR_REG_HIST_LENGTH];
426+ u32 reg[UFS_ERR_REG_HIST_LENGTH];
427+ ktime_t tstamp[UFS_ERR_REG_HIST_LENGTH];
426428 };
427429
428430 /**
@@ -436,15 +438,37 @@ struct ufs_uic_err_reg_hist { · 7 unmodified lines
436438 * @nl_err: tracks nl-uic errors
437439 * @tl_err: tracks tl-uic errors
438440 * @dme_err: tracks dme errors
441+ * @auto_hibern8_err: tracks auto-hibernate errors
442+ * @fatal_err: tracks fatal errors
443+ * @linkup_err: tracks link-startup errors
444+ * @resume_err: tracks resume errors
445+ * @suspend_err: tracks suspend errors
446+ * @dev_reset: tracks device reset events
447+ * @host_reset: tracks host reset events
448+ * @tsk_abort: tracks task abort events
439449 */
440450 struct ufs_stats {
441451 u32 hibern8_exit_cnt;
442452 ktime_t last_hibern8_exit_tstamp;
443− struct ufs_uic_err_reg_hist pa_err;
444− struct ufs_uic_err_reg_hist dl_err;
445− struct ufs_uic_err_reg_hist nl_err;
446− struct ufs_uic_err_reg_hist tl_err;
447− struct ufs_uic_err_reg_hist dme_err;
453+
454+ /* uic specific errors */
455+ struct ufs_err_reg_hist pa_err;
456+ struct ufs_err_reg_hist dl_err;
457+ struct ufs_err_reg_hist nl_err;
458+ struct ufs_err_reg_hist tl_err;
459+ struct ufs_err_reg_hist dme_err;
460+
461+ /* fatal errors */
462+ struct ufs_err_reg_hist auto_hibern8_err;
463+ struct ufs_err_reg_hist fatal_err;
464+ struct ufs_err_reg_hist link_startup_err;
465+ struct ufs_err_reg_hist resume_err;
466+ struct ufs_err_reg_hist suspend_err;
467+
468+ /* abnormal events */
469+ struct ufs_err_reg_hist dev_reset;
470+ struct ufs_err_reg_hist host_reset;
471+ struct ufs_err_reg_hist task_abort;
448472 };
449473
450474 /**
@@ -891,8 +915,11 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode, · 440 unmodified lines
891915 enum attr_idn idn, u8 index, u8 selector, u32 *attr_val);
892916 int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
893917 enum flag_idn idn, bool *flag_res);
894−int ufshcd_read_string_desc(struct ufs_hba *hba, int desc_index,
895− u8 *buf, u32 size, bool ascii);
918+
919+#define SD_ASCII_STD true
920+#define SD_RAW false
921+int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
922+ u8 **buf, bool ascii);
896923
897924 int ufshcd_hold(struct ufs_hba *hba, bool async);
898925 void ufshcd_release(struct ufs_hba *hba);
@@ -1045,6 +1072,12 @@ static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba) · 146 unmodified lines
10451072 hba->vops->dbg_register_dump(hba);
10461073 }
10471074
1075+static inline void ufshcd_vops_device_reset(struct ufs_hba *hba)
1076+{
1077+ if (hba->vops && hba->vops->device_reset)
1078+ hba->vops->device_reset(hba);
1079+}
1080+
10481081 extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];
10491082
10501083 /*
drivers/scsi/virtio_scsi.c+73−15
@@ -30,6 +30,8 @@ · 29 unmodified lines
3030 #include <linux/seqlock.h>
3131 #include <linux/blk-mq-virtio.h>
3232
33+#include "sd.h"
34+
3335 #define VIRTIO_SCSI_MEMPOOL_SZ 64
3436 #define VIRTIO_SCSI_EVENT_LEN 8
3537 #define VIRTIO_SCSI_VQ_BASE 2
@@ -324,6 +326,36 @@ static void virtscsi_handle_param_change(struct virtio_scsi *vscsi, · 288 unmodified lines
324326 scsi_device_put(sdev);
325327 }
326328
329+static void virtscsi_rescan_hotunplug(struct virtio_scsi *vscsi)
330+{
331+ struct scsi_device *sdev;
332+ struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev);
333+ unsigned char scsi_cmd[MAX_COMMAND_SIZE];
334+ int result, inquiry_len, inq_result_len = 256;
335+ char *inq_result = kmalloc(inq_result_len, GFP_KERNEL);
336+
337+ shost_for_each_device(sdev, shost) {
338+ inquiry_len = sdev->inquiry_len ? sdev->inquiry_len : 36;
339+
340+ memset(scsi_cmd, 0, sizeof(scsi_cmd));
341+ scsi_cmd[0] = INQUIRY;
342+ scsi_cmd[4] = (unsigned char) inquiry_len;
343+
344+ memset(inq_result, 0, inq_result_len);
345+
346+ result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE,
347+ inq_result, inquiry_len, NULL,
348+ SD_TIMEOUT, SD_MAX_RETRIES, NULL);
349+
350+ if (result == 0 && inq_result[0] >> 5) {
351+ /* PQ indicates the LUN is not attached */
352+ scsi_remove_device(sdev);
353+ }
354+ }
355+
356+ kfree(inq_result);
357+}
358+
327359 static void virtscsi_handle_event(struct work_struct *work)
328360 {
329361 struct virtio_scsi_event_node *event_node =
@@ -335,6 +367,7 @@ static void virtscsi_handle_event(struct work_struct *work) · 5 unmodified lines
335367 cpu_to_virtio32(vscsi->vdev, VIRTIO_SCSI_T_EVENTS_MISSED)) {
336368 event->event &= ~cpu_to_virtio32(vscsi->vdev,
337369 VIRTIO_SCSI_T_EVENTS_MISSED);
370+ virtscsi_rescan_hotunplug(vscsi);
338371 scsi_scan_host(virtio_scsi_host(vscsi->vdev));
339372 }
340373
@@ -369,14 +402,7 @@ static void virtscsi_event_done(struct virtqueue *vq) · 28 unmodified lines
369402 virtscsi_vq_done(vscsi, &vscsi->event_vq, virtscsi_complete_event);
370403 };
371404
372−/**
373− * virtscsi_add_cmd - add a virtio_scsi_cmd to a virtqueue
374− * @vq : the struct virtqueue we're talking about
375− * @cmd : command structure
376− * @req_size : size of the request buffer
377− * @resp_size : size of the response buffer
378− */
379−static int virtscsi_add_cmd(struct virtqueue *vq,
405+static int __virtscsi_add_cmd(struct virtqueue *vq,
380406 struct virtio_scsi_cmd *cmd,
381407 size_t req_size, size_t resp_size)
382408 {
@@ -421,17 +447,39 @@ static int virtscsi_add_cmd(struct virtqueue *vq, · 38 unmodified lines
421447 return virtqueue_add_sgs(vq, sgs, out_num, in_num, cmd, GFP_ATOMIC);
422448 }
423449
424−static int virtscsi_kick_cmd(struct virtio_scsi_vq *vq,
450+static void virtscsi_kick_vq(struct virtio_scsi_vq *vq)
451+{
452+ bool needs_kick;
453+ unsigned long flags;
454+
455+ spin_lock_irqsave(&vq->vq_lock, flags);
456+ needs_kick = virtqueue_kick_prepare(vq->vq);
457+ spin_unlock_irqrestore(&vq->vq_lock, flags);
458+
459+ if (needs_kick)
460+ virtqueue_notify(vq->vq);
461+}
462+
463+/**
464+ * virtscsi_add_cmd - add a virtio_scsi_cmd to a virtqueue, optionally kick it
465+ * @vq : the struct virtqueue we're talking about
466+ * @cmd : command structure
467+ * @req_size : size of the request buffer
468+ * @resp_size : size of the response buffer
469+ * @kick : whether to kick the virtqueue immediately
470+ */
471+static int virtscsi_add_cmd(struct virtio_scsi_vq *vq,
425472 struct virtio_scsi_cmd *cmd,
426− size_t req_size, size_t resp_size)
473+ size_t req_size, size_t resp_size,
474+ bool kick)
427475 {
428476 unsigned long flags;
429477 int err;
430478 bool needs_kick = false;
431479
432480 spin_lock_irqsave(&vq->vq_lock, flags);
433− err = virtscsi_add_cmd(vq->vq, cmd, req_size, resp_size);
434− if (!err)
481+ err = __virtscsi_add_cmd(vq->vq, cmd, req_size, resp_size);
482+ if (!err && kick)
435483 needs_kick = virtqueue_kick_prepare(vq->vq);
436484
437485 spin_unlock_irqrestore(&vq->vq_lock, flags);
@@ -496,6 +544,7 @@ static int virtscsi_queuecommand(struct Scsi_Host *shost, · 58 unmodified lines
496544 struct virtio_scsi *vscsi = shost_priv(shost);
497545 struct virtio_scsi_vq *req_vq = virtscsi_pick_vq_mq(vscsi, sc);
498546 struct virtio_scsi_cmd *cmd = scsi_cmd_priv(sc);
547+ bool kick;
499548 unsigned long flags;
500549 int req_size;
501550 int ret;
@@ -525,7 +574,8 @@ static int virtscsi_queuecommand(struct Scsi_Host *shost, · 23 unmodified lines
525574 req_size = sizeof(cmd->req.cmd);
526575 }
527576
528− ret = virtscsi_kick_cmd(req_vq, cmd, req_size, sizeof(cmd->resp.cmd));
577+ kick = (sc->flags & SCMD_LAST) != 0;
578+ ret = virtscsi_add_cmd(req_vq, cmd, req_size, sizeof(cmd->resp.cmd), kick);
529579 if (ret == -EIO) {
530580 cmd->resp.cmd.response = VIRTIO_SCSI_S_BAD_TARGET;
531581 spin_lock_irqsave(&req_vq->vq_lock, flags);
@@ -543,8 +593,8 @@ static int virtscsi_tmf(struct virtio_scsi *vscsi, struct virtio_scsi_cmd *cmd) · 11 unmodified lines
543593 int ret = FAILED;
544594
545595 cmd->comp = &comp;
546− if (virtscsi_kick_cmd(&vscsi->ctrl_vq, cmd,
547− sizeof cmd->req.tmf, sizeof cmd->resp.tmf) < 0)
596+ if (virtscsi_add_cmd(&vscsi->ctrl_vq, cmd,
597+ sizeof cmd->req.tmf, sizeof cmd->resp.tmf, true) < 0)
548598 goto out;
549599
550600 wait_for_completion(&comp);
@@ -658,6 +708,13 @@ static int virtscsi_map_queues(struct Scsi_Host *shost) · 107 unmodified lines
658708 return blk_mq_virtio_map_queues(qmap, vscsi->vdev, 2);
659709 }
660710
711+static void virtscsi_commit_rqs(struct Scsi_Host *shost, u16 hwq)
712+{
713+ struct virtio_scsi *vscsi = shost_priv(shost);
714+
715+ virtscsi_kick_vq(&vscsi->req_vqs[hwq]);
716+}
717+
661718 /*
662719 * The host guarantees to respond to each command, although I/O
663720 * latencies might be higher than on bare metal. Reset the timer
@@ -675,6 +732,7 @@ static struct scsi_host_template virtscsi_host_template = { · 11 unmodified lines
675732 .this_id = -1,
676733 .cmd_size = sizeof(struct virtio_scsi_cmd),
677734 .queuecommand = virtscsi_queuecommand,
735+ .commit_rqs = virtscsi_commit_rqs,
678736 .change_queue_depth = virtscsi_change_queue_depth,
679737 .eh_abort_handler = virtscsi_abort,
680738 .eh_device_reset_handler = virtscsi_device_reset,
drivers/scsi/wd33c93.c+1−0
@@ -1854,6 +1854,7 @@ round_4(unsigned int x) · 1853 unmodified lines
18541854 case 1: --x;
18551855 break;
18561856 case 2: ++x;
1857+ /* fall through */
18571858 case 3: ++x;
18581859 }
18591860 return x;
drivers/target/target_core_user.c+20−0
@@ -1712,6 +1712,24 @@ static int tcmu_init_genl_cmd_reply(struct tcmu_dev *udev, int cmd) · 1711 unmodified lines
17121712 return 0;
17131713 }
17141714
1715+static void tcmu_destroy_genl_cmd_reply(struct tcmu_dev *udev)
1716+{
1717+ struct tcmu_nl_cmd *nl_cmd = &udev->curr_nl_cmd;
1718+
1719+ if (!tcmu_kern_cmd_reply_supported)
1720+ return;
1721+
1722+ if (udev->nl_reply_supported <= 0)
1723+ return;
1724+
1725+ mutex_lock(&tcmu_nl_cmd_mutex);
1726+
1727+ list_del(&nl_cmd->nl_list);
1728+ memset(nl_cmd, 0, sizeof(*nl_cmd));
1729+
1730+ mutex_unlock(&tcmu_nl_cmd_mutex);
1731+}
1732+
17151733 static int tcmu_wait_genl_cmd_reply(struct tcmu_dev *udev)
17161734 {
17171735 struct tcmu_nl_cmd *nl_cmd = &udev->curr_nl_cmd;
@@ -1792,6 +1810,8 @@ static int tcmu_netlink_event_send(struct tcmu_dev *udev, · 74 unmodified lines
17921810 if (ret == 0 ||
17931811 (ret == -ESRCH && cmd == TCMU_CMD_ADDED_DEVICE))
17941812 return tcmu_wait_genl_cmd_reply(udev);
1813+ else
1814+ tcmu_destroy_genl_cmd_reply(udev);
17951815
17961816 return ret;
17971817 }
include/linux/nvme-fc-driver.h+2−0
@@ -6,6 +6,8 @@ · 5 unmodified lines
66 #ifndef _NVME_FC_DRIVER_H
77 #define _NVME_FC_DRIVER_H 1
88
9+#include <linux/scatterlist.h>
10+
911
1012 /*
1113 * ********************** LLDD FC-NVME Host API ********************
include/scsi/scsi_cmnd.h+1−0
@@ -57,6 +57,7 @@ struct scsi_pointer { · 56 unmodified lines
5757 #define SCMD_TAGGED (1 << 0)
5858 #define SCMD_UNCHECKED_ISA_DMA (1 << 1)
5959 #define SCMD_INITIALIZED (1 << 2)
60+#define SCMD_LAST (1 << 3)
6061 /* flags preserved across unprep / reprep */
6162 #define SCMD_PRESERVED_FLAGS (SCMD_UNCHECKED_ISA_DMA | SCMD_INITIALIZED)
6263
include/scsi/scsi_dbg.h+0−2
@@ -6,8 +6,6 @@ struct scsi_cmnd; · 5 unmodified lines
66 struct scsi_device;
77 struct scsi_sense_hdr;
88
9−#define SCSI_LOG_BUFSIZE 128
10−
119 extern void scsi_print_command(struct scsi_cmnd *);
1210 extern size_t __scsi_format_command(char *, size_t,
1311 const unsigned char *, size_t);
include/scsi/scsi_host.h+14−2
@@ -80,8 +80,10 @@ struct scsi_host_template { · 79 unmodified lines
8080 * command block to the LLDD. When the driver finished
8181 * processing the command the done callback is invoked.
8282 *
83− * If queuecommand returns 0, then the HBA has accepted the
84− * command. The done() function must be called on the command
83+ * If queuecommand returns 0, then the driver has accepted the
84+ * command. It must also push it to the HBA if the scsi_cmnd
85+ * flag SCMD_LAST is set, or if the driver does not implement
86+ * commit_rqs. The done() function must be called on the command
8587 * when the driver has finished with it. (you may call done on the
8688 * command before queuecommand returns, but in this case you
8789 * *must* return 0 from queuecommand).
@@ -109,6 +111,16 @@ struct scsi_host_template { · 21 unmodified lines
109111 */
110112 int (* queuecommand)(struct Scsi_Host *, struct scsi_cmnd *);
111113
114+ /*
115+ * The commit_rqs function is used to trigger a hardware
116+ * doorbell after some requests have been queued with
117+ * queuecommand, when an error is encountered before sending
118+ * the request with SCMD_LAST set.
119+ *
120+ * STATUS: OPTIONAL
121+ */
122+ void (*commit_rqs)(struct Scsi_Host *, u16);
123+
112124 /*
113125 * This is an error handling strategy routine. You don't need to
114126 * define one of these if you don't want to - there is a default
include/uapi/scsi/scsi_bsg_fc.h+28−26
@@ -8,6 +8,8 @@ · 7 unmodified lines
88 #ifndef SCSI_BSG_FC_H
99 #define SCSI_BSG_FC_H
1010
11+#include <linux/types.h>
12+
1113 /*
1214 * This file intended to be included by both kernel and user space
1315 */
@@ -66,10 +68,10 @@ · 52 unmodified lines
6668 * with the transport upon completion of the login.
6769 */
6870 struct fc_bsg_host_add_rport {
69− uint8_t reserved;
71+ __u8 reserved;
7072
7173 /* FC Address Identier of the remote port to login to */
72− uint8_t port_id[3];
74+ __u8 port_id[3];
7375 };
7476
7577 /* Response:
@@ -87,10 +89,10 @@ struct fc_bsg_host_add_rport { · 11 unmodified lines
8789 * remain logged in with the remote port.
8890 */
8991 struct fc_bsg_host_del_rport {
90− uint8_t reserved;
92+ __u8 reserved;
9193
9294 /* FC Address Identier of the remote port to logout of */
93− uint8_t port_id[3];
95+ __u8 port_id[3];
9496 };
9597
9698 /* Response:
@@ -111,10 +113,10 @@ struct fc_bsg_host_els { · 14 unmodified lines
111113 * ELS Command Code being sent (must be the same as byte 0
112114 * of the payload)
113115 */
114− uint8_t command_code;
116+ __u8 command_code;
115117
116118 /* FC Address Identier of the remote port to send the ELS to */
117− uint8_t port_id[3];
119+ __u8 port_id[3];
118120 };
119121
120122 /* Response:
@@ -151,14 +153,14 @@ struct fc_bsg_ctels_reply { · 30 unmodified lines
151153 * Note: x_RJT/BSY status will indicae that the rjt_data field
152154 * is valid and contains the reason/explanation values.
153155 */
154− uint32_t status; /* See FC_CTELS_STATUS_xxx */
156+ __u32 status; /* See FC_CTELS_STATUS_xxx */
155157
156158 /* valid if status is not FC_CTELS_STATUS_OK */
157159 struct {
158− uint8_t action; /* fragment_id for CT REJECT */
159− uint8_t reason_code;
160− uint8_t reason_explanation;
161− uint8_t vendor_unique;
160+ __u8 action; /* fragment_id for CT REJECT */
161+ __u8 reason_code;
162+ __u8 reason_explanation;
163+ __u8 vendor_unique;
162164 } rjt_data;
163165 };
164166
@@ -174,17 +176,17 @@ struct fc_bsg_ctels_reply { · 9 unmodified lines
174176 * and whether to tear it down after the request.
175177 */
176178 struct fc_bsg_host_ct {
177− uint8_t reserved;
179+ __u8 reserved;
178180
179181 /* FC Address Identier of the remote port to send the ELS to */
180− uint8_t port_id[3];
182+ __u8 port_id[3];
181183
182184 /*
183185 * We need words 0-2 of the generic preamble for the LLD's
184186 */
185− uint32_t preamble_word0; /* revision & IN_ID */
186− uint32_t preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
187− uint32_t preamble_word2; /* Cmd Code, Max Size */
187+ __u32 preamble_word0; /* revision & IN_ID */
188+ __u32 preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
189+ __u32 preamble_word2; /* Cmd Code, Max Size */
188190
189191 };
190192 /* Response:
@@ -204,17 +206,17 @@ struct fc_bsg_host_vendor { · 13 unmodified lines
204206 * Identifies the vendor that the message is formatted for. This
205207 * should be the recipient of the message.
206208 */
207− uint64_t vendor_id;
209+ __u64 vendor_id;
208210
209211 /* start of vendor command area */
210− uint32_t vendor_cmd[0];
212+ __u32 vendor_cmd[0];
211213 };
212214
213215 /* Response:
214216 */
215217 struct fc_bsg_host_vendor_reply {
216218 /* start of vendor response area */
217− uint32_t vendor_rsp[0];
219+ __u32 vendor_rsp[0];
218220 };
219221
220222
@@ -233,7 +235,7 @@ struct fc_bsg_rport_els { · 12 unmodified lines
233235 * ELS Command Code being sent (must be the same as
234236 * byte 0 of the payload)
235237 */
236− uint8_t els_code;
238+ __u8 els_code;
237239 };
238240
239241 /* Response:
@@ -251,9 +253,9 @@ struct fc_bsg_rport_ct { · 11 unmodified lines
251253 /*
252254 * We need words 0-2 of the generic preamble for the LLD's
253255 */
254− uint32_t preamble_word0; /* revision & IN_ID */
255− uint32_t preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
256− uint32_t preamble_word2; /* Cmd Code, Max Size */
256+ __u32 preamble_word0; /* revision & IN_ID */
257+ __u32 preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
258+ __u32 preamble_word2; /* Cmd Code, Max Size */
257259 };
258260 /* Response:
259261 *
@@ -265,7 +267,7 @@ struct fc_bsg_rport_ct { · 5 unmodified lines
265267
266268 /* request (CDB) structure of the sg_io_v4 */
267269 struct fc_bsg_request {
268− uint32_t msgcode;
270+ __u32 msgcode;
269271 union {
270272 struct fc_bsg_host_add_rport h_addrport;
271273 struct fc_bsg_host_del_rport h_delrport;
@@ -289,10 +291,10 @@ struct fc_bsg_reply { · 17 unmodified lines
289291 * msg and status fields. The per-msgcode reply structure
290292 * will contain valid data.
291293 */
292− uint32_t result;
294+ __u32 result;
293295
294296 /* If there was reply_payload, how much was recevied ? */
295− uint32_t reply_payload_rcv_len;
297+ __u32 reply_payload_rcv_len;
296298
297299 union {
298300 struct fc_bsg_host_vendor_reply vendor_reply;
include/uapi/scsi/scsi_netlink.h+10−10
@@ -26,12 +26,12 @@ · 25 unmodified lines
2626
2727 /* SCSI_TRANSPORT_MSG event message header */
2828 struct scsi_nl_hdr {
29− uint8_t version;
30− uint8_t transport;
31− uint16_t magic;
32− uint16_t msgtype;
33− uint16_t msglen;
34−} __attribute__((aligned(sizeof(uint64_t))));
29+ __u8 version;
30+ __u8 transport;
31+ __u16 magic;
32+ __u16 msgtype;
33+ __u16 msglen;
34+} __attribute__((aligned(sizeof(__u64))));
3535
3636 /* scsi_nl_hdr->version value */
3737 #define SCSI_NL_VERSION 1
@@ -75,10 +75,10 @@ struct scsi_nl_hdr { · 37 unmodified lines
7575 */
7676 struct scsi_nl_host_vendor_msg {
7777 struct scsi_nl_hdr snlh; /* must be 1st element ! */
78− uint64_t vendor_id;
79− uint16_t host_no;
80− uint16_t vmsg_datalen;
81−} __attribute__((aligned(sizeof(uint64_t))));
78+ __u64 vendor_id;
79+ __u16 host_no;
80+ __u16 vmsg_datalen;
81+} __attribute__((aligned(sizeof(__u64))));
8282
8383
8484 /*
include/uapi/scsi/scsi_netlink_fc.h+9−8
@@ -7,6 +7,7 @@ · 6 unmodified lines
77 #ifndef SCSI_NETLINK_FC_H
88 #define SCSI_NETLINK_FC_H
99
10+#include <linux/types.h>
1011 #include <scsi/scsi_netlink.h>
1112
1213 /*
@@ -43,14 +44,14 @@ · 30 unmodified lines
4344 */
4445 struct fc_nl_event {
4546 struct scsi_nl_hdr snlh; /* must be 1st element ! */
46− uint64_t seconds;
47− uint64_t vendor_id;
48− uint16_t host_no;
49− uint16_t event_datalen;
50− uint32_t event_num;
51− uint32_t event_code;
52− uint32_t event_data;
53−} __attribute__((aligned(sizeof(uint64_t))));
47+ __u64 seconds;
48+ __u64 vendor_id;
49+ __u16 host_no;
50+ __u16 event_datalen;
51+ __u32 event_num;
52+ __u32 event_code;
53+ __u32 event_data;
54+} __attribute__((aligned(sizeof(__u64))));
5455
5556
5657 #endif /* SCSI_NETLINK_FC_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t