Skip to content

Commit

Permalink
nvme-pci: fix freeze accounting for error handling
Browse files Browse the repository at this point in the history
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: b98235d ("nvme-pci: harden drive presence detect in nvme_dev_disable()")
Reported-by: Niklas Schnelle <[email protected]>
Signed-off-by: Keith Busch <[email protected]>
Tested-by: Niklas Schnelle <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
keithbusch authored and Christoph Hellwig committed Jul 14, 2022
1 parent 6b0de7d commit 081f5e7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/nvme/host/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 081f5e7

Please sign in to comment.