iommu/arm-smmu: Allow skipping context bank disable at reset time

On some SoCs some IOMMU context banks are actively used from TZ
during system boot, or some hypervisor configurations will trigger
a system reset upon disabling some protected/secured CBs.

Allow skipping the disablement of such contexts at IOMMU reset time
during initialization with a new implementation detail to work around
this quirk.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
This commit is contained in:
AngeloGioacchino Del Regno 2021-08-06 13:14:41 +02:00 committed by Jami Kettunen
parent 5d25ef59ae
commit 8058f9b46a
2 changed files with 11 additions and 0 deletions

View file

@ -1622,6 +1622,16 @@ static void arm_smmu_device_reset(struct arm_smmu_device *smmu)
/* Make sure all context banks are disabled and clear CB_FSR */
for (i = 0; i < smmu->num_context_banks; ++i) {
/*
* Some context banks cannot be disabled due to hypervisor
* configuration on some systems; if this is the case,
* skip disabling and writing FAULT on the CB FSR in order
* to avoid a system crash.
*/
if (smmu->impl && smmu->impl->reset_cb_nodisable &&
smmu->impl->reset_cb_nodisable(smmu, i)) {
continue;
}
arm_smmu_write_context_bank(smmu, i);
arm_smmu_cb_write(smmu, i, ARM_SMMU_CB_FSR, ARM_SMMU_FSR_FAULT);
}

View file

@ -430,6 +430,7 @@ struct arm_smmu_impl {
u64 val);
int (*cfg_probe)(struct arm_smmu_device *smmu);
int (*reset)(struct arm_smmu_device *smmu);
bool (*reset_cb_nodisable)(struct arm_smmu_device *smmu, int cbndx);
int (*init_context)(struct arm_smmu_domain *smmu_domain,
struct io_pgtable_cfg *cfg, struct device *dev);
void (*tlb_sync)(struct arm_smmu_device *smmu, int page, int sync,