Skip to content

Commit 9b82e65

Browse files
committed
Merge git://github.com/rustyrussell/linux
* git://github.com/rustyrussell/linux: virtio-pci: make reset operation safer virtio-mmio: Correct the name of the guest features selector virtio: add HAS_IOMEM dependency to MMIO platform bus driver
2 parents 8174a06 + e6af578 commit 9b82e65

5 files changed

Lines changed: 23 additions & 3 deletions

File tree

‎drivers/virtio/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ config VIRTIO_BALLOON
3737

3838
config VIRTIO_MMIO
3939
tristate "Platform bus driver for memory mapped virtio devices (EXPERIMENTAL)"
40-
depends on EXPERIMENTAL
40+
depends on HAS_IOMEM && EXPERIMENTAL
4141
select VIRTIO
4242
select VIRTIO_RING
4343
---help---

‎drivers/virtio/virtio_mmio.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static void vm_finalize_features(struct virtio_device *vdev)
118118
vring_transport_features(vdev);
119119

120120
for (i = 0; i < ARRAY_SIZE(vdev->features); i++) {
121-
writel(i, vm_dev->base + VIRTIO_MMIO_GUEST_FEATURES_SET);
121+
writel(i, vm_dev->base + VIRTIO_MMIO_GUEST_FEATURES_SEL);
122122
writel(vdev->features[i],
123123
vm_dev->base + VIRTIO_MMIO_GUEST_FEATURES);
124124
}

‎drivers/virtio/virtio_pci.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,29 @@ static void vp_set_status(struct virtio_device *vdev, u8 status)
169169
iowrite8(status, vp_dev->ioaddr + VIRTIO_PCI_STATUS);
170170
}
171171

172+
/* wait for pending irq handlers */
173+
static void vp_synchronize_vectors(struct virtio_device *vdev)
174+
{
175+
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
176+
int i;
177+
178+
if (vp_dev->intx_enabled)
179+
synchronize_irq(vp_dev->pci_dev->irq);
180+
181+
for (i = 0; i < vp_dev->msix_vectors; ++i)
182+
synchronize_irq(vp_dev->msix_entries[i].vector);
183+
}
184+
172185
static void vp_reset(struct virtio_device *vdev)
173186
{
174187
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
175188
/* 0 status means a reset. */
176189
iowrite8(0, vp_dev->ioaddr + VIRTIO_PCI_STATUS);
190+
/* Flush out the status write, and flush in device writes,
191+
* including MSi-X interrupts, if any. */
192+
ioread8(vp_dev->ioaddr + VIRTIO_PCI_STATUS);
193+
/* Flush pending VQ/configuration callbacks. */
194+
vp_synchronize_vectors(vdev);
177195
}
178196

179197
/* the notify function used when creating a virt queue */

‎include/linux/virtio_config.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
* @reset: reset the device
8686
* vdev: the virtio device
8787
* After this, status and feature negotiation must be done again
88+
* Device must not be reset from its vq/config callbacks, or in
89+
* parallel with being added/removed.
8890
* @find_vqs: find virtqueues and instantiate them.
8991
* vdev: the virtio_device
9092
* nvqs: the number of virtqueues to find

‎include/linux/virtio_mmio.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
#define VIRTIO_MMIO_GUEST_FEATURES 0x020
6464

6565
/* Activated features set selector - Write Only */
66-
#define VIRTIO_MMIO_GUEST_FEATURES_SET 0x024
66+
#define VIRTIO_MMIO_GUEST_FEATURES_SEL 0x024
6767

6868
/* Guest's memory page size in bytes - Write Only */
6969
#define VIRTIO_MMIO_GUEST_PAGE_SIZE 0x028

0 commit comments

Comments
 (0)