[Pdbg] [PATCH v2 5/7] libpdbg: Rescan fsi bus only once

Joel Stanley joel at jms.id.au
Tue Jun 16 11:32:35 AEST 2020


On Wed, 10 Jun 2020 at 05:25, Amitay Isaacs <amitay at ozlabs.org> wrote:
>
> On rescan, kernel driver re-creates all the slave devices.  This
> invalidates all the slave deviced opened before the scan.  So avoid
> scanning fsi bus, if any of the devices are opened.
>
> Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>

This looks good.

Reviewed-by: Joel Stanley <joel at jms.id.au>


> ---
>  libpdbg/kernel.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/libpdbg/kernel.c b/libpdbg/kernel.c
> index 2cc81f2..c63ef93 100644
> --- a/libpdbg/kernel.c
> +++ b/libpdbg/kernel.c
> @@ -149,6 +149,7 @@ int kernel_fsi_probe(struct pdbg_target *target)
>         const char *kernel_path = kernel_get_fsi_path();
>         const char *fsi_path;
>         char *path;
> +       static bool first_probe = true;
>
>         if (!kernel_path)
>                 return -1;
> @@ -163,23 +164,30 @@ int kernel_fsi_probe(struct pdbg_target *target)
>         }
>
>         while (tries) {
> -               /* Open first raw device */
>                 fsi->fd = open(path, O_RDWR | O_SYNC);
>                 if (fsi->fd >= 0) {
>                         free(path);
> +                       first_probe = false;
>                         return 0;
>                 }
>                 tries--;
>
> -               /* Scan */
> -               kernel_fsi_scan_devices();
> -               sleep(1);
> -       }
> -       if (fsi->fd < 0) {
> -               PR_ERROR("Unable to open %s\n", path);
> -               free(path);
> +               /*
> +                * On fsi bus rescan, kernel re-creates all the slave device
> +                * entries.  It means any currently open devices will be
> +                * invalid and need to be re-opened.  So avoid scanning if
> +                * some devices are already probed.
> +                */
> +               if (first_probe) {
> +                       kernel_fsi_scan_devices();
> +                       sleep(1);
> +               } else {
> +                       break;
> +               }
>         }
>
> +       PR_ERROR("Unable to open %s\n", path);
> +       free(path);
>         return -1;
>  }
>
> --
> 2.26.2
>
> --
> Pdbg mailing list
> Pdbg at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/pdbg


More information about the Pdbg mailing list