mbox series

[v5,00/15] Do not stop uclass iteration on error

Message ID cover.1664314042.git.msuchanek@suse.de
Headers show
Series Do not stop uclass iteration on error | expand

Message

Michal Suchánek Sept. 27, 2022, 9:37 p.m. UTC
Hello,

this patch series fixes the simple uclass iterators to be usable for
iterating uclasses even if some devices fail to probe.

Before this series when a probe error happens an error is returned
without any device pointer, and iteration cannot continue to devices
that happen to be after the failing device in the uclass list.

This is rarely expected, nor clearly documented, and for the most part
not useful in any way.

All but the last patch are new in v4 removing problematic iterator use.

v5:

Split off patches that can be applied independently

Fix uclass_foreach_dev_probe, pci_sriov_init, and sysinfo_get to work
after the uclass_first_device_err change.

Document that uclass_first_device_err and uclass_first_device_check can
return non-activated device on error.

Consolidate multiple similar cleanups into one patch.

Thanks

Michal

Michal Suchanek (15):
  dm: core: Fix uclass_probe_all to really probe all devices
  dm: treewide: Do not opencode uclass_probe_all()
  dm: pci: Fix device PCI iteration
  bootstd: Fix listing boot devices
  usb: ether: Fix error handling in usb_ether_init
  stdio: Fix class iteration in stdio_add_devices()
  video: ipuv3: Fix error handling when getting the display
  w1: Fix bus counting in w1_get_bus
  cmd: List all uclass devices regardless of probe error
  dm: treewide: Use uclass_first_device_err when accessing one device
  dm: treewide: Use uclass_next_device_err when accessing second device
  dm: blk: Do not use uclass_next_device_err
  dm: core: Switch uclass_*_device_err to use uclass_*_device_check
  dm: treewide: Do not use the return value of simple uclass iterator
  dm: core: Do not stop uclass iteration on error

 arch/arm/mach-k3/j721s2_init.c            |  2 +-
 arch/arm/mach-omap2/am33xx/board.c        |  4 +-
 arch/x86/cpu/broadwell/cpu.c              |  4 +-
 arch/x86/cpu/intel_common/cpu.c           |  4 +-
 arch/x86/lib/pinctrl_ich6.c               |  4 +-
 board/atmel/common/mac_eeprom.c           |  2 +-
 board/intel/cougarcanyon2/cougarcanyon2.c |  4 +-
 boot/bootdev-uclass.c                     |  7 +--
 cmd/adc.c                                 | 22 ++++-----
 cmd/demo.c                                | 16 ++++---
 cmd/gpio.c                                | 15 ++++--
 cmd/pmic.c                                | 15 +++---
 cmd/regulator.c                           | 13 +++---
 cmd/virtio.c                              |  9 ++--
 common/stdio.c                            | 33 ++++++-------
 drivers/block/blk-uclass.c                | 16 +++----
 drivers/core/uclass.c                     | 56 ++++++++++++-----------
 drivers/cpu/cpu-uclass.c                  | 20 ++------
 drivers/dma/dma-uclass.c                  |  7 ++-
 drivers/gpio/gpio-uclass.c                | 14 +++---
 drivers/mmc/omap_hsmmc.c                  |  2 +-
 drivers/pci/pci-uclass.c                  | 26 ++++-------
 drivers/serial/serial-uclass.c            |  2 +-
 drivers/serial/serial_bcm283x_mu.c        |  2 +-
 drivers/serial/serial_bcm283x_pl011.c     |  2 +-
 drivers/sysinfo/sysinfo-uclass.c          | 10 +++-
 drivers/sysreset/sysreset_ast.c           |  2 +-
 drivers/usb/gadget/ether.c                | 11 ++---
 drivers/video/exynos/exynos_fb.c          | 24 ++++------
 drivers/video/imx/mxc_ipuv3_fb.c          |  9 ++--
 drivers/video/mali_dp.c                   |  2 +-
 drivers/video/stm32/stm32_dsi.c           |  6 ++-
 drivers/video/tegra124/dp.c               |  7 +--
 drivers/virtio/virtio-uclass.c            | 15 +-----
 drivers/w1/w1-uclass.c                    | 29 ++++++------
 include/dm/uclass.h                       | 49 ++++++++++----------
 lib/acpi/acpi_table.c                     |  2 +-
 lib/efi_loader/efi_gop.c                  |  2 +-
 net/eth-uclass.c                          |  6 ++-
 test/boot/bootmeth.c                      |  2 +-
 test/dm/acpi.c                            | 14 +++---
 test/dm/core.c                            | 27 +++--------
 test/dm/devres.c                          |  4 +-
 test/dm/i2c.c                             |  8 ++--
 test/dm/test-fdt.c                        | 27 ++++++++---
 test/dm/virtio_device.c                   |  8 ++--
 test/dm/virtio_rng.c                      |  2 +-
 test/fuzz/cmd_fuzz.c                      |  2 +-
 test/fuzz/virtio.c                        |  2 +-
 test/test-main.c                          | 11 +----
 50 files changed, 269 insertions(+), 313 deletions(-)

--
2.37.3

Comments

Simon Glass Sept. 29, 2022, 10 a.m. UTC | #1
Hi Michal,

