From: Jan Kiszka <[email protected]>

Use GET_FIELD where possible, drop pointless clearing of ID0_S1TS and
ID0_NTS.

Signed-off-by: Jan Kiszka <[email protected]>
---
 hypervisor/arch/arm64/smmu.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/hypervisor/arch/arm64/smmu.c b/hypervisor/arch/arm64/smmu.c
index 0fa48588..5073c705 100644
--- a/hypervisor/arch/arm64/smmu.c
+++ b/hypervisor/arch/arm64/smmu.c
@@ -47,21 +47,15 @@
 
 /* Identification registers */
 #define ARM_SMMU_GR0_ID0               0x20
-#define ARM_SMMU_GR0_ID1               0x24
-#define ARM_SMMU_GR0_ID2               0x28
-#define ARM_SMMU_GR0_ID7               0x3c
-#define ID0_S1TS                       (1 << 30)
 #define ID0_S2TS                       (1 << 29)
-#define ID0_NTS                                (1 << 28)
 #define ID0_SMS                                (1 << 27)
-#define ID0_PTFS_NO_AARCH32            (1 << 25)
-#define ID0_PTFS_NO_AARCH32S           (1 << 24)
 #define ID0_CTTW                       (1 << 14)
-#define ID0_NUMSIDB_SHIFT              9
-#define ID0_NUMSIDB_MASK               0xf
-#define ID0_EXIDS                      (1 << 8)
-#define ID0_NUMSMRG_SHIFT              0
-#define ID0_NUMSMRG_MASK               0xff
+#define ID0_NUMSIDB(id)                        GET_FIELD(id, 12, 9)
+#define ID0_NUMSMRG(id)                        GET_FIELD(id, 7, 0)
+
+#define ARM_SMMU_GR0_ID1               0x24
+#define ARM_SMMU_GR0_ID2               0x28
+#define ARM_SMMU_GR0_ID7               0x3c
 
 #define ID1_PAGESIZE                   (1 << 31)
 #define ID1_NUMPAGENDXB_SHIFT          28
@@ -396,16 +390,13 @@ static int arm_smmu_device_cfg_probe(struct 
arm_smmu_device *smmu)
        /* ID0 */
        id = mmio_read32(gr0_base + ARM_SMMU_GR0_ID0);
 
-       /* Only stage 2 translation is supported */
-       id &= ~(ID0_S1TS | ID0_NTS);
-
        if (!(id & ID0_S2TS))
                return trace_error(-EIO);
 
-       size = 1 << ((id >> ID0_NUMSIDB_SHIFT) & ID0_NUMSIDB_MASK);
+       size = 1 << ID0_NUMSIDB(id);
 
        if (id & ID0_SMS) {
-               size = (id >> ID0_NUMSMRG_SHIFT) & ID0_NUMSMRG_MASK;
+               size = ID0_NUMSMRG(id);
                if (size == 0)
                        return trace_error(-ENODEV);
 
-- 
2.26.2

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/efb57a396e9242c0e73be207e48cea4d8e3190c6.1601838005.git.jan.kiszka%40siemens.com.

Reply via email to