hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/scsi/qla2xxx/qla_mid.c
....@@ -1,8 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * QLogic Fibre Channel HBA Driver
34 * Copyright (c) 2003-2014 QLogic Corporation
4
- *
5
- * See LICENSE.qla2xxx for copyright and licensing details.
65 */
76 #include "qla_def.h"
87 #include "qla_gbl.h"
....@@ -66,6 +65,7 @@
6665 uint16_t vp_id;
6766 struct qla_hw_data *ha = vha->hw;
6867 unsigned long flags = 0;
68
+ u8 i;
6969
7070 mutex_lock(&ha->vport_lock);
7171 /*
....@@ -75,8 +75,11 @@
7575 * ensures no active vp_list traversal while the vport is removed
7676 * from the queue)
7777 */
78
- wait_event_timeout(vha->vref_waitq, !atomic_read(&vha->vref_count),
79
- 10*HZ);
78
+ for (i = 0; i < 10; i++) {
79
+ if (wait_event_timeout(vha->vref_waitq,
80
+ !atomic_read(&vha->vref_count), HZ) > 0)
81
+ break;
82
+ }
8083
8184 spin_lock_irqsave(&ha->vport_slock, flags);
8285 if (atomic_read(&vha->vref_count)) {
....@@ -143,7 +146,7 @@
143146 "Marking port dead, loop_id=0x%04x : %x.\n",
144147 fcport->loop_id, fcport->vha->vp_idx);
145148
146
- qla2x00_mark_device_lost(vha, fcport, 0, 0);
149
+ qla2x00_mark_device_lost(vha, fcport, 0);
147150 qla2x00_set_fcport_state(fcport, FCS_UNCONFIGURED);
148151 }
149152 }
....@@ -163,7 +166,7 @@
163166 list_for_each_entry(fcport, &vha->vp_fcports, list)
164167 fcport->logout_on_delete = 0;
165168
166
- qla2x00_mark_all_devices_lost(vha, 0);
169
+ qla2x00_mark_all_devices_lost(vha);
167170
168171 /* Remove port id from vp target map */
169172 spin_lock_irqsave(&vha->hw->hardware_lock, flags);
....@@ -262,6 +265,9 @@
262265 spin_lock_irqsave(&ha->vport_slock, flags);
263266 list_for_each_entry(vha, &ha->vp_list, list) {
264267 if (vha->vp_idx) {
268
+ if (test_bit(VPORT_DELETE, &vha->dpc_flags))
269
+ continue;
270
+
265271 atomic_inc(&vha->vref_count);
266272 spin_unlock_irqrestore(&ha->vport_slock, flags);
267273
....@@ -300,28 +306,35 @@
300306 int
301307 qla2x00_vp_abort_isp(scsi_qla_host_t *vha)
302308 {
309
+ fc_port_t *fcport;
310
+
311
+ /*
312
+ * To exclusively reset vport, we need to log it out first.
313
+ * Note: This control_vp can fail if ISP reset is already
314
+ * issued, this is expected, as the vp would be already
315
+ * logged out due to ISP reset.
316
+ */
317
+ if (!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) {
318
+ qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL);
319
+ list_for_each_entry(fcport, &vha->vp_fcports, list)
320
+ fcport->logout_on_delete = 0;
321
+ }
322
+
303323 /*
304324 * Physical port will do most of the abort and recovery work. We can
305325 * just treat it as a loop down
306326 */
307327 if (atomic_read(&vha->loop_state) != LOOP_DOWN) {
308328 atomic_set(&vha->loop_state, LOOP_DOWN);
309
- qla2x00_mark_all_devices_lost(vha, 0);
329
+ qla2x00_mark_all_devices_lost(vha);
310330 } else {
311331 if (!atomic_read(&vha->loop_down_timer))
312332 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
313333 }
314334
315
- /*
316
- * To exclusively reset vport, we need to log it out first. Note: this
317
- * control_vp can fail if ISP reset is already issued, this is
318
- * expected, as the vp would be already logged out due to ISP reset.
319
- */
320
- if (!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))
321
- qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL);
322
-
323335 ql_dbg(ql_dbg_taskm, vha, 0x801d,
324336 "Scheduling enable of Vport %d.\n", vha->vp_idx);
337
+
325338 return qla24xx_enable_vp(vha);
326339 }
327340
....@@ -344,6 +357,13 @@
344357 ql_dbg(ql_dbg_dpc, vha, 0x4015,
345358 "Configure VP end.\n");
346359 return 0;
360
+ }
361
+ }
362
+
363
+ if (test_bit(PROCESS_PUREX_IOCB, &vha->dpc_flags)) {
364
+ if (atomic_read(&vha->loop_state) == LOOP_READY) {
365
+ qla24xx_process_purex_list(&vha->purex_list);
366
+ clear_bit(PROCESS_PUREX_IOCB, &vha->dpc_flags);
347367 }
348368 }
349369
....@@ -495,6 +515,9 @@
495515 vha->mgmt_svr_loop_id = qla2x00_reserve_mgmt_server_loop_id(vha);
496516
497517 vha->dpc_flags = 0L;
518
+ ha->dpc_active = 0;
519
+ set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags);
520
+ set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags);
498521
499522 /*
500523 * To fix the issue of processing a parent's RSCN for the vport before
....@@ -507,6 +530,7 @@
507530 qla2x00_start_timer(vha, WATCH_INTERVAL);
508531
509532 vha->req = base_vha->req;
533
+ vha->flags.nvme_enabled = base_vha->flags.nvme_enabled;
510534 host->can_queue = base_vha->req->length + 128;
511535 host->cmd_per_lun = 3;
512536 if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif)
....@@ -745,7 +769,7 @@
745769 req->req_q_in = &reg->isp25mq.req_q_in;
746770 req->req_q_out = &reg->isp25mq.req_q_out;
747771 req->max_q_depth = ha->req_q_map[0]->max_q_depth;
748
- req->out_ptr = (void *)(req->ring + req->length);
772
+ req->out_ptr = (uint16_t *)(req->ring + req->length);
749773 mutex_unlock(&ha->mq_lock);
750774 ql_dbg(ql_dbg_multiq, base_vha, 0xc004,
751775 "ring_ptr=%p ring_index=%d, "
....@@ -783,11 +807,9 @@
783807 {
784808 unsigned long flags;
785809 struct qla_qpair *qpair = container_of(work, struct qla_qpair, q_work);
786
- struct scsi_qla_host *vha;
787
- struct qla_hw_data *ha = qpair->hw;
810
+ struct scsi_qla_host *vha = qpair->vha;
788811
789812 spin_lock_irqsave(&qpair->qp_lock, flags);
790
- vha = pci_get_drvdata(ha->pdev);
791813 qla24xx_process_response_queue(vha, qpair->rsp);
792814 spin_unlock_irqrestore(&qpair->qp_lock, flags);
793815
....@@ -859,7 +881,7 @@
859881 reg = ISP_QUE_REG(ha, que_id);
860882 rsp->rsp_q_in = &reg->isp25mq.rsp_q_in;
861883 rsp->rsp_q_out = &reg->isp25mq.rsp_q_out;
862
- rsp->in_ptr = (void *)(rsp->ring + rsp->length);
884
+ rsp->in_ptr = (uint16_t *)(rsp->ring + rsp->length);
863885 mutex_unlock(&ha->mq_lock);
864886 ql_dbg(ql_dbg_multiq, base_vha, 0xc00b,
865887 "options=%x id=%d rsp_q_in=%p rsp_q_out=%p\n",
....@@ -871,7 +893,8 @@
871893 rsp->rsp_q_out);
872894
873895 ret = qla25xx_request_irq(ha, qpair, qpair->msix,
874
- QLA_MSIX_QPAIR_MULTIQ_RSP_Q);
896
+ ha->flags.disable_msix_handshake ?
897
+ QLA_MSIX_QPAIR_MULTIQ_RSP_Q : QLA_MSIX_QPAIR_MULTIQ_RSP_Q_HS);
875898 if (ret)
876899 goto que_failed;
877900
....@@ -900,11 +923,10 @@
900923 return 0;
901924 }
902925
903
-static void qla_ctrlvp_sp_done(void *s, int res)
926
+static void qla_ctrlvp_sp_done(srb_t *sp, int res)
904927 {
905
- struct srb *sp = s;
906
-
907
- complete(&sp->comp);
928
+ if (sp->comp)
929
+ complete(sp->comp);
908930 /* don't free sp here. Let the caller do the free */
909931 }
910932
....@@ -921,6 +943,7 @@
921943 struct qla_hw_data *ha = vha->hw;
922944 int vp_index = vha->vp_idx;
923945 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
946
+ DECLARE_COMPLETION_ONSTACK(comp);
924947 srb_t *sp;
925948
926949 ql_dbg(ql_dbg_vport, vha, 0x10c1,
....@@ -935,6 +958,7 @@
935958
936959 sp->type = SRB_CTRL_VP;
937960 sp->name = "ctrl_vp";
961
+ sp->comp = &comp;
938962 sp->done = qla_ctrlvp_sp_done;
939963 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
940964 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
....@@ -952,7 +976,9 @@
952976 ql_dbg(ql_dbg_vport, vha, 0x113f, "%s hndl %x submitted\n",
953977 sp->name, sp->handle);
954978
955
- wait_for_completion(&sp->comp);
979
+ wait_for_completion(&comp);
980
+ sp->comp = NULL;
981
+
956982 rval = sp->rc;
957983 switch (rval) {
958984 case QLA_FUNCTION_TIMEOUT: