All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] coresight: etm4x: Fix crash observed on Qcom ETM parts with 'Low power override'
@ 2022-08-03 19:12 ` Bhupesh Sharma
  0 siblings, 0 replies; 6+ messages in thread
From: Bhupesh Sharma @ 2022-08-03 19:12 UTC (permalink / raw)
  To: coresight, linux-arm-kernel
  Cc: mathieu.poirier, suzuki.poulose, mike.leach, leo.yan,
	alexander.shishkin, linux-kernel, bhupesh.linux, Bhupesh Sharma,
	Greg Kroah-Hartman

Some Qualcomm ETM implementations require skipping powering up
the trace unit, as the ETMs are in the same power domain as
their CPU cores.

Via commit 5214b563588e ("coresight: etm4x: Add support for
sysreg only devices"), the setting of 'skip_power_up' flag was
moved after the 'etm4_init_arch_data' function is called, whereas
the flag value is itself used inside the function. This causes
a crash when ETM mode 'Low-power state behavior override' is set
on some Qualcomm parts.

Fix the same.

Fixes: 5214b563588e ("coresight: etm4x: Add support for sysreg only devices")
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etm4x-core.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
index d39660a3e50c..cf6254b87fd5 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
@@ -1943,6 +1943,16 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid)
 	init_arg.csa = &desc.access;
 	init_arg.pid = etm_pid;
 
+	/*
+	 * Some Qualcomm implementations require skipping powering up the trace unit,
+	 * as the ETMs are in the same power domain as their CPU cores.
+	 *
+	 * Since the 'skip_power_up' flag is used inside 'etm4_init_arch_data' function,
+	 * initialize it before the function is called.
+	 */
+	if (fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up"))
+		drvdata->skip_power_up = true;
+
 	if (smp_call_function_single(drvdata->cpu,
 				etm4_init_arch_data,  &init_arg, 1))
 		dev_err(dev, "ETM arch init failed\n");
@@ -1951,8 +1961,7 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid)
 		return -EINVAL;
 
 	/* TRCPDCR is not accessible with system instructions. */
-	if (!desc.access.io_mem ||
-	    fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up"))
+	if (!desc.access.io_mem)
 		drvdata->skip_power_up = true;
 
 	major = ETM_ARCH_MAJOR_VERSION(drvdata->arch);
-- 
2.35.3


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

* [PATCH] coresight: etm4x: Fix crash observed on Qcom ETM parts with 'Low power override'
@ 2022-08-03 19:12 ` Bhupesh Sharma
  0 siblings, 0 replies; 6+ messages in thread
From: Bhupesh Sharma @ 2022-08-03 19:12 UTC (permalink / raw)
  To: coresight, linux-arm-kernel
  Cc: mathieu.poirier, suzuki.poulose, mike.leach, leo.yan,
	alexander.shishkin, linux-kernel, bhupesh.linux, Bhupesh Sharma,
	Greg Kroah-Hartman

Some Qualcomm ETM implementations require skipping powering up
the trace unit, as the ETMs are in the same power domain as
their CPU cores.

Via commit 5214b563588e ("coresight: etm4x: Add support for
sysreg only devices"), the setting of 'skip_power_up' flag was
moved after the 'etm4_init_arch_data' function is called, whereas
the flag value is itself used inside the function. This causes
a crash when ETM mode 'Low-power state behavior override' is set
on some Qualcomm parts.

Fix the same.

Fixes: 5214b563588e ("coresight: etm4x: Add support for sysreg only devices")
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etm4x-core.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
index d39660a3e50c..cf6254b87fd5 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
@@ -1943,6 +1943,16 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid)
 	init_arg.csa = &desc.access;
 	init_arg.pid = etm_pid;
 
+	/*
+	 * Some Qualcomm implementations require skipping powering up the trace unit,
+	 * as the ETMs are in the same power domain as their CPU cores.
+	 *
+	 * Since the 'skip_power_up' flag is used inside 'etm4_init_arch_data' function,
+	 * initialize it before the function is called.
+	 */
+	if (fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up"))
+		drvdata->skip_power_up = true;
+
 	if (smp_call_function_single(drvdata->cpu,
 				etm4_init_arch_data,  &init_arg, 1))
 		dev_err(dev, "ETM arch init failed\n");
@@ -1951,8 +1961,7 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid)
 		return -EINVAL;
 
 	/* TRCPDCR is not accessible with system instructions. */
