Skip to contentSkip to conversation

qla2xxx: synchronize rport dev_loss_tmo setting

PATCH Applied Daniel Wagner 3 participants 4 messages Dec 14, 2021 – Dec 23, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 qla2xxx: synchronize rport dev_loss_tmo setting

From: Hannes Reinecke <[email protected]>

Currently, the dev_loss_tmo setting is only ever used for SCSI devices. This patch reshuffles initialisation such that the SCSI remote ports are registered before the NVMe ones, allowing the dev_loss_tmo setting to be synchronized between SCSI and NVMe.

---
We have this patch in our kernels for a while and it works fine.

v3:
- added additional check if fcport pointer is valid in qla2x00_set_rport_loss_tmo (crash reported)

v2:
- https://lore.kernel.org/linux-scsi/[email protected]/
- fixed build failure for !NVME_FC reported by lkp

v1:
- https://lore.kernel.org/linux-scsi/[email protected]/
- initial version

 drivers/scsi/qla2xxx/qla_attr.c |  6 ++++++
 drivers/scsi/qla2xxx/qla_init.c | 10 +++-------
 drivers/scsi/qla2xxx/qla_nvme.c |  5 ++++-
 3 files changed, 13 insertions(+), 8 deletions(-)
drivers/scsi/qla2xxx/qla_attr.c +6 -0
index 032efb294ee5..db55737000ab 100644
@@ -2700,7 +2700,13 @@ qla2x00_get_starget_port_id(struct scsi_target *starget)
 static inline void
 qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
 {
+	fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
+
 	rport->dev_loss_tmo = timeout ? timeout : 1;
+
+	if (IS_ENABLED(CONFIG_NVME_FC) && fcport && fcport->nvme_remote_port)
+		nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port,
+					       rport->dev_loss_tmo);
 }
 
 static void
drivers/scsi/qla2xxx/qla_init.c +3 -7
index 070b636802d0..1fe4966fc2f6 100644
@@ -5828,13 +5828,6 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
 
 	qla2x00_dfs_create_rport(vha, fcport);
 
-	if (NVME_TARGET(vha->hw, fcport)) {
-		qla_nvme_register_remote(vha, fcport);
-		qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_COMPLETE);
-		qla2x00_set_fcport_state(fcport, FCS_ONLINE);
-		return;
-	}
-
 	qla24xx_update_fcport_fcp_prio(vha, fcport);
 
 	switch (vha->host->active_mode) {
@@ -5856,6 +5849,9 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
 		break;
 	}
 
+	if (NVME_TARGET(vha->hw, fcport))
+		qla_nvme_register_remote(vha, fcport);
+
 	qla2x00_set_fcport_state(fcport, FCS_ONLINE);
 
 	if (IS_IIDMA_CAPABLE(vha->hw) && vha->hw->flags.gpsc_supported) {
drivers/scsi/qla2xxx/qla_nvme.c +4 -1
index 138ffdb5c92c..e22ec7cb65db 100644
@@ -43,7 +43,7 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport)
 	req.port_name = wwn_to_u64(fcport->port_name);
 	req.node_name = wwn_to_u64(fcport->node_name);
 	req.port_role = 0;
-	req.dev_loss_tmo = 0;
+	req.dev_loss_tmo = fcport->dev_loss_tmo;
 
 	if (fcport->nvme_prli_service_param & NVME_PRLI_SP_INITIATOR)
 		req.port_role = FC_PORT_ROLE_NVME_INITIATOR;
@@ -70,6 +70,9 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport)
 		return ret;
 	}
 
+	nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port,
+				       fcport->dev_loss_tmo);
+
 	if (fcport->nvme_prli_service_param & NVME_PRLI_SP_SLER)
 		ql_log(ql_log_info, vha, 0x212a,
 		       "PortID:%06x Supports SLER\n", req.port_id);
Signature · 1 line
2.29.2
Reviewed-by on v3 1/1
#1 lore raw
Quoted 106 lines · Daniel Wagner

From: Hannes Reinecke <[email protected]>

Currently, the dev_loss_tmo setting is only ever used for SCSI devices. This patch reshuffles initialisation such that the SCSI remote ports are registered before the NVMe ones, allowing the dev_loss_tmo setting to be synchronized between SCSI and NVMe.

---
We have this patch in our kernels for a while and it works fine.

