coresight: Do not default to CPU0 for missing CPU phandle
Subsystems (4)
v2 cover coresight: Do not default to CPU0 for missing CPU phandle
In case of missing CPU phandle, the affinity is set default to CPU0 which is not a correct assumption. Fix this in coresight platform to set affinity to invalid and abort the probe in drivers. Also update the dt-bindings accordingly.
Patch 2 allows the probe of coresight etm and cpu-debug to abort earlier in case cpus are not available.
v2:
* Addressed review comments from Suzuki and Mathieu.
* Allows the probe of etm and cpu-debug to abort earlier in case of unavailability of respective cpus.
Sai Prakash Ranjan (2):
coresight: Do not default to CPU0 for missing CPU phandle
coresight: Abort probe if cpus are not available
Documentation/devicetree/bindings/arm/coresight.txt | 2 +- drivers/hwtracing/coresight/coresight-cpu-debug.c | 3 +++ drivers/hwtracing/coresight/coresight-etm3x.c | 3 +++ drivers/hwtracing/coresight/coresight-etm4x.c | 3 +++ drivers/hwtracing/coresight/coresight-platform.c | 13 ++++++++----- 5 files changed, 18 insertions(+), 6 deletions(-)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH v2 1/2 coresight: Do not default to CPU0 for missing CPU phandle
Coresight platform support assumes that a missing "cpu" phandle defaults to CPU0. This could be problematic and unnecessarily binds components to CPU0, where they may not be. Let us make the DT binding rules a bit stricter by not defaulting to CPU0 for missing "cpu" affinity information.
Also in coresight etm and cpu-debug drivers, abort the probe for such cases.
--- Documentation/devicetree/bindings/arm/coresight.txt | 2 +- drivers/hwtracing/coresight/coresight-cpu-debug.c | 3 +++ drivers/hwtracing/coresight/coresight-etm3x.c | 3 +++ drivers/hwtracing/coresight/coresight-etm4x.c | 3 +++ drivers/hwtracing/coresight/coresight-platform.c | 10 +++++----- 5 files changed, 15 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/arm/coresight.txt +1 -1
@@ -88,7 +88,7 @@ its hardware characteristcs. registers via co-processor 14. * cpu: the cpu phandle this ETM/PTM is affined to. When omitted the - source is considered to belong to CPU0. + affinity is set to invalid. * Optional property for TMC:
drivers/hwtracing/coresight/coresight-cpu-debug.c +3 -0
@@ -579,6 +579,9 @@ static int debug_probe(struct amba_device *adev, const struct amba_id *id)return -ENOMEM ; drvdata->cpu =coresight_get_cpu (dev); +if (drvdata->cpu <0 ) +return drvdata->cpu; +if (per_cpu (debug_drvdata, drvdata->cpu)) {dev_err (dev,"CPU%d drvdata has already been initialized\n" , drvdata->cpu);
drivers/hwtracing/coresight/coresight-etm3x.c +3 -0
@@ -816,6 +816,9 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id) } drvdata->cpu =coresight_get_cpu (dev); +if (drvdata->cpu <0 ) +return drvdata->cpu; + desc.name =devm_kasprintf (dev,GFP_KERNEL ,"etm%d" , drvdata->cpu);if (!desc.name)return -ENOMEM ;
drivers/hwtracing/coresight/coresight-etm4x.c +3 -0
@@ -1101,6 +1101,9 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id)spin_lock_init (&drvdata->spinlock); drvdata->cpu =coresight_get_cpu (dev); +if (drvdata->cpu <0 ) +return drvdata->cpu; + desc.name =devm_kasprintf (dev,GFP_KERNEL ,"etm%d" , drvdata->cpu);if (!desc.name)return -ENOMEM ;
drivers/hwtracing/coresight/coresight-platform.c +5 -5
@@ -159,16 +159,16 @@ static int of_coresight_get_cpu(struct device *dev)struct device_node *dn;if (!dev->of_node) -return 0 ; +return -ENODEV ; + dn =of_parse_phandle (dev->of_node,"cpu" ,0 ); -/* Affinity defaults to CPU0 */ if (!dn) -return 0 ; +return -ENODEV ; + cpu =of_cpu_node_to_id (dn);of_node_put (dn); -/* Affinity to CPU0 if no cpu nodes are found */ -return (cpu <0 ) ?0 : cpu; +return cpu; }/*
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Suzuki K Poulose
maintainerHi Sai,
Quoted 11 lines · Sai Prakash Ranjan
Coresight platform support assumes that a missing "cpu" phandle defaults to CPU0. This could be problematic and unnecessarily binds components to CPU0, where they may not be. Let us make the DT binding rules a bit stricter by not defaulting to CPU0 for missing "cpu" affinity information.
Also in coresight etm and cpu-debug drivers, abort the probe for such cases.
Signed-off-by Sai Prakash Ranjan <[email protected]>Reviewed-by Suzuki K Poulose <[email protected]>
Please drop this tag for now.
Quoted 13 lines
--- Documentation/devicetree/bindings/arm/coresight.txt | 2 +- drivers/hwtracing/coresight/coresight-cpu-debug.c | 3 +++ drivers/hwtracing/coresight/coresight-etm3x.c | 3 +++ drivers/hwtracing/coresight/coresight-etm4x.c | 3 +++ drivers/hwtracing/coresight/coresight-platform.c | 10 +++++----- 5 files changed, 15 insertions(+), 6 deletions(-)Documentation/devicetree/bindings/arm/coresight.txt +0
-0
Documentation/devicetree/bindings/arm/coresight.txt its hardware characteristcs. · line 92
Quoted 6 lines
Documentation/devicetree/bindings/arm/coresight.txt +1
-1@@ -88,7 +88,7 @@ its hardware characteristcs. registers via co-processor 14. * cpu: the cpu phandle this ETM/PTM is affined to. When omitted the - source is considered to belong to CPU0. + affinity is set to invalid.
Please move this from the "Optional properties". It is not "Optional" anymore with this change. Please make sure it is evident that this is mandatory. Also please fix the bindings document for cpu-debug.txt.
Quoted 13 lines
Documentation/devicetree/bindings/arm/coresight.txt +0
-0* Optional property for TMC:drivers/hwtracing/coresight/coresight-platform.c +1
-1@@ -159,16 +159,16 @@ static int of_coresight_get_cpu(struct device *dev)struct device_node *dn;if (!dev->of_node) -return 0 ; +return -ENODEV ;
drivers/hwtracing/coresight/coresight-platform.c static int of_coresight_get_cpu(struct device *dev) · line 170
Quoted 10 lines
drivers/hwtracing/coresight/coresight-platform.c +3
-2+ dn =of_parse_phandle (dev->of_node,"cpu" ,0 ); -/* Affinity defaults to CPU0 */ if (!dn) -return 0 ; +return -ENODEV ; + cpu =of_cpu_node_to_id (dn);of_node_put (dn);
Please fix the acpi_coresight_get_cpu() for ACPI.
Rest looks fine to me.
Suzuki
Hello Suzuki,
Quoted 10 lines · Suzuki K Poulose
Hi Sai,
Quoted 6 lines · Sai Prakash Ranjan
Coresight platform support assumes that a missing "cpu" phandle defaults to CPU0. This could be problematic and unnecessarily binds components to CPU0, where they may not be. Let us make the DT binding rules a bit stricter by not defaulting to CPU0 for missing "cpu" affinity information.
Quoted 8 lines
Quoted 5 lines
Also in coresight etm and cpu-debug drivers, abort the probe for such cases.
Signed-off-by Sai Prakash Ranjan <[email protected]>Reviewed-by Suzuki K Poulose <[email protected]>Please drop this tag for now.
Ok will drop this.
Quoted 37 lines
Quoted 13 lines
---
Documentation/devicetree/bindings/arm/coresight.txt| 2 +- drivers/hwtracing/coresight/coresight-cpu-debug.c | 3 +++ drivers/hwtracing/coresight/coresight-etm3x.c | 3 +++ drivers/hwtracing/coresight/coresight-etm4x.c | 3 +++ drivers/hwtracing/coresight/coresight-platform.c | 10 +++++-----5 files changed, 15 insertions(+), 6 deletions(-)Documentation/devicetree/bindings/arm/coresight.txt +0
-0@@ -88,7 +88,7 @@ its hardware characteristcs.Quoted 4 lines
registers via co-processor 14.
* cpu: the cpu phandle this ETM/PTM is affined to. When omitted the - source is considered to belong to CPU0.
+ affinity is set to invalid.Please move this from the "Optional properties". It is not "Optional" anymore with this change. Please make sure it is evident that this is mandatory. Also please fix the bindings document for cpu-debug.txt.
Quoted 14 lines
* Optional property for TMC:
drivers/hwtracing/coresight/coresight-platform.c +2
-2@@ -159,16 +159,16 @@ static int of_coresight_get_cpu(struct device *dev) struct device_node *dn; if (!dev->of_node) - return 0; + return -ENODEV; + dn = of_parse_phandle(dev->of_node, "cpu", 0); - /* Affinity defaults to CPU0 */
Quoted 9 lines
drivers/hwtracing/coresight/coresight-platform.c static int of_coresight_get_cpu(struct device *dev) · line 169
Quoted 6 lines
drivers/hwtracing/coresight/coresight-platform.c +2
-1if (!dn) - return 0; + return -ENODEV; + cpu = of_cpu_node_to_id(dn); of_node_put(dn);Please fix the
acpi_coresight_get_cpu()for ACPI.
Ok will do it. Thanks again for the review comments.
-Sai
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH v2 2/2 coresight: Abort probe if cpus are not available
In reply to Sai Prakash RanjanCurrently coresight etm and cpu-debug will go ahead with the probe even when corresponding cpus are not available and error out later in the probe path. In such cases, it is better to abort the probe earlier.
Without this, setting *nosmp* will throw below errors:
[ 5.910622] coresight-cpu-debug 850000.debug: Coresight debug-CPU0 initialized [ 5.914266] coresight-cpu-debug 852000.debug: CPU1 debug arch init failed [ 5.921474] coresight-cpu-debug 854000.debug: CPU2 debug arch init failed [ 5.928328] coresight-cpu-debug 856000.debug: CPU3 debug arch init failed [ 5.935330] coresight etm0: CPU0: ETM v4.0 initialized [ 5.941875] coresight-etm4x 85d000.etm: ETM arch init failed [ 5.946794] coresight-etm4x: probe of 85d000.etm failed with error -22 [ 5.952707] coresight-etm4x 85e000.etm: ETM arch init failed [ 5.958945] coresight-etm4x: probe of 85e000.etm failed with error -22 [ 5.964853] coresight-etm4x 85f000.etm: ETM arch init failed [ 5.971096] coresight-etm4x: probe of 85f000.etm failed with error -22
--- drivers/hwtracing/coresight/coresight-platform.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hwtracing/coresight/coresight-platform.c +3 -0
@@ -168,6 +168,9 @@ static int of_coresight_get_cpu(struct device *dev) cpu =of_cpu_node_to_id (dn);of_node_put (dn); +if (num_online_cpus () <= cpu) +return -ENODEV ; +return cpu; }
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Suzuki K Poulose
maintainerRe: [PATCHv2 2/2] coresight: Abort probe if cpus are not available
Quoted 7 lines · Sai Prakash Ranjan
Currently coresight etm and cpu-debug will go ahead with the probe even when corresponding cpus are not available and error out later in the probe path. In such cases, it is better to abort the probe earlier.
Without this, setting *nosmp* will throw below errors:
Quoted 11 lines
[ 5.910622] coresight-cpu-debug 850000.debug: Coresight debug-CPU0 initialized [ 5.914266] coresight-cpu-debug 852000.debug: CPU1 debug arch init failed [ 5.921474] coresight-cpu-debug 854000.debug: CPU2 debug arch init failed [ 5.928328] coresight-cpu-debug 856000.debug: CPU3 debug arch init failed [ 5.935330] coresight etm0: CPU0: ETM v4.0 initialized [ 5.941875] coresight-etm4x 85d000.etm: ETM arch init failed [ 5.946794] coresight-etm4x: probe of 85d000.etm failed with error -22 [ 5.952707] coresight-etm4x 85e000.etm: ETM arch init failed [ 5.958945] coresight-etm4x: probe of 85e000.etm failed with error -22 [ 5.964853] coresight-etm4x 85f000.etm: ETM arch init failed [ 5.971096] coresight-etm4x: probe of 85f000.etm failed with error -22
That is expected. What else do you expect ?
Quoted 11 lines
Signed-off-by Sai Prakash Ranjan <[email protected]>--- drivers/hwtracing/coresight/coresight-platform.c | 3 +++ 1 file changed, 3 insertions(+)drivers/hwtracing/coresight/coresight-platform.c +0
-0
drivers/hwtracing/coresight/coresight-platform.c static int of_coresight_get_cpu(struct device *dev) · line 172
Quoted 5 lines
drivers/hwtracing/coresight/coresight-platform.c +2
-0@@ -168,6 +168,9 @@ static int of_coresight_get_cpu(struct device *dev) cpu =of_cpu_node_to_id (dn);of_node_put (dn); +if (num_online_cpus () <= cpu) +return -ENODEV ;
That is a pointless and terribly wrong check. What if you have only 2 online CPUs (CPU0 and CPU4) and you were processing the ETM for CPU4 ?
More over you should simply let the driver handle a case where the CPU is not online. May be the driver could register a hotplug notifier and bring itself up when the CPU comes online.
So, please drop this patch.
Kind regards
Suzuki
Re: [PATCHv2 2/2] coresight: Abort probe if cpus are not available
Hi Suzuki,
Quoted 28 lines · Suzuki K Poulose
Quoted 7 lines · Sai Prakash Ranjan
Currently coresight etm and cpu-debug will go ahead with the probe even when corresponding cpus are not available and error out later in the probe path. In such cases, it is better to abort the probe earlier.
Without this, setting *nosmp* will throw below errors:
Quoted 11 lines
[ 5.910622] coresight-cpu-debug 850000.debug: Coresight debug-CPU0 initialized [ 5.914266] coresight-cpu-debug 852000.debug: CPU1 debug arch init failed [ 5.921474] coresight-cpu-debug 854000.debug: CPU2 debug arch init failed [ 5.928328] coresight-cpu-debug 856000.debug: CPU3 debug arch init failed [ 5.935330] coresight etm0: CPU0: ETM v4.0 initialized
[ 5.941875] coresight-etm4x 85d000.etm: ETM arch init failed
[ 5.946794] coresight-etm4x: probe of 85d000.etm failed with error -22 [ 5.952707] coresight-etm4x 85e000.etm: ETM arch init failed
[ 5.958945] coresight-etm4x: probe of 85e000.etm failed with error -22 [ 5.964853] coresight-etm4x 85f000.etm: ETM arch init failed
[ 5.971096] coresight-etm4x: probe of 85f000.etm failed with error -22That is expected. What else do you expect ?
Quoted 6 lines
Signed-off-by Sai Prakash Ranjan <[email protected]>---
drivers/hwtracing/coresight/coresight-platform.c| 3 +++1 file changed, 3 insertions(+)
Quoted 13 lines
drivers/hwtracing/coresight/coresight-platform.c static int of_coresight_get_cpu(struct device *dev) · line 171
Quoted 9 lines
drivers/hwtracing/coresight/coresight-platform.c +2
-0@@ -168,6 +168,9 @@ static int of_coresight_get_cpu(struct device *dev) cpu = of_cpu_node_to_id(dn); of_node_put(dn); + if (num_online_cpus() <= cpu) + return -ENODEV;That is a pointless and terribly wrong check. What if you have only 2 online CPUs (CPU0 and CPU4) and you were processing the ETM for CPU4 ?
Sorry, I did not consider such cases.
Quoted 6 lines
More over you should simply let the driver handle a case where the CPU is not online. May be the driver could register a hotplug notifier and bring itself up when the CPU comes online.
So, please drop this patch.
Sure I will drop this patch.
Thanks,
Sai
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation