From 729f55b35d09100fa017f3a7c7937f421faac73c Mon Sep 17 00:00:00 2001 From: John Stultz Date: Wed, 2 Jun 2021 01:34:57 +0000 Subject: [PATCH] Revert "ANDROID: iommu/arm-smmu: Allow inherting stream mapping from bootloader" This reverts Change-Id: Ibb3784360a4424f7dc7c64a241811642aa0de7f4 (commit 7e24cc89a14d in android-mainline-tracking). Recently, the commit 792c2bf3a5dd ("FROMGIT: iommu/arm-smmu: Don't bypass pinned stream mappings") was reverted from android-mainline, due to alternative solutions eventually landing upstream. However, that change resolved an issue with another patch that ended up getting an alternative solution. So reverting it broke the db845c from booting. Thus this patch reverts the prior patch as well, so that we are aligned with upstream and properly boot. Cc: Todd Kjos Cc: Lee Jones Cc: Bjorn Andersson Fixes: 5b9e3e32e0d87 ("Revert "FROMGIT: iommu/arm-smmu: Don't bypass pinned stream mappings"") Signed-off-by: John Stultz Change-Id: I5316d492f22ac797fba6748dd47e4d475e372c86 --- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 39 ---------------------- drivers/iommu/arm/arm-smmu/arm-smmu.c | 9 +---- drivers/iommu/arm/arm-smmu/arm-smmu.h | 2 +- 3 files changed, 2 insertions(+), 48 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c index 6486a7cd43f3..98b3a1c2a181 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c @@ -3,7 +3,6 @@ * Copyright (c) 2019, The Linux Foundation. All rights reserved. */ -#include #include #include #include @@ -16,43 +15,6 @@ struct qcom_smmu { u8 bypass_cbndx; }; -static int qcom_sdm845_smmu500_cfg_probe(struct arm_smmu_device *smmu) -{ - u32 s2cr; - u32 smr; - int i; - - for (i = 0; i < smmu->num_mapping_groups; i++) { - smr = arm_smmu_gr0_read(smmu, ARM_SMMU_GR0_SMR(i)); - s2cr = arm_smmu_gr0_read(smmu, ARM_SMMU_GR0_S2CR(i)); - - smmu->smrs[i].mask = FIELD_GET(ARM_SMMU_SMR_MASK, smr); - smmu->smrs[i].id = FIELD_GET(ARM_SMMU_SMR_ID, smr); - if (smmu->features & ARM_SMMU_FEAT_EXIDS) - smmu->smrs[i].valid = FIELD_GET( - ARM_SMMU_S2CR_EXIDVALID, - s2cr); - else - smmu->smrs[i].valid = FIELD_GET( - ARM_SMMU_SMR_VALID, - smr); - - smmu->s2crs[i].group = NULL; - smmu->s2crs[i].count = 0; - smmu->s2crs[i].type = FIELD_GET(ARM_SMMU_S2CR_TYPE, s2cr); - smmu->s2crs[i].privcfg = FIELD_GET(ARM_SMMU_S2CR_PRIVCFG, s2cr); - smmu->s2crs[i].cbndx = FIELD_GET(ARM_SMMU_S2CR_CBNDX, s2cr); - - if (!smmu->smrs[i].valid) - continue; - - smmu->s2crs[i].pinned = true; - bitmap_set(smmu->context_map, smmu->s2crs[i].cbndx, 1); - } - - return 0; -} - static struct qcom_smmu *to_qcom_smmu(struct arm_smmu_device *smmu) { return container_of(smmu, struct qcom_smmu, smmu); @@ -335,7 +297,6 @@ static int qcom_smmu500_reset(struct arm_smmu_device *smmu) static const struct arm_smmu_impl qcom_smmu_impl = { .cfg_probe = qcom_smmu_cfg_probe, .def_domain_type = qcom_smmu_def_domain_type, - .cfg_probe = qcom_sdm845_smmu500_cfg_probe, .reset = qcom_smmu500_reset, .write_s2cr = qcom_smmu_write_s2cr, }; diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index 131f3996ac66..6f72c4d208ca 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -1024,19 +1024,12 @@ static int arm_smmu_find_sme(struct arm_smmu_device *smmu, u16 id, u16 mask) static bool arm_smmu_free_sme(struct arm_smmu_device *smmu, int idx) { - bool pinned = smmu->s2crs[idx].pinned; - u8 cbndx = smmu->s2crs[idx].cbndx; - if (--smmu->s2crs[idx].count) return false; smmu->s2crs[idx] = s2cr_init_val; - if (pinned) { - smmu->s2crs[idx].pinned = true; - smmu->s2crs[idx].cbndx = cbndx; - } else if (smmu->smrs) { + if (smmu->smrs) smmu->smrs[idx].valid = false; - } return true; } diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h index fc6d2b4d8c14..c31a59d35c64 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h @@ -263,13 +263,13 @@ struct arm_smmu_s2cr { enum arm_smmu_s2cr_type type; enum arm_smmu_s2cr_privcfg privcfg; u8 cbndx; - bool pinned; }; struct arm_smmu_smr { u16 mask; u16 id; bool valid; + bool pinned; }; struct arm_smmu_device {