public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] coresight: etm4x: Fix number of resources check for ETM 4.3 and above.
@ 2020-09-15 11:36 Mike Leach
  2020-09-15 16:45 ` Mathieu Poirier
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Leach @ 2020-09-15 11:36 UTC (permalink / raw)
  To: linux-arm-kernel, coresight, mathieu.poirier; +Cc: Mike Leach, suzuki.poulose

The initialisation code checks TRCIDR4 to determine the number of resource
selectors available on the system. Since ETM v 4.3, the value 0 has a
different meaning. This patch takes into account this change.

Signed-off-by: Mike Leach <mike.leach@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etm4x.c | 8 +++++++-
 drivers/hwtracing/coresight/coresight-etm4x.h | 3 +++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
index 00c9f0bb8b1a..be687276704c 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x.c
@@ -742,8 +742,14 @@ static void etm4_init_arch_data(void *info)
 	 * The number of resource pairs conveyed by the HW starts at 0, i.e a
 	 * value of 0x0 indicate 1 resource pair, 0x1 indicate two and so on.
 	 * As such add 1 to the value of NUMRSPAIR for a better representation.
+	 *
+	 * For ETM v4.3 and later, 0x0 means 0, and no pairs are available -
+	 * the default TRUE and FALSE resource selectors are omitted.
+	 * Otherwise for values 0x1 and above the number is N + 1 as per v4.2.
 	 */
-	drvdata->nr_resource = BMVAL(etmidr4, 16, 19) + 1;
+	drvdata->nr_resource = BMVAL(etmidr4, 16, 19);
+	if ((drvdata->arch < ETM4X_ARCH_4V3) || (drvdata->nr_resource > 0))
+		drvdata->nr_resource += 1;
 	/*
 	 * NUMSSCC, bits[23:20] the number of single-shot
 	 * comparator control for tracing. Read any status regs as these
diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h
index 5259f96fd28a..eefc7371c6c4 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x.h
+++ b/drivers/hwtracing/coresight/coresight-etm4x.h
@@ -200,6 +200,9 @@
 /* NS MON (EL3) mode never implemented */
 #define ETM_EXLEVEL_NS_VICTLR_MASK	GENMASK(22, 20)
 
+/* Interpretation of resource numbers change at ETM v4.3 architecture */
+#define ETM4X_ARCH_4V3	0x43
+
 /**
  * struct etmv4_config - configuration information related to an ETMv4
  * @mode:	Controls various modes supported by this ETM.
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] coresight: etm4x: Fix number of resources check for ETM 4.3 and above.
  2020-09-15 11:36 [PATCH] coresight: etm4x: Fix number of resources check for ETM 4.3 and above Mike Leach
@ 2020-09-15 16:45 ` Mathieu Poirier
  0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Poirier @ 2020-09-15 16:45 UTC (permalink / raw)
  To: Mike Leach; +Cc: coresight, linux-arm-kernel, suzuki.poulose

Hi Mike,

On Tue, Sep 15, 2020 at 12:36:21PM +0100, Mike Leach wrote:
> The initialisation code checks TRCIDR4 to determine the number of resource
> selectors available on the system. Since ETM v 4.3, the value 0 has a
> different meaning. This patch takes into account this change.
> 
> Signed-off-by: Mike Leach <mike.leach@linaro.org>
> ---
>  drivers/hwtracing/coresight/coresight-etm4x.c | 8 +++++++-
>  drivers/hwtracing/coresight/coresight-etm4x.h | 3 +++
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
> index 00c9f0bb8b1a..be687276704c 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x.c
> @@ -742,8 +742,14 @@ static void etm4_init_arch_data(void *info)
>  	 * The number of resource pairs conveyed by the HW starts at 0, i.e a
>  	 * value of 0x0 indicate 1 resource pair, 0x1 indicate two and so on.
>  	 * As such add 1 to the value of NUMRSPAIR for a better representation.
> +	 *
> +	 * For ETM v4.3 and later, 0x0 means 0, and no pairs are available -
> +	 * the default TRUE and FALSE resource selectors are omitted.
> +	 * Otherwise for values 0x1 and above the number is N + 1 as per v4.2.
>  	 */

That's a weird implementation...  I had to double check the documentation to convince me
that your comment was correct before applying the patch.

Thanks,
Mathieu

> -	drvdata->nr_resource = BMVAL(etmidr4, 16, 19) + 1;
> +	drvdata->nr_resource = BMVAL(etmidr4, 16, 19);
> +	if ((drvdata->arch < ETM4X_ARCH_4V3) || (drvdata->nr_resource > 0))
> +		drvdata->nr_resource += 1;
>  	/*
>  	 * NUMSSCC, bits[23:20] the number of single-shot
>  	 * comparator control for tracing. Read any status regs as these
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h
> index 5259f96fd28a..eefc7371c6c4 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x.h
> +++ b/drivers/hwtracing/coresight/coresight-etm4x.h
> @@ -200,6 +200,9 @@
>  /* NS MON (EL3) mode never implemented */
>  #define ETM_EXLEVEL_NS_VICTLR_MASK	GENMASK(22, 20)
>  
> +/* Interpretation of resource numbers change at ETM v4.3 architecture */
> +#define ETM4X_ARCH_4V3	0x43
> +
>  /**
>   * struct etmv4_config - configuration information related to an ETMv4
>   * @mode:	Controls various modes supported by this ETM.
> -- 
> 2.17.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-15 16:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-15 11:36 [PATCH] coresight: etm4x: Fix number of resources check for ETM 4.3 and above Mike Leach
2020-09-15 16:45 ` Mathieu Poirier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox