Skip to content

Commit 86d2d92

Browse files
rmurphy-armwilldeacon
authored andcommitted
iommu/arm-smmu-v3: Remove the page 1 fixup
Since we now keep track of page 1 via a separate pointer that already encapsulates aliasing to page 0 as necessary, we can remove the clunky fixup routine and simply use the relevant bases directly. The current architecture spec (IHI0070D.a) defines SMMU_{EVENTQ,PRIQ}_{PROD,CONS} as offsets relative to page 1, so the cleanup represents a little bit of convergence as well as just lines of code saved. Signed-off-by: Robin Murphy <[email protected]> Link: https://lore.kernel.org/r/08d9bda570bb5681f11a2f250a31be9ef763b8c5.1611238182.git.robin.murphy@arm.com Signed-off-by: Will Deacon <[email protected]>
1 parent d8498b1 commit 86d2d92

File tree

2 files changed

+20
-30
lines changed

2 files changed

+20
-30
lines changed

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

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,6 @@ static struct arm_smmu_option_prop arm_smmu_options[] = {
8888
{ 0, NULL},
8989
};
9090

91-
static inline void __iomem *arm_smmu_page1_fixup(unsigned long offset,
92-
struct arm_smmu_device *smmu)
93-
{
94-
if (offset > SZ_64K)
95-
return smmu->page1 + offset - SZ_64K;
96-
97-
return smmu->base + offset;
98-
}
99-
10091
static void parse_driver_options(struct arm_smmu_device *smmu)
10192
{
10293
int i = 0;
@@ -2611,6 +2602,7 @@ static struct iommu_ops arm_smmu_ops = {
26112602
/* Probing and initialisation functions */
26122603
static int arm_smmu_init_one_queue(struct arm_smmu_device *smmu,
26132604
struct arm_smmu_queue *q,
2605+
void __iomem *page,
26142606
unsigned long prod_off,
26152607
unsigned long cons_off,
26162608
size_t dwords, const char *name)
@@ -2639,8 +2631,8 @@ static int arm_smmu_init_one_queue(struct arm_smmu_device *smmu,
26392631
1 << q->llq.max_n_shift, name);
26402632
}
26412633

2642-
q->prod_reg = arm_smmu_page1_fixup(prod_off, smmu);
2643-
q->cons_reg = arm_smmu_page1_fixup(cons_off, smmu);
2634+
q->prod_reg = page + prod_off;
2635+
q->cons_reg = page + cons_off;
26442636
q->ent_dwords = dwords;
26452637

26462638
q->q_base = Q_BASE_RWA;
@@ -2684,9 +2676,9 @@ static int arm_smmu_init_queues(struct arm_smmu_device *smmu)
26842676
int ret;
26852677

26862678
/* cmdq */
2687-
ret = arm_smmu_init_one_queue(smmu, &smmu->cmdq.q, ARM_SMMU_CMDQ_PROD,
2688-
ARM_SMMU_CMDQ_CONS, CMDQ_ENT_DWORDS,
2689-
"cmdq");
2679+
ret = arm_smmu_init_one_queue(smmu, &smmu->cmdq.q, smmu->base,
2680+
ARM_SMMU_CMDQ_PROD, ARM_SMMU_CMDQ_CONS,
2681+
CMDQ_ENT_DWORDS, "cmdq");
26902682
if (ret)
26912683
return ret;
26922684

@@ -2695,19 +2687,19 @@ static int arm_smmu_init_queues(struct arm_smmu_device *smmu)
26952687
return ret;
26962688

26972689
/* evtq */
2698-
ret = arm_smmu_init_one_queue(smmu, &smmu->evtq.q, ARM_SMMU_EVTQ_PROD,
2699-
ARM_SMMU_EVTQ_CONS, EVTQ_ENT_DWORDS,
2700-
"evtq");
2690+
ret = arm_smmu_init_one_queue(smmu, &smmu->evtq.q, smmu->page1,
2691+
ARM_SMMU_EVTQ_PROD, ARM_SMMU_EVTQ_CONS,
2692+
EVTQ_ENT_DWORDS, "evtq");
27012693
if (ret)
27022694
return ret;
27032695

27042696
/* priq */
27052697
if (!(smmu->features & ARM_SMMU_FEAT_PRI))
27062698
return 0;
27072699

2708-
return arm_smmu_init_one_queue(smmu, &smmu->priq.q, ARM_SMMU_PRIQ_PROD,
2709-
ARM_SMMU_PRIQ_CONS, PRIQ_ENT_DWORDS,
2710-
"priq");
2700+
return arm_smmu_init_one_queue(smmu, &smmu->priq.q, smmu->page1,
2701+
ARM_SMMU_PRIQ_PROD, ARM_SMMU_PRIQ_CONS,
2702+
PRIQ_ENT_DWORDS, "priq");
27112703
}
27122704