-	if (!desc.access.io_mem ||
-	    fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up"))
+	if (!desc.access.io_mem)
 		drvdata->skip_power_up = true;
 
 	major = ETM_ARCH_MAJOR_VERSION(drvdata->arch);
-- 
2.35.3


_______________________________________________
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] 6+ messages in thread

* Re: [PATCH] coresight: etm4x: Fix crash observed on Qcom ETM parts with 'Low power override'
  2022-08-03 19:12 ` Bhupesh Sharma
@ 2022-08-04 13:32   ` Suzuki K Poulose
  -1 siblings, 0 replies; 6+ messages in thread
From: Suzuki K Poulose @ 2022-08-04 13:32 UTC (permalink / raw)
  To: Bhupesh Sharma, coresight, linux-arm-kernel
  Cc: mathieu.poirier, mike.leach, leo.yan, alexander.shishkin,
	linux-kernel, bhupesh.linux, Greg Kroah-Hartman

Hi Bhupesh,


On 03/08/2022 20:12, Bhupesh Sharma wrote:
> Some Qualcomm ETM implementations require skipping powering up
> the trace unit, as the ETMs are in the same power domain as
> their CPU cores.
> 
> Via commit 5214b563588e ("coresight: etm4x: Add support for
> sysreg only devices"), the setting of 'skip_power_up' flag was
> moved after the 'etm4_init_arch_data' function is called, whereas
> the flag value is itself used inside the function. This causes
> a crash when ETM mode 'Low-power state behavior override' is set
> on some Qualcomm parts.
> 
> Fix the same.
> 

Thanks for the patch. The patch is correct. But please see my comment
below.

> Fixes: 5214b563588e ("coresight: etm4x: Add support for sysreg only devices")
> Cc: Mike Leach <mike.leach@linaro.org>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
> ---
>   drivers/hwtracing/coresight/coresight-etm4x-core.c | 13 +++++++++++--
>   1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> index d39660a3e50c..cf6254b87fd5 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> @@ -1943,6 +1943,16 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid)
>   	init_arg.csa = &desc.access;
>   	init_arg.pid = etm_pid;
>   
> +	/*
> +	 * Some Qualcomm implementations require skipping powering up the trace unit,
> +	 * as the ETMs are in the same power domain as their CPU cores.
> +	 *
> +	 * Since the 'skip_power_up' flag is used inside 'etm4_init_arch_data' function,
> +	 * initialize it before the function is called.
> +	 */
> +	if (fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up"))
> +		drvdata->skip_power_up = true;
> +
>   	if (smp_call_function_single(drvdata->cpu,
>   				etm4_init_arch_data,  &init_arg, 1))
>   		dev_err(dev, "ETM arch init failed\n");
> @@ -1951,8 +1961,7 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid)
>   		return -EINVAL;
>   
>   	/* TRCPDCR is not accessible with system instructions. */
> -	if (!desc.access.io_mem ||
> -	    fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up"))
> +	if (!desc.access.io_mem)
>   		drvdata->skip_power_up = true;
>   

Please could you move this setting into "etm4_init_sysreg_access()" ? It 
looks a bit odd to split the check in the same function. Moving this to
the sysreg_access() makes it explicit.

Suzuki



>   	major = ETM_ARCH_MAJOR_VERSION(drvdata->arch);


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

* Re: [PATCH] coresight: etm4x: Fix crash observed on Qcom ETM parts with 'Low power override'
@ 2022-08-04 13:32   ` Suzuki K Poulose
  0 siblings, 0 replies; 6+ messages in thread
From: Suzuki K Poulose @ 2022-08-04 13:32 UTC (permalink / raw)
  To: Bhupesh Sharma, coresight, linux-arm-kernel
  Cc: mathieu.poirier, mike.leach, leo.yan, alexander.shishkin,
	linux-kernel, bhupesh.linux, Greg Kroah-Hartman

Hi Bhupesh,


On 03/08/2022 20:12, Bhupesh Sharma wrote:
> Some Qualcomm ETM implementations require skipping powering up
> the trace unit, as the ETMs are in the same power domain as
> their CPU cores.
> 
> Via commit 5214b563588e ("coresight: etm4x: Add support for
> sysreg only devices"), the setting of 'skip_power_up' flag was
> moved after the 'etm4_init_arch_data' function is called, whereas
> the flag value is itself used inside the function. This causes
> a crash when ETM mode 'Low-power state behavior override' is set
> on some Qualcomm parts.
> 
> Fix the same.
> 

Thanks for the patch. The patch is correct. But please see my comment
below.

> Fixes: 5214b563588e ("coresight: etm4x: Add support for sysreg only devices")
> Cc: Mike Leach <mike.leach@linaro.org>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
> ---
>   drivers/hwtracing/coresight/coresight-etm4x-core.c | 13 +++++++++++--
>   1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> index d39660a3e50c..cf6254b87fd5 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> @@ -1943,6 +1943,16 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid)
>   	init_arg.csa = &desc.access;
>   	init_arg.pid = etm_pid;
>   
> +	/*
> +	 * Some Qualcomm implementations require skipping powering up the trace unit,
> +	 * as the ETMs are in the same power domain as their CPU cores.
> +	 *
> +	 * Since the 'skip_power_up' flag is used inside 'etm4_init_arch_data' function,
> +	 * initialize it before the function is called.
> +	 */
> +	if (fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up"))
> +		drvdata->skip_power_up = true;
> +
>   	if (smp_call_function_single(drvdata->cpu,
>   				etm4_init_arch_data,  &init_arg, 1))
>   		dev_err(dev, "ETM arch init failed\n");
> @@ -1951,8 +1961,7 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid)
>   		return -EINVAL;
>   
>   	/* TRCPDCR is not accessible with system instructions. */
> -	if (!desc.access.io_mem ||
> -	    fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up"))
> +	if (!desc.access.io_mem)
>   		drvdata->skip_power_up = true;
>   

Please could you move this setting into "etm4_init_sysreg_access()" ? It 
looks a bit odd to split the check in the same function. Moving this to
the sysreg_access() makes it explicit.

Suzuki



>   	major = ETM_ARCH_MAJOR_VERSION(drvdata->arch);


_______________________________________________
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] 6+ messages in thread

* Re: [PATCH] coresight: etm4x: Fix crash observed on Qcom ETM parts with 'Low power override'
  2022-08-04 13:32   ` Suzuki K Poulose
@ 2022-08-04 15:19     ` Bhupesh Sharma
  -1 siblings, 0 replies; 6+ messages in thread
From: Bhupesh Sharma @ 2022-08-04 15:19 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: coresight, linux-arm-kernel, mathieu.poirier, mike.leach,
	leo.yan, alexander.shishkin, linux-kernel, bhupesh.linux,
	Greg Kroah-Hartman

Hi Suzuki,

On Thu, 4 Aug 2022 at 19:02, Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>
> Hi Bhupesh,
>
>
> On 03/08/2022 20:12, Bhupesh Sharma wrote:
> > Some Qualcomm ETM implementations require skipping powering up
> > the trace unit, as the ETMs are in the same power domain as
> > their CPU cores.
> >
> > Via commit 5214b563588e ("coresight: etm4x: Add support for
> > sysreg only devices"), the setting of 'skip_power_up' flag was
> > moved after the 'etm4_init_arch_data' function is called, whereas
> > the flag value is itself used inside the function. This causes
> > a crash when ETM mode 'Low-power state behavior override' is set
> > on some Qualcomm parts.
> >
> > Fix the same.
> >
>
> Thanks for the patch. The patch is correct. But please see my comment
> below.
>
> > Fixes: 5214b563588e ("coresight: etm4x: Add support for sysreg only devices")
> > Cc: Mike Leach <mike.leach@linaro.org>
> > Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> > Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
> > ---
> >   drivers/hwtracing/coresight/coresight-etm4x-core.c | 13 +++++++++++--
> >   1 file changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> > index d39660a3e50c..cf6254b87fd5 100644
> > --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
> > +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> > @@ -1943,6 +1943,16 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid)
> >       init_arg.csa = &desc.access;
> >       init_arg.pid = etm_pid;
> >
> > +     /*
> > +      * Some Qualcomm implementations require skipping powering up the trace unit,
> > +      * as the ETMs are in the same power domain as their CPU cores.
> > +      *
> > +      * Since the 'skip_power_up' flag is used inside 'etm4_init_arch_data' function,
> > +      * initialize it before the function is called.
> > +      */
> > +     if (fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up"))
> > +             drvdata->skip_power_up = true;
> > +
> >       if (smp_call_function_single(drvdata->cpu,
> >                               etm4_init_arch_data,  &init_arg, 1))
> >               dev_err(dev, "ETM arch init failed\n");
> > @@ -1951,8 +1961,7 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid)
> >               return -EINVAL;
> >
> >       /* TRCPDCR is not accessible with system instructions. */
> > -     if (!desc.access.io_mem ||
> > -         fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up"))
> > +     if (!desc.access.io_mem)
> >               drvdata->skip_power_up = true;
> >
>
> Please could you move this setting into "etm4_init_sysreg_access()" ? It
> looks a bit odd to split the check in the same function. Moving this to
> the sysreg_access() makes it explicit.

Sure, let me fix this in v2.

Regards,
Bhupesh

> >       major = ETM_ARCH_MAJOR_VERSION(drvdata->arch);
>

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

* Re: [PATCH] coresight: etm4x: Fix crash observed on Qcom ETM parts with 'Low power override'
@ 2022-08-04 15:19     ` Bhupesh Sharma
  0 siblings, 0 replies; 6+ messages in thread
From: Bhupesh Sharma @ 2022-08-04 15:19 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: coresight, linux-arm-kernel, mathieu.poirier, mike.leach,
	leo.yan, alexander.shishkin, linux-kernel, bhupesh.linux,
	Greg Kroah-Hartman

Hi Suzuki,

On Thu, 4 Aug 2022 at 19:02, Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>
> Hi Bhupesh,
>
>
> On 03/08/2022 20:12, Bhupesh Sharma wrote:
> > Some Qualcomm ETM implementations require skipping powering up
> > the trace unit, as the ETMs are in the same power domain as
> > their CPU cores.
> >
> > Via commit 5214b563588e ("coresight: etm4x: Add support for
> > sysreg only devices"), the setting of 'skip_power_up' flag was
> > moved after the 'etm4_init_arch_data' function is called, whereas
> > the flag value is itself used inside the function. This causes
> > a crash when ETM mode 'Low-power state behavior override' is set
> > on some Qualcomm parts.
> >
> > Fix the same.
> >
>
> Thanks for the patch. The patch is correct. But please see my comment
> below.
>
> > Fixes: 5214b563588e ("coresight: etm4x: Add support for sysreg only devices")
> > Cc: Mike Leach <mike.leach@linaro.org>
> > Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> > Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
> > ---
> >   drivers/hwtracing/coresight/coresight-etm4x-core.c | 13 +++++++++++--
> >   1 file changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> > index d39660a3e50c..cf6254b87fd5 100644
> > --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
> > +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> > @@ -1943,6 +1943,16 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid)
> >       init_arg.csa = &desc.access;
> >       init_arg.pid = etm_pid;
> >
> > +     /*
> > +      * Some Qualcomm implementations require skipping powering up the trace unit,
> > +      * as the ETMs are in the same power domain as their CPU cores.
> > +      *
> > +      * Since the 'skip_power_up' flag is used inside 'etm4_init_arch_data' function,
> > +      * initialize it before the function is called.
> > +      */
> > +     if (fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up"))
> > +             drvdata->skip_power_up = true;
> > +
> >       if (smp_call_function_single(drvdata->cpu,
> >                               etm4_init_arch_data,  &init_arg, 1))
> >               dev_err(dev, "ETM arch init failed\n");
> > @@ -1951,8 +1961,7 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid)
> >               return -EINVAL;
> >
> >       /* TRCPDCR is not accessible with system instructions. */
> > -     if (!desc.access.io_mem ||
> > -         fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up"))
> > +     if (!desc.access.io_mem)
> >               drvdata->skip_power_up = true;
> >
>
> Please could you move this setting into "etm4_init_sysreg_access()" ? It
> looks a bit odd to split the check in the same function. Moving this to
> the sysreg_access() makes it explicit.

Sure, let me fix this in v2.

Regards,
Bhupesh

> >       major = ETM_ARCH_MAJOR_VERSION(drvdata->arch);
>

_______________________________________________
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] 6+ messages in thread

end of thread, other threads:[~2022-08-04 15:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-03 19:12 [PATCH] coresight: etm4x: Fix crash observed on Qcom ETM parts with 'Low power override' Bhupesh Sharma
2022-08-03 19:12 ` Bhupesh Sharma
2022-08-04 13:32 ` Suzuki K Poulose
2022-08-04 13:32   ` Suzuki K Poulose
2022-08-04 15:19   ` Bhupesh Sharma
2022-08-04 15:19     ` Bhupesh Sharma

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.