All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] iommu/tegra-smmu: Adding PCI support and mappings debugfs node
@ 2020-09-26  8:07 ` Nicolin Chen
  0 siblings, 0 replies; 49+ messages in thread
From: Nicolin Chen @ 2020-09-26  8:07 UTC (permalink / raw)
  To: thierry.reding, joro, krzk; +Cc: linux-tegra, linux-kernel, iommu, jonathanh

This series of patches are some followup patches for tegra-smmu.

There are four parts:
1, PATCH-1 is a clean-up patch for the recently applied SWGROUP change.
2, PATCH-2 fixes a potential race condition
3, PATCH-3/4 adds PCI device support
4, PATCH-5 adds a debugfs node for phys<=>iova mappings

Each of the four parts is sort of functional independent, so we may
apply them separately or incrementally depending on the reviews.

Nicolin Chen (5):
  iommu/tegra-smmu: Unwrap tegra_smmu_group_get
  iommu/tegra-smmu: Expend mutex protection range
  iommu/tegra-smmu: Use iommu_fwspec in .probe_/.attach_device()
  iommu/tegra-smmu: Add PCI support
  iommu/tegra-smmu: Add pagetable mappings to debugfs

 drivers/iommu/tegra-smmu.c | 287 ++++++++++++++++++++++++++++---------
 drivers/memory/tegra/mc.c  |   2 +-
 include/soc/tegra/mc.h     |   2 +
 3 files changed, 221 insertions(+), 70 deletions(-)

-- 
2.17.1

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

^ permalink raw reply	[flat|nested] 49+ messages in thread
* [PATCH 1/5] iommu/tegra-smmu: Fix domain_alloc
@ 2019-01-16 20:50 Navneet Kumar
       [not found] ` <1547671814-30088-1-git-send-email-navneetk-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 49+ messages in thread
From: Navneet Kumar @ 2019-01-16 20:50 UTC (permalink / raw)
  To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	joro-zLv9SwRftAIdnm+yROfE0A
  Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	navneetk-DDmLM1+adcrQT0dZR+AlfA,
	thierry.reding-Re5JQEeQqe8AvxtiuMwx3w,
	jonathanh-DDmLM1+adcrQT0dZR+AlfA

* Allocate dma iova cookie for a domain while adding dma iommu
devices.
* Perform a stricter check for domain type parameter.

Signed-off-by: Navneet Kumar <navneetk-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 drivers/iommu/tegra-smmu.c | 43 +++++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index 543f7c9..ee4d8a8 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -16,6 +16,7 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/dma-mapping.h>
+#include <linux/dma-iommu.h>
 
 #include <soc/tegra/ahb.h>
 #include <soc/tegra/mc.h>
@@ -271,8 +272,10 @@ static bool tegra_smmu_capable(enum iommu_cap cap)
 static struct iommu_domain *tegra_smmu_domain_alloc(unsigned type)
 {
 	struct tegra_smmu_as *as;
+	int ret;
 
-	if (type != IOMMU_DOMAIN_UNMANAGED)
+	if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_DMA &&
+			type != IOMMU_DOMAIN_IDENTITY)
 		return NULL;
 
 	as = kzalloc(sizeof(*as), GFP_KERNEL);
@@ -281,26 +284,22 @@ static struct iommu_domain *tegra_smmu_domain_alloc(unsigned type)
 
 	as->attr = SMMU_PD_READABLE | SMMU_PD_WRITABLE | SMMU_PD_NONSECURE;
 
+	ret = (type == IOMMU_DOMAIN_DMA) ? iommu_get_dma_cookie(&as->domain) :
+		-ENODEV;
+	if (ret)
+		goto free_as;
+
 	as->pd = alloc_page(GFP_KERNEL | __GFP_DMA | __GFP_ZERO);
-	if (!as->pd) {
-		kfree(as);
-		return NULL;
-	}
+	if (!as->pd)
+		goto put_dma_cookie;
 
 	as->count = kcalloc(SMMU_NUM_PDE, sizeof(u32), GFP_KERNEL);
-	if (!as->count) {
-		__free_page(as->pd);
-		kfree(as);
-		return NULL;
-	}
+	if (!as->count)
+		goto free_pd_range;
 
 	as->pts = kcalloc(SMMU_NUM_PDE, sizeof(*as->pts), GFP_KERNEL);
