Skip to contentSkip to conversation

nvme: set dma alignment to 3

PATCH Applied Keith Busch 4 participants 5 messages May 4, 2022 – May 10, 2022 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: set dma alignment to 3

From: Keith Busch <[email protected]>

The nvme specification only requires qword alignment for segment descriptors, and the driver already guarantees that. The spec has always allowed user data to be dword aligned, which is what the queue's attribute is for, so relax the alignment requirement to that value.

While we could allow byte alignment for some controllers when using SGLs, we still need to support PRP, and that only allows dword.

Fixes 3b2a1ebceba3 ("nvme: set dma alignment to qword")
---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
index bea054565eed..0a6fb515a339 100644
@@ -1771,7 +1771,7 @@ static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
 		blk_queue_max_segments(q, min_t(u32, max_segments, USHRT_MAX));
 	}
 	blk_queue_virt_boundary(q, NVME_CTRL_PAGE_SIZE - 1);
-	blk_queue_dma_alignment(q, 7);
+	blk_queue_dma_alignment(q, 3);
 	blk_queue_write_cache(q, vwc, vwc);
 }
 
Signature · 1 line
2.30.2
#1 lore raw
Quoted 9 lines · Keith Busch

From: Keith Busch <[email protected]>

The nvme specification only requires qword alignment for segment descriptors, and the driver already guarantees that. The spec has always allowed user data to be dword aligned, which is what the queue's attribute is for, so relax the alignment requirement to that value.

While we could allow byte alignment for some controllers when using SGLs, we still need to support PRP, and that only allows dword.

Can't we just turn it go up to eleven? ;-)

maintainer
#2 lore raw
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · Keith Busch

From: Keith Busch <[email protected]>

The nvme specification only requires qword alignment for segment descriptors, and the driver already guarantees that. The spec has always allowed user data to be dword aligned, which is what the queue's attribute is for, so relax the alignment requirement to that value.

Quoted 4 lines
Quoted 2 lines

While we could allow byte alignment for some controllers when using SGLs, we still need to support PRP, and that only allows dword.

Can't we just turn it go up to eleven? ;-)

Excellent idea! Best I can do is a binary 11 :p

#3 lore raw
In reply to Keith Busch

Hey Keith

Quoted 11 lines · Keith Busch

From: Keith Busch <[email protected]>

The nvme specification only requires qword alignment for segment descriptors, and the driver already guarantees that. The spec has always allowed user data to be dword aligned, which is what the queue's attribute is for, so relax the alignment requirement to that value.

While we could allow byte alignment for some controllers when using SGLs, we still need to support PRP, and that only allows dword.

Fixes 3b2a1ebceba3 ("nvme: set dma alignment to qword")

Just a small nitpick but the original commit uses 'qword' and yours uses '3' Would it be more descriptive to use 'dword'?

Quoted 18 lines
---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
index bea054565eed..0a6fb515a339 100644
@@ -1771,7 +1771,7 @@ static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
 		blk_queue_max_segments(q, min_t(u32, max_segments, USHRT_MAX));
 	}
 	blk_queue_virt_boundary(q, NVME_CTRL_PAGE_SIZE - 1);
-	blk_queue_dma_alignment(q, 7);
+	blk_queue_dma_alignment(q, 3);
 	blk_queue_write_cache(q, vwc, vwc);
 }