From: Eric Auger <eric.auger@redhat.com>
To: eric.auger.pro@gmail.com, eric.auger@redhat.com,
qemu-devel@nongnu.org, qemu-arm@nongnu.org, stefanha@redhat.com,
fam@euphon.net, philmd@redhat.com, alex.williamson@redhat.com
Cc: kwolf@redhat.com, mreitz@redhat.com
Subject: [RFC 2/5] block/nvme: Change size and alignment of IDENTIFY response buffer
Date: Thu, 15 Oct 2020 13:52:49 +0200 [thread overview]
Message-ID: <20201015115252.15582-3-eric.auger@redhat.com> (raw)
In-Reply-To: <20201015115252.15582-1-eric.auger@redhat.com>
In preparation of 64kB host page support, let's change the size
and alignment of the IDENTIFY command response buffer so that
the VFIO DMA MAP succeeds. We align on the host page size.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
block/nvme.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/block/nvme.c b/block/nvme.c
index e3d96f20d0..088ff1825a 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -513,19 +513,21 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
.opcode = NVME_ADM_CMD_IDENTIFY,
.cdw10 = cpu_to_le32(0x1),
};
+ size_t id_size = QEMU_ALIGN_UP(sizeof(*id), qemu_real_host_page_size);
- id = qemu_try_memalign(s->page_size, sizeof(*id));
+ id = qemu_try_memalign(qemu_real_host_page_size, id_size);
if (!id) {
error_setg(errp, "Cannot allocate buffer for identify response");
goto out;
}
- r = qemu_vfio_dma_map(s->vfio, id, sizeof(*id), true, &iova);
+ r = qemu_vfio_dma_map(s->vfio, id, id_size, true, &iova);
if (r) {
error_setg(errp, "Cannot map buffer for DMA");
goto out;
}
- memset(id, 0, sizeof(*id));
+ memset(id, 0, id_size);
+
cmd.dptr.prp1 = cpu_to_le64(iova);
if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
error_setg(errp, "Failed to identify controller");
@@ -547,7 +549,7 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
s->supports_write_zeroes = !!(oncs & NVME_ONCS_WRITE_ZEROES);
s->supports_discard = !!(oncs & NVME_ONCS_DSM);
- memset(id, 0, sizeof(*id));
+ memset(id, 0, id_size);
cmd.cdw10 = 0;
cmd.nsid = cpu_to_le32(namespace);
if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
--
2.21.3
next prev parent reply other threads:[~2020-10-15 11:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-15 11:52 [RFC 0/5] NVMe passthrough: Support 64kB page host Eric Auger
2020-10-15 11:52 ` [RFC 1/5] block/nvme: use some NVME_CAP_* macros Eric Auger
2020-10-15 13:29 ` Philippe Mathieu-Daudé
2020-10-15 13:32 ` Philippe Mathieu-Daudé
2020-10-15 13:36 ` Philippe Mathieu-Daudé
2020-10-15 16:11 ` Auger Eric
2020-10-15 11:52 ` Eric Auger [this message]
2020-10-20 10:59 ` [RFC 2/5] block/nvme: Change size and alignment of IDENTIFY response buffer Philippe Mathieu-Daudé
2020-10-20 11:31 ` Philippe Mathieu-Daudé
2020-10-15 11:52 ` [RFC 3/5] block/nvme: Change size and alignment of queue Eric Auger
2020-10-15 11:52 ` [RFC 4/5] block/nvme: Change size and alignment of prp_list_pages Eric Auger
2020-10-15 11:52 ` [RFC 5/5] block/nvme: Align iov's va and size on host page size Eric Auger
2020-10-20 11:33 ` Philippe Mathieu-Daudé
2020-10-15 13:49 ` [RFC 0/5] NVMe passthrough: Support 64kB page host Philippe Mathieu-Daudé
2020-10-15 16:15 ` Auger Eric
2020-10-15 18:01 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201015115252.15582-3-eric.auger@redhat.com \
--to=eric.auger@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).