Thread (31 messages) read the whole thread 31 messages, 4 authors, 2023-05-03

Re: [PATCH 16/20] iommu/sun50i: Add an IOMMU_IDENTITIY_DOMAIN

From: Robin Murphy <robin.murphy@arm.com>
Date: 2023-05-03 15:54:43
Also in: linux-arm-msm, linux-iommu, linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc, linux-sunxi, linux-tegra

On 2023-05-01 19:03, Jason Gunthorpe wrote:
quoted hunk ↗ jump to hunk
This brings back the ops->detach_dev() code that commit
1b932ceddd19 ("iommu: Remove detach_dev callbacks") deleted and turns it
into an IDENTITY domain.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
  drivers/iommu/sun50i-iommu.c | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)
diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c
index 74c5cb93e90027..15fd62d360778f 100644
--- a/drivers/iommu/sun50i-iommu.c
+++ b/drivers/iommu/sun50i-iommu.c
@@ -772,6 +772,26 @@ static void sun50i_iommu_detach_device(struct iommu_domain *domain,
  		sun50i_iommu_detach_domain(iommu, sun50i_domain);
  }
  
+static int sun50i_iommu_identity_attach(struct iommu_domain *identity_domain,
+					struct device *dev)
+{
+	struct sun50i_iommu *iommu = dev_iommu_priv_get(dev);
+
+	if (iommu->domain == identity_domain || !iommu->domain)
I don't think that first condition could ever be true.

Thanks,
Robin.
quoted hunk ↗ jump to hunk
+		return 0;
+	sun50i_iommu_detach_device(iommu->domain, dev);
+	return 0;
+}
+
+static struct iommu_domain_ops sun50i_iommu_identity_ops = {
+	.attach_dev = sun50i_iommu_identity_attach,
+};
+
+static struct iommu_domain sun50i_iommu_identity_domain = {
+	.type = IOMMU_DOMAIN_IDENTITY,
+	.ops = &sun50i_iommu_identity_ops,
+};
+
  static int sun50i_iommu_attach_device(struct iommu_domain *domain,
  				      struct device *dev)
  {
@@ -827,6 +847,7 @@ static int sun50i_iommu_of_xlate(struct device *dev,
  }
  
  static const struct iommu_ops sun50i_iommu_ops = {
+	.identity_domain = &sun50i_iommu_identity_domain,
  	.pgsize_bitmap	= SZ_4K,
  	.device_group	= sun50i_iommu_device_group,
  	.domain_alloc	= sun50i_iommu_domain_alloc,
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help