Skip to content

Commit 6ed3d08

Browse files
committed
Merge branch 'core' into next
* core: iommu/qcom: Fix pgsize_bitmap iommu/intel: Convert to msi_create_parent_irq_domain() helper iommu/amd: Convert to msi_create_parent_irq_domain() helper iommu: Remove ops->pgsize_bitmap iommu/msm: Remove ops->pgsize_bitmap iommu/qcom: Remove iommu_ops pgsize_bitmap iommu/mtk: Remove iommu_ops pgsize_bitmap iommu: Remove iommu_ops pgsize_bitmap from simple drivers iommu: Remove ops.pgsize_bitmap from drivers that don't use it iommu/arm-smmu: Remove iommu_ops pgsize_bitmap qiommu/arm-smmu-v3: Remove iommu_ops pgsize_bitmap
2 parents 86731a2 + ced24bf commit 6ed3d08

25 files changed

+64
-82
lines changed

drivers/iommu/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ source "drivers/iommu/riscv/Kconfig"
200200
config IRQ_REMAP
201201
bool "Support for Interrupt Remapping"
202202
depends on X86_64 && X86_IO_APIC && PCI_MSI && ACPI
203+
select IRQ_MSI_LIB
203204
help
204205
Supports Interrupt remapping for IO-APIC and MSI devices.
205206
To use x2apic mode in the CPU's which support x2APIC enhancements or

drivers/iommu/amd/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ config AMD_IOMMU
77
select PCI_ATS
88
select PCI_PRI
99
select PCI_PASID
10+
select IRQ_MSI_LIB
1011
select MMU_NOTIFIER
1112
select IOMMU_API
1213
select IOMMU_IOVA

