Skip to content

Commit

Permalink
nvme: use iommu_dmabuf api
Browse files Browse the repository at this point in the history
Replace all pgmap/iommu_map_vaddr pairs with iommu_get/put_dmabuf.

Signed-off-by: Klaus Jensen <[email protected]>
  • Loading branch information
birkelund committed Sep 6, 2024
1 parent 6476e80 commit 9866a6d
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 133 deletions.
1 change: 1 addition & 0 deletions include/vfn/nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extern "C" {
#include <vfn/trace.h>
#include <vfn/trace/events.h>
#include <vfn/iommu.h>
#include <vfn/iommu/dmabuf.h>
#include <vfn/vfio.h>
#include <vfn/nvme/types.h>
#include <vfn/nvme/queue.h>
Expand Down
4 changes: 2 additions & 2 deletions include/vfn/nvme/ctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ struct nvme_ctrl {
* @dbbuf: doorbell buffers
*/
struct {
void *doorbells;
void *eventidxs;
struct iommu_dmabuf doorbells;
struct iommu_dmabuf eventidxs;
} dbbuf;

/**
Expand Down
16 changes: 5 additions & 11 deletions include/vfn/nvme/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ struct nvme_dbbuf {
*/
struct nvme_cq {
/* private: */
void *vaddr;
uint64_t iova;
struct iommu_dmabuf mem;

int id;
uint16_t head;
Expand All @@ -51,13 +50,8 @@ struct nvme_sq {
/* private: */
struct nvme_cq *cq;

void *vaddr;
uint64_t iova;

struct {
void *vaddr;
uint64_t iova;
} pages;
struct iommu_dmabuf mem;
struct iommu_dmabuf pages;

uint16_t tail, ptail;
int qsize;
Expand All @@ -84,7 +78,7 @@ struct nvme_sq {
*/
static inline void nvme_sq_post(struct nvme_sq *sq, const union nvme_cmd *sqe)
{
memcpy(sq->vaddr + (sq->tail << NVME_SQES), sqe, 1 << NVME_SQES);
memcpy(sq->mem.vaddr + (sq->tail << NVME_SQES), sqe, 1 << NVME_SQES);

trace_guard(NVME_SQ_POST) {
trace_emit("sqid %d tail %d\n", sq->id, sq->tail);
Expand Down Expand Up @@ -174,7 +168,7 @@ static inline void nvme_sq_exec(struct nvme_sq *sq, const union nvme_cmd *sqe)
*/
static inline struct nvme_cqe *nvme_cq_head(struct nvme_cq *cq)
{
return (struct nvme_cqe *)(cq->vaddr + (cq->head << NVME_CQES));
return (struct nvme_cqe *)(cq->mem.vaddr + (cq->head << NVME_CQES));
}

/**
Expand Down
Loading

0 comments on commit 9866a6d

Please sign in to comment.