summaryrefslogtreecommitdiffstats
path: root/drivers/virtio/virtio_pci_modern.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/virtio/virtio_pci_modern.c')
-rw-r--r--drivers/virtio/virtio_pci_modern.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
index d828bee69e..2dd369b02e 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
*
@@ -223,14 +223,6 @@ error_available:
static void virtio_pci_del_vq(struct virtqueue *vq)
{
- struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev);
- unsigned int index = vq->index;
-
- iowrite16(index, &vp_dev->common->queue_select);
-
- /* Select and deactivate the queue */
- iowrite16(0, &vp_dev->common->queue_enable);
-
vring_del_virtqueue(vq);
}
@@ -355,19 +347,23 @@ static const struct virtio_config_ops virtio_pci_config_ops = {
int virtio_pci_modern_probe(struct virtio_pci_device *vp_dev)
{
struct pci_dev *pci_dev = vp_dev->pci_dev;
- struct device_d *dev = &pci_dev->dev;
+ struct device *dev = &pci_dev->dev;
int common, notify, device;
int offset;
- /*
- * We only own devices >= 0x1000 and <= 0x107f. We don't support
- * transitional devices, so start at 0x1040 and leave the rest.
- */
- if (pci_dev->device < 0x1040 || pci_dev->device > 0x107f)
+ /* We only own devices >= 0x1000 and <= 0x107f: leave the rest. */
+ if (pci_dev->device < 0x1000 || pci_dev->device > 0x107f)
return -ENODEV;
- /* Modern devices: simply use PCI device id, but start from 0x1040. */
- vp_dev->vdev.id.device = pci_dev->device - 0x1040;
+ if (pci_dev->device < 0x1040) {
+ /* Transitional devices: use the PCI subsystem device id as
+ * virtio device id, same as legacy driver always did.
+ */
+ vp_dev->vdev.id.device = pci_dev->subsystem_device;
+ } else {
+ /* Modern devices: simply use PCI device id, but start from 0x1040. */
+ vp_dev->vdev.id.device = pci_dev->device - 0x1040;
+ }
vp_dev->vdev.id.vendor = pci_dev->subsystem_vendor;
/* Check for a common config: if not, driver could fall back to legacy mode (bar 0) */