Skip to content

Commit ad91308

Browse files
damien-lemoalChristoph Hellwig
authored andcommitted
nvmet: pci-epf: cleanup link state management
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>
1 parent f8e01fa commit ad91308

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/nvme/target/pci-epf.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,11 +2095,18 @@ static int nvmet_pci_epf_create_ctrl(struct nvmet_pci_epf *nvme_epf,
20952095

20962096
static void nvmet_pci_epf_start_ctrl(struct nvmet_pci_epf_ctrl *ctrl)
20972097
{
2098+
2099+
dev_info(ctrl->dev, "PCI link up\n");
2100+
ctrl->link_up = true;
2101+
20982102
schedule_delayed_work(&ctrl->poll_cc, NVMET_PCI_EPF_CC_POLL_INTERVAL);
20992103
}
21002104

21012105
static void nvmet_pci_epf_stop_ctrl(struct nvmet_pci_epf_ctrl *ctrl)
21022106
{
2107+
dev_info(ctrl->dev, "PCI link down\n");
2108+
ctrl->link_up = false;
2109+
21032110
cancel_delayed_work_sync(&ctrl->poll_cc);
21042111

21052112
nvmet_pci_epf_disable_ctrl(ctrl, false);
@@ -2326,10 +2333,8 @@ static int nvmet_pci_epf_epc_init(struct pci_epf *epf)
23262333
if (ret)
23272334
goto out_clear_bar;
23282335

2329-
if (!epc_features->linkup_notifier) {
2330-
ctrl->link_up = true;
2336+
if (!epc_features->linkup_notifier)
23312337
nvmet_pci_epf_start_ctrl(&nvme_epf->ctrl);
2332-
}
23332338

23342339
return 0;
23352340

@@ -2345,7 +2350,6 @@ static void nvmet_pci_epf_epc_deinit(struct pci_epf *epf)
23452350
struct nvmet_pci_epf *nvme_epf = epf_get_drvdata(epf);
23462351
struct nvmet_pci_epf_ctrl *ctrl = &nvme_epf->ctrl;
23472352

2348-
ctrl->link_up = false;
23492353
nvmet_pci_epf_destroy_ctrl(ctrl);
23502354

23512355
nvmet_pci_epf_deinit_dma(nvme_epf);
@@ -2357,7 +2361,6 @@ static int nvmet_pci_epf_link_up(struct pci_epf *epf)
23572361
struct nvmet_pci_epf *nvme_epf = epf_get_drvdata(epf);
23582362
struct nvmet_pci_epf_ctrl *ctrl = &nvme_epf->ctrl;
23592363

2360-
ctrl->link_up = true;
23612364
nvmet_pci_epf_start_ctrl(ctrl);
23622365

23632366
return 0;
@@ -2368,7 +2371,6 @@ static int nvmet_pci_epf_link_down(struct pci_epf *epf)
23682371
struct nvmet_pci_epf *nvme_epf = epf_get_drvdata(epf);
23692372
struct nvmet_pci_epf_ctrl *ctrl = &nvme_epf->ctrl;
23702373

2371-
ctrl->link_up = false;
23722374
nvmet_pci_epf_stop_ctrl(ctrl);
23732375

23742376
return 0;

0 commit comments

Comments
 (0)