Skip to content

Commit 40f682a

Browse files
Leo-YanSuzuki K Poulose
authored andcommitted
coresight: etm4x: Extract the trace unit controlling
The trace unit is controlled in the ETM hardware enabling and disabling. The sequential changes for support AUX pause and resume will reuse the same operations. Extract the operations in the etm4_{enable|disable}_trace_unit() functions. A minor improvement in etm4_enable_trace_unit() is for returning the timeout error to callers. Signed-off-by: Leo Yan <[email protected]> Reviewed-by: Mike Leach <[email protected]> Reviewed-by: James Clark <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent aad548a commit 40f682a

File tree

1 file changed

+62
-41
lines changed

1 file changed

+62
-41
lines changed

drivers/hwtracing/coresight/coresight-etm4x-core.c

Lines changed: 62 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,44 @@ static int etm4x_wait_status(struct csdev_access *csa, int pos, int val)
431431
return coresight_timeout(csa, TRCSTATR, pos, val);
432432
}
433433

434+
static int etm4_enable_trace_unit(struct etmv4_drvdata *drvdata)
435+
{
436+
struct coresight_device *csdev = drvdata->csdev;
437+
struct device *etm_dev = &csdev->dev;
438+
struct csdev_access *csa = &csdev->access;
439+
440+
/*
441+
* ETE mandates that the TRCRSR is written to before
442+
* enabling it.
443+
*/
444+
if (etm4x_is_ete(drvdata))
445+
etm4x_relaxed_write32(csa, TRCRSR_TA, TRCRSR);
446+
447+
etm4x_allow_trace(drvdata);
448+
/* Enable the trace unit */
449+
etm4x_relaxed_write32(csa, 1, TRCPRGCTLR);
450+
451+
/* Synchronize the register updates for sysreg access */
452+
if (!csa->io_mem)
453+
isb();
454+
455+
/* wait for TRCSTATR.IDLE to go back down to '0' */
456+
if (etm4x_wait_status(csa, TRCSTATR_IDLE_BIT, 0)) {
457+
dev_err(etm_dev,
458+
"timeout while waiting for Idle Trace Status\n");
459+
return -ETIME;
460+
}
461+
462+
/*
463+
* As recommended by section 4.3.7 ("Synchronization when using the
464+
* memory-mapped interface") of ARM IHI 0064D
465+
*/
466+
dsb(sy);
467+
isb();
468+
469+
return 0;
470+
}
471+
434472
static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
435473
{
436474
int i, rc;
@@ -539,33 +577,7 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
539577
etm4x_relaxed_write32(csa, trcpdcr | TRCPDCR_PU, TRCPDCR);
540578
}
541579

542-
/*
543-
* ETE mandates that the TRCRSR is written to before
544-
* enabling it.
545-
*/
546-
if (etm4x_is_ete(drvdata))
547-
etm4x_relaxed_write32(csa, TRCRSR_TA, TRCRSR);
548-
549-
etm4x_allow_trace(drvdata);
550-
/* Enable the trace unit */
551-
etm4x_relaxed_write32(csa, 1, TRCPRGCTLR);
552-
553-
/* Synchronize the register updates for sysreg access */
554-
if (!csa->io_mem)
555-
isb();
556-
557-
/* wait for TRCSTATR.IDLE to go back down to '0' */
558-
if (etm4x_wait_status(csa, TRCSTATR_IDLE_BIT, 0))
559-
dev_err(etm_dev,
560-
"timeout while waiting for Idle Trace Status\n");
561-
562-
/*
563-
* As recommended by section 4.3.7 ("Synchronization when using the
564-
* memory-mapped interface") of ARM IHI 0064D
565-
*/
566-
dsb(sy);
567-
isb();
568-
580+
rc = etm4_enable_trace_unit(drvdata);
569581
done:
570582
etm4_cs_lock(drvdata, csa);
571583

@@ -884,25 +896,12 @@ static int etm4_enable(struct coresight_device *csdev, struct perf_event *event,
884896
return ret;
885897
}
886898

887-
static void etm4_disable_hw(void *info)
899+
static void etm4_disable_trace_unit(struct etmv4_drvdata *drvdata)
888900
{
889901
u32 control;
890-
struct etmv4_drvdata *drvdata = info;
891-
struct etmv4_config *config = &drvdata->config;
892902
struct coresight_device *csdev = drvdata->csdev;
893903
struct device *etm_dev = &csdev->dev;
894904
struct csdev_access *csa = &csdev->access;
895-
int i;
896-
897-
etm4_cs_unlock(drvdata, csa);
898-
etm4_disable_arch_specific(drvdata);
899-
900-
if (!drvdata->skip_power_up) {
901-
/* power can be removed from the trace unit now */
902-
control = etm4x_relaxed_read32(csa, TRCPDCR);
903-
control &= ~TRCPDCR_PU;
904-
etm4x_relaxed_write32(csa, control, TRCPDCR);
905-
}
906905

907906
control = etm4x_relaxed_read32(csa, TRCPRGCTLR);
908907

@@ -943,6 +942,28 @@ static void etm4_disable_hw(void *info)
943942
* of ARM IHI 0064H.b.
944943
*/
945944
isb();
945+
}
946+
947+
static void etm4_disable_hw(void *info)
948+
{
949+
u32 control;
950+
struct etmv4_drvdata *drvdata = info;
951+
struct etmv4_config *config = &drvdata->config;
952+
struct coresight_device *csdev = drvdata->csdev;
953+
struct csdev_access *csa = &csdev->access;
954+
int i;
955+
956+
etm4_cs_unlock(drvdata, csa);
957+
etm4_disable_arch_specific(drvdata);
958+
959+
if (!drvdata->skip_power_up) {
960+
/* power can be removed from the trace unit now */
961+
control = etm4x_relaxed_read32(csa, TRCPDCR);
962+
control &= ~TRCPDCR_PU;
963+
etm4x_relaxed_write32(csa, control, TRCPDCR);
964+
}
965+
966+
etm4_disable_trace_unit(drvdata);
946967

947968
/* read the status of the single shot comparators */
948969
for (i = 0; i < drvdata->nr_ss_cmp; i++) {

0 commit comments

Comments
 (0)