]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.75/nvme-apply-delay_before_chk_rdy-quirk-at-probe-time-too.patch
5.0-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.75 / nvme-apply-delay_before_chk_rdy-quirk-at-probe-time-too.patch
CommitLineData
eac43d9e
GKH
1From b5a10c5f7532b7473776da87e67f8301bbc32693 Mon Sep 17 00:00:00 2001
2From: "Guilherme G. Piccoli" <gpiccoli@linux.vnet.ibm.com>
3Date: Wed, 28 Dec 2016 22:13:15 -0200
4Subject: nvme: apply DELAY_BEFORE_CHK_RDY quirk at probe time too
5
6From: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
7
8commit b5a10c5f7532b7473776da87e67f8301bbc32693 upstream.
9
10Commit 54adc01055b7 ("nvme/quirk: Add a delay before checking for adapter
11readiness") introduced a quirk to adapters that cannot read the bit
12NVME_CSTS_RDY right after register NVME_REG_CC is set; these adapters
13need a delay or else the action of reading the bit NVME_CSTS_RDY could
14somehow corrupt adapter's registers state and it never recovers.
15
16When this quirk was added, we checked ctrl->tagset in order to avoid
17quirking in probe time, supposing we would never require such delay
18during probe. Well, it was too optimistic; we in fact need this quirk
19at probe time in some cases, like after a kexec.
20
21In some experiments, after abnormal shutdown of machine (aka power cord
22unplug), we booted into our bootloader in Power, which is a Linux kernel,
23and kexec'ed into another distro. If this kexec is too quick, we end up
24reaching the probe of NVMe adapter in that distro when adapter is in
25bad state (not fully initialized on our bootloader). What happens next
26is that nvme_wait_ready() is unable to complete, except if the quirk is
27enabled.
28
29So, this patch removes the original ctrl->tagset verification in order
30to enable the quirk even on probe time.
31
32Fixes: 54adc01055b7 ("nvme/quirk: Add a delay before checking for adapter readiness")
33Reported-by: Andrew Byrne <byrneadw@ie.ibm.com>
34Reported-by: Jaime A. H. Gomez <jahgomez@mx1.ibm.com>
35Reported-by: Zachary D. Myers <zdmyers@us.ibm.com>
36Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
37Acked-by: Jeffrey Lien <Jeff.Lien@wdc.com>
38Signed-off-by: Christoph Hellwig <hch@lst.de>
39[mauricfo: backport to v4.4.70 without nvme quirk handling & nvme_ctrl]
40Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
41Tested-by: Narasimhan Vaidyanathan <vnarasimhan@in.ibm.com>
42Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
43---
44 drivers/nvme/host/pci.c | 7 +------
45 1 file changed, 1 insertion(+), 6 deletions(-)
46
47--- a/drivers/nvme/host/pci.c
48+++ b/drivers/nvme/host/pci.c
49@@ -1639,12 +1639,7 @@ static int nvme_disable_ctrl(struct nvme
50 dev->ctrl_config &= ~NVME_CC_ENABLE;
51 writel(dev->ctrl_config, &dev->bar->cc);
52
53- /* Checking for dev->tagset is a trick to avoid sleeping on module
54- * load, since we only need the quirk on reset_controller. Notice
55- * that the HGST device needs this delay only in firmware activation
56- * procedure; unfortunately we have no (easy) way to verify this.
57- */
58- if (pdev->vendor == 0x1c58 && pdev->device == 0x0003 && dev->tagset)
59+ if (pdev->vendor == 0x1c58 && pdev->device == 0x0003)
60 msleep(NVME_QUIRK_DELAY_AMOUNT);
61
62 return nvme_wait_ready(dev, cap, false);