From patchwork Wed Mar 1 23:16:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tee X-Patchwork-Id: 658379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72472C7EE23 for ; Wed, 1 Mar 2023 23:07:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbjCAXHQ (ORCPT ); Wed, 1 Mar 2023 18:07:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbjCAXHP (ORCPT ); Wed, 1 Mar 2023 18:07:15 -0500 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4437FC679 for ; Wed, 1 Mar 2023 15:07:14 -0800 (PST) Received: by mail-qt1-x836.google.com with SMTP id d7so16189741qtr.12 for ; Wed, 01 Mar 2023 15:07:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677712033; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rieBKGd7o1erdCd49tEdelZ5ZlqM1PJ8uG8LaNXqWMQ=; b=KY/FgldWcTxWmPWg9B8VWskQfoI8NrCDW72/K9RCY/U1WzBuZdXCYGq/nq7BEskkQH bkiar3Y1fWOkstd1b/VirPr+6nFPOeKfcQ/j9lzf07GhWY9SOii+Qtwdr7Jd0iuedVP/ EHMnsjfj+BRL/mUUZ6fs9ZAo0xpi4GUNULl4Qkzbik1rlrN918/ZOWqF8uEM612VF2bM wPR5Gj9nzH1PNUzxbwtGDZbn6+8gKk+lWiJ8Uoj/L+ideGI2KRWr+Eh4qFbDfRGRdJN4 q+z0ywaj6MblbIE2iMBt9cOWRaP2Gah2z/0iM1iopttNMsLv5/0yq2WheQLYC/KPMEc4 Cp3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677712033; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rieBKGd7o1erdCd49tEdelZ5ZlqM1PJ8uG8LaNXqWMQ=; b=kSr5XSG7DHieHa9TkxPyk8XAvnQA1F1YOaWVsN7h4adF0ghwZAv6yJWz7/y3Hc8eQD rBtdx3PhrlcQn6d9Km9/2u9hS9QpY2JmxXUnlT4DZkwbs9iQUTfd1ldDBqpGooxcSipC KvR7DoiWGZytyu9zdgH9Dmsen4FMIhxE1U+MYPTLl8QM1pneQPNxcWv2GdjvXmZAhKrM EyRHIWO6mbHlNRTzRcNFMlZkh4I01EQcPiAKLPjsJbYzqPh6Uj1Iqx3cT4uDA1uilwFd 08x3Yz554/tubScz9XhcxpLRC/iNnv9E3fsIZOmRM8aTt9E/mauYYgF73o957kMDUa5d pS8Q== X-Gm-Message-State: AO0yUKUTotcrv3XZ+UhfpCswxEJyjifvRUBSs3t0nLeiCyZCWigKH/Ex H0XAjDGFq8KNAZUI5x5IxIFPh2x9DSM= X-Google-Smtp-Source: AK7set/6JAzKSssGjSY04m6wpZtMHReuZcNPmJUMfEalF4dXX5NNVs/QQ1mYAN6YUku+IfyYUUPCcA== X-Received: by 2002:a05:622a:1896:b0:3bd:1c0f:74f3 with SMTP id v22-20020a05622a189600b003bd1c0f74f3mr16810352qtc.2.1677712033226; Wed, 01 Mar 2023 15:07:13 -0800 (PST) Received: from dhcp-10-231-55-133.dhcp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j9-20020ac85509000000b003b86b99690fsm9047572qtq.62.2023.03.01.15.07.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2023 15:07:12 -0800 (PST) From: Justin Tee To: linux-scsi@vger.kernel.org Cc: jsmart2021@gmail.com, justin.tee@broadcom.com, Justin Tee Subject: [PATCH 01/10] lpfc: Protect against potential lpfc_debugfs_lockstat_write buffer overflow Date: Wed, 1 Mar 2023 15:16:17 -0800 Message-Id: <20230301231626.9621-2-justintee8345@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230301231626.9621-1-justintee8345@gmail.com> References: <20230301231626.9621-1-justintee8345@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org A static code analysis tool flagged the possibility of buffer overflow when using copy_from_user for a debugfs entry. Currently, it is possible that copy_from_user copies more bytes than what would fit in the mybuf char array. Add a min restriction check between sizeof(mybuf) - 1 and nbytes passed from the userspace buffer to protect against buffer overflow. Signed-off-by: Justin Tee --- drivers/scsi/lpfc/lpfc_debugfs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c index f5252e45a48a..3e365e5e194a 100644 --- a/drivers/scsi/lpfc/lpfc_debugfs.c +++ b/drivers/scsi/lpfc/lpfc_debugfs.c @@ -2157,10 +2157,13 @@ lpfc_debugfs_lockstat_write(struct file *file, const char __user *buf, char mybuf[64]; char *pbuf; int i; + size_t bsize; memset(mybuf, 0, sizeof(mybuf)); - if (copy_from_user(mybuf, buf, nbytes)) + bsize = min(nbytes, (sizeof(mybuf) - 1)); + + if (copy_from_user(mybuf, buf, bsize)) return -EFAULT; pbuf = &mybuf[0]; @@ -2181,7 +2184,7 @@ lpfc_debugfs_lockstat_write(struct file *file, const char __user *buf, qp->lock_conflict.wq_access = 0; } } - return nbytes; + return bsize; } #endif From patchwork Wed Mar 1 23:16:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tee X-Patchwork-Id: 658057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E3AFC678D4 for ; Wed, 1 Mar 2023 23:07:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229592AbjCAXHT (ORCPT ); Wed, 1 Mar 2023 18:07:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbjCAXHS (ORCPT ); Wed, 1 Mar 2023 18:07:18 -0500 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 747C855078 for ; Wed, 1 Mar 2023 15:07:17 -0800 (PST) Received: by mail-qt1-x82c.google.com with SMTP id cf14so16214089qtb.10 for ; Wed, 01 Mar 2023 15:07:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677712036; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=n1QquRWHvbN6HKV/l3mb+CElIpFpVP7PNk57/ZB3AMM=; b=qwTBNC63JUyKdjzGpZeB+2/LFbg5FeIhj0uKt2lx4WbfPHHTzTfDgIcs9/zGlTwoL9 5IL8q3JeEVpedBwnHigeXeSN1qjkUWcHl5Oqh+VRSKv5+4ZjBze5tdon5vL0JRc5/lxT oCIxjX2bvp8AHAI8ijKu+4b6SM3QDse6XYav1NrPjipqVa651GzM2/Gwf2TqV5KvJd1m 5B9BAjXHg1YjPPwyKc3XZj+NRCBDIdf2nfesYVrBZcMgqDl5sSN6xfJnAqr4v8S648gX QVXtOU+dDFFFBaTmb6wlTfXhNsEmQu7ptezUm87rd6IYKUi7TS6xiIhQM0hIrDFMXt9N N4mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677712036; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n1QquRWHvbN6HKV/l3mb+CElIpFpVP7PNk57/ZB3AMM=; b=h3dePGvy/qrdKS3UU1p0eyOmLxUMbz3cASKLPvz0sOpqeG4P/YGFvKY9UV51gF4Tuc FB3C5+n5qrhHWHh6ZzReSh8bQ6cwyxHZXQ4oEsY7TGCeWw9GJ9PDtihQufJNLIWRipbM 0Y5caD9KMDLvhn3wM7N8ONWGk5eO2vqF3ZKnHMF59277Wzn8DshJR+iKLQA9nuN0kMeX 9GVXBvEDmUvSUbitbBXAez6jn87EYytOntfGtmVChug/aisW1R9Dc2G35MbgPSthoLHQ zTeC3H9k/T6GmFQCxoZKK0VDu8cUq1Slfpr3VTOHxZIn2bTTg3enFxy4xCmzHnkPL8S1 w7wA== X-Gm-Message-State: AO0yUKUxjLEjIkQ7Ld9q/Kyzx9y7jIoTVhi4ns+3NTYl1shsfAUeYn9E kx3tT3yJZB8zWx83B9iWLYWJ4ZTX8JA= X-Google-Smtp-Source: AK7set+Sdr9kKjULPmOyiFi3JHiPOqq4wWu6YSU1d+hYHl9n95D/oxYwZecMWRRpFk5zY71kPTxUFA== X-Received: by 2002:a05:622a:18a1:b0:3bf:a3d0:9023 with SMTP id v33-20020a05622a18a100b003bfa3d09023mr14467998qtc.5.1677712036446; Wed, 01 Mar 2023 15:07:16 -0800 (PST) Received: from dhcp-10-231-55-133.dhcp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j9-20020ac85509000000b003b86b99690fsm9047572qtq.62.2023.03.01.15.07.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2023 15:07:16 -0800 (PST) From: Justin Tee To: linux-scsi@vger.kernel.org Cc: jsmart2021@gmail.com, justin.tee@broadcom.com, Justin Tee Subject: [PATCH 02/10] lpfc: Reorder freeing of various dma buffers and their list removal Date: Wed, 1 Mar 2023 15:16:18 -0800 Message-Id: <20230301231626.9621-3-justintee8345@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230301231626.9621-1-justintee8345@gmail.com> References: <20230301231626.9621-1-justintee8345@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Code sections where dma resources are freed before list removal are reworked to ensure item removal before freed. Signed-off-by: Justin Tee --- drivers/scsi/lpfc/lpfc_bsg.c | 2 +- drivers/scsi/lpfc/lpfc_ct.c | 2 +- drivers/scsi/lpfc/lpfc_sli.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c index 852b025e2fec..d8e86b468ef6 100644 --- a/drivers/scsi/lpfc/lpfc_bsg.c +++ b/drivers/scsi/lpfc/lpfc_bsg.c @@ -134,8 +134,8 @@ lpfc_free_bsg_buffers(struct lpfc_hba *phba, struct lpfc_dmabuf *mlist) if (mlist) { list_for_each_entry_safe(mlast, next_mlast, &mlist->list, list) { - lpfc_mbuf_free(phba, mlast->virt, mlast->phys); list_del(&mlast->list); + lpfc_mbuf_free(phba, mlast->virt, mlast->phys); kfree(mlast); } lpfc_mbuf_free(phba, mlist->virt, mlist->phys); diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index e941a99aa965..e290aff2e881 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -476,8 +476,8 @@ lpfc_free_ct_rsp(struct lpfc_hba *phba, struct lpfc_dmabuf *mlist) struct lpfc_dmabuf *mlast, *next_mlast; list_for_each_entry_safe(mlast, next_mlast, &mlist->list, list) { - lpfc_mbuf_free(phba, mlast->virt, mlast->phys); list_del(&mlast->list); + lpfc_mbuf_free(phba, mlast->virt, mlast->phys); kfree(mlast); } lpfc_mbuf_free(phba, mlist->virt, mlist->phys); diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index c5b69f313af3..bfab1f0fb3f0 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -22329,10 +22329,10 @@ lpfc_free_sgl_per_hdwq(struct lpfc_hba *phba, /* Free sgl pool */ list_for_each_entry_safe(list_entry, tmp, buf_list, list_node) { + list_del(&list_entry->list_node); dma_pool_free(phba->lpfc_sg_dma_buf_pool, list_entry->dma_sgl, list_entry->dma_phys_sgl); - list_del(&list_entry->list_node); kfree(list_entry); } @@ -22479,10 +22479,10 @@ lpfc_free_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba, list_for_each_entry_safe(list_entry, tmp, buf_list, list_node) { + list_del(&list_entry->list_node); dma_pool_free(phba->lpfc_cmd_rsp_buf_pool, list_entry->fcp_cmnd, list_entry->fcp_cmd_rsp_dma_handle); - list_del(&list_entry->list_node); kfree(list_entry); } From patchwork Wed Mar 1 23:16:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tee X-Patchwork-Id: 658378 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08466C7EE23 for ; Wed, 1 Mar 2023 23:07:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbjCAXHX (ORCPT ); Wed, 1 Mar 2023 18:07:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229606AbjCAXHU (ORCPT ); Wed, 1 Mar 2023 18:07:20 -0500 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E853C679 for ; Wed, 1 Mar 2023 15:07:19 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id c3so11966319qtc.8 for ; Wed, 01 Mar 2023 15:07:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677712038; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AI2fawHrIFIsmBLK6Y4XhK0A9vo7XAxtFMc3BM1lWn0=; b=XTYz7iHRxvN+8Wzm9snDSiG7ZLj2Ezpm82ViOu3AsI7iSuD7V+lavQ3BHP7QHupuCa DOLIigX1crDB2zL36aztfXXX2NmIYP8+mmmEXvD6SNNfz0UaGJsWmnsOa5OoB4FPFdhf wkXUUL4PctyxkC52RLMNKDPTOOolU5YsOtB/2PvTBWAWpgKVKoqD3oBiGRi2Ph1tWjn/ ThC+f6UwYwGhSKJ0i2c37M2+OSFzZpoX+fkNfRX6PHXBz5zRCed/f7c4qmdlQOtxE1/4 XxYIePVVkvbzqYBLuv1N4nMpyTzp709xnWhDSYc2aoptTTp5mdcHmVHg/Si5X3/BsUz+ iBMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677712038; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AI2fawHrIFIsmBLK6Y4XhK0A9vo7XAxtFMc3BM1lWn0=; b=OcP57nfNNgKINdFmCr1eDUbrEwsLpSlbh+IW+Lq+Ea9Dxfb9m4W/t7u1WUaS4la0kN FgNubI2QUeVCT0Dh/9lhq8T92HUPcee0FzU8K97t/v7xOb6IgwvwnHKSuxXPvMje4LOT I4uZ0Nbv8HdwBwmCyT5y7V0yQC9mJOb4YlP60Gs4snW25U0BVismyQb51E09dy0HBl7e v/ptWi2YpzkxQk56n1C6fJwsbmk7fAXlUo6wG3eUsll8PKHzW3H4RQHEElyvK8rKv3Vm EWaiFuWwx45DOMrmBvTxp2hAvZTiSu98Yn3bP5zRsQ/GHrEASapgtM7JGLVWLBvYYwN6 oh3Q== X-Gm-Message-State: AO0yUKUnXF2+mu4Ucj0jwvx66TK8Jn/RbPu4D0sYeKERyuTbd+LkIof+ bBYF5F36c3eQuSgKkABbfK9O7oAb0SM= X-Google-Smtp-Source: AK7set89soqW6SCSn+NEh0MYIe7rVgsb2Yy+NiclJdbVudF8KIyNq9T+kTD9rSkkGKbjqzkuQqtceQ== X-Received: by 2002:a05:622a:18a1:b0:3bf:a3d0:9023 with SMTP id v33-20020a05622a18a100b003bfa3d09023mr14468192qtc.5.1677712038629; Wed, 01 Mar 2023 15:07:18 -0800 (PST) Received: from dhcp-10-231-55-133.dhcp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j9-20020ac85509000000b003b86b99690fsm9047572qtq.62.2023.03.01.15.07.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2023 15:07:18 -0800 (PST) From: Justin Tee To: linux-scsi@vger.kernel.org Cc: jsmart2021@gmail.com, justin.tee@broadcom.com, Justin Tee Subject: [PATCH 03/10] lpfc: Fix lockdep warning for rx_monitor lock when unloading driver Date: Wed, 1 Mar 2023 15:16:19 -0800 Message-Id: <20230301231626.9621-4-justintee8345@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230301231626.9621-1-justintee8345@gmail.com> References: <20230301231626.9621-1-justintee8345@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Lockdep enabled kernels report a theoretical deadlock state where the cmf_timer interrupt occurs while the rx_monitor ring is being destroyed. During rmmod, the cmf_timer is cancelled prior to the lpfc_rx_monitor_destroy_ring call. This actually eliminates the need to take the rx_monitor ring lock in lpfc_rx_monitor_destroy_ring. Thus, just remove lock/unlock of rx_monitor in lpfc_rx_monitor_destroy_ring. Signed-off-by: Justin Tee --- drivers/scsi/lpfc/lpfc_sli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index bfab1f0fb3f0..c8b4632e3dd4 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -8080,16 +8080,16 @@ int lpfc_rx_monitor_create_ring(struct lpfc_rx_info_monitor *rx_monitor, /** * lpfc_rx_monitor_destroy_ring - Free ring buffer for rx_monitor * @rx_monitor: Pointer to lpfc_rx_info_monitor object + * + * Called after cancellation of cmf_timer. **/ void lpfc_rx_monitor_destroy_ring(struct lpfc_rx_info_monitor *rx_monitor) { - spin_lock(&rx_monitor->lock); kfree(rx_monitor->ring); rx_monitor->ring = NULL; rx_monitor->entries = 0; rx_monitor->head_idx = 0; rx_monitor->tail_idx = 0; - spin_unlock(&rx_monitor->lock); } /** From patchwork Wed Mar 1 23:16:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tee X-Patchwork-Id: 658056 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36C43C7EE30 for ; Wed, 1 Mar 2023 23:07:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229629AbjCAXHY (ORCPT ); Wed, 1 Mar 2023 18:07:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbjCAXHW (ORCPT ); Wed, 1 Mar 2023 18:07:22 -0500 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2D28532BD for ; Wed, 1 Mar 2023 15:07:21 -0800 (PST) Received: by mail-qt1-x82c.google.com with SMTP id cf14so16214265qtb.10 for ; Wed, 01 Mar 2023 15:07:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677712041; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HManWOjPmFUq2jVBu5Nnyv5SDU2R/VQCUqB9Sa7inlM=; b=e2abyrabU3jk9rbp2/jG1e5AXL7bo6o7CJUO+lDsw4PwIw2QAfHwB0O7bWStMdLu7Y rjPUZTNZhwh4IseypT2Eq3v96WlRB4PWK9QCptce1P0pxaFqDfrQylPU6EzZX2CjxNBd agt3w/6GwESqW7vD0ljwtkKUDjNPteUN+4ZE7cZT5ldIdtyJAPdRAKWJg+GdQNxvZsF4 7+gEPpKQixdcvz28Opz8qUzjrW173IsprGO/7gG4a+Pw/RGdGgxh8rS9HDfBaPuDMG8H luVj+s9CWFHcTVFnbh3YBSFJ6Nv2tKg4tP1rOgzeNv+VBCfm5GdqrK0XKI7jL0hoXB3S ai7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677712041; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HManWOjPmFUq2jVBu5Nnyv5SDU2R/VQCUqB9Sa7inlM=; b=lUOS0d8WmF+BXocj88QHEd4FRJNOO6+iBH4ir3WP0EBH9YFe/neB0q+MUhDxsAd+cd I6kM0wn5ZJaamq9WRB/1sBfTSDIChx8BEmqzthl/a0eZAnjLsFmZMTem058jpo8/cIpb OM9hPfZzFiu28awnMgwCW+NQFpyTqIIQ/TtKIEAo/+4yscAvDk40t8Yh2aGO3+OePWJa ohixWehFKln6jAlAkgB1D/6WTu5kTii/z2vWEeq5hM5Edz1su3LXf3nHfXpZL41mJB4C avAHoWZIMEmp8DgTHDuoVBysSc+vu0iVBmUqXc2VTFK+k6F6NYCV7Dwfl/R/qe8bAe9y rIgA== X-Gm-Message-State: AO0yUKXgS+HHBccimSYg6ERMoL5un+1V1+mcLuJ7ztNobIaA254/TpDZ Qo6K7YltVBr6/xeiT9n9lHfGiQD4VQE= X-Google-Smtp-Source: AK7set89gM0u9TPC/vt9HKcd8/vrDEPuPcRZCawrTmHZWrYk2ZrSb8AtRDjZJ1olJ7LuhUWoPvkv+Q== X-Received: by 2002:ac8:5c86:0:b0:3b6:309e:dfe1 with SMTP id r6-20020ac85c86000000b003b6309edfe1mr15763675qta.3.1677712041178; Wed, 01 Mar 2023 15:07:21 -0800 (PST) Received: from dhcp-10-231-55-133.dhcp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j9-20020ac85509000000b003b86b99690fsm9047572qtq.62.2023.03.01.15.07.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2023 15:07:20 -0800 (PST) From: Justin Tee To: linux-scsi@vger.kernel.org Cc: jsmart2021@gmail.com, justin.tee@broadcom.com, Justin Tee Subject: [PATCH 04/10] lpfc: Record LOGO state with discovery engine even if aborted Date: Wed, 1 Mar 2023 15:16:20 -0800 Message-Id: <20230301231626.9621-5-justintee8345@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230301231626.9621-1-justintee8345@gmail.com> References: <20230301231626.9621-1-justintee8345@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org A target vendor array reboot in P2P topology can sometimes result in unsuccessful rediscovery. Rework the lpfc_cmpl_els_logo routine such that when the LOGO completes as a failure because of driver abort, the LOGO state is still recorded with the discovery state machine. This is a small rework to set LOGO completion without forcing a device removal state change. Signed-off-by: Justin Tee --- drivers/scsi/lpfc/lpfc_els.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 35b252f1ef73..459e50836853 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -3037,15 +3037,16 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, ndlp->nlp_DID, ulp_status, ulp_word4); - if (lpfc_error_lost_link(ulp_status, ulp_word4)) { + if (lpfc_error_lost_link(ulp_status, ulp_word4)) skip_recovery = 1; - goto out; - } } /* Call state machine. This will unregister the rpi if needed. */ lpfc_disc_state_machine(vport, ndlp, cmdiocb, NLP_EVT_CMPL_LOGO); + if (skip_recovery) + goto out; + /* The driver sets this flag for an NPIV instance that doesn't want to * log into the remote port. */ From patchwork Wed Mar 1 23:16:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tee X-Patchwork-Id: 658377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4197AC678D4 for ; Wed, 1 Mar 2023 23:07:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229673AbjCAXH3 (ORCPT ); Wed, 1 Mar 2023 18:07:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbjCAXHZ (ORCPT ); Wed, 1 Mar 2023 18:07:25 -0500 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A426B51FB0 for ; Wed, 1 Mar 2023 15:07:23 -0800 (PST) Received: by mail-qt1-x836.google.com with SMTP id d7so16190134qtr.12 for ; Wed, 01 Mar 2023 15:07:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677712043; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L+FbzE3d4VkAbn1mH30ojxXllj1qg8tDcoBi1dQjlTQ=; b=Ol5vv3xVw9lj2S7kRjFZURkL8Bykla0Jka3PzI11Kay65JYlT69vdjcDephFqWdA4l RHootngGgqRRDuIP+oadPGYVSO0QR+h7CYAl03YhlDTbNriLRCwkvO8imFtd9bcc3XyM zinqYk3/lFmaVtc4IEir3gpBKWz1ixv8DTO2bd4Bwxs5H2vjxEx23H8NxHBdZImunPwr Xd3G/LkW3F3moUrXZ/W/qlsneRmRQqLhTkW9r2z97sCKCbAtBoYIx2FEa4bQq6cS9zxp wvMGMqd2yl3ZLcEKIFqvBal0UBSEk13Wenr4E2TZMJIPC5/HS6EImcsDPyWXWsZGkpxk UXaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677712043; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L+FbzE3d4VkAbn1mH30ojxXllj1qg8tDcoBi1dQjlTQ=; b=wznCeUr7xfuDco/GPZj/8FKwisgBCPyI2bvF7XO6eQ9QiqahcQunYSh+DMm7UM2N49 tNkraOgHx7C5N6YXyqZcdelTjRE0uYZMKZsgI4m32X2EulAepanF/MScDIw1LP66Df0G uGoh+wh5UzPwOkEecjJUvvMk90redQVp8TND+IViBX/YaFQGBVCtbISe5JapEvvGSe3K fIZmBOkyO5QeQdykMkj3Yfm/sFc0LXq4bK1Op9GwnFcOPf1liFuMRNBLrSvKl4DL/Pj/ yVTdxqlU54KdtUaLrhwlQjC8x0+KvNMzDOBSuR03bAAe6qwjk9tk9yJW61NkzQVQ3q5J oeBw== X-Gm-Message-State: AO0yUKVzU+qFswz+7x3e9yCN72spUvYHJD3aoaTnKW6WYmnWjEX1cY9v yrgX9UNL4HKaxYEdzjSNpRcSQqpCVjw= X-Google-Smtp-Source: AK7set8bdhVGD/oiJsq9dtWiTBQa9QoDm1YFiMd3422cJnHj3IjtSc9LLTwbThupf00L3wOmDCRT3w== X-Received: by 2002:a05:622a:1a2a:b0:3bd:d8f:2da9 with SMTP id f42-20020a05622a1a2a00b003bd0d8f2da9mr16395330qtb.2.1677712043201; Wed, 01 Mar 2023 15:07:23 -0800 (PST) Received: from dhcp-10-231-55-133.dhcp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j9-20020ac85509000000b003b86b99690fsm9047572qtq.62.2023.03.01.15.07.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2023 15:07:22 -0800 (PST) From: Justin Tee To: linux-scsi@vger.kernel.org Cc: jsmart2021@gmail.com, justin.tee@broadcom.com, Justin Tee Subject: [PATCH 05/10] lpfc: Defer issuing new PLOGI if received RSCN before completing REG_LOGIN Date: Wed, 1 Mar 2023 15:16:21 -0800 Message-Id: <20230301231626.9621-6-justintee8345@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230301231626.9621-1-justintee8345@gmail.com> References: <20230301231626.9621-1-justintee8345@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org When mapped to a target with multiple virtual ports, a link bounce sometimes results in unsuccessful rediscovery of all of the target's virtual ports. This is because a succession of repeat RSCNs for the virtual target ports leaves ndlps in the REG_LOGIN state with the NLP_REG_LOGIN_SEND flag set. With NLP_REG_LOGIN_SEND set, during the next PLOGI, the driver will UNREG_RPI. When UNREG_RPI is processed, the driver can be in the middle of PRLI_ISSUE or MAPPED state resulting in an illegal state transition by the discovery engine and stalling. Fix by calling the discovery state machine with DEVICE_RECOVERY event during RSCN processing. This will set the NLP_IGNR_REG_CMPL bit and prevent the old REG_LOGIN state from advancing. Then for the new PLOGI issue, add the check for the NLP_IGNR_REG_CMPL bit to delay issuing the new PLOGI until the queued REG_LOGIN and UNREG_LOGIN have been processed. Signed-off-by: Justin Tee --- drivers/scsi/lpfc/lpfc_els.c | 7 ++++--- drivers/scsi/lpfc/lpfc_hbadisc.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 459e50836853..0342e8cdcc9e 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -2208,14 +2208,15 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) * outstanding UNREG_RPI mbox command completes, unless we * are going offline. This logic does not apply for Fabric DIDs */ - if ((ndlp->nlp_flag & NLP_UNREG_INP) && + if ((ndlp->nlp_flag & (NLP_IGNR_REG_CMPL | NLP_UNREG_INP)) && ((ndlp->nlp_DID & Fabric_DID_MASK) != Fabric_DID_MASK) && !(vport->fc_flag & FC_OFFLINE_MODE)) { lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, "4110 Issue PLOGI x%x deferred " - "on NPort x%x rpi x%x Data: x%px\n", + "on NPort x%x rpi x%x flg x%x Data:" + " x%px\n", ndlp->nlp_defer_did, ndlp->nlp_DID, - ndlp->nlp_rpi, ndlp); + ndlp->nlp_rpi, ndlp->nlp_flag, ndlp); /* We can only defer 1st PLOGI */ if (ndlp->nlp_defer_did == NLP_EVT_NOTHING_PENDING) diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 66cd0b1dbbd0..11ba26ac495a 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -5755,8 +5755,8 @@ lpfc_setup_disc_node(struct lpfc_vport *vport, uint32_t did) (NLP_FCP_TARGET | NLP_NVME_TARGET))) return NULL; - ndlp->nlp_prev_state = ndlp->nlp_state; - lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); + lpfc_disc_state_machine(vport, ndlp, NULL, + NLP_EVT_DEVICE_RECOVERY); spin_lock_irq(&ndlp->lock); ndlp->nlp_flag |= NLP_NPR_2B_DISC; From patchwork Wed Mar 1 23:16:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tee X-Patchwork-Id: 658055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C796AC7EE23 for ; Wed, 1 Mar 2023 23:07:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229636AbjCAXHa (ORCPT ); Wed, 1 Mar 2023 18:07:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbjCAXH2 (ORCPT ); Wed, 1 Mar 2023 18:07:28 -0500 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 106B255069 for ; Wed, 1 Mar 2023 15:07:26 -0800 (PST) Received: by mail-qt1-x82e.google.com with SMTP id z6so16349128qtv.0 for ; Wed, 01 Mar 2023 15:07:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677712045; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2OV29THXOZY2edWcUqqWsKITaN7ZDlRq/tj62pWhmxo=; b=BM6qPGju7uZG4wGF0lrWEGqdCMKbBCpcpOmlf7yCoZWf5bthggId9Z+1bIqggtHVEb fqzjdNSV8PsChrbj+w3kN+ncv5C3984PLsq5xwQgaH1omeqYHaGZyNAfsno21zduB3oy K1WCtLypEMNt3uRM5OoKK6E/u2sjAnFTkY5ZbFui0vjXq6YeFyfYSlxFfA+kNPu36el1 RFmEURCt0Wuhju/V47x7AHkX/SDWwNIisrCNFaUCKWAgNTlW/bwiUhtF7Z0mNI2JmioO p+UgvuFpusiZcpA/uOKlTjv5wZxhduXbeFL538Mh1r7vBZT+/8hd0jUkUwWjPXHi/mvk TjsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677712045; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2OV29THXOZY2edWcUqqWsKITaN7ZDlRq/tj62pWhmxo=; b=XwaU8v7477VLJBApKT6LzqwR6LiTOteSbRjXwNQpBamZnvscfFRPpcF3fa8WI5ENbQ mnvLYfgv6RMwPuV+/NJX81TPAsJ/NJ3H+JpMj3dv370iYwOpMIdkgy7F0jh4G4Vjg5uo PsqyTBH9PmJ/rSAri+jKzG3uzGYDf7hO7OH8TWFAEx8u0LBw9KF12qsW74lzMMMy2LPP SX+KtvCgYaAPeCU7LzJjR6CSvSdAF4H2DsEITQSVTc348jILqjcmzAvzOF+GVfSAcwHB dkLl24BoZHZmhkngGNvUESpAi/c9+aqiivQYckksGs3oaZ2jXckcePTPRQejhQ++fj/o Wo0w== X-Gm-Message-State: AO0yUKXg+LRHq68kjsEwLNQ/vJmJ8O8kpE38Z7UUAP+zTZXM+eMBayrF 4XbpO5QEMsss4c89zm0nHnzVSIdnUro= X-Google-Smtp-Source: AK7set+ZB+o8o7ec4IL1NA/YpXu9B0HuEvhCqt/7kDu7SpC15NtrBqsLiIZPIvTM93u6HxPI74o+Gw== X-Received: by 2002:a05:622a:15d4:b0:3b9:a4d4:7f37 with SMTP id d20-20020a05622a15d400b003b9a4d47f37mr15288995qty.3.1677712045096; Wed, 01 Mar 2023 15:07:25 -0800 (PST) Received: from dhcp-10-231-55-133.dhcp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j9-20020ac85509000000b003b86b99690fsm9047572qtq.62.2023.03.01.15.07.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2023 15:07:24 -0800 (PST) From: Justin Tee To: linux-scsi@vger.kernel.org Cc: jsmart2021@gmail.com, justin.tee@broadcom.com, Justin Tee Subject: [PATCH 06/10] lpfc: Correct used_rpi count when devloss tmo fires with no recovery Date: Wed, 1 Mar 2023 15:16:22 -0800 Message-Id: <20230301231626.9621-7-justintee8345@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230301231626.9621-1-justintee8345@gmail.com> References: <20230301231626.9621-1-justintee8345@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org A fabric controller can sometimes send an RDP request right before a link down event. Because of this outstanding RDP request, the driver does not remove the last reference count on its ndlp causing a potential leak of RPI resources when devloss tmo fires. In lpfc_cmpl_els_rsp, modify the NPIV clause to always allow the lpfc_drop_node routine to execute when not registered with SCSI transport. This relaxes the contraint that an NPIV ndlp must be in a specific state in order to call lpfc_drop node. Logic is revised such that the lpfc_drop_node routine is always called to ensure the last ndlp decrement occurs. Signed-off-by: Justin Tee --- drivers/scsi/lpfc/lpfc_els.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 0342e8cdcc9e..9f50f6116627 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -5457,18 +5457,20 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, * these conditions and release the RPI. */ if (phba->sli_rev == LPFC_SLI_REV4 && - (vport && vport->port_type == LPFC_NPIV_PORT) && - !(ndlp->fc4_xpt_flags & SCSI_XPT_REGD) && - ndlp->nlp_flag & NLP_RELEASE_RPI) { - if (ndlp->nlp_state != NLP_STE_PLOGI_ISSUE && - ndlp->nlp_state != NLP_STE_REG_LOGIN_ISSUE) { - lpfc_sli4_free_rpi(phba, ndlp->nlp_rpi); - spin_lock_irq(&ndlp->lock); - ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR; - ndlp->nlp_flag &= ~NLP_RELEASE_RPI; - spin_unlock_irq(&ndlp->lock); - lpfc_drop_node(vport, ndlp); + vport && vport->port_type == LPFC_NPIV_PORT && + !(ndlp->fc4_xpt_flags & SCSI_XPT_REGD)) { + if (ndlp->nlp_flag & NLP_RELEASE_RPI) { + if (ndlp->nlp_state != NLP_STE_PLOGI_ISSUE && + ndlp->nlp_state != NLP_STE_REG_LOGIN_ISSUE) { + lpfc_sli4_free_rpi(phba, ndlp->nlp_rpi); + spin_lock_irq(&ndlp->lock); + ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR; + ndlp->nlp_flag &= ~NLP_RELEASE_RPI; + spin_unlock_irq(&ndlp->lock); + } } + + lpfc_drop_node(vport, ndlp); } /* Release the originating I/O reference. */ From patchwork Wed Mar 1 23:16:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tee X-Patchwork-Id: 658376 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D53EC7EE30 for ; Wed, 1 Mar 2023 23:07:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229629AbjCAXHb (ORCPT ); Wed, 1 Mar 2023 18:07:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbjCAXH3 (ORCPT ); Wed, 1 Mar 2023 18:07:29 -0500 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1313E532BD for ; Wed, 1 Mar 2023 15:07:28 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id c3so11966687qtc.8 for ; Wed, 01 Mar 2023 15:07:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677712047; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eUFfC/BQFxsF2xQOSvo1rTHxeOp4p0RpbXqkeMxYikg=; b=gbxZATYbrsIs5bNL/rrKPGjRrMPzUo5xLVpfESgfZNy0l3bJSFgCJi8Cv6VuFXAF5V fhV2feWACoftff0VZFHi5mVZcgZtVKte1E7rjD/huUQulxiTl/jRfxBOH1XAz90YRJ9P hWzjCAYmgsf+zFNAPMQ67LoicLtnQOtPUiWVIjWasePjzJihgBL3AWOZxVnMq5W9ykx/ 7kxs9dLGAyiaLRH2fzvlA2oNwuc7DoP5CLTTyk8oEpaP0lw6QyiPxHp+gxmuxJha9dBa vEtDqXPQ8I9nTT52M8EGG+/qsEg+NWWInIZxPKyCwIiigDTzbkNALiVkqX0SmiPlp/Lm v5mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677712047; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eUFfC/BQFxsF2xQOSvo1rTHxeOp4p0RpbXqkeMxYikg=; b=rXmyIpmrq8porLREWsHsl77tz0yumxUK/+cCyRTLZ3Zc/lg005du02LWD62DSQQkfH +fv9fMYtSId8zrSU9sDbuqTG/njpsrCR/C0pEIW9M2HUrG9Rr6me8yndtSAsJeMOTa+u iRKdUO/oG88LV3ZalD5Mmli0SquO9yoY5SJ9yhnIlK7j4eqEuwHiXf7tSeqwbATqUONG mskvaCKvJb7qfBJ12zZistBvjVMC8Rbe4YsQ+eSqbaGry5W7Zp+5hZc1DBFrhfMLTIUk qpyKIhcCLVl4/w7i1ZKKOmUC6o++5okBVGm0zRAqnagS/ZbJVKVw+K7m9YvIYCcg4+DR 2NQQ== X-Gm-Message-State: AO0yUKU9UFsyB8dYFRa6anz3UTngLJBBwEezQe5DCE3qSeiN2Al2vhs6 45eaMO0b7DIdKU7GfIOdSvXzppNkcyU= X-Google-Smtp-Source: AK7set9i9wv/LnYxc7bw8LkLFQEndwi+lKIrXB40Jx1Iwl0h5PlsbpUxYW8BXCED5W/CDJwUjppqZA== X-Received: by 2002:a05:622a:1448:b0:3bf:bfde:91bd with SMTP id v8-20020a05622a144800b003bfbfde91bdmr16189215qtx.5.1677712047024; Wed, 01 Mar 2023 15:07:27 -0800 (PST) Received: from dhcp-10-231-55-133.dhcp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j9-20020ac85509000000b003b86b99690fsm9047572qtq.62.2023.03.01.15.07.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2023 15:07:26 -0800 (PST) From: Justin Tee To: linux-scsi@vger.kernel.org Cc: jsmart2021@gmail.com, justin.tee@broadcom.com, Justin Tee Subject: [PATCH 07/10] lpfc: Skip waiting for register ready bits when in unrecoverable state Date: Wed, 1 Mar 2023 15:16:23 -0800 Message-Id: <20230301231626.9621-8-justintee8345@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230301231626.9621-1-justintee8345@gmail.com> References: <20230301231626.9621-1-justintee8345@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org During tolerance tests that force an HBA to become unresponsive, rmmod hangs resulting in the inability to remove the driver. The lpfc_pci_remove_one_s4 routine attempts to submit a clean up mailbox command via the lpfc_sli4_post_sync_mbox routine, but ends up waiting forever for a mailbox register to set its ready bit. Because the HBA is in an unrecoverable and unresponsive state, the ready bit will never be set. Create a new routine called lpfc_sli4_unrecoverable_port, which checks a port status register's error notification bits. Use the lpfc_sli4_unrecoverable_port routine in ready bit check routines to early return error if port is deemed unrecoverable. Also, when the lpfc_handle_eratt_s4 handler detects an unrecoverable state, call the lpfc_sli4_offline_eratt routine to kick off flushing outstanding I/O. Signed-off-by: Justin Tee --- drivers/scsi/lpfc/lpfc_attr.c | 6 ++++++ drivers/scsi/lpfc/lpfc_init.c | 5 ++--- drivers/scsi/lpfc/lpfc_nvme.c | 4 +++- drivers/scsi/lpfc/lpfc_sli.c | 20 +++++++++++++++++++- drivers/scsi/lpfc/lpfc_sli4.h | 19 +++++++++++++++++++ 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 22f2e046e8eb..ddbc54e8bcfd 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -1644,6 +1644,12 @@ lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *phba) !bf_get(lpfc_sliport_status_err, &portstat_reg)) return -EPERM; + /* There is no point to wait if the port is in an unrecoverable + * state. + */ + if (lpfc_sli4_unrecoverable_port(&portstat_reg)) + return -EIO; + /* wait for the SLI port firmware ready after firmware reset */ for (i = 0; i < LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT; i++) { msleep(10); diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 75737088d011..5b30e71dc926 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -2147,7 +2147,7 @@ lpfc_handle_eratt_s4(struct lpfc_hba *phba) /* fall through for not able to recover */ lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, "3152 Unrecoverable error\n"); - phba->link_state = LPFC_HBA_ERROR; + lpfc_sli4_offline_eratt(phba); break; case LPFC_SLI_INTF_IF_TYPE_1: default: @@ -9566,8 +9566,7 @@ lpfc_sli4_post_status_check(struct lpfc_hba *phba) /* Final checks. The port status should be clean. */ if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, ®_data.word0) || - (bf_get(lpfc_sliport_status_err, ®_data) && - !bf_get(lpfc_sliport_status_rn, ®_data))) { + lpfc_sli4_unrecoverable_port(®_data)) { phba->work_status[0] = readl(phba->sli4_hba.u.if_type2. ERR1regaddr); diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c index 152245f7cacc..ae3207e73113 100644 --- a/drivers/scsi/lpfc/lpfc_nvme.c +++ b/drivers/scsi/lpfc/lpfc_nvme.c @@ -2265,6 +2265,7 @@ lpfc_nvme_lport_unreg_wait(struct lpfc_vport *vport, } if (!vport->localport || test_bit(HBA_PCI_ERR, &vport->phba->bit_flags) || + phba->link_state == LPFC_HBA_ERROR || vport->load_flag & FC_UNLOADING) return; @@ -2630,7 +2631,8 @@ lpfc_nvme_unregister_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) * return values is ignored. The upcall is a courtesy to the * transport. */ - if (vport->load_flag & FC_UNLOADING) + if (vport->load_flag & FC_UNLOADING || + unlikely(vport->phba->link_state == LPFC_HBA_ERROR)) (void)nvme_fc_set_remoteport_devloss(remoteport, 0); ret = nvme_fc_unregister_remoteport(remoteport); diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index c8b4632e3dd4..b4917db6e532 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -9895,7 +9895,8 @@ lpfc_sli4_async_mbox_unblock(struct lpfc_hba *phba) * port for twice the regular mailbox command timeout value. * * 0 - no timeout on waiting for bootstrap mailbox register ready. - * MBXERR_ERROR - wait for bootstrap mailbox register timed out. + * MBXERR_ERROR - wait for bootstrap mailbox register timed out or port + * is in an unrecoverable state. **/ static int lpfc_sli4_wait_bmbx_ready(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) @@ -9903,6 +9904,23 @@ lpfc_sli4_wait_bmbx_ready(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) uint32_t db_ready; unsigned long timeout; struct lpfc_register bmbx_reg; + struct lpfc_register portstat_reg = {-1}; + + /* Sanity check - there is no point to wait if the port is in an + * unrecoverable state. + */ + if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= + LPFC_SLI_INTF_IF_TYPE_2) { + if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, + &portstat_reg.word0) || + lpfc_sli4_unrecoverable_port(&portstat_reg)) { + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, + "3858 Skipping bmbx ready because " + "Port Status x%x\n", + portstat_reg.word0); + return MBXERR_ERROR; + } + } timeout = msecs_to_jiffies(lpfc_mbox_tmo_val(phba, mboxq) * 1000) + jiffies; diff --git a/drivers/scsi/lpfc/lpfc_sli4.h b/drivers/scsi/lpfc/lpfc_sli4.h index 3b62c4032c31..2a0864e6d7cd 100644 --- a/drivers/scsi/lpfc/lpfc_sli4.h +++ b/drivers/scsi/lpfc/lpfc_sli4.h @@ -1180,3 +1180,22 @@ static inline void *lpfc_sli4_qe(struct lpfc_queue *q, uint16_t idx) return q->q_pgs[idx / q->entry_cnt_per_pg] + (q->entry_size * (idx % q->entry_cnt_per_pg)); } + +/** + * lpfc_sli4_unrecoverable_port - Check ERR and RN bits in portstat_reg + * @portstat_reg: portstat_reg pointer containing portstat_reg contents + * + * Description: + * Use only for SLI4 interface type-2 or later. If ERR is set && RN is 0, then + * port is deemed unrecoverable. + * + * Returns: + * true - ERR && !RN + * false - otherwise + */ +static inline bool +lpfc_sli4_unrecoverable_port(struct lpfc_register *portstat_reg) +{ + return bf_get(lpfc_sliport_status_err, portstat_reg) && + !bf_get(lpfc_sliport_status_rn, portstat_reg); +} From patchwork Wed Mar 1 23:16:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tee X-Patchwork-Id: 658054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1263C7EE23 for ; Wed, 1 Mar 2023 23:07:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229929AbjCAXHm (ORCPT ); Wed, 1 Mar 2023 18:07:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbjCAXHd (ORCPT ); Wed, 1 Mar 2023 18:07:33 -0500 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E846556501 for ; Wed, 1 Mar 2023 15:07:30 -0800 (PST) Received: by mail-qt1-x830.google.com with SMTP id l18so15180229qtp.1 for ; Wed, 01 Mar 2023 15:07:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677712050; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4NuW/fyBX5PvRhWHd/VY/4AadEIaueL9fCOPZtAPXjM=; b=aGC/c5Y5djl40XdnKpP9RQu275cv+fS5OFsWd51LLP5vYDrcElvgstVAUQP+zpp7Yr oh6XYOzi+I6jRq5g9XwyIuIbG2wFqJsKFvWj6Kra4uvN7yDfgVdM+luMrMGqBrqYVqyx edp2mlu7F/kxA46TxzQz8FedANNQEL18w5gxQYaBsqq3xekdaq+9qU8bUfqwE4JWXc5t 4dlB1FRnEnenDvLI9WfbMwMCPj7cY8Djq8409R4nq9mES7YbTZ7yRpMFklLX9NZpz8h/ Ix+i3bhaHpj2L24OptMM72cy1W6jFp1kyW8tvJdX1tYO7vXmmn4AEcU+Ofp9Ds2NAi6I Z0vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677712050; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4NuW/fyBX5PvRhWHd/VY/4AadEIaueL9fCOPZtAPXjM=; b=PwJ/HXCCI6YDn4751+Uaxr2bHRu4E+F7OZSMgn0xsWSxUr+7c4T+vQHYLDM0A564dP SkmfjcPDk6POsiz5LTmbIR/MGNzQyDtKFO5iQEDs6g3Y7yVR6nHBH/AeNDVLHfFFXYDJ SVWTOdO676VyG0zdx+uzVvfu4Fp72edpH1ncsqAs2wn0cxWcU8FwktJyaHk/TKafSL9m qdWu2Z+Woo8w32LiCAORUB/hzWnNXLdUIlvN0Op6811B4rloFaabL6UBBOd2OYgRGGc3 35PUq7Coc/OQ3lZZD1E0gXiuQKUDG0ysbJgCJ8cTokjdjceXUK+qxcsrMLcRGUkB//86 GL4A== X-Gm-Message-State: AO0yUKUyA7sJwFMRame5GKa9UcslyToTuHGqBQkM89znBOeKJN3HHLm8 +f75T7D54ANNPREMXI0ufohzwEZg0yk= X-Google-Smtp-Source: AK7set9rj/WlBq1QudITm99Cm5zFstKVdBLAJ69dyvrCQ2HGabyQtQSCgz4jvHmYqAXOZJP4JM/0kg== X-Received: by 2002:ac8:5c86:0:b0:3bf:b0c6:497b with SMTP id r6-20020ac85c86000000b003bfb0c6497bmr16155956qta.2.1677712049722; Wed, 01 Mar 2023 15:07:29 -0800 (PST) Received: from dhcp-10-231-55-133.dhcp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j9-20020ac85509000000b003b86b99690fsm9047572qtq.62.2023.03.01.15.07.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2023 15:07:29 -0800 (PST) From: Justin Tee To: linux-scsi@vger.kernel.org Cc: jsmart2021@gmail.com, justin.tee@broadcom.com, Justin Tee Subject: [PATCH 08/10] lpfc: Revise lpfc_error_lost_link reason code evaluation logic Date: Wed, 1 Mar 2023 15:16:24 -0800 Message-Id: <20230301231626.9621-9-justintee8345@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230301231626.9621-1-justintee8345@gmail.com> References: <20230301231626.9621-1-justintee8345@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Extended status reason code errors should mask off the IOERR_PARAM_MASK before checking strict equalities for IOERR values. Update the lpfc_error_lost_link routine as such. Signed-off-by: Justin Tee --- drivers/scsi/lpfc/lpfc_crtn.h | 2 ++ drivers/scsi/lpfc/lpfc_ct.c | 4 ++-- drivers/scsi/lpfc/lpfc_els.c | 14 ++++++------- drivers/scsi/lpfc/lpfc_hbadisc.c | 35 ++++++++++++++++++++++++++++++++ drivers/scsi/lpfc/lpfc_hw.h | 12 ----------- 5 files changed, 46 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h index 976fd5ee7f7e..b833b983e69d 100644 --- a/drivers/scsi/lpfc/lpfc_crtn.h +++ b/drivers/scsi/lpfc/lpfc_crtn.h @@ -458,6 +458,8 @@ void lpfc_get_cfgparam(struct lpfc_hba *); void lpfc_get_vport_cfgparam(struct lpfc_vport *); int lpfc_alloc_sysfs_attr(struct lpfc_vport *); void lpfc_free_sysfs_attr(struct lpfc_vport *); +bool lpfc_error_lost_link(struct lpfc_vport *vport, u32 ulp_status, + u32 ulp_word4); extern const struct attribute_group *lpfc_hba_groups[]; extern const struct attribute_group *lpfc_vport_groups[]; extern struct scsi_host_template lpfc_template; diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index e290aff2e881..c6e10e23f342 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -958,7 +958,7 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, lpfc_vport_set_state(vport, FC_VPORT_FAILED); goto out; } - if (lpfc_error_lost_link(ulp_status, ulp_word4)) { + if (lpfc_error_lost_link(vport, ulp_status, ulp_word4)) { lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, "0226 NS query failed due to link event: " "ulp_status x%x ulp_word4 x%x fc_flag x%x " @@ -1181,7 +1181,7 @@ lpfc_cmpl_ct_cmd_gid_pt(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, lpfc_vport_set_state(vport, FC_VPORT_FAILED); goto out; } - if (lpfc_error_lost_link(ulp_status, ulp_word4)) { + if (lpfc_error_lost_link(vport, ulp_status, ulp_word4)) { lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, "4166 NS query failed due to link event: " "ulp_status x%x ulp_word4 x%x fc_flag x%x " diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 9f50f6116627..6a15f879e517 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -1088,7 +1088,7 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, } /* Do not register VFI if the driver aborted FLOGI */ - if (!lpfc_error_lost_link(ulp_status, ulp_word4)) + if (!lpfc_error_lost_link(vport, ulp_status, ulp_word4)) lpfc_issue_reg_vfi(vport); lpfc_nlp_put(ndlp); @@ -1207,7 +1207,7 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, phba->fcf.fcf_flag &= ~FCF_DISCOVERY; spin_unlock_irq(&phba->hbalock); - if (!lpfc_error_lost_link(ulp_status, ulp_word4)) { + if (!lpfc_error_lost_link(vport, ulp_status, ulp_word4)) { /* FLOGI failed, so just use loop map to make discovery list */ lpfc_disc_list_loopmap(vport); @@ -2087,7 +2087,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, ulp_word4); /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ - if (!lpfc_error_lost_link(ulp_status, ulp_word4)) + if (!lpfc_error_lost_link(vport, ulp_status, ulp_word4)) lpfc_disc_state_machine(vport, ndlp, cmdiocb, NLP_EVT_CMPL_PLOGI); @@ -2383,7 +2383,7 @@ lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, ndlp->fc4_prli_sent); /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ - if (!lpfc_error_lost_link(ulp_status, ulp_word4)) + if (!lpfc_error_lost_link(vport, ulp_status, ulp_word4)) lpfc_disc_state_machine(vport, ndlp, cmdiocb, NLP_EVT_CMPL_PRLI); @@ -3038,7 +3038,7 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, ndlp->nlp_DID, ulp_status, ulp_word4); - if (lpfc_error_lost_link(ulp_status, ulp_word4)) + if (lpfc_error_lost_link(vport, ulp_status, ulp_word4)) skip_recovery = 1; } @@ -4930,7 +4930,7 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, if ((cmd == ELS_CMD_FLOGI) && (phba->fc_topology != LPFC_TOPOLOGY_LOOP) && - !lpfc_error_lost_link(ulp_status, ulp_word4)) { + !lpfc_error_lost_link(vport, ulp_status, ulp_word4)) { /* FLOGI retry policy */ retry = 1; /* retry FLOGI forever */ @@ -4944,7 +4944,7 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, else if (cmdiocb->retry >= 32) delay = 1000; } else if ((cmd == ELS_CMD_FDISC) && - !lpfc_error_lost_link(ulp_status, ulp_word4)) { + !lpfc_error_lost_link(vport, ulp_status, ulp_word4)) { /* retry FDISCs every second up to devloss */ retry = 1; maxretry = vport->cfg_devloss_tmo; diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 11ba26ac495a..5ba3a9ad9501 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -7269,3 +7269,38 @@ lpfc_parse_fcoe_conf(struct lpfc_hba *phba, lpfc_read_fcf_conn_tbl(phba, rec_ptr); } + +/* + * lpfc_error_lost_link - IO failure from link event or FW reset check. + * + * @vport: Pointer to lpfc_vport data structure. + * @ulp_status: IO completion status. + * @ulp_word4: Reason code for the ulp_status. + * + * This function evaluates the ulp_status and ulp_word4 values + * for specific error values that indicate an internal link fault + * or fw reset event for the completing IO. Callers require this + * common data to decide next steps on the IO. + * + * Return: + * false - No link or reset error occurred. + * true - A link or reset error occurred. + */ +bool +lpfc_error_lost_link(struct lpfc_vport *vport, u32 ulp_status, u32 ulp_word4) +{ + /* Mask off the extra port data to get just the reason code. */ + u32 rsn_code = IOERR_PARAM_MASK & ulp_word4; + + if (ulp_status == IOSTAT_LOCAL_REJECT && + (rsn_code == IOERR_SLI_ABORTED || + rsn_code == IOERR_LINK_DOWN || + rsn_code == IOERR_SLI_DOWN)) { + lpfc_printf_vlog(vport, KERN_WARNING, LOG_SLI | LOG_ELS, + "0408 Report link error true: \n", + ulp_status, ulp_word4); + return true; + } + + return false; +} diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h index 5c283936ff08..e9244bedb0f4 100644 --- a/drivers/scsi/lpfc/lpfc_hw.h +++ b/drivers/scsi/lpfc/lpfc_hw.h @@ -4435,16 +4435,4 @@ lpfc_is_LC_HBA(unsigned short device) return 0; } -/* - * Determine if failed because of a link event or firmware reset. - */ -static inline int -lpfc_error_lost_link(u32 ulp_status, u32 ulp_word4) -{ - return (ulp_status == IOSTAT_LOCAL_REJECT && - (ulp_word4 == IOERR_SLI_ABORTED || - ulp_word4 == IOERR_LINK_DOWN || - ulp_word4 == IOERR_SLI_DOWN)); -} - #define BPL_ALIGN_SZ 8 /* 8 byte alignment for bpl and mbufs */ From patchwork Wed Mar 1 23:16:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Tee X-Patchwork-Id: 658375 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67D0AC678D4 for ; Wed, 1 Mar 2023 23:07:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229696AbjCAXHo (ORCPT ); Wed, 1 Mar 2023 18:07:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229751AbjCAXHd (ORCPT ); Wed, 1 Mar 2023 18:07:33 -0500 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C6625650D for ; Wed, 1 Mar 2023 15:07:32 -0800 (PST) Received: by mail-qt1-x836.google.com with SMTP id l13so16286917qtv.3 for ; Wed, 01 Mar 2023 15:07:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677712051; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J6gvLxOzVNI5Fx692m3rWn9dH/1qatcHRsy6IAsmSMU=; b=eBAPlw29NLhT4NeQXRrb0kpoWgNgrYSsaRJtqZVJch6+3HulH82/zYaKtyv6uCWaay RXzqAW4eUknf/zLnkrE7OWFUh0TqLA+oTNlogEliqBV/p3uaywpC0XvBiCmoEQ8edEVl x8zeooK37t6UPlOpr90CYvM+8V0+U0aCobDvsRJlilFQf7pKezHY6DIcLN4s/+aJpuum Xl4ZjawDy30lURCL5nxx1weDeQQA93N2SNEv79hclx154NzIoYA1nC688oF47o4ObO+z JomsWdFivVCQMTftChN2rYybJ2LIU4g24oHEOzzKRqClO8Qt3XXSMBcrAUAlqI1KGdTz m7dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677712051; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J6gvLxOzVNI5Fx692m3rWn9dH/1qatcHRsy6IAsmSMU=; b=UfCbLT2JG2pm3mBBe1OC+9JPInd/Wtpia1gm+gj8SIBwNTcXyFoL2r+PDiqOYxEB9U cRZychS5krcav9qvuw91O216PWEbM6OgkPoAXB+YA2W31wmMK/uxI9dzByhq5xO1Wa/C udZEw0GIFUqK45sYOlXDFueFpCUTPtPjOdumtBAvF8Kv5OjGF17FnzUcre7rThpY24Ji VtNlgX4FQQ+9btgzhGrNh3xkJgjS47UghvZsOHdpH/ITF8YPDLgN6sctjjKm9XoOdPTG M2WdXlbGT0vseBEx1bh6LW88M7hMw0M27qeEJMuUXmpalwpBqvMB74aSu7K/dvzOzQof VHzQ== X-Gm-Message-State: AO0yUKWb3QCLnBq5jKq0t/AjYuBffqFy9EbFbK/QldITvBqhRYR7cBbH EW4wgdzC4XOMOpTJ0X3YgklNxKzLf2k= X-Google-Smtp-Source: AK7set/gjS6DNVuYhOP8+dVL/jIqnyIXjJ/aMHZXmORRh2T8cRZEoCjQyw1Qxue6a+W0YB5Uu7yL0Q== X-Received: by 2002:a05:622a:1391:b0:3bf:c458:5bac with SMTP id o17-20020a05622a139100b003bfc4585bacmr16252621qtk.0.1677712051679; Wed, 01 Mar 2023 15:07:31 -0800 (PST) Received: from dhcp-10-231-55-133.dhcp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j9-20020ac85509000000b003b86b99690fsm9047572qtq.62.2023.03.01.15.07.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2023 15:07:31 -0800 (PST) From: Justin Tee To: linux-scsi@vger.kernel.org Cc: jsmart2021@gmail.com, justin.tee@broadcom.com, Justin Tee Subject: [PATCH 09/10] lpfc: Update lpfc version to 14.2.0.11 Date: Wed, 1 Mar 2023 15:16:25 -0800 Message-Id: <20230301231626.9621-10-justintee8345@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230301231626.9621-1-justintee8345@gmail.com> References: <20230301231626.9621-1-justintee8345@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Update lpfc version to 14.2.0.11 Signed-off-by: Justin Tee --- drivers/scsi/lpfc/lpfc_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h index 0238208cdd11..c97411b0992e 100644 --- a/drivers/scsi/lpfc/lpfc_version.h +++ b/drivers/scsi/lpfc/lpfc_version.h @@ -20,7 +20,7 @@ * included with this package. * *******************************************************************/ -#define LPFC_DRIVER_VERSION "14.2.0.10" +#define LPFC_DRIVER_VERSION "14.2.0.11" #define LPFC_DRIVER_NAME "lpfc" /* Used for SLI 2/3 */ From patchwork Wed Mar 1 23:16:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Justin Tee X-Patchwork-Id: 658053 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 969C2C7EE33 for ; Wed, 1 Mar 2023 23:07:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229914AbjCAXHp (ORCPT ); Wed, 1 Mar 2023 18:07:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229854AbjCAXHg (ORCPT ); Wed, 1 Mar 2023 18:07:36 -0500 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90E1351FB0 for ; Wed, 1 Mar 2023 15:07:34 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id w23so16249719qtn.6 for ; Wed, 01 Mar 2023 15:07:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677712053; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/UUk9ojxrg7vzWS/4PKV4bYUzOKrLkaKmA1W4GVN9dI=; b=MaPyJgS96UUN0Q+hhhwuDkK2YTQq2ZPyKq2Tn03B7xtxfV6m3To7Pk0Sshzk8aHQnq b8nogqnJ/luLe4/FzFjM4NZkJ/6qk6Q+Bg8Wd71IlpyMFeJdLq8RpfoYV0V0/WXQyN3E bgO0BvqLV7Heq1MCcpv5EsNiebSF2sIaDogJtDZ0XemgaPpsAYZe1gnvSoxfUL2rFGGU S9KIyZ1f2opLBkKQi3wzSVsDFmZ5fWSvjK9hRjqB/ltj9/vIY1WWAiB1T21D0SfeL0Pw KaW8NDhum/gRelmkAzxALxwFRDj1TvbG3EDgB1i/Igfjo06mPD+SulFk4DR7X08QqShV pVxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677712053; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/UUk9ojxrg7vzWS/4PKV4bYUzOKrLkaKmA1W4GVN9dI=; b=bzV/fVlPm9m9WHRnKk5qV1cuxRgwSYokMfsib0AamU0LShe+kVj/OKK4EV+yUwrPKr 90yEh6int+tRr+g6vUgl15A0HdRTfiXsFEALsyLHGu9wVXKl3n2/hYhe9wNo0myVTa4l XUhAq8C1uc0EynkkPU2jl+0YNKPXvtApgMkVVVd0q42vb60ZbaR9+eA+oBX6HHdvgA/H avBAdI1eaBDiB68W31t3jdhFMRndKZbdqW/H4gtUsQ94jIobTGkZLmRc4LA+iH872sD+ 6yV02FAFBib3V+41YK6xl26QD/81P/zDcHEmiwtwJxdf3AtZN/qAogDLXNPRZFKJc5/Q j38g== X-Gm-Message-State: AO0yUKVQ+LmgfwX0p3F3YQK0DAmcEyJnXLTiaHywfj+FKWNoQbElt0na VMpnUNcdE2w1MwJ3ccLCKzYuy+P0vp4= X-Google-Smtp-Source: AK7set9m7GwTqIZ8CriMeEwoInY1TJY7XEq/Ms4BiGdktiOXD2lNmu5NIG0XiXoG/Mk9cn3HBrkphg== X-Received: by 2002:a05:622a:4cb:b0:3bf:d841:f1ee with SMTP id q11-20020a05622a04cb00b003bfd841f1eemr16462167qtx.6.1677712053615; Wed, 01 Mar 2023 15:07:33 -0800 (PST) Received: from dhcp-10-231-55-133.dhcp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j9-20020ac85509000000b003b86b99690fsm9047572qtq.62.2023.03.01.15.07.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2023 15:07:33 -0800 (PST) From: Justin Tee To: linux-scsi@vger.kernel.org Cc: jsmart2021@gmail.com, justin.tee@broadcom.com, Justin Tee Subject: [PATCH 10/10] lpfc: Copyright updates for 14.2.0.11 patches Date: Wed, 1 Mar 2023 15:16:26 -0800 Message-Id: <20230301231626.9621-11-justintee8345@gmail.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230301231626.9621-1-justintee8345@gmail.com> References: <20230301231626.9621-1-justintee8345@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Update copyrights to 2023 for files modified in the 14.2.0.11 patch set. Signed-off-by: Justin Tee --- drivers/scsi/lpfc/lpfc_bsg.c | 2 +- drivers/scsi/lpfc/lpfc_ct.c | 2 +- drivers/scsi/lpfc/lpfc_debugfs.c | 2 +- drivers/scsi/lpfc/lpfc_hw.h | 2 +- drivers/scsi/lpfc/lpfc_nvme.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c index d8e86b468ef6..9a322a3a2150 100644 --- a/drivers/scsi/lpfc/lpfc_bsg.c +++ b/drivers/scsi/lpfc/lpfc_bsg.c @@ -1,7 +1,7 @@ /******************************************************************* * This file is part of the Emulex Linux Device Driver for * * Fibre Channel Host Bus Adapters. * - * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term * + * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * * Copyright (C) 2009-2015 Emulex. All rights reserved. * * EMULEX and SLI are trademarks of Emulex. * diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index c6e10e23f342..f3bdcebe67f5 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -1,7 +1,7 @@ /******************************************************************* * This file is part of the Emulex Linux Device Driver for * * Fibre Channel Host Bus Adapters. * - * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term * + * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * * Copyright (C) 2004-2016 Emulex. All rights reserved. * * EMULEX and SLI are trademarks of Emulex. * diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c index 3e365e5e194a..bdf34af4ef36 100644 --- a/drivers/scsi/lpfc/lpfc_debugfs.c +++ b/drivers/scsi/lpfc/lpfc_debugfs.c @@ -1,7 +1,7 @@ /******************************************************************* * This file is part of the Emulex Linux Device Driver for * * Fibre Channel Host Bus Adapters. * - * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term * + * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * * Copyright (C) 2007-2015 Emulex. All rights reserved. * * EMULEX and SLI are trademarks of Emulex. * diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h index e9244bedb0f4..19b2d2754f32 100644 --- a/drivers/scsi/lpfc/lpfc_hw.h +++ b/drivers/scsi/lpfc/lpfc_hw.h @@ -1,7 +1,7 @@ /******************************************************************* * This file is part of the Emulex Linux Device Driver for * * Fibre Channel Host Bus Adapters. * - * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term * + * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * * Copyright (C) 2004-2016 Emulex. All rights reserved. * * EMULEX and SLI are trademarks of Emulex. * diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c index ae3207e73113..adda70423c77 100644 --- a/drivers/scsi/lpfc/lpfc_nvme.c +++ b/drivers/scsi/lpfc/lpfc_nvme.c @@ -1,7 +1,7 @@ /******************************************************************* * This file is part of the Emulex Linux Device Driver for * * Fibre Channel Host Bus Adapters. * - * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term * + * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * * Copyright (C) 2004-2016 Emulex. All rights reserved. * * EMULEX and SLI are trademarks of Emulex. *