Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1285762
| Path | csiph.com!news.mixmin.net!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Stefano Stabellini <stefano.stabellini@eu.citrix.com> |
| Newsgroups | linux.kernel |
| Subject | [PATCH RFC 2/3] xen/virtio: allocate a contiguous region to be use as virtio queue |
| Date | Mon, 07 Dec 2015 17:30:02 +0100 |
| Message-ID | <qD6PL-6WV-3@gated-at.bofh.it> (permalink) |
| References | <qD6PL-6WV-5@gated-at.bofh.it> |
| X-Original-To | <mst@redhat.com> |
| X-Ironport-Av | E=Sophos;i="5.20,395,1444694400"; d="scan'208";a="323180812" |
| X-Mailer | git-send-email 1.7.9.5 |
| MIME-Version | 1.0 |
| Content-Type | text/plain |
| X-Dlp | MIA1 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 71 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | <virtualization@lists.linux-foundation.org>, <linux-kernel@vger.kernel.org>, <xen-devel@lists.xenproject.org>, <Stefano.Stabellini@eu.citrix.com>, Stefano Stabellini <stefano.stabellini@eu.citrix.com> |
| X-Original-Date | Mon, 7 Dec 2015 16:19:42 +0000 |
| X-Original-Message-ID | <1449505183-29740-2-git-send-email-stefano.stabellini@eu.citrix.com> |
| X-Original-References | <alpine.DEB.2.02.1512071555590.24652@kaball.uk.xensource.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1285762 |
Show key headers only | View raw
When running on Xen inside as virtual machine (nested virt scenario),
memory allocated by alloc_pages_exact might not actually be contiguous.
Call xen_swiotlb_alloc_coherent instead, which is going to take care of
making the buffer contiguous in machine memory.
No changes in behavior for the non-Xen case.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
Alternatively we could call dma_alloc_coherent in all cases, but that
would make the non-Xen code path more complex.
---
drivers/virtio/virtio_pci_legacy.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/virtio/virtio_pci_legacy.c b/drivers/virtio/virtio_pci_legacy.c
index 48bc979..27359ac 100644
--- a/drivers/virtio/virtio_pci_legacy.c
+++ b/drivers/virtio/virtio_pci_legacy.c
@@ -18,6 +18,8 @@
*/
#include "virtio_pci_common.h"
+#include <xen/xen.h>
+#include <xen/swiotlb-xen.h>
/* virtio config->get_features() implementation */
static u64 vp_get_features(struct virtio_device *vdev)
@@ -122,6 +124,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
unsigned long size;
u16 num;
int err;
+ dma_addr_t dma_addr;
/* Select the queue we're interested in */
iowrite16(index, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_SEL);
@@ -135,12 +138,20 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
info->msix_vector = msix_vec;
size = PAGE_ALIGN(vring_size(num, VIRTIO_PCI_VRING_ALIGN));
- info->queue = alloc_pages_exact(size, GFP_KERNEL|__GFP_ZERO);
+ /* activate the queue */
+ if (xen_domain()) {
+ info->queue = xen_swiotlb_alloc_coherent(NULL,
+ size,
+ &dma_addr,
+ GFP_KERNEL|__GFP_ZERO,
+ NULL);
+ } else {
+ info->queue = alloc_pages_exact(size, GFP_KERNEL|__GFP_ZERO);
+ dma_addr = virt_to_phys(info->queue);
+ }
if (info->queue == NULL)
return ERR_PTR(-ENOMEM);
-
- /* activate the queue */
- iowrite32(virt_to_phys(info->queue) >> VIRTIO_PCI_QUEUE_ADDR_SHIFT,
+ iowrite32(dma_addr >> VIRTIO_PCI_QUEUE_ADDR_SHIFT,
vp_dev->ioaddr + VIRTIO_PCI_QUEUE_PFN);
/* create the vring */
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH RFC 2/3] xen/virtio: allocate a contiguous region to be use as virtio queue Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2015-12-07 17:30 +0100
csiph-web