diff mbox series

pdbg: Fix target selection when using I2C

Message ID 20180524034924.4478-1-alistair@popple.id.au
State Accepted
Headers show
Series pdbg: Fix target selection when using I2C | expand

Commit Message

Alistair Popple May 24, 2018, 3:49 a.m. UTC
I2C based access is unique in that to access the PIB on secondary processors we
need to traverse the PIB on the primary processor. This confuses our current
selection logic as every core becomes a child of the primary PIB. Hopefully our
selection logic will get rewritten soon, but in the meantime add a check to
ensure a cores immediate parent PIB matches the currently selected processor.

Signed-off-by: Alistair Popple <alistair@popple.id.au>
---
 src/main.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/main.c b/src/main.c
index 20f5319..4a0b3df 100644
--- a/src/main.c
+++ b/src/main.c
@@ -454,12 +454,16 @@  static int target_selection(void)
 			target_select(pib);
 			pdbg_for_each_target("core", pib, chip) {
 				int chip_index = pdbg_target_index(chip);
-				target_select(chip);
+				if (pdbg_parent_index(chip, "pib") != proc_index)
+					continue;
+
 				if (chipsel[proc_index][chip_index]) {
+					target_select(chip);
 					pdbg_for_each_target("thread", chip, thread) {
 						int thread_index = pdbg_target_index(thread);
-						target_select(thread);
-						if (!threadsel[proc_index][chip_index][thread_index])
+						if (threadsel[proc_index][chip_index][thread_index])
+							target_select(thread);
+						else
 							target_unselect(thread);
 					}
 				} else