coresight: etm4x: Fix accesses to TRCCIDCTLR1
authorSuzuki K Poulose <suzuki.poulose@arm.com>
Fri, 27 Nov 2020 17:52:45 +0000 (10:52 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Nov 2020 19:23:12 +0000 (20:23 +0100)
The TRCCIDCTLR1 is only implemented if TRCIDR4.NUMCIDC > 4.
Don't touch the register if it is not implemented.

Cc: stable@vger.kernel.org
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20201127175256.1092685-5-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwtracing/coresight/coresight-etm4x-core.c

index e67365d..af0ab2f 100644 (file)
@@ -187,7 +187,8 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
                writeq_relaxed(config->ctxid_pid[i],
                               drvdata->base + TRCCIDCVRn(i));
        writel_relaxed(config->ctxid_mask0, drvdata->base + TRCCIDCCTLR0);
-       writel_relaxed(config->ctxid_mask1, drvdata->base + TRCCIDCCTLR1);
+       if (drvdata->numcidc > 4)
+               writel_relaxed(config->ctxid_mask1, drvdata->base + TRCCIDCCTLR1);
 
        for (i = 0; i < drvdata->numvmidc; i++)
                writeq_relaxed(config->vmid_val[i],
@@ -1241,7 +1242,8 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata)
                state->trcvmidcvr[i] = readq(drvdata->base + TRCVMIDCVRn(i));
 
        state->trccidcctlr0 = readl(drvdata->base + TRCCIDCCTLR0);
-       state->trccidcctlr1 = readl(drvdata->base + TRCCIDCCTLR1);
+       if (drvdata->numcidc > 4)
+               state->trccidcctlr1 = readl(drvdata->base + TRCCIDCCTLR1);
 
        state->trcvmidcctlr0 = readl(drvdata->base + TRCVMIDCCTLR0);
        if (drvdata->numvmidc > 4)
@@ -1352,7 +1354,8 @@ static void etm4_cpu_restore(struct etmv4_drvdata *drvdata)
                               drvdata->base + TRCVMIDCVRn(i));
 
        writel_relaxed(state->trccidcctlr0, drvdata->base + TRCCIDCCTLR0);
-       writel_relaxed(state->trccidcctlr1, drvdata->base + TRCCIDCCTLR1);
+       if (drvdata->numcidc > 4)
+               writel_relaxed(state->trccidcctlr1, drvdata->base + TRCCIDCCTLR1);
 
        writel_relaxed(state->trcvmidcctlr0, drvdata->base + TRCVMIDCCTLR0);
        if (drvdata->numvmidc > 4)