NVMe: Only clear the enable bit when disabling controller
authorMatthew Wilcox <matthew.r.wilcox@intel.com>
Sat, 4 May 2013 10:43:17 +0000 (06:43 -0400)
committerMatthew Wilcox <matthew.r.wilcox@intel.com>
Wed, 8 May 2013 13:54:31 +0000 (09:54 -0400)
Many of the bits in the Controller Configuration register may only be
modified when the Enable bit is clear.  Clearing them at the same time
as the Enable bit might be OK, but let's play it safe and only touch the
Enable bit.

Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
drivers/block/nvme-core.c

index 2b1b5a74dc72e657c45db8893ee024c941715ddd..310d573b9e8da38b4361542e98f88e595f02a47d 100644 (file)
@@ -1137,7 +1137,10 @@ static int nvme_wait_ready(struct nvme_dev *dev, u64 cap, bool enabled)
  */
 static int nvme_disable_ctrl(struct nvme_dev *dev, u64 cap)
 {
-       writel(0, &dev->bar->cc);
+       u32 cc = readl(&dev->bar->cc);
+
+       if (cc & NVME_CC_ENABLE)
+               writel(cc & ~NVME_CC_ENABLE, &dev->bar->cc);
        return nvme_wait_ready(dev, cap, false);
 }