vhost-iotlb: Add an opaque pointer for vhost IOTLB
Add an opaque pointer for vhost IOTLB. And introduce vhost_iotlb_add_range_ctx() to accept it. Suggested-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Xie Yongji <xieyongji@bytedance.com> Acked-by: Jason Wang <jasowang@redhat.com> Link: https://lore.kernel.org/r/20210831103634.33-8-xieyongji@bytedance.com Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Родитель
7f05630dc6
Коммит
59dfe4f1e8
|
@ -36,19 +36,21 @@ void vhost_iotlb_map_free(struct vhost_iotlb *iotlb,
|
||||||
EXPORT_SYMBOL_GPL(vhost_iotlb_map_free);
|
EXPORT_SYMBOL_GPL(vhost_iotlb_map_free);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vhost_iotlb_add_range - add a new range to vhost IOTLB
|
* vhost_iotlb_add_range_ctx - add a new range to vhost IOTLB
|
||||||
* @iotlb: the IOTLB
|
* @iotlb: the IOTLB
|
||||||
* @start: start of the IOVA range
|
* @start: start of the IOVA range
|
||||||
* @last: last of IOVA range
|
* @last: last of IOVA range
|
||||||
* @addr: the address that is mapped to @start
|
* @addr: the address that is mapped to @start
|
||||||
* @perm: access permission of this range
|
* @perm: access permission of this range
|
||||||
|
* @opaque: the opaque pointer for the new mapping
|
||||||
*
|
*
|
||||||
* Returns an error last is smaller than start or memory allocation
|
* Returns an error last is smaller than start or memory allocation
|
||||||
* fails
|
* fails
|
||||||
*/
|
*/
|
||||||
int vhost_iotlb_add_range(struct vhost_iotlb *iotlb,
|
int vhost_iotlb_add_range_ctx(struct vhost_iotlb *iotlb,
|
||||||
u64 start, u64 last,
|
u64 start, u64 last,
|
||||||
u64 addr, unsigned int perm)
|
u64 addr, unsigned int perm,
|
||||||
|
void *opaque)
|
||||||
{
|
{
|
||||||
struct vhost_iotlb_map *map;
|
struct vhost_iotlb_map *map;
|
||||||
|
|
||||||
|
@ -71,6 +73,7 @@ int vhost_iotlb_add_range(struct vhost_iotlb *iotlb,
|
||||||
map->last = last;
|
map->last = last;
|
||||||
map->addr = addr;
|
map->addr = addr;
|
||||||
map->perm = perm;
|
map->perm = perm;
|
||||||
|
map->opaque = opaque;
|
||||||
|
|
||||||
iotlb->nmaps++;
|
iotlb->nmaps++;
|
||||||
vhost_iotlb_itree_insert(map, &iotlb->root);
|
vhost_iotlb_itree_insert(map, &iotlb->root);
|
||||||
|
@ -80,6 +83,15 @@ int vhost_iotlb_add_range(struct vhost_iotlb *iotlb,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(vhost_iotlb_add_range_ctx);
|
||||||
|
|
||||||
|
int vhost_iotlb_add_range(struct vhost_iotlb *iotlb,
|
||||||
|
u64 start, u64 last,
|
||||||
|
u64 addr, unsigned int perm)
|
||||||
|
{
|
||||||
|
return vhost_iotlb_add_range_ctx(iotlb, start, last,
|
||||||
|
addr, perm, NULL);
|
||||||
|
}
|
||||||
EXPORT_SYMBOL_GPL(vhost_iotlb_add_range);
|
EXPORT_SYMBOL_GPL(vhost_iotlb_add_range);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,6 +17,7 @@ struct vhost_iotlb_map {
|
||||||
u32 perm;
|
u32 perm;
|
||||||
u32 flags_padding;
|
u32 flags_padding;
|
||||||
u64 __subtree_last;
|
u64 __subtree_last;
|
||||||
|
void *opaque;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define VHOST_IOTLB_FLAG_RETIRE 0x1
|
#define VHOST_IOTLB_FLAG_RETIRE 0x1
|
||||||
|
@ -29,6 +30,8 @@ struct vhost_iotlb {
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int vhost_iotlb_add_range_ctx(struct vhost_iotlb *iotlb, u64 start, u64 last,
|
||||||
|
u64 addr, unsigned int perm, void *opaque);
|
||||||
int vhost_iotlb_add_range(struct vhost_iotlb *iotlb, u64 start, u64 last,
|
int vhost_iotlb_add_range(struct vhost_iotlb *iotlb, u64 start, u64 last,
|
||||||
u64 addr, unsigned int perm);
|
u64 addr, unsigned int perm);
|
||||||
void vhost_iotlb_del_range(struct vhost_iotlb *iotlb, u64 start, u64 last);
|
void vhost_iotlb_del_range(struct vhost_iotlb *iotlb, u64 start, u64 last);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче