From: Stefano Garzarella <sgarzare@redhat.com>
To: Xie Yongji <xieyongji@bytedance.com>
Cc: virtualization@lists.linux-foundation.org, mst@redhat.com
Subject: Re: [PATCH] vdpa_sim: Fix incorrect size passed to alloc_iova()
Date: Mon, 9 Aug 2021 11:04:35 +0200 [thread overview]
Message-ID: <20210809090435.e5dpn4fw75rjwtw5@steredhat> (raw)
In-Reply-To: <20210809060257.99-1-xieyongji@bytedance.com>
On Mon, Aug 09, 2021 at 02:02:57PM +0800, Xie Yongji wrote:
>The size passed to alloc_iova() should be the size of
>page frames to allocate rather than size in bytes.
>
>Fixes: 4080fc106750 ("vdpa_sim: use iova module to allocate IOVA addresses")
>Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
>---
> drivers/vdpa/vdpa_sim/vdpa_sim.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
>index 14e024de5cbf..1ccf615221fe 100644
>--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
>+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
>@@ -137,7 +137,8 @@ static dma_addr_t vdpasim_map_range(struct vdpasim *vdpasim, phys_addr_t paddr,
> int ret;
>
> /* We set the limit_pfn to the maximum (ULONG_MAX - 1) */
>- iova = alloc_iova(&vdpasim->iova, size, ULONG_MAX - 1, true);
>+ iova = alloc_iova(&vdpasim->iova, size >> iova_shift(&vdpasim->iova),
>+ ULONG_MAX - 1, true);
> if (!iova)
> return DMA_MAPPING_ERROR;
>
>--
>2.11.0
>
We invoked init_iova_domain() with granularity = 1, so it should be
correct to use the size in bytes.
However, in order to avoid future bugs if we change granularity, I agree
that it's better to use iova_shift():
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Thanks,
Stefano
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next parent reply other threads:[~2021-08-09 9:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210809060257.99-1-xieyongji@bytedance.com>
2021-08-09 9:04 ` Stefano Garzarella [this message]
[not found] ` <CACycT3s9ZKGhXquuVBiOEmEELCMgqVw1no7JpA8_J3maCKKqxA@mail.gmail.com>
2021-08-09 9:35 ` [PATCH] vdpa_sim: Fix incorrect size passed to alloc_iova() Michael S. Tsirkin
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=20210809090435.e5dpn4fw75rjwtw5@steredhat \
--to=sgarzare@redhat.com \
--cc=mst@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=xieyongji@bytedance.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.