[Pdbg] [PATCH v3 06/25] libpdbg: Backend device tree cannot be overriden
Alistair Popple
alistair at popple.id.au
Mon Apr 20 12:46:58 AEST 2020
Reviewed-by: Alistair Popple <alistair at popple.id.au>
On Friday, 17 April 2020 5:07:30 PM AEST Amitay Isaacs wrote:
> With drivers getting registered per backend, backend needs to be
> initialised before any device tree can be parsed. PDBG_BACKEND_DTB
> allowed to override backend device tree without specifying backend,
> which cannot work any more.
>
> To be able to dynamically update backend introduce PDBG_BACKEND and
> PDBG_BACKEND_OPTION variables instead of PDBG_BACKEND_DTB.
>
> Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
> ---
> libpdbg/dtb.c | 30 ++++++++++++++++++++++--------
> tests/test_p9_fapi_translation.sh | 2 +-
> 2 files changed, 23 insertions(+), 9 deletions(-)
>
> diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c
> index ef51718..077bc62 100644
> --- a/libpdbg/dtb.c
> +++ b/libpdbg/dtb.c
> @@ -308,21 +308,36 @@ const char *pdbg_get_backend_option(void)
> struct pdbg_dtb *pdbg_default_dtb(void *system_fdt)
> {
> struct pdbg_dtb *dtb = &pdbg_dtb;
> - const char *fdt;
> + const char *fdt, *backend;
>
> dtb->backend.fdt = NULL;
> dtb->system.fdt = system_fdt;
>
> - fdt = getenv("PDBG_BACKEND_DTB");
> - if (fdt)
> - mmap_dtb(fdt, false, &dtb->backend);
> -
> fdt = getenv("PDBG_DTB");
> if (fdt)
> mmap_dtb(fdt, false, &dtb->system);
>
> - if (dtb->backend.fdt && dtb->system.fdt)
> - goto done;
> + backend = getenv("PDBG_BACKEND");
> + if (backend) {
> + const char *arg;
> +
> + arg = getenv("PDBG_BACKEND_OPTION");
> +
> + if (!strcmp(backend, "fsi"))
> + pdbg_set_backend(PDBG_BACKEND_FSI, arg);
> + else if (!strcmp(backend, "i2c"))
> + pdbg_set_backend(PDBG_BACKEND_I2C, arg);
> + else if (!strcmp(backend, "kernel"))
> + pdbg_set_backend(PDBG_BACKEND_KERNEL, arg);
> + else if (!strcmp(backend, "fake"))
> + pdbg_set_backend(PDBG_BACKEND_FAKE, arg);
> + else if (!strcmp(backend, "host"))
> + pdbg_set_backend(PDBG_BACKEND_HOST, arg);
> + else if (!strcmp(backend, "cronus"))
> + pdbg_set_backend(PDBG_BACKEND_CRONUS, arg);
> + else
> + pdbg_log(PDBG_ERROR, "Invalid backend '%s', ignoring\n", backend);
> + }
>
> if (!pdbg_backend)
> pdbg_backend = default_backend();
> @@ -412,7 +427,6 @@ struct pdbg_dtb *pdbg_default_dtb(void *system_fdt)
> break;
> }
>
> -done:
> return dtb;
> }
>
> diff --git a/tests/test_p9_fapi_translation.sh
> b/tests/test_p9_fapi_translation.sh index a5a09b1..9891d39 100755
> --- a/tests/test_p9_fapi_translation.sh
> +++ b/tests/test_p9_fapi_translation.sh
> @@ -4,7 +4,7 @@
>
> test_group "p9 fapi translation tests"
>
> -export PDBG_BACKEND_DTB=p9-kernel.dtb
> +export PDBG_BACKEND=kernel
> export PDBG_DTB=p9.dtb
>
> test_result 0 <<EOF
More information about the Pdbg
mailing list