hw/nvme fixes

-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEUigzqnXi3OaiR2bATeGvMW1PDekFAmQhzX8ACgkQTeGvMW1P
 DekD4gf9GhPfYxpltYI4KmjfPotY0fIZQ/33jZtjJXdKpzmCCAknuCZdoI1yM5X7
 I9EiP3I6hfMyzUe58K8Gi8v8Vy9/UUtKjWGpYoWiLol01IkqqvsBNZC8KGQpUDfX
 cYXI13XAutHxKbH9sp10OvMEI1jBGHBvzEAtUHhFYxX0jazt68PJVL01YhCMIsQo
 4KQOes8Bxxroh/0c7/zbMdVFfDxj/Vtm3dpj9PLRlc9lqhkzh2gpiY4tI4RA85KR
 4Ceq8+ihhbXn81CrLMpx2JqOcp+GNhJDQ8VekfbIsoT3DY5PN7G4p7FaIUxhba9k
 VoB4U1cbjdMk3sohPXVhsLrwpixf1w==
 =WdhG
 -----END PGP SIGNATURE-----

Merge tag 'nvme-next-pull-request' of https://gitlab.com/birkelund/qemu into staging

hw/nvme fixes

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEUigzqnXi3OaiR2bATeGvMW1PDekFAmQhzX8ACgkQTeGvMW1P
# DekD4gf9GhPfYxpltYI4KmjfPotY0fIZQ/33jZtjJXdKpzmCCAknuCZdoI1yM5X7
# I9EiP3I6hfMyzUe58K8Gi8v8Vy9/UUtKjWGpYoWiLol01IkqqvsBNZC8KGQpUDfX
# cYXI13XAutHxKbH9sp10OvMEI1jBGHBvzEAtUHhFYxX0jazt68PJVL01YhCMIsQo
# 4KQOes8Bxxroh/0c7/zbMdVFfDxj/Vtm3dpj9PLRlc9lqhkzh2gpiY4tI4RA85KR
# 4Ceq8+ihhbXn81CrLMpx2JqOcp+GNhJDQ8VekfbIsoT3DY5PN7G4p7FaIUxhba9k
# VoB4U1cbjdMk3sohPXVhsLrwpixf1w==
# =WdhG
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 27 Mar 2023 18:08:15 BST
# gpg:                using RSA key 522833AA75E2DCE6A24766C04DE1AF316D4F0DE9
# gpg: Good signature from "Klaus Jensen <its@irrelevant.dk>" [full]
# gpg:                 aka "Klaus Jensen <k.jensen@samsung.com>" [full]
# Primary key fingerprint: DDCA 4D9C 9EF9 31CC 3468  4272 63D5 6FC5 E55D A838
#      Subkey fingerprint: 5228 33AA 75E2 DCE6 A247  66C0 4DE1 AF31 6D4F 0DE9

* tag 'nvme-next-pull-request' of https://gitlab.com/birkelund/qemu:
  hw/nvme: fix missing DNR on compare failure
  hw/nvme: Change alignment in dma functions for nvme_blk_*

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2023-03-28 11:21:39 +01:00
commit ecaefc8f50

View File

@ -1434,26 +1434,26 @@ uint16_t nvme_bounce_mdata(NvmeCtrl *n, void *ptr, uint32_t len,
}
static inline void nvme_blk_read(BlockBackend *blk, int64_t offset,
BlockCompletionFunc *cb, NvmeRequest *req)
uint32_t align, BlockCompletionFunc *cb,
NvmeRequest *req)
{
assert(req->sg.flags & NVME_SG_ALLOC);
if (req->sg.flags & NVME_SG_DMA) {
req->aiocb = dma_blk_read(blk, &req->sg.qsg, offset, BDRV_SECTOR_SIZE,
cb, req);
req->aiocb = dma_blk_read(blk, &req->sg.qsg, offset, align, cb, req);
} else {
req->aiocb = blk_aio_preadv(blk, offset, &req->sg.iov, 0, cb, req);
}
}
static inline void nvme_blk_write(BlockBackend *blk, int64_t offset,
BlockCompletionFunc *cb, NvmeRequest *req)
uint32_t align, BlockCompletionFunc *cb,
NvmeRequest *req)
{
assert(req->sg.flags & NVME_SG_ALLOC);
if (req->sg.flags & NVME_SG_DMA) {
req->aiocb = dma_blk_write(blk, &req->sg.qsg, offset, BDRV_SECTOR_SIZE,
cb, req);
req->aiocb = dma_blk_write(blk, &req->sg.qsg, offset, align, cb, req);
} else {
req->aiocb = blk_aio_pwritev(blk, offset, &req->sg.iov, 0, cb, req);
}
@ -2207,10 +2207,10 @@ static void nvme_rw_cb(void *opaque, int ret)
}
if (req->cmd.opcode == NVME_CMD_READ) {
return nvme_blk_read(blk, offset, nvme_rw_complete_cb, req);
return nvme_blk_read(blk, offset, 1, nvme_rw_complete_cb, req);
}
return nvme_blk_write(blk, offset, nvme_rw_complete_cb, req);
return nvme_blk_write(blk, offset, 1, nvme_rw_complete_cb, req);
}
}
@ -2378,7 +2378,7 @@ static void nvme_compare_mdata_cb(void *opaque, int ret)
for (bufp = buf; mbufp < end; bufp += ns->lbaf.ms, mbufp += ns->lbaf.ms) {
if (memcmp(bufp + pil, mbufp + pil, ns->lbaf.ms - pil)) {
req->status = NVME_CMP_FAILURE;
req->status = NVME_CMP_FAILURE | NVME_DNR;
goto out;
}
}
@ -2387,7 +2387,7 @@ static void nvme_compare_mdata_cb(void *opaque, int ret)
}
if (memcmp(buf, ctx->mdata.bounce, ctx->mdata.iov.size)) {
req->status = NVME_CMP_FAILURE;
req->status = NVME_CMP_FAILURE | NVME_DNR;
goto out;
}
@ -2436,7 +2436,7 @@ static void nvme_compare_data_cb(void *opaque, int ret)
}
if (memcmp(buf, ctx->data.bounce, ctx->data.iov.size)) {
req->status = NVME_CMP_FAILURE;
req->status = NVME_CMP_FAILURE | NVME_DNR;
goto out;
}
@ -3437,7 +3437,7 @@ static uint16_t nvme_read(NvmeCtrl *n, NvmeRequest *req)
block_acct_start(blk_get_stats(blk), &req->acct, data_size,
BLOCK_ACCT_READ);
nvme_blk_read(blk, data_offset, nvme_rw_cb, req);
nvme_blk_read(blk, data_offset, BDRV_SECTOR_SIZE, nvme_rw_cb, req);
return NVME_NO_COMPLETE;
invalid:
@ -3607,7 +3607,7 @@ static uint16_t nvme_do_write(NvmeCtrl *n, NvmeRequest *req, bool append,
block_acct_start(blk_get_stats(blk), &req->acct, data_size,
BLOCK_ACCT_WRITE);
nvme_blk_write(blk, data_offset, nvme_rw_cb, req);
nvme_blk_write(blk, data_offset, BDRV_SECTOR_SIZE, nvme_rw_cb, req);
} else {
req->aiocb = blk_aio_pwrite_zeroes(blk, data_offset, data_size,
BDRV_REQ_MAY_UNMAP, nvme_rw_cb,