Skip to content

Commit 1d599fe

Browse files
robclarkaustriancoder
authored andcommitted
iommu/arm-smmu: Add a way for implementations to influence SCTLR
For the Adreno GPU's SMMU, we want SCTLR.HUPCF set to ensure that pending translations are not terminated on iova fault. Otherwise a terminated CP read could hang the GPU by returning invalid command-stream data. Signed-off-by: Rob Clark <robdclark@chromium.org> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
1 parent 723c06e commit 1d599fe

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ static int qcom_adreno_smmu_init_context(struct arm_smmu_domain *smmu_domain,
127127
(smmu_domain->cfg.fmt == ARM_SMMU_CTX_FMT_AARCH64))
128128
pgtbl_cfg->quirks |= IO_PGTABLE_QUIRK_ARM_TTBR1;
129129

130+
/*
131+
* On the GPU device we want to process subsequent transactions after a
132+
* fault to keep the GPU from hanging
133+
*/
134+
smmu_domain->cfg.sctlr_set |= ARM_SMMU_SCTLR_HUPCF;
135+
130136
/*
131137
* Initialize private interface with GPU:
132138
*/

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,9 @@ void arm_smmu_write_context_bank(struct arm_smmu_device *smmu, int idx)
617617
if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
618618
reg |= ARM_SMMU_SCTLR_E;
619619

620+
reg |= cfg->sctlr_set;
621+
reg &= ~cfg->sctlr_clr;
622+
620623
arm_smmu_cb_write(smmu, idx, ARM_SMMU_CB_SCTLR, reg);
621624
}
622625

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ enum arm_smmu_cbar_type {
144144
#define ARM_SMMU_CB_SCTLR 0x0
145145
#define ARM_SMMU_SCTLR_S1_ASIDPNE BIT(12)
146146
#define ARM_SMMU_SCTLR_CFCFG BIT(7)
147+
#define ARM_SMMU_SCTLR_HUPCF BIT(8)
147148
#define ARM_SMMU_SCTLR_CFIE BIT(6)
148149
#define ARM_SMMU_SCTLR_CFRE BIT(5)
149150
#define ARM_SMMU_SCTLR_E BIT(4)
@@ -341,6 +342,8 @@ struct arm_smmu_cfg {
341342
u16 asid;
342343
u16 vmid;
343344
};
345+
u32 sctlr_set; /* extra bits to set in SCTLR */
346+
u32 sctlr_clr; /* bits to mask in SCTLR */
344347
enum arm_smmu_cbar_type cbar;
345348
enum arm_smmu_context_fmt fmt;
346349
};

0 commit comments

Comments
 (0)