All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: joro@8bytes.org, will@kernel.org
Cc: iommu@lists.linux-foundation.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, suravee.suthikulpanit@amd.com,
	baolu.lu@linux.intel.com, john.garry@huawei.com,
	dianders@chromium.org, rajatja@google.com,
	chenxiang66@hisilicon.com, Yong Wu <yong.wu@mediatek.com>,
	Chunyan Zhang <chunyan.zhang@unisoc.com>,
	Maxime Ripard <mripard@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	Jean-Philippe Brucker <jean-philippe@linaro.org>
Subject: [PATCH v4 01/24] iommu: Pull IOVA cookie management into the core
Date: Wed, 11 Aug 2021 13:21:15 +0100	[thread overview]
Message-ID: <46a2c0e7419c7d1d931762dc7b6a69fa082d199a.1628682048.git.robin.murphy@arm.com> (raw)
In-Reply-To: <cover.1628682048.git.robin.murphy@arm.com>

Now that everyone has converged on iommu-dma for IOMMU_DOMAIN_DMA
support, we can abandon the notion of drivers being responsible for the
cookie type, and consolidate all the management into the core code.

CC: Yong Wu <yong.wu@mediatek.com>
CC: Chunyan Zhang <chunyan.zhang@unisoc.com>
CC: Maxime Ripard <mripard@kernel.org>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>

---

v3: Use a simpler temporary check instead of trying to be clever with
    the error code
---
 drivers/iommu/iommu.c | 7 +++++++
 include/linux/iommu.h | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index f2cda9950bd5..b65fcc66ffa4 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -7,6 +7,7 @@
 #define pr_fmt(fmt)    "iommu: " fmt
 
 #include <linux/device.h>
+#include <linux/dma-iommu.h>
 #include <linux/kernel.h>
 #include <linux/bits.h>
 #include <linux/bug.h>
@@ -1946,6 +1947,11 @@ static struct iommu_domain *__iommu_domain_alloc(struct bus_type *bus,
 	/* Assume all sizes by default; the driver may override this later */
 	domain->pgsize_bitmap  = bus->iommu_ops->pgsize_bitmap;
 
+	/* Temporarily avoid -EEXIST while drivers still get their own cookies */
+	if (type == IOMMU_DOMAIN_DMA && !domain->iova_cookie && iommu_get_dma_cookie(domain)) {
+		iommu_domain_free(domain);
+		domain = NULL;
+	}
 	return domain;
 }
 
@@ -1957,6 +1963,7 @@ EXPORT_SYMBOL_GPL(iommu_domain_alloc);
 
 void iommu_domain_free(struct iommu_domain *domain)
 {
+	iommu_put_dma_cookie(domain);
 	domain->ops->domain_free(domain);
 }
 EXPORT_SYMBOL_GPL(iommu_domain_free);
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 4997c78e2670..141779d76035 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -40,6 +40,7 @@ struct iommu_domain;
 struct notifier_block;
 struct iommu_sva;
 struct iommu_fault_event;
+struct iommu_dma_cookie;
 
 /* iommu fault flags */
 #define IOMMU_FAULT_READ	0x0
@@ -86,7 +87,7 @@ struct iommu_domain {
 	iommu_fault_handler_t handler;
 	void *handler_token;
 	struct iommu_domain_geometry geometry;
-	void *iova_cookie;
+	struct iommu_dma_cookie *iova_cookie;
 };
 
 enum iommu_cap {
-- 
2.25.1


WARNING: multiple messages have this Message-ID (diff)
From: Robin Murphy <robin.murphy@arm.com>
To: joro@8bytes.org, will@kernel.org
Cc: Maxime Ripard <mripard@kernel.org>,
	Jean-Philippe Brucker <jean-philippe@linaro.org>,
	Heiko Stuebner <heiko@sntech.de>,
	linux-kernel@vger.kernel.org,
	Chunyan Zhang <chunyan.zhang@unisoc.com>,
	dianders@chromium.org, iommu@lists.linux-foundation.org,
	rajatja@google.com, linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 01/24] iommu: Pull IOVA cookie management into the core
Date: Wed, 11 Aug 2021 13:21:15 +0100	[thread overview]
Message-ID: <46a2c0e7419c7d1d931762dc7b6a69fa082d199a.1628682048.git.robin.murphy@arm.com> (raw)
In-Reply-To: <cover.1628682048.git.robin.murphy@arm.com>

Now that everyone has converged on iommu-dma for IOMMU_DOMAIN_DMA
support, we can abandon the notion of drivers being responsible for the
cookie type, and consolidate all the management into the core code.

