Skip to content

Commit 735e7b3

Browse files
author
Suzuki K Poulose
committed
coresight: etm4x: Do not access TRCIDR1 for identification
CoreSight ETM4x architecture clearly provides ways to identify a device via registers in the "Management" class, TRCDEVARCH and TRCDEVTYPE. These registers can be accessed without the Trace domain being powered on. We additionally added TRCIDR1 as fallback in order to cover for any ETMs that may not have implemented TRCDEVARCH. So far, nobody has reported hitting a WARNING we placed to catch such systems. Also, more importantly it is problematic to access TRCIDR1, which is a "Trace" register via MMIO access, without clearing the OSLK. But we cannot mess with the OSLK until we know for sure that this is an ETMv4 device. Thus, this kind of creates a chicken and egg problem unnecessarily for systems "which are compliant" to the ETMv4 architecture. Let us remove the TRCIDR1 fall back check and rely only on TRCDEVARCH. Fixes: 8b94db1 ("coresight: etm4x: Use TRCDEVARCH for component discovery") Cc: [email protected] Reported-by: Steve Clevenger <[email protected]> Link: https://lore.kernel.org/all/143540e5623d4c7393d24833f2b80600d8d745d2.1677881753.git.scclevenger@os.amperecomputing.com/ Cc: Mike Leach <[email protected]> Cc: James Clark <[email protected]> Reviewed-by: Mike Leach <[email protected]> Reviewed-by: Anshuman Khandual <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent bf84937 commit 735e7b3

2 files changed

Lines changed: 15 additions & 27 deletions

File tree

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

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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)