Skip to content

Commit 2f8d617

Browse files
jpbruckerwilldeacon
authored andcommitted
iommu/arm-smmu-v3: Add feature detection for HTTU
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 <[email protected]> Signed-off-by: Joao Martins <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Ryan Roberts <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Reviewed-by: Nicolin Chen <[email protected]> Signed-off-by: Shameer Kolothum <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 52acd7d commit 2f8d617

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4014,6 +4014,28 @@ static void arm_smmu_device_iidr_probe(struct arm_smmu_device *smmu)
40144014
}
40154015
}
40164016

4017+
static void arm_smmu_get_httu(struct arm_smmu_device *smmu, u32 reg)
4018+
{
4019+
u32 fw_features = smmu->features & (ARM_SMMU_FEAT_HA | ARM_SMMU_FEAT_HD);
4020+
u32 hw_features = 0;
4021+
4022+
switch (FIELD_GET(IDR0_HTTU, reg)) {
4023+
case IDR0_HTTU_ACCESS_DIRTY:
4024+
hw_features |= ARM_SMMU_FEAT_HD;
4025+
fallthrough;
4026+
case IDR0_HTTU_ACCESS:
4027+
hw_features |= ARM_SMMU_FEAT_HA;
4028+
}
4029+
4030+
if (smmu->dev->of_node)
4031+
smmu->features |= hw_features;
4032+
else if (hw_features != fw_features)
4033+
/* ACPI IORT sets the HTTU bits */
4034+
dev_warn(smmu->dev,
4035+
"IDR0.HTTU features(0x%x) overridden by FW configuration (0x%x)\n",
4036+
hw_features, fw_features);
4037+
}
4038+
40174039
static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
40184040
{
40194041
u32 reg;
@@ -4074,6 +4096,8 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
40744096
smmu->features |= ARM_SMMU_FEAT_E2H;
40754097
}
40764098

4099+
arm_smmu_get_httu(smmu, reg);
4100+
40774101
/*
40784102
* The coherency feature as set by FW is used in preference to the ID
40794103
* register, but warn on mismatch.
@@ -4269,6 +4293,14 @@ static int arm_smmu_device_acpi_probe(struct platform_device *pdev,
42694293
if (iort_smmu->flags & ACPI_IORT_SMMU_V3_COHACC_OVERRIDE)
42704294
smmu->features |= ARM_SMMU_FEAT_COHERENCY;
42714295

4296+
switch (FIELD_GET(ACPI_IORT_SMMU_V3_HTTU_OVERRIDE, iort_smmu->flags)) {
4297+
case IDR0_HTTU_ACCESS_DIRTY:
4298+
smmu->features |= ARM_SMMU_FEAT_HD;
4299+
fallthrough;
4300+
case IDR0_HTTU_ACCESS:
4301+
smmu->features |= ARM_SMMU_FEAT_HA;
4302+
}
4303+
42724304
return 0;
42734305
}
42744306
#else

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
#define IDR0_ASID16 (1 << 12)
3434
#define IDR0_ATS (1 << 10)
3535
#define IDR0_HYP (1 << 9)
36+
#define IDR0_HTTU GENMASK(7, 6)
37+
#define IDR0_HTTU_ACCESS 1
38+
#define IDR0_HTTU_ACCESS_DIRTY 2
3639
#define IDR0_COHACC (1 << 4)
3740
#define IDR0_TTF GENMASK(3, 2)
3841
#define IDR0_TTF_AARCH64 2
@@ -650,6 +653,8 @@ struct arm_smmu_device {
650653
#define ARM_SMMU_FEAT_E2H (1 << 18)
651654
#define ARM_SMMU_FEAT_NESTING (1 << 19)
652655
#define ARM_SMMU_FEAT_ATTR_TYPES_OVR (1 << 20)
656+
#define ARM_SMMU_FEAT_HA (1 << 21)
657+
#define ARM_SMMU_FEAT_HD (1 << 22)
653658
u32 features;
654659

655660
#define ARM_SMMU_OPT_SKIP_PREFETCH (1 << 0)

0 commit comments

Comments
 (0)