From: Jean-Philippe Brucker jean-philippe@linaro.org
mainline inclusion from mainline-v6.11-rc1 commit 2f8d6178b4fe3e2f50782fa640921a9ee46b6d6f category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IB4WDJ CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
--------------------------------
If the SMMU supports it and the kernel was built with HTTU support, Probe support for Hardware Translation Table Update (HTTU) which is essentially to enable hardware update of access and dirty flags.
Probe and set the smmu::features for Hardware Dirty and Hardware Access bits. This is in preparation, to enable it on the context descriptors of stage 1 format.
Signed-off-by: Jean-Philippe Brucker jean-philippe@linaro.org Signed-off-by: Joao Martins joao.m.martins@oracle.com Reviewed-by: Jason Gunthorpe jgg@nvidia.com Reviewed-by: Ryan Roberts ryan.roberts@arm.com Reviewed-by: Kevin Tian kevin.tian@intel.com Reviewed-by: Nicolin Chen nicolinc@nvidia.com Signed-off-by: Shameer Kolothum shameerali.kolothum.thodi@huawei.com Link: https://lore.kernel.org/r/20240703101604.2576-3-shameerali.kolothum.thodi@hu... Signed-off-by: Will Deacon will@kernel.org Signed-off-by: Kunkun Jiang jiangkunkun@huawei.com --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 44 ++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-)
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 77044c0c2bfb..e1da05d3b26f 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -4852,28 +4852,6 @@ static void arm_smmu_device_iidr_probe(struct arm_smmu_device *smmu) #endif }
-static void arm_smmu_get_httu(struct arm_smmu_device *smmu, u32 reg) -{ - u32 fw_features = smmu->features & (ARM_SMMU_FEAT_HA | ARM_SMMU_FEAT_HD); - u32 features = 0; - - switch (FIELD_GET(IDR0_HTTU, reg)) { - case IDR0_HTTU_ACCESS_DIRTY: - features |= ARM_SMMU_FEAT_HD; - fallthrough; - case IDR0_HTTU_ACCESS: - features |= ARM_SMMU_FEAT_HA; - } - - if (smmu->dev->of_node) - smmu->features |= features; - else if (features != fw_features) - /* ACPI IORT sets the HTTU bits */ - dev_warn(smmu->dev, - "IDR0.HTTU overridden by FW configuration (0x%x)\n", - fw_features); -} - #ifdef CONFIG_HISILICON_ERRATUM_162100602 static void hisi_smmu_check_errata(struct arm_smmu_device *smmu) { @@ -4913,6 +4891,28 @@ static void hisi_smmu_check_errata(struct arm_smmu_device *smmu) static void hisi_smmu_check_errata(struct arm_smmu_device *smmu) {} #endif
+static void arm_smmu_get_httu(struct arm_smmu_device *smmu, u32 reg) +{ + u32 fw_features = smmu->features & (ARM_SMMU_FEAT_HA | ARM_SMMU_FEAT_HD); + u32 hw_features = 0; + + switch (FIELD_GET(IDR0_HTTU, reg)) { + case IDR0_HTTU_ACCESS_DIRTY: + hw_features |= ARM_SMMU_FEAT_HD; + fallthrough; + case IDR0_HTTU_ACCESS: + hw_features |= ARM_SMMU_FEAT_HA; + } + + if (smmu->dev->of_node) + smmu->features |= hw_features; + else if (hw_features != fw_features) + /* ACPI IORT sets the HTTU bits */ + dev_warn(smmu->dev, + "IDR0.HTTU features(0x%x) overridden by FW configuration (0x%x)\n", + hw_features, fw_features); +} + static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu) { u32 reg;