mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-25 00:52:45 -04:00
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>
This commit is contained in:
committed by
Michael S. Tsirkin
parent
564a69ad90
commit
4d0efa600e
@@ -28,19 +28,6 @@ struct virtio_vdpa_device {
|
||||
struct virtio_device vdev;
|
||||
struct vdpa_device *vdpa;
|
||||
u64 features;
|
||||
|
||||
/* The lock to protect virtqueue list */
|
||||
spinlock_t lock;
|
||||
/* List of virtio_vdpa_vq_info */
|
||||
struct list_head virtqueues;
|
||||
};
|
||||
|
||||
struct virtio_vdpa_vq_info {
|
||||
/* the actual virtqueue */
|
||||
struct virtqueue *vq;
|
||||
|
||||
/* the list node for the virtqueues list */
|
||||
struct list_head node;
|
||||
};
|
||||
|
||||
static inline struct virtio_vdpa_device *
|
||||
@@ -135,9 +122,9 @@ static irqreturn_t virtio_vdpa_config_cb(void *private)
|
||||
|
||||
static irqreturn_t virtio_vdpa_virtqueue_cb(void *private)
|
||||
{
|
||||
struct virtio_vdpa_vq_info *info = private;
|
||||
struct virtqueue *vq = private;
|
||||
|
||||
return vring_interrupt(0, info->vq);
|
||||
return vring_interrupt(0, vq);
|
||||
}
|
||||
|
||||
static struct virtqueue *
|
||||
@@ -145,18 +132,15 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
|
||||
void (*callback)(struct virtqueue *vq),
|
||||
const char *name, bool ctx)
|
||||
{
|
||||
struct virtio_vdpa_device *vd_dev = to_virtio_vdpa_device(vdev);
|
||||
struct vdpa_device *vdpa = vd_get_vdpa(vdev);
|
||||
struct device *dma_dev;
|
||||
const struct vdpa_config_ops *ops = vdpa->config;
|
||||
struct virtio_vdpa_vq_info *info;
|
||||
bool (*notify)(struct virtqueue *vq) = virtio_vdpa_notify;
|
||||
struct vdpa_callback cb;
|
||||
struct virtqueue *vq;
|
||||
u64 desc_addr, driver_addr, device_addr;
|
||||
/* Assume split virtqueue, switch to packed if necessary */
|
||||
struct vdpa_vq_state state = {0};
|
||||
unsigned long flags;
|
||||
u32 align, max_num, min_num = 1;
|
||||
bool may_reduce_num = true;
|
||||
int err;
|
||||
@@ -179,10 +163,6 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
|
||||
if (ops->get_vq_ready(vdpa, index))
|
||||
return ERR_PTR(-ENOENT);
|
||||
|
||||
/* Allocate and fill out our active queue description */
|
||||
info = kmalloc(sizeof(*info), GFP_KERNEL);
|
||||
if (!info)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
if (ops->get_vq_size)
|
||||
max_num = ops->get_vq_size(vdpa, index);
|
||||
else
|
||||
@@ -217,7 +197,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
|
||||
|
||||
/* Setup virtqueue callback */
|
||||
cb.callback = callback ? virtio_vdpa_virtqueue_cb : NULL;
|
||||
cb.private = info;
|
||||
cb.private = vq;
|
||||
cb.trigger = NULL;
|
||||
ops->set_vq_cb(vdpa, index, &cb);
|
||||
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,
|
||||
|
||||
ops->set_vq_ready(vdpa, index, 1);
|
||||
|
||||
vq->priv = info;
|
||||
info->vq = vq;
|
||||
|
||||
spin_lock_irqsave(&vd_dev->lock, flags);
|
||||
list_add(&info->node, &vd_dev->virtqueues);
|
||||
spin_unlock_irqrestore(&vd_dev->lock, flags);
|
||||
|
||||
return vq;
|
||||
|
||||
err_vq:
|
||||
@@ -263,7 +236,6 @@ error_new_virtqueue:
|
||||
ops->set_vq_ready(vdpa, index, 0);
|
||||
/* VDPA driver should make sure vq is stopeed here */
|
||||
WARN_ON(ops->get_vq_ready(vdpa, index));
|
||||
kfree(info);
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
@@ -272,20 +244,12 @@ static void virtio_vdpa_del_vq(struct virtqueue *vq)
|
||||
struct virtio_vdpa_device *vd_dev = to_virtio_vdpa_device(vq->vdev);
|
||||
struct vdpa_device *vdpa = vd_dev->vdpa;
|
||||
const struct vdpa_config_ops *ops = vdpa->config;
|
||||
struct virtio_vdpa_vq_info *info = vq->priv;
|
||||
unsigned int index = vq->index;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&vd_dev->lock, flags);
|
||||
list_del(&info->node);
|
||||
spin_unlock_irqrestore(&vd_dev->lock, flags);
|
||||
|
||||
/* Select and deactivate the queue (best effort) */
|
||||
ops->set_vq_ready(vdpa, index, 0);
|
||||
|
||||
vring_del_virtqueue(vq);
|
||||
|
||||
kfree(info);
|
||||
}
|
||||
|
||||
static void virtio_vdpa_del_vqs(struct virtio_device *vdev)
|
||||
@@ -501,8 +465,6 @@ static int virtio_vdpa_probe(struct vdpa_device *vdpa)
|
||||
vd_dev->vdev.dev.release = virtio_vdpa_release_dev;
|
||||
vd_dev->vdev.config = &virtio_vdpa_config_ops;
|
||||
vd_dev->vdpa = vdpa;
|
||||
INIT_LIST_HEAD(&vd_dev->virtqueues);
|
||||
spin_lock_init(&vd_dev->lock);
|
||||
|
||||
vd_dev->vdev.id.device = ops->get_device_id(vdpa);
|
||||
if (vd_dev->vdev.id.device == 0)
|
||||
|
||||
Reference in New Issue
Block a user