]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scsi: lpfc: Add clean up of aborted NVMe commands during PCI fcn reset
authorJustin Tee <justin.tee@broadcom.com>
Thu, 12 Feb 2026 21:30:04 +0000 (13:30 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 24 Feb 2026 18:06:52 +0000 (13:06 -0500)
When handling a PCI function reset, notification to the NVMe transport
layer is skipped for outstanding aborted NVMe I/O.  Introduce a new
routine called lpfc_nvme_flush_abts_list(), which notifies upper NVMe
transport layer of outstanding aborted NVMe I/O that are not planned to
be completed normally due to a PCI function reset request.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://patch.msgid.link/20260212213008.149873-10-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc_crtn.h
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_nvme.c

index efeb61b15a5b5b4f515cb706359dff9e37de53a9..ddd6485f31be3d85a9f8e2ce4f7ae9e324950483 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2026 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.                        *
@@ -660,6 +660,7 @@ void lpfc_wqe_cmd_template(void);
 void lpfc_nvmet_cmd_template(void);
 void lpfc_nvme_cancel_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
                           uint32_t stat, uint32_t param);
+void lpfc_nvme_flush_abts_list(struct lpfc_hba *phba);
 void lpfc_nvmels_flush_cmd(struct lpfc_hba *phba);
 extern int lpfc_enable_nvmet_cnt;
 extern unsigned long long lpfc_enable_nvmet[];
index be65496fc1c7b4764b220a8ed84e732cf0d42344..704c59cc8892211ef099fb055245c2da8c073831 100644 (file)
@@ -1087,7 +1087,6 @@ lpfc_hba_down_post_s4(struct lpfc_hba *phba)
        struct lpfc_async_xchg_ctx *ctxp, *ctxp_next;
        struct lpfc_sli4_hdw_queue *qp;
        LIST_HEAD(aborts);
-       LIST_HEAD(nvme_aborts);
        LIST_HEAD(nvmet_aborts);
        struct lpfc_sglq *sglq_entry = NULL;
        int cnt, idx;
@@ -1946,6 +1945,7 @@ lpfc_sli4_port_sta_fn_reset(struct lpfc_hba *phba, int mbx_action,
 
        lpfc_offline_prep(phba, mbx_action);
        lpfc_sli_flush_io_rings(phba);
+       lpfc_nvme_flush_abts_list(phba);
        lpfc_nvmels_flush_cmd(phba);
        lpfc_offline(phba);
        /* release interrupt for possible resource change */
index a6b3b16f870da3d634b7ba8995a04fd69f2fc758..74c2820c64f3a5e8f3a398f1c84f519e4ccced9d 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2025 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2026 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.                        *
@@ -2846,6 +2846,54 @@ lpfc_nvme_cancel_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
 #endif
 }
 
+/**
+ * lpfc_nvme_flush_abts_list - Clean up nvme commands from the abts list
+ * @phba: Pointer to HBA context object.
+ *
+ **/
+void
+lpfc_nvme_flush_abts_list(struct lpfc_hba *phba)
+{
+#if (IS_ENABLED(CONFIG_NVME_FC))
+       struct lpfc_io_buf *psb, *psb_next;
+       struct lpfc_sli4_hdw_queue *qp;
+       LIST_HEAD(aborts);
+       int i;
+
+       /* abts_xxxx_buf_list_lock required because worker thread uses this
+        * list.
+        */
+       spin_lock_irq(&phba->hbalock);
+       for (i = 0; i < phba->cfg_hdw_queue; i++) {
+               qp = &phba->sli4_hba.hdwq[i];
+
+               spin_lock(&qp->abts_io_buf_list_lock);
+               list_for_each_entry_safe(psb, psb_next,
+                                        &qp->lpfc_abts_io_buf_list, list) {
+                       if (!(psb->cur_iocbq.cmd_flag & LPFC_IO_NVME))
+                               continue;
+                       list_move(&psb->list, &aborts);
+                       qp->abts_nvme_io_bufs--;
+               }
+               spin_unlock(&qp->abts_io_buf_list_lock);
+       }
+       spin_unlock_irq(&phba->hbalock);
+
+       list_for_each_entry_safe(psb, psb_next, &aborts, list) {
+               list_del_init(&psb->list);
+               lpfc_printf_log(phba, KERN_INFO, LOG_NVME_ABTS,
+                               "6195 %s: lpfc_ncmd x%px flags x%x "
+                               "cmd_flag x%x xri x%x\n", __func__,
+                               psb, psb->flags,
+                               psb->cur_iocbq.cmd_flag,
+                               psb->cur_iocbq.sli4_xritag);
+               psb->flags &= ~LPFC_SBUF_XBUSY;
+               psb->status = IOSTAT_SUCCESS;
+               lpfc_sli4_nvme_pci_offline_aborted(phba, psb);
+       }
+#endif
+}
+
 /**
  * lpfc_nvmels_flush_cmd - Clean up outstanding nvmels commands for a port
  * @phba: Pointer to HBA context object.