On Tue, 27 Sept 2022 at 15:38, Michal Suchanek <msuchanek@suse.de> wrote:
>
> Hello,
>
> this patch series fixes the simple uclass iterators to be usable for
> iterating uclasses even if some devices fail to probe.
>
> Before this series when a probe error happens an error is returned
> without any device pointer, and iteration cannot continue to devices
> that happen to be after the failing device in the uclass list.
>
> This is rarely expected, nor clearly documented, and for the most part
> not useful in any way.
>
> All but the last patch are new in v4 removing problematic iterator use.

Thank you for taking this on. It has been bugging me for about 6
years. It is not an easy task and you have dug in and carefully looked
at each situation and how to fix it.

Regards,
Simon


>
> v5:
>
> Split off patches that can be applied independently
>
> Fix uclass_foreach_dev_probe, pci_sriov_init, and sysinfo_get to work
> after the uclass_first_device_err change.
>
> Document that uclass_first_device_err and uclass_first_device_check can
> return non-activated device on error.
>
> Consolidate multiple similar cleanups into one patch.
>
> Thanks
>
> Michal
>
> Michal Suchanek (15):
>   dm: core: Fix uclass_probe_all to really probe all devices
>   dm: treewide: Do not opencode uclass_probe_all()
>   dm: pci: Fix device PCI iteration
>   bootstd: Fix listing boot devices
>   usb: ether: Fix error handling in usb_ether_init
>   stdio: Fix class iteration in stdio_add_devices()
>   video: ipuv3: Fix error handling when getting the display
>   w1: Fix bus counting in w1_get_bus
>   cmd: List all uclass devices regardless of probe error
>   dm: treewide: Use uclass_first_device_err when accessing one device
>   dm: treewide: Use uclass_next_device_err when accessing second device
>   dm: blk: Do not use uclass_next_device_err
>   dm: core: Switch uclass_*_device_err to use uclass_*_device_check
>   dm: treewide: Do not use the return value of simple uclass iterator
>   dm: core: Do not stop uclass iteration on error
>
>  arch/arm/mach-k3/j721s2_init.c            |  2 +-
>  arch/arm/mach-omap2/am33xx/board.c        |  4 +-
>  arch/x86/cpu/broadwell/cpu.c              |  4 +-
>  arch/x86/cpu/intel_common/cpu.c           |  4 +-
>  arch/x86/lib/pinctrl_ich6.c               |  4 +-
>  board/atmel/common/mac_eeprom.c           |  2 +-
>  board/intel/cougarcanyon2/cougarcanyon2.c |  4 +-
>  boot/bootdev-uclass.c                     |  7 +--
>  cmd/adc.c                                 | 22 ++++-----
>  cmd/demo.c                                | 16 ++++---
>  cmd/gpio.c                                | 15 ++++--
>  cmd/pmic.c                                | 15 +++---
>  cmd/regulator.c                           | 13 +++---
>  cmd/virtio.c                              |  9 ++--
>  common/stdio.c                            | 33 ++++++-------
>  drivers/block/blk-uclass.c                | 16 +++----
>  drivers/core/uclass.c                     | 56 ++++++++++++-----------
>  drivers/cpu/cpu-uclass.c                  | 20 ++------
>  drivers/dma/dma-uclass.c                  |  7 ++-
>  drivers/gpio/gpio-uclass.c                | 14 +++---
>  drivers/mmc/omap_hsmmc.c                  |  2 +-
>  drivers/pci/pci-uclass.c                  | 26 ++++-------
>  drivers/serial/serial-uclass.c            |  2 +-
>  drivers/serial/serial_bcm283x_mu.c        |  2 +-
>  drivers/serial/serial_bcm283x_pl011.c     |  2 +-
>  drivers/sysinfo/sysinfo-uclass.c          | 10 +++-
>  drivers/sysreset/sysreset_ast.c           |  2 +-
>  drivers/usb/gadget/ether.c                | 11 ++---
>  drivers/video/exynos/exynos_fb.c          | 24 ++++------
>  drivers/video/imx/mxc_ipuv3_fb.c          |  9 ++--
>  drivers/video/mali_dp.c                   |  2 +-
>  drivers/video/stm32/stm32_dsi.c           |  6 ++-
>  drivers/video/tegra124/dp.c               |  7 +--
>  drivers/virtio/virtio-uclass.c            | 15 +-----
>  drivers/w1/w1-uclass.c                    | 29 ++++++------
>  include/dm/uclass.h                       | 49 ++++++++++----------
>  lib/acpi/acpi_table.c                     |  2 +-
>  lib/efi_loader/efi_gop.c                  |  2 +-
>  net/eth-uclass.c                          |  6 ++-
>  test/boot/bootmeth.c                      |  2 +-
>  test/dm/acpi.c                            | 14 +++---
>  test/dm/core.c                            | 27 +++--------
>  test/dm/devres.c                          |  4 +-
>  test/dm/i2c.c                             |  8 ++--
>  test/dm/test-fdt.c                        | 27 ++++++++---
>  test/dm/virtio_device.c                   |  8 ++--
>  test/dm/virtio_rng.c                      |  2 +-
>  test/fuzz/cmd_fuzz.c                      |  2 +-
>  test/fuzz/virtio.c                        |  2 +-
>  test/test-main.c                          | 11 +----
>  50 files changed, 269 insertions(+), 313 deletions(-)
>
> --
> 2.37.3
>