Skip to content

Commit e097633

Browse files
jgunthorpewilldeacon
authored andcommitted
iommu/arm-smmu: Pass arm_smmu_domain to internal functions
Keep the types consistent, all the callers of these functions already have obtained a struct arm_smmu_domain, don't needlessly go to/from an iommu_domain through the internal call chains. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/4-v2-c86cc8c2230e+160bb-smmu_newapi_jgg@nvidia.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent bbbf11e commit e097633

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,7 @@ static irqreturn_t arm_smmu_context_fault(int irq, void *dev)
409409
{
410410
u32 fsr, fsynr, cbfrsynra;
411411
unsigned long iova;
412-
struct iommu_domain *domain = dev;
413-
struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
412+
struct arm_smmu_domain *smmu_domain = dev;
414413
struct arm_smmu_device *smmu = smmu_domain->smmu;
415414
int idx = smmu_domain->cfg.cbndx;
416415
int ret;
@@ -423,7 +422,7 @@ static irqreturn_t arm_smmu_context_fault(int irq, void *dev)
423422
iova = arm_smmu_cb_readq(smmu, idx, ARM_SMMU_CB_FAR);
424423
cbfrsynra = arm_smmu_gr1_read(smmu, ARM_SMMU_GR1_CBFRSYNRA(idx));
425424

426-
ret = report_iommu_fault(domain, NULL, iova,
425+
ret = report_iommu_fault(&smmu_domain->domain, NULL, iova,
427426
fsynr & ARM_SMMU_FSYNR0_WNR ? IOMMU_FAULT_WRITE : IOMMU_FAULT_READ);
428427

429428
if (ret == -ENOSYS)
@@ -624,7 +623,7 @@ static int arm_smmu_alloc_context_bank(struct arm_smmu_domain *smmu_domain,
624623
return __arm_smmu_alloc_bitmap(smmu->context_map, start, smmu->num_context_banks);
625624
}
626625

627-
static int arm_smmu_init_domain_context(struct iommu_domain *domain,
626+
static int arm_smmu_init_domain_context(struct arm_smmu_domain *smmu_domain,
628627
struct arm_smmu_device *smmu,
629628
struct device *dev)
630629
{
@@ -633,7 +632,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
633632
struct io_pgtable_ops *pgtbl_ops;
634633
struct io_pgtable_cfg pgtbl_cfg;
635634
enum io_pgtable_fmt fmt;
636-
struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
635+
struct iommu_domain *domain = &smmu_domain->domain;
637636
struct arm_smmu_cfg *cfg = &smmu_domain->cfg;
638637
irqreturn_t (*context_fault)(int irq, void *dev);
639638

@@ -807,8 +806,8 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
807806
else
808807
context_fault = arm_smmu_context_fault;
809808

810-
ret = devm_request_irq(smmu->dev, irq, context_fault,
811-
IRQF_SHARED, "arm-smmu-context-fault", domain);
809+
ret = devm_request_irq(smmu->dev, irq, context_fault, IRQF_SHARED,
810+
"arm-smmu-context-fault", smmu_domain);
812811
if (ret < 0) {
813812
dev_err(smmu->dev, "failed to request context IRQ %d (%u)\n",
814813
cfg->irptndx, irq);
@@ -829,9 +828,8 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
829828
return ret;
830829
}
831830

832-
static void arm_smmu_destroy_domain_context(struct iommu_domain *domain)
831+
static void arm_smmu_destroy_domain_context(struct arm_smmu_domain *smmu_domain)
833832
{
834-
struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
835833
struct arm_smmu_device *smmu = smmu_domain->smmu;
836834
struct arm_smmu_cfg *cfg = &smmu_domain->cfg;
837835
int ret, irq;
@@ -852,7 +850,7 @@ static void arm_smmu_destroy_domain_context(struct iommu_domain *domain)
852850

853851
if (cfg->irptndx != ARM_SMMU_INVALID_IRPTNDX) {
854852
irq = smmu->irqs[cfg->irptndx];
855-
devm_free_irq(smmu->dev, irq, domain);
853+
devm_free_irq(smmu->dev, irq, smmu_domain);
856854
}
857855

858856
free_io_pgtable_ops(smmu_domain->pgtbl_ops);
@@ -892,7 +890,7 @@ static void arm_smmu_domain_free(struct iommu_domain *domain)
892890
* Free the domain resources. We assume that all devices have
893891
* already been detached.
894892
*/
895-
arm_smmu_destroy_domain_context(domain);
893+
arm_smmu_destroy_domain_context(smmu_domain);
896894
kfree(smmu_domain);
897895
}
898896

@@ -1142,7 +1140,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
11421140
return ret;
11431141

11441142
/* Ensure that the domain is finalised */
1145-
ret = arm_smmu_init_domain_context(domain, smmu, dev);
1143+
ret = arm_smmu_init_domain_context(smmu_domain, smmu, dev);
11461144
if (ret < 0)
11471145
goto rpm_put;
11481146

0 commit comments

Comments
 (0)