[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/11] nvme: properly report volatile write caches
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 02/11] nvme: properly report volatile write caches |
Date: |
Tue, 14 Jul 2015 17:39:23 +0200 |
From: Christoph Hellwig <address@hidden>
Implement support in Identify and Get/Set Features to properly report
and allow to change the Volatile Write Cache status reported by the
virtual NVMe device.
Signed-off-by: Christoph Hellwig <address@hidden>
Acked-by: Keith Busch <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
hw/block/nvme.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index dc9caf0..40d4880 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -487,26 +487,32 @@ static uint16_t nvme_identify(NvmeCtrl *n, NvmeCmd *cmd)
static uint16_t nvme_get_feature(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
{
uint32_t dw10 = le32_to_cpu(cmd->cdw10);
+ uint32_t result;
switch (dw10) {
- case NVME_NUMBER_OF_QUEUES:
- req->cqe.result =
- cpu_to_le32((n->num_queues - 1) | ((n->num_queues - 1) << 16));
- break;
case NVME_VOLATILE_WRITE_CACHE:
- req->cqe.result = cpu_to_le32(1);
+ result = blk_enable_write_cache(n->conf.blk);
+ break;
+ case NVME_NUMBER_OF_QUEUES:
+ result = cpu_to_le32((n->num_queues - 1) | ((n->num_queues - 1) <<
16));
break;
default:
return NVME_INVALID_FIELD | NVME_DNR;
}
+
+ req->cqe.result = result;
return NVME_SUCCESS;
}
static uint16_t nvme_set_feature(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
{
uint32_t dw10 = le32_to_cpu(cmd->cdw10);
+ uint32_t dw11 = le32_to_cpu(cmd->cdw11);
switch (dw10) {
+ case NVME_VOLATILE_WRITE_CACHE:
+ blk_set_enable_write_cache(n->conf.blk, dw11 & 1);
+ break;
case NVME_NUMBER_OF_QUEUES:
req->cqe.result =
cpu_to_le32((n->num_queues - 1) | ((n->num_queues - 1) << 16));
@@ -831,6 +837,9 @@ static int nvme_init(PCIDevice *pci_dev)
id->psd[0].mp = cpu_to_le16(0x9c4);
id->psd[0].enlat = cpu_to_le32(0x10);
id->psd[0].exlat = cpu_to_le32(0x4);
+ if (blk_enable_write_cache(n->conf.blk)) {
+ id->vwc = 1;
+ }
n->bar.cap = 0;
NVME_CAP_SET_MQES(n->bar.cap, 0x7ff);
--
1.8.3.1
- [Qemu-devel] [PULL 00/11] Block layer patches for 2.4.0-rc1, Kevin Wolf, 2015/07/14
- [Qemu-devel] [PULL 02/11] nvme: properly report volatile write caches,
Kevin Wolf <=
- [Qemu-devel] [PULL 03/11] block: Move bdrv_attach_child() calls up the call chain, Kevin Wolf, 2015/07/14
- [Qemu-devel] [PULL 01/11] nvme: implement the Flush command, Kevin Wolf, 2015/07/14
- [Qemu-devel] [PULL 05/11] block: Introduce bdrv_unref_child(), Kevin Wolf, 2015/07/14
- [Qemu-devel] [PULL 04/11] block: Introduce bdrv_open_child(), Kevin Wolf, 2015/07/14
- [Qemu-devel] [PULL 06/11] block: Reorder cleanups in bdrv_close(), Kevin Wolf, 2015/07/14
- [Qemu-devel] [PULL 08/11] rbd: remove unused constants and fields, Kevin Wolf, 2015/07/14
- [Qemu-devel] [PULL 09/11] MAINTAINERS: update email address, Kevin Wolf, 2015/07/14
- [Qemu-devel] [PULL 07/11] block: Fix backing file child when modifying graph, Kevin Wolf, 2015/07/14
- [Qemu-devel] [PULL 11/11] rbd: fix ceph settings precedence, Kevin Wolf, 2015/07/14
- [Qemu-devel] [PULL 10/11] rbd: make qemu's cache setting override any ceph setting, Kevin Wolf, 2015/07/14