Daniel Wagner a3f49f
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Daniel Wagner a3f49f
Date: Thu, 3 Oct 2019 13:57:29 +0200
Daniel Wagner a3f49f
Subject: nvme: retain split access workaround for capability reads
Daniel Wagner a3f49f
Patch-mainline: v5.4-rc4
Daniel Wagner a3f49f
Git-commit: 3a8ecc935efabdad106b5e06d07b150c394b4465
Daniel Wagner a3f49f
References: git-fixes
Daniel Wagner a3f49f
Daniel Wagner a3f49f
Commit 7fd8930f26be4
Daniel Wagner a3f49f
Daniel Wagner a3f49f
  "nvme: add a common helper to read Identify Controller data"
Daniel Wagner a3f49f
Daniel Wagner a3f49f
has re-introduced an issue that we have attempted to work around in the
Daniel Wagner a3f49f
past, in commit a310acd7a7ea ("NVMe: use split lo_hi_{read,write}q").
Daniel Wagner a3f49f
Daniel Wagner a3f49f
The problem is that some PCIe NVMe controllers do not implement 64-bit
Daniel Wagner a3f49f
outbound accesses correctly, which is why the commit above switched
Daniel Wagner a3f49f
to using lo_hi_[read|write]q for all 64-bit BAR accesses occuring in
Daniel Wagner a3f49f
the code.
Daniel Wagner a3f49f
Daniel Wagner a3f49f
In the mean time, the NVMe subsystem has been refactored, and now calls
Daniel Wagner a3f49f
into the PCIe support layer for NVMe via a .reg_read64() method, which
Daniel Wagner a3f49f
fails to use lo_hi_readq(), and thus reintroduces the problem that the
Daniel Wagner a3f49f
workaround above aimed to address.
Daniel Wagner a3f49f
Daniel Wagner a3f49f
Given that, at the moment, .reg_read64() is only used to read the
Daniel Wagner a3f49f
capability register [which is known to tolerate split reads], let's
Daniel Wagner a3f49f
switch .reg_read64() to lo_hi_readq() as well.
Daniel Wagner a3f49f
Daniel Wagner a3f49f
This fixes a boot issue on some ARM boxes with NVMe behind a Synopsys
Daniel Wagner a3f49f
DesignWare PCIe host controller.
Daniel Wagner a3f49f
Daniel Wagner a3f49f
Fixes: 7fd8930f26be4 ("nvme: add a common helper to read Identify Controller data")
Daniel Wagner a3f49f
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Daniel Wagner a3f49f
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Daniel Wagner a3f49f
Acked-by: Daniel Wagner <dwagner@suse.de>
Daniel Wagner a3f49f
---
Daniel Wagner a3f49f
 drivers/nvme/host/pci.c |    2 +-
Daniel Wagner a3f49f
 1 file changed, 1 insertion(+), 1 deletion(-)
Daniel Wagner a3f49f
Daniel Wagner a3f49f
--- a/drivers/nvme/host/pci.c
Daniel Wagner a3f49f
+++ b/drivers/nvme/host/pci.c
Daniel Wagner a3f49f
@@ -2381,7 +2381,7 @@ static int nvme_pci_reg_write32(struct n
Daniel Wagner a3f49f
 
Daniel Wagner a3f49f
 static int nvme_pci_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val)
Daniel Wagner a3f49f
 {
Daniel Wagner a3f49f
-	*val = readq(to_nvme_dev(ctrl)->bar + off);
Daniel Wagner a3f49f
+	*val = lo_hi_readq(to_nvme_dev(ctrl)->bar + off);
Daniel Wagner a3f49f
 	return 0;
Daniel Wagner a3f49f
 }
Daniel Wagner a3f49f