linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] nvme: retain split access workaround for capability reads
@ 2019-10-02  7:36 Ard Biesheuvel
  2019-10-02 22:05 ` Nadolski, Edmund
  2019-10-03 11:49 ` Keith Busch
  0 siblings, 2 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2019-10-02  7:36 UTC (permalink / raw)
  To: linux-nvme; +Cc: sagi, Ard Biesheuvel, ilias.apalodimas, axboe, kbusch, hch

Recent changes to the NVMe core have re-introduced an issue that we
have attempted to work around in the past, in commit a310acd7a7ea
("NVMe: use split lo_hi_{read,write}q").

The problem is that some PCIe NVMe controllers do not implement 64-bit
outbound accesses correctly, which is why the commit above switched
to using lo_hi_[read|write]q for all 64-bit BAR accesses.

In the mean time, the NVMe subsystem has been refactored, and now calls
into the PCIe support layer for NVMe via a .reg_read64() method, which
fails to use lo_hi_readq(), and thus reintroduces the problem that the
commit above aimed to address.

Given that, at the moment, .reg_read64() is only used to read the
capability register [which is known to tolerate split reads, which is
not guaranteed in the general case, given that the NVMe BAR may be
non-prefetchable], let's switch .reg_read64() to lo_hi_readq() as
well.

To ensure that we will spot any changes that will start using the
.reg_read64() method for other purposes, WARN() if the requested
offset != NVME_REG_CAP.

This fixes a boot issue on some ARM boxes with NVMe behind a
Synopsys DesignWare PCIe host controller.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
Broken since v5.3, so if this gets fixed one way or the other, please
add cc: stable.

Given that reg_read64() is only used in a single place to read the
capability register, it would be cleaner to just drop it and add a
.reg_readcap() method instead, but this is a more invasive change.

 drivers/nvme/host/pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index c0808f9eb8ab..bb012075fbb2 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2672,7 +2672,8 @@ static int nvme_pci_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val)
 
 static int nvme_pci_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val)
 {
-	*val = readq(to_nvme_dev(ctrl)->bar + off);
+	WARN_ON(off != NVME_REG_CAP);
+	*val = lo_hi_readq(to_nvme_dev(ctrl)->bar + off);
 	return 0;
 }
 
-- 
2.20.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-10-04 21:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-02  7:36 [RFC PATCH] nvme: retain split access workaround for capability reads Ard Biesheuvel
2019-10-02 22:05 ` Nadolski, Edmund
2019-10-03 11:49 ` Keith Busch
2019-10-03 11:51   ` Ard Biesheuvel
2019-10-03 12:03     ` Keith Busch
2019-10-03 12:05       ` Ard Biesheuvel
2019-10-04 21:57         ` Sagi Grimberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).