Skip to content

Commit ffa3556

Browse files
damien-lemoalkeithbusch
authored andcommitted
nvmet: pci-epf: Do not uselessly write the CSTS register
The function nvmet_pci_epf_poll_cc_work() will do nothing if there are no changes to the controller configuration (CC) register. However, even for such case, this function still calls nvmet_update_cc() and uselessly writes the CSTS register. Avoid this by simply rescheduling the poll_cc work if the CC register has not changed. Also reschedule the poll_cc work if the function nvmet_pci_epf_enable_ctrl() fails to allow the host the chance to try again enabling the controller. While at it, since there is no point in trying to handle the CC register as quickly as possible, change the poll_cc work scheduling interval to 10 ms (from 5ms), to avoid excessive read accesses to that register. Fixes: 0faa0fe ("nvmet: New NVMe PCI endpoint function target driver") Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 68a5c91 commit ffa3556

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/nvme/target/pci-epf.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static DEFINE_MUTEX(nvmet_pci_epf_ports_mutex);
4646
/*
4747
* BAR CC register and SQ polling intervals.
4848
*/
49-
#define NVMET_PCI_EPF_CC_POLL_INTERVAL msecs_to_jiffies(5)
49+
#define NVMET_PCI_EPF_CC_POLL_INTERVAL msecs_to_jiffies(10)
5050
#define NVMET_PCI_EPF_SQ_POLL_INTERVAL msecs_to_jiffies(5)
5151
#define NVMET_PCI_EPF_SQ_POLL_IDLE msecs_to_jiffies(5000)
5252

@@ -1910,12 +1910,15 @@ static void nvmet_pci_epf_poll_cc_work(struct work_struct *work)
19101910

19111911
old_cc = ctrl->cc;
19121912
new_cc = nvmet_pci_epf_bar_read32(ctrl, NVME_REG_CC);
1913+
if (new_cc == old_cc)
1914+
goto reschedule_work;
1915+
19131916
ctrl->cc = new_cc;
19141917

19151918
if (nvmet_cc_en(new_cc) && !nvmet_cc_en(old_cc)) {
19161919
ret = nvmet_pci_epf_enable_ctrl(ctrl);
19171920
if (ret)
1918-
return;
1921+
goto reschedule_work;
19191922
}
19201923

19211924
if (!nvmet_cc_en(new_cc) && nvmet_cc_en(old_cc))
@@ -1932,6 +1935,7 @@ static void nvmet_pci_epf_poll_cc_work(struct work_struct *work)
19321935
nvmet_update_cc(ctrl->tctrl, ctrl->cc);
19331936
nvmet_pci_epf_bar_write32(ctrl, NVME_REG_CSTS, ctrl->csts);
19341937

1938+
reschedule_work:
19351939
schedule_delayed_work(&ctrl->poll_cc, NVMET_PCI_EPF_CC_POLL_INTERVAL);
19361940
}
19371941

0 commit comments

Comments
 (0)