From: "Michael S. Tsirkin" <mst@redhat.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: will.deacon@arm.com, linux-arm-kernel@lists.infradead.org,
luto@kernel.org, virtualization@lists.linux-foundation.org
Subject: Re: [PATCH v2 1/2] virtio_mmio: Set DMA masks appropriately
Date: Wed, 11 Jan 2017 01:30:43 +0200 [thread overview]
Message-ID: <20170111013032-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <85015f1653eb7e36f992708362b75d1f4391b783.1484070340.git.robin.murphy@arm.com>
On Tue, Jan 10, 2017 at 05:51:17PM +0000, Robin Murphy wrote:
> Once DMA API usage is enabled, it becomes apparent that virtio-mmio is
> inadvertently relying on the default 32-bit DMA mask, which leads to
> problems like rapidly exhausting SWIOTLB bounce buffers.
>
> Ensure that we set the appropriate 64-bit DMA mask whenever possible,
> with the coherent mask suitably limited for the legacy vring as per
> a0be1db4304f ("virtio_pci: Limit DMA mask to 44 bits for legacy virtio
> devices").
>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Reported-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
> Fixes: b42111382f0e ("virtio_mmio: Use the DMA API if enabled")
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
I'mm merge this soon.
> ---
> drivers/virtio/virtio_mmio.c | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
> index d47a2fcef818..c71fde5fe835 100644
> --- a/drivers/virtio/virtio_mmio.c
> +++ b/drivers/virtio/virtio_mmio.c
> @@ -59,6 +59,7 @@
> #define pr_fmt(fmt) "virtio-mmio: " fmt
>
> #include <linux/acpi.h>
> +#include <linux/dma-mapping.h>
> #include <linux/highmem.h>
> #include <linux/interrupt.h>
> #include <linux/io.h>
> @@ -498,6 +499,7 @@ static int virtio_mmio_probe(struct platform_device *pdev)
> struct virtio_mmio_device *vm_dev;
> struct resource *mem;
> unsigned long magic;
> + int rc;
>
> mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> if (!mem)
> @@ -547,9 +549,25 @@ static int virtio_mmio_probe(struct platform_device *pdev)
> }
> vm_dev->vdev.id.vendor = readl(vm_dev->base + VIRTIO_MMIO_VENDOR_ID);
>
> - if (vm_dev->version == 1)
> + if (vm_dev->version == 1) {
> writel(PAGE_SIZE, vm_dev->base + VIRTIO_MMIO_GUEST_PAGE_SIZE);
>
> + rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
> + /*
> + * In the legacy case, ensure our coherently-allocated virtio
> + * ring will be at an address expressable as a 32-bit PFN.
> + */
> + if (!rc)
> + dma_set_coherent_mask(&pdev->dev,
> + DMA_BIT_MASK(32 + PAGE_SHIFT));
> + } else {
> + rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
> + }
> + if (rc)
> + rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> + if (rc)
> + dev_warn(&pdev->dev, "Failed to enable 64-bit or 32-bit DMA. Trying to continue, but this might not work.\n");
> +
> platform_set_drvdata(pdev, vm_dev);
>
> return register_virtio_device(&vm_dev->vdev);
> --
> 2.10.2.dirty
next prev parent reply other threads:[~2017-01-10 23:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-10 17:51 [PATCH v2 1/2] virtio_mmio: Set DMA masks appropriately Robin Murphy
2017-01-10 17:51 ` [PATCH v2 2/2] vring: Force use of DMA API for ARM-based systems Robin Murphy
2017-01-10 23:33 ` Michael S. Tsirkin
2017-01-11 10:01 ` Will Deacon
2017-01-11 18:12 ` Andy Lutomirski
2017-01-13 9:40 ` Will Deacon
2017-01-13 16:59 ` Michael S. Tsirkin
2017-01-12 22:12 ` Michael S. Tsirkin
2017-01-13 9:25 ` Will Deacon
2017-01-13 16:46 ` Michael S. Tsirkin
2017-01-13 17:21 ` Will Deacon
2017-01-13 18:23 ` Michael S. Tsirkin
2017-01-16 10:40 ` Will Deacon
2017-01-16 14:18 ` Michael S. Tsirkin
2017-01-16 14:21 ` Will Deacon
2017-01-16 14:27 ` Michael S. Tsirkin
2017-01-16 14:34 ` Will Deacon
2017-01-19 21:51 ` Michael S. Tsirkin
2017-01-20 10:33 ` Will Deacon
2017-01-24 16:04 ` Marc Zyngier
[not found] ` <5ad8ce42-a469-7417-d2c5-58cc0da89e8d@arm.com>
2017-01-24 16:06 ` Michael S. Tsirkin
2017-01-24 16:10 ` Marc Zyngier
2017-01-10 23:30 ` Michael S. Tsirkin [this message]
2017-01-11 10:31 ` [PATCH v2 1/2] virtio_mmio: Set DMA masks appropriately Jean-Philippe Brucker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170111013032-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=luto@kernel.org \
--cc=robin.murphy@arm.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).