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
This commit is contained in:
Ruslan Bukin 2020-10-09 13:11:14 +00:00
parent 4b72ae16ed
commit 72479f6bf9
2 changed files with 18 additions and 7 deletions

View File

@ -269,14 +269,12 @@ iommu_instantiate_ctx(struct iommu_unit *unit, device_t dev, bool rmrr)
return (ctx); return (ctx);
} }
bus_dma_tag_t struct iommu_ctx *
iommu_get_dma_tag(device_t dev, device_t child) iommu_get_dev_ctx(device_t dev)
{ {
struct iommu_unit *unit; 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 ? */ /* Not in scope of any IOMMU ? */
if (unit == NULL) if (unit == NULL)
return (NULL); return (NULL);
@ -288,8 +286,20 @@ iommu_get_dma_tag(device_t dev, device_t child)
dmar_instantiate_rmrr_ctxs(unit); dmar_instantiate_rmrr_ctxs(unit);
#endif #endif
ctx = iommu_instantiate_ctx(unit, child, false); return (iommu_instantiate_ctx(unit, dev, false));
res = ctx == NULL ? NULL : (bus_dma_tag_t)ctx->tag; }
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); return (res);
} }

View File

@ -233,6 +233,7 @@ int bus_dma_iommu_load_ident(bus_dma_tag_t dmat, bus_dmamap_t map,
vm_paddr_t start, vm_size_t length, int flags); vm_paddr_t start, vm_size_t length, int flags);
bus_dma_tag_t iommu_get_dma_tag(device_t dev, device_t child); 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); SYSCTL_DECL(_hw_iommu);