59 lines
1.9 KiB
Diff
59 lines
1.9 KiB
Diff
From 0f7bfee47191d977261c293b878a1b719aa36ca7 Mon Sep 17 00:00:00 2001
|
|
From: Sergio Lopez <slp@sinrega.org>
|
|
Date: Fri, 10 Sep 2021 13:05:01 +0200
|
|
Subject: [PATCH 1/4] virtio: enable DMA API if memory is restricted
|
|
|
|
When running on a system with restricted memory access, the driver
|
|
can't have direct access to the memory. In this scenario,
|
|
automatically enable the use of the DMA API, which knows how to
|
|
operate in this context (usually by using bounce buffers).
|
|
|
|
Signed-off-by: Sergio Lopez <slp@redhat.com>
|
|
---
|
|
drivers/virtio/virtio.c | 6 ------
|
|
drivers/virtio/virtio_ring.c | 4 ++++
|
|
2 files changed, 4 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
|
|
index b9095751e43b..9e6420d5bc66 100644
|
|
--- a/drivers/virtio/virtio.c
|
|
+++ b/drivers/virtio/virtio.c
|
|
@@ -213,12 +213,6 @@ static int virtio_features_ok(struct virtio_device *dev)
|
|
"device must provide VIRTIO_F_VERSION_1\n");
|
|
return -ENODEV;
|
|
}
|
|
-
|
|
- if (!virtio_has_feature(dev, VIRTIO_F_ACCESS_PLATFORM)) {
|
|
- dev_warn(&dev->dev,
|
|
- "device must provide VIRTIO_F_ACCESS_PLATFORM\n");
|
|
- return -ENODEV;
|
|
- }
|
|
}
|
|
|
|
if (!virtio_has_feature(dev, VIRTIO_F_VERSION_1))
|
|
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
|
|
index 0112742e4504..84bfe596405f 100644
|
|
--- a/drivers/virtio/virtio_ring.c
|
|
+++ b/drivers/virtio/virtio_ring.c
|
|
@@ -6,6 +6,7 @@
|
|
#include <linux/virtio.h>
|
|
#include <linux/virtio_ring.h>
|
|
#include <linux/virtio_config.h>
|
|
+#include <linux/virtio_anchor.h>
|
|
#include <linux/device.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/module.h>
|
|
@@ -282,6 +283,9 @@ static bool vring_use_dma_api(const struct virtio_device *vdev)
|
|
if (!virtio_has_dma_quirk(vdev))
|
|
return true;
|
|
|
|
+ if (virtio_check_mem_acc_cb(vdev))
|
|
+ return true;
|
|
+
|
|
/* Otherwise, we are left to guess. */
|
|
/*
|
|
* In theory, it's possible to have a buggy QEMU-supposed
|
|
--
|
|
2.47.1
|
|
|