]> www.infradead.org Git - nvme.git/commit
nvmet: pci-epf: Correctly initialize CSTS when enabling the controller
authorDamien Le Moal <dlemoal@kernel.org>
Thu, 13 Feb 2025 06:52:28 +0000 (15:52 +0900)
committerKeith Busch <kbusch@kernel.org>
Tue, 18 Feb 2025 15:25:14 +0000 (07:25 -0800)
commit68a5c91f01fc9f086567b260cced003ed9fdff3f
tree337fe1863f71f9b68924e7dcb6dfd0899cc18e0d
parent3988ac1c67e6e84d2feb987d7b36d5791174b3da
nvmet: pci-epf: Correctly initialize CSTS when enabling the controller

The function nvmet_pci_epf_poll_cc_work() sets the NVME_CSTS_RDY bit of
the controller status register (CSTS) when nvmet_pci_epf_enable_ctrl()
returns success. However, since this function can be called several
times (e.g. if the host reboots), instead of setting the bit in
ctrl->csts, initialize this field to only have NVME_CSTS_RDY set.
Conversely, if nvmet_pci_epf_enable_ctrl() fails, make sure to clear all
bits from ctrl->csts.

To simplify nvmet_pci_epf_poll_cc_work(), initialize ctrl->csts to
NVME_CSTS_RDY directly inside nvmet_pci_epf_enable_ctrl() and clear this
field in that function as well in case of a failure. To be consistent,
move clearing the NVME_CSTS_RDY bit from ctrl->csts when the controller
is being disabled from nvmet_pci_epf_poll_cc_work() into
nvmet_pci_epf_disable_ctrl().

Fixes: 0faa0fe6f90e ("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>
drivers/nvme/target/pci-epf.c