maillist inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/10362 ------------------ Disabling BTM by configuring IDR0 requires a cold reset. Offer a CONFIG_SMMU_DISABLE_BTM option and a disable_btm module parameter to turn BTM off softly at probe time. Signed-off-by: Wang Wensheng <wangwensheng4@huawei.com> Signed-off-by: Zhang Yuwei <zhangyuwei20@huawei.com> --- arch/arm64/configs/openeuler_defconfig | 1 + drivers/iommu/Kconfig | 7 +++++++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index da76ac4f7881..54895a54e4fd 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -6753,6 +6753,7 @@ CONFIG_ARM_SMMU_V3_IOMMUFD=y # CONFIG_QCOM_IOMMU is not set # CONFIG_VIRTIO_IOMMU is not set CONFIG_SMMU_BYPASS_DEV=y +# CONFIG_SMMU_DISABLE_BTM is not set # # Remoteproc drivers diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index f91ab5cba204..876a8f39e93b 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -568,4 +568,11 @@ config LOONGARCH_IOMMU can isolate the DMA memory of different devices and protect the system from misbehaving device drivers or hardware. +config SMMU_DISABLE_BTM + bool "disable BTM" + depends on ARM_SMMU_V3=y + help + Disabling BTM by configuring IDR0 requires a cold reset. + Provide a module parameter to disable BTM softly. + endif # IOMMU_SUPPORT diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index c82fe5c948f3..8daa1be222d0 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -42,6 +42,12 @@ #include <asm/hisi_cca_da.h> #endif +static bool disable_btm; +#ifdef CONFIG_SMMU_DISABLE_BTM +module_param(disable_btm, bool, 0444); +MODULE_PARM_DESC(disable_btm, "Disable BTM"); +#endif + static bool disable_msipolling; module_param(disable_msipolling, bool, 0444); MODULE_PARM_DESC(disable_msipolling, @@ -5345,7 +5351,7 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu) * broadcasted TLB invalidations that target EL2-E2H world. Don't enable * BTM in that case. */ - if (reg & IDR0_BTM && (!vhe || reg & IDR0_HYP)) + if (reg & IDR0_BTM && (!vhe || reg & IDR0_HYP) && !disable_btm) smmu->features |= ARM_SMMU_FEAT_BTM; /* -- 2.22.0