virtio_pmem.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * virtio_pmem.h: virtio pmem Driver
  4. *
  5. * Discovers persistent memory range information
  6. * from host and provides a virtio based flushing
  7. * interface.
  8. **/
  9. #ifndef _LINUX_VIRTIO_PMEM_H
  10. #define _LINUX_VIRTIO_PMEM_H
  11. #include <linux/module.h>
  12. #include <uapi/linux/virtio_pmem.h>
  13. #include <linux/libnvdimm.h>
  14. #include <linux/mutex.h>
  15. #include <linux/spinlock.h>
  16. struct virtio_pmem_request {
  17. struct virtio_pmem_req req;
  18. struct virtio_pmem_resp resp;
  19. /* Wait queue to process deferred work after ack from host */
  20. wait_queue_head_t host_acked;
  21. bool done;
  22. /* Wait queue to process deferred work after virt queue buffer avail */
  23. wait_queue_head_t wq_buf;
  24. bool wq_buf_avail;
  25. struct list_head list;
  26. };
  27. struct virtio_pmem {
  28. struct virtio_device *vdev;
  29. /* Virtio pmem request queue */
  30. struct virtqueue *req_vq;
  31. /* Serialize flush requests to the device. */
  32. struct mutex flush_lock;
  33. /* nvdimm bus registers virtio pmem device */
  34. struct nvdimm_bus *nvdimm_bus;
  35. struct nvdimm_bus_descriptor nd_desc;
  36. /* List to store deferred work if virtqueue is full */
  37. struct list_head req_list;
  38. /* Synchronize virtqueue data */
  39. spinlock_t pmem_lock;
  40. /* Memory region information */
  41. __u64 start;
  42. __u64 size;
  43. };
  44. void virtio_pmem_host_ack(struct virtqueue *vq);
  45. int async_pmem_flush(struct nd_region *nd_region, struct bio *bio);
  46. #endif