Skip to content

Commit 8b94db1

Browse files
Suzuki K Poulosegregkh
Suzuki K Poulose
authored andcommitted
coresight: etm4x: Use TRCDEVARCH for component discovery
We have been using TRCIDR1 for detecting the ETM version. This is in preparation for the future IP support. Link: https://lore.kernel.org/r/[email protected] Cc: Mike Leach <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Signed-off-by: Mathieu Poirier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fd6e790 commit 8b94db1

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

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

+23-23
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,6 @@ static void etm4_cs_unlock(struct etmv4_drvdata *drvdata,
153153
CS_UNLOCK(csa->base);
154154
}
155155

156-
static bool etm4_arch_supported(u8 arch)
157-
{
158-
/* Mask out the minor version number */
159-
switch (arch & 0xf0) {
160-
case ETM_ARCH_V4:
161-
break;
162-
default:
163-
return false;
164-
}
165-
return true;
166-
}
167-
168156
static int etm4_cpu_id(struct coresight_device *csdev)
169157
{
170158
struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
@@ -784,6 +772,26 @@ static const struct coresight_ops etm4_cs_ops = {
784772
static bool etm4_init_iomem_access(struct etmv4_drvdata *drvdata,
785773
struct csdev_access *csa)
786774
{
775+
u32 devarch = readl_relaxed(drvdata->base + TRCDEVARCH);
776+
u32 idr1 = readl_relaxed(drvdata->base + TRCIDR1);
777+
778+
/*
779+
* All ETMs must implement TRCDEVARCH to indicate that
780+
* the component is an ETMv4. To support any broken
781+
* implementations we fall back to TRCIDR1 check, which
782+
* is not really reliable.
783+
*/
784+
if ((devarch & ETM_DEVARCH_ID_MASK) == ETM_DEVARCH_ETMv4x_ARCH) {
785+
drvdata->arch = etm_devarch_to_arch(devarch);
786+
} else {
787+
pr_warn("CPU%d: ETM4x incompatible TRCDEVARCH: %x, falling back to TRCIDR1\n",
788+
smp_processor_id(), devarch);
789+
790+
if (ETM_TRCIDR1_ARCH_MAJOR(idr1) != ETM_TRCIDR1_ARCH_ETMv4)
791+
return false;
792+
drvdata->arch = etm_trcidr_to_arch(idr1);
793+
}
794+
787795
*csa = CSDEV_ACCESS_IOMEM(drvdata->base);
788796
return true;
789797
}
@@ -800,7 +808,6 @@ static bool etm4_init_csdev_access(struct etmv4_drvdata *drvdata,
800808
static void etm4_init_arch_data(void *info)
801809
{
802810
u32 etmidr0;
803-
u32 etmidr1;
804811
u32 etmidr2;
805812
u32 etmidr3;
806813
u32 etmidr4;
@@ -865,14 +872,6 @@ static void etm4_init_arch_data(void *info)
865872
/* TSSIZE, bits[28:24] Global timestamp size field */
866873
drvdata->ts_size = BMVAL(etmidr0, 24, 28);
867874

868-
/* base architecture of trace unit */
869-
etmidr1 = etm4x_relaxed_read32(csa, TRCIDR1);
870-
/*
871-
* TRCARCHMIN, bits[7:4] architecture the minor version number
872-
* TRCARCHMAJ, bits[11:8] architecture major versin number
873-
*/
874-
drvdata->arch = BMVAL(etmidr1, 4, 11);
875-
876875
/* maximum size of resources */
877876
etmidr2 = etm4x_relaxed_read32(csa, TRCIDR2);
878877
/* CIDSIZE, bits[9:5] Indicates the Context ID size */
@@ -1712,7 +1711,7 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
17121711
etm4_init_arch_data, &init_arg, 1))
17131712
dev_err(dev, "ETM arch init failed\n");
17141713

1715-
if (etm4_arch_supported(drvdata->arch) == false)
1714+
if (!drvdata->arch)
17161715
return -EINVAL;
17171716

17181717
etm4_init_trace_id(drvdata);
@@ -1744,7 +1743,8 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
17441743

17451744
pm_runtime_put(&adev->dev);
17461745
dev_info(&drvdata->csdev->dev, "CPU%d: ETM v%d.%d initialized\n",
1747-
drvdata->cpu, drvdata->arch >> 4, drvdata->arch & 0xf);
1746+
drvdata->cpu, ETM_ARCH_MAJOR_VERSION(drvdata->arch),
1747+
ETM_ARCH_MINOR_VERSION(drvdata->arch));
17481748

17491749
if (boot_enable) {
17501750
coresight_enable(drvdata->csdev);

0 commit comments

Comments
 (0)