[Pdbg] [PATCH 2/4] libpdbg: Use index instead of chip-id for id

Amitay Isaacs amitay at ozlabs.org
Mon Dec 3 14:27:56 AEDT 2018


Instead of using two different ways to id various chiplets, consistently
use "index" property.

Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
 libpdbg/host.c |  6 +++---
 libpdbg/htm.c  | 11 +++++++----
 p9-host.dts.m4 |  2 +-
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/libpdbg/host.c b/libpdbg/host.c
index 1cc1b48..163b991 100644
--- a/libpdbg/host.c
+++ b/libpdbg/host.c
@@ -85,13 +85,13 @@ static int host_pib_probe(struct pdbg_target *target)
 	struct pib *pib = target_to_pib(target);
 	int *fd;
 	char *access_fn;
-	uint32_t chip_id;
+	uint32_t index;
 
 	fd = malloc(sizeof(fd));
 	if (!fd)
 		return -1;
 
-	chip_id = pdbg_target_chip_id(target);
+	index = pdbg_target_index(target);
 
 	/* This check should probably be done earlier */
 	if (access(XSCOM_BASE_PATH, F_OK) == -1)
@@ -101,7 +101,7 @@ static int host_pib_probe(struct pdbg_target *target)
 		PR_ERROR("You may need to re-run the command as root.\n");
 	}
 
-	if (asprintf(&access_fn, "%s/%08x/access", XSCOM_BASE_PATH, chip_id) < 0)
+	if (asprintf(&access_fn, "%s/%08x/access", XSCOM_BASE_PATH, index) < 0)
 		goto out;
 
 	*fd = open(access_fn, O_RDWR);
diff --git a/libpdbg/htm.c b/libpdbg/htm.c
index 1ca176d..dd25b24 100644
--- a/libpdbg/htm.c
+++ b/libpdbg/htm.c
@@ -548,13 +548,16 @@ static int is_startable(struct htm_status *status)
 
 static char *get_debugfs_file(struct htm *htm, const char *file)
 {
-	uint32_t chip_id;
+	struct pdbg_target *pib;
+	uint32_t index;
 	char *filename;
 
-	chip_id = pdbg_target_chip_id(&htm->target);
-	if (asprintf(&filename, "%s/%08x/%s", DEBUGFS_MEMTRACE, chip_id, file) == -1) {
+	pib = pdbg_target_parent("pib", &htm->target);
+	assert(pib);
+	index = pdbg_target_index(pib);
+	if (asprintf(&filename, "%s/%08x/%s", DEBUGFS_MEMTRACE, index, file) == -1) {
 		PR_ERROR("Couldn't asprintf() '%s/%08x/size': %m\n",
-				DEBUGFS_MEMTRACE, chip_id);
+				DEBUGFS_MEMTRACE, index);
 		return NULL;
 	}
 
diff --git a/p9-host.dts.m4 b/p9-host.dts.m4
index e1ec779..c6f5090 100644
--- a/p9-host.dts.m4
+++ b/p9-host.dts.m4
@@ -21,7 +21,7 @@
 	      compatible = "ibm,host-pib";
 	      reg = <0x8>;
 	      chip-id = <0x8>;
-	      index = <0x1>;
+	      index = <0x8>;
 	      include(p9-pib.dts.m4)dnl
 	};
 };
-- 
2.19.2



More information about the Pdbg mailing list