Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vhost_iotlb: split out IOTLB initialization

This patch splits out IOTLB initialization to make sure it could be
reused by external modules.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Gautam Dawar <gdawar@xilinx.com>
Message-Id: <20220330180436.24644-9-gdawar@xilinx.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Gautam Dawar and committed by
Michael S. Tsirkin
1cb10899 46d554b1

+20 -5
+18 -5
drivers/vhost/iotlb.c
··· 126 126 EXPORT_SYMBOL_GPL(vhost_iotlb_del_range); 127 127 128 128 /** 129 + * vhost_iotlb_init - initialize a vhost IOTLB 130 + * @iotlb: the IOTLB that needs to be initialized 131 + * @limit: maximum number of IOTLB entries 132 + * @flags: VHOST_IOTLB_FLAG_XXX 133 + */ 134 + void vhost_iotlb_init(struct vhost_iotlb *iotlb, unsigned int limit, 135 + unsigned int flags) 136 + { 137 + iotlb->root = RB_ROOT_CACHED; 138 + iotlb->limit = limit; 139 + iotlb->nmaps = 0; 140 + iotlb->flags = flags; 141 + INIT_LIST_HEAD(&iotlb->list); 142 + } 143 + EXPORT_SYMBOL_GPL(vhost_iotlb_init); 144 + 145 + /** 129 146 * vhost_iotlb_alloc - add a new vhost IOTLB 130 147 * @limit: maximum number of IOTLB entries 131 148 * @flags: VHOST_IOTLB_FLAG_XXX ··· 156 139 if (!iotlb) 157 140 return NULL; 158 141 159 - iotlb->root = RB_ROOT_CACHED; 160 - iotlb->limit = limit; 161 - iotlb->nmaps = 0; 162 - iotlb->flags = flags; 163 - INIT_LIST_HEAD(&iotlb->list); 142 + vhost_iotlb_init(iotlb, limit, flags); 164 143 165 144 return iotlb; 166 145 }
+2
include/linux/vhost_iotlb.h
··· 36 36 u64 addr, unsigned int perm); 37 37 void vhost_iotlb_del_range(struct vhost_iotlb *iotlb, u64 start, u64 last); 38 38 39 + void vhost_iotlb_init(struct vhost_iotlb *iotlb, unsigned int limit, 40 + unsigned int flags); 39 41 struct vhost_iotlb *vhost_iotlb_alloc(unsigned int limit, unsigned int flags); 40 42 void vhost_iotlb_free(struct vhost_iotlb *iotlb); 41 43 void vhost_iotlb_reset(struct vhost_iotlb *iotlb);