* [PATCH v3] vfio/type1: Fix vfio_find_dma_valid return
@ 2021-08-23 16:35 Anthony Yznaga
2021-08-26 22:21 ` Alex Williamson
0 siblings, 1 reply; 2+ messages in thread
From: Anthony Yznaga @ 2021-08-23 16:35 UTC (permalink / raw)
To: kvm; +Cc: alex.williamson, steven.sistare
vfio_find_dma_valid is defined to return WAITED on success if it was
necessary to wait. However, the loop forgets the WAITED value returned
by vfio_wait() and returns 0 in a later iteration. Fix it.
Signed-off-by: Anthony Yznaga <anthony.yznaga@oracle.com>
Reviewed-by: Steve Sistare <steven.sistare@oracle.com>
---
v3:
use Steve Sistare's suggested commit text and add his R-b
v2:
use Alex Williamson's simplified fix
drivers/vfio/vfio_iommu_type1.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 0b4f7c174c7a..0e9217687f5c 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -612,17 +612,17 @@ static int vfio_wait(struct vfio_iommu *iommu)
static int vfio_find_dma_valid(struct vfio_iommu *iommu, dma_addr_t start,
size_t size, struct vfio_dma **dma_p)
{
- int ret;
+ int ret = 0;
do {
*dma_p = vfio_find_dma(iommu, start, size);
if (!*dma_p)
- ret = -EINVAL;
+ return -EINVAL;
else if (!(*dma_p)->vaddr_invalid)
- ret = 0;
+ return ret;
else
ret = vfio_wait(iommu);
- } while (ret > 0);
+ } while (ret == WAITED);
return ret;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] vfio/type1: Fix vfio_find_dma_valid return
2021-08-23 16:35 [PATCH v3] vfio/type1: Fix vfio_find_dma_valid return Anthony Yznaga
@ 2021-08-26 22:21 ` Alex Williamson
0 siblings, 0 replies; 2+ messages in thread
From: Alex Williamson @ 2021-08-26 22:21 UTC (permalink / raw)
To: Anthony Yznaga; +Cc: kvm, steven.sistare
On Mon, 23 Aug 2021 09:35:50 -0700
Anthony Yznaga <anthony.yznaga@oracle.com> wrote:
> vfio_find_dma_valid is defined to return WAITED on success if it was
> necessary to wait. However, the loop forgets the WAITED value returned
> by vfio_wait() and returns 0 in a later iteration. Fix it.
>
> Signed-off-by: Anthony Yznaga <anthony.yznaga@oracle.com>
> Reviewed-by: Steve Sistare <steven.sistare@oracle.com>
>
> ---
> v3:
> use Steve Sistare's suggested commit text and add his R-b
> v2:
> use Alex Williamson's simplified fix
>
> drivers/vfio/vfio_iommu_type1.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
Applied to vfio next branch for v5.15. Thanks,
Alex
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-26 22:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-23 16:35 [PATCH v3] vfio/type1: Fix vfio_find_dma_valid return Anthony Yznaga
2021-08-26 22:21 ` Alex Williamson
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).