aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nvme/host/pci.c
diff options
context:
space:
mode:
authorKeith Busch <kbusch@kernel.org>2022-07-12 08:16:32 -0700
committerChristoph Hellwig <hch@lst.de>2022-07-14 16:35:25 +0200
commit081f5e753c9c4cd1dd86000bcc7f5fe14cbdcab0 (patch)
tree9989e9c3b934f0737e3c87d3496687747c7140d5 /drivers/nvme/host/pci.c
parentMerge tag 'nvme-5.19-2022-07-07' of git://git.infradead.org/nvme into block-5.19 (diff)
downloadlinux-dev-081f5e753c9c4cd1dd86000bcc7f5fe14cbdcab0.tar.xz
linux-dev-081f5e753c9c4cd1dd86000bcc7f5fe14cbdcab0.zip
nvme-pci: fix freeze accounting for error handling
A reset on a live device experiencing a link error still needs to have the queue freeze state started for the subsequent reinitialization. Skip only the register read if the device is not present instead of bypassing the freeze checks. Fixes: b98235d3a471e ("nvme-pci: harden drive presence detect in nvme_dev_disable()") Reported-by: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Keith Busch <kbusch@kernel.org> Tested-by: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to '')
-rw-r--r--drivers/nvme/host/pci.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 193b44755662..58c72d55769a 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2690,8 +2690,13 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
struct pci_dev *pdev = to_pci_dev(dev->dev);
mutex_lock(&dev->shutdown_lock);
- if (pci_device_is_present(pdev) && pci_is_enabled(pdev)) {
- u32 csts = readl(dev->bar + NVME_REG_CSTS);
+ if (pci_is_enabled(pdev)) {
+ u32 csts;
+
+ if (pci_device_is_present(pdev))
+ csts = readl(dev->bar + NVME_REG_CSTS);
+ else
+ csts = ~0;
if (dev->ctrl.state == NVME_CTRL_LIVE ||
dev->ctrl.state == NVME_CTRL_RESETTING) {