Skip to contentSkip to conversation

perf/arm-cmn: Workaround AmpereOneX errata AC04_MESH_1 (incorrect child count)

PATCH In review Ilkka Koskinen 3 participants 4 messages Feb 5, 2024 – Feb 9, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf/arm-cmn: Workaround AmpereOneX errata AC04_MESH_1 (incorrect child count)

AmpereOneX mesh implementation has a bug in HN-P nodes that makes them report incorrect child count. The failing crosspoints report 8 children while they only have two.

When the driver tries to access the inexistent child nodes, it believes it has reached an invalid node type and probing fails. The workaround is to ignore those incorrect child nodes and continue normally.

---
 drivers/perf/arm-cmn.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/perf/arm-cmn.c +25 -0
index c584165b13ba..97fed8ec3693 100644
@@ -2168,6 +2168,23 @@ static enum cmn_node_type arm_cmn_subtype(enum cmn_node_type type)
 	}
 }
 
+static inline bool arm_cmn_is_ampereonex_bug(const struct arm_cmn *cmn,
+					     struct arm_cmn_node *dn,
+					     u16 child_count, int child)
+{
+	/*
+	 * The bug occurs only when a crosspoint reports 8 children
+	 * while it only has two HN-P child nodes.
+	 */
+	dn -= 2;
+
+	if (arm_cmn_model(cmn) == CMN650 && child_count == 8 &&
+	    child == 2 && dn->type == CMN_TYPE_HNP)
+		return true;
+
+	return false;
+}
+
 static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
 {
 	void __iomem *cfg_region;
@@ -2292,6 +2309,14 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
 
 		for (j = 0; j < child_count; j++) {
 			reg = readq_relaxed(xp_region + child_poff + j * 8);
+			if (reg == 0)
+				if (arm_cmn_is_ampereonex_bug(cmn, dn, child_count, j))
+					/*
+					 * We know there are only two real children and the rest 6
+					 * are inexistent. Thus, we can skip the rest of the loop
+					 */
+					break;
+
 			/*
 			 * Don't even try to touch anything external, since in general
 			 * we haven't a clue how to power up arbitrary CHI requesters.
Signature · 1 line
2.40.1
maintainer
#1 lore raw
Quoted 3 lines · Ilkka Koskinen

AmpereOneX mesh implementation has a bug in HN-P nodes that makes them report incorrect child count. The failing crosspoints report 8 children while they only have two.

Ooh, fun :)

Quoted 39 lines

When the driver tries to access the inexistent child nodes, it believes it has reached an invalid node type and probing fails. The workaround is to ignore those incorrect child nodes and continue normally.

---
  drivers/perf/arm-cmn.c | 25 +++++++++++++++++++++++++
  1 file changed, 25 insertions(+)
drivers/perf/arm-cmn.c +17 -0
index c584165b13ba..97fed8ec3693 100644
@@ -2168,6 +2168,23 @@ static enum cmn_node_type arm_cmn_subtype(enum cmn_node_type type)
  	}
  }
 
+static inline bool arm_cmn_is_ampereonex_bug(const struct arm_cmn *cmn,
+					     struct arm_cmn_node *dn,
+					     u16 child_count, int child)
+{
+	/*
+	 * The bug occurs only when a crosspoint reports 8 children
+	 * while it only has two HN-P child nodes.
+	 */
+	dn -= 2;
+
+	if (arm_cmn_model(cmn) == CMN650 && child_count == 8 &&
+	    child == 2 && dn->type == CMN_TYPE_HNP)
+		return true;
+
+	return false;
+}
+
  static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
  {
  	void __iomem *cfg_region;
@@ -2292,6 +2309,14 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
 

drivers/perf/arm-cmn.c static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset) · line 2319

Quoted 10 lines
drivers/perf/arm-cmn.c +8 -0
  		for (j = 0; j < child_count; j++) {
  			reg = readq_relaxed(xp_region + child_poff + j * 8);
+			if (reg == 0)
+				if (arm_cmn_is_ampereonex_bug(cmn, dn, child_count, j))
+					/*
+					 * We know there are only two real children and the rest 6
+					 * are inexistent. Thus, we can skip the rest of the loop
+					 */
+					break;
+

TBH I don't see much harm in taking an even simpler approach, so I'd be inclined to not bother being all that specific beyond documenting it, something like the below:

Cheers,
Robin.

----->8-----

drivers/perf/arm-cmn.c +11 -0
index c584165b13ba..7e3aa7e2345f 100644
@@ -2305,6 +2305,17 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
 				dev_dbg(cmn->dev, "ignoring external node %llx\n", reg);
 				continue;
 			}
+			/*
+			 * AmpereOneX erratum AC04_MESH_1 makes some XPs report a bogus
+			 * child count larger than the number of valid child pointers.
+			 * A child offset of 0 can only occur on CMN-600; otherwise it
+			 * would imply the root node being its own grandchild, which
+			 * we can safely dismiss in general.
+			 */
+			if (reg == 0 && cmn->part != PART_CMN600) {
+				dev_dbg(cmn->dev, "bogus child pointer?\n");
+				continue;
+			}
 
 			arm_cmn_init_node_info(cmn, reg & CMN_CHILD_NODE_ADDR, dn);
 
author Tested-by
#2 lore raw
Quoted 55 lines · Robin Murphy
Quoted 3 lines · Ilkka Koskinen

AmpereOneX mesh implementation has a bug in HN-P nodes that makes them report incorrect child count. The failing crosspoints report 8 children while they only have two.

Ooh, fun :)

