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

iommu: remove DOMAIN_ATTR_IO_PGTABLE_CFG

Use an explicit set_pgtable_quirks method instead that just passes
the actual quirk bitmask instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Will Deacon <will@kernel.org>
Acked-by: Li Yang <leoyang.li@nxp.com>
Link: https://lore.kernel.org/r/20210401155256.298656-20-hch@lst.de
Signed-off-by: Joerg Roedel <jroedel@suse.de>

authored by

Christoph Hellwig and committed by
Joerg Roedel
4fc52b81 a250c23f

+35 -63
+1 -4
drivers/gpu/drm/msm/adreno/adreno_gpu.c
··· 188 188 189 189 void adreno_set_llc_attributes(struct iommu_domain *iommu) 190 190 { 191 - struct io_pgtable_domain_attr pgtbl_cfg; 192 - 193 - pgtbl_cfg.quirks = IO_PGTABLE_QUIRK_ARM_OUTER_WBWA; 194 - iommu_domain_set_attr(iommu, DOMAIN_ATTR_IO_PGTABLE_CFG, &pgtbl_cfg); 191 + iommu_set_pgtable_quirks(iommu, IO_PGTABLE_QUIRK_ARM_OUTER_WBWA); 195 192 } 196 193 197 194 struct msm_gem_address_space *
+11 -53
drivers/iommu/arm/arm-smmu/arm-smmu.c
··· 770 770 goto out_clear_smmu; 771 771 } 772 772 773 - if (smmu_domain->pgtbl_cfg.quirks) 774 - pgtbl_cfg.quirks |= smmu_domain->pgtbl_cfg.quirks; 773 + if (smmu_domain->pgtbl_quirks) 774 + pgtbl_cfg.quirks |= smmu_domain->pgtbl_quirks; 775 775 776 776 pgtbl_ops = alloc_io_pgtable_ops(fmt, &pgtbl_cfg, smmu_domain); 777 777 if (!pgtbl_ops) { ··· 1484 1484 return group; 1485 1485 } 1486 1486 1487 - static int arm_smmu_domain_get_attr(struct iommu_domain *domain, 1488 - enum iommu_attr attr, void *data) 1489 - { 1490 - struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); 1491 - 1492 - switch(domain->type) { 1493 - case IOMMU_DOMAIN_UNMANAGED: 1494 - switch (attr) { 1495 - case DOMAIN_ATTR_IO_PGTABLE_CFG: { 1496 - struct io_pgtable_domain_attr *pgtbl_cfg = data; 1497 - *pgtbl_cfg = smmu_domain->pgtbl_cfg; 1498 - 1499 - return 0; 1500 - } 1501 - default: 1502 - return -ENODEV; 1503 - } 1504 - break; 1505 - default: 1506 - return -EINVAL; 1507 - } 1508 - } 1509 - 1510 1487 static int arm_smmu_enable_nesting(struct iommu_domain *domain) 1511 1488 { 1512 1489 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); ··· 1499 1522 return ret; 1500 1523 } 1501 1524 1502 - static int arm_smmu_domain_set_attr(struct iommu_domain *domain, 1503 - enum iommu_attr attr, void *data) 1525 + static int arm_smmu_set_pgtable_quirks(struct iommu_domain *domain, 1526 + unsigned long quirks) 1504 1527 { 1505 - int ret = 0; 1506 1528 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); 1529 + int ret = 0; 1507 1530 1508 1531 mutex_lock(&smmu_domain->init_mutex); 1509 - 1510 - switch(domain->type) { 1511 - case IOMMU_DOMAIN_UNMANAGED: 1512 - switch (attr) { 1513 - case DOMAIN_ATTR_IO_PGTABLE_CFG: { 1514 - struct io_pgtable_domain_attr *pgtbl_cfg = data; 1515 - 1516 - if (smmu_domain->smmu) { 1517 - ret = -EPERM; 1518 - goto out_unlock; 1519 - } 1520 - 1521 - smmu_domain->pgtbl_cfg = *pgtbl_cfg; 1522 - break; 1523 - } 1524 - default: 1525 - ret = -ENODEV; 1526 - } 1527 - break; 1528 - default: 1529 - ret = -EINVAL; 1530 - } 1531 - out_unlock: 1532 + if (smmu_domain->smmu) 1533 + ret = -EPERM; 1534 + else 1535 + smmu_domain->pgtbl_quirks = quirks; 1532 1536 mutex_unlock(&smmu_domain->init_mutex); 1537 + 1533 1538 return ret; 1534 1539 } 1535 1540 ··· 1570 1611 .probe_device = arm_smmu_probe_device, 1571 1612 .release_device = arm_smmu_release_device, 1572 1613 .device_group = arm_smmu_device_group, 1573 - .domain_get_attr = arm_smmu_domain_get_attr, 1574 - .domain_set_attr = arm_smmu_domain_set_attr, 1575 1614 .enable_nesting = arm_smmu_enable_nesting, 1615 + .set_pgtable_quirks = arm_smmu_set_pgtable_quirks, 1576 1616 .of_xlate = arm_smmu_of_xlate, 1577 1617 .get_resv_regions = arm_smmu_get_resv_regions, 1578 1618 .put_resv_regions = generic_iommu_put_resv_regions,
+1 -1
drivers/iommu/arm/arm-smmu/arm-smmu.h
··· 364 364 struct arm_smmu_domain { 365 365 struct arm_smmu_device *smmu; 366 366 struct io_pgtable_ops *pgtbl_ops; 367 - struct io_pgtable_domain_attr pgtbl_cfg; 367 + unsigned long pgtbl_quirks; 368 368 const struct iommu_flush_ops *flush_ops; 369 369 struct arm_smmu_cfg cfg; 370 370 enum arm_smmu_domain_stage stage;
+11
drivers/iommu/iommu.c
··· 2701 2701 } 2702 2702 EXPORT_SYMBOL_GPL(iommu_enable_nesting); 2703 2703 2704 + int iommu_set_pgtable_quirks(struct iommu_domain *domain, 2705 + unsigned long quirk) 2706 + { 2707 + if (domain->type != IOMMU_DOMAIN_UNMANAGED) 2708 + return -EINVAL; 2709 + if (!domain->ops->set_pgtable_quirks) 2710 + return -EINVAL; 2711 + return domain->ops->set_pgtable_quirks(domain, quirk); 2712 + } 2713 + EXPORT_SYMBOL_GPL(iommu_set_pgtable_quirks); 2714 + 2704 2715 void iommu_get_resv_regions(struct device *dev, struct list_head *list) 2705 2716 { 2706 2717 const struct iommu_ops *ops = dev->bus->iommu_ops;
-4
include/linux/io-pgtable.h
··· 204 204 205 205 #define io_pgtable_ops_to_pgtable(x) container_of((x), struct io_pgtable, ops) 206 206 207 - struct io_pgtable_domain_attr { 208 - unsigned long quirks; 209 - }; 210 - 211 207 static inline void io_pgtable_tlb_flush_all(struct io_pgtable *iop) 212 208 { 213 209 if (iop->cfg.tlb && iop->cfg.tlb->tlb_flush_all)
+11 -1
include/linux/iommu.h
··· 107 107 */ 108 108 109 109 enum iommu_attr { 110 - DOMAIN_ATTR_IO_PGTABLE_CFG, 111 110 DOMAIN_ATTR_MAX, 112 111 }; 113 112 ··· 208 209 * @domain_get_attr: Query domain attributes 209 210 * @domain_set_attr: Change domain attributes 210 211 * @enable_nesting: Enable nesting 212 + * @set_pgtable_quirks: Set io page table quirks (IO_PGTABLE_QUIRK_*) 211 213 * @get_resv_regions: Request list of reserved regions for a device 212 214 * @put_resv_regions: Free list of reserved regions for a device 213 215 * @apply_resv_region: Temporary helper call-back for iova reserved ranges ··· 262 262 int (*domain_set_attr)(struct iommu_domain *domain, 263 263 enum iommu_attr attr, void *data); 264 264 int (*enable_nesting)(struct iommu_domain *domain); 265 + int (*set_pgtable_quirks)(struct iommu_domain *domain, 266 + unsigned long quirks); 265 267 266 268 /* Request/Free a list of reserved regions for a device */ 267 269 void (*get_resv_regions)(struct device *dev, struct list_head *list); ··· 514 512 extern int iommu_domain_set_attr(struct iommu_domain *domain, enum iommu_attr, 515 513 void *data); 516 514 int iommu_enable_nesting(struct iommu_domain *domain); 515 + int iommu_set_pgtable_quirks(struct iommu_domain *domain, 516 + unsigned long quirks); 517 517 518 518 void iommu_set_dma_strict(bool val); 519 519 bool iommu_get_dma_strict(struct iommu_domain *domain); ··· 893 889 enum iommu_attr attr, void *data) 894 890 { 895 891 return -EINVAL; 892 + } 893 + 894 + static inline int iommu_set_pgtable_quirks(struct iommu_domain *domain, 895 + unsigned long quirks) 896 + { 897 + return 0; 896 898 } 897 899 898 900 static inline int iommu_device_register(struct iommu_device *iommu)