CC: Yong Wu <yong.wu@mediatek.com>
CC: Chunyan Zhang <chunyan.zhang@unisoc.com>
CC: Maxime Ripard <mripard@kernel.org>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>

---

v3: Use a simpler temporary check instead of trying to be clever with
    the error code
---
 drivers/iommu/iommu.c | 7 +++++++
 include/linux/iommu.h | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index f2cda9950bd5..b65fcc66ffa4 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -7,6 +7,7 @@
 #define pr_fmt(fmt)    "iommu: " fmt
 
 #include <linux/device.h>
+#include <linux/dma-iommu.h>
 #include <linux/kernel.h>
 #include <linux/bits.h>
 #include <linux/bug.h>
@@ -1946,6 +1947,11 @@ static struct iommu_domain *__iommu_domain_alloc(struct bus_type *bus,
 	/* Assume all sizes by default; the driver may override this later */
 	domain->pgsize_bitmap  = bus->iommu_ops->pgsize_bitmap;
 
+	/* Temporarily avoid -EEXIST while drivers still get their own cookies */
+	if (type == IOMMU_DOMAIN_DMA && !domain->iova_cookie && iommu_get_dma_cookie(domain)) {
+		iommu_domain_free(domain);
+		domain = NULL;
+	}
 	return domain;
 }
 
@@ -1957,6 +1963,7 @@ EXPORT_SYMBOL_GPL(iommu_domain_alloc);
 
 void iommu_domain_free(struct iommu_domain *domain)
 {
+	iommu_put_dma_cookie(domain);
 	domain->ops->domain_free(domain);
 }
 EXPORT_SYMBOL_GPL(iommu_domain_free);
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 4997c78e2670..141779d76035 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -40,6 +40,7 @@ struct iommu_domain;
 struct notifier_block;
 struct iommu_sva;
 struct iommu_fault_event;
+struct iommu_dma_cookie;
 
 /* iommu fault flags */
 #define IOMMU_FAULT_READ	0x0
