Sai,
Thanks for the patch. Please could you change the subject to :
"coresight: Do not default to CPU0 for missing CPU phandle"
On 20/06/2019 14:45, Sai Prakash Ranjan wrote:
Affinity defaults to CPU0 in case of missing CPU phandle
and this leads to crashes in some cases because of such
wrong assumption. Fix this by returning -ENODEV in
Thats not the right justification. Causing crashes is due to
bad DT/firmware. I would be happy with something like :
"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, you must
1) update the devicetree/bindings document to reflect the same.
2) update the drivers to take appropriate action on the missing CPU
ÂÂ where they are expected (e.g, CPU-debug, etm*), to prevent
ÂÂ breaking a bisect.
coresight platform for such cases and then handle it
in the coresight drivers.
Signed-off-by: Sai Prakash Ranjan <saiprakash.ranjan@xxxxxxxxxxxxxx>
---
 drivers/hwtracing/coresight/coresight-platform.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c
index 3c5ceda8db24..b1ea60c210e1 100644
--- a/drivers/hwtracing/coresight/coresight-platform.c
+++ b/drivers/hwtracing/coresight/coresight-platform.c
@@ -160,15 +160,17 @@ static int of_coresight_get_cpu(struct device *dev)
ÂÂÂÂÂ if (!dev->of_node)
ÂÂÂÂÂÂÂÂÂ return 0;
+
ÂÂÂÂÂ dn = of_parse_phandle(dev->of_node, "cpu", 0);
-ÂÂÂ /* Affinity defaults to CPU0 */
+
+ÂÂÂ /* Affinity defaults to invalid if no cpu nodes are found*/
The code is self explanatory here. You could drop the comment.
ÂÂÂÂÂ 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;
 }
Suzuki