提交 aeec835f 编写于 作者: A Arun Easi 提交者: Zheng Zengkai

scsi: qla2xxx: Fix discovery issues in FC-AL topology

stable inclusion
from stable-v5.10.137
commit 2ffe5285ea5d907be5f5617abf498c5d8417e107
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I60PLB

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2ffe5285ea5d907be5f5617abf498c5d8417e107

--------------------------------

commit 47ccb113 upstream.

A direct attach tape device, when gets swapped with another, was not
discovered. Fix this by looking at loop map and reinitialize link if there
are devices present.

Link: https://lore.kernel.org/linux-scsi/baef87c3-5dad-3b47-44c1-6914bfc90108@cybernetics.com/
Link: https://lore.kernel.org/r/20220713052045.10683-8-njavali@marvell.com
Cc: stable@vger.kernel.org
Reported-by: NTony Battersby <tonyb@cybernetics.com>
Tested-by: NTony Battersby <tonyb@cybernetics.com>
Reviewed-by: NHimanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: NArun Easi <aeasi@marvell.com>
Signed-off-by: NNilesh Javali <njavali@marvell.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 22adb0c1
...@@ -405,7 +405,8 @@ extern int ...@@ -405,7 +405,8 @@ extern int
qla2x00_get_resource_cnts(scsi_qla_host_t *); qla2x00_get_resource_cnts(scsi_qla_host_t *);
extern int extern int
qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map); qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map,
u8 *num_entries);
extern int extern int
qla2x00_get_link_status(scsi_qla_host_t *, uint16_t, struct link_statistics *, qla2x00_get_link_status(scsi_qla_host_t *, uint16_t, struct link_statistics *,
......
...@@ -5270,6 +5270,22 @@ static int qla2x00_configure_n2n_loop(scsi_qla_host_t *vha) ...@@ -5270,6 +5270,22 @@ static int qla2x00_configure_n2n_loop(scsi_qla_host_t *vha)
return QLA_FUNCTION_FAILED; return QLA_FUNCTION_FAILED;
} }
static void
qla_reinitialize_link(scsi_qla_host_t *vha)
{
int rval;
atomic_set(&vha->loop_state, LOOP_DOWN);
atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
rval = qla2x00_full_login_lip(vha);
if (rval == QLA_SUCCESS) {
ql_dbg(ql_dbg_disc, vha, 0xd050, "Link reinitialized\n");
} else {
ql_dbg(ql_dbg_disc, vha, 0xd051,
"Link reinitialization failed (%d)\n", rval);
}
}
/* /*
* qla2x00_configure_local_loop * qla2x00_configure_local_loop
* Updates Fibre Channel Device Database with local loop devices. * Updates Fibre Channel Device Database with local loop devices.
...@@ -5321,6 +5337,19 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha) ...@@ -5321,6 +5337,19 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
spin_unlock_irqrestore(&vha->work_lock, flags); spin_unlock_irqrestore(&vha->work_lock, flags);
if (vha->scan.scan_retry < MAX_SCAN_RETRIES) { if (vha->scan.scan_retry < MAX_SCAN_RETRIES) {
u8 loop_map_entries = 0;
int rc;
rc = qla2x00_get_fcal_position_map(vha, NULL,
&loop_map_entries);
if (rc == QLA_SUCCESS && loop_map_entries > 1) {
/*
* There are devices that are still not logged
* in. Reinitialize to give them a chance.
*/
qla_reinitialize_link(vha);
return QLA_FUNCTION_FAILED;
}
set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
} }
......
...@@ -3017,7 +3017,8 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *vha) ...@@ -3017,7 +3017,8 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *vha)
* Kernel context. * Kernel context.
*/ */
int int
qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map) qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map,
u8 *num_entries)
{ {
int rval; int rval;
mbx_cmd_t mc; mbx_cmd_t mc;
...@@ -3057,6 +3058,8 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map) ...@@ -3057,6 +3058,8 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map)
if (pos_map) if (pos_map)
memcpy(pos_map, pmap, FCAL_MAP_SIZE); memcpy(pos_map, pmap, FCAL_MAP_SIZE);
if (num_entries)
*num_entries = pmap[0];
} }
dma_pool_free(ha->s_dma_pool, pmap, pmap_dma); dma_pool_free(ha->s_dma_pool, pmap, pmap_dma);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册