From 130307862b126743edce192e29f436a69ee2203d Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 23 Apr 2018 09:44:43 -0700 Subject: [PATCH] vhost/nvme: fix doorbell buffer size calculation The existing code was using sizeof() on a calculation that already returned the right size, so this would originally just memset() 4 bytes instead of the whole region. The spec requires the doorbell buffer to be exactly one physical memory page, and our controller emulation chooses MPS so that only 4096-byte pages are supported, so just zero out the page and drop the calculation entirely. Change-Id: I71db1bebf0a4d5dbe55fd411786e19a8d6802c20 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/408730 Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker --- lib/vhost/vhost_nvme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vhost/vhost_nvme.c b/lib/vhost/vhost_nvme.c index 142fce816..75065f005 100644 --- a/lib/vhost/vhost_nvme.c +++ b/lib/vhost/vhost_nvme.c @@ -566,8 +566,8 @@ vhost_nvme_doorbell_buffer_config(struct spdk_vhost_nvme_dev *nvme, return -1; } /* zeroed the doorbell buffer memory */ - memset((void *)nvme->dbbuf_dbs, 0, sizeof((nvme->num_sqs + 1) * 8)); - memset((void *)nvme->dbbuf_eis, 0, sizeof((nvme->num_sqs + 1) * 8)); + memset((void *)nvme->dbbuf_dbs, 0, 4096); + memset((void *)nvme->dbbuf_eis, 0, 4096); cpl->status.sc = 0; cpl->status.sct = 0;