diff mbox series

[08/19] libpdbg: Check if scom controllers are exposed

Message ID 20180829015047.7355-9-rashmica.g@gmail.com
State Superseded
Headers show
Series Basic gdbserver for POWER8 | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied
snowpatch_ozlabs/build-multiarch success Test build-multiarch on branch master

Commit Message

Rashmica Gupta Aug. 29, 2018, 1:50 a.m. UTC
If CONFIG_SCOM_DEBUGFS is not set in the running kernel then
the scom controllers are not exposed and so using getscom
won't work. Add check for /sys/kernel/debug/powerpc/scom to
give a more useful error message.

Signed-off-by: Rashmica Gupta <rashmica.g@gmail.com>
---
 libpdbg/host.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libpdbg/host.c b/libpdbg/host.c
index 483e048..eb627be 100644
--- a/libpdbg/host.c
+++ b/libpdbg/host.c
@@ -95,7 +95,15 @@  static int host_pib_probe(struct pdbg_target *target)
 	if (chip_id == -1)
 		goto out;
 
-	if (asprintf(&access_fn, "%s/%08x/access", XSCOM_BASE_PATH, chip_id) < 0)
+	/* This check should probably be done earlier */
+	if (access(XSCOM_BASE_PATH, F_OK) == -1)
+	{
+		PR_ERROR("Can not access %s. ", XSCOM_BASE_PATH);
+		PR_ERROR("Is CONFIG_SCOM_DEBUGFS set? ");
+		PR_ERROR("You may need to re-run the command as root.\n");
+	}
+
+	if (asprintf(&access_fn, "%s/%08d/access", XSCOM_BASE_PATH, chip_id) < 0)
 		goto out;
 
 	*fd = open(access_fn, O_RDWR);