Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3027834rwb; Mon, 15 Aug 2022 16:26:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR6t8TBGk9eAfRBRnY0j77HFgZrXv+wOCKBODlFYx/c2pJ1FinbYXMCETNCLD0MfBRZlxzpi X-Received: by 2002:a05:6402:42c3:b0:43d:682f:c0ca with SMTP id i3-20020a05640242c300b0043d682fc0camr16467047edc.334.1660605972706; Mon, 15 Aug 2022 16:26:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605972; cv=none; d=google.com; s=arc-20160816; b=Jabiw1kRe/ebz3yeL69nenap7dJs6RX7Euxv+wXPdWScPXJeBvBfizlUL7Af793VwG Ppf1+bhJ4gWG1tFSYdBFezzgesgbmJizc0HWW+MaNtqk9utqd7ys/dqoq3Hbto/9TTYl UdsVg2huaHfp3YnPa+8DxEGLtU92RdMpX2EaPw0DPV94NAn/Icsz9xc/I4k+glF+94KF rzCFGyknaROnWtaosT9vsU5pgDF7J4x5okAWczITscxzFiMic9O67thFh9yzX/P/WHFq nyNw0TrAMhwvaYV5IExxtYJnrqS9ABYjCk1d/m/FfBdQiQnZz4jCTHVwohX8tQ229y2y iI/Q== 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=SZ2038qalHr45uRw6dG31SU269tCWDf5DBwSjD0IVGY=; b=vT/rdo8GKHBCYaOdyK1uGauXfOaRJGiqm57NuYwKIpWJGJ41d6T26GdDCGkmFaZJPB dVjOUd1T3T6JWhmvYxLTzHukI/NosKRzgN1DSnG3rtR9lGjo0tYiDFNWhcSO+VgCx2h6 MvLL//imFhyk5SQ5ss7CfvetI0jfcvtiOwu1moCb55XuZ5Bbp+tWa5uhHEOsyALvBM3g +NboHdhjAoF5M3N2jNIyRp1p0Sksgln3ib8VNcLY5Sf1nnU6fEBAxeE9oH+h0jg99qUa oIXcJvMn5bjIyWkTcc1ki0826FeE/e7bbwz16enm2RVvYkqdseOKkJFM2phxNRvNlseZ 9bWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uGHGoHXa; 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 g10-20020a056402424a00b0043d7f3e0aa7si10188264edb.26.2022.08.15.16.25.48; Mon, 15 Aug 2022 16:26:12 -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=uGHGoHXa; 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 S1345355AbiHOXIP (ORCPT + 99 others); Mon, 15 Aug 2022 19:08:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352560AbiHOXFn (ORCPT ); Mon, 15 Aug 2022 19:05:43 -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 09092140CAE; Mon, 15 Aug 2022 12:58:44 -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 6A81D612A3; Mon, 15 Aug 2022 19:58:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 737EAC433C1; Mon, 15 Aug 2022 19:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593522; bh=9/s9PwEz8qdZIEIq4LzwD7S4d3nxllJUbhvznSvycco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uGHGoHXan/UE51ElJORySsHwS5FfFGMubgG+mKEfTA4TwWufRmEvN/DFPGfuzE1MJ T39va/EmxPsM5WpLOwXlUxRyOgM5hs2waRysiZKzqdRJxZC9qI9GSwEnHUvu/20pwN Y+bq3fQZ3LiYr2ruCfIYSviSisTPywm06rOsRRbM= 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.18 0962/1095] scsi: qla2xxx: Fix discovery issues in FC-AL topology Date: Mon, 15 Aug 2022 20:06:01 +0200 Message-Id: <20220815180508.876319591@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 @@ -434,7 +434,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 @@ -5505,6 +5505,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. @@ -5556,6 +5572,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 @@ -3068,7 +3068,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; @@ -3108,6 +3109,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);