27132705
static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu)
@@ -3099,10 +3091,8 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu, bool bypass)
30993091

31003092
/* Event queue */
31013093
writeq_relaxed(smmu->evtq.q.q_base, smmu->base + ARM_SMMU_EVTQ_BASE);
3102-
writel_relaxed(smmu->evtq.q.llq.prod,
3103-
arm_smmu_page1_fixup(ARM_SMMU_EVTQ_PROD, smmu));
3104-
writel_relaxed(smmu->evtq.q.llq.cons,
3105-
arm_smmu_page1_fixup(ARM_SMMU_EVTQ_CONS, smmu));
3094+
writel_relaxed(smmu->evtq.q.llq.prod, smmu->page1 + ARM_SMMU_EVTQ_PROD);
3095+
writel_relaxed(smmu->evtq.q.llq.cons, smmu->page1 + ARM_SMMU_EVTQ_CONS);
31063096

31073097
enables |= CR0_EVTQEN;
31083098
ret = arm_smmu_write_reg_sync(smmu, enables, ARM_SMMU_CR0,
@@ -3117,9 +3107,9 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu, bool bypass)
31173107
writeq_relaxed(smmu->priq.q.q_base,
31183108
smmu->base + ARM_SMMU_PRIQ_BASE);
31193109
writel_relaxed(smmu->priq.q.llq.prod,
3120-
arm_smmu_page1_fixup(ARM_SMMU_PRIQ_PROD, smmu));
3110+
smmu->page1 + ARM_SMMU_PRIQ_PROD);
31213111
writel_relaxed(smmu->priq.q.llq.cons,
3122-
arm_smmu_page1_fixup(ARM_SMMU_PRIQ_CONS, smmu));
3112+
smmu->page1 + ARM_SMMU_PRIQ_CONS);
31233113

31243114
enables |= CR0_PRIQEN;
31253115
ret = arm_smmu_write_reg_sync(smmu, enables, ARM_SMMU_CR0,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@
139139
#define ARM_SMMU_CMDQ_CONS 0x9c
140140

141141
#define ARM_SMMU_EVTQ_BASE 0xa0
142-
#define ARM_SMMU_EVTQ_PROD 0x100a8
143-
#define ARM_SMMU_EVTQ_CONS 0x100ac
142+
#define ARM_SMMU_EVTQ_PROD 0xa8
143+
#define ARM_SMMU_EVTQ_CONS 0xac
144144
#define ARM_SMMU_EVTQ_IRQ_CFG0 0xb0
145145
#define ARM_SMMU_EVTQ_IRQ_CFG1 0xb8
146146
#define ARM_SMMU_EVTQ_IRQ_CFG2 0xbc
147147

148148
#define ARM_SMMU_PRIQ_BASE 0xc0
149-
#define ARM_SMMU_PRIQ_PROD 0x100c8
150-
#define ARM_SMMU_PRIQ_CONS 0x100cc
149+
#define ARM_SMMU_PRIQ_PROD 0xc8
150+
#define ARM_SMMU_PRIQ_CONS 0xcc
151151
#define ARM_SMMU_PRIQ_IRQ_CFG0 0xd0
152152
#define ARM_SMMU_PRIQ_IRQ_CFG1 0xd8
153153
#define ARM_SMMU_PRIQ_IRQ_CFG2 0xdc

0 commit comments

Comments
 (0)