Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] nvme: Check the PRINFO bit and the Metadata size before deciding the host buffer length
@ 2021-01-12 17:29 Revanth Rajashekar
  2021-01-12 18:39 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Revanth Rajashekar @ 2021-01-12 17:29 UTC (permalink / raw)
  To: linux-nvme; +Cc: Keith Busch, Revanth Rajashekar, hch, Jonathan Derrick

According to NVMe spec v1.4, section 8.3.1, the PRINFO bit and
the metadata size play a vital role in deteriming the host buffer size.

If PRIFNO bit is set and MS==8, the host doesn't add the metadata buffer,
instead the controller adds it.

Changes from v1:
1. Remove the definition 'NVME_PRINFO_CTRL_BIT'
2. Remove variable 'control'
3. Remove test_bit and check the bit with the CPU arch's native endianness

Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com>
---
 drivers/nvme/host/core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f320273fc672..03261e0abdcc 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1546,6 +1546,11 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
 	meta_len = (io.nblocks + 1) * ns->ms;
 	metadata = nvme_to_user_ptr(io.metadata);

+	if (io.control & NVME_RW_PRINFO_PRACT && ns->ms == 8) {
+		meta_len = 0;
+		metadata = NULL;
+	}
+
 	if (ns->features & NVME_NS_EXT_LBAS) {
 		length += meta_len;
 		meta_len = 0;
--
2.17.1


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

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

end of thread, other threads:[~2021-01-13 16:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-12 17:29 [PATCH v2] nvme: Check the PRINFO bit and the Metadata size before deciding the host buffer length Revanth Rajashekar
2021-01-12 18:39 ` Christoph Hellwig
2021-01-13 16:57   ` Rajashekar, Revanth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox