summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorJeremy Gebben <jgebben@codeaurora.org>2015-07-10 16:43:23 -0600
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-22 11:13:37 -0700
commit36e4ea4ac1063624ee470f9769f47cf93a13e777 (patch)
tree28b99b390f69267d5cf1f9517559516c5e2b4c8a /include/linux
parent930d3bcb94eeff1773bccf221274b110d9517fb6 (diff)
iommu: introduce DOMAIN_ATTR_DYNAMIC
Some devices can support per-process iommu domains, which are used asynchronously by the hardware which directly updates to the TTBR0 and CONTEXTIDR registers. Add DOMAIN_ATTR_DYNAMIC to do indicate a domain may be used dynamically. This attribute must be set before attaching, as it changes what domain and hardware configuration is done by the iommu driver. Before attaching any dynamic domains, the driver must first attach a non-dynamic domain to do initial hardware configuration. A simplified example: void use_domain(struct iommu_domain *domain, struct job *job) { u64 ttbr0; u32 contextidr; iommu_domain_get_attr(domain, DOMAIN_ATTR_TTBR0, &ttbr0); iommu_domain_get_attr(domain, DOMAIN_ATTR_CONTEXTIDR, &contextidr); /* * Schedule work on the hardware, which is time sliced between * clients. Each client has a separate iommu domain and when * a job is run, the hardware first programs TTBR0 and * CONTEXTIDR to use the appropriate domain. */ submit_job(ttbr0, contextidr, job); } void init(void) { struct iommu_domain *master_domain, *dyn_domain1, *dyn_domain2; int dynamic = 1; master_domain = iommu_domain_alloc(bus); dyn_domain1 = iommu_domain_alloc(bus); dyn_domain2 = iommu_domain_alloc(bus); iommu_attach_device(base_domain, dev); iommu_domain_set_attr(dyn_domain1, DOMAIN_ATTR_DYNAMIC, &dynamic); iommu_domain_set_attr(dyn_domain2, DOMAIN_ATTR_DYNAMIC, &dynamic); iommu_attach_device(dyn_domain1, dev); iommu_attach_device(dyn_domain2, dev); while (keep_going) { iommu_map(dyn_domain1, ...); iommu_map(dyn_domain2, ...); use_domain(dyn_domain1, job1); use_domain(dyn_domain2, job2); iommu_unmap(dyn_domain1, ...); iommu_unmap(dyn_domain2, ...); } iommu_detach_device(dyn_domain2, dev); iommu_detach_device(dyn_domain1, dev); iommu_detach_device(master_domain, dev); } Change-Id: Ic4fa0a831751eb4b10fff5d9aec28a411856fbd1 Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/iommu.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 74e7bee7c08a..a0edc7c93f0a 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -97,6 +97,7 @@ enum iommu_attr {
DOMAIN_ATTR_TTBR0,
DOMAIN_ATTR_CONTEXTIDR,
DOMAIN_ATTR_PROCID,
+ DOMAIN_ATTR_DYNAMIC,
DOMAIN_ATTR_MAX,
};