mirror of
https://github.com/torvalds/linux.git
synced 2024-12-05 02:23:16 +00:00
6e84200c0a
This patch adds virtio-pmem driver for KVM guest. Guest reads the persistent memory range information from Qemu over VIRTIO and registers it on nvdimm_bus. It also creates a nd_region object with the persistent memory range information so that existing 'nvdimm/pmem' driver can reserve this into system memory map. This way 'virtio-pmem' driver uses existing functionality of pmem driver to register persistent memory compatible for DAX capable filesystems. This also provides function to perform guest flush over VIRTIO from 'pmem' driver when userspace performs flush on DAX memory range. Signed-off-by: Pankaj Gupta <pagupta@redhat.com> Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jakub Staron <jstaron@google.com> Tested-by: Jakub Staron <jstaron@google.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
56 lines
1.3 KiB
C
56 lines
1.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* virtio_pmem.h: virtio pmem Driver
|
|
*
|
|
* Discovers persistent memory range information
|
|
* from host and provides a virtio based flushing
|
|
* interface.
|
|
**/
|
|
|
|
#ifndef _LINUX_VIRTIO_PMEM_H
|
|
#define _LINUX_VIRTIO_PMEM_H
|
|
|
|
#include <linux/module.h>
|
|
#include <uapi/linux/virtio_pmem.h>
|
|
#include <linux/libnvdimm.h>
|
|
#include <linux/spinlock.h>
|
|
|
|
struct virtio_pmem_request {
|
|
struct virtio_pmem_req req;
|
|
struct virtio_pmem_resp resp;
|
|
|
|
/* Wait queue to process deferred work after ack from host */
|
|
wait_queue_head_t host_acked;
|
|
bool done;
|
|
|
|
/* Wait queue to process deferred work after virt queue buffer avail */
|
|
wait_queue_head_t wq_buf;
|
|
bool wq_buf_avail;
|
|
struct list_head list;
|
|
};
|
|
|
|
struct virtio_pmem {
|
|
struct virtio_device *vdev;
|
|
|
|
/* Virtio pmem request queue */
|
|
struct virtqueue *req_vq;
|
|
|
|
/* nvdimm bus registers virtio pmem device */
|
|
struct nvdimm_bus *nvdimm_bus;
|
|
struct nvdimm_bus_descriptor nd_desc;
|
|
|
|
/* List to store deferred work if virtqueue is full */
|
|
struct list_head req_list;
|
|
|
|
/* Synchronize virtqueue data */
|
|
spinlock_t pmem_lock;
|
|
|
|
/* Memory region information */
|
|
__u64 start;
|
|
__u64 size;
|
|
};
|
|
|
|
void virtio_pmem_host_ack(struct virtqueue *vq);
|
|
int async_pmem_flush(struct nd_region *nd_region, struct bio *bio);
|
|
#endif
|