All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v3 00/28] dm: Change the way sequence numbers are implemented
Date: Wed, 16 Dec 2020 21:20:05 -0700	[thread overview]
Message-ID: <20201217042034.411902-1-sjg@chromium.org> (raw)

At present each device has two sequence numbers, with 'req_seq' being
set up at bind time and 'seq' at probe time. The idea is that devices
can 'request' a sequence number and then the conflicts are resolved when
the device is probed.

This makes things complicated in a few cases, since we don't really know
(at bind time) what the sequence number will end up being. We want to
honour the bind-time requests if at all possible, but in fact the only
source of these at present is the devicetree aliases.

Apart from the obvious need for sequence numbers to supports U-Boot's
numbering on devices on the command line, the current scheme was
designed to:

- avoid calculating the sequence number until it is needed, to save
  execution time
- allow multiple devices to obtain a particular sequence number as they
  are probed and removed
- retain a record of the 'requested' sequence number even if it turns out
  that a device could not get it (to allow debugging and retrying)

After some years using the current scheme it seems on balance that these
goals don't have as much merit as first thought. The first point would
be persuasive except that we end up reading the devicetree aliases at
bind-time anyway. So the work of resolving the sequence numbers during
probing is not that great. The second point hasn't really been an issue,
as there is typically no contention for sequence numbers (boards tend to
allocate them statically in the devicetree). Re the third point, we can
often figure out what was requested by looking at aliases, and in the
cases where we can't, it doesn't seem to matter much.

Since we have the devicetree available at bind time, we may as well just
use it, in the hope that the required processing will turn out to be
useful later (i.e. the device actually gets used). In addition, it is
simpler to use a single sequence number, since it avoids confusion and
some extra code.

This series moves U-Boot to use a single, bind-time sequence number. All
uclasses assign sequence numbers to their devices, so that as soon as a
device is bound, it has a sequence number. If the uclass flag
DM_UC_FLAG_SEQ_ALIAS is enabled (as well as the CONFIG option), a
devicetree alias provides the number. Otherwise, the next available number
(after the last alias and avoiding existing devices) is used.

Note that it is still possible to have the uclass manually allocate
sequence numbers, using the DM_UC_FLAG_NO_SEQ flag. This is used by PCI,
due to its special requirements.

Apart from the simplicity gains, overall these changes seem to reduce the
number of tweaks and workarounds needed to get the desired behaviour.

However there will certainly be some problems created, so board
maintainers should test this out.

This series is available at u-boot-dm/seq-working

Changes in v3:
- Update PCI to use manual sequence numbering
- Add new patch to test DM_UC_FLAG_NO_AUTO_SEQ

Changes in v2:
- Give all devices a sequence number
- Drop uclass_alloc_all_seqs() and GD_FLG_DM_NO_SEQ flag
- Drop the GD_FLG_DM_NO_SEQ flag
- Drop special numbering in the i2c uclass
- Add new patch to allow manual sequence numbering
- Use the sequence number directly instead of max bus
- Adjust the tests to handle the new allocation scheme
- Drop the networking changes which are no-longer needed
- Update for new logic
- Adjust commit message
- Drop pointless check for max == -1
- Adjust the tests to handle the new allocation scheme
- Simplify the logic so auto_seq is positive
- Update the docs to indicate all devices get a sequence number
- Update the docs to explain how aliases reserve sequence numbers
- Drop commit changing efi_uc_destroy()

