[PATCH 02/26] nvme: fix buffer advancement when chunking due to max_hw_sectors

Ahmad Fatoum a.fatoum at barebox.org
Fri Jun 26 01:42:13 PDT 2026


max_hw_sectors can be derived by reading from the NVMe driver and
controls how many sectors to maximally read/write at once.

Bigger reads/writes were split by doing the operation in a loop.

However, only the first iteration of the loop worked, because the buffer
was advanced by the _block_ count and not the _byte_ count.

Fix this by advancing by advancing by number of bytes instead.

Fixes: aedcb568afe4 ("drivers: Import a very basic NVME implementation from Linux")
Assisted-by: Codex:gpt-5.5
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 98731ffe7cb2..21aeda78ebfb 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -328,7 +328,7 @@ static int nvme_submit_sync_rw(struct nvme_ns *ns, struct nvme_command *cmnd,
 				break;
 
 			num_blocks -= chunk;
-			buffer += chunk;
+			buffer += chunk << ns->lba_shift;
 			block += chunk;
 		}
 
-- 
2.47.3




More information about the barebox mailing list