Skip to contentSkip to conversation

coresight: etm4x: Fix accesses to TRCSEQRSTEVR and TRCSEQSTR

PATCH Superseded Junhao He 4 participants 6 messages Jan 10, 2023 – Jan 14, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Junhao He

author
#0 lore raw

PATCH 1/1 coresight: etm4x: Fix accesses to TRCSEQRSTEVR and TRCSEQSTR

The TRCSEQRSTEVR and TRCSEQSTR register is not implemented if the TRCIDR5.NUMSEQSTATE == 0. Skip accessing the register in such cases.

---
 .../hwtracing/coresight/coresight-etm4x-core.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +12 -6
index 80fefaba58ee..c7a65d1524fc 100644
@@ -424,8 +424,10 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
 		etm4x_relaxed_write32(csa, config->vipcssctlr, TRCVIPCSSCTLR);
 	for (i = 0; i < drvdata->nrseqstate - 1; i++)
 		etm4x_relaxed_write32(csa, config->seq_ctrl[i], TRCSEQEVRn(i));
-	etm4x_relaxed_write32(csa, config->seq_rst, TRCSEQRSTEVR);
-	etm4x_relaxed_write32(csa, config->seq_state, TRCSEQSTR);
+	if (drvdata->nrseqstate) {
+		etm4x_relaxed_write32(csa, config->seq_rst, TRCSEQRSTEVR);
+		etm4x_relaxed_write32(csa, config->seq_state, TRCSEQSTR);
+	}
 	etm4x_relaxed_write32(csa, config->ext_inp, TRCEXTINSELR);
 	for (i = 0; i < drvdata->nr_cntr; i++) {
 		etm4x_relaxed_write32(csa, config->cntrldvr[i], TRCCNTRLDVRn(i));
@@ -1631,8 +1633,10 @@ static int __etm4_cpu_save(struct etmv4_drvdata *drvdata)
 	for (i = 0; i < drvdata->nrseqstate - 1; i++)
 		state->trcseqevr[i] = etm4x_read32(csa, TRCSEQEVRn(i));
 
-	state->trcseqrstevr = etm4x_read32(csa, TRCSEQRSTEVR);
-	state->trcseqstr = etm4x_read32(csa, TRCSEQSTR);
+	if (drvdata->nrseqstate) {
+		state->trcseqrstevr = etm4x_read32(csa, TRCSEQRSTEVR);
+		state->trcseqstr = etm4x_read32(csa, TRCSEQSTR);
+	}
 	state->trcextinselr = etm4x_read32(csa, TRCEXTINSELR);
 
 	for (i = 0; i < drvdata->nr_cntr; i++) {
@@ -1760,8 +1764,10 @@ static void __etm4_cpu_restore(struct etmv4_drvdata *drvdata)
 	for (i = 0; i < drvdata->nrseqstate - 1; i++)
 		etm4x_relaxed_write32(csa, state->trcseqevr[i], TRCSEQEVRn(i));
 
-	etm4x_relaxed_write32(csa, state->trcseqrstevr, TRCSEQRSTEVR);
-	etm4x_relaxed_write32(csa, state->trcseqstr, TRCSEQSTR);
+	if (drvdata->nrseqstate) {
+		etm4x_relaxed_write32(csa, state->trcseqrstevr, TRCSEQRSTEVR);
+		etm4x_relaxed_write32(csa, state->trcseqstr, TRCSEQSTR);
+	}
 	etm4x_relaxed_write32(csa, state->trcextinselr, TRCEXTINSELR);
 
 	for (i = 0; i < drvdata->nr_cntr; i++) {
Signature · 7 lines
2.33.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 55 lines · Junhao He

The TRCSEQRSTEVR and TRCSEQSTR register is not implemented if the TRCIDR5.NUMSEQSTATE == 0. Skip accessing the register in such cases.

---
 .../hwtracing/coresight/coresight-etm4x-core.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +12 -7
index 80fefaba58ee..c7a65d1524fc 100644
@@ -424,8 +424,10 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
                etm4x_relaxed_write32(csa, config->vipcssctlr, TRCVIPCSSCTLR);
        for (i = 0; i < drvdata->nrseqstate - 1; i++)
                etm4x_relaxed_write32(csa, config->seq_ctrl[i], TRCSEQEVRn(i));
-       etm4x_relaxed_write32(csa, config->seq_rst, TRCSEQRSTEVR);
-       etm4x_relaxed_write32(csa, config->seq_state, TRCSEQSTR);
+       if (drvdata->nrseqstate) {
+               etm4x_relaxed_write32(csa, config->seq_rst, TRCSEQRSTEVR);
+               etm4x_relaxed_write32(csa, config->seq_state, TRCSEQSTR);
+       }
        etm4x_relaxed_write32(csa, config->ext_inp, TRCEXTINSELR);
        for (i = 0; i < drvdata->nr_cntr; i++) {
                etm4x_relaxed_write32(csa, config->cntrldvr[i], TRCCNTRLDVRn(i));
@@ -1631,8 +1633,10 @@ static int __etm4_cpu_save(struct etmv4_drvdata *drvdata)
        for (i = 0; i < drvdata->nrseqstate - 1; i++)
                state->trcseqevr[i] = etm4x_read32(csa, TRCSEQEVRn(i));
 
-       state->trcseqrstevr = etm4x_read32(csa, TRCSEQRSTEVR);
-       state->trcseqstr = etm4x_read32(csa, TRCSEQSTR);
+       if (drvdata->nrseqstate) {
+               state->trcseqrstevr = etm4x_read32(csa, TRCSEQRSTEVR);
+               state->trcseqstr = etm4x_read32(csa, TRCSEQSTR);
+       }
        state->trcextinselr = etm4x_read32(csa, TRCEXTINSELR);
 
        for (i = 0; i < drvdata->nr_cntr; i++) {
@@ -1760,8 +1764,10 @@ static void __etm4_cpu_restore(struct etmv4_drvdata *drvdata)
        for (i = 0; i < drvdata->nrseqstate - 1; i++)
                etm4x_relaxed_write32(csa, state->trcseqevr[i], TRCSEQEVRn(i));
 
-       etm4x_relaxed_write32(csa, state->trcseqrstevr, TRCSEQRSTEVR);
-       etm4x_relaxed_write32(csa, state->trcseqstr, TRCSEQSTR);
+       if (drvdata->nrseqstate) {
+               etm4x_relaxed_write32(csa, state->trcseqrstevr, TRCSEQRSTEVR);
+               etm4x_relaxed_write32(csa, state->trcseqstr, TRCSEQSTR);
+       }
        etm4x_relaxed_write32(csa, state->trcextinselr, TRCEXTINSELR);
 
        for (i = 0; i < drvdata->nr_cntr; i++) {
--

2.33.0

Quoted 3 lines

_______________________________________________
CoreSight mailing list -- [email protected] To unsubscribe send an email to [email protected]

Signature · 3 lines
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
maintainer
#2 lore raw
In reply to Junhao He
Quoted 4 lines · Junhao He

The TRCSEQRSTEVR and TRCSEQSTR register is not implemented if the TRCIDR5.NUMSEQSTATE == 0. Skip accessing the register in such cases.

This must have :

Fixes 2e1cdfe184b5 ("coresight-etm4x: Adding CoreSight ETM4x driver")

The patch as such looks correct to me.

I will queue this.

Thanks
Suzuki

Quoted 47 lines
---
  .../hwtracing/coresight/coresight-etm4x-core.c | 18 ++++++++++++------
  1 file changed, 12 insertions(+), 6 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +12 -6
index 80fefaba58ee..c7a65d1524fc 100644
@@ -424,8 +424,10 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
  		etm4x_relaxed_write32(csa, config->vipcssctlr, TRCVIPCSSCTLR);
  	for (i = 0; i < drvdata->nrseqstate - 1; i++)
  		etm4x_relaxed_write32(csa, config->seq_ctrl[i], TRCSEQEVRn(i));
-	etm4x_relaxed_write32(csa, config->seq_rst, TRCSEQRSTEVR);
-	etm4x_relaxed_write32(csa, config->seq_state, TRCSEQSTR);
+	if (drvdata->nrseqstate) {
+		etm4x_relaxed_write32(csa, config->seq_rst, TRCSEQRSTEVR);
+		etm4x_relaxed_write32(csa, config->seq_state, TRCSEQSTR);
+	}
  	etm4x_relaxed_write32(csa, config->ext_inp, TRCEXTINSELR);
  	for (i = 0; i < drvdata->nr_cntr; i++) {
  		etm4x_relaxed_write32(csa, config->cntrldvr[i], TRCCNTRLDVRn(i));
@@ -1631,8 +1633,10 @@ static int __etm4_cpu_save(struct etmv4_drvdata *drvdata)
  	for (i = 0; i < drvdata->nrseqstate - 1; i++)
  		state->trcseqevr[i] = etm4x_read32(csa, TRCSEQEVRn(i));
 
-	state->trcseqrstevr = etm4x_read32(csa, TRCSEQRSTEVR);
-	state->trcseqstr = etm4x_read32(csa, TRCSEQSTR);
+	if (drvdata->nrseqstate) {
+		state->trcseqrstevr = etm4x_read32(csa, TRCSEQRSTEVR);
+		state->trcseqstr = etm4x_read32(csa, TRCSEQSTR);
+	}
  	state->trcextinselr = etm4x_read32(csa, TRCEXTINSELR);
 
  	for (i = 0; i < drvdata->nr_cntr; i++) {
@@ -1760,8 +1764,10 @@ static void __etm4_cpu_restore(struct etmv4_drvdata *drvdata)
  	for (i = 0; i < drvdata->nrseqstate - 1; i++)
  		etm4x_relaxed_write32(csa, state->trcseqevr[i], TRCSEQEVRn(i));
 
-	etm4x_relaxed_write32(csa, state->trcseqrstevr, TRCSEQRSTEVR);
-	etm4x_relaxed_write32(csa, state->trcseqstr, TRCSEQSTR);
+	if (drvdata->nrseqstate) {
+		etm4x_relaxed_write32(csa, state->trcseqrstevr, TRCSEQRSTEVR);
+		etm4x_relaxed_write32(csa, state->trcseqstr, TRCSEQSTR);
+	}
  	etm4x_relaxed_write32(csa, state->trcextinselr, TRCEXTINSELR);
 
  	for (i = 0; i < drvdata->nr_cntr; i++) {
author
#3 lore raw
Quoted 9 lines · Suzuki K Poulose
Quoted 4 lines · Junhao He

The TRCSEQRSTEVR and TRCSEQSTR register is not implemented if the TRCIDR5.NUMSEQSTATE == 0. Skip accessing the register in such cases.

This must have :

Quoted 8 lines
Fixes 2e1cdfe184b5 ("coresight-etm4x: Adding CoreSight ETM4x driver")

The patch as such looks correct to me.

I will queue this.

Thanks
Suzuki

Sure, Will fix in next version.

Best regards,
Junhao.

Quoted 57 lines
Quoted 40 lines
---
  .../hwtracing/coresight/coresight-etm4x-core.c | 18 ++++++++++++------
  1 file changed, 12 insertions(+), 6 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +4 -2
index 80fefaba58ee..c7a65d1524fc 100644
@@ -424,8 +424,10 @@ static int etm4_enable_hw(struct etmv4_drvdata 
 *drvdata)
          etm4x_relaxed_write32(csa, config->vipcssctlr, TRCVIPCSSCTLR);
      for (i = 0; i < drvdata->nrseqstate - 1; i++)
          etm4x_relaxed_write32(csa, config->seq_ctrl[i], 
 TRCSEQEVRn(i));
-    etm4x_relaxed_write32(csa, config->seq_rst, TRCSEQRSTEVR);
-    etm4x_relaxed_write32(csa, config->seq_state, TRCSEQSTR);
+    if (drvdata->nrseqstate) {
+        etm4x_relaxed_write32(csa, config->seq_rst, TRCSEQRSTEVR);
+        etm4x_relaxed_write32(csa, config->seq_state, TRCSEQSTR);
+    }
      etm4x_relaxed_write32(csa, config->ext_inp, TRCEXTINSELR);
      for (i = 0; i < drvdata->nr_cntr; i++) {
          etm4x_relaxed_write32(csa, config->cntrldvr[i], 

TRCCNTRLDVRn(i));

drivers/hwtracing/coresight/coresight-etm4x-core.c +4 -1
@@ -1631,8 +1633,10 @@ static int __etm4_cpu_save(struct 
 etmv4_drvdata *drvdata)
      for (i = 0; i < drvdata->nrseqstate - 1; i++)
          state->trcseqevr[i] = etm4x_read32(csa, TRCSEQEVRn(i));
  -    state->trcseqrstevr = etm4x_read32(csa, TRCSEQRSTEVR);
-    state->trcseqstr = etm4x_read32(csa, TRCSEQSTR);
+    if (drvdata->nrseqstate) {
+        state->trcseqrstevr = etm4x_read32(csa, TRCSEQRSTEVR);
+        state->trcseqstr = etm4x_read32(csa, TRCSEQSTR);
+    }
      state->trcextinselr = etm4x_read32(csa, TRCEXTINSELR);
        for (i = 0; i < drvdata->nr_cntr; i++) {
@@ -1760,8 +1764,10 @@ static void __etm4_cpu_restore(struct 
 etmv4_drvdata *drvdata)
      for (i = 0; i < drvdata->nrseqstate - 1; i++)

drivers/hwtracing/coresight/coresight-etm4x-core.c static void __etm4_cpu_restore(struct · line 1773

Quoted 10 lines
drivers/hwtracing/coresight/coresight-etm4x-core.c +4 -1
          etm4x_relaxed_write32(csa, state->trcseqevr[i], 
 TRCSEQEVRn(i));
  -    etm4x_relaxed_write32(csa, state->trcseqrstevr, TRCSEQRSTEVR);
-    etm4x_relaxed_write32(csa, state->trcseqstr, TRCSEQSTR);
+    if (drvdata->nrseqstate) {
+        etm4x_relaxed_write32(csa, state->trcseqrstevr, TRCSEQRSTEVR);
+        etm4x_relaxed_write32(csa, state->trcseqstr, TRCSEQSTR);
+    }
      etm4x_relaxed_write32(csa, state->trcextinselr, TRCEXTINSELR);
        for (i = 0; i < drvdata->nr_cntr; i++) {

_______________________________________________
CoreSight mailing list -- [email protected] To unsubscribe send an email to [email protected]

.

Reviewed-by on v1 1/1
#4 lore raw
In reply to Junhao He
Quoted 1 line · Junhao He

The TRCSEQRSTEVR and TRCSEQSTR register is not implemented if the

s/register is/registers are/

Quoted 1 line

TRCIDR5.NUMSEQSTATE == 0. Skip accessing the register in such cases.

s/register/registers/

Quoted 2 lines
Quoted 47 lines
---
 .../hwtracing/coresight/coresight-etm4x-core.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +12 -6
index 80fefaba58ee..c7a65d1524fc 100644
@@ -424,8 +424,10 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
 		etm4x_relaxed_write32(csa, config->vipcssctlr, TRCVIPCSSCTLR);
 	for (i = 0; i < drvdata->nrseqstate - 1; i++)
 		etm4x_relaxed_write32(csa, config->seq_ctrl[i], TRCSEQEVRn(i));
-	etm4x_relaxed_write32(csa, config->seq_rst, TRCSEQRSTEVR);
-	etm4x_relaxed_write32(csa, config->seq_state, TRCSEQSTR);
+	if (drvdata->nrseqstate) {
+		etm4x_relaxed_write32(csa, config->seq_rst, TRCSEQRSTEVR);
+		etm4x_relaxed_write32(csa, config->seq_state, TRCSEQSTR);
+	}
 	etm4x_relaxed_write32(csa, config->ext_inp, TRCEXTINSELR);
 	for (i = 0; i < drvdata->nr_cntr; i++) {
 		etm4x_relaxed_write32(csa, config->cntrldvr[i], TRCCNTRLDVRn(i));
@@ -1631,8 +1633,10 @@ static int __etm4_cpu_save(struct etmv4_drvdata *drvdata)
 	for (i = 0; i < drvdata->nrseqstate - 1; i++)
 		state->trcseqevr[i] = etm4x_read32(csa, TRCSEQEVRn(i));
 
-	state->trcseqrstevr = etm4x_read32(csa, TRCSEQRSTEVR);
-	state->trcseqstr = etm4x_read32(csa, TRCSEQSTR);
+	if (drvdata->nrseqstate) {
+		state->trcseqrstevr = etm4x_read32(csa, TRCSEQRSTEVR);
+		state->trcseqstr = etm4x_read32(csa, TRCSEQSTR);
+	}
 	state->trcextinselr = etm4x_read32(csa, TRCEXTINSELR);
 
 	for (i = 0; i < drvdata->nr_cntr; i++) {
@@ -1760,8 +1764,10 @@ static void __etm4_cpu_restore(struct etmv4_drvdata *drvdata)
 	for (i = 0; i < drvdata->nrseqstate - 1; i++)
 		etm4x_relaxed_write32(csa, state->trcseqevr[i], TRCSEQEVRn(i));
 
-	etm4x_relaxed_write32(csa, state->trcseqrstevr, TRCSEQRSTEVR);
-	etm4x_relaxed_write32(csa, state->trcseqstr, TRCSEQSTR);
+	if (drvdata->nrseqstate) {
+		etm4x_relaxed_write32(csa, state->trcseqrstevr, TRCSEQRSTEVR);
+		etm4x_relaxed_write32(csa, state->trcseqstr, TRCSEQSTR);
+	}
 	etm4x_relaxed_write32(csa, state->trcextinselr, TRCEXTINSELR);
 
 	for (i = 0; i < drvdata->nr_cntr; i++) {
author
#5 lore raw
Quoted 4 lines · Anshuman Khandual
Quoted 1 line · Junhao He

The TRCSEQRSTEVR and TRCSEQSTR register is not implemented if the

s/register is/registers are/

Ok, will fix it.
Thanks.

Quoted 2 lines
Quoted 1 line

TRCIDR5.NUMSEQSTATE == 0. Skip accessing the register in such cases.

s/register/registers/

Ok, will fix it.
Thanks.

Quoted 52 lines
Quoted 1 line
Quoted 37 lines
---
  .../hwtracing/coresight/coresight-etm4x-core.c | 18 ++++++++++++------
  1 file changed, 12 insertions(+), 6 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +8 -4
index 80fefaba58ee..c7a65d1524fc 100644
@@ -424,8 +424,10 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
  		etm4x_relaxed_write32(csa, config->vipcssctlr, TRCVIPCSSCTLR);
  	for (i = 0; i < drvdata->nrseqstate - 1; i++)
  		etm4x_relaxed_write32(csa, config->seq_ctrl[i], TRCSEQEVRn(i));
-	etm4x_relaxed_write32(csa, config->seq_rst, TRCSEQRSTEVR);
-	etm4x_relaxed_write32(csa, config->seq_state, TRCSEQSTR);
+	if (drvdata->nrseqstate) {
+		etm4x_relaxed_write32(csa, config->seq_rst, TRCSEQRSTEVR);
+		etm4x_relaxed_write32(csa, config->seq_state, TRCSEQSTR);
+	}
  	etm4x_relaxed_write32(csa, config->ext_inp, TRCEXTINSELR);
  	for (i = 0; i < drvdata->nr_cntr; i++) {
  		etm4x_relaxed_write32(csa, config->cntrldvr[i], TRCCNTRLDVRn(i));
@@ -1631,8 +1633,10 @@ static int __etm4_cpu_save(struct etmv4_drvdata *drvdata)
  	for (i = 0; i < drvdata->nrseqstate - 1; i++)
  		state->trcseqevr[i] = etm4x_read32(csa, TRCSEQEVRn(i));
 
-	state->trcseqrstevr = etm4x_read32(csa, TRCSEQRSTEVR);
-	state->trcseqstr = etm4x_read32(csa, TRCSEQSTR);
+	if (drvdata->nrseqstate) {
+		state->trcseqrstevr = etm4x_read32(csa, TRCSEQRSTEVR);
+		state->trcseqstr = etm4x_read32(csa, TRCSEQSTR);
+	}
  	state->trcextinselr = etm4x_read32(csa, TRCEXTINSELR);
 
  	for (i = 0; i < drvdata->nr_cntr; i++) {
@@ -1760,8 +1764,10 @@ static void __etm4_cpu_restore(struct etmv4_drvdata *drvdata)
  	for (i = 0; i < drvdata->nrseqstate - 1; i++)
  		etm4x_relaxed_write32(csa, state->trcseqevr[i], TRCSEQEVRn(i));

drivers/hwtracing/coresight/coresight-etm4x-core.c static void __etm4_cpu_restore(struct etmv4_drvdata *drvdata) · line 1773

Quoted 10 lines
drivers/hwtracing/coresight/coresight-etm4x-core.c +4 -2
 
-	etm4x_relaxed_write32(csa, state->trcseqrstevr, TRCSEQRSTEVR);
-	etm4x_relaxed_write32(csa, state->trcseqstr, TRCSEQSTR);
+	if (drvdata->nrseqstate) {
+		etm4x_relaxed_write32(csa, state->trcseqrstevr, TRCSEQRSTEVR);
+		etm4x_relaxed_write32(csa, state->trcseqstr, TRCSEQSTR);
+	}
  	etm4x_relaxed_write32(csa, state->trcextinselr, TRCEXTINSELR);
 
  	for (i = 0; i < drvdata->nr_cntr; i++) {

.