The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, will@kernel.org,
	jasowang@redhat.com, virtualization@lists.linux-foundation.org,
	Joerg Roedel <jroedel@suse.de>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Christoph Hellwig <hch@lst.de>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Steven Price <steven.price@arm.com>
Subject: Re: [PATCH] virtio_vring: Fix maximum DMA mapping size computation
Date: Fri, 03 Dec 2021 12:26:24 +0000	[thread overview]
Message-ID: <0a13bd69696e1197bbc022d88ff0781c@kernel.org> (raw)
In-Reply-To: <20211203121614.3380162-1-suzuki.poulose@arm.com>

On 2021-12-03 12:16, Suzuki K Poulose wrote:
> The virtio vring is a bit messy about the DMA allocations. We
> use the parent device for any DMA alloc/free. However, we use the
> child device for calculating the maximum size mapped by the DMA API
> for the device. This leads to issues where the max size is set to
> SIZE_MAX, and if the virtio device (e.g, virtio-blk) is bound to
> swiotlb (e.g., via restricted-dma pool), we end up trying to allocate
> larger chunks of memory, which are never satisfied by the swiotlb and
> eventually fails.
> 
> Fix this by using the parent device (just like all the other
> DMA API calls) for the max mapping size.
> 
> Fixes: e6d6dd6c875e ("virtio: Introduce virtio_max_dma_size()")
> Cc: Joerg Roedel <jroedel@suse.de>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Steven Price <steven.price@arm.com>
> Co-developed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/virtio/virtio_ring.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/virtio/virtio_ring.c 
> b/drivers/virtio/virtio_ring.c
> index 6d2614e34470..028b05d44546 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -268,7 +268,7 @@ size_t virtio_max_dma_size(struct virtio_device 
> *vdev)
>  	size_t max_segment_size = SIZE_MAX;
> 
>  	if (vring_use_dma_api(vdev))
> -		max_segment_size = dma_max_mapping_size(&vdev->dev);
> +		max_segment_size = dma_max_mapping_size(vdev->dev.parent);
> 
>  	return max_segment_size;
>  }

Ah, it looks like we all hit the same thing[1] at the same time!

         M.

[1] https://lore.kernel.org/r/20211201112018.25276-1-will@kernel.org
-- 
Jazz is not dead. It just smells funny...

  reply	other threads:[~2021-12-03 12:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-03 12:16 [PATCH] virtio_vring: Fix maximum DMA mapping size computation Suzuki K Poulose
2021-12-03 12:26 ` Marc Zyngier [this message]
2021-12-03 14:32   ` Suzuki K Poulose

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=0a13bd69696e1197bbc022d88ff0781c@kernel.org \
    --to=maz@kernel.org \
    --cc=hch@lst.de \
    --cc=jasowang@redhat.com \
    --cc=jroedel@suse.de \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=robin.murphy@arm.com \
    --cc=steven.price@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=will@kernel.org \
    /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