Skip to content

Commit 59dfe4f

Browse files
YongjiXiemstsirkin
authored andcommitted
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 <[email protected]> Signed-off-by: Xie Yongji <[email protected]> Acked-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 7f05630 commit 59dfe4f

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

drivers/vhost/iotlb.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,21 @@ void vhost_iotlb_map_free(struct vhost_iotlb *iotlb,
3636
EXPORT_SYMBOL_GPL(vhost_iotlb_map_free);
3737

3838
/**
39-
* vhost_iotlb_add_range - add a new range to vhost IOTLB
39+
* vhost_iotlb_add_range_ctx - add a new range to vhost IOTLB
4040
* @iotlb: the IOTLB
4141
* @start: start of the IOVA range
4242
* @last: last of IOVA range
4343
* @addr: the address that is mapped to @start
4444
* @perm: access permission of this range
45+
* @opaque: the opaque pointer for the new mapping
4546
*
4647
* Returns an error last is smaller than start or memory allocation
4748
* fails
4849
*/
49-
int vhost_iotlb_add_range(struct vhost_iotlb *iotlb,
50-
u64 start, u64 last,
51-
u64 addr, unsigned int perm)
50+
int vhost_iotlb_add_range_ctx(struct vhost_iotlb *iotlb,
51+
u64 start, u64 last,
52+
u64 addr, unsigned int perm,
53+
void *opaque)
5254
{
5355
struct vhost_iotlb_map *map;
5456

@@ -71,6 +73,7 @@ int vhost_iotlb_add_range(struct vhost_iotlb *iotlb,
7173
map->last = last;
7274
map->addr = addr;
7375
map->perm = perm;
76+
map->opaque = opaque;
7477

7578
iotlb->nmaps++;
7679
vhost_iotlb_itree_insert(map, &iotlb->root);
@@ -80,6 +83,15 @@ int vhost_iotlb_add_range(struct vhost_iotlb *iotlb,
8083

8184
return 0;
8285
}
86+
EXPORT_SYMBOL_GPL(vhost_iotlb_add_range_ctx);
87+
88+
int vhost_iotlb_add_range(struct vhost_iotlb *iotlb,
89+
u64 start, u64 last,
90+
u64 addr, unsigned int perm)
91+
{
92+
return vhost_iotlb_add_range_ctx(iotlb, start, last,
93+
addr, perm, NULL);
94+
}
8395
EXPORT_SYMBOL_GPL(vhost_iotlb_add_range);
8496

8597
/**

include/linux/vhost_iotlb.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ struct vhost_iotlb_map {
1717
u32 perm;
1818
u32 flags_padding;
1919
u64 __subtree_last;
20+
void *opaque;
2021
};
2122

2223
#define VHOST_IOTLB_FLAG_RETIRE 0x1
@@ -29,6 +30,8 @@ struct vhost_iotlb {
2930
unsigned int flags;
3031
};
3132

33+
int vhost_iotlb_add_range_ctx(struct vhost_iotlb *iotlb, u64 start, u64 last,
34+
u64 addr, unsigned int perm, void *opaque);
3235
int vhost_iotlb_add_range(struct vhost_iotlb *iotlb, u64 start, u64 last,
3336
u64 addr, unsigned int perm);
3437
void vhost_iotlb_del_range(struct vhost_iotlb *iotlb, u64 start, u64 last);

0 commit comments

Comments
 (0)