All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] virtio_ring: check dma_mem for xen_domain
@ 2019-01-21  4:51 ` Peng Fan
  0 siblings, 0 replies; 61+ messages in thread
From: Peng Fan @ 2019-01-21  4:51 UTC (permalink / raw)
  To: mst, jasowang, sstabellini, hch
  Cc: virtualization, xen-devel, linux-kernel, linux-remoteproc, Peng Fan

on i.MX8QM, M4_1 is communicating with DomU using rpmsg with a fixed
address as the dma mem buffer which is predefined.

Without this patch, the flow is:
vring_map_one_sg -> vring_use_dma_api
                 -> dma_map_page
		       -> __swiotlb_map_page
		                ->swiotlb_map_page
				->__dma_map_area(phys_to_virt(dma_to_phys(dev, dev_addr)), size, dir);
However we are using per device dma area for rpmsg, phys_to_virt
could not return a correct virtual address for virtual address in
vmalloc area. Then kernel panic.

With this patch, vring_use_dma_api will return false, and
vring_map_one_sg will return sg_phys(sg) which is the correct phys
address in the predefined memory region.
vring_map_one_sg -> vring_use_dma_api
                 -> sg_phys(sg)

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/virtio/virtio_ring.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index cd7e755484e3..8993d7cb3592 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -248,6 +248,8 @@ static inline bool virtqueue_use_indirect(struct virtqueue *_vq,
 
 static bool vring_use_dma_api(struct virtio_device *vdev)
 {
+	struct device *dma_dev = vdev->dev.parent;
+
 	if (!virtio_has_iommu_quirk(vdev))
 		return true;
 
@@ -260,7 +262,7 @@ static bool vring_use_dma_api(struct virtio_device *vdev)
 	 * the DMA API if we're a Xen guest, which at least allows
 	 * all of the sensible Xen configurations to work correctly.
 	 */
-	if (xen_domain())
+	if (xen_domain() && !dma_dev->dma_mem)
 		return true;
 
 	return false;
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 61+ messages in thread

end of thread, other threads:[~2019-01-29  9:27 UTC | newest]

Thread overview: 61+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-21  4:51 [RFC] virtio_ring: check dma_mem for xen_domain Peng Fan
2019-01-21  4:51 ` Peng Fan
2019-01-21  4:51 ` Peng Fan
2019-01-21  8:28 ` hch
2019-01-21  8:28 ` hch
2019-01-21  8:28   ` hch
2019-01-22  2:32   ` Peng Fan
2019-01-22  2:32   ` Peng Fan
2019-01-22  2:32     ` Peng Fan
2019-01-22  2:36   ` Michael S. Tsirkin
2019-01-22  2:36   ` Michael S. Tsirkin
2019-01-22  2:36     ` Michael S. Tsirkin
2019-01-22  2:36   ` Michael S. Tsirkin
2019-01-21  8:28 ` hch
2019-01-22 19:59 ` Stefano Stabellini
2019-01-22 19:59 ` [Xen-devel] " Stefano Stabellini
2019-01-22 19:59   ` Stefano Stabellini
2019-01-23  2:57   ` Michael S. Tsirkin
2019-01-23  2:57   ` Michael S. Tsirkin
2019-01-23  2:57   ` [Xen-devel] " Michael S. Tsirkin
2019-01-23  2:57     ` Michael S. Tsirkin
2019-01-23  7:12   ` hch
2019-01-23  7:12     ` hch
2019-01-23 21:04     ` Stefano Stabellini
2019-01-23 21:04     ` [Xen-devel] " Stefano Stabellini
2019-01-23 21:04       ` Stefano Stabellini
2019-01-23 21:14       ` hch
2019-01-23 21:14       ` hch
2019-01-23 21:14       ` [Xen-devel] " hch
2019-01-23 21:14         ` hch
2019-01-23 23:43         ` Stefano Stabellini
2019-01-23 23:43           ` Stefano Stabellini
2019-01-24  6:47           ` Peng Fan
2019-01-24  6:47           ` [Xen-devel] " Peng Fan
2019-01-24  6:47             ` Peng Fan
2019-01-24 19:14             ` Stefano Stabellini
2019-01-24 19:14             ` [Xen-devel] " Stefano Stabellini
2019-01-24 19:14               ` Stefano Stabellini
2019-01-24 20:34               ` Michael S. Tsirkin
2019-01-24 20:34               ` Michael S. Tsirkin
2019-01-24 20:34               ` [Xen-devel] " Michael S. Tsirkin
2019-01-24 20:34                 ` Michael S. Tsirkin
2019-01-23 23:43         ` Stefano Stabellini
2019-01-25  9:45         ` [Xen-devel] " Peng Fan
2019-01-25  9:45           ` Peng Fan
2019-01-25 19:18           ` Stefano Stabellini
2019-01-25 19:18           ` [Xen-devel] " Stefano Stabellini
2019-01-25 19:18             ` Stefano Stabellini
2019-01-28  8:00           ` hch
2019-01-28  8:00           ` [Xen-devel] " hch
2019-01-28  8:00             ` hch
2019-01-29  9:26             ` Peng Fan
2019-01-29  9:26             ` [Xen-devel] " Peng Fan
2019-01-29  9:26               ` Peng Fan
2019-01-28  8:00           ` hch
2019-01-25  9:45         ` Peng Fan
2019-01-23  7:12   ` [Xen-devel] " hch
2019-01-23  7:12   ` hch
2019-01-24  6:42   ` Peng Fan
2019-01-24  6:42   ` [Xen-devel] " Peng Fan
2019-01-24  6:42     ` Peng Fan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.