Simon Glass (28):
  linker_lists: Fix alignment issue
  dm: Avoid accessing seq directly
  dm: core: Update uclass_find_next_free_req_seq() args
  dm: core: Add a new sequence number for devices
  dm: test: Check all devices have a sequence numbers
  dm: core: Switch binding to use new sequence numbers
  dm: Fix return value in dev_read_alias_seq()
  dm: test: Drop assumptions of no sequence numbers
  octeon: Don't attempt to set the sequence number
  i2c: Update for new sequence numbers
  net: Update to use new sequence numbers
  dm: core: Allow manual sequence numbering
  pci: Update to use new sequence numbers
  spi: Update for new sequence numbers
  usb: ehci-mx6: Drop assignment of sequence number
  usb: Update for new sequence numbers
  x86: Drop unnecessary mp_init logic
  x86: Simplify acpi_device_infer_name()
  gpio: Update for new sequence numbers
  pinctrl: Update for new sequence numbers
  dm: Switch over to use new sequence number for dev_seq()
  dm: test: Add a test for DM_UC_FLAG_NO_AUTO_SEQ
  dm: Drop uclass_resolve_seq()
  dm: Drop the unused arg in uclass_find_device_by_seq()
  dm: core: Update uclass_find_next_free_req_seq() for new scheme
  cmd: Drop use of old sequence numbers in commands
  dm: core: Drop seq and req_seq
  dm: Update documentation for new sequence numbers

 arch/Kconfig                             |  11 ++
 arch/arm/include/asm/mach-imx/mxc_i2c.h  |   2 +-
 arch/arm/mach-k3/am6_init.c              |   2 +-
 arch/arm/mach-k3/j721e_init.c            |   2 +-
 arch/arm/mach-k3/sysfw-loader.c          |   2 +-
 arch/sandbox/dts/test.dts                |  15 +-
 arch/x86/cpu/apollolake/cpu.c            |   2 +-
 arch/x86/cpu/broadwell/cpu_full.c        |   2 +-
 arch/x86/cpu/ivybridge/model_206ax.c     |   2 +-
 arch/x86/cpu/mp_init.c                   |  23 +---
 arch/x86/include/asm/mp.h                |   2 +-
 board/xilinx/versal/board.c              |  12 +-
 board/xilinx/zynqmp/zynqmp.c             |  12 +-
 cmd/axi.c                                |   6 +-
 cmd/cpu.c                                |   2 +-
 cmd/i2c.c                                |   6 +-
 cmd/misc.c                               |   2 +-
 cmd/osd.c                                |   6 +-
 cmd/pci.c                                |   7 +-
 cmd/pmic.c                               |   4 +-
 cmd/remoteproc.c                         |   2 +-
 cmd/w1.c                                 |   4 +-
 doc/api/linker_lists.rst                 |  59 ++++++++
 doc/driver-model/design.rst              |  59 ++++----
 drivers/core/device-remove.c             |   1 -
 drivers/core/device.c                    |  50 ++-----
 drivers/core/dump.c                      |   4 +-
 drivers/core/read.c                      |   4 +-
 drivers/core/root.c                      |   8 +-
 drivers/core/uclass.c                    |  86 +++---------
 drivers/gpio/imx_rgpio2p.c               |   2 +-
 drivers/gpio/iproc_gpio.c                |   2 +-
 drivers/gpio/mvebu_gpio.c                |   2 +-
 drivers/gpio/mxc_gpio.c                  |   2 +-
 drivers/gpio/octeon_gpio.c               |   2 +-
 drivers/gpio/vybrid_gpio.c               |   2 +-
 drivers/i2c/ast_i2c.c                    |   4 +-
 drivers/i2c/davinci_i2c.c                |   2 +-
 drivers/i2c/designware_i2c_pci.c         |  16 +--
 drivers/i2c/exynos_hs_i2c.c              |   2 +-
 drivers/i2c/i2c-gpio.c                   |   2 +-
 drivers/i2c/i2c-uclass.c                 |  39 +-----
 drivers/i2c/i2c-versatile.c              |   5 -
 drivers/i2c/imx_lpi2c.c                  |  12 +-
 drivers/i2c/intel_i2c.c                  |  12 +-
 drivers/i2c/lpc32xx_i2c.c                |   6 +-
 drivers/i2c/muxes/i2c-mux-uclass.c       |   4 +-
 drivers/i2c/mvtwsi.c                     |   6 +-
 drivers/i2c/mxc_i2c.c                    |  10 +-
 drivers/i2c/nx_i2c.c                     |   2 +-
 drivers/i2c/octeon_i2c.c                 |   3 +-
 drivers/i2c/s3c24x0_i2c.c                |   2 +-
 drivers/i2c/tegra_i2c.c                  |   5 +-
 drivers/mmc/fsl_esdhc_imx.c              |   4 +-
 drivers/mmc/octeontx_hsmmc.c             |   2 -
 drivers/mtd/spi/sandbox.c                |   4 +-
 drivers/net/dwc_eth_qos.c                |   2 +-
 drivers/net/fec_mxc.c                    |   7 +-
 drivers/net/fsl-mc/mc.c                  |   2 +-
 drivers/net/fsl_mcdmafec.c               |   2 +-
 drivers/net/ftgmac100.c                  |   2 +-
 drivers/net/higmacv300.c                 |   2 +-
 drivers/net/mcffec.c                     |   2 +-
 drivers/net/octeontx/nicvf_main.c        |   9 +-
 drivers/net/octeontx/smi.c               |   3 +-
 drivers/net/octeontx2/nix.c              |   2 +-
 drivers/net/octeontx2/rvu_pf.c           |   6 +-
 drivers/net/xilinx_axi_emac.c            |   2 +-
 drivers/net/xilinx_emaclite.c            |   2 +-
 drivers/net/zynq_gem.c                   |   2 +-
 drivers/pci/pci-aardvark.c               |   2 +-
 drivers/pci/pci-uclass.c                 |  77 ++++++-----
 drivers/pci/pci_auto.c                   |  16 +--
 drivers/pci/pcie_dw_mvebu.c              |   6 +-
 drivers/pci/pcie_dw_ti.c                 |   6 +-
 drivers/pci/pcie_ecam_generic.c          |   2 +-
 drivers/pci/pcie_fsl.c                   |  16 +--
 drivers/pci/pcie_intel_fpga.c            |   2 +-
 drivers/pci/pcie_layerscape_fixup.c      |   4 +-
 drivers/pci/pcie_layerscape_gen4.c       |  10 +-
 drivers/pci/pcie_layerscape_gen4_fixup.c |   2 +-
 drivers/pci/pcie_layerscape_rc.c         |  12 +-
 drivers/pci/pcie_mediatek.c              |   2 +-
 drivers/pci/pcie_rockchip.c              |   6 +-
 drivers/pinctrl/exynos/pinctrl-exynos.c  |   2 +-
 drivers/serial/serial_mcf.c              |   2 +-
 drivers/serial/serial_s5p.c              |   2 +-
 drivers/spi/altera_spi.c                 |   2 +-
 drivers/spi/cf_spi.c                     |  12 +-
 drivers/spi/fsl_dspi.c                   |   8 +-
 drivers/spi/fsl_espi.c                   |   2 +-
 drivers/spi/octeon_spi.c                 |   2 +-
 drivers/spi/pic32_spi.c                  |   4 +-
 drivers/spi/rk_spi.c                     |   1 -
 drivers/spi/sandbox_spi.c                |   2 +-
 drivers/spi/spi-uclass.c                 |   4 +-
 drivers/spi/tegra114_spi.c               |   2 +-
 drivers/spi/tegra20_sflash.c             |   2 +-
 drivers/spi/tegra20_slink.c              |   2 +-
 drivers/spi/tegra210_qspi.c              |   2 +-
 drivers/spi/xilinx_spi.c                 |   2 +-
 drivers/spi/zynq_qspi.c                  |   2 +-
 drivers/spi/zynq_spi.c                   |   2 +-
 drivers/usb/gadget/max3420_udc.c         |   2 +-
 drivers/usb/host/ehci-mx5.c              |   2 +-
 drivers/usb/host/ehci-mx6.c              |  14 +-
 drivers/usb/host/ehci-omap.c             |   2 +-
 drivers/usb/host/ehci-vf.c               |   8 +-
 drivers/usb/host/usb-sandbox.c           |   2 +-
 drivers/usb/host/usb-uclass.c            |   6 +-
 drivers/video/vidconsole-uclass.c        |   4 +-
 drivers/virtio/virtio-uclass.c           |   2 +-
 drivers/watchdog/ast_wdt.c               |   2 +-
 drivers/watchdog/at91sam9_wdt.c          |   2 +-
 drivers/watchdog/cdns_wdt.c              |   2 +-
 drivers/watchdog/omap_wdt.c              |   2 +-
 drivers/watchdog/orion_wdt.c             |   2 +-
 drivers/watchdog/sbsa_gwdt.c             |   2 +-
 drivers/watchdog/sp805_wdt.c             |   2 +-
 drivers/watchdog/tangier_wdt.c           |   2 +-
 drivers/watchdog/xilinx_tb_wdt.c         |   2 +-
 drivers/watchdog/xilinx_wwdt.c           |   2 +-
 include/dm/device.h                      |  32 ++---
 include/dm/uclass-id.h                   |   1 +
 include/dm/uclass-internal.h             |  37 +++--
 include/dm/uclass.h                      |  18 +--
 include/linker_lists.h                   |   3 +-
 include/pci.h                            |   2 +-
 include/spi.h                            |   2 +-
 lib/acpi/acpi_device.c                   |  27 +---
 lib/efi_loader/efi_device_path.c         |   4 +-
 net/eth-uclass.c                         |  24 ++--
 test/dm/acpi.c                           |   6 +-
 test/dm/blk.c                            |   3 -
 test/dm/bus.c                            |  15 +-
 test/dm/core.c                           |  19 +++
 test/dm/i2c.c                            |   3 -
 test/dm/spi.c                            |   3 -
 test/dm/test-fdt.c                       | 168 +++++++++++++++++------
 139 files changed, 634 insertions(+), 613 deletions(-)

