Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2861083rwb; Mon, 15 Aug 2022 12:48:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR5HiPd8UKjpr0lPP1kLe2J9t6ytbxpHHYw/moy6ATgEFbzHvRLbhjiK3wPxP2RFxXQaz06u X-Received: by 2002:a17:90a:17e1:b0:1f2:2ff2:6cae with SMTP id q88-20020a17090a17e100b001f22ff26caemr29571641pja.196.1660592882422; Mon, 15 Aug 2022 12:48:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660592882; cv=none; d=google.com; s=arc-20160816; b=cKOXeMFxbP+9Sa5Yx3U0FrD6F107AvoprpDg5sv6D1mpC9GY2/WUmMDtQKGF5rNgIC +fLggGYlShi547iBnhYiYzt+AdG0wKZpTegMbBPkqVhX0M0BC/ZXOoOiW9xxMTr6sEpI IVZwb4h7LDdZ4ZKe5jRqSs4vjFQ3ozyc1qgjd0tzlVXTa7Vo4JoIHaCFyYaCebBE3Qnd 4cFh+GOFbEdV+ja5Ns4dt9zfO+C/7ZRH66ITdOzi4C0P6DLIk9Fe5Sw+SaNSaceQhewy zAELGIYcTxElLUBIHRRsLy34PSmoW3ciK8F43JMPZqCxUjWbolCOxdnSjObYPqFFbBS4 gLCg== 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=pmsV/4QIvALbBibO12yrdXlUtPJ35mT9JtWAijncpt4=; b=TU1KZeXqG0TiQKC55P6IJOM8Z+/z0JUcTWqzC680fsWPvICvVFvoWObyX/fq7ZuyAf J+GTbPDGEyOOuKX5o3POr0TtYoWN5LAd3fXu4IQMSpmnSYJk1eCmkvV1XxT7YOPMfkmg w2psk2u6GU/Bb9EyigLy2Q56AVFHgqO1okWi+VNbnJXS3AXVsKiuY+n8H9IT9tIm6oE2 cZaayQOAB3yOpGoBfkX3539X2p66E0Vi5THs/4eYLXAB1oXt+BI67KQBMw4qhuQxK1Dz SnN2MYpI3c1PMlMs2GG3X0BCxM69dx00ip6oqFzqDkNswdUPEPuB5yR76I5gisMRiaFM IXJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NKzL1Yqf; 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 h6-20020a170902704600b0017127a4e742si10507000plt.443.2022.08.15.12.47.50; Mon, 15 Aug 2022 12:48:02 -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=NKzL1Yqf; 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 S1344974AbiHOTp5 (ORCPT + 99 others); Mon, 15 Aug 2022 15:45:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345187AbiHOTme (ORCPT ); Mon, 15 Aug 2022 15:42:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2B1F6B646; Mon, 15 Aug 2022 11:48:11 -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 ams.source.kernel.org (Postfix) with ESMTPS id E0C4CB810A0; Mon, 15 Aug 2022 18:48:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3464FC433C1; Mon, 15 Aug 2022 18:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589288; bh=5AooMPA3ZrJcRMxrL843yoAkL5TcRwMlZgvuvKA3e4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NKzL1YqfnYZX2lx6BNn87/mGOQaJrrYuk1Phqswj64Q1zT4su6yBhHQvlVeDHByOe kd4Mhxim+nKhsf8EGGFvbcOPOsDWuwMRrZ6no1ZysgL93hIXzAELeEVub+kBsvGjN7 VvDaxF4LJJJo8Jos6Id4+EcIgFbJWJ3ni2zy1eHc= 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.15 672/779] scsi: qla2xxx: Fix discovery issues in FC-AL topology Date: Mon, 15 Aug 2022 20:05:16 +0200 Message-Id: <20220815180406.063549006@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 @@ -433,7 +433,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 @@ -5510,6 +5510,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. @@ -5561,6 +5577,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 @@ -3062,7 +3062,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; @@ -3102,6 +3103,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);