[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190121050056.14325-1-peng.fan@nxp.com>
Date: Mon, 21 Jan 2019 04:51:57 +0000
From: Peng Fan <peng.fan@....com>
To: "mst@...hat.com" <mst@...hat.com>,
"jasowang@...hat.com" <jasowang@...hat.com>,
"sstabellini@...nel.org" <sstabellini@...nel.org>,
"hch@...radead.org" <hch@...radead.org>
CC: "virtualization@...ts.linux-foundation.org"
<virtualization@...ts.linux-foundation.org>,
"xen-devel@...ts.xenproject.org" <xen-devel@...ts.xenproject.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-remoteproc@...r.kernel.org" <linux-remoteproc@...r.kernel.org>,
Peng Fan <peng.fan@....com>
Subject: [RFC] virtio_ring: check dma_mem for xen_domain
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@....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
Powered by blists - more mailing lists