summaryrefslogtreecommitdiff
path: root/drivers/virtio/virtio_pci_common.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-12-11 14:59:51 +0300
committerRusty Russell <rusty@rustcorp.com.au>2015-01-21 08:58:53 +0300
commit1fcf0512c9c870e78e1c9898ecb9458593403466 (patch)
tree002fa2a03688453e491f2224c31a96c1b3a47be6 /drivers/virtio/virtio_pci_common.c
parent71d70c266c84c4e708bb36b20d0c0a29af42821c (diff)
downloadlinux-1fcf0512c9c870e78e1c9898ecb9458593403466.tar.xz
virtio_pci: modern driver
Lightly tested against qemu. One thing *not* implemented here is separate mappings for descriptor/avail/used rings. That's nice to have, will be done later after we have core support. This also exposes the PCI layout to userspace, and adds macros for PCI layout offsets: QEMU wants it, so why not? Trust, but verify. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/virtio/virtio_pci_common.c')
-rw-r--r--drivers/virtio/virtio_pci_common.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
index 457cbe29c8c4..8ae34a34f3af 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -505,7 +505,9 @@ static int virtio_pci_probe(struct pci_dev *pci_dev,
if (rc)
goto err_request_regions;
- rc = virtio_pci_legacy_probe(vp_dev);
+ rc = virtio_pci_modern_probe(vp_dev);
+ if (rc == -ENODEV)
+ rc = virtio_pci_legacy_probe(vp_dev);
if (rc)
goto err_probe;
@@ -518,7 +520,10 @@ static int virtio_pci_probe(struct pci_dev *pci_dev,
return 0;
err_register:
- virtio_pci_legacy_remove(vp_dev);
+ if (vp_dev->ioaddr)
+ virtio_pci_legacy_remove(vp_dev);
+ else
+ virtio_pci_modern_remove(vp_dev);
err_probe:
pci_release_regions(pci_dev);
err_request_regions:
@@ -534,7 +539,10 @@ static void virtio_pci_remove(struct pci_dev *pci_dev)
unregister_virtio_device(&vp_dev->vdev);
- virtio_pci_legacy_remove(pci_dev);
+ if (vp_dev->ioaddr)
+ virtio_pci_legacy_remove(vp_dev);
+ else
+ virtio_pci_modern_remove(vp_dev);
pci_release_regions(pci_dev);
pci_disable_device(pci_dev);