Linux IOMMU Development
 help / color / mirror / Atom feed
From: Baptiste Reynal <b.reynal@virtualopensystems.com>
To: iommu@lists.linux-foundation.org, kvmarm@lists.cs.columbia.edu
Cc: "open list:VFIO DRIVER" <kvm@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	alex.williamson@redhat.com, tech@virtualopensystems.com
Subject: [PATCH v5 3/4] vfio: type1: replace vfio_domains_have_iommu_cache with generic function
Date: Wed,  4 Mar 2015 17:07:53 +0100	[thread overview]
Message-ID: <1425485274-5709-4-git-send-email-b.reynal@virtualopensystems.com> (raw)
In-Reply-To: <1425485274-5709-1-git-send-email-b.reynal@virtualopensystems.com>

From: Antonios Motakis <a.motakis@virtualopensystems.com>

Replace the function vfio_domains_have_iommu_cache() with a more generic
function vfio_domains_have_iommu_cap() which allows to check all domains
of an vfio_iommu structure for a given cached capability.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Baptiste Reynal <b.reynal@virtualopensystems.com>
---
 drivers/vfio/vfio_iommu_type1.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 57d8c37..a5847e8 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -82,6 +82,23 @@ struct vfio_group {
 	struct list_head	next;
 };
 
+static int vfio_domains_have_iommu_cap(struct vfio_iommu *iommu, int cap)
+{
+	struct vfio_domain *domain;
+	int ret = 1;
+
+	mutex_lock(&iommu->lock);
+	list_for_each_entry(domain, &iommu->domain_list, next) {
+		if (!(domain->domain->ops->capable(cap))) {
+			ret = 0;
+			break;
+		}
+	}
+	mutex_unlock(&iommu->lock);
+
+	return ret;
+}
+
 /*
  * This code handles mapping and unmapping of user data buffers
  * into DMA'ble space using the IOMMU
@@ -935,23 +952,6 @@ static void vfio_iommu_type1_release(void *iommu_data)
 	kfree(iommu);
 }
 
-static int vfio_domains_have_iommu_cache(struct vfio_iommu *iommu)
-{
-	struct vfio_domain *domain;
-	int ret = 1;
-
-	mutex_lock(&iommu->lock);
-	list_for_each_entry(domain, &iommu->domain_list, next) {
-		if (!(domain->prot & IOMMU_CACHE)) {
-			ret = 0;
-			break;
-		}
-	}
-	mutex_unlock(&iommu->lock);
-
-	return ret;
-}
-
 static long vfio_iommu_type1_ioctl(void *iommu_data,
 				   unsigned int cmd, unsigned long arg)
 {
@@ -967,7 +967,8 @@ static long vfio_iommu_type1_ioctl(void *iommu_data,
 		case VFIO_DMA_CC_IOMMU:
 			if (!iommu)
 				return 0;
-			return vfio_domains_have_iommu_cache(iommu);
+			return vfio_domains_have_iommu_cap(iommu,
+						  IOMMU_CAP_CACHE_COHERENCY);
 		default:
 			return 0;
 		}
-- 
2.3.1

  parent reply	other threads:[~2015-03-04 16:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04 16:07 [PATCH v5 0/4] vfio: type1: support for ARM SMMUS with VFIO_IOMMU_TYPE1 Baptiste Reynal
2015-03-04 16:07 ` [PATCH v5 1/4] vfio: implement iommu driver capabilities with an enum Baptiste Reynal
2015-03-04 16:07 ` Baptiste Reynal [this message]
     [not found] ` <1425485274-5709-1-git-send-email-b.reynal-lrHrjnjw1UfHK3s98zE1ajGjJy/sRE9J@public.gmane.org>
2015-03-04 16:07   ` [PATCH v5 2/4] vfio: introduce the VFIO_DMA_MAP_FLAG_NOEXEC flag Baptiste Reynal
2015-03-04 16:07   ` [PATCH v5 4/4] vfio: type1: implement " Baptiste Reynal
2015-03-04 17:45   ` [PATCH v5 0/4] vfio: type1: support for ARM SMMUS with VFIO_IOMMU_TYPE1 Alex Williamson
2015-03-05 10:16     ` Baptiste Reynal
     [not found]     ` <1425491104.5200.268.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-05 17:34       ` Eric Auger
     [not found]         ` <54F893C3.6020006-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-03-05 17:54           ` Alex Williamson
     [not found]             ` <1425578066.5200.331.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-05 18:09               ` Will Deacon
2015-03-05 21:11           ` Alex Williamson
     [not found]             ` <1425589915.5200.336.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-06  9:04               ` Eric Auger
     [not found]                 ` <54F96D96.8040207-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-03-06 10:41                   ` Will Deacon
     [not found]                     ` <20150306104148.GC22377-5wv7dgnIgG8@public.gmane.org>
2015-03-06 11:27                       ` Baptiste Reynal
     [not found]                         ` <CAN9JPjHWcXuzkByJY1gnbvi28nZX8RBbZXDA2t-VeK6v8OrSRg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-06 12:41                           ` Eric Auger
2015-03-06 13:17                           ` Eric Auger
     [not found]                             ` <54F9A8EE.9020008-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-03-06 13:44                               ` Baptiste Reynal
2015-03-06 14: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=1425485274-5709-4-git-send-email-b.reynal@virtualopensystems.com \
    --to=b.reynal@virtualopensystems.com \
    --cc=alex.williamson@redhat.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tech@virtualopensystems.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