-	if (!as->pts) {
-		kfree(as->count);
-		__free_page(as->pd);
-		kfree(as);
-		return NULL;
-	}
+	if (!as->pts)
+		goto free_pts;
 
 	/* setup aperture */
 	as->domain.geometry.aperture_start = 0;
@@ -308,6 +307,18 @@ static struct iommu_domain *tegra_smmu_domain_alloc(unsigned type)
 	as->domain.geometry.force_aperture = true;
 
 	return &as->domain;
+
+free_pts:
+	kfree(as->pts);
+free_pd_range:
+	__free_page(as->pd);
+put_dma_cookie:
+	if (type == IOMMU_DOMAIN_DMA)
+		iommu_put_dma_cookie(&as->domain);
+free_as:
+	kfree(as);
+
+	return NULL;
 }
 
 static void tegra_smmu_domain_free(struct iommu_domain *domain)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2020-09-29  5:42 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-26  8:07 [PATCH 0/5] iommu/tegra-smmu: Adding PCI support and mappings debugfs node Nicolin Chen
2020-09-26  8:07 ` Nicolin Chen
2020-09-26  8:07 ` [PATCH 1/5] iommu/tegra-smmu: Unwrap tegra_smmu_group_get Nicolin Chen
2020-09-26  8:07   ` Nicolin Chen
2020-09-28  7:13   ` Thierry Reding
2020-09-28  7:13     ` Thierry Reding
2020-09-28 19:33     ` Nicolin Chen
2020-09-28 19:33       ` Nicolin Chen
2020-09-26  8:07 ` [PATCH 2/5] iommu/tegra-smmu: Expend mutex protection range Nicolin Chen
2020-09-26  8:07   ` Nicolin Chen
2020-09-26  8:07 ` [PATCH 3/5] iommu/tegra-smmu: Use iommu_fwspec in .probe_/.attach_device() Nicolin Chen
2020-09-26  8:07   ` Nicolin Chen
2020-09-26 14:48   ` Dmitry Osipenko
2020-09-26 14:48     ` Dmitry Osipenko
2020-09-26 20:42     ` Nicolin Chen
2020-09-26 20:42       ` Nicolin Chen
2020-09-28  7:29     ` Thierry Reding
2020-09-28  7:29       ` Thierry Reding
2020-09-28  7:52   ` Thierry Reding
2020-09-28  7:52     ` Thierry Reding
2020-09-28 22:18     ` Nicolin Chen
2020-09-28 22:18       ` Nicolin Chen
2020-09-29  4:06       ` Dmitry Osipenko
2020-09-29  4:06         ` Dmitry Osipenko
2020-09-29  5:36         ` Nicolin Chen
2020-09-29  5:36           ` Nicolin Chen
2020-09-26  8:07 ` [PATCH 4/5] iommu/tegra-smmu: Add PCI support Nicolin Chen
2020-09-26  8:07   ` Nicolin Chen
2020-09-26 22:18   ` Dmitry Osipenko
2020-09-26 22:18     ` Dmitry Osipenko
2020-09-28 22:31     ` Nicolin Chen
2020-09-28 22:31       ` Nicolin Chen
2020-09-28  7:55   ` Thierry Reding
2020-09-28  7:55     ` Thierry Reding
2020-09-28 22:33     ` Nicolin Chen
2020-09-28 22:33       ` Nicolin Chen
2020-09-26  8:07 ` [PATCH 5/5] iommu/tegra-smmu: Add pagetable mappings to debugfs Nicolin Chen
2020-09-26  8:07   ` Nicolin Chen
2020-09-26 14:48   ` Dmitry Osipenko
2020-09-26 14:48     ` Dmitry Osipenko
2020-09-26 20:47     ` Nicolin Chen
2020-09-26 20:47       ` Nicolin Chen
2020-09-26 21:41       ` Dmitry Osipenko
2020-09-26 21:41         ` Dmitry Osipenko
2020-09-26 21:24   ` Dmitry Osipenko
2020-09-26 21:24     ` Dmitry Osipenko
2020-09-26 21:37     ` Dmitry Osipenko
2020-09-26 21:37       ` Dmitry Osipenko
  -- strict thread matches above, loose matches on Subject: below --
2019-01-16 20:50 [PATCH 1/5] iommu/tegra-smmu: Fix domain_alloc Navneet Kumar
     [not found] ` <1547671814-30088-1-git-send-email-navneetk-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2019-01-16 20:50   ` [PATCH 4/5] iommu/tegra-smmu: Add PCI support Navneet Kumar

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.