Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+28 -3
+4
drivers/iommu/amd_iommu.c
··· 3069 3069 3070 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 3076 return 0; 3073 3077 3074 3078 out_free:
+16 -3
drivers/iommu/iommu.c
··· 348 348 int iommu_domain_get_attr(struct iommu_domain *domain, 349 349 enum iommu_attr attr, void *data) 350 350 { 351 - if (!domain->ops->domain_get_attr) 352 - return -EINVAL; 351 + struct iommu_domain_geometry *geometry; 352 + int ret = 0; 353 353 354 - return domain->ops->domain_get_attr(domain, attr, data); 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; 363 + 364 + ret = domain->ops->domain_get_attr(domain, attr, data); 365 + } 366 + 367 + return ret; 355 368 } 356 369 EXPORT_SYMBOL_GPL(iommu_domain_get_attr); 357 370
+8
include/linux/iommu.h
··· 37 37 typedef int (*iommu_fault_handler_t)(struct iommu_domain *, 38 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 46 struct iommu_domain { 41 47 struct iommu_ops *ops; 42 48 void *priv; 43 49 iommu_fault_handler_t handler; 44 50 void *handler_token; 51 + struct iommu_domain_geometry geometry; 45 52 }; 46 53 47 54 #define IOMMU_CAP_CACHE_COHERENCY 0x1 ··· 56 49 57 50 enum iommu_attr { 58 51 DOMAIN_ATTR_MAX, 52 + DOMAIN_ATTR_GEOMETRY, 59 53 }; 60 54 61 55 #ifdef CONFIG_IOMMU_API