coresight: Do not default to CPU0 for missing CPU phandle
Subsystems (4)
v5 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.
v5:
* Separate out the dt-bindings patch.
v4:
* Fix return for !CONFIG_ACPI and !CONFIG_OF.
v3:
* Addressed review comments from Suzuki and updated acpi_coresight_get_cpu.
* Removed patch 2 which had invalid check for online cpus.
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):
dt-bindings: coresight: Change CPU phandle to required property
coresight: Do not default to CPU0 for missing CPU phandle
.../bindings/arm/coresight-cpu-debug.txt | 4 ++-- .../devicetree/bindings/arm/coresight.txt | 8 +++++--- .../hwtracing/coresight/coresight-cpu-debug.c | 3 +++ drivers/hwtracing/coresight/coresight-etm3x.c | 3 +++ drivers/hwtracing/coresight/coresight-etm4x.c | 3 +++ .../hwtracing/coresight/coresight-platform.c | 20 +++++++++---------- 6 files changed, 26 insertions(+), 15 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 v5 1/2 dt-bindings: coresight: Change CPU phandle to required property
Do not assume the affinity to CPU0 if cpu phandle is omitted. Update the DT binding rules to reflect the same by changing it to a required property.
--- .../devicetree/bindings/arm/coresight-cpu-debug.txt | 4 ++-- Documentation/devicetree/bindings/arm/coresight.txt | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/arm/coresight-cpu-debug.txt +2 -2
@@ -26,8 +26,8 @@ Required properties: processor core is clocked by the internal CPU clock, so it is enabled with CPU clock by default. -- cpu : the CPU phandle the debug module is affined to. When omitted - the module is considered to belong to CPU0. +- cpu : the CPU phandle the debug module is affined to. Do not assume it + to default to CPU0 if omitted. Optional properties:
Documentation/devicetree/bindings/arm/coresight.txt +5 -3
@@ -59,6 +59,11 @@ its hardware characteristcs. * port or ports: see "Graph bindings for Coresight" below. +* Additional required property for Embedded Trace Macrocell (version 3.x and + version 4.x): + * cpu: the cpu phandle this ETM/PTM is affined to. Do not + assume it to default to CPU0 if omitted. + * Additional required properties for System Trace Macrocells (STM): * reg: along with the physical base address and length of the register set as described above, another entry is required to describe the
@@ -87,9 +92,6 @@ its hardware characteristcs. * arm,cp14: must be present if the system accesses ETM/PTM management 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. - * Optional property for TMC: * arm,buffer-size: size of contiguous buffer space for TMC ETR
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 v5 2/2 coresight: Do not default to CPU0 for missing CPU phandle
In reply to Sai Prakash RanjanCoresight 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. In coresight etm and cpu-debug drivers, abort the probe for such cases.
--- .../hwtracing/coresight/coresight-cpu-debug.c | 3 +++ drivers/hwtracing/coresight/coresight-etm3x.c | 3 +++ drivers/hwtracing/coresight/coresight-etm4x.c | 3 +++ .../hwtracing/coresight/coresight-platform.c | 20 +++++++++---------- 4 files changed, 19 insertions(+), 10 deletions(-)
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 +10 -10
@@ -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; }/*
@@ -310,7 +310,7 @@ of_get_coresight_platform_data(struct device *dev,static inline int of_coresight_get_cpu (struct device *dev) { -return 0 ; +return -ENODEV ; }#endif
@@ -734,14 +734,14 @@ static int acpi_coresight_get_cpu(struct device *dev)struct acpi_device *adev =ACPI_COMPANION (dev);if (!adev) -return 0 ; +return -ENODEV ; status =acpi_get_parent (adev->handle, &cpu_handle);if (ACPI_FAILURE (status)) -return 0 ; +return -ENODEV ; cpu =acpi_handle_to_logical_cpuid (cpu_handle);if (cpu >= nr_cpu_ids) -return 0 ; +return -ENODEV ;return cpu; }
@@ -769,7 +769,7 @@ acpi_get_coresight_platform_data(struct device *dev,static inline int acpi_coresight_get_cpu (struct device *dev) { -return 0 ; +return -ENODEV ; }#endif
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCHv5 1/2] dt-bindings: coresight: Change CPU phandle to required property
In reply to Sai Prakash RanjanHi Greg,
Quoted 7 lines · Sai Prakash Ranjan
Do not assume the affinity to CPU0 if cpu phandle is omitted. Update the DT binding rules to reflect the same by changing it to a required property.
Signed-off-by Sai Prakash Ranjan <[email protected]>Reviewed-by Suzuki K Poulose <[email protected]>
I'm all good with this patch - can you pick this up for the coming merge window? If not I'll simply keep it in my tree for 5.4.
Quoted 50 lines
--- .../devicetree/bindings/arm/coresight-cpu-debug.txt | 4 ++-- Documentation/devicetree/bindings/arm/coresight.txt | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-)Documentation/devicetree/bindings/arm/coresight-cpu-debug.txt +2
-2@@ -26,8 +26,8 @@ Required properties: processor core is clocked by the internal CPU clock, so it is enabled with CPU clock by default. -- cpu : the CPU phandle the debug module is affined to. When omitted - the module is considered to belong to CPU0. +- cpu : the CPU phandle the debug module is affined to. Do not assume it + to default to CPU0 if omitted. Optional properties:Documentation/devicetree/bindings/arm/coresight.txt +5
-4@@ -59,6 +59,11 @@ its hardware characteristcs. * port or ports: see "Graph bindings for Coresight" below. +* Additional required property for Embedded Trace Macrocell (version 3.x and + version 4.x): + * cpu: the cpu phandle this ETM/PTM is affined to. Do not + assume it to default to CPU0 if omitted. + * Additional required properties for System Trace Macrocells (STM): * reg: along with the physical base address and length of the register set as described above, another entry is required to describe the@@ -87,9 +92,6 @@ its hardware characteristcs. * arm,cp14: must be present if the system accesses ETM/PTM management 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. - * Optional property for TMC: * arm,buffer-size: size of contiguous buffer space for TMC ETR --QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Quoted 8 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. 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]>
Same with this one:
Quoted 115 lines
--- .../hwtracing/coresight/coresight-cpu-debug.c | 3 +++ drivers/hwtracing/coresight/coresight-etm3x.c | 3 +++ drivers/hwtracing/coresight/coresight-etm4x.c | 3 +++ .../hwtracing/coresight/coresight-platform.c | 20 +++++++++---------- 4 files changed, 19 insertions(+), 10 deletions(-)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 +10
-11@@ -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; }/* @@ -310,7 +310,7 @@ of_get_coresight_platform_data(struct device *dev,static inline int of_coresight_get_cpu (struct device *dev) { -return 0 ; +return -ENODEV ; }#endif @@ -734,14 +734,14 @@ static int acpi_coresight_get_cpu(struct device *dev)struct acpi_device *adev =ACPI_COMPANION (dev);if (!adev) -return 0 ; +return -ENODEV ; status =acpi_get_parent (adev->handle, &cpu_handle);if (ACPI_FAILURE (status)) -return 0 ; +return -ENODEV ; cpu =acpi_handle_to_logical_cpuid (cpu_handle);if (cpu >= nr_cpu_ids) -return 0 ; +return -ENODEV ;return cpu; }@@ -769,7 +769,7 @@ acpi_get_coresight_platform_data(struct device *dev,static inline int acpi_coresight_get_cpu (struct device *dev) { -return 0 ; +return -ENODEV ; }#endif --QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCHv5 1/2] dt-bindings: coresight: Change CPU phandle to required property
In reply to Mathieu PoirierQuoted 9 lines · Mathieu Poirier
Hi Greg,
Quoted 5 lines · Sai Prakash Ranjan
Do not assume the affinity to CPU0 if cpu phandle is omitted. Update the DT binding rules to reflect the same by changing it to a required property.
Quoted 9 lines
Quoted 2 lines
Signed-off-by Sai Prakash Ranjan <[email protected]>Reviewed-by Suzuki K Poulose <[email protected]>I'm all good with this patch - can you pick this up for the coming merge window? If not I'll simply keep it in my tree for 5.4.
Tested-by Mathieu Poirier <[email protected]>Reviewed-by Mathieu Poirier <[email protected]>
I think you missed adding Greg, adding him now ;)
-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
Re: [PATCHv5 1/2] dt-bindings: coresight: Change CPU phandle to required property
Quoted 13 lines · Sai Prakash Ranjan
Quoted 12 lines · Mathieu Poirier
Hi Greg,
Quoted 7 lines · Sai Prakash Ranjan
Do not assume the affinity to CPU0 if cpu phandle is omitted. Update the DT binding rules to reflect the same by changing it to a required property.
Signed-off-by Sai Prakash Ranjan <[email protected]>Reviewed-by Suzuki K Poulose <[email protected]>
Quoted 8 lines
Quoted 6 lines
I'm all good with this patch - can you pick this up for the coming merge window? If not I'll simply keep it in my tree for 5.4.
Tested-by Mathieu Poirier <[email protected]>Reviewed-by Mathieu Poirier <[email protected]>I think you missed adding Greg, adding him now ;)
I don't see any patch here for me to actually take :(
Re: [PATCHv5 1/2] dt-bindings: coresight: Change CPU phandle to required property
[ Trimming recipients list ]
Quoted 18 lines · Greg Kroah-Hartman
Quoted 16 lines · Sai Prakash Ranjan
Quoted 14 lines · Mathieu Poirier
Hi Greg,
Quoted 7 lines · Sai Prakash Ranjan
Do not assume the affinity to CPU0 if cpu phandle is omitted. Update the DT binding rules to reflect the same by changing it to a required property.
Signed-off-by Sai Prakash Ranjan <[email protected]>Reviewed-by Suzuki K Poulose <[email protected]>I'm all good with this patch - can you pick this up for the coming merge window? If not I'll simply keep it in my tree for 5.4.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Tested-by Mathieu Poirier <[email protected]>Reviewed-by Mathieu Poirier <[email protected]>I think you missed adding Greg, adding him now ;)
I don't see any patch here for me to actually take :(
I see what you're doing here ^_^
https://lore.kernel.org/patchwork/patch/1094935/
Regards.
Re: [PATCHv5 1/2] dt-bindings: coresight: Change CPU phandle to required property
Quoted 25 lines · Marc Gonzalez
[ Trimming recipients list ]
Quoted 21 lines · Greg Kroah-Hartman
Quoted 19 lines · Sai Prakash Ranjan
Quoted 16 lines · Mathieu Poirier
Hi Greg,
Quoted 7 lines · Sai Prakash Ranjan
Do not assume the affinity to CPU0 if cpu phandle is omitted. Update the DT binding rules to reflect the same by changing it to a required property.
Signed-off-by Sai Prakash Ranjan <[email protected]>Reviewed-by Suzuki K Poulose <[email protected]>I'm all good with this patch - can you pick this up for the coming merge window? If not I'll simply keep it in my tree for 5.4.
Tested-by Mathieu Poirier <[email protected]>Reviewed-by Mathieu Poirier <[email protected]>
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
I think you missed adding Greg, adding him now ;)
I don't see any patch here for me to actually take :(
I see what you're doing here ^_^
What can I do with a random url?
Please send patches as emails, if you want me to be able to actually take it.
greg k-h
Re: [PATCHv5 1/2] dt-bindings: coresight: Change CPU phandle to required property
Quoted 32 lines · Greg Kroah-Hartman
Quoted 31 lines · Marc Gonzalez
[ Trimming recipients list ]
Quoted 18 lines · Greg Kroah-Hartman
Quoted 16 lines · Sai Prakash Ranjan
Quoted 14 lines · Mathieu Poirier
Hi Greg,
Quoted 7 lines · Sai Prakash Ranjan
Do not assume the affinity to CPU0 if cpu phandle is omitted. Update the DT binding rules to reflect the same by changing it to a required property.
Signed-off-by Sai Prakash Ranjan <[email protected]>Reviewed-by Suzuki K Poulose <[email protected]>I'm all good with this patch - can you pick this up for the coming merge window? If not I'll simply keep it in my tree for 5.4.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Tested-by Mathieu Poirier <[email protected]>Reviewed-by Mathieu Poirier <[email protected]>I think you missed adding Greg, adding him now ;)
I don't see any patch here for me to actually take :(
I see what you're doing here ^_^
Quoted 9 lines
Quoted 1 line
What can I do with a random url?
Please send patches as emails, if you want me to be able to actually take it.
greg k-h
No worries I will resend them. And thanks Marc :)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCHv5 1/2] dt-bindings: coresight: Change CPU phandle to required property
In reply to Greg Kroah-HartmanQuoted 5 lines · Greg Kroah-Hartman
Quoted 1 line · Marc Gonzalez
What can I do with a random url?
I dunno, click it? ^_^
More seriously, patchwork provides individual patches, as well as patch series, in the same mbox format used by MUAs, e.g.
https://lore.kernel.org/patchwork/patch/1094935/mbox/
https://lore.kernel.org/patchwork/series/400118/mbox/
Then 'git am' works exactly as expected.
I suspect you know all this, and it's too big a hassle vs your usual work flow, considering the volume of patches you handle.
Just wanted to point it out to those who might not know.
Regards.
Re: [PATCHv5 1/2] dt-bindings: coresight: Change CPU phandle to required property
Quoted 13 lines · Marc Gonzalez
Quoted 5 lines · Greg Kroah-Hartman
Quoted 1 line · Marc Gonzalez
What can I do with a random url?
I dunno, click it? ^_^
More seriously, patchwork provides individual patches, as well as patch series, in the same mbox format used by MUAs, e.g.
Quoted 7 lines
https://lore.kernel.org/patchwork/patch/1094935/mbox/
https://lore.kernel.org/patchwork/series/400118/mbox/Then 'git am' works exactly as expected.
I suspect you know all this, and it's too big a hassle vs your usual work flow, considering the volume of patches you handle.
And considering that at some times, while traveling, I can _only_ get email, not web access, so I can't rely on patchwork.
thanks,
greg k-h