@@ -86,7 +87,7 @@ struct iommu_domain {
 	iommu_fault_handler_t handler;
 	void *handler_token;
 	struct iommu_domain_geometry geometry;
-	void *iova_cookie;
+	struct iommu_dma_cookie *iova_cookie;
 };
 
 enum iommu_cap {
-- 
2.25.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

WARNING: multiple messages have this Message-ID (diff)
From: Robin Murphy <robin.murphy@arm.com>
To: joro@8bytes.org, will@kernel.org
Cc: iommu@lists.linux-foundation.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, suravee.suthikulpanit@amd.com,
	baolu.lu@linux.intel.com, john.garry@huawei.com,
	dianders@chromium.org, rajatja@google.com,
	chenxiang66@hisilicon.com, Yong Wu <yong.wu@mediatek.com>,
	Chunyan Zhang <chunyan.zhang@unisoc.com>,
	Maxime Ripard <mripard@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	Jean-Philippe Brucker <jean-philippe@linaro.org>
Subject: [PATCH v4 01/24] iommu: Pull IOVA cookie management into the core
Date: Wed, 11 Aug 2021 13:21:15 +0100	[thread overview]
Message-ID: <46a2c0e7419c7d1d931762dc7b6a69fa082d199a.1628682048.git.robin.murphy@arm.com> (raw)
In-Reply-To: <cover.1628682048.git.robin.murphy@arm.com>

Now that everyone has converged on iommu-dma for IOMMU_DOMAIN_DMA
support, we can abandon the notion of drivers being responsible for the
cookie type, and consolidate all the management into the core code.

CC: Yong Wu <yong.wu@mediatek.com>
CC: Chunyan Zhang <chunyan.zhang@unisoc.com>
CC: Maxime Ripard <mripard@kernel.org>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>

---

v3: Use a simpler temporary check instead of trying to be clever with
    the error code
---
 drivers/iommu/iommu.c | 7 +++++++
 include/linux/iommu.h | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index f2cda9950bd5..b65fcc66ffa4 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -7,6 +7,7 @@
 #define pr_fmt(fmt)    "iommu: " fmt
 
 #include <linux/device.h>
+#include <linux/dma-iommu.h>
 #include <linux/kernel.h>
 #include <linux/bits.h>
 #include <linux/bug.h>
@@ -1946,6 +1947,11 @@ static struct iommu_domain *__iommu_domain_alloc(struct bus_type *bus,
 	/* Assume all sizes by default; the driver may override this later */
 	domain->pgsize_bitmap  = bus->iommu_ops->pgsize_bitmap;
 
+	/* Temporarily avoid -EEXIST while drivers still get their own cookies */
+	if (type == IOMMU_DOMAIN_DMA && !domain->iova_cookie && iommu_get_dma_cookie(domain)) {
+		iommu_domain_free(domain);
+		domain = NULL;
+	}
 	return domain;
 }
 
@@ -1957,6 +1963,7 @@ EXPORT_SYMBOL_GPL(iommu_domain_alloc);
 
 void iommu_domain_free(struct iommu_domain *domain)
 {
+	iommu_put_dma_cookie(domain);
 	domain->ops->domain_free(domain);
 }
 EXPORT_SYMBOL_GPL(iommu_domain_free);
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 4997c78e2670..141779d76035 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -40,6 +40,7 @@ struct iommu_domain;
 struct notifier_block;
 struct iommu_sva;
 struct iommu_fault_event;
+struct iommu_dma_cookie;
 
 /* iommu fault flags */
 #define IOMMU_FAULT_READ	0x0
@@ -86,7 +87,7 @@ struct iommu_domain {
 	iommu_fault_handler_t handler;
 	void *handler_token;
 	struct iommu_domain_geometry geometry;
-	void *iova_cookie;
+	struct iommu_dma_cookie *iova_cookie;
 };
 
 enum iommu_cap {
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-08-11 12:21 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11 12:21 [PATCH v4 00/24] iommu: Refactor DMA domain strictness Robin Murphy
2021-08-11 12:21 ` Robin Murphy
2021-08-11 12:21 ` Robin Murphy
2021-08-11 12:21 ` Robin Murphy [this message]
2021-08-11 12:21   ` [PATCH v4 01/24] iommu: Pull IOVA cookie management into the core Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 02/24] iommu/amd: Drop IOVA cookie management Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 03/24] iommu/arm-smmu: " Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 04/24] iommu/vt-d: " Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 05/24] iommu/exynos: " Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 06/24] iommu/ipmmu-vmsa: " Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 07/24] iommu/mtk: " Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 08/24] iommu/rockchip: " Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 09/24] iommu/sprd: " Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 10/24] iommu/sun50i: " Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 11/24] iommu/virtio: " Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 12/24] iommu/dma: Unexport " Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 13/24] iommu/dma: Remove redundant "!dev" checks Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 14/24] iommu: Indicate queued flushes via gather data Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 15/24] iommu/io-pgtable: Remove non-strict quirk Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-24 13:25   ` Geert Uytterhoeven
2021-08-24 13:25     ` Geert Uytterhoeven
2021-08-24 13:25     ` Geert Uytterhoeven
2021-08-24 13:46     ` Robin Murphy
2021-08-24 13:46       ` Robin Murphy
2021-08-24 13:46       ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 16/24] iommu: Introduce explicit type for non-strict DMA domains Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 17/24] iommu/amd: Prepare for multiple DMA domain types Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 18/24] iommu/arm-smmu: " Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 19/24] iommu/vt-d: " Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 20/24] iommu: Express DMA strictness via the domain type Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 21/24] iommu: Expose DMA domain strictness via sysfs Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 22/24] iommu: Only log strictness for DMA domains Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 23/24] iommu: Merge strictness and domain type configs Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21 ` [PATCH v4 24/24] iommu: Allow enabling non-strict mode dynamically Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-11 12:21   ` Robin Murphy
2021-08-18 11:29 ` [PATCH v4 00/24] iommu: Refactor DMA domain strictness Joerg Roedel
2021-08-18 11:29   ` Joerg Roedel
2021-08-18 11:29   ` Joerg Roedel
2021-08-18 15:13   ` Robin Murphy
2021-08-18 15:13     ` Robin Murphy
2021-08-18 15:13     ` Robin Murphy
2021-08-21  8:55     ` Sven Peter
2021-08-21  8:55       ` Sven Peter
2021-08-21  8:55       ` Sven Peter via iommu

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=46a2c0e7419c7d1d931762dc7b6a69fa082d199a.1628682048.git.robin.murphy@arm.com \
    --to=robin.murphy@arm.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=chenxiang66@hisilicon.com \
    --cc=chunyan.zhang@unisoc.com \
    --cc=dianders@chromium.org \
    --cc=heiko@sntech.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jean-philippe@linaro.org \
    --cc=john.garry@huawei.com \
    --cc=joro@8bytes.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mripard@kernel.org \
    --cc=rajatja@google.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=will@kernel.org \
    --cc=yong.wu@mediatek.com \
    --cc=yoshihiro.shimoda.uh@renesas.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.