Skip to contentSkip to conversation

Revert "vring: Force use of DMA API for ARM-based systems with legacy devices"

PATCH In review Michael S. Tsirkin 2 participants 2 messages Feb 3, 2017

Subsystems (2)
lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#0 lore raw

PATCH 1/1 Revert "vring: Force use of DMA API for ARM-based systems with legacy devices"

This reverts commit c7070619f3408d9a0dffbed9149e6f00479cf43b.

This has been shown to regress on some ARM systems:

by forcing on DMA API usage for ARM systems, we have inadvertently kicked open a hornets' nest in terms of cache-coherency. Namely that unless the virtio device is explicitly described as capable of coherent DMA by firmware, the DMA APIs on ARM and other DT-based platforms will assume it is non-coherent. This turns out to cause a big problem for the likes of QEMU and kvmtool, which generate virtio-mmio devices in their guest DTs but neglect to add the often-overlooked "dma-coherent" property; as a result, we end up with the guest making non-cacheable accesses to the vring, the host doing so cacheably, both talking past each other and things going horribly wrong.

We are working on a safer work-around.

Fixes c7070619f340 ("vring: Force use of DMA API for ARM-based systems with legacy devices")

---

I'll merge this for 4.10. Let's fix it properly for 4.11.

 drivers/virtio/virtio_ring.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/virtio/virtio_ring.c +0 -7
index 7e38ed7..409aeaa 100644
@@ -159,13 +159,6 @@ static bool vring_use_dma_api(struct virtio_device *vdev)
 	if (xen_domain())
 		return true;
 
-	/*
-	 * On ARM-based machines, the DMA ops will do the right thing,
-	 * so always use them with legacy devices.
-	 */
-	if (IS_ENABLED(CONFIG_ARM) || IS_ENABLED(CONFIG_ARM64))
-		return !virtio_has_feature(vdev, VIRTIO_F_VERSION_1);
-
 	return false;
 }
 
Signature · 1 line
MST
Acked-by on v1 1/1
#1 lore raw
Quoted 23 lines · Michael S. Tsirkin

This reverts commit c7070619f3408d9a0dffbed9149e6f00479cf43b.

This has been shown to regress on some ARM systems:

by forcing on DMA API usage for ARM systems, we have inadvertently kicked open a hornets' nest in terms of cache-coherency. Namely that unless the virtio device is explicitly described as capable of coherent DMA by firmware, the DMA APIs on ARM and other DT-based platforms will assume it is non-coherent. This turns out to cause a big problem for the likes of QEMU and kvmtool, which generate virtio-mmio devices in their guest DTs but neglect to add the often-overlooked "dma-coherent" property; as a result, we end up with the guest making non-cacheable accesses to the vring, the host doing so cacheably, both talking past each other and things going horribly wrong.

We are working on a safer work-around.

Fixes c7070619f340 ("vring: Force use of DMA API for ARM-based systems with legacy devices")
Quoted 3 lines

---

I'll merge this for 4.10. Let's fix it properly for 4.11.

Will