Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1858006rwb; Fri, 19 Aug 2022 10:32:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR6T2rumn0z+/WHU+7l/QWvO/OcD+JnHKgzdfw2DRVXjbBln19rEhR8re6nLkMECInzkVEYC X-Received: by 2002:a17:90a:1d0:b0:1fa:c551:5e83 with SMTP id 16-20020a17090a01d000b001fac5515e83mr10542888pjd.106.1660930360453; Fri, 19 Aug 2022 10:32:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930360; cv=none; d=google.com; s=arc-20160816; b=OjthFm00bJQOSmjFAmal5LKDLH9KLGF9Z9YdEOuou3xQ2yEp1s5soNrdD0NVoDxmLa WpIdYSUTCHqp5JNbhHfBA/u/L4gNtF3bJy/suVzhinfsIEIaMCqnbX9Yy06mm7cs8XYY bS46MO65HsdHIQAckhGcETGDJ8wLpT8g2E+h8Zl5A3lhTUySw86grornbHexrZSH1W+p z0DGQb9HvVpVS0OHWcaXF6b9KppF3GZSJNiLOQBpCNzZ/uCfrvV+EqUbqyU5koDQf90M fsADcG6JjuNhajoVM8ce5w3SYVMDSPJ7y0S2DhvLy2WBHHcogR+9+eCjhVGDsV5HtjiH nmrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=njIReekJCnHdySwaGYfw9KiSdDh8fHLSte4xfJ6QIyY=; b=s72w/15JSrK80qm/Gn7MK1jz+Xg9ODv8icu/6fCK3GBLRa7AZybPYHfDWObN2MQ5mW +PNqIDKejYOE5UDY0E/OshywgWC15bGHJO9GSQ+ERshovh8PCWUdm7ua+upX5FglFmVP TDQVDvPj0Ahv8j4A72PRpfC/YvWfb43dBmyoN/WY1uZQ1auD5dhrrPtQiF/KRgaD7ukc K8d8nsjkz8O9/S+4lLSP14sq9FA14K/DnxTE6SjatJWNPAfaqVDcW7hbWgHJdrqNsNvL aTOd/Vj6UQ2RGtnQaAlVsYkxgb3cSZ/ktlYVGLXNPHDmKXs8JsO4kdQbr6vzXDnln6ur qKow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Far5wnp3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e65-20020a636944000000b0041e1bbc16a8si4335052pgc.608.2022.08.19.10.32.29; Fri, 19 Aug 2022 10:32:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Far5wnp3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353744AbiHSQno (ORCPT + 99 others); Fri, 19 Aug 2022 12:43:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353857AbiHSQlJ (ORCPT ); Fri, 19 Aug 2022 12:41:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4D2B12578F; Fri, 19 Aug 2022 09:09:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AC6CD61639; Fri, 19 Aug 2022 16:08:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D570C43141; Fri, 19 Aug 2022 16:08:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925332; bh=qBJun0bWQYxXyX9cv6OKocqYB+O1BIvrD1jsikgfFIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Far5wnp31bNbkUbATA0TOtUdbhp6VurU6CnHw227cul447uu3RRtgPG2ouiw8AB/l T5GO9iVI+70UTiaOOyS8Rv0aluLFTeKtQL/mw10vnwShcLug2G42wLdPHlVUslcC6g wctB0TQD2QRV2Id99rc9ZtZd1IlReVILHXApUakw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tony Battersby , Himanshu Madhani , Arun Easi , Nilesh Javali , "Martin K. Petersen" Subject: [PATCH 5.10 440/545] scsi: qla2xxx: Fix discovery issues in FC-AL topology Date: Fri, 19 Aug 2022 17:43:30 +0200 Message-Id: <20220819153849.113964391@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arun Easi commit 47ccb113cead905bdc236571bf8ac6fed90321b3 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: Tony Battersby Tested-by: Tony Battersby Reviewed-by: Himanshu Madhani Signed-off-by: Arun Easi Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/qla2xxx/qla_gbl.h | 3 ++- drivers/scsi/qla2xxx/qla_init.c | 29 +++++++++++++++++++++++++++++ drivers/scsi/qla2xxx/qla_mbx.c | 5 ++++- 3 files changed, 35 insertions(+), 2 deletions(-) --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -405,7 +405,8 @@ extern int qla2x00_get_resource_cnts(scsi_qla_host_t *); 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 qla2x00_get_link_status(scsi_qla_host_t *, uint16_t, struct link_statistics *, --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -5270,6 +5270,22 @@ static int qla2x00_configure_n2n_loop(sc 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 * Updates Fibre Channel Device Database with local loop devices. @@ -5321,6 +5337,19 @@ qla2x00_configure_local_loop(scsi_qla_ho spin_unlock_irqrestore(&vha->work_lock, flags); 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(LOOP_RESYNC_NEEDED, &vha->dpc_flags); } --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -3017,7 +3017,8 @@ qla2x00_get_resource_cnts(scsi_qla_host_ * Kernel context. */ 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; mbx_cmd_t mc; @@ -3057,6 +3058,8 @@ qla2x00_get_fcal_position_map(scsi_qla_h if (pos_map) memcpy(pos_map, pmap, FCAL_MAP_SIZE); + if (num_entries) + *num_entries = pmap[0]; } dma_pool_free(ha->s_dma_pool, pmap, pmap_dma);