All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Yznaga <anthony.yznaga@oracle.com>
To: kvm@vger.kernel.org
Cc: alex.williamson@redhat.com, steven.sistare@oracle.com
Subject: [PATCH] vfio/type1: Fix vfio_find_dma_valid return
Date: Thu, 19 Aug 2021 16:53:57 -0700	[thread overview]
Message-ID: <1629417237-8924-1-git-send-email-anthony.yznaga@oracle.com> (raw)

Fix vfio_find_dma_valid to return WAITED on success if it was necessary
to wait which mean iommu lock was dropped and reacquired.  This allows
vfio_iommu_type1_pin_pages to recheck vaddr_invalid_count and possibly
avoid the checking the validity of every vaddr in its list.

Signed-off-by: Anthony Yznaga <anthony.yznaga@oracle.com>
---
 drivers/vfio/vfio_iommu_type1.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index a3e925a41b0d..7ca8c4e95da4 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -612,6 +612,7 @@ 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 waited = 0;
 
 	do {
 		*dma_p = vfio_find_dma(iommu, start, size);
@@ -620,10 +621,10 @@ static int vfio_find_dma_valid(struct vfio_iommu *iommu, dma_addr_t start,
 		else if (!(*dma_p)->vaddr_invalid)
 			ret = 0;
 		else
-			ret = vfio_wait(iommu);
+			ret = waited = vfio_wait(iommu);
 	} while (ret > 0);
 
-	return ret;
+	return ret ? ret : waited;
 }
 
 /*
-- 
1.8.3.1


             reply	other threads:[~2021-08-19 23:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-19 23:53 Anthony Yznaga [this message]
2021-08-20 16:24 ` [PATCH] vfio/type1: Fix vfio_find_dma_valid return Alex Williamson
2021-08-20 18:44   ` Anthony Yznaga
2021-08-20 19:46     ` Alex Williamson

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=1629417237-8924-1-git-send-email-anthony.yznaga@oracle.com \
    --to=anthony.yznaga@oracle.com \
    --cc=alex.williamson@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=steven.sistare@oracle.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.