Commit 16ffc3ee authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-virtio

* git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-virtio:
  virtio: enhance id_matching for virtio drivers
  virtio: fix id_matching for virtio drivers
  virtio: handle short buffers in virtio_rng.
  virtio_blk: add missing __dev{init,exit} markings
  virtio: indirect ring entries (VIRTIO_RING_F_INDIRECT_DESC)
  virtio: teach virtio_has_feature() about transport features
  virtio: expose features in sysfs
  virtio_pci: optional MSI-X support
  virtio_pci: split up vp_interrupt
  virtio: find_vqs/del_vqs virtio operations
  virtio: add names to virtqueue struct, mapping from devices to queues.
  virtio: meet virtio spec by finalizing features before using device
  virtio: fix obsolete documentation on probe function
parents c34752bc e3353853
...@@ -254,7 +254,7 @@ static int index_to_minor(int index) ...@@ -254,7 +254,7 @@ static int index_to_minor(int index)
return index << PART_BITS; return index << PART_BITS;
} }
static int virtblk_probe(struct virtio_device *vdev) static int __devinit virtblk_probe(struct virtio_device *vdev)
{ {
struct virtio_blk *vblk; struct virtio_blk *vblk;
int err; int err;
...@@ -288,7 +288,7 @@ static int virtblk_probe(struct virtio_device *vdev) ...@@ -288,7 +288,7 @@ static int virtblk_probe(struct virtio_device *vdev)
sg_init_table(vblk->sg, vblk->sg_elems); sg_init_table(vblk->sg, vblk->sg_elems);
/* We expect one virtqueue, for output. */ /* We expect one virtqueue, for output. */
vblk->vq = vdev->config->find_vq(vdev, 0, blk_done); vblk->vq = virtio_find_single_vq(vdev, blk_done, "requests");
if (IS_ERR(vblk->vq)) { if (IS_ERR(vblk->vq)) {
err = PTR_ERR(vblk->vq); err = PTR_ERR(vblk->vq);
goto out_free_vblk; goto out_free_vblk;
...@@ -388,14 +388,14 @@ static int virtblk_probe(struct virtio_device *vdev) ...@@ -388,14 +388,14 @@ static int virtblk_probe(struct virtio_device *vdev)
out_mempool: out_mempool:
mempool_destroy(vblk->pool); mempool_destroy(vblk->pool);
out_free_vq: out_free_vq:
vdev->config->del_vq(vblk->vq); vdev->config->del_vqs(vdev);
out_free_vblk: out_free_vblk:
kfree(vblk); kfree(vblk);
out: out:
return err; return err;
} }
static void virtblk_remove(struct virtio_device *vdev) static void __devexit virtblk_remove(struct virtio_device *vdev)
{ {
struct virtio_blk *vblk = vdev->priv; struct virtio_blk *vblk = vdev->priv;
...@@ -409,7 +409,7 @@ static void virtblk_remove(struct virtio_device *vdev) ...@@ -409,7 +409,7 @@ static void virtblk_remove(struct virtio_device *vdev)
blk_cleanup_queue(vblk->disk->queue); blk_cleanup_queue(vblk->disk->queue);
put_disk(vblk->disk); put_disk(vblk->disk);
mempool_destroy(vblk->pool); mempool_destroy(vblk->pool);
vdev->config->del_vq(vblk->vq); vdev->config->del_vqs(vdev);
kfree(vblk); kfree(vblk);
} }
......
...@@ -35,13 +35,13 @@ static DECLARE_COMPLETION(have_data); ...@@ -35,13 +35,13 @@ static DECLARE_COMPLETION(have_data);
static void random_recv_done(struct virtqueue *vq) static void random_recv_done(struct virtqueue *vq)
{ {
int len; unsigned int len;
/* We can get spurious callbacks, e.g. shared IRQs + virtio_pci. */ /* We can get spurious callbacks, e.g. shared IRQs + virtio_pci. */
if (!vq->vq_ops->get_buf(vq, &len)) if (!vq->vq_ops->get_buf(vq, &len))
return; return;
data_left = len / sizeof(random_data[0]); data_left += len;
complete(&have_data); complete(&have_data);
} }
...@@ -49,7 +49,7 @@ static void register_buffer(void) ...@@ -49,7 +49,7 @@ static void register_buffer(void)
{ {
struct scatterlist sg; struct scatterlist sg;
sg_init_one(&sg, random_data, RANDOM_DATA_SIZE); sg_init_one(&sg, random_data+data_left, RANDOM_DATA_SIZE-data_left);
/* There should always be room for one buffer. */ /* There should always be room for one buffer. */
if (vq->vq_ops->add_buf(vq, &sg, 0, 1, random_data) != 0) if (vq->vq_ops->add_buf(vq, &sg, 0, 1, random_data) != 0)
BUG(); BUG();
...@@ -59,24 +59,32 @@ static void register_buffer(void) ...@@ -59,24 +59,32 @@ static void register_buffer(void)
/* At least we don't udelay() in a loop like some other drivers. */ /* At least we don't udelay() in a loop like some other drivers. */
static int virtio_data_present(struct hwrng *rng, int wait) static int virtio_data_present(struct hwrng *rng, int wait)
{ {
if (data_left) if (data_left >= sizeof(u32))
return 1; return 1;
again:
if (!wait) if (!wait)
return 0; return 0;
wait_for_completion(&have_data); wait_for_completion(&have_data);
/* Not enough? Re-register. */
if (unlikely(data_left < sizeof(u32))) {
register_buffer();
goto again;
}
return 1; return 1;
} }
/* virtio_data_present() must have succeeded before this is called. */ /* virtio_data_present() must have succeeded before this is called. */
static int virtio_data_read(struct hwrng *rng, u32 *data) static int virtio_data_read(struct hwrng *rng, u32 *data)
{ {
BUG_ON(!data_left); BUG_ON(data_left < sizeof(u32));
data_left -= sizeof(u32);
*data = random_data[--data_left]; *data = random_data[data_left / 4];
if (!data_left) { if (data_left < sizeof(u32)) {
init_completion(&have_data); init_completion(&have_data);
register_buffer(); register_buffer();
} }
...@@ -94,13 +102,13 @@ static int virtrng_probe(struct virtio_device *vdev) ...@@ -94,13 +102,13 @@ static int virtrng_probe(struct virtio_device *vdev)
int err; int err;
/* We expect a single virtqueue. */ /* We expect a single virtqueue. */
vq = vdev->config->find_vq(vdev, 0, random_recv_done); vq = virtio_find_single_vq(vdev, random_recv_done, "input");
if (IS_ERR(vq)) if (IS_ERR(vq))
return PTR_ERR(vq); return PTR_ERR(vq);
err = hwrng_register(&virtio_hwrng); err = hwrng_register(&virtio_hwrng);
if (err) { if (err) {
vdev->config->del_vq(vq); vdev->config->del_vqs(vdev);
return err; return err;
} }
...@@ -112,7 +120,7 @@ static void virtrng_remove(struct virtio_device *vdev) ...@@ -112,7 +120,7 @@ static void virtrng_remove(struct virtio_device *vdev)
{ {
vdev->config->reset(vdev); vdev->config->reset(vdev);
hwrng_unregister(&virtio_hwrng); hwrng_unregister(&virtio_hwrng);
vdev->config->del_vq(vq); vdev->config->del_vqs(vdev);
} }
static struct virtio_device_id id_table[] = { static struct virtio_device_id id_table[] = {
......
...@@ -188,6 +188,9 @@ static void hvc_handle_input(struct virtqueue *vq) ...@@ -188,6 +188,9 @@ static void hvc_handle_input(struct virtqueue *vq)
* Finally we put our input buffer in the input queue, ready to receive. */ * Finally we put our input buffer in the input queue, ready to receive. */
static int __devinit virtcons_probe(struct virtio_device *dev) static int __devinit virtcons_probe(struct virtio_device *dev)
{ {
vq_callback_t *callbacks[] = { hvc_handle_input, NULL};
const char *names[] = { "input", "output" };
struct virtqueue *vqs[2];
int err; int err;
vdev = dev; vdev = dev;
...@@ -199,20 +202,15 @@ static int __devinit virtcons_probe(struct virtio_device *dev) ...@@ -199,20 +202,15 @@ static int __devinit virtcons_probe(struct virtio_device *dev)
goto fail; goto fail;
} }
/* Find the input queue. */ /* Find the queues. */
/* FIXME: This is why we want to wean off hvc: we do nothing /* FIXME: This is why we want to wean off hvc: we do nothing
* when input comes in. */ * when input comes in. */
in_vq = vdev->config->find_vq(vdev, 0, hvc_handle_input); err = vdev->config->find_vqs(vdev, 2, vqs, callbacks, names);
if (IS_ERR(in_vq)) { if (err)
err = PTR_ERR(in_vq);
goto free; goto free;
}
out_vq = vdev->config->find_vq(vdev, 1, NULL); in_vq = vqs[0];
if (IS_ERR(out_vq)) { out_vq = vqs[1];
err = PTR_ERR(out_vq);
goto free_in_vq;
}
/* Start using the new console output. */ /* Start using the new console output. */
virtio_cons.get_chars = get_chars; virtio_cons.get_chars = get_chars;
...@@ -233,17 +231,15 @@ static int __devinit virtcons_probe(struct virtio_device *dev) ...@@ -233,17 +231,15 @@ static int __devinit virtcons_probe(struct virtio_device *dev)
hvc = hvc_alloc(0, 0, &virtio_cons, PAGE_SIZE); hvc = hvc_alloc(0, 0, &virtio_cons, PAGE_SIZE);
if (IS_ERR(hvc)) { if (IS_ERR(hvc)) {
err = PTR_ERR(hvc); err = PTR_ERR(hvc);
goto free_out_vq; goto free_vqs;
} }
/* Register the input buffer the first time. */ /* Register the input buffer the first time. */
add_inbuf(); add_inbuf();
return 0; return 0;
free_out_vq: free_vqs:
vdev->config->del_vq(out_vq); vdev->config->del_vqs(vdev);
free_in_vq:
vdev->config->del_vq(in_vq);
free: free:
kfree(inbuf); kfree(inbuf);
fail: fail:
......
...@@ -228,7 +228,8 @@ extern void lguest_setup_irq(unsigned int irq); ...@@ -228,7 +228,8 @@ extern void lguest_setup_irq(unsigned int irq);
* function. */ * function. */
static struct virtqueue *lg_find_vq(struct virtio_device *vdev, static struct virtqueue *lg_find_vq(struct virtio_device *vdev,
unsigned index, unsigned index,
void (*callback)(struct virtqueue *vq)) void (*callback)(struct virtqueue *vq),
const char *name)
{ {
struct lguest_device *ldev = to_lgdev(vdev); struct lguest_device *ldev = to_lgdev(vdev);
struct lguest_vq_info *lvq; struct lguest_vq_info *lvq;
...@@ -263,7 +264,7 @@ static struct virtqueue *lg_find_vq(struct virtio_device *vdev, ...@@ -263,7 +264,7 @@ static struct virtqueue *lg_find_vq(struct virtio_device *vdev,
/* OK, tell virtio_ring.c to set up a virtqueue now we know its size /* OK, tell virtio_ring.c to set up a virtqueue now we know its size
* and we've got a pointer to its pages. */ * and we've got a pointer to its pages. */
vq = vring_new_virtqueue(lvq->config.num, LGUEST_VRING_ALIGN, vq = vring_new_virtqueue(lvq->config.num, LGUEST_VRING_ALIGN,
vdev, lvq->pages, lg_notify, callback); vdev, lvq->pages, lg_notify, callback, name);
if (!vq) { if (!vq) {
err = -ENOMEM; err = -ENOMEM;
goto unmap; goto unmap;
...@@ -312,6 +313,38 @@ static void lg_del_vq(struct virtqueue *vq) ...@@ -312,6 +313,38 @@ static void lg_del_vq(struct virtqueue *vq)
kfree(lvq); kfree(lvq);
} }
static void lg_del_vqs(struct virtio_device *vdev)
{
struct virtqueue *vq, *n;
list_for_each_entry_safe(vq, n, &vdev->vqs, list)
lg_del_vq(vq);
}
static int lg_find_vqs(struct virtio_device *vdev, unsigned nvqs,
struct virtqueue *vqs[],
vq_callback_t *callbacks[],
const char *names[])
{
struct lguest_device *ldev = to_lgdev(vdev);
int i;
/* We must have this many virtqueues. */
if (nvqs > ldev->desc->num_vq)
return -ENOENT;
for (i = 0; i < nvqs; ++i) {
vqs[i] = lg_find_vq(vdev, i, callbacks[i], names[i]);
if (IS_ERR(vqs[i]))
goto error;
}
return 0;
error:
lg_del_vqs(vdev);
return PTR_ERR(vqs[i]);
}
/* The ops structure which hooks everything together. */ /* The ops structure which hooks everything together. */
static struct virtio_config_ops lguest_config_ops = { static struct virtio_config_ops lguest_config_ops = {
.get_features = lg_get_features, .get_features = lg_get_features,
...@@ -321,8 +354,8 @@ static struct virtio_config_ops lguest_config_ops = { ...@@ -321,8 +354,8 @@ static struct virtio_config_ops lguest_config_ops = {
.get_status = lg_get_status, .get_status = lg_get_status,
.set_status = lg_set_status, .set_status = lg_set_status,
.reset = lg_reset, .reset = lg_reset,
.find_vq = lg_find_vq, .find_vqs = lg_find_vqs,
.del_vq = lg_del_vq, .del_vqs = lg_del_vqs,
}; };
/* The root device for the lguest virtio devices. This makes them appear as /* The root device for the lguest virtio devices. This makes them appear as
......
...@@ -845,6 +845,10 @@ static int virtnet_probe(struct virtio_device *vdev) ...@@ -845,6 +845,10 @@ static int virtnet_probe(struct virtio_device *vdev)
int err; int err;
struct net_device *dev; struct net_device *dev;
struct virtnet_info *vi; struct virtnet_info *vi;
struct virtqueue *vqs[3];
vq_callback_t *callbacks[] = { skb_recv_done, skb_xmit_done, NULL};
const char *names[] = { "input", "output", "control" };
int nvqs;
/* Allocate ourselves a network device with room for our info */ /* Allocate ourselves a network device with room for our info */
dev = alloc_etherdev(sizeof(struct virtnet_info)); dev = alloc_etherdev(sizeof(struct virtnet_info));
...@@ -905,25 +909,19 @@ static int virtnet_probe(struct virtio_device *vdev) ...@@ -905,25 +909,19 @@ static int virtnet_probe(struct virtio_device *vdev)
if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF)) if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
vi->mergeable_rx_bufs = true; vi->mergeable_rx_bufs = true;
/* We expect two virtqueues, receive then send. */ /* We expect two virtqueues, receive then send,
vi->rvq = vdev->config->find_vq(vdev, 0, skb_recv_done); * and optionally control. */
if (IS_ERR(vi->rvq)) { nvqs = virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ) ? 3 : 2;
err = PTR_ERR(vi->rvq);
err = vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names);
if (err)
goto free; goto free;
}
vi->svq = vdev->config->find_vq(vdev, 1, skb_xmit_done); vi->rvq = vqs[0];
if (IS_ERR(vi->svq)) { vi->svq = vqs[1];
err = PTR_ERR(vi->svq);
goto free_recv;
}
if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)) { if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)) {
vi->cvq = vdev->config->find_vq(vdev, 2, NULL); vi->cvq = vqs[2];
if (IS_ERR(vi->cvq)) {
err = PTR_ERR(vi->svq);
goto free_send;
}
if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VLAN)) if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VLAN))
dev->features |= NETIF_F_HW_VLAN_FILTER; dev->features |= NETIF_F_HW_VLAN_FILTER;
...@@ -941,7 +939,7 @@ static int virtnet_probe(struct virtio_device *vdev) ...@@ -941,7 +939,7 @@ static int virtnet_probe(struct virtio_device *vdev)
err = register_netdev(dev); err = register_netdev(dev);
if (err) { if (err) {
pr_debug("virtio_net: registering device failed\n"); pr_debug("virtio_net: registering device failed\n");
goto free_ctrl; goto free_vqs;
} }
/* Last of all, set up some receive buffers. */ /* Last of all, set up some receive buffers. */
...@@ -962,13 +960,8 @@ static int virtnet_probe(struct virtio_device *vdev) ...@@ -962,13 +960,8 @@ static int virtnet_probe(struct virtio_device *vdev)
unregister: unregister:
unregister_netdev(dev); unregister_netdev(dev);
free_ctrl: free_vqs:
if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)) vdev->config->del_vqs(vdev);
vdev->config->del_vq(vi->cvq);
free_send:
vdev->config->del_vq(vi->svq);
free_recv:
vdev->config->del_vq(vi->rvq);
free: free:
free_netdev(dev); free_netdev(dev);
return err; return err;
...@@ -994,12 +987,10 @@ static void virtnet_remove(struct virtio_device *vdev) ...@@ -994,12 +987,10 @@ static void virtnet_remove(struct virtio_device *vdev)
BUG_ON(vi->num != 0); BUG_ON(vi->num != 0);
vdev->config->del_vq(vi->svq);
vdev->config->del_vq(vi->rvq);
if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ))
vdev->config->del_vq(vi->cvq);
unregister_netdev(vi->dev); unregister_netdev(vi->dev);
vdev->config->del_vqs(vi->vdev);
while (vi->pages) while (vi->pages)
__free_pages(get_a_page(vi, GFP_KERNEL), 0); __free_pages(get_a_page(vi, GFP_KERNEL), 0);
......
...@@ -174,7 +174,8 @@ static void kvm_notify(struct virtqueue *vq) ...@@ -174,7 +174,8 @@ static void kvm_notify(struct virtqueue *vq)
*/ */
static struct virtqueue *kvm_find_vq(struct virtio_device *vdev, static struct virtqueue *kvm_find_vq(struct virtio_device *vdev,
unsigned index, unsigned index,
void (*callback)(struct virtqueue *vq)) void (*callback)(struct virtqueue *vq),
const char *name)
{ {
struct kvm_device *kdev = to_kvmdev(vdev); struct kvm_device *kdev = to_kvmdev(vdev);
struct kvm_vqconfig *config; struct kvm_vqconfig *config;
...@@ -194,7 +195,7 @@ static struct virtqueue *kvm_find_vq(struct virtio_device *vdev, ...@@ -194,7 +195,7 @@ static struct virtqueue *kvm_find_vq(struct virtio_device *vdev,
vq = vring_new_virtqueue(config->num, KVM_S390_VIRTIO_RING_ALIGN, vq = vring_new_virtqueue(config->num, KVM_S390_VIRTIO_RING_ALIGN,
vdev, (void *) config->address, vdev, (void *) config->address,
kvm_notify, callback); kvm_notify, callback, name);
if (!vq) { if (!vq) {
err = -ENOMEM; err = -ENOMEM;
goto unmap; goto unmap;
...@@ -226,6 +227,38 @@ static void kvm_del_vq(struct virtqueue *vq) ...@@ -226,6 +227,38 @@ static void kvm_del_vq(struct virtqueue *vq)
KVM_S390_VIRTIO_RING_ALIGN)); KVM_S390_VIRTIO_RING_ALIGN));
} }
static void kvm_del_vqs(struct virtio_device *vdev)
{
struct virtqueue *vq, *n;
list_for_each_entry_safe(vq, n, &vdev->vqs, list)
kvm_del_vq(vq);
}
static int kvm_find_vqs(struct virtio_device *vdev, unsigned nvqs,
struct virtqueue *vqs[],
vq_callback_t *callbacks[],
const char *names[])
{
struct kvm_device *kdev = to_kvmdev(vdev);
int i;
/* We must have this many virtqueues. */
if (nvqs > kdev->desc->num_vq)
return -ENOENT;
for (i = 0; i < nvqs; ++i) {
vqs[i] = kvm_find_vq(vdev, i, callbacks[i], names[i]);
if (IS_ERR(vqs[i]))
goto error;
}
return 0;
error:
kvm_del_vqs(vdev);
return PTR_ERR(vqs[i]);
}
/* /*
* The config ops structure as defined by virtio config * The config ops structure as defined by virtio config
*/ */
...@@ -237,8 +270,8 @@ static struct virtio_config_ops kvm_vq_configspace_ops = { ...@@ -237,8 +270,8 @@ static struct virtio_config_ops kvm_vq_configspace_ops = {
.get_status = kvm_get_status, .get_status = kvm_get_status,
.set_status = kvm_set_status, .set_status = kvm_set_status,
.reset = kvm_reset, .reset = kvm_reset,
.find_vq = kvm_find_vq, .find_vqs = kvm_find_vqs,
.del_vq = kvm_del_vq, .del_vqs = kvm_del_vqs,
}; };
/* /*
......
...@@ -31,21 +31,37 @@ static ssize_t modalias_show(struct device *_d, ...@@ -31,21 +31,37 @@ static ssize_t modalias_show(struct device *_d,
return sprintf(buf, "virtio:d%08Xv%08X\n", return sprintf(buf, "virtio:d%08Xv%08X\n",
dev->id.device, dev->id.vendor); dev->id.device, dev->id.vendor);
} }
static ssize_t features_show(struct device *_d,
struct device_attribute *attr, char *buf)
{
struct virtio_device *dev = container_of(_d, struct virtio_device, dev);
unsigned int i;
ssize_t len = 0;
/* We actually represent this as a bitstring, as it could be
* arbitrary length in future. */
for (i = 0; i < ARRAY_SIZE(dev->features)*BITS_PER_LONG; i++)
len += sprintf(buf+len, "%c",
test_bit(i, dev->features) ? '1' : '0');
len += sprintf(buf+len, "\n");
return len;
}
static struct device_attribute virtio_dev_attrs[] = { static struct device_attribute virtio_dev_attrs[] = {
__ATTR_RO(device), __ATTR_RO(device),
__ATTR_RO(vendor), __ATTR_RO(vendor),
__ATTR_RO(status), __ATTR_RO(status),
__ATTR_RO(modalias), __ATTR_RO(modalias),
__ATTR_RO(features),
__ATTR_NULL __ATTR_NULL
}; };
static inline int virtio_id_match(const struct virtio_device *dev, static inline int virtio_id_match(const struct virtio_device *dev,
const struct virtio_device_id *id) const struct virtio_device_id *id)
{ {
if (id->device != dev->id.device) if (id->device != dev->id.device && id->device != VIRTIO_DEV_ANY_ID)
return 0; return 0;
return id->vendor == VIRTIO_DEV_ANY_ID || id->vendor != dev->id.vendor; return id->vendor == VIRTIO_DEV_ANY_ID || id->vendor == dev->id.vendor;
} }
/* This looks through all the IDs a driver claims to support. If any of them /* This looks through all the IDs a driver claims to support. If any of them
...@@ -118,13 +134,14 @@ static int virtio_dev_probe(struct device *_d) ...@@ -118,13 +134,14 @@ static int virtio_dev_probe(struct device *_d)
if (device_features & (1 << i)) if (device_features & (1 << i))
set_bit(i, dev->features); set_bit(i, dev->features);
dev->config->finalize_features(dev);
err = drv->probe(dev); err = drv->probe(dev);
if (err) if (err)
add_status(dev, VIRTIO_CONFIG_S_FAILED); add_status(dev, VIRTIO_CONFIG_S_FAILED);
else { else
dev->config->finalize_features(dev);
add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
}
return err; return err;
} }
...@@ -185,6 +202,8 @@ int register_virtio_device(struct virtio_device *dev) ...@@ -185,6 +202,8 @@ int register_virtio_device(struct virtio_device *dev)
/* Acknowledge that we've seen the device. */ /* Acknowledge that we've seen the device. */
add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE); add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE);
INIT_LIST_HEAD(&dev->vqs);
/* device_register() causes the bus infrastructure to look for a /* device_register() causes the bus infrastructure to look for a
* matching driver. */ * matching driver. */
err = device_register(&dev->dev); err = device_register(&dev->dev);
......
...@@ -204,6 +204,9 @@ static int balloon(void *_vballoon) ...@@ -204,6 +204,9 @@ static int balloon(void *_vballoon)
static int virtballoon_probe(struct virtio_device *vdev) static int virtballoon_probe(struct virtio_device *vdev)
{ {
struct virtio_balloon *vb; struct virtio_balloon *vb;
struct virtqueue *vqs[2];
vq_callback_t *callbacks[] = { balloon_ack, balloon_ack };
const char *names[] = { "inflate", "deflate" };
int err; int err;
vdev->priv = vb = kmalloc(sizeof(*vb), GFP_KERNEL); vdev->priv = vb = kmalloc(sizeof(*vb), GFP_KERNEL);
...@@ -218,22 +221,17 @@ static int virtballoon_probe(struct virtio_device *vdev) ...@@ -218,22 +221,17 @@ static int virtballoon_probe(struct virtio_device *vdev)
vb->vdev = vdev; vb->vdev = vdev;
/* We expect two virtqueues. */ /* We expect two virtqueues. */
vb->inflate_vq = vdev->config->find_vq(vdev, 0, balloon_ack); err = vdev->config->find_vqs(vdev, 2, vqs, callbacks, names);
if (IS_ERR(vb->inflate_vq)) { if (err)
err = PTR_ERR(vb->inflate_vq);
goto out_free_vb; goto out_free_vb;
}
vb->deflate_vq = vdev->config->find_vq(vdev, 1, balloon_ack); vb->inflate_vq = vqs[0];
if (IS_ERR(vb->deflate_vq)) { vb->deflate_vq = vqs[1];
err = PTR_ERR(vb->deflate_vq);
goto out_del_inflate_vq;
}
vb->thread = kthread_run(balloon, vb, "vballoon"); vb->thread = kthread_run(balloon, vb, "vballoon");
if (IS_ERR(vb->thread)) { if (IS_ERR(vb->thread)) {
err = PTR_ERR(vb->thread); err = PTR_ERR(vb->thread);
goto out_del_deflate_vq; goto out_del_vqs;
} }
vb->tell_host_first vb->tell_host_first
...@@ -241,10 +239,8 @@ static int virtballoon_probe(struct virtio_device *vdev) ...@@ -241,10 +239,8 @@ static int virtballoon_probe(struct virtio_device *vdev)
return 0; return 0;
out_del_deflate_vq: out_del_vqs:
vdev->config->del_vq(vb->deflate_vq); vdev->config->del_vqs(vdev);
out_del_inflate_vq:
vdev->config->del_vq(vb->inflate_vq);
out_free_vb: out_free_vb:
kfree(vb); kfree(vb);
out: out:
...@@ -264,8 +260,7 @@ static void virtballoon_remove(struct virtio_device *vdev) ...@@ -264,8 +260,7 @@ static void virtballoon_remove(struct virtio_device *vdev)
/* Now we reset the device so we can clean up the queues. */ /* Now we reset the device so we can clean up the queues. */
vdev->config->reset(vdev); vdev->config->reset(vdev);
vdev->config->del_vq(vb->deflate_vq); vdev->config->del_vqs(vdev);
vdev->config->del_vq(vb->inflate_vq);
kfree(vb); kfree(vb);
} }
......
This diff is collapsed.
...@@ -23,21 +23,30 @@ ...@@ -23,21 +23,30 @@
#ifdef DEBUG #ifdef DEBUG
/* For development, we want to crash whenever the ring is screwed. */ /* For development, we want to crash whenever the ring is screwed. */
#define BAD_RING(_vq, fmt...) \ #define BAD_RING(_vq, fmt, args...) \
do { dev_err(&(_vq)->vq.vdev->dev, fmt); BUG(); } while(0) do { \
dev_err(&(_vq)->vq.vdev->dev, \
"%s:"fmt, (_vq)->vq.name, ##args); \
BUG(); \
} while (0)
/* Caller is supposed to guarantee no reentry. */ /* Caller is supposed to guarantee no reentry. */
#define START_USE(_vq) \ #define START_USE(_vq) \
do { \ do { \
if ((_vq)->in_use) \ if ((_vq)->in_use) \
panic("in_use = %i\n", (_vq)->in_use); \ panic("%s:in_use = %i\n", \
(_vq)->vq.name, (_vq)->in_use); \
(_vq)->in_use = __LINE__; \ (_vq)->in_use = __LINE__; \
mb(); \ mb(); \
} while(0) } while (0)
#define END_USE(_vq) \ #define END_USE(_vq) \
do { BUG_ON(!(_vq)->in_use); (_vq)->in_use = 0; mb(); } while(0) do { BUG_ON(!(_vq)->in_use); (_vq)->in_use = 0; mb(); } while(0)
#else #else
#define BAD_RING(_vq, fmt...) \ #define BAD_RING(_vq, fmt, args...) \
do { dev_err(&_vq->vq.vdev->dev, fmt); (_vq)->broken = true; } while(0) do { \
dev_err(&_vq->vq.vdev->dev, \
"%s:"fmt, (_vq)->vq.name, ##args); \
(_vq)->broken = true; \
} while (0)
#define START_USE(vq) #define START_USE(vq)
#define END_USE(vq) #define END_USE(vq)
#endif #endif
...@@ -52,6 +61,9 @@ struct vring_virtqueue ...@@ -52,6 +61,9 @@ struct vring_virtqueue
/* Other side has made a mess, don't try any more. */ /* Other side has made a mess, don't try any more. */
bool broken; bool broken;
/* Host supports indirect buffers */
bool indirect;
/* Number of free buffers */ /* Number of free buffers */
unsigned int num_free; unsigned int num_free;
/* Head of free buffer list. */ /* Head of free buffer list. */
...@@ -76,6 +88,55 @@ struct vring_virtqueue ...@@ -76,6 +88,55 @@ struct vring_virtqueue
#define to_vvq(_vq) container_of(_vq, struct vring_virtqueue, vq) #define to_vvq(_vq) container_of(_vq, struct vring_virtqueue, vq)
/* Set up an indirect table of descriptors and add it to the queue. */
static int vring_add_indirect(struct vring_virtqueue *vq,
struct scatterlist sg[],
unsigned int out,
unsigned int in)
{
struct vring_desc *desc;
unsigned head;
int i;
desc = kmalloc((out + in) * sizeof(struct vring_desc), GFP_ATOMIC);
if (!desc)
return vq->vring.num;
/* Transfer entries from the sg list into the indirect page */
for (i = 0; i < out; i++) {
desc[i].flags = VRING_DESC_F_NEXT;
desc[i].addr = sg_phys(sg);
desc[i].len = sg->length;
desc[i].next = i+1;
sg++;
}
for (; i < (out + in); i++) {
desc[i].flags = VRING_DESC_F_NEXT|VRING_DESC_F_WRITE;
desc[i].addr = sg_phys(sg);
desc[i].len = sg->length;
desc[i].next = i+1;
sg++;
}
/* Last one doesn't continue. */
desc[i-1].flags &= ~VRING_DESC_F_NEXT;
desc[i-1].next = 0;
/* We're about to use a buffer */
vq->num_free--;
/* Use a single buffer which doesn't continue */
head = vq->free_head;
vq->vring.desc[head].flags = VRING_DESC_F_INDIRECT;
vq->vring.desc[head].addr = virt_to_phys(desc);
vq->vring.desc[head].len = i * sizeof(struct vring_desc);
/* Update free pointer */
vq->free_head = vq->vring.desc[head].next;
return head;
}
static int vring_add_buf(struct virtqueue *_vq, static int vring_add_buf(struct virtqueue *_vq,
struct scatterlist sg[], struct scatterlist sg[],
unsigned int out, unsigned int out,
...@@ -85,12 +146,21 @@ static int vring_add_buf(struct virtqueue *_vq, ...@@ -85,12 +146,21 @@ static int vring_add_buf(struct virtqueue *_vq,
struct vring_virtqueue *vq = to_vvq(_vq); struct vring_virtqueue *vq = to_vvq(_vq);
unsigned int i, avail, head, uninitialized_var(prev); unsigned int i, avail, head, uninitialized_var(prev);
START_USE(vq);
BUG_ON(data == NULL); BUG_ON(data == NULL);
/* If the host supports indirect descriptor tables, and we have multiple
* buffers, then go indirect. FIXME: tune this threshold */
if (vq->indirect && (out + in) > 1 && vq->num_free) {
head = vring_add_indirect(vq, sg, out, in);
if (head != vq->vring.num)
goto add_head;
}
BUG_ON(out + in > vq->vring.num); BUG_ON(out + in > vq->vring.num);
BUG_ON(out + in == 0); BUG_ON(out + in == 0);
START_USE(vq);
if (vq->num_free < out + in) { if (vq->num_free < out + in) {
pr_debug("Can't add buf len %i - avail = %i\n", pr_debug("Can't add buf len %i - avail = %i\n",
out + in, vq->num_free); out + in, vq->num_free);
...@@ -127,6 +197,7 @@ static int vring_add_buf(struct virtqueue *_vq, ...@@ -127,6 +197,7 @@ static int vring_add_buf(struct virtqueue *_vq,
/* Update free pointer */ /* Update free pointer */
vq->free_head = i; vq->free_head = i;
add_head:
/* Set token. */ /* Set token. */
vq->data[head] = data; vq->data[head] = data;
...@@ -170,6 +241,11 @@ static void detach_buf(struct vring_virtqueue *vq, unsigned int head) ...@@ -170,6 +241,11 @@ static void detach_buf(struct vring_virtqueue *vq, unsigned int head)
/* Put back on free list: find end */ /* Put back on free list: find end */
i = head; i = head;
/* Free the indirect table */
if (vq->vring.desc[i].flags & VRING_DESC_F_INDIRECT)
kfree(phys_to_virt(vq->vring.desc[i].addr));
while (vq->vring.desc[i].flags & VRING_DESC_F_NEXT) { while (vq->vring.desc[i].flags & VRING_DESC_F_NEXT) {
i = vq->vring.desc[i].next; i = vq->vring.desc[i].next;
vq->num_free++; vq->num_free++;
...@@ -284,7 +360,8 @@ struct virtqueue *vring_new_virtqueue(unsigned int num, ...@@ -284,7 +360,8 @@ struct virtqueue *vring_new_virtqueue(unsigned int num,
struct virtio_device *vdev, struct virtio_device *vdev,
void *pages, void *pages,
void (*notify)(struct virtqueue *), void (*notify)(struct virtqueue *),
void (*callback)(struct virtqueue *)) void (*callback)(struct virtqueue *),
const char *name)
{ {
struct vring_virtqueue *vq; struct vring_virtqueue *vq;
unsigned int i; unsigned int i;
...@@ -303,14 +380,18 @@ struct virtqueue *vring_new_virtqueue(unsigned int num, ...@@ -303,14 +380,18 @@ struct virtqueue *vring_new_virtqueue(unsigned int num,
vq->vq.callback = callback; vq->vq.callback = callback;
vq->vq.vdev = vdev; vq->vq.vdev = vdev;
vq->vq.vq_ops = &vring_vq_ops; vq->vq.vq_ops = &vring_vq_ops;
vq->vq.name = name;
vq->notify = notify; vq->notify = notify;
vq->broken = false; vq->broken = false;
vq->last_used_idx = 0; vq->last_used_idx = 0;
vq->num_added = 0; vq->num_added = 0;
list_add_tail(&vq->vq.list, &vdev->vqs);
#ifdef DEBUG #ifdef DEBUG
vq->in_use = false; vq->in_use = false;
#endif #endif
vq->indirect = virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC);
/* No callback? Tell other side not to bother us. */ /* No callback? Tell other side not to bother us. */
if (!callback) if (!callback)
vq->vring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT; vq->vring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
...@@ -327,6 +408,7 @@ EXPORT_SYMBOL_GPL(vring_new_virtqueue); ...@@ -327,6 +408,7 @@ EXPORT_SYMBOL_GPL(vring_new_virtqueue);
void vring_del_virtqueue(struct virtqueue *vq) void vring_del_virtqueue(struct virtqueue *vq)
{ {
list_del(&vq->list);
kfree(to_vvq(vq)); kfree(to_vvq(vq));
} }
EXPORT_SYMBOL_GPL(vring_del_virtqueue); EXPORT_SYMBOL_GPL(vring_del_virtqueue);
...@@ -338,6 +420,8 @@ void vring_transport_features(struct virtio_device *vdev) ...@@ -338,6 +420,8 @@ void vring_transport_features(struct virtio_device *vdev)
for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) { for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) {
switch (i) { switch (i) {
case VIRTIO_RING_F_INDIRECT_DESC:
break;
default: default:
/* We don't understand this bit. */ /* We don't understand this bit. */
clear_bit(i, vdev->features); clear_bit(i, vdev->features);
......
...@@ -10,14 +10,17 @@ ...@@ -10,14 +10,17 @@
/** /**
* virtqueue - a queue to register buffers for sending or receiving. * virtqueue - a queue to register buffers for sending or receiving.
* @list: the chain of virtqueues for this device
* @callback: the function to call when buffers are consumed (can be NULL). * @callback: the function to call when buffers are consumed (can be NULL).
* @name: the name of this virtqueue (mainly for debugging)
* @vdev: the virtio device this queue was created for. * @vdev: the virtio device this queue was created for.
* @vq_ops: the operations for this virtqueue (see below). * @vq_ops: the operations for this virtqueue (see below).
* @priv: a pointer for the virtqueue implementation to use. * @priv: a pointer for the virtqueue implementation to use.
*/ */
struct virtqueue struct virtqueue {
{ struct list_head list;
void (*callback)(struct virtqueue *vq); void (*callback)(struct virtqueue *vq);
const char *name;
struct virtio_device *vdev; struct virtio_device *vdev;
struct virtqueue_ops *vq_ops; struct virtqueue_ops *vq_ops;
void *priv; void *priv;
...@@ -76,15 +79,16 @@ struct virtqueue_ops { ...@@ -76,15 +79,16 @@ struct virtqueue_ops {
* @dev: underlying device. * @dev: underlying device.
* @id: the device type identification (used to match it with a driver). * @id: the device type identification (used to match it with a driver).
* @config: the configuration ops for this device. * @config: the configuration ops for this device.
* @vqs: the list of virtqueues for this device.
* @features: the features supported by both driver and device. * @features: the features supported by both driver and device.
* @priv: private pointer for the driver's use. * @priv: private pointer for the driver's use.
*/ */
struct virtio_device struct virtio_device {
{
int index; int index;
struct device dev; struct device dev;
struct virtio_device_id id; struct virtio_device_id id;
struct virtio_config_ops *config; struct virtio_config_ops *config;
struct list_head vqs;
/* Note that this is a Linux set_bit-style bitmap. */ /* Note that this is a Linux set_bit-style bitmap. */
unsigned long features[1]; unsigned long features[1];
void *priv; void *priv;
...@@ -99,8 +103,7 @@ void unregister_virtio_device(struct virtio_device *dev); ...@@ -99,8 +103,7 @@ void unregister_virtio_device(struct virtio_device *dev);
* @id_table: the ids serviced by this driver. * @id_table: the ids serviced by this driver.
* @feature_table: an array of feature numbers supported by this device. * @feature_table: an array of feature numbers supported by this device.
* @feature_table_size: number of entries in the feature table array. * @feature_table_size: number of entries in the feature table array.
* @probe: the function to call when a device is found. Returns a token for * @probe: the function to call when a device is found. Returns 0 or -errno.
* remove, or PTR_ERR().
* @remove: the function when a device is removed. * @remove: the function when a device is removed.
* @config_changed: optional function to call when the device configuration * @config_changed: optional function to call when the device configuration
* changes; may be called in interrupt context. * changes; may be called in interrupt context.
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#define VIRTIO_F_NOTIFY_ON_EMPTY 24 #define VIRTIO_F_NOTIFY_ON_EMPTY 24
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/err.h>
#include <linux/virtio.h> #include <linux/virtio.h>
/** /**
...@@ -49,15 +50,26 @@ ...@@ -49,15 +50,26 @@
* @set_status: write the status byte * @set_status: write the status byte
* vdev: the virtio_device * vdev: the virtio_device
* status: the new status byte * status: the new status byte
* @request_vqs: request the specified number of virtqueues
* vdev: the virtio_device
* max_vqs: the max number of virtqueues we want
* If supplied, must call before any virtqueues are instantiated.
* To modify the max number of virtqueues after request_vqs has been
* called, call free_vqs and then request_vqs with a new value.
* @free_vqs: cleanup resources allocated by request_vqs
* vdev: the virtio_device
* If supplied, must call after all virtqueues have been deleted.
* @reset: reset the device * @reset: reset the device
* vdev: the virtio device * vdev: the virtio device
* After this, status and feature negotiation must be done again * After this, status and feature negotiation must be done again
* @find_vq: find a virtqueue and instantiate it. * @find_vqs: find virtqueues and instantiate them.
* vdev: the virtio_device * vdev: the virtio_device
* index: the 0-based virtqueue number in case there's more than one. * nvqs: the number of virtqueues to find
* callback: the virqtueue callback * vqs: on success, includes new virtqueues
* Returns the new virtqueue or ERR_PTR() (eg. -ENOENT). * callbacks: array of callbacks, for each virtqueue
* @del_vq: free a virtqueue found by find_vq(). * names: array of virtqueue names (mainly for debugging)
* Returns 0 on success or error status
* @del_vqs: free virtqueues found by find_vqs().
* @get_features: get the array of feature bits for this device. * @get_features: get the array of feature bits for this device.
* vdev: the virtio_device * vdev: the virtio_device
* Returns the first 32 feature bits (all we currently need). * Returns the first 32 feature bits (all we currently need).
...@@ -66,6 +78,7 @@ ...@@ -66,6 +78,7 @@
* This gives the final feature bits for the device: it can change * This gives the final feature bits for the device: it can change
* the dev->feature bits if it wants. * the dev->feature bits if it wants.
*/ */
typedef void vq_callback_t(struct virtqueue *);
struct virtio_config_ops struct virtio_config_ops
{ {
void (*get)(struct virtio_device *vdev, unsigned offset, void (*get)(struct virtio_device *vdev, unsigned offset,
...@@ -75,10 +88,11 @@ struct virtio_config_ops ...@@ -75,10 +88,11 @@ struct virtio_config_ops
u8 (*get_status)(struct virtio_device *vdev); u8 (*get_status)(struct virtio_device *vdev);
void (*set_status)(struct virtio_device *vdev, u8 status); void (*set_status)(struct virtio_device *vdev, u8 status);
void (*reset)(struct virtio_device *vdev); void (*reset)(struct virtio_device *vdev);
struct virtqueue *(*find_vq)(struct virtio_device *vdev, int (*find_vqs)(struct virtio_device *, unsigned nvqs,
unsigned index, struct virtqueue *vqs[],
void (*callback)(struct virtqueue *)); vq_callback_t *callbacks[],
void (*del_vq)(struct virtqueue *vq); const char *names[]);
void (*del_vqs)(struct virtio_device *);
u32 (*get_features)(struct virtio_device *vdev); u32 (*get_features)(struct virtio_device *vdev);
void (*finalize_features)(struct virtio_device *vdev); void (*finalize_features)(struct virtio_device *vdev);
}; };
...@@ -99,7 +113,9 @@ static inline bool virtio_has_feature(const struct virtio_device *vdev, ...@@ -99,7 +113,9 @@ static inline bool virtio_has_feature(const struct virtio_device *vdev,
if (__builtin_constant_p(fbit)) if (__builtin_constant_p(fbit))
BUILD_BUG_ON(fbit >= 32); BUILD_BUG_ON(fbit >= 32);
if (fbit < VIRTIO_TRANSPORT_F_START)
virtio_check_driver_offered_feature(vdev, fbit); virtio_check_driver_offered_feature(vdev, fbit);
return test_bit(fbit, vdev->features); return test_bit(fbit, vdev->features);
} }
...@@ -126,5 +142,18 @@ static inline int virtio_config_buf(struct virtio_device *vdev, ...@@ -126,5 +142,18 @@ static inline int virtio_config_buf(struct virtio_device *vdev,
vdev->config->get(vdev, offset, buf, len); vdev->config->get(vdev, offset, buf, len);
return 0; return 0;
} }
static inline
struct virtqueue *virtio_find_single_vq(struct virtio_device *vdev,
vq_callback_t *c, const char *n)
{
vq_callback_t *callbacks[] = { c };
const char *names[] = { n };
struct virtqueue *vq;
int err = vdev->config->find_vqs(vdev, 1, &vq, callbacks, names);
if (err < 0)
return ERR_PTR(err);
return vq;
}
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _LINUX_VIRTIO_CONFIG_H */ #endif /* _LINUX_VIRTIO_CONFIG_H */
...@@ -47,9 +47,17 @@ ...@@ -47,9 +47,17 @@
/* The bit of the ISR which indicates a device configuration change. */ /* The bit of the ISR which indicates a device configuration change. */
#define VIRTIO_PCI_ISR_CONFIG 0x2 #define VIRTIO_PCI_ISR_CONFIG 0x2
/* MSI-X registers: only enabled if MSI-X is enabled. */
/* A 16-bit vector for configuration changes. */
#define VIRTIO_MSI_CONFIG_VECTOR 20
/* A 16-bit vector for selected queue notifications. */
#define VIRTIO_MSI_QUEUE_VECTOR 22
/* Vector value used to disable MSI for queue */
#define VIRTIO_MSI_NO_VECTOR 0xffff
/* The remaining space is defined by each driver as the per-driver /* The remaining space is defined by each driver as the per-driver
* configuration space */ * configuration space */
#define VIRTIO_PCI_CONFIG 20 #define VIRTIO_PCI_CONFIG(dev) ((dev)->msix_enabled ? 24 : 20)
/* Virtio ABI version, this must match exactly */ /* Virtio ABI version, this must match exactly */
#define VIRTIO_PCI_ABI_VERSION 0 #define VIRTIO_PCI_ABI_VERSION 0
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#define VRING_DESC_F_NEXT 1 #define VRING_DESC_F_NEXT 1
/* This marks a buffer as write-only (otherwise read-only). */ /* This marks a buffer as write-only (otherwise read-only). */
#define VRING_DESC_F_WRITE 2 #define VRING_DESC_F_WRITE 2
/* This means the buffer contains a list of buffer descriptors. */
#define VRING_DESC_F_INDIRECT 4
/* The Host uses this in used->flags to advise the Guest: don't kick me when /* The Host uses this in used->flags to advise the Guest: don't kick me when
* you add a buffer. It's unreliable, so it's simply an optimization. Guest * you add a buffer. It's unreliable, so it's simply an optimization. Guest
...@@ -24,6 +26,9 @@ ...@@ -24,6 +26,9 @@
* optimization. */ * optimization. */
#define VRING_AVAIL_F_NO_INTERRUPT 1 #define VRING_AVAIL_F_NO_INTERRUPT 1
/* We support indirect buffer descriptors */
#define VIRTIO_RING_F_INDIRECT_DESC 28
/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */ /* Virtio ring descriptors: 16 bytes. These can chain together via "next". */
struct vring_desc struct vring_desc
{ {
...@@ -119,7 +124,8 @@ struct virtqueue *vring_new_virtqueue(unsigned int num, ...@@ -119,7 +124,8 @@ struct virtqueue *vring_new_virtqueue(unsigned int num,
struct virtio_device *vdev, struct virtio_device *vdev,
void *pages, void *pages,
void (*notify)(struct virtqueue *vq), void (*notify)(struct virtqueue *vq),
void (*callback)(struct virtqueue *vq)); void (*callback)(struct virtqueue *vq),
const char *name);
void vring_del_virtqueue(struct virtqueue *vq); void vring_del_virtqueue(struct virtqueue *vq);
/* Filter out transport-specific feature bits. */ /* Filter out transport-specific feature bits. */
void vring_transport_features(struct virtio_device *vdev); void vring_transport_features(struct virtio_device *vdev);
......
...@@ -246,7 +246,7 @@ static int p9_virtio_probe(struct virtio_device *vdev) ...@@ -246,7 +246,7 @@ static int p9_virtio_probe(struct virtio_device *vdev)
chan->vdev = vdev; chan->vdev = vdev;
/* We expect one virtqueue, for requests. */ /* We expect one virtqueue, for requests. */
chan->vq = vdev->config->find_vq(vdev, 0, req_done); chan->vq = virtio_find_single_vq(vdev, req_done, "requests");
if (IS_ERR(chan->vq)) { if (IS_ERR(chan->vq)) {
err = PTR_ERR(chan->vq); err = PTR_ERR(chan->vq);
goto out_free_vq; goto out_free_vq;
...@@ -261,7 +261,7 @@ static int p9_virtio_probe(struct virtio_device *vdev) ...@@ -261,7 +261,7 @@ static int p9_virtio_probe(struct virtio_device *vdev)
return 0; return 0;
out_free_vq: out_free_vq:
vdev->config->del_vq(chan->vq); vdev->config->del_vqs(vdev);
fail: fail:
mutex_lock(&virtio_9p_lock); mutex_lock(&virtio_9p_lock);
chan_index--; chan_index--;
...@@ -332,7 +332,7 @@ static void p9_virtio_remove(struct virtio_device *vdev) ...@@ -332,7 +332,7 @@ static void p9_virtio_remove(struct virtio_device *vdev)
BUG_ON(chan->inuse); BUG_ON(chan->inuse);
if (chan->initialized) { if (chan->initialized) {
vdev->config->del_vq(chan->vq); vdev->config->del_vqs(vdev);
chan->initialized = false; chan->initialized = false;
} }
} }
......
...@@ -641,7 +641,7 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id, ...@@ -641,7 +641,7 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id,
id->vendor = TO_NATIVE(id->vendor); id->vendor = TO_NATIVE(id->vendor);
strcpy(alias, "virtio:"); strcpy(alias, "virtio:");
ADD(alias, "d", 1, id->device); ADD(alias, "d", id->device != VIRTIO_DEV_ANY_ID, id->device);
ADD(alias, "v", id->vendor != VIRTIO_DEV_ANY_ID, id->vendor); ADD(alias, "v", id->vendor != VIRTIO_DEV_ANY_ID, id->vendor);
add_wildcard(alias); add_wildcard(alias);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment