diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2012-01-26 13:40:53 -0500 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2012-07-11 06:15:45 -0400 |
commit | 0ff64f80e075ae036a4c80c7d7752b1e07fed792 (patch) | |
tree | ac1bbe189cfe6908d0bdceaa3042ddd767b98187 | |
parent | 0cd76dd13bdd2f7f02a2dc931e808e92b191082f (diff) |
iommu/amd: Implement DOMAIN_ATTR_GEOMETRY attribute
Implement the attribute itself and add the code for the
AMD IOMMU driver.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
-rw-r--r-- | drivers/iommu/amd_iommu.c | 4 | ||||
-rw-r--r-- | drivers/iommu/iommu.c | 19 | ||||
-rw-r--r-- | include/linux/iommu.h | 8 |
3 files changed, 28 insertions, 3 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index a2e418cba0ff..259a6beddece 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c | |||
@@ -3069,6 +3069,10 @@ static int amd_iommu_domain_init(struct iommu_domain *dom) | |||
3069 | 3069 | ||
3070 | dom->priv = domain; | 3070 | dom->priv = domain; |
3071 | 3071 | ||
3072 | dom->geometry.aperture_start = 0; | ||
3073 | dom->geometry.aperture_end = ~0ULL; | ||
3074 | dom->geometry.force_aperture = true; | ||
3075 | |||
3072 | return 0; | 3076 | return 0; |
3073 | 3077 | ||
3074 | out_free: | 3078 | out_free: |
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index c39972d8ded3..ed5e0a553ca7 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c | |||
@@ -348,10 +348,23 @@ EXPORT_SYMBOL_GPL(iommu_device_group); | |||
348 | int iommu_domain_get_attr(struct iommu_domain *domain, | 348 | int iommu_domain_get_attr(struct iommu_domain *domain, |
349 | enum iommu_attr attr, void *data) | 349 | enum iommu_attr attr, void *data) |
350 | { | 350 | { |
351 | if (!domain->ops->domain_get_attr) | 351 | struct iommu_domain_geometry *geometry; |
352 | return -EINVAL; | 352 | int ret = 0; |
353 | |||
354 | switch (attr) { | ||
355 | case DOMAIN_ATTR_GEOMETRY: | ||
356 | geometry = data; | ||
357 | *geometry = domain->geometry; | ||
358 | |||
359 | break; | ||
360 | default: | ||
361 | if (!domain->ops->domain_get_attr) | ||
362 | return -EINVAL; | ||
353 | 363 | ||
354 | return domain->ops->domain_get_attr(domain, attr, data); | 364 | ret = domain->ops->domain_get_attr(domain, attr, data); |
365 | } | ||
366 | |||
367 | return ret; | ||
355 | } | 368 | } |
356 | EXPORT_SYMBOL_GPL(iommu_domain_get_attr); | 369 | EXPORT_SYMBOL_GPL(iommu_domain_get_attr); |
357 | 370 | ||
diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 0eef096183e8..f7df4aa527f3 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h | |||
@@ -37,11 +37,18 @@ struct iommu_domain; | |||
37 | typedef int (*iommu_fault_handler_t)(struct iommu_domain *, | 37 | typedef int (*iommu_fault_handler_t)(struct iommu_domain *, |
38 | struct device *, unsigned long, int, void *); | 38 | struct device *, unsigned long, int, void *); |
39 | 39 | ||
40 | struct iommu_domain_geometry { | ||
41 | dma_addr_t aperture_start; /* First address that can be mapped */ | ||
42 | dma_addr_t aperture_end; /* Last address that can be mapped */ | ||
43 | bool force_aperture; /* DMA only allowed in mappable range? */ | ||
44 | }; | ||
45 | |||
40 | struct iommu_domain { | 46 | struct iommu_domain { |
41 | struct iommu_ops *ops; | 47 | struct iommu_ops *ops; |
42 | void *priv; | 48 | void *priv; |
43 | iommu_fault_handler_t handler; | 49 | iommu_fault_handler_t handler; |
44 | void *handler_token; | 50 | void *handler_token; |
51 | struct iommu_domain_geometry geometry; | ||
45 | }; | 52 | }; |
46 | 53 | ||
47 | #define IOMMU_CAP_CACHE_COHERENCY 0x1 | 54 | #define IOMMU_CAP_CACHE_COHERENCY 0x1 |
@@ -49,6 +56,7 @@ struct iommu_domain { | |||
49 | 56 | ||
50 | enum iommu_attr { | 57 | enum iommu_attr { |
51 | DOMAIN_ATTR_MAX, | 58 | DOMAIN_ATTR_MAX, |
59 | DOMAIN_ATTR_GEOMETRY, | ||
52 | }; | 60 | }; |
53 | 61 | ||
54 | #ifdef CONFIG_IOMMU_API | 62 | #ifdef CONFIG_IOMMU_API |