]> www.infradead.org Git - nvme.git/commitdiff
nvmet: pci-epf: cleanup link state management nvme-6.15-2025-04-17
authorDamien Le Moal <dlemoal@kernel.org>
Fri, 11 Apr 2025 01:42:11 +0000 (10:42 +0900)
committerChristoph Hellwig <hch@lst.de>
Wed, 16 Apr 2025 05:37:37 +0000 (07:37 +0200)
Since the link_up boolean field of struct nvmet_pci_epf_ctrl is always
set to true when nvmet_pci_epf_start_ctrl() is called, assign true to
this field in nvmet_pci_epf_start_ctrl(). Conversely, since this field
is set to false when nvmet_pci_epf_stop_ctrl() is called, set this field
to false directly inside that function.

While at it, also add information messages to notify the user of the PCI
link state changes to help troubleshoot any link stability issues
without needing to enable debug messages.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/pci-epf.c

index c3d30d34f8cedcf0dc2de23922856267993f479d..7fab7f3d79b7436e82152afdb337715c20d382f5 100644 (file)
@@ -2095,11 +2095,18 @@ out_mempool_exit:
 
 static void nvmet_pci_epf_start_ctrl(struct nvmet_pci_epf_ctrl *ctrl)
 {
+
+       dev_info(ctrl->dev, "PCI link up\n");
+       ctrl->link_up = true;
+
        schedule_delayed_work(&ctrl->poll_cc, NVMET_PCI_EPF_CC_POLL_INTERVAL);
 }
 
 static void nvmet_pci_epf_stop_ctrl(struct nvmet_pci_epf_ctrl *ctrl)
 {
+       dev_info(ctrl->dev, "PCI link down\n");
+       ctrl->link_up = false;
+
        cancel_delayed_work_sync(&ctrl->poll_cc);
 
        nvmet_pci_epf_disable_ctrl(ctrl, false);
@@ -2326,10 +2333,8 @@ static int nvmet_pci_epf_epc_init(struct pci_epf *epf)
        if (ret)
                goto out_clear_bar;
 
-       if (!epc_features->linkup_notifier) {
-               ctrl->link_up = true;
+       if (!epc_features->linkup_notifier)
                nvmet_pci_epf_start_ctrl(&nvme_epf->ctrl);
-       }
 
        return 0;
 
@@ -2345,7 +2350,6 @@ static void nvmet_pci_epf_epc_deinit(struct pci_epf *epf)
        struct nvmet_pci_epf *nvme_epf = epf_get_drvdata(epf);
        struct nvmet_pci_epf_ctrl *ctrl = &nvme_epf->ctrl;
 
-       ctrl->link_up = false;
        nvmet_pci_epf_destroy_ctrl(ctrl);
 
        nvmet_pci_epf_deinit_dma(nvme_epf);
@@ -2357,7 +2361,6 @@ static int nvmet_pci_epf_link_up(struct pci_epf *epf)
        struct nvmet_pci_epf *nvme_epf = epf_get_drvdata(epf);
        struct nvmet_pci_epf_ctrl *ctrl = &nvme_epf->ctrl;
 
-       ctrl->link_up = true;
        nvmet_pci_epf_start_ctrl(ctrl);
 
        return 0;
@@ -2368,7 +2371,6 @@ static int nvmet_pci_epf_link_down(struct pci_epf *epf)
        struct nvmet_pci_epf *nvme_epf = epf_get_drvdata(epf);
        struct nvmet_pci_epf_ctrl *ctrl = &nvme_epf->ctrl;
 
-       ctrl->link_up = false;
        nvmet_pci_epf_stop_ctrl(ctrl);
 
        return 0;