[09/10] libpdbg: Check if scom controllers are exposed

Message ID 20180531052915.31171-9-rashmica.g@gmail.com
State Changes Requested
Headers show
Series
  • [01/10] libpdbg: Print the name of the instruction when erroring
Related show

Commit Message

Rashmica Gupta May 31, 2018, 5:29 a.m.
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 | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Alistair Popple June 15, 2018, 1:42 a.m. | #1
On Thursday, 31 May 2018 3:29:14 PM AEST Rashmica Gupta wrote:
> 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 | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/libpdbg/host.c b/libpdbg/host.c
> index 5e0e08f..8dd3725 100644
> --- a/libpdbg/host.c
> +++ b/libpdbg/host.c
> @@ -95,6 +95,14 @@ static int host_pib_probe(struct pdbg_target *target)
>  	if (chip_id == -1)
>  		goto out;
>  
> +	/* This check should probably be done earlier */
> +	if (access(XSCOM_BASE_PATH, F_OK) == -1)
> +	{
> +		fprintf(stderr, "Can not access %s. ", XSCOM_BASE_PATH);
> +		fprintf(stderr, "Is CONFIG_SCOM_DEBUGFS set? ");
> +		fprintf(stderr, "You may need to re-run the command as root.\n");

Any chance you could update this to use the logging API? (ie.
pdbg_log(PDBG_ERROR, ...)). Otherwise looks good. Thanks!

- Alistair

> +	}
> +
>  	if (asprintf(&access_fn, "%s/%08d/access", XSCOM_BASE_PATH, chip_id) < 0)
>  		goto out;
>  
>

Patch

diff --git a/libpdbg/host.c b/libpdbg/host.c
index 5e0e08f..8dd3725 100644
--- a/libpdbg/host.c
+++ b/libpdbg/host.c
@@ -95,6 +95,14 @@  static int host_pib_probe(struct pdbg_target *target)
 	if (chip_id == -1)
 		goto out;
 
+	/* This check should probably be done earlier */
+	if (access(XSCOM_BASE_PATH, F_OK) == -1)
+	{
+		fprintf(stderr, "Can not access %s. ", XSCOM_BASE_PATH);
+		fprintf(stderr, "Is CONFIG_SCOM_DEBUGFS set? ");
+		fprintf(stderr, "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;