From 5f146372467f12ba79f9a734be71718939239811 Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Wed, 27 Jun 2018 20:56:36 +0200 Subject: [PATCH] nvme/pcie: merge physically contiguous SGEs There's no need to split a bufffer if it's physically contiguous. We can now merge buffers that would be previously split by the nvme_pcie driver and also separate SGEs provided by the user that happen to be physically contiguous. Change-Id: I9c9de31d52a9dc9e384806555cb94609aff0ccf3 Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/417061 Tested-by: SPDK Automated Test System Reviewed-by: Shuhei Matsumoto Reviewed-by: Daniel Verkamp --- lib/nvme/nvme_pcie.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index 9960929e5..737c86362 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -1818,6 +1818,13 @@ nvme_pcie_qpair_build_hw_sgl_request(struct spdk_nvme_qpair *qpair, struct nvme_ remaining_user_sge_len -= length; virt_addr += length; + if (nseg > 0 && phys_addr == + (*(sgl - 1)).address + (*(sgl - 1)).unkeyed.length) { + /* extend previous entry */ + (*(sgl - 1)).unkeyed.length += length; + continue; + } + sgl->unkeyed.type = SPDK_NVME_SGL_TYPE_DATA_BLOCK; sgl->unkeyed.length = length; sgl->address = phys_addr;