Quoted 48 lines

When the driver tries to access the inexistent child nodes, it believes it has reached an invalid node type and probing fails. The workaround is to ignore those incorrect child nodes and continue normally.

---
  drivers/perf/arm-cmn.c | 25 +++++++++++++++++++++++++
  1 file changed, 25 insertions(+)
drivers/perf/arm-cmn.c +20 -0
index c584165b13ba..97fed8ec3693 100644
@@ -2168,6 +2168,23 @@ static enum cmn_node_type arm_cmn_subtype(enum 
 cmn_node_type type)
  	}
  }
  +static inline bool arm_cmn_is_ampereonex_bug(const struct arm_cmn *cmn,
+					     struct arm_cmn_node *dn,
+					     u16 child_count, int child)
+{
+	/*
+	 * The bug occurs only when a crosspoint reports 8 children
+	 * while it only has two HN-P child nodes.
+	 */
+	dn -= 2;
+
+	if (arm_cmn_model(cmn) == CMN650 && child_count == 8 &&
+	    child == 2 && dn->type == CMN_TYPE_HNP)
+		return true;
+
+	return false;
+}
+
  static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
  {
  	void __iomem *cfg_region;
@@ -2292,6 +2309,14 @@ static int arm_cmn_discover(struct arm_cmn *cmn, 
 unsigned int rgn_offset)
    		for (j = 0; j < child_count; j++) {
  			reg = readq_relaxed(xp_region + child_poff + j * 8);
+			if (reg == 0)
+				if (arm_cmn_is_ampereonex_bug(cmn, dn, 
 child_count, j))
+					/*
+					 * We know there are only two real 

children and the rest 6

drivers/perf/arm-cmn.c +1 -0
+					 * are inexistent. Thus, we can skip 
Quoted 8 lines

drivers/perf/arm-cmn.c

Quoted 4 lines

the rest of the loop

drivers/perf/arm-cmn.c +3 -0
+					 */
+					break;
+

TBH I don't see much harm in taking an even simpler approach, so I'd be inclined to not bother being all that specific beyond documenting it, something like the below:

Sounds good to me.

Quoted 32 lines

Cheers,
Robin.

----->8-----

drivers/perf/arm-cmn.c +2 -0
index c584165b13ba..7e3aa7e2345f 100644
@@ -2305,6 +2305,17 @@ static int arm_cmn_discover(struct arm_cmn *cmn, 
 unsigned int rgn_offset)
 				dev_dbg(cmn->dev, "ignoring external node 
 %llx\n", reg);
 				continue;
 			}
+			/*
+			 * AmpereOneX erratum AC04_MESH_1 makes some XPs 

report a bogus

drivers/perf/arm-cmn.c +1 -0
+			 * child count larger than the number of valid child 

pointers.

drivers/perf/arm-cmn.c +1 -0
+			 * A child offset of 0 can only occur on CMN-600; 

otherwise it

drivers/perf/arm-cmn.c +1 -0
+			 * would imply the root node being its own 

grandchild, which

drivers/perf/arm-cmn.c +6 -0
+			 * we can safely dismiss in general.
+			 */
+			if (reg == 0 && cmn->part != PART_CMN600) {
+				dev_dbg(cmn->dev, "bogus child pointer?\n");
+				continue;
+			}
 			arm_cmn_init_node_info(cmn, reg & 
Quoted 2 lines

CMN_CHILD_NODE_ADDR, dn);

Cheers, Ilkka

maintainer
#3 lore raw
Quoted 18 lines · Ilkka Koskinen
Quoted 17 lines · Robin Murphy

On 2024-02-05 7:46 pm, Ilkka Koskinen wrote:

drivers/perf/arm-cmn.c +7 -0
index c584165b13ba..7e3aa7e2345f 100644
@@ -2305,6 +2305,17 @@ static int arm_cmn_discover(struct arm_cmn *cmn,
 unsigned int rgn_offset)
 				dev_dbg(cmn->dev, "ignoring external node %llx\n", reg);
 				continue;
 			}
+			/*
+			 * AmpereOneX erratum AC04_MESH_1 makes some XPs report a bogus
+			 * child count larger than the number of valid child pointers.
+			 * A child offset of 0 can only occur on CMN-600; otherwise it
+			 * would imply the root node being its own grandchild, which
+			 * we can safely dismiss in general.
+			 */
Quoted 8 lines

drivers/perf/arm-cmn.c static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset) · line 2321

Quoted 6 lines
drivers/perf/arm-cmn.c +4 -0
+			if (reg == 0 && cmn->part != PART_CMN600) {
+				dev_dbg(cmn->dev, "bogus child pointer?\n");
+				continue;
+			}
 			arm_cmn_init_node_info(cmn, reg & CMN_CHILD_NODE_ADDR, dn);
 

Mind sending that out as a proper patch that I can pick up, please?

Cheers,

Will