@@ -28,19 +28,6 @@ struct virtio_vdpa_device {
2828 struct virtio_device vdev ;
2929 struct vdpa_device * vdpa ;
3030 u64 features ;
31-
32- /* The lock to protect virtqueue list */
33- spinlock_t lock ;
34- /* List of virtio_vdpa_vq_info */
35- struct list_head virtqueues ;
36- };
37-
38- struct virtio_vdpa_vq_info {
39- /* the actual virtqueue */
40- struct virtqueue * vq ;
41-
42- /* the list node for the virtqueues list */
43- struct list_head node ;
4431};
4532
4633static inline struct virtio_vdpa_device *
@@ -135,28 +122,25 @@ static irqreturn_t virtio_vdpa_config_cb(void *private)
135122
136123static irqreturn_t virtio_vdpa_virtqueue_cb (void * private )
137124{
138- struct virtio_vdpa_vq_info * info = private ;
125+ struct virtqueue * vq = private ;
139126
140- return vring_interrupt (0 , info -> vq );
127+ return vring_interrupt (0 , vq );
141128}
142129
143130static struct virtqueue *
144131virtio_vdpa_setup_vq (struct virtio_device * vdev , unsigned int index ,
145132 void (* callback )(struct virtqueue * vq ),
146133 const char * name , bool ctx )
147134{
148- struct virtio_vdpa_device * vd_dev = to_virtio_vdpa_device (vdev );
149135 struct vdpa_device * vdpa = vd_get_vdpa (vdev );
150136 struct device * dma_dev ;
151137 const struct vdpa_config_ops * ops = vdpa -> config ;
152- struct virtio_vdpa_vq_info * info ;
153138 bool (* notify )(struct virtqueue * vq ) = virtio_vdpa_notify ;
154139 struct vdpa_callback cb ;
155140 struct virtqueue * vq ;
156141 u64 desc_addr , driver_addr , device_addr ;
157142 /* Assume split virtqueue, switch to packed if necessary */
158143 struct vdpa_vq_state state = {0 };
159- unsigned long flags ;
160144 u32 align , max_num , min_num = 1 ;
161145 bool may_reduce_num = true;
162146 int err ;
@@ -179,10 +163,6 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
179163 if (ops -> get_vq_ready (vdpa , index ))
180164 return ERR_PTR (- ENOENT );
181165
182- /* Allocate and fill out our active queue description */
183- info = kmalloc (sizeof (* info ), GFP_KERNEL );
184- if (!info )
185- return ERR_PTR (- ENOMEM );
186166 if (ops -> get_vq_size )
187167 max_num = ops -> get_vq_size (vdpa , index );
188168 else
@@ -217,7 +197,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
217197
218198 /* Setup virtqueue callback */
219199 cb .callback = callback ? virtio_vdpa_virtqueue_cb : NULL ;
220- cb .private = info ;
200+ cb .private = vq ;
221201 cb .trigger = NULL ;
222202 ops -> set_vq_cb (vdpa , index , & cb );
223203 ops -> set_vq_num (vdpa , index , virtqueue_get_vring_size (vq ));
@@ -248,13 +228,6 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
248228
249229 ops -> set_vq_ready (vdpa , index , 1 );
250230
251- vq -> priv = info ;
252- info -> vq = vq ;
253-
254- spin_lock_irqsave (& vd_dev -> lock , flags );
255- list_add (& info -> node , & vd_dev -> virtqueues );
256- spin_unlock_irqrestore (& vd_dev -> lock , flags );
257-
258231 return vq ;
259232
260233err_vq :
@@ -263,7 +236,6 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
263236 ops -> set_vq_ready (vdpa , index , 0 );
264237 /* VDPA driver should make sure vq is stopeed here */
265238 WARN_ON (ops -> get_vq_ready (vdpa , index ));
266- kfree (info );
267239 return ERR_PTR (err );
268240}
269241
@@ -272,20 +244,12 @@ static void virtio_vdpa_del_vq(struct virtqueue *vq)
272244 struct virtio_vdpa_device * vd_dev = to_virtio_vdpa_device (vq -> vdev );
273245 struct vdpa_device * vdpa = vd_dev -> vdpa ;
274246 const struct vdpa_config_ops * ops = vdpa -> config ;
275- struct virtio_vdpa_vq_info * info = vq -> priv ;
276247 unsigned int index = vq -> index ;
277- unsigned long flags ;
278-
279- spin_lock_irqsave (& vd_dev -> lock , flags );
280- list_del (& info -> node );
281- spin_unlock_irqrestore (& vd_dev -> lock , flags );
282248
283249 /* Select and deactivate the queue (best effort) */
284250 ops -> set_vq_ready (vdpa , index , 0 );
285251
286252 vring_del_virtqueue (vq );
287-
288- kfree (info );
289253}
290254
291255static void virtio_vdpa_del_vqs (struct virtio_device * vdev )
@@ -501,8 +465,6 @@ static int virtio_vdpa_probe(struct vdpa_device *vdpa)
501465 vd_dev -> vdev .dev .release = virtio_vdpa_release_dev ;
502466 vd_dev -> vdev .config = & virtio_vdpa_config_ops ;
503467 vd_dev -> vdpa = vdpa ;
504- INIT_LIST_HEAD (& vd_dev -> virtqueues );
505- spin_lock_init (& vd_dev -> lock );
506468
507469 vd_dev -> vdev .id .device = ops -> get_device_id (vdpa );
508470 if (vd_dev -> vdev .id .device == 0 )
0 commit comments