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

Configure Feed

Select the types of activity you want to include in your feed.

virtio-vdpa: Remove virtqueue list

The virtio vdpa implementation creates a list of virtqueues, while the
same is already available in the struct virtio_device.

This list is never traversed though, and only the pointer to the struct
virtio_vdpa_vq_info is used in the callback, where the virtqueue pointer
could be directly used.

Remove the unwanted code to simplify the driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Message-Id: <7808f2f7e484987b95f172fffb6c71a5da20ed1e.1748503784.git.viresh.kumar@linaro.org>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Eugenio Pérez <eperezma@redhat.com>

authored by

Viresh Kumar and committed by
Michael S. Tsirkin
4d0efa60 564a69ad

+3 -41
+3 -41
drivers/virtio/virtio_vdpa.c
··· 28 28 struct virtio_device vdev; 29 29 struct vdpa_device *vdpa; 30 30 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; 44 31 }; 45 32 46 33 static inline struct virtio_vdpa_device * ··· 122 135 123 136 static irqreturn_t virtio_vdpa_virtqueue_cb(void *private) 124 137 { 125 - struct virtio_vdpa_vq_info *info = private; 138 + struct virtqueue *vq = private; 126 139 127 - return vring_interrupt(0, info->vq); 140 + return vring_interrupt(0, vq); 128 141 } 129 142 130 143 static struct virtqueue * ··· 132 145 void (*callback)(struct virtqueue *vq), 133 146 const char *name, bool ctx) 134 147 { 135 - struct virtio_vdpa_device *vd_dev = to_virtio_vdpa_device(vdev); 136 148 struct vdpa_device *vdpa = vd_get_vdpa(vdev); 137 149 struct device *dma_dev; 138 150 const struct vdpa_config_ops *ops = vdpa->config; 139 - struct virtio_vdpa_vq_info *info; 140 151 bool (*notify)(struct virtqueue *vq) = virtio_vdpa_notify; 141 152 struct vdpa_callback cb; 142 153 struct virtqueue *vq; 143 154 u64 desc_addr, driver_addr, device_addr; 144 155 /* Assume split virtqueue, switch to packed if necessary */ 145 156 struct vdpa_vq_state state = {0}; 146 - unsigned long flags; 147 157 u32 align, max_num, min_num = 1; 148 158 bool may_reduce_num = true; 149 159 int err; ··· 163 179 if (ops->get_vq_ready(vdpa, index)) 164 180 return ERR_PTR(-ENOENT); 165 181 166 - /* Allocate and fill out our active queue description */ 167 - info = kmalloc(sizeof(*info), GFP_KERNEL); 168 - if (!info) 169 - return ERR_PTR(-ENOMEM); 170 182 if (ops->get_vq_size) 171 183 max_num = ops->get_vq_size(vdpa, index); 172 184 else ··· 197 217 198 218 /* Setup virtqueue callback */ 199 219 cb.callback = callback ? virtio_vdpa_virtqueue_cb : NULL; 200 - cb.private = info; 220 + cb.private = vq; 201 221 cb.trigger = NULL; 202 222 ops->set_vq_cb(vdpa, index, &cb); 203 223 ops->set_vq_num(vdpa, index, virtqueue_get_vring_size(vq)); ··· 228 248 229 249 ops->set_vq_ready(vdpa, index, 1); 230 250 231 - vq->priv = info; 232 - info->vq = vq; 233 - 234 - spin_lock_irqsave(&vd_dev->lock, flags); 235 - list_add(&info->node, &vd_dev->virtqueues); 236 - spin_unlock_irqrestore(&vd_dev->lock, flags); 237 - 238 251 return vq; 239 252 240 253 err_vq: ··· 236 263 ops->set_vq_ready(vdpa, index, 0); 237 264 /* VDPA driver should make sure vq is stopeed here */ 238 265 WARN_ON(ops->get_vq_ready(vdpa, index)); 239 - kfree(info); 240 266 return ERR_PTR(err); 241 267 } 242 268 ··· 244 272 struct virtio_vdpa_device *vd_dev = to_virtio_vdpa_device(vq->vdev); 245 273 struct vdpa_device *vdpa = vd_dev->vdpa; 246 274 const struct vdpa_config_ops *ops = vdpa->config; 247 - struct virtio_vdpa_vq_info *info = vq->priv; 248 275 unsigned int index = vq->index; 249 - unsigned long flags; 250 - 251 - spin_lock_irqsave(&vd_dev->lock, flags); 252 - list_del(&info->node); 253 - spin_unlock_irqrestore(&vd_dev->lock, flags); 254 276 255 277 /* Select and deactivate the queue (best effort) */ 256 278 ops->set_vq_ready(vdpa, index, 0); 257 279 258 280 vring_del_virtqueue(vq); 259 - 260 - kfree(info); 261 281 } 262 282 263 283 static void virtio_vdpa_del_vqs(struct virtio_device *vdev) ··· 465 501 vd_dev->vdev.dev.release = virtio_vdpa_release_dev; 466 502 vd_dev->vdev.config = &virtio_vdpa_config_ops; 467 503 vd_dev->vdpa = vdpa; 468 - INIT_LIST_HEAD(&vd_dev->virtqueues); 469 - spin_lock_init(&vd_dev->lock); 470 504 471 505 vd_dev->vdev.id.device = ops->get_device_id(vdpa); 472 506 if (vd_dev->vdev.id.device == 0)