v3:
- added additional check if fcport pointer is valid in qla2x00_set_rport_loss_tmo (crash reported)

v2:
- https://lore.kernel.org/linux-scsi/[email protected]/
- fixed build failure for !NVME_FC reported by lkp

v1:
- https://lore.kernel.org/linux-scsi/[email protected]/
- initial version

drivers/scsi/qla2xxx/qla_attr.c |  6 ++++++
drivers/scsi/qla2xxx/qla_init.c | 10 +++-------
drivers/scsi/qla2xxx/qla_nvme.c |  5 ++++-
3 files changed, 13 insertions(+), 8 deletions(-)
drivers/scsi/qla2xxx/qla_attr.c +0 -0
index 032efb294ee5..db55737000ab 100644
@@ -2700,7 +2700,13 @@ qla2x00_get_starget_port_id(struct scsi_target *starget)

static inline void
qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) {

drivers/scsi/qla2xxx/qla_attr.c +2 -0
+	fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
+
	rport->dev_loss_tmo = timeout ? timeout : 1;
drivers/scsi/qla2xxx/qla_attr.c +4 -0
+
+	if (IS_ENABLED(CONFIG_NVME_FC) && fcport && fcport->nvme_remote_port)
+		nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port,
+					       rport->dev_loss_tmo);

}

static void

drivers/scsi/qla2xxx/qla_init.c +3 -7
index 070b636802d0..1fe4966fc2f6 100644
@@ -5828,13 +5828,6 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
 
 	qla2x00_dfs_create_rport(vha, fcport);
 
-	if (NVME_TARGET(vha->hw, fcport)) {
-		qla_nvme_register_remote(vha, fcport);
-		qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_COMPLETE);
-		qla2x00_set_fcport_state(fcport, FCS_ONLINE);
-		return;
-	}
-
 	qla24xx_update_fcport_fcp_prio(vha, fcport);
 
 	switch (vha->host->active_mode) {
@@ -5856,6 +5849,9 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
 		break;
 	}
 
+	if (NVME_TARGET(vha->hw, fcport))
+		qla_nvme_register_remote(vha, fcport);
+
 	qla2x00_set_fcport_state(fcport, FCS_ONLINE);
 
 	if (IS_IIDMA_CAPABLE(vha->hw) && vha->hw->flags.gpsc_supported) {
drivers/scsi/qla2xxx/qla_nvme.c +4 -1
index 138ffdb5c92c..e22ec7cb65db 100644
@@ -43,7 +43,7 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport)
 	req.port_name = wwn_to_u64(fcport->port_name);
 	req.node_name = wwn_to_u64(fcport->node_name);
 	req.port_role = 0;
-	req.dev_loss_tmo = 0;
+	req.dev_loss_tmo = fcport->dev_loss_tmo;
 
 	if (fcport->nvme_prli_service_param & NVME_PRLI_SP_INITIATOR)
 		req.port_role = FC_PORT_ROLE_NVME_INITIATOR;
@@ -70,6 +70,9 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport)
 		return ret;
 	}
 
+	nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port,
+				       fcport->dev_loss_tmo);
+
 	if (fcport->nvme_prli_service_param & NVME_PRLI_SP_SLER)
 		ql_log(ql_log_info, vha, 0x212a,
 		       "PortID:%06x Supports SLER\n", req.port_id);
Signature · 1 line
2.29.2

Looks Good.

--
Himanshu Madhani Oracle Linux Engineering

#2 lore raw
In reply to Daniel Wagner

Daniel,

Quoted 4 lines

Currently, the dev_loss_tmo setting is only ever used for SCSI devices. This patch reshuffles initialisation such that the SCSI remote ports are registered before the NVMe ones, allowing the dev_loss_tmo setting to be synchronized between SCSI and NVMe.

Applied to 5.17/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#3 lore raw
In reply to Daniel Wagner
Quoted 8 lines · Daniel Wagner

From: Hannes Reinecke <[email protected]>

Currently, the dev_loss_tmo setting is only ever used for SCSI devices. This patch reshuffles initialisation such that the SCSI remote ports are registered before the NVMe ones, allowing the dev_loss_tmo setting to be synchronized between SCSI and NVMe.

[...]

Applied to 5.17/scsi-queue, thanks!

[1/1] qla2xxx: synchronize rport dev_loss_tmo setting

      https://git.kernel.org/mkp/scsi/c/baea0e833f76
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering