Message ID | 20211210064947.73361-11-takahiro.akashi@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | efi_loader: more tightly integrate UEFI disks to driver model | expand |
On Fri, 10 Dec 2021 at 00:00, AKASHI Takahiro <takahiro.akashi@linaro.org> wrote: > > virtio_init() enumerates all the peripherals that are to be materialised > with udevices(UCLASS_VIRIO) and creates particular device instances > (UCLASS_BlK or whatever else) as children. > On the other hand, device_probe() won't be invoked against those resultant > udevices unlike other ordinary device drivers do in the driver model. > > This is particularly incovenient when we want to add "event notification" > callback so that we will be able to automatically create all efi_disk > objects in a later patch. > > With this patch applied, "virtio scan" will work in a similar way > to "scsi rescan", "usb start" or others in term of 'probe' semantics. > > I didn't add this change to virtio_init() itself because this function > may be called in board_init_r() (indrectly in board_late_init()) > before UEFI subsustem is initialized. > > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> > --- > cmd/virtio.c | 21 +++++++++++++++++++-- > 1 file changed, 19 insertions(+), 2 deletions(-) Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/cmd/virtio.c b/cmd/virtio.c index 3dace5344f7e..ea3ed2e631e4 100644 --- a/cmd/virtio.c +++ b/cmd/virtio.c @@ -17,8 +17,25 @@ static int do_virtio(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { if (argc == 2 && !strcmp(argv[1], "scan")) { - /* make sure all virtio devices are enumerated */ - virtio_init(); + /* + * make sure all virtio devices are enumerated. + * Do the same as virtio_init(), but also call + * device_probe() for children (i.e. virtio devices) + */ + struct udevice *bus, *child; + int ret; + + ret = uclass_first_device(UCLASS_VIRTIO, &bus); + if (ret) + return CMD_RET_FAILURE; + + while (bus) { + device_foreach_child_probe(child, bus) + ; + ret = uclass_next_device(&bus); + if (ret) + break; + } return CMD_RET_SUCCESS; }
virtio_init() enumerates all the peripherals that are to be materialised with udevices(UCLASS_VIRIO) and creates particular device instances (UCLASS_BlK or whatever else) as children. On the other hand, device_probe() won't be invoked against those resultant udevices unlike other ordinary device drivers do in the driver model. This is particularly incovenient when we want to add "event notification" callback so that we will be able to automatically create all efi_disk objects in a later patch. With this patch applied, "virtio scan" will work in a similar way to "scsi rescan", "usb start" or others in term of 'probe' semantics. I didn't add this change to virtio_init() itself because this function may be called in board_init_r() (indrectly in board_late_init()) before UEFI subsustem is initialized. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> --- cmd/virtio.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)