diff options
Diffstat (limited to 'drivers/hwtracing')
| -rw-r--r-- | drivers/hwtracing/coresight/coresight-etm-perf.c | 2 | ||||
| -rw-r--r-- | drivers/hwtracing/coresight/coresight-etm4x-core.c | 24 | ||||
| -rw-r--r-- | drivers/hwtracing/coresight/coresight-etm4x.h | 20 | ||||
| -rw-r--r-- | drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 | 
4 files changed, 19 insertions, 29 deletions
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index a48c97da8165..89e8ed214ea4 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -402,6 +402,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,  		trace_id = coresight_trace_id_get_cpu_id(cpu);  		if (!IS_VALID_CS_TRACE_ID(trace_id)) {  			cpumask_clear_cpu(cpu, mask); +			coresight_release_path(path);  			continue;  		} @@ -901,6 +902,7 @@ int __init etm_perf_init(void)  	etm_pmu.addr_filters_sync	= etm_addr_filters_sync;  	etm_pmu.addr_filters_validate	= etm_addr_filters_validate;  	etm_pmu.nr_addr_filters		= ETM_ADDR_CMP_MAX; +	etm_pmu.module			= THIS_MODULE;  	ret = perf_pmu_register(&etm_pmu, CORESIGHT_ETM_PMU_NAME, -1);  	if (ret == 0) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index 1ea8f173cca0..4c15fae534f3 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -472,7 +472,7 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)  		if (etm4x_sspcicrn_present(drvdata, i))  			etm4x_relaxed_write32(csa, config->ss_pe_cmp[i], TRCSSPCICRn(i));  	} -	for (i = 0; i < drvdata->nr_addr_cmp; i++) { +	for (i = 0; i < drvdata->nr_addr_cmp * 2; i++) {  		etm4x_relaxed_write64(csa, config->addr_val[i], TRCACVRn(i));  		etm4x_relaxed_write64(csa, config->addr_acc[i], TRCACATRn(i));  	} @@ -1070,25 +1070,21 @@ static bool etm4_init_iomem_access(struct etmv4_drvdata *drvdata,  				   struct csdev_access *csa)  {  	u32 devarch = readl_relaxed(drvdata->base + TRCDEVARCH); -	u32 idr1 = readl_relaxed(drvdata->base + TRCIDR1);  	/*  	 * All ETMs must implement TRCDEVARCH to indicate that -	 * the component is an ETMv4. To support any broken -	 * implementations we fall back to TRCIDR1 check, which -	 * is not really reliable. +	 * the component is an ETMv4. Even though TRCIDR1 also +	 * contains the information, it is part of the "Trace" +	 * register and must be accessed with the OSLK cleared, +	 * with MMIO. But we cannot touch the OSLK until we are +	 * sure this is an ETM. So rely only on the TRCDEVARCH.  	 */ -	if ((devarch & ETM_DEVARCH_ID_MASK) == ETM_DEVARCH_ETMv4x_ARCH) { -		drvdata->arch = etm_devarch_to_arch(devarch); -	} else { -		pr_warn("CPU%d: ETM4x incompatible TRCDEVARCH: %x, falling back to TRCIDR1\n", -			smp_processor_id(), devarch); - -		if (ETM_TRCIDR1_ARCH_MAJOR(idr1) != ETM_TRCIDR1_ARCH_ETMv4) -			return false; -		drvdata->arch = etm_trcidr_to_arch(idr1); +	if ((devarch & ETM_DEVARCH_ID_MASK) != ETM_DEVARCH_ETMv4x_ARCH) { +		pr_warn_once("TRCDEVARCH doesn't match ETMv4 architecture\n"); +		return false;  	} +	drvdata->arch = etm_devarch_to_arch(devarch);  	*csa = CSDEV_ACCESS_IOMEM(drvdata->base);  	return true;  } diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h index 434f4e95ee17..27c8a9901868 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -753,14 +753,12 @@   * TRCDEVARCH	- CoreSight architected register   *                - Bits[15:12] - Major version   *                - Bits[19:16] - Minor version - * TRCIDR1	- ETM architected register - *                - Bits[11:8] - Major version - *                - Bits[7:4]  - Minor version - * We must rely on TRCDEVARCH for the version information, - * however we don't want to break the support for potential - * old implementations which might not implement it. Thus - * we fall back to TRCIDR1 if TRCDEVARCH is not implemented - * for memory mapped components. + * + * We must rely only on TRCDEVARCH for the version information. Even though, + * TRCIDR1 also provides the architecture version, it is a "Trace" register + * and as such must be accessed only with Trace power domain ON. This may + * not be available at probe time. + *   * Now to make certain decisions easier based on the version   * we use an internal representation of the version in the   * driver, as follows : @@ -786,12 +784,6 @@ static inline u8 etm_devarch_to_arch(u32 devarch)  				ETM_DEVARCH_REVISION(devarch));  } -static inline u8 etm_trcidr_to_arch(u32 trcidr1) -{ -	return ETM_ARCH_VERSION(ETM_TRCIDR1_ARCH_MAJOR(trcidr1), -				ETM_TRCIDR1_ARCH_MINOR(trcidr1)); -} -  enum etm_impdef_type {  	ETM4_IMPDEF_HISI_CORE_COMMIT,  	ETM4_IMPDEF_FEATURE_MAX, diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index 918d461fcf4a..eaa296ced167 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -942,7 +942,7 @@ tmc_etr_buf_insert_barrier_packet(struct etr_buf *etr_buf, u64 offset)  	len = tmc_etr_buf_get_data(etr_buf, offset,  				   CORESIGHT_BARRIER_PKT_SIZE, &bufp); -	if (WARN_ON(len < CORESIGHT_BARRIER_PKT_SIZE)) +	if (WARN_ON(len < 0 || len < CORESIGHT_BARRIER_PKT_SIZE))  		return -EINVAL;  	coresight_insert_barrier_packet(bufp);  	return offset + CORESIGHT_BARRIER_PKT_SIZE;  |