Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3120635rwb; Mon, 15 Aug 2022 18:37:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR5CQiihZtmLCMIFBB3idHvZfxjfcuIkQLFb8nPiGMq5tb1/j+dBexgbi5rdJVqgPsZDuKQ8 X-Received: by 2002:a62:6497:0:b0:52e:e0cd:1963 with SMTP id y145-20020a626497000000b0052ee0cd1963mr18906435pfb.58.1660613848007; Mon, 15 Aug 2022 18:37:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660613847; cv=none; d=google.com; s=arc-20160816; b=JmAMJrTQ9SjaVnPA+iR79I+guQOoVXwcirBTmk45tLlaxB18JfPapF0wyADWRmIIvR h9Bo6bYAZUUpEsnTwkuyovsGxgj24ZtS+uK+6pP90+4zQwKDNkB9I/E7MErmQbZGHuhH 7SMQMB8wvJ/gF4aeRUMaW+GKhWvuDIkwVL0NXAEHIyj147MFbRlYkS5MvKY8GXlmsokB TWeB0/IeDTeeRmFfr4Kz6miVOlHv7RnKbTI+UpVomAmUzHG+LmH+TEuYn6xyKdUew7mE vgl3raJv2mKuZ50m9d+aSJnkgKMBX82irqeo8lboIc5TG+2SeMzgiayopvCpXkconB4U TuKw== 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=OamC5KrcbQuPv9IMZdfWVWF/yObUZ89Q3upnkY6Pr/+WapGJz4qaXqZ8dsv/8Lb3c2 jhotsvx4oKeZU1bIyGFP1vzvtUxRhEoHO5f/1/VqCUdqHvbSnl5cxT24Z6Y5CcYn4skW 2xNWRUGZeuKQzieessGgCKWOfaXc6TwlTeF+UgHY/fJyTp87io2+CoyNy275ca+aKwi7 bsG9enM2uFWS1PkgGo3t+9SDnhyt5Y21CQM5FAmuGSdwQM6pIJCLoWNXVdcBIao+IMR1 +hV6q5Co9//UhtSpRhJhv/h/G+3DiCzR7vAWOgbrJrjd84vb1NUqfyKchUWmm+/OFWut pysg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1DI6AUl7; 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 u8-20020a634548000000b0041ccbc553d9si11842823pgk.485.2022.08.15.18.37.16; Mon, 15 Aug 2022 18:37:27 -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=1DI6AUl7; 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 S242343AbiHPAwR (ORCPT + 99 others); Mon, 15 Aug 2022 20:52:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349725AbiHPAqn (ORCPT ); Mon, 15 Aug 2022 20:46:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9CC7D87FD; Mon, 15 Aug 2022 13:45:05 -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 5F5C3B811A6; Mon, 15 Aug 2022 20:45:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4493C433D6; Mon, 15 Aug 2022 20:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596303; bh=9/s9PwEz8qdZIEIq4LzwD7S4d3nxllJUbhvznSvycco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1DI6AUl7mjT3xlANx7sKthfe07bNBeIM7Pc7xww6q6Uzl6tj33pIYI0dr4kBu3MNB /xMQwXnPdK0n/LjdFYYjHIpOk8eI3QMHixRbFF92NcIroEIvc8CROisE3oLK2xrrGT fUIC07M4jQNXw+Z4oiNettGt06YHW7tgLLcmiLNY= 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.19 1036/1157] scsi: qla2xxx: Fix discovery issues in FC-AL topology Date: Mon, 15 Aug 2022 20:06:32 +0200 Message-Id: <20220815180521.418220972@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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);