Skip to content

Commit 4dd5239

Browse files
committed
Merge tag 'coresight-fixes-v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/coresight/linux into char-misc-linus
Suzuki writes: coresight: Fixes for v6.3 Fixes for coresight subsystem includes: - Fix etm4_enable_hw to program all the address comparator pairs (instead of half of them) - Do not access TRCIDR1 register without OSLK cleared in etm4_probe for mmio access. Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> * tag 'coresight-fixes-v6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/coresight/linux: coresight: etm4x: Do not access TRCIDR1 for identification coresight-etm4: Fix for() loop drvdata->nr_addr_cmp range bug
2 parents 8405254 + 735e7b3 commit 4dd5239

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
472472
if (etm4x_sspcicrn_present(drvdata, i))
473473
etm4x_relaxed_write32(csa, config->ss_pe_cmp[i], TRCSSPCICRn(i));
474474
}
475-
for (i = 0; i < drvdata->nr_addr_cmp; i++) {
475+
for (i = 0; i < drvdata->nr_addr_cmp * 2; i++) {
476476
etm4x_relaxed_write64(csa, config->addr_val[i], TRCACVRn(i));
477477
etm4x_relaxed_write64(csa, config->addr_acc[i], TRCACATRn(i));
478478
}
@@ -1070,25 +1070,21 @@ static bool etm4_init_iomem_access(struct etmv4_drvdata *drvdata,
10701070
struct csdev_access *csa)
10711071
{
10721072
u32 devarch = readl_relaxed(drvdata->base + TRCDEVARCH);
1073-
u32 idr1 = readl_relaxed(drvdata->base + TRCIDR1);
10741073

10751074
/*
10761075
* All ETMs must implement TRCDEVARCH to indicate that
1077-
* the component is an ETMv4. To support any broken
1078-
* implementations we fall back to TRCIDR1 check, which
1079-
* is not really reliable.
1076+
* the component is an ETMv4. Even though TRCIDR1 also
1077+
* contains the information, it is part of the "Trace"
1078+
* register and must be accessed with the OSLK cleared,
1079+
* with MMIO. But we cannot touch the OSLK until we are
1080+
* sure this is an ETM. So rely only on the TRCDEVARCH.
10801081
*/
1081-
if ((devarch & ETM_DEVARCH_ID_MASK) == ETM_DEVARCH_ETMv4x_ARCH) {
1082-
drvdata->arch = etm_devarch_to_arch(devarch);
1083-
} else {
1084-
pr_warn("CPU%d: ETM4x incompatible TRCDEVARCH: %x, falling back to TRCIDR1\n",
1085-
smp_processor_id(), devarch);
1086-
1087-
if (ETM_TRCIDR1_ARCH_MAJOR(idr1) != ETM_TRCIDR1_ARCH_ETMv4)
1088-
return false;
1089-
drvdata->arch = etm_trcidr_to_arch(idr1);
1082+
if ((devarch & ETM_DEVARCH_ID_MASK) != ETM_DEVARCH_ETMv4x_ARCH) {
1083+
pr_warn_once("TRCDEVARCH doesn't match ETMv4 architecture\n");
1084+
return false;
10901085
}
10911086

1087+
drvdata->arch = etm_devarch_to_arch(devarch);
10921088
*csa = CSDEV_ACCESS_IOMEM(drvdata->base);
10931089
return true;
10941090
}

drivers/hwtracing/coresight/coresight-etm4x.h

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -753,14 +753,12 @@
753753
* TRCDEVARCH - CoreSight architected register
754754
* - Bits[15:12] - Major version
755755
* - Bits[19:16] - Minor version
756-
* TRCIDR1 - ETM architected register
757-
* - Bits[11:8] - Major version
758-
* - Bits[7:4] - Minor version
759-
* We must rely on TRCDEVARCH for the version information,
760-
* however we don't want to break the support for potential
761-
* old implementations which might not implement it. Thus
762-
* we fall back to TRCIDR1 if TRCDEVARCH is not implemented
763-
* for memory mapped components.
756+
*
757+
* We must rely only on TRCDEVARCH for the version information. Even though,
758+
* TRCIDR1 also provides the architecture version, it is a "Trace" register
759+
* and as such must be accessed only with Trace power domain ON. This may
760+
* not be available at probe time.
761+
*
764762
* Now to make certain decisions easier based on the version
765763
* we use an internal representation of the version in the
766764
* driver, as follows :
@@ -786,12 +784,6 @@ static inline u8 etm_devarch_to_arch(u32 devarch)
786784
ETM_DEVARCH_REVISION(devarch));
787785
}
788786

789-
static inline u8 etm_trcidr_to_arch(u32 trcidr1)
790-
{
791-
return ETM_ARCH_VERSION(ETM_TRCIDR1_ARCH_MAJOR(trcidr1),
792-
ETM_TRCIDR1_ARCH_MINOR(trcidr1));
793-
}
794-
795787
enum etm_impdef_type {
796788
ETM4_IMPDEF_HISI_CORE_COMMIT,
797789
ETM4_IMPDEF_FEATURE_MAX,

0 commit comments

Comments
 (0)