-- 
2.29.2.684.gfbc64c5ab5-goog

             reply	other threads:[~2020-12-17  4:20 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17  4:20 Simon Glass [this message]
2020-12-17  4:20 ` [PATCH v3 01/28] linker_lists: Fix alignment issue Simon Glass
2021-04-15  7:39   ` Heinrich Schuchardt
2021-04-21  7:14     ` Simon Glass
2020-12-17  4:20 ` [PATCH v3 02/28] dm: Avoid accessing seq directly Simon Glass
2020-12-17  4:20 ` [PATCH v3 03/28] dm: core: Update uclass_find_next_free_req_seq() args Simon Glass
2020-12-17  4:20 ` [PATCH v3 04/28] dm: core: Add a new sequence number for devices Simon Glass
2020-12-17  4:20 ` [PATCH v3 05/28] dm: test: Check all devices have a sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 06/28] dm: core: Switch binding to use new " Simon Glass
2020-12-17  4:20 ` [PATCH v3 07/28] dm: Fix return value in dev_read_alias_seq() Simon Glass
2020-12-17  4:20 ` [PATCH v3 08/28] dm: test: Drop assumptions of no sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 09/28] octeon: Don't attempt to set the sequence number Simon Glass
2020-12-17  4:20 ` [PATCH v3 10/28] i2c: Update for new sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 11/28] net: Update to use " Simon Glass
2020-12-17  4:20 ` [PATCH v3 12/28] dm: core: Allow manual sequence numbering Simon Glass
2020-12-17  4:20 ` [PATCH v3 13/28] pci: Update to use new sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 14/28] spi: Update for " Simon Glass
2020-12-17  4:20 ` [PATCH v3 15/28] usb: ehci-mx6: Drop assignment of sequence number Simon Glass
2020-12-17  4:20 ` [PATCH v3 16/28] usb: Update for new sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 17/28] x86: Drop unnecessary mp_init logic Simon Glass
2020-12-17  4:20 ` [PATCH v3 18/28] x86: Simplify acpi_device_infer_name() Simon Glass
2020-12-17  4:20 ` [PATCH v3 19/28] gpio: Update for new sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 20/28] pinctrl: " Simon Glass
2020-12-17  4:20 ` [PATCH v3 21/28] dm: Switch over to use new sequence number for dev_seq() Simon Glass
2020-12-17  4:20 ` [PATCH v3 22/28] dm: test: Add a test for DM_UC_FLAG_NO_AUTO_SEQ Simon Glass
2020-12-17  4:20 ` [PATCH v3 23/28] dm: Drop uclass_resolve_seq() Simon Glass
2020-12-17  4:20 ` [PATCH v3 24/28] dm: Drop the unused arg in uclass_find_device_by_seq() Simon Glass
2020-12-17  4:20 ` [PATCH v3 25/28] dm: core: Update uclass_find_next_free_req_seq() for new scheme Simon Glass
2020-12-17  4:20 ` [PATCH v3 26/28] cmd: Drop use of old sequence numbers in commands Simon Glass
2020-12-17  4:20 ` [PATCH v3 27/28] dm: core: Drop seq and req_seq Simon Glass
2020-12-17  4:20 ` [PATCH v3 28/28] dm: Update documentation for new sequence numbers Simon Glass
2020-12-18 11:09 ` [PATCH v3 00/28] dm: Change the way sequence numbers are implemented Michael Walle
2020-12-19 16:40 ` [PATCH v3 28/28] dm: Update documentation for new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 27/28] dm: core: Drop seq and req_seq Simon Glass
2020-12-19 16:40 ` [PATCH v3 25/28] dm: core: Update uclass_find_next_free_req_seq() for new scheme Simon Glass
2020-12-19 16:40 ` [PATCH v3 26/28] cmd: Drop use of old sequence numbers in commands Simon Glass
2020-12-19 16:40 ` [PATCH v3 24/28] dm: Drop the unused arg in uclass_find_device_by_seq() Simon Glass
2020-12-19 16:40 ` [PATCH v3 23/28] dm: Drop uclass_resolve_seq() Simon Glass
2020-12-19 16:40 ` [PATCH v3 22/28] dm: test: Add a test for DM_UC_FLAG_NO_AUTO_SEQ Simon Glass
2020-12-19 16:40 ` [PATCH v3 21/28] dm: Switch over to use new sequence number for dev_seq() Simon Glass
2020-12-19 16:40 ` [PATCH v3 20/28] pinctrl: Update for new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 19/28] gpio: " Simon Glass
2020-12-19 16:40 ` [PATCH v3 18/28] x86: Simplify acpi_device_infer_name() Simon Glass
2020-12-19 16:40 ` [PATCH v3 17/28] x86: Drop unnecessary mp_init logic Simon Glass
2020-12-19 16:40 ` [PATCH v3 16/28] usb: Update for new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 15/28] usb: ehci-mx6: Drop assignment of sequence number Simon Glass
2021-03-31 19:14   ` Marek Vasut
2021-03-31 19:27     ` Tom Rini
2021-03-31 22:20       ` Simon Glass
2020-12-19 16:40 ` [PATCH v3 14/28] spi: Update for new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 13/28] pci: Update to use " Simon Glass
2021-04-13 18:32   ` Tim Harvey
2021-04-14 19:37     ` Simon Glass
2021-04-15  0:28       ` Tim Harvey
2021-04-15  0:44         ` Simon Glass
2020-12-19 16:40 ` [PATCH v3 12/28] dm: core: Allow manual sequence numbering Simon Glass
2020-12-19 16:40 ` [PATCH v3 11/28] net: Update to use new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 10/28] i2c: Update for " Simon Glass
2020-12-19 16:40 ` [PATCH v3 09/28] octeon: Don't attempt to set the sequence number Simon Glass
2020-12-19 16:40 ` [PATCH v3 08/28] dm: test: Drop assumptions of no sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 07/28] dm: Fix return value in dev_read_alias_seq() Simon Glass
2020-12-19 16:40 ` [PATCH v3 06/28] dm: core: Switch binding to use new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 05/28] dm: test: Check all devices have a " Simon Glass
2020-12-19 16:40 ` [PATCH v3 04/28] dm: core: Add a new sequence number for devices Simon Glass
2020-12-19 16:40 ` [PATCH v3 03/28] dm: core: Update uclass_find_next_free_req_seq() args Simon Glass
2020-12-19 16:40 ` [PATCH v3 02/28] dm: Avoid accessing seq directly Simon Glass
2020-12-19 16:40 ` [PATCH v3 01/28] linker_lists: Fix alignment issue Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201217042034.411902-1-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.