drivers/iommu/amd/iommu.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/notifier.h>
2626
#include <linux/export.h>
2727
#include <linux/irq.h>
28+
#include <linux/irqchip/irq-msi-lib.h>
2829
#include <linux/msi.h>
2930
#include <linux/irqdomain.h>
3031
#include <linux/percpu.h>
@@ -3970,29 +3971,30 @@ static struct irq_chip amd_ir_chip = {
39703971

39713972
static const struct msi_parent_ops amdvi_msi_parent_ops = {
39723973
.supported_flags = X86_VECTOR_MSI_FLAGS_SUPPORTED | MSI_FLAG_MULTI_PCI_MSI,
3974+
.bus_select_token = DOMAIN_BUS_AMDVI,
3975+
.bus_select_mask = MATCH_PCI_MSI,
39733976
.prefix = "IR-",
39743977
.init_dev_msi_info = msi_parent_init_dev_msi_info,
39753978
};
39763979

39773980
int amd_iommu_create_irq_domain(struct amd_iommu *iommu)
39783981
{
3979-
struct fwnode_handle *fn;
3982+
struct irq_domain_info info = {
3983+
.fwnode = irq_domain_alloc_named_id_fwnode("AMD-IR", iommu->index),
3984+
.ops = &amd_ir_domain_ops,
3985+
.domain_flags = IRQ_DOMAIN_FLAG_ISOLATED_MSI,
3986+
.host_data = iommu,
3987+
.parent = arch_get_ir_parent_domain(),
3988+
};
39803989

3981-
fn = irq_domain_alloc_named_id_fwnode("AMD-IR", iommu->index);
3982-
if (!fn)
3990+
if (!info.fwnode)
39833991
return -ENOMEM;
3984-
iommu->ir_domain = irq_domain_create_hierarchy(arch_get_ir_parent_domain(), 0, 0,
3985-
fn, &amd_ir_domain_ops, iommu);
3992+
3993+
iommu->ir_domain = msi_create_parent_irq_domain(&info, &amdvi_msi_parent_ops);
39863994
if (!iommu->ir_domain) {
3987-
irq_domain_free_fwnode(fn);
3995+
irq_domain_free_fwnode(info.fwnode);
39883996
return -ENOMEM;
39893997
}
3990-
3991-
irq_domain_update_bus_token(iommu->ir_domain, DOMAIN_BUS_AMDVI);
3992-
iommu->ir_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT |
3993-
IRQ_DOMAIN_FLAG_ISOLATED_MSI;
3994-
iommu->ir_domain->msi_parent_ops = &amdvi_msi_parent_ops;
3995-
39963998
return 0;
39973999
}
39984000

drivers/iommu/apple-dart.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,6 @@ static const struct iommu_ops apple_dart_iommu_ops = {
991991
.of_xlate = apple_dart_of_xlate,
992992
.def_domain_type = apple_dart_def_domain_type,
993993
.get_resv_regions = apple_dart_get_resv_regions,
994-
.pgsize_bitmap = -1UL, /* Restricted during dart probe */
995994
.owner = THIS_MODULE,
996995
.default_domain_ops = &(const struct iommu_domain_ops) {
997996
.attach_dev = apple_dart_attach_dev_paging,

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module_param(disable_msipolling, bool, 0444);
3838
MODULE_PARM_DESC(disable_msipolling,
3939
"Disable MSI-based polling for CMD_SYNC completion.");
4040

41-
static struct iommu_ops arm_smmu_ops;
41+
static const struct iommu_ops arm_smmu_ops;
4242
static struct iommu_dirty_ops arm_smmu_dirty_ops;
4343

4444
enum arm_smmu_msi_index {
@@ -3674,7 +3674,7 @@ static int arm_smmu_def_domain_type(struct device *dev)
36743674
return 0;
36753675
}
36763676

3677-
static struct iommu_ops arm_smmu_ops = {
3677+
static const struct iommu_ops arm_smmu_ops = {
36783678
.identity_domain = &arm_smmu_identity_domain,
36793679
.blocked_domain = &arm_smmu_blocked_domain,
36803680
.capable = arm_smmu_capable,
@@ -3690,7 +3690,6 @@ static struct iommu_ops arm_smmu_ops = {
36903690
.def_domain_type = arm_smmu_def_domain_type,
36913691
.viommu_alloc = arm_vsmmu_alloc,
36923692
.user_pasid_table = 1,
3693-
.pgsize_bitmap = -1UL, /* Restricted during device attach */
36943693
.owner = THIS_MODULE,
36953694
.default_domain_ops = &(const struct iommu_domain_ops) {
36963695
.attach_dev = arm_smmu_attach_dev,
@@ -4504,11 +4503,6 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
45044503
smmu->oas = 48;
45054504
}
45064505

4507-
if (arm_smmu_ops.pgsize_bitmap == -1UL)
4508-
arm_smmu_ops.pgsize_bitmap = smmu->pgsize_bitmap;
4509-
else
4510-
arm_smmu_ops.pgsize_bitmap |= smmu->pgsize_bitmap;
4511-
45124506
/* Set the DMA mask for our table walker */
45134507
if (dma_set_mask_and_coherent(smmu->dev, DMA_BIT_MASK(smmu->oas)))
45144508
dev_warn(smmu->dev,

drivers/iommu/arm/arm-smmu/arm-smmu.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static struct arm_smmu_domain *to_smmu_domain(struct iommu_domain *dom)
109109
}
110110

111111
static struct platform_driver arm_smmu_driver;
112-
static struct iommu_ops arm_smmu_ops;
112+
static const struct iommu_ops arm_smmu_ops;
113113

114114
#ifdef CONFIG_ARM_SMMU_LEGACY_DT_BINDINGS
115115
static struct device_node *dev_get_dev_node(struct device *dev)
@@ -919,6 +919,8 @@ static void arm_smmu_destroy_domain_context(struct arm_smmu_domain *smmu_domain)
919919
static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev)
920920
{
921921
struct arm_smmu_domain *smmu_domain;
922+
struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev);
923+
struct arm_smmu_device *smmu = cfg->smmu;
922924

923925
/*
924926
* Allocate the domain and initialise some of its data structures.
@@ -931,6 +933,7 @@ static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev)
931933

932934
mutex_init(&smmu_domain->init_mutex);
933935
spin_lock_init(&smmu_domain->cb_lock);
936+
smmu_domain->domain.pgsize_bitmap = smmu->pgsize_bitmap;
934937

935938
return &smmu_domain->domain;
936939
}
@@ -1627,7 +1630,7 @@ static int arm_smmu_def_domain_type(struct device *dev)
16271630
return 0;
16281631
}
16291632

1630-
static struct iommu_ops arm_smmu_ops = {
1633+
static const struct iommu_ops arm_smmu_ops = {
16311634
.identity_domain = &arm_smmu_identity_domain,
16321635
.blocked_domain = &arm_smmu_blocked_domain,
16331636
.capable = arm_smmu_capable,
@@ -1639,7 +1642,6 @@ static struct iommu_ops arm_smmu_ops = {
16391642
.of_xlate = arm_smmu_of_xlate,
16401643
.get_resv_regions = arm_smmu_get_resv_regions,
16411644
.def_domain_type = arm_smmu_def_domain_type,
1642-
.pgsize_bitmap = -1UL, /* Restricted during device attach */
16431645
.owner = THIS_MODULE,
16441646
.default_domain_ops = &(const struct iommu_domain_ops) {
16451647
.attach_dev = arm_smmu_attach_dev,
@@ -1919,10 +1921,6 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
19191921
if (smmu->features & ARM_SMMU_FEAT_FMT_AARCH64_64K)
19201922
smmu->pgsize_bitmap |= SZ_64K | SZ_512M;
19211923

1922-
if (arm_smmu_ops.pgsize_bitmap == -1UL)
1923-
arm_smmu_ops.pgsize_bitmap = smmu->pgsize_bitmap;
1924-
else
1925-
arm_smmu_ops.pgsize_bitmap |= smmu->pgsize_bitmap;
19261924
dev_notice(smmu->dev, "\tSupported page sizes: 0x%08lx\n",
19271925
smmu->pgsize_bitmap);
19281926

drivers/iommu/arm/arm-smmu/qcom_iommu.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static int qcom_iommu_init_domain(struct iommu_domain *domain,
229229
goto out_unlock;
230230

231231
pgtbl_cfg = (struct io_pgtable_cfg) {
232-
.pgsize_bitmap = qcom_iommu_ops.pgsize_bitmap,
232+
.pgsize_bitmap = domain->pgsize_bitmap,
233233
.ias = 32,
234234
.oas = 40,
235235
.tlb = &qcom_flush_ops,
@@ -246,8 +246,6 @@ static int qcom_iommu_init_domain(struct iommu_domain *domain,
246246
goto out_clear_iommu;
247247
}
248248

249-
/* Update the domain's page sizes to reflect the page table format */
250-
domain->pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
251249
domain->geometry.aperture_end = (1ULL << pgtbl_cfg.ias) - 1;
252250
domain->geometry.force_aperture = true;
253251

@@ -337,6 +335,7 @@ static struct iommu_domain *qcom_iommu_domain_alloc_paging(struct device *dev)
337335

338336
mutex_init(&qcom_domain->init_mutex);
339337
spin_lock_init(&qcom_domain->pgtbl_lock);
338+
qcom_domain->domain.pgsize_bitmap = SZ_4K;
340339

341340
return &qcom_domain->domain;
342341
}
@@ -598,7 +597,6 @@ static const struct iommu_ops qcom_iommu_ops = {
598597
.probe_device = qcom_iommu_probe_device,
599598
.device_group = generic_device_group,
600599
.of_xlate = qcom_iommu_of_xlate,
601-
.pgsize_bitmap = SZ_4K | SZ_64K | SZ_1M | SZ_16M,
602600
.default_domain_ops = &(const struct iommu_domain_ops) {
603601
.attach_dev = qcom_iommu_attach_dev,
604602
.map_pages = qcom_iommu_map,

drivers/iommu/exynos-iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,8 @@ static struct iommu_domain *exynos_iommu_domain_alloc_paging(struct device *dev)
925925
spin_lock_init(&domain->pgtablelock);
926926
INIT_LIST_HEAD(&domain->clients);
927927

928+
domain->domain.pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE;
929+
928930
domain->domain.geometry.aperture_start = 0;
929931
domain->domain.geometry.aperture_end = ~0UL;
930932
domain->domain.geometry.force_aperture = true;
@@ -1477,7 +1479,6 @@ static const struct iommu_ops exynos_iommu_ops = {
14771479
.device_group = generic_device_group,
14781480
.probe_device = exynos_iommu_probe_device,
14791481
.release_device = exynos_iommu_release_device,
1480-
.pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE,
14811482
.of_xlate = exynos_iommu_of_xlate,
14821483
.default_domain_ops = &(const struct iommu_domain_ops) {
14831484
.attach_dev = exynos_iommu_attach_device,

drivers/iommu/intel/iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4365,7 +4365,6 @@ const struct iommu_ops intel_iommu_ops = {
43654365
.device_group = intel_iommu_device_group,
43664366
.is_attach_deferred = intel_iommu_is_attach_deferred,
43674367
.def_domain_type = device_def_domain_type,
4368-
.pgsize_bitmap = SZ_4K,
43694368
.page_response = intel_iommu_page_response,
43704369
.default_domain_ops = &(const struct iommu_domain_ops) {
43714370
.attach_dev = intel_iommu_attach_device,

drivers/iommu/intel/irq_remapping.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/hpet.h>
1111
#include <linux/pci.h>
1212
#include <linux/irq.h>
13+
#include <linux/irqchip/irq-msi-lib.h>
1314
#include <linux/acpi.h>
1415
#include <linux/irqdomain.h>
1516
#include <linux/crash_dump.h>
@@ -518,8 +519,14 @@ static void iommu_enable_irq_remapping(struct intel_iommu *iommu)
518519

519520
static int intel_setup_irq_remapping(struct intel_iommu *iommu)
520521
{
522+
struct irq_domain_info info = {
523+
.ops = &intel_ir_domain_ops,
524+
.parent = arch_get_ir_parent_domain(),
525+
.domain_flags = IRQ_DOMAIN_FLAG_ISOLATED_MSI,
526+
.size = INTR_REMAP_TABLE_ENTRIES,
527+
.host_data = iommu,
528+
};
521529
struct ir_table *ir_table;
522-
struct fwnode_handle *fn;
523530
unsigned long *bitmap;
524531
void *ir_table_base;
525532

@@ -544,25 +551,16 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
544551
goto out_free_pages;
545552
}
546553

547-
fn = irq_domain_alloc_named_id_fwnode("INTEL-IR", iommu->seq_id);
548-
if (!fn)
554+
info.fwnode = irq_domain_alloc_named_id_fwnode("INTEL-IR", iommu->seq_id);
555+
if (!info.fwnode)
549556
goto out_free_bitmap;
550557

551-
iommu->ir_domain =
552-
irq_domain_create_hierarchy(arch_get_ir_parent_domain(),
553-
0, INTR_REMAP_TABLE_ENTRIES,
554-
fn, &intel_ir_domain_ops,
555-
iommu);
558+
iommu->ir_domain = msi_create_parent_irq_domain(&info, &dmar_msi_parent_ops);
556559
if (!iommu->ir_domain) {
557560
pr_err("IR%d: failed to allocate irqdomain\n", iommu->seq_id);
558561
goto out_free_fwnode;
559562
}
560563

561-
irq_domain_update_bus_token(iommu->ir_domain, DOMAIN_BUS_DMAR);
562-
iommu->ir_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT |
563-
IRQ_DOMAIN_FLAG_ISOLATED_MSI;
564-
iommu->ir_domain->msi_parent_ops = &dmar_msi_parent_ops;
565-
566564
ir_table->base = ir_table_base;
567565
ir_table->bitmap = bitmap;
568566
iommu->ir_table = ir_table;
@@ -608,7 +606,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
608606
irq_domain_remove(iommu->ir_domain);
609607
iommu->ir_domain = NULL;
610608
out_free_fwnode:
611-
irq_domain_free_fwnode(fn);
609+
irq_domain_free_fwnode(info.fwnode);
612610
out_free_bitmap:
613611
bitmap_free(bitmap);
614612
out_free_pages:
@@ -1530,6 +1528,8 @@ static const struct irq_domain_ops intel_ir_domain_ops = {
15301528

15311529
static const struct msi_parent_ops dmar_msi_parent_ops = {
15321530
.supported_flags = X86_VECTOR_MSI_FLAGS_SUPPORTED | MSI_FLAG_MULTI_PCI_MSI,
1531+
.bus_select_token = DOMAIN_BUS_DMAR,
1532+
.bus_select_mask = MATCH_PCI_MSI,
15331533
.prefix = "IR-",
15341534
.init_dev_msi_info = msi_parent_init_dev_msi_info,
15351535
};

0 commit comments

Comments
 (0)