[Pdbg] [PATCH v2 5/7] libpdbg: Rescan fsi bus only once
Alistair Popple
alistair at popple.id.au
Mon Jun 15 17:31:25 AEST 2020
Looks good to me. It's up to higher level system logic to manage scanning of
the busses in relation to power on/off so in theory pdbg shouldn't have to
initiate a rescan anyway.
Reviewed-by: Alistair Popple <alistair at popple.id.au>
On Wednesday, 10 June 2020 3:24:24 PM AEST Amitay Isaacs 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>
> ---
> 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;
> }
>
>
More information about the Pdbg
mailing list