svn commit: r366571 - head/sys/dev/iommu

Ruslan Bukin br at FreeBSD.org
Fri Oct 9 13:11:15 UTC 2020


Author: br
Date: Fri Oct  9 13:11:14 2020
New Revision: 366571
URL: https://svnweb.freebsd.org/changeset/base/366571

Log:
  Add iommu_get_dev_ctx() helper that allows to instantiate an iommu context
  for a given device_t.
  
  Submitted by:	andrew
  Reviewed by:	kib
  Sponsored by:	DARPA, AFRL

Modified:
  head/sys/dev/iommu/busdma_iommu.c
  head/sys/dev/iommu/iommu.h

Modified: head/sys/dev/iommu/busdma_iommu.c
==============================================================================
--- head/sys/dev/iommu/busdma_iommu.c	Fri Oct  9 12:44:56 2020	(r366570)
+++ head/sys/dev/iommu/busdma_iommu.c	Fri Oct  9 13:11:14 2020	(r366571)
@@ -269,14 +269,12 @@ iommu_instantiate_ctx(struct iommu_unit *unit, device_
 	return (ctx);
 }
 
-bus_dma_tag_t
-iommu_get_dma_tag(device_t dev, device_t child)
+struct iommu_ctx *
+iommu_get_dev_ctx(device_t dev)
 {
 	struct iommu_unit *unit;
-	struct iommu_ctx *ctx;
-	bus_dma_tag_t res;
 
-	unit = iommu_find(child, bootverbose);
+	unit = iommu_find(dev, bootverbose);
 	/* Not in scope of any IOMMU ? */
 	if (unit == NULL)
 		return (NULL);
@@ -288,8 +286,20 @@ iommu_get_dma_tag(device_t dev, device_t child)
 	dmar_instantiate_rmrr_ctxs(unit);
 #endif
 
-	ctx = iommu_instantiate_ctx(unit, child, false);
-	res = ctx == NULL ? NULL : (bus_dma_tag_t)ctx->tag;
+	return (iommu_instantiate_ctx(unit, dev, false));
+}
+
+bus_dma_tag_t
+iommu_get_dma_tag(device_t dev, device_t child)
+{
+	struct iommu_ctx *ctx;
+	bus_dma_tag_t res;
+
+	ctx = iommu_get_dev_ctx(child);
+	if (ctx == NULL)
+		return (NULL);
+
+	res = (bus_dma_tag_t)ctx->tag;
 	return (res);
 }
 

Modified: head/sys/dev/iommu/iommu.h
==============================================================================
--- head/sys/dev/iommu/iommu.h	Fri Oct  9 12:44:56 2020	(r366570)
+++ head/sys/dev/iommu/iommu.h	Fri Oct  9 13:11:14 2020	(r366571)
@@ -233,6 +233,7 @@ int bus_dma_iommu_load_ident(bus_dma_tag_t dmat, bus_d
     vm_paddr_t start, vm_size_t length, int flags);
 
 bus_dma_tag_t iommu_get_dma_tag(device_t dev, device_t child);
+struct iommu_ctx *iommu_get_dev_ctx(device_t dev);
 
 SYSCTL_DECL(_hw_iommu);
 


More information about the svn-src-head mailing list