From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: linux-nvme@lists.infradead.org
Cc: sagi@grimberg.me, Ard Biesheuvel <ard.biesheuvel@linaro.org>,
ilias.apalodimas@linaro.org, axboe@fb.com, kbusch@kernel.org,
hch@lst.de
Subject: [PATCH v4] nvme/pci: Split 8-byte reads
Date: Mon, 7 Oct 2019 20:22:44 +0200 [thread overview]
Message-ID: <20191007182244.8516-1-ard.biesheuvel@linaro.org> (raw)
The nvme pci driver had split 8-byte register reads using lo_hi_readq()
due to nvme controllers that do not support that sized access. This
behavior was inadvertently changed to readq(), which may break those
controllers. Restore the previous behavior.
Fixes: 7fd8930f26be4 ("nvme: add a common helper to read Identify Controller data")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
v4: update comment and commit text according to Keith's guidance
v3: add comment explaining why we need the split read
v2: drop WARN_ON(), add reference to commit that [re-]introduced the issue
---
drivers/nvme/host/pci.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index bb88681f4dc3..3fe0c5185646 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2672,7 +2672,12 @@ 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);
+ /*
+ * Split the 8-byte read into two 4-byte reads since all controllers
+ * support 4 byte register reads, but some do not support the larger
+ * access size.
+ */
+ *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
next reply other threads:[~2019-10-07 18:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-07 18:22 Ard Biesheuvel [this message]
2019-10-07 18:28 ` [PATCH v4] nvme/pci: Split 8-byte reads Keith Busch
2019-10-07 18:47 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191007182244.8516-1-ard.biesheuvel@linaro.org \
--to=ard.biesheuvel@linaro.org \
--cc=axboe@fb.com \
--cc=hch@lst.de \
--cc=ilias.apalodimas@linaro.org \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).