dm: Change the way sequence numbers are implemented
Subsystems (28)
v3 cover dm: Change the way sequence numbers are implemented
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(-)
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 1/28 linker_lists: Fix alignment issue
The linker script uses alphabetic sorting to group the different linker lists together. Each group has its own struct and potentially its own alignment. But when the linker packs the structs together it cannot ensure that a linker list starts on the expected alignment boundary.
For example, if the first list has a struct size of 8 and we place 3 of them in the image, that means that the next struct will start at offset 0x18 from the start of the linker_list section. If the next struct has a size of 16 then it will start at an 8-byte aligned offset, but not a 16-byte aligned offset.
With sandbox on x86_64, a reference to a linker list item using ll_entry_get() can force alignment of that particular linker_list item, if it is in the same file as the linker_list item is declared.
Consider this example, where struct driver is 0x80 bytes:
ll_entry_declare(struct driver, fred, driver)
...
void *p = ll_entry_get(struct driver, fred, driver)
If these two lines of code are in the same file, then the entry is forced to be aligned at the 'struct driver' alignment, which is 16 bytes. If the second line of code is in a different file, then no action is taken, since the compiler cannot update the alignment of the linker_list item.
In the first case, an 8-byte 'fill' region is added:
.u_boot_list_2_driver_2_testbus_drv
0x0000000000270018 0x80 test/built-in.o
0x0000000000270018 _u_boot_list_2_driver_2_testbus_drv
.u_boot_list_2_driver_2_testfdt1_drv
0x0000000000270098 0x80 test/built-in.o
0x0000000000270098 _u_boot_list_2_driver_2_testfdt1_drv
*fill* 0x0000000000270118 0x8
.u_boot_list_2_driver_2_testfdt_drv
0x0000000000270120 0x80 test/built-in.o
0x0000000000270120 _u_boot_list_2_driver_2_testfdt_drv
.u_boot_list_2_driver_2_testprobe_drv
0x00000000002701a0 0x80 test/built-in.o
0x00000000002701a0 _u_boot_list_2_driver_2_testprobe_drvWith this, the linker_list no-longer works since items after testfdt1_drv are not at the expected address.
Ideally we would have a way to tell gcc not to align structs in this way. It is not clear how we could do this, and in any case it would require us to adjust every struct used by the linker_list feature.
One possible fix is to force each separate linker_list to start on the largest possible boundary that can be required by the compiler. However that does not seem to work on x86_64, which uses 16-byte alignment in this case but needs 32-byte alignment.
So add a Kconfig option to handle this. Set the default value to 4 so as to avoid changing platforms that don't need it.
Update the ll_entry_start() accordingly.
---
(no changes since v1)
arch/Kconfig | 11 ++++++++ doc/api/linker_lists.rst | 59 ++++++++++++++++++++++++++++++++++++++++ include/linker_lists.h | 3 +- 3 files changed, 72 insertions(+), 1 deletion(-)
arch/Kconfig +11 -0
@@ -7,6 +7,17 @@ config HAVE_ARCH_IOREMAP config NEEDS_MANUAL_RELOC bool +config LINKER_LIST_ALIGN + int + default 32 if SANDBOX + default 8 if ARM64 || X86 + default 4 + help + Force the each linker list to be aligned to this boundary. This + is required if ll_entry_get() is used, since otherwise the linker + may add padding into the table, thus breaking it. + See linker_lists.rst for full details. + choice prompt "Architecture select" default SANDBOX
doc/api/linker_lists.rst +59 -0
64 lines not on this page · raw message
include/linker_lists.h +2 -1
@@ -124,7 +124,8 @@*/ #define ll_entry_start (_type, _list) \ ({ \ - static char start[0] __aligned(4) __attribute__((unused, \ + static char start[0] __aligned(CONFIG_LINKER_LIST_ALIGN) \ + __attribute__((unused, \ section(".u_boot_list_2_"#_list"_1"))); \ (_type *)&start; \ })
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 1/28 linker_lists: Fix alignment issue
The linker script uses alphabetic sorting to group the different linker lists together. Each group has its own struct and potentially its own alignment. But when the linker packs the structs together it cannot ensure that a linker list starts on the expected alignment boundary.
For example, if the first list has a struct size of 8 and we place 3 of them in the image, that means that the next struct will start at offset 0x18 from the start of the linker_list section. If the next struct has a size of 16 then it will start at an 8-byte aligned offset, but not a 16-byte aligned offset.
With sandbox on x86_64, a reference to a linker list item using ll_entry_get() can force alignment of that particular linker_list item, if it is in the same file as the linker_list item is declared.
Consider this example, where struct driver is 0x80 bytes:
ll_entry_declare(struct driver, fred, driver)
...
void *p = ll_entry_get(struct driver, fred, driver)
If these two lines of code are in the same file, then the entry is forced to be aligned at the 'struct driver' alignment, which is 16 bytes. If the second line of code is in a different file, then no action is taken, since the compiler cannot update the alignment of the linker_list item.
In the first case, an 8-byte 'fill' region is added:
.u_boot_list_2_driver_2_testbus_drv
0x0000000000270018 0x80 test/built-in.o
0x0000000000270018
_u_boot_list_2_driver_2_testbus_drv
.u_boot_list_2_driver_2_testfdt1_drv
0x0000000000270098 0x80 test/built-in.o
0x0000000000270098
_u_boot_list_2_driver_2_testfdt1_drv
*fill* 0x0000000000270118 0x8
.u_boot_list_2_driver_2_testfdt_drv
0x0000000000270120 0x80 test/built-in.o
0x0000000000270120
_u_boot_list_2_driver_2_testfdt_drv
.u_boot_list_2_driver_2_testprobe_drv
0x00000000002701a0 0x80 test/built-in.o
0x00000000002701a0_u_boot_list_2_driver_2_testprobe_drv
With this, the linker_list no-longer works since items after testfdt1_drv are not at the expected address.
Ideally we would have a way to tell gcc not to align structs in this way. It is not clear how we could do this, and in any case it would require us to adjust every struct used by the linker_list feature.
One possible fix is to force each separate linker_list to start on the largest possible boundary that can be required by the compiler. However that does not seem to work on x86_64, which uses 16-byte alignment in this case but needs 32-byte alignment.
So add a Kconfig option to handle this. Set the default value to 4 so as to avoid changing platforms that don't need it.
Update the ll_entry_start() accordingly.
---
(no changes since v1)
arch/Kconfig | 11 ++++++++ doc/api/linker_lists.rst | 59 ++++++++++++++++++++++++++++++++++++++++ include/linker_lists.h | 3 +- 3 files changed, 72 insertions(+), 1 deletion(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 1/28 linker_lists: Fix alignment issue
In reply to Simon GlassQuoted 76 lines · Simon Glass
The linker script uses alphabetic sorting to group the different linker lists together. Each group has its own struct and potentially its own alignment. But when the linker packs the structs together it cannot ensure that a linker list starts on the expected alignment boundary.
For example, if the first list has a struct size of 8 and we place 3 of them in the image, that means that the next struct will start at offset
0x18from the start of thelinker_listsection. If the next struct has a size of 16 then it will start at an 8-byte aligned offset, but not a 16-byte aligned offset.With sandbox on
x86_64, a reference to a linker list item usingll_entry_get()can force alignment of that particularlinker_listitem, if it is in the same file as thelinker_listitem is declared.Consider this example, where struct driver is
0x80bytes:
ll_entry_declare(struct driver, fred, driver)...
void *p =
ll_entry_get(struct driver, fred, driver)If these two lines of code are in the same file, then the entry is forced to be aligned at the 'struct driver' alignment, which is 16 bytes. If the second line of code is in a different file, then no action is taken, since the compiler cannot update the alignment of the
linker_listitem.In the first case, an 8-byte 'fill' region is added:
.u_boot_list_2_driver_2_testbus_drv
0x0000000000270018 0x80 test/built-in.o 0x0000000000270018 _u_boot_list_2_driver_2_testbus_drv .u_boot_list_2_driver_2_testfdt1_drv 0x0000000000270098 0x80 test/built-in.o 0x0000000000270098 _u_boot_list_2_driver_2_testfdt1_drv *fill* 0x0000000000270118 0x8 .u_boot_list_2_driver_2_testfdt_drv 0x0000000000270120 0x80 test/built-in.o 0x0000000000270120 _u_boot_list_2_driver_2_testfdt_drv .u_boot_list_2_driver_2_testprobe_drv 0x00000000002701a0 0x80 test/built-in.o 0x00000000002701a0 _u_boot_list_2_driver_2_testprobe_drvWith this, the
linker_listno-longer works since items aftertestfdt1_drvare not at the expected address.Ideally we would have a way to tell gcc not to align structs in this way. It is not clear how we could do this, and in any case it would require us to adjust every struct used by the
linker_listfeature.One possible fix is to force each separate
linker_listto start on the largest possible boundary that can be required by the compiler. However that does not seem to work onx86_64, which uses 16-byte alignment in this case but needs 32-byte alignment.So add a
Kconfigoption to handle this. Set the default value to 4 so as to avoid changing platforms that don't need it.Update the
ll_entry_start()accordingly.Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
arch/Kconfig | 11 ++++++++ doc/api/linker_lists.rst | 59 ++++++++++++++++++++++++++++++++++++++++ include/linker_lists.h | 3 +- 3 files changed, 72 insertions(+), 1 deletion(-)arch/Kconfig +0
-0
arch/Kconfig config HAVE_ARCH_IOREMAP · line 12
Quoted 6 lines
arch/Kconfig +3
-0@@ -7,6 +7,17 @@ config HAVE_ARCH_IOREMAP config NEEDS_MANUAL_RELOC bool +config LINKER_LIST_ALIGN + int + default 32 if SANDBOX
On which host architecture would the sandbox actually require 32 bytes?
Please, use an alignment based on the bitness of the generated binary to get relevant test results.
arch/Kconfig config HAVE_ARCH_IOREMAP · line 13
Quoted 1 line
arch/Kconfig +1
-0+ default 8 if ARM64 || X86
Except for jmp_buf the maximum alignment requirement on i386 is 4 and on amd64 it is 8.
arch/Kconfig config HAVE_ARCH_IOREMAP · line 14
Quoted 1 line
arch/Kconfig +1
-0+ default 4
This defies the alignment requirements of 64 bit systems like RV64, mips64.
The code must work on *all* architectures.
Best regards
Heinrich
Quoted 93 lines
arch/Kconfig +6
-0+ help + Force the each linker list to be aligned to this boundary. This + is required if ll_entry_get() is used, since otherwise the linker + may add padding into the table, thus breaking it. + See linker_lists.rst for full details. + choice prompt "Architecture select" default SANDBOXdoc/api/linker_lists.rst +59
-0@@ -96,5 +96,64 @@ defined for the whole list and each sub-list: %u_boot_list_2_drivers_2_pci_3 %u_boot_list_2_drivers_3 +Alignment issues +---------------- + +The linker script uses alphabetic sorting to group the different linker +lists together. Each group has its own struct and potentially its own +alignment. But when the linker packs the structs together it cannot ensure +that a linker list starts on the expected alignment boundary. + +For example, if the first list has a struct size of 8 and we place 3 of +them in the image, that means that the next struct will start at offset +0x18 from the start of the linker_list section. If the next struct has +a size of 16 then it will start at an 8-byte aligned offset, but not a +16-byte aligned offset. + +With sandbox on x86_64, a reference to a linker list item using +ll_entry_get() can force alignment of that particular linker_list item, +if it is in the same file as the linker_list item is declared. + +Consider this example, where struct driver is 0x80 bytes:: + + ll_entry_declare(struct driver, fred, driver) + + ... + + void *p = ll_entry_get(struct driver, fred, driver) + +If these two lines of code are in the same file, then the entry is forced +to be aligned at the 'struct driver' alignment, which is 16 bytes. If the +second line of code is in a different file, then no action is taken, since +the compiler cannot update the alignment of the linker_list item. + +In the first case, an 8-byte 'fill' region is added:: + + .u_boot_list_2_driver_2_testbus_drv + 0x0000000000270018 0x80 test/built-in.o + 0x0000000000270018 _u_boot_list_2_driver_2_testbus_drv + .u_boot_list_2_driver_2_testfdt1_drv + 0x0000000000270098 0x80 test/built-in.o + 0x0000000000270098 _u_boot_list_2_driver_2_testfdt1_drv + *fill* 0x0000000000270118 0x8 + .u_boot_list_2_driver_2_testfdt_drv + 0x0000000000270120 0x80 test/built-in.o + 0x0000000000270120 _u_boot_list_2_driver_2_testfdt_drv + .u_boot_list_2_driver_2_testprobe_drv + 0x00000000002701a0 0x80 test/built-in.o + 0x00000000002701a0 _u_boot_list_2_driver_2_testprobe_drv + +With this, the linker_list no-longer works since items after testfdt1_drv +are not at the expected address. + +Ideally we would have a way to tell gcc not to align structs in this way. +It is not clear how we could do this, and in any case it would require us +to adjust every struct used by the linker_list feature. + +The simplest fix seems to be to force each separate linker_list to start +on the largest possible boundary that can be required by the compiler. This +is the purpose of CONFIG_LINKER_LIST_ALIGN + + .. kernel-doc:: include/linker_lists.h :internal:include/linker_lists.h +2
-1@@ -124,7 +124,8 @@*/ #define ll_entry_start (_type, _list) \ ({ \ - static char start[0] __aligned(4) __attribute__((unused, \ + static char start[0] __aligned(CONFIG_LINKER_LIST_ALIGN) \ + __attribute__((unused, \ section(".u_boot_list_2_"#_list"_1"))); \ (_type *)&start; \ })
PATCH v3 1/28 linker_lists: Fix alignment issue
Hi Heinrich,
Quoted 81 lines · Heinrich Schuchardt
Quoted 79 lines · Simon Glass
The linker script uses alphabetic sorting to group the different linker lists together. Each group has its own struct and potentially its own alignment. But when the linker packs the structs together it cannot ensure that a linker list starts on the expected alignment boundary.
For example, if the first list has a struct size of 8 and we place 3 of them in the image, that means that the next struct will start at offset
0x18from the start of thelinker_listsection. If the next struct has a size of 16 then it will start at an 8-byte aligned offset, but not a 16-byte aligned offset.With sandbox on
x86_64, a reference to a linker list item usingll_entry_get()can force alignment of that particularlinker_listitem, if it is in the same file as thelinker_listitem is declared.Consider this example, where struct driver is
0x80bytes:
ll_entry_declare(struct driver, fred, driver)...
void *p =
ll_entry_get(struct driver, fred, driver)If these two lines of code are in the same file, then the entry is forced to be aligned at the 'struct driver' alignment, which is 16 bytes. If the second line of code is in a different file, then no action is taken, since the compiler cannot update the alignment of the
linker_listitem.In the first case, an 8-byte 'fill' region is added:
.u_boot_list_2_driver_2_testbus_drv
0x0000000000270018 0x80 test/built-in.o 0x0000000000270018 _u_boot_list_2_driver_2_testbus_drv .u_boot_list_2_driver_2_testfdt1_drv 0x0000000000270098 0x80 test/built-in.o 0x0000000000270098 _u_boot_list_2_driver_2_testfdt1_drv *fill* 0x0000000000270118 0x8 .u_boot_list_2_driver_2_testfdt_drv 0x0000000000270120 0x80 test/built-in.o 0x0000000000270120 _u_boot_list_2_driver_2_testfdt_drv .u_boot_list_2_driver_2_testprobe_drv 0x00000000002701a0 0x80 test/built-in.o 0x00000000002701a0 _u_boot_list_2_driver_2_testprobe_drvWith this, the
linker_listno-longer works since items aftertestfdt1_drvare not at the expected address.Ideally we would have a way to tell gcc not to align structs in this way. It is not clear how we could do this, and in any case it would require us to adjust every struct used by the
linker_listfeature.One possible fix is to force each separate
linker_listto start on the largest possible boundary that can be required by the compiler. However that does not seem to work onx86_64, which uses 16-byte alignment in this case but needs 32-byte alignment.So add a
Kconfigoption to handle this. Set the default value to 4 so as to avoid changing platforms that don't need it.Update the
ll_entry_start()accordingly.Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
arch/Kconfig | 11 ++++++++ doc/api/linker_lists.rst | 59 ++++++++++++++++++++++++++++++++++++++++ include/linker_lists.h | 3 +- 3 files changed, 72 insertions(+), 1 deletion(-)arch/Kconfig +0
-0@@ -7,6 +7,17 @@ config HAVE_ARCH_IOREMAP config NEEDS_MANUAL_RELOC bool
Quoted 5 lines
arch/Kconfig config HAVE_ARCH_IOREMAP · line 12
Quoted 3 lines
arch/Kconfig +3
-0+config LINKER_LIST_ALIGN + int + default 32 if SANDBOXOn which host architecture would the sandbox actually require 32 bytes?
x86_64, for example.
Quoted 10 lines
Please, use an alignment based on the bitness of the generated binary to get relevant test results.
arch/Kconfig config HAVE_ARCH_IOREMAP · line 13
Quoted 1 line
arch/Kconfig +1
-0+ default 8 if ARM64 || X86Except for
jmp_bufthe maximum alignment requirement on i386 is 4 and on amd64 it is 8.Quoted 1 line
arch/Kconfig +1
-0+ default 4
Please do check the above commit message. This is a real problem and causes U-Boot to crash. If you have a better idea how to fix it, I am all ears, as I don't like this either.
Quoted 4 lines
This defies the alignment requirements of 64 bit systems like RV64, mips64.
The code must work on *all* architectures.
The status quo is 4 as you can see, so I am only actually changing sandbox. I have not seen this problem on other archs, although I wouldn't rule it out.
Regards,
Simon
Quoted 95 lines
Quoted 94 lines
arch/Kconfig +6
-0+ help + Force the each linker list to be aligned to this boundary. This + is required if ll_entry_get() is used, since otherwise the linker + may add padding into the table, thus breaking it. + See linker_lists.rst for full details. + choice prompt "Architecture select" default SANDBOXdoc/api/linker_lists.rst +59
-0@@ -96,5 +96,64 @@ defined for the whole list and each sub-list: %u_boot_list_2_drivers_2_pci_3 %u_boot_list_2_drivers_3 +Alignment issues +---------------- + +The linker script uses alphabetic sorting to group the different linker +lists together. Each group has its own struct and potentially its own +alignment. But when the linker packs the structs together it cannot ensure +that a linker list starts on the expected alignment boundary. + +For example, if the first list has a struct size of 8 and we place 3 of +them in the image, that means that the next struct will start at offset +0x18 from the start of the linker_list section. If the next struct has +a size of 16 then it will start at an 8-byte aligned offset, but not a +16-byte aligned offset. + +With sandbox on x86_64, a reference to a linker list item using +ll_entry_get() can force alignment of that particular linker_list item, +if it is in the same file as the linker_list item is declared. + +Consider this example, where struct driver is 0x80 bytes:: + + ll_entry_declare(struct driver, fred, driver) + + ... + + void *p = ll_entry_get(struct driver, fred, driver) + +If these two lines of code are in the same file, then the entry is forced +to be aligned at the 'struct driver' alignment, which is 16 bytes. If the +second line of code is in a different file, then no action is taken, since +the compiler cannot update the alignment of the linker_list item. + +In the first case, an 8-byte 'fill' region is added:: + + .u_boot_list_2_driver_2_testbus_drv + 0x0000000000270018 0x80 test/built-in.o + 0x0000000000270018 _u_boot_list_2_driver_2_testbus_drv + .u_boot_list_2_driver_2_testfdt1_drv + 0x0000000000270098 0x80 test/built-in.o + 0x0000000000270098 _u_boot_list_2_driver_2_testfdt1_drv + *fill* 0x0000000000270118 0x8 + .u_boot_list_2_driver_2_testfdt_drv + 0x0000000000270120 0x80 test/built-in.o + 0x0000000000270120 _u_boot_list_2_driver_2_testfdt_drv + .u_boot_list_2_driver_2_testprobe_drv + 0x00000000002701a0 0x80 test/built-in.o + 0x00000000002701a0 _u_boot_list_2_driver_2_testprobe_drv + +With this, the linker_list no-longer works since items after testfdt1_drv +are not at the expected address. + +Ideally we would have a way to tell gcc not to align structs in this way. +It is not clear how we could do this, and in any case it would require us +to adjust every struct used by the linker_list feature. + +The simplest fix seems to be to force each separate linker_list to start +on the largest possible boundary that can be required by the compiler. This +is the purpose of CONFIG_LINKER_LIST_ALIGN + + .. kernel-doc:: include/linker_lists.h :internal:include/linker_lists.h +2
-1@@ -124,7 +124,8 @@*/ #define ll_entry_start (_type, _list) \ ({ \ - static char start[0] __aligned(4) __attribute__((unused, \ + static char start[0] __aligned(CONFIG_LINKER_LIST_ALIGN) \ + __attribute__((unused, \ section(".u_boot_list_2_"#_list"_1"))); \ (_type *)&start; \ })
PATCH v3 2/28 dm: Avoid accessing seq directly
In reply to Simon GlassAt present various drivers etc. access the device's 'seq' member directly. This makes it harder to change the meaning of that member. Change access to go through a function instead.
The drivers/i2c/lpc32xx_i2c.c file is left unchanged for now.
---
(no changes since v1)
arch/arm/include/asm/mach-imx/mxc_i2c.h | 2 +- arch/x86/cpu/broadwell/cpu_full.c | 2 +- arch/x86/cpu/ivybridge/model_206ax.c | 2 +- board/xilinx/versal/board.c | 12 ++++---- board/xilinx/zynqmp/zynqmp.c | 12 ++++---- cmd/axi.c | 4 +-- cmd/cpu.c | 2 +- cmd/i2c.c | 4 +-- cmd/misc.c | 2 +- cmd/osd.c | 4 +-- cmd/pci.c | 7 +++-- cmd/pmic.c | 4 +-- cmd/remoteproc.c | 2 +- cmd/w1.c | 4 +-- drivers/core/device.c | 2 +- drivers/core/dump.c | 4 +-- drivers/core/uclass.c | 6 ++-- drivers/gpio/octeon_gpio.c | 2 +- drivers/i2c/ast_i2c.c | 4 +-- drivers/i2c/davinci_i2c.c | 2 +- drivers/i2c/exynos_hs_i2c.c | 2 +- drivers/i2c/i2c-gpio.c | 2 +- drivers/i2c/imx_lpi2c.c | 12 ++++---- drivers/i2c/lpc32xx_i2c.c | 6 +++- drivers/i2c/mxc_i2c.c | 10 +++---- drivers/i2c/nx_i2c.c | 2 +- drivers/i2c/octeon_i2c.c | 2 +- drivers/i2c/s3c24x0_i2c.c | 2 +- drivers/i2c/tegra_i2c.c | 5 ++-- drivers/mmc/fsl_esdhc_imx.c | 4 +-- drivers/mtd/spi/sandbox.c | 4 +-- 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 | 2 +- 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 | 36 ++++++++++++------------ drivers/pci/pci_auto.c | 6 ++-- 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/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 | 6 ++-- drivers/spi/fsl_espi.c | 2 +- drivers/spi/octeon_spi.c | 2 +- drivers/spi/pic32_spi.c | 4 +-- drivers/spi/sandbox_spi.c | 2 +- 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 | 2 +- drivers/usb/host/ehci-omap.c | 2 +- drivers/usb/host/ehci-vf.c | 2 +- drivers/usb/host/usb-sandbox.c | 2 +- drivers/usb/host/usb-uclass.c | 2 +- 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 | 5 ++++ include/pci.h | 2 +- include/spi.h | 2 +- lib/efi_loader/efi_device_path.c | 4 +-- net/eth-uclass.c | 19 +++++++------ 98 files changed, 211 insertions(+), 197 deletions(-)
arch/arm/include/asm/mach-imx/mxc_i2c.h +1 -1
@@ -42,7 +42,7 @@ struct mxc_i2c_bus {/* * board file can use this index to locate which i2c_pads_info is for * i2c_idle_bus. When pinmux is implement, this entry can be -* discarded. Here we do not use dev->seq, because we do not want to +* discarded. Here we do not use dev_seq(dev), because we do not want to * export device to board file. */ int index;
arch/x86/cpu/broadwell/cpu_full.c +1 -1
@@ -638,7 +638,7 @@ static int broadwell_get_count(const struct udevice *dev)static int cpu_x86_broadwell_probe (struct udevice *dev) { -if (dev->seq ==0 ) { +if (dev_seq (dev) ==0 ) {cpu_core_init (dev);return broadwell_init (dev); }
arch/x86/cpu/ivybridge/model_206ax.c +1 -1
@@ -425,7 +425,7 @@ static int model_206ax_get_count(const struct udevice *dev)static int cpu_x86_model_206ax_probe (struct udevice *dev) { -if (dev->seq ==0 ) +if (dev_seq (dev) ==0 )model_206ax_init (dev);return 0 ;
board/xilinx/versal/board.c +6 -6
@@ -153,9 +153,9 @@ int board_late_init(void)puts ("Boot from EMMC but without SD1 enabled!\n" );return -1 ; } -debug ("mmc1 device found at %p, seq %d\n" , dev, dev->seq); +debug ("mmc1 device found at %p, seq %d\n" , dev,dev_seq (dev)); mode ="mmc" ; - bootseq = dev->seq; + bootseq =dev_seq (dev);break ;case SD_MODE :puts ("SD_MODE\n" );
@@ -164,10 +164,10 @@ int board_late_init(void)puts ("Boot from SD0 but without SD0 enabled!\n" );return -1 ; } -debug ("mmc0 device found at %p, seq %d\n" , dev, dev->seq); +debug ("mmc0 device found at %p, seq %d\n" , dev,dev_seq (dev)); mode ="mmc" ; - bootseq = dev->seq; + bootseq =dev_seq (dev);break ;case SD1_LSHFT_MODE :puts ("LVL_SHFT_" );
@@ -179,10 +179,10 @@ int board_late_init(void)puts ("Boot from SD1 but without SD1 enabled!\n" );return -1 ; } -debug ("mmc1 device found at %p, seq %d\n" , dev, dev->seq); +debug ("mmc1 device found at %p, seq %d\n" , dev,dev_seq (dev)); mode ="mmc" ; - bootseq = dev->seq; + bootseq =dev_seq (dev);break ;default : mode ="" ;
board/xilinx/zynqmp/zynqmp.c +6 -6
@@ -596,10 +596,10 @@ int board_late_init(void)puts ("Boot from EMMC but without SD0 enabled!\n" );return -1 ; } -debug ("mmc0 device found at %p, seq %d\n" , dev, dev->seq); +debug ("mmc0 device found at %p, seq %d\n" , dev,dev_seq (dev)); mode ="mmc" ; - bootseq = dev->seq; + bootseq =dev_seq (dev);break ;case SD_MODE :puts ("SD_MODE\n" );
@@ -610,10 +610,10 @@ int board_late_init(void)puts ("Boot from SD0 but without SD0 enabled!\n" );return -1 ; } -debug ("mmc0 device found at %p, seq %d\n" , dev, dev->seq); +debug ("mmc0 device found at %p, seq %d\n" , dev,dev_seq (dev)); mode ="mmc" ; - bootseq = dev->seq; + bootseq =dev_seq (dev);env_set ("modeboot" ,"sdboot" );break ;case SD1_LSHFT_MODE :
@@ -628,10 +628,10 @@ int board_late_init(void)puts ("Boot from SD1 but without SD1 enabled!\n" );return -1 ; } -debug ("mmc1 device found at %p, seq %d\n" , dev, dev->seq); +debug ("mmc1 device found at %p, seq %d\n" , dev,dev_seq (dev)); mode ="mmc" ; - bootseq = dev->seq; + bootseq =dev_seq (dev);env_set ("modeboot" ,"sdboot" );break ;case NAND_MODE :
cmd/axi.c +2 -2
@@ -35,7 +35,7 @@ static void show_bus(struct udevice *bus)printf ("Bus %d:\t%s" , bus->req_seq, bus->name);if (device_active (bus)) -printf (" (active %d)" , bus->seq); +printf (" (active %d)" ,dev_seq (bus));printf ("\n" ); for (device_find_first_child(bus, &dev); dev;
@@ -147,7 +147,7 @@ static int do_axi_bus_num(struct cmd_tbl *cmdtp, int flag, int argc,struct udevice *bus;if (!axi_get_cur_bus (&bus)) - bus_no = bus->seq; + bus_no =dev_seq (bus);else bus_no =-1 ;
cmd/cpu.c +1 -1
@@ -32,7 +32,7 @@ static int print_cpu_list(bool detail)int ret, i; ret =cpu_get_desc (dev, buf,sizeof (buf)); -printf ("%3d: %-10s %s\n" , dev->seq, dev->name, +printf ("%3d: %-10s %s\n" ,dev_seq (dev), dev->name, ret ?"<no description>" : buf);if (!detail)continue ;
cmd/i2c.c +2 -2
@@ -1702,7 +1702,7 @@ static void show_bus(struct udevice *bus)printf ("Bus %d:\t%s" , bus->req_seq, bus->name);if (device_active (bus)) -printf (" (active %d)" , bus->seq); +printf (" (active %d)" ,dev_seq (bus));printf ("\n" ); for (device_find_first_child(bus, &dev); dev;
@@ -1825,7 +1825,7 @@ static int do_i2c_bus_num(struct cmd_tbl *cmdtp, int flag, int argc,struct udevice *bus;if (!i2c_get_cur_bus (&bus)) - bus_no = bus->seq; + bus_no =dev_seq (bus);else bus_no =-1 ;#else
cmd/misc.c +1 -1
@@ -34,7 +34,7 @@ static int do_misc_list(struct cmd_tbl *cmdtp, int flag,for (uclass_first_device (UCLASS_MISC , &dev); dev;uclass_next_device (&dev)) { -printf ("%-20s %5d %10s\n" , dev->name, dev->seq, +printf ("%-20s %5d %10s\n" , dev->name,dev_seq (dev), dev->driver->name); }
cmd/osd.c +2 -2
@@ -77,7 +77,7 @@ static void show_osd(struct udevice *osd) {printf ("OSD %d:\t%s" , osd->req_seq, osd->name);if (device_active (osd)) -printf (" (active %d)" , osd->seq); +printf (" (active %d)" ,dev_seq (osd));printf ("\n" ); }
@@ -235,7 +235,7 @@ static int do_osd_num(struct cmd_tbl *cmdtp, int flag, int argc,struct udevice *osd;if (!osd_get_osd_cur (&osd)) - osd_no = osd->seq; + osd_no =dev_seq (osd);else osd_no =-1 ;printf ("Current osd is %d\n" , osd_no);
cmd/pci.c +4 -3
@@ -334,7 +334,7 @@ static void pciinfo(struct udevice *bus, bool short_listing) {struct udevice *dev; -pciinfo_header (bus->seq, short_listing); +pciinfo_header (dev_seq (bus), short_listing); for (device_find_first_child(bus, &dev); dev;
@@ -343,11 +343,12 @@ static void pciinfo(struct udevice *bus, bool short_listing) pplat =dev_get_parent_plat (dev);if (short_listing) { -printf ("%02x.%02x.%02x " , bus->seq, +printf ("%02x.%02x.%02x " ,dev_seq (bus),PCI_DEV (pplat->devfn),PCI_FUNC (pplat->devfn));pci_header_show_brief (dev); }else { -printf ("\nFound PCI device %02x.%02x.%02x:\n" , bus->seq, +printf ("\nFound PCI device %02x.%02x.%02x:\n" , +dev_seq (bus),PCI_DEV (pplat->devfn),PCI_FUNC (pplat->devfn));pci_header_show (dev); }
cmd/pmic.c +2 -2
@@ -41,7 +41,7 @@ static int do_dev(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])return CMD_RET_USAGE ; } -printf ("dev: %d @ %s\n" , currdev->seq, currdev->name); +printf ("dev: %d @ %s\n" ,dev_seq (currdev), currdev->name); }return CMD_RET_SUCCESS ;
@@ -66,7 +66,7 @@ static int do_list(struct cmd_tbl *cmdtp, int flag, int argc,printf ("| %-*.*s| %-*.*s| %s @ %d\n" ,LIMIT_DEV ,LIMIT_DEV , dev->name,LIMIT_PARENT ,LIMIT_PARENT , dev->parent->name, -dev_get_uclass_name (dev->parent), dev->parent->seq); +dev_get_uclass_name (dev->parent),dev_seq (dev->parent)); }if (ret)
cmd/remoteproc.c +1 -1
@@ -47,7 +47,7 @@ static int print_remoteproc_list(void)break ; } printf("%d - Name:'%s' type:'%s' supports: %s%s%s%s%s%s\n", - dev->seq, + dev_seq(dev), uc_pdata->name, type, ops->load ? "load " : "",
cmd/w1.c +2 -2
@@ -21,7 +21,7 @@ static int w1_bus(void)printf ("one wire interface not found\n" );return CMD_RET_FAILURE ; } -printf ("Bus %d:\t%s" , bus->seq, bus->name); +printf ("Bus %d:\t%s" ,dev_seq (bus), bus->name);if (device_active (bus))printf (" (active)" );printf ("\n" );
@@ -31,7 +31,7 @@ static int w1_bus(void) device_find_next_child(&dev)) { ret =device_probe (dev); -printf ("\t%s (%d) uclass %s : " , dev->name, dev->seq, +printf ("\t%s (%d) uclass %s : " , dev->name,dev_seq (dev), dev->uclass->uc_drv->name);if (ret)
drivers/core/device.c +1 -1
@@ -655,7 +655,7 @@ int device_find_child_by_seq(const struct udevice *parent, int seq_or_req_seq,return -ENODEV ;list_for_each_entry (dev, &parent->child_head, sibling_node) { -if ((find_req_seq ? dev->req_seq : dev->seq) == +if ((find_req_seq ? dev->req_seq :dev_seq (dev)) == seq_or_req_seq) { *devp = dev;return 0 ;
drivers/core/dump.c +2 -2
@@ -67,8 +67,8 @@ static void dm_display_line(struct udevice *dev, int index)printf ("%-3i %c %s @ %08lx" , index, dev->flags &DM_FLAG_ACTIVATED ?'*' :' ' , dev->name, (ulong )map_to_sysmem (dev)); -if (dev->seq !=-1 || dev->req_seq !=-1 ) -printf (", seq %d, (req %d)" , dev->seq, dev->req_seq); +if (dev_seq (dev) !=-1 || dev->req_seq !=-1 ) +printf (", seq %d, (req %d)" ,dev_seq (dev), dev->req_seq);puts ("\n" ); }
drivers/core/uclass.c +3 -3
@@ -311,8 +311,8 @@ int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq, uclass_foreach_dev(dev, uc) {log_debug (" - %d %d '%s'\n" , - dev->req_seq, dev->seq, dev->name); -if ((find_req_seq ? dev->req_seq : dev->seq) == + dev->req_seq,dev_seq (dev), dev->name); +if ((find_req_seq ? dev->req_seq :dev_seq (dev)) == seq_or_req_seq) { *devp = dev;log_debug (" - found\n" );
@@ -695,7 +695,7 @@ int uclass_resolve_seq(struct udevice *dev)int seq =0 ;int ret; -assert (dev->seq ==-1 ); +assert (dev_seq (dev) ==-1 ); ret =uclass_find_device_by_seq (uc_drv->id, dev->req_seq, false, &dup);if (!ret) { dm_warn("Device '%s': seq %d is in use by '%s'\n",
drivers/gpio/octeon_gpio.c +1 -1
@@ -202,7 +202,7 @@ static int octeon_gpio_probe(struct udevice *dev) uc_priv->bank_name =strdup (dev->name); end =strchr (uc_priv->bank_name,'@' ); - end[0 ] ='A' + dev->seq; + end[0 ] ='A' +dev_seq (dev); end[1 ] ='\0' ; debug("%s(%s): base address: %p, pin count: %d\n",
drivers/i2c/ast_i2c.c +2 -2
@@ -110,7 +110,7 @@ static int ast_i2c_probe(struct udevice *dev) {struct ast2500_scu *scu; -debug ("Enabling I2C%u\n" , dev->seq); +debug ("Enabling I2C%u\n" ,dev_seq (dev));/* * Get all I2C devices out of Reset.
@@ -307,7 +307,7 @@ static int ast_i2c_set_speed(struct udevice *dev, unsigned int speed)struct ast_i2c_regs *regs = priv->regs;ulong i2c_rate, divider; -debug ("Setting speed for I2C%d to <%u>\n" , dev->seq, speed); +debug ("Setting speed for I2C%d to <%u>\n" ,dev_seq (dev), speed);if (!speed) {debug ("No valid speed specified\n" );return -EINVAL ;
drivers/i2c/davinci_i2c.c +1 -1
@@ -470,7 +470,7 @@ static int davinci_i2c_probe(struct udevice *dev) {struct i2c_bus *i2c_bus =dev_get_priv (dev); - i2c_bus->id = dev->seq; + i2c_bus->id =dev_seq (dev); i2c_bus->regs =dev_read_addr_ptr (dev); i2c_bus->speed =100000 ;
drivers/i2c/exynos_hs_i2c.c +1 -1
@@ -533,7 +533,7 @@ static int s3c_i2c_of_to_plat(struct udevice *dev)dev_read_u32_default (dev,"clock-frequency" ,I2C_SPEED_STANDARD_RATE ); i2c_bus->node = node; - i2c_bus->bus_num = dev->seq; + i2c_bus->bus_num =dev_seq (dev);exynos_pinmux_config (i2c_bus->id,PINMUX_FLAG_HS_MODE );
drivers/i2c/i2c-gpio.c +1 -1
@@ -298,7 +298,7 @@ static int i2c_gpio_probe(struct udevice *dev, uint chip, uint chip_flags)i2c_gpio_send_stop (bus, delay);debug ("%s: bus: %d (%s) chip: %x flags: %x ret: %d\n" , - __func__, dev->seq, dev->name, chip, chip_flags, ret); + __func__,dev_seq (dev), dev->name, chip, chip_flags, ret);return ret; }
drivers/i2c/imx_lpi2c.c +6 -6
@@ -289,7 +289,7 @@ static int bus_i2c_set_bus_speed(struct udevice *bus, int speed)return clock_rate; } }else { - clock_rate =imx_get_i2cclk (bus->seq); + clock_rate =imx_get_i2cclk (dev_seq (bus));if (!clock_rate)return -EPERM ; }
@@ -377,7 +377,7 @@ static int bus_i2c_init(struct udevice *bus, int speed) val =readl (®s->mcr) & ~LPI2C_MCR_MEN_MASK ;writel (val |LPI2C_MCR_MEN (1 ), ®s->mcr); -debug ("i2c : controller bus %d, speed %d:\n" , bus->seq, speed); +debug ("i2c : controller bus %d, speed %d:\n" ,dev_seq (bus), speed);return ret; }
@@ -452,11 +452,11 @@ static int imx_lpi2c_probe(struct udevice *bus)return -EINVAL ; i2c_bus->base = addr; - i2c_bus->index = bus->seq; + i2c_bus->index =dev_seq (bus); i2c_bus->bus = bus;/* power up i2c resource */ - ret =init_i2c_power (bus->seq); + ret =init_i2c_power (dev_seq (bus));if (ret) {debug ("init_i2c_power err = %d\n" , ret);return ret;
@@ -486,7 +486,7 @@ static int imx_lpi2c_probe(struct udevice *bus) } }else {/* To i.MX7ULP, only i2c4-7 can be handled by A7 core */ - ret =enable_i2c_clk (1 , bus->seq); + ret =enable_i2c_clk (1 ,dev_seq (bus));if (ret <0 )return ret; }
@@ -496,7 +496,7 @@ static int imx_lpi2c_probe(struct udevice *bus)return ret;debug ("i2c : controller bus %d@0x%lx , speed %d: " , - bus->seq, i2c_bus->base, +dev_seq (bus), i2c_bus->base, i2c_bus->speed);return 0 ;
drivers/i2c/lpc32xx_i2c.c +5 -1
@@ -282,7 +282,11 @@ U_BOOT_I2C_ADAP_COMPLETE(lpc32xx_2, lpc32xx_i2c_init, NULL,static int lpc32xx_i2c_probe (struct udevice *bus) {struct lpc32xx_i2c_dev *dev =dev_get_plat (bus); - bus->seq = dev->index; + +/* +* FIXME: This is not permitted +* dev_seq(bus) = dev->index; +*/ __i2c_init (dev->base, dev->speed,0 , dev->index);return 0 ;
drivers/i2c/mxc_i2c.c +5 -5
@@ -914,7 +914,7 @@ static int mxc_i2c_probe(struct udevice *bus) } i2c_bus->base = addr; - i2c_bus->index = bus->seq; + i2c_bus->index =dev_seq (bus); i2c_bus->bus = bus;/* Enable clk */
@@ -930,7 +930,7 @@ static int mxc_i2c_probe(struct udevice *bus) return ret; }#else - ret =enable_i2c_clk (1 , bus->seq); + ret =enable_i2c_clk (1 ,dev_seq (bus));if (ret <0 )return ret;#endif
@@ -942,7 +942,7 @@ static int mxc_i2c_probe(struct udevice *bus) ret =fdt_stringlist_search (fdt, node,"pinctrl-names" ,"gpio" );if (ret <0 ) {debug ("i2c bus %d@0x%2lx, no gpio pinctrl state.\n" , - bus->seq, i2c_bus->base); +dev_seq (bus), i2c_bus->base); }else { ret = gpio_request_by_name_nodev(offset_to_ofnode(node), "scl-gpios", 0, &i2c_bus->scl_gpio,
@@ -955,7 +955,7 @@ static int mxc_i2c_probe(struct udevice *bus) ret || ret2) {dev_err (bus,"i2c bus %d at %lu, fail to request scl/sda gpio\n" , - bus->seq, i2c_bus->base); +dev_seq (bus), i2c_bus->base);return -EINVAL ; } }
@@ -966,7 +966,7 @@ static int mxc_i2c_probe(struct udevice *bus)*/ debug ("i2c : controller bus %d at %lu , speed %d: " , - bus->seq, i2c_bus->base, +dev_seq (bus), i2c_bus->base, i2c_bus->speed);return 0 ;
drivers/i2c/nx_i2c.c +1 -1
@@ -240,7 +240,7 @@ static int nx_i2c_probe(struct udevice *dev)return -EINVAL ; bus->regs = (struct nx_i2c_regs *)addr; - bus->bus_num = dev->seq; + bus->bus_num =dev_seq (dev);/* i2c node parsing */ i2c_process_node (dev);
drivers/i2c/octeon_i2c.c +1 -1
@@ -811,7 +811,7 @@ static int octeon_i2c_probe(struct udevice *dev)if (ret)return ret; -debug ("TWSI bus %d at %p\n" , dev->seq, twsi->base); +debug ("TWSI bus %d at %p\n" ,dev_seq (dev), twsi->base);/* Start with standard speed, real speed set via DT or cmd */ return twsi_init (twsi->base, i2c_slave_addr);
drivers/i2c/s3c24x0_i2c.c +1 -1
@@ -318,7 +318,7 @@ static int s3c_i2c_of_to_plat(struct udevice *dev)dev_read_u32_default (dev,"clock-frequency" ,I2C_SPEED_STANDARD_RATE ); i2c_bus->node = node; - i2c_bus->bus_num = dev->seq; + i2c_bus->bus_num =dev_seq (dev);exynos_pinmux_config (i2c_bus->id,0 );
drivers/i2c/tegra_i2c.c +3 -2
@@ -362,7 +362,7 @@ static int tegra_i2c_probe(struct udevice *dev)int ret;bool is_dvc; - i2c_bus->id = dev->seq; + i2c_bus->id =dev_seq (dev); i2c_bus->type =dev_get_driver_data (dev); i2c_bus->regs = (struct i2c_ctlr *)dev_read_addr (dev);if ((ulong )i2c_bus->regs ==FDT_ADDR_T_NONE ) {
@@ -408,7 +408,8 @@ static int tegra_i2c_probe(struct udevice *dev) }i2c_init_controller (i2c_bus);debug ("%s: controller bus %d at %p, speed %d: " , - is_dvc ?"dvc" :"i2c" , dev->seq, i2c_bus->regs, i2c_bus->speed); + is_dvc ?"dvc" :"i2c" ,dev_seq (dev), i2c_bus->regs, + i2c_bus->speed);return 0 ; }
drivers/mmc/fsl_esdhc_imx.c +2 -2
@@ -1542,7 +1542,7 @@ static int fsl_esdhc_probe(struct udevice *dev)* work as expected. */ -init_clk_usdhc (dev->seq); +init_clk_usdhc (dev_seq (dev));#if CONFIG_IS_ENABLED (CLK )/* Assigned clock already set clock */
@@ -1559,7 +1559,7 @@ static int fsl_esdhc_probe(struct udevice *dev) priv->sdhc_clk =clk_get_rate (&priv->per_clk);#else - priv->sdhc_clk =mxc_get_clock (MXC_ESDHC_CLK + dev->seq); + priv->sdhc_clk =mxc_get_clock (MXC_ESDHC_CLK +dev_seq (dev));if (priv->sdhc_clk <=0 ) {dev_err (dev,"Unable to get clk for %s\n" , dev->name);return -EINVAL ;
drivers/mtd/spi/sandbox.c +2 -2
@@ -131,7 +131,7 @@ static int sandbox_sf_probe(struct udevice *dev)int ret =0 ;int cs =-1 ; -debug ("%s: bus %d, looking for emul=%p: " , __func__, bus->seq, dev); +debug ("%s: bus %d, looking for emul=%p: " , __func__,dev_seq (bus), dev); ret =sandbox_spi_get_emul (state, bus, dev, &emul);if (ret) { printf("Error: Unknown chip select for device '%s'\n",
@@ -565,7 +565,7 @@ int sandbox_spi_get_emul(struct sandbox_state *state, struct udevice **emulp) {struct sandbox_spi_info *info; -int busnum = bus->seq; +int busnum =dev_seq (bus);int cs =spi_chip_select (slave);int ret;
drivers/net/fec_mxc.c +4 -3
@@ -1451,7 +1451,7 @@ static int fecmxc_probe(struct udevice *dev)fec_reg_setup (priv); - priv->dev_id = dev->seq; + priv->dev_id =dev_seq (dev);#ifdef CONFIG_DM_ETH_PHY bus =eth_phy_get_mdio_bus (dev);
@@ -1459,9 +1459,10 @@ static int fecmxc_probe(struct udevice *dev)if (!bus) {#ifdef CONFIG_FEC_MXC_MDIO_BASE - bus =fec_get_miibus ((ulong )CONFIG_FEC_MXC_MDIO_BASE , dev->seq); + bus =fec_get_miibus ((ulong )CONFIG_FEC_MXC_MDIO_BASE , +dev_seq (dev));#else - bus =fec_get_miibus ((ulong )priv->eth, dev->seq); + bus =fec_get_miibus ((ulong )priv->eth,dev_seq (dev));#endif }if (!bus) {
drivers/net/fsl-mc/mc.c +1 -1
@@ -187,7 +187,7 @@ static int mc_fixup_mac_addr(void *blob, int nodeoffset,#ifdef CONFIG_DM_ETH struct eth_pdata *plat =dev_get_plat (eth_dev);unsigned char *enetaddr = plat->enetaddr; -int eth_index = eth_dev->seq; +int eth_index =dev_seq (eth_dev);#else unsigned char *enetaddr = eth_dev->enetaddr;int eth_index = eth_dev->index;
drivers/net/fsl_mcdmafec.c +1 -1
@@ -502,7 +502,7 @@ static int mcdmafec_probe(struct udevice *dev)int retval;const u32 *val; - info->index = dev->seq; + info->index =dev_seq (dev); info->iobase = pdata->iobase; info->miibase = pdata->iobase; info->phy_addr =-1 ;
drivers/net/ftgmac100.c +1 -1
@@ -171,7 +171,7 @@ static int ftgmac100_mdio_init(struct udevice *dev) bus->write = ftgmac100_mdio_write; bus->priv = priv; - ret =mdio_register_seq (bus, dev->seq); + ret =mdio_register_seq (bus,dev_seq (dev));if (ret) {free (bus);return ret;
drivers/net/higmacv300.c +1 -1
@@ -528,7 +528,7 @@ static int higmac_probe(struct udevice *dev) bus->priv = priv; priv->bus = bus; - ret =mdio_register_seq (bus, dev->seq); + ret =mdio_register_seq (bus,dev_seq (dev));if (ret)return ret;
drivers/net/mcffec.c +1 -1
@@ -524,7 +524,7 @@ static int mcffec_probe(struct udevice *dev)int retval, fec_idx;const u32 *val; - info->index = dev->seq; + info->index =dev_seq (dev); info->iobase = pdata->iobase; info->phy_addr =-1 ;
drivers/net/octeontx/nicvf_main.c +5 -4
@@ -452,11 +452,12 @@ int nicvf_write_hwaddr(struct udevice *dev)* u-boot framework updates MAC to random address. * Use this hook to update mac address in environment. */ -if (!eth_env_get_enetaddr_by_index ("eth" , dev->seq, ethaddr)) { -eth_env_set_enetaddr_by_index ("eth" , dev->seq, pdata->enetaddr); +if (!eth_env_get_enetaddr_by_index ("eth" ,dev_seq (dev), ethaddr)) { +eth_env_set_enetaddr_by_index ("eth" ,dev_seq (dev), + pdata->enetaddr);debug ("%s: pMAC %pM\n" , __func__, pdata->enetaddr); } -eth_env_get_enetaddr_by_index ("eth" , dev->seq, ethaddr); +eth_env_get_enetaddr_by_index ("eth" ,dev_seq (dev), ethaddr);if (memcmp (ethaddr, pdata->enetaddr,ARP_HLEN )) {debug ("%s: pMAC %pM\n" , __func__, pdata->enetaddr);nicvf_hw_set_mac_addr (nic, dev);
@@ -540,7 +541,7 @@ int nicvf_initialize(struct udevice *dev)if (is_valid_ethaddr (ethaddr)) {memcpy (pdata->enetaddr, ethaddr,ARP_HLEN ); -eth_env_set_enetaddr_by_index ("eth" , dev->seq, ethaddr); +eth_env_set_enetaddr_by_index ("eth" ,dev_seq (dev), ethaddr); }debug ("%s enetaddr %pM ethaddr %pM\n" , __func__, pdata->enetaddr, ethaddr);
drivers/net/octeontx/smi.c +1 -1
@@ -335,7 +335,7 @@ int octeontx_smi_probe(struct udevice *dev) priv =malloc (sizeof (*priv));if (!bus || !priv) {printf ("Failed to allocate OcteonTX MDIO bus # %u\n" , - dev->seq); +dev_seq (dev));return -1 ; }
drivers/net/octeontx2/nix.c +1 -1
@@ -736,7 +736,7 @@ int nix_lf_setup_mac(struct udevice *dev)*/ if (memcmp (nix->lmac->mac_addr, pdata->enetaddr,ARP_HLEN )) {memcpy (nix->lmac->mac_addr, pdata->enetaddr,6 ); -eth_env_set_enetaddr_by_index ("eth" , rvu->dev->seq, +eth_env_set_enetaddr_by_index ("eth" ,dev_seq (rvu->dev), pdata->enetaddr);cgx_lmac_mac_filter_setup (nix->lmac);/* Update user given MAC address to ATF for update
drivers/net/octeontx2/rvu_pf.c +3 -3
@@ -34,7 +34,7 @@ int rvu_pf_init(struct rvu_pf *rvu)/* to make post_probe happy */ if (is_valid_ethaddr (nix->lmac->mac_addr)) {memcpy (pdata->enetaddr, nix->lmac->mac_addr,6 ); -eth_env_set_enetaddr_by_index ("eth" , rvu->dev->seq, +eth_env_set_enetaddr_by_index ("eth" ,dev_seq (rvu->dev), pdata->enetaddr); }
@@ -59,7 +59,7 @@ int rvu_pf_probe(struct udevice *dev)debug ("%s: name: %s\n" , __func__, dev->name); rvu->pf_base =dm_pci_map_bar (dev,PCI_BASE_ADDRESS_2 ,PCI_REGION_MEM ); - rvu->pfid = dev->seq +1 ;// RVU PF's start from 1; + rvu->pfid =dev_seq (dev) +1 ;// RVU PF's start from 1; rvu->dev = dev;if (!rvu_af_dev) { printf("%s: Error: Could not find RVU AF device\n",
@@ -80,7 +80,7 @@ int rvu_pf_probe(struct udevice *dev)* modify device name to include index/sequence number, * for better readability, this is 1:1 mapping with eth0/1/2.. names. */ -sprintf (name,"rvu_pf#%d" , dev->seq); +sprintf (name,"rvu_pf#%d" ,dev_seq (dev));device_set_name (dev, name);debug ("%s: name: %s\n" , __func__, dev->name);return err;
drivers/net/xilinx_axi_emac.c +1 -1
@@ -697,7 +697,7 @@ static int axi_emac_probe(struct udevice *dev) priv->bus->write = axiemac_miiphy_write; priv->bus->priv = priv; - ret =mdio_register_seq (priv->bus, dev->seq); + ret =mdio_register_seq (priv->bus,dev_seq (dev));if (ret)return ret;
drivers/net/xilinx_emaclite.c +1 -1
@@ -568,7 +568,7 @@ static int emaclite_probe(struct udevice *dev) emaclite->bus->write = emaclite_miiphy_write; emaclite->bus->priv = emaclite; - ret =mdio_register_seq (emaclite->bus, dev->seq); + ret =mdio_register_seq (emaclite->bus,dev_seq (dev));if (ret)return ret;
drivers/net/zynq_gem.c +1 -1
@@ -705,7 +705,7 @@ static int zynq_gem_probe(struct udevice *dev) priv->bus->write = zynq_gem_miiphy_write; priv->bus->priv = priv; - ret =mdio_register_seq (priv->bus, dev->seq); + ret =mdio_register_seq (priv->bus,dev_seq (dev));if (ret) goto err2;
drivers/pci/pci-aardvark.c +1 -1
@@ -638,7 +638,7 @@ static int pcie_advk_probe(struct udevice *dev)dev_warn (pcie->dev,"PCIE Reset on GPIO support is missing\n" ); } - pcie->first_busno = dev->seq; + pcie->first_busno =dev_seq (dev); pcie->dev =pci_get_controller (dev);return pcie_advk_setup_hw (pcie);
drivers/pci/pci-uclass.c +18 -18
@@ -65,7 +65,7 @@ pci_dev_t dm_pci_get_bdf(const struct udevice *dev)if (!device_active (bus))log_err ("PCI: Device '%s' on unprobed bus '%s'\n" , dev->name, bus->name); -return PCI_ADD_BUS (bus->seq, pplat->devfn); +return PCI_ADD_BUS (dev_seq (bus), pplat->devfn); }/**
@@ -81,8 +81,8 @@ static int pci_get_bus_max(void) ret =uclass_get (UCLASS_PCI , &uc); uclass_foreach_dev(bus, uc) { -if (bus->seq > ret) - ret = bus->seq; +if (dev_seq (bus) > ret) + ret =dev_seq (bus); }debug ("%s: ret=%d\n" , __func__, ret);
@@ -513,7 +513,7 @@ static void set_vga_bridge_bits(struct udevice *dev)struct udevice *parent = dev->parent;u16 bc; -while (parent->seq !=0 ) { +while (dev_seq (parent) !=0 ) {dm_pci_read_config16 (parent,PCI_BRIDGE_CONTROL , &bc); bc |=PCI_BRIDGE_CTL_VGA ;dm_pci_write_config16 (parent,PCI_BRIDGE_CONTROL , bc);
@@ -529,7 +529,7 @@ int pci_auto_config_devices(struct udevice *bus)struct udevice *dev;int ret; - sub_bus = bus->seq; + sub_bus =dev_seq (bus);debug ("%s: start\n" , __func__);pciauto_config_init (hose); for (ret = device_find_first_child(bus, &dev);
@@ -645,9 +645,9 @@ int dm_pci_hose_probe_bus(struct udevice *bus) }if (!ea_pos) { -if (sub_bus != bus->seq) { +if (sub_bus !=dev_seq (bus)) {debug ("%s: Internal error, bus '%s' got seq %d, expected %d\n" , - __func__, bus->name, bus->seq, sub_bus); + __func__, bus->name,dev_seq (bus), sub_bus);return -EPIPE ; } sub_bus =pci_get_bus_max ();
@@ -771,7 +771,7 @@ static int pci_find_and_bind_driver(struct udevice *parent,return -EPERM ;/* Bind a generic driver so that the device can be used */ -sprintf (name,"pci_%x:%x.%x" , parent->seq,PCI_DEV (bdf), +sprintf (name,"pci_%x:%x.%x" ,dev_seq (parent),PCI_DEV (bdf),PCI_FUNC (bdf)); str =strdup (name);if (!str)
@@ -803,9 +803,9 @@ int pci_bind_bus_devices(struct udevice *bus)int ret; found_multi = false; - end =PCI_BDF (bus->seq,PCI_MAX_PCI_DEVICES -1 , + end =PCI_BDF (dev_seq (bus),PCI_MAX_PCI_DEVICES -1 ,PCI_MAX_PCI_FUNCTIONS -1 ); -for (bdf =PCI_BDF (bus->seq,0 ,0 ); bdf <= end; +for (bdf =PCI_BDF (dev_seq (bus),0 ,0 ); bdf <= end; bdf +=PCI_BDF (0 ,0 ,1 )) {struct pci_child_plat *pplat;struct udevice *dev;
@@ -832,7 +832,7 @@ int pci_bind_bus_devices(struct udevice *bus) found_multi = header_type &0x80 ;debug ("%s: bus %d/%s: found device %x, function %d" , __func__, - bus->seq, bus->name,PCI_DEV (bdf),PCI_FUNC (bdf)); +dev_seq (bus), bus->name,PCI_DEV (bdf),PCI_FUNC (bdf));pci_bus_read_config (bus, bdf,PCI_DEVICE_ID , &device,PCI_SIZE_16 ); pci_bus_read_config(bus, bdf, PCI_CLASS_REVISION, &class,
@@ -1010,7 +1010,7 @@ static int pci_uclass_pre_probe(struct udevice *bus) {struct pci_controller *hose; -debug ("%s, bus=%d/%s, parent=%s\n" , __func__, bus->seq, bus->name, +debug ("%s, bus=%d/%s, parent=%s\n" , __func__,dev_seq (bus), bus->name, bus->parent->name); hose = bus->uclass_priv;
@@ -1025,8 +1025,8 @@ static int pci_uclass_pre_probe(struct udevice *bus) hose->ctlr = parent_hose->bus; } hose->bus = bus; - hose->first_busno = bus->seq; - hose->last_busno = bus->seq; + hose->first_busno =dev_seq (bus); + hose->last_busno =dev_seq (bus);if (dev_of_valid (bus)) { hose->skip_auto_config_until_reloc = dev_read_bool(bus,
@@ -1041,7 +1041,7 @@ static int pci_uclass_post_probe(struct udevice *bus)struct pci_controller *hose =dev_get_uclass_priv (bus);int ret; -debug ("%s: probing bus %d\n" , __func__, bus->seq); +debug ("%s: probing bus %d\n" , __func__,dev_seq (bus)); ret =pci_bind_bus_devices (bus);if (ret)return ret;
@@ -1068,7 +1068,7 @@ static int pci_uclass_post_probe(struct udevice *bus)* Note we only call this 1) after U-Boot is relocated, and 2) * root bus has finished probing. */ -if ((gd->flags &GD_FLG_RELOC ) && bus->seq ==0 &&ll_boot_init ()) { +if ((gd->flags &GD_FLG_RELOC ) &&dev_seq (bus) ==0 &&ll_boot_init ()) { ret =fsp_init_phase_pci ();if (ret)return ret;
@@ -1732,7 +1732,7 @@ int pci_sriov_init(struct udevice *pdev, int vf_en) &class, PCI_SIZE_16);debug ("%s: bus %d/%s: found VF %x:%x\n" , __func__, - bus->seq, bus->name,PCI_DEV (bdf),PCI_FUNC (bdf)); +dev_seq (bus), bus->name,PCI_DEV (bdf),PCI_FUNC (bdf));/* Find this device in the device tree */ ret =pci_bus_find_devfn (bus,PCI_MASK_BUS (bdf), &dev);
@@ -1763,7 +1763,7 @@ int pci_sriov_init(struct udevice *pdev, int vf_en) pplat->virtid = vf * vf_stride + vf_offset;debug ("%s: bus %d/%s: found VF %x:%x %x:%x class %lx id %x\n" , - __func__, dev->seq, dev->name,PCI_DEV (bdf), + __func__,dev_seq (dev), dev->name,PCI_DEV (bdf),PCI_FUNC (bdf), vendor, device, class, pplat->virtid); bdf +=PCI_BDF (0 ,0 , vf_stride); }
drivers/pci/pci_auto.c +3 -3
@@ -189,8 +189,8 @@ void dm_pciauto_prescan_setup_bridge(struct udevice *dev, int sub_bus)/* Configure bus number registers */ dm_pci_write_config8 (dev,PCI_PRIMARY_BUS , -PCI_BUS (dm_pci_get_bdf (dev)) - ctlr->seq); -dm_pci_write_config8 (dev,PCI_SECONDARY_BUS , sub_bus - ctlr->seq); +PCI_BUS (dm_pci_get_bdf (dev)) -dev_seq (ctlr)); +dm_pci_write_config8 (dev,PCI_SECONDARY_BUS , sub_bus -dev_seq (ctlr));dm_pci_write_config8 (dev,PCI_SUBORDINATE_BUS ,0xff );if (pci_mem) {
@@ -265,7 +265,7 @@ void dm_pciauto_postscan_setup_bridge(struct udevice *dev, int sub_bus) pci_io = ctlr_hose->pci_io;/* Configure bus number registers */ -dm_pci_write_config8 (dev,PCI_SUBORDINATE_BUS , sub_bus - ctlr->seq); +dm_pci_write_config8 (dev,PCI_SUBORDINATE_BUS , sub_bus -dev_seq (ctlr));if (pci_mem) {/* Round memory allocator to 1MB boundary */
drivers/pci/pcie_dw_mvebu.c +3 -3
@@ -500,13 +500,13 @@ static int pcie_dw_mvebu_probe(struct udevice *dev)debug ("PCIE Reset on GPIO support is missing\n" );#endif /* DM_GPIO */ - pcie->first_busno = dev->seq; + pcie->first_busno =dev_seq (dev);/* Don't register host if link is down */ if (!pcie_dw_mvebu_pcie_link_up (pcie->ctrl_base,LINK_SPEED_GEN_3 )) { -printf ("PCIE-%d: Link down\n" , dev->seq); +printf ("PCIE-%d: Link down\n" ,dev_seq (dev)); }else { -printf ("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n" , dev->seq, +printf ("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n" ,dev_seq (dev),pcie_dw_get_link_speed (pcie->ctrl_base),pcie_dw_get_link_width (pcie->ctrl_base), hose->first_busno);
drivers/pci/pcie_dw_ti.c +3 -3
@@ -634,7 +634,7 @@ static int pcie_dw_ti_probe(struct udevice *dev)generic_phy_init (&phy1);generic_phy_power_on (&phy1); - pci->first_busno = dev->seq; + pci->first_busno =dev_seq (dev); pci->dev = dev;pcie_dw_setup_host (pci);
@@ -644,11 +644,11 @@ static int pcie_dw_ti_probe(struct udevice *dev)pcie_am654_set_mode (pci,DW_PCIE_RC_TYPE );if (!pcie_dw_ti_pcie_link_up (pci,LINK_SPEED_GEN_2 )) { -printf ("PCIE-%d: Link down\n" , dev->seq); +printf ("PCIE-%d: Link down\n" ,dev_seq (dev));return -ENODEV ; } -printf ("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n" , dev->seq, +printf ("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n" ,dev_seq (dev),pcie_dw_get_link_speed (pci),pcie_dw_get_link_width (pci), hose->first_busno);
drivers/pci/pcie_ecam_generic.c +1 -1
@@ -146,7 +146,7 @@ static int pci_generic_ecam_probe(struct udevice *dev) {struct generic_ecam_pcie *pcie =dev_get_priv (dev); - pcie->first_busno = dev->seq; + pcie->first_busno =dev_seq (dev);return 0 ; }
drivers/pci/pcie_fsl.c +8 -8
@@ -29,16 +29,16 @@ static int fsl_pcie_addr_valid(struct fsl_pcie *pcie, pci_dev_t bdf)if (!pcie->enabled)return -ENXIO ; -if (PCI_BUS (bdf) < bus->seq) +if (PCI_BUS (bdf) <dev_seq (bus))return -EINVAL ; -if (PCI_BUS (bdf) > bus->seq && (!fsl_pcie_link_up (pcie) || pcie->mode)) +if (PCI_BUS (bdf) >dev_seq (bus) && (!fsl_pcie_link_up (pcie) || pcie->mode))return -EINVAL ; -if (PCI_BUS (bdf) == bus->seq && (PCI_DEV (bdf) >0 ||PCI_FUNC (bdf) >0 )) +if (PCI_BUS (bdf) ==dev_seq (bus) && (PCI_DEV (bdf) >0 ||PCI_FUNC (bdf) >0 ))return -EINVAL ; -if (PCI_BUS (bdf) == (bus->seq +1 ) && (PCI_DEV (bdf) >0 )) +if (PCI_BUS (bdf) == (dev_seq (bus) +1 ) && (PCI_DEV (bdf) >0 ))return -EINVAL ;return 0 ;
@@ -57,7 +57,7 @@ static int fsl_pcie_read_config(const struct udevice *bus, pci_dev_t bdf,return 0 ; } - bdf = bdf -PCI_BDF (bus->seq,0 ,0 ); + bdf = bdf -PCI_BDF (dev_seq (bus),0 ,0 ); val = bdf | (offset &0xfc ) | ((offset &0xf00 ) <<16 ) |0x80000000 ;out_be32 (®s->cfg_addr, val);
@@ -93,7 +93,7 @@ static int fsl_pcie_write_config(struct udevice *bus, pci_dev_t bdf,if (fsl_pcie_addr_valid (pcie, bdf))return 0 ; - bdf = bdf -PCI_BDF (bus->seq,0 ,0 ); + bdf = bdf -PCI_BDF (dev_seq (bus),0 ,0 ); val = bdf | (offset &0xfc ) | ((offset &0xf00 ) <<16 ) |0x80000000 ;out_be32 (®s->cfg_addr, val);
@@ -123,7 +123,7 @@ static int fsl_pcie_hose_read_config(struct fsl_pcie *pcie, uint offset,int ret;struct udevice *bus = pcie->bus; - ret =fsl_pcie_read_config (bus,PCI_BDF (bus->seq,0 ,0 ), + ret =fsl_pcie_read_config (bus,PCI_BDF (dev_seq (bus),0 ,0 ), offset, valuep, size);return ret;
@@ -134,7 +134,7 @@ static int fsl_pcie_hose_write_config(struct fsl_pcie *pcie, uint offset, {struct udevice *bus = pcie->bus; -return fsl_pcie_write_config (bus,PCI_BDF (bus->seq,0 ,0 ), +return fsl_pcie_write_config (bus,PCI_BDF (dev_seq (bus),0 ,0 ), offset, value, size); }
drivers/pci/pcie_intel_fpga.c +1 -1
@@ -369,7 +369,7 @@ static int pcie_intel_fpga_probe(struct udevice *dev)struct intel_fpga_pcie *pcie =dev_get_priv (dev); pcie->bus =pci_get_controller (dev); - pcie->first_busno = dev->seq; + pcie->first_busno =dev_seq (dev);/* clear all interrupts */ cra_writel (pcie,P2A_INT_STS_ALL ,P2A_INT_STATUS );
drivers/pci/pcie_layerscape_fixup.c +2 -2
@@ -479,7 +479,7 @@ static int fdt_fixup_pci_vfs(void *blob, struct extra_iommu_entry *entry,for (bus = dev;device_is_on_pci_bus (bus);) bus = bus->parent; - bdf = entry->bdf -PCI_BDF (bus->seq,0 ,0 ) + (vf_offset <<8 ); + bdf = entry->bdf -PCI_BDF (dev_seq (bus),0 ,0 ) + (vf_offset <<8 );for (i =0 ; i < entry->num_vfs; i++) {if (fdt_fixup_pcie_device_ls (blob, bdf, pcie_rc) <0 )
@@ -518,7 +518,7 @@ static void fdt_fixup_pcie_ls(void *blob) pcie_rc =dev_get_priv (bus);/* the DT fixup must be relative to the hose first_busno */ - bdf =dm_pci_get_bdf (dev) -PCI_BDF (bus->seq,0 ,0 ); + bdf =dm_pci_get_bdf (dev) -PCI_BDF (dev_seq (bus),0 ,0 );if (fdt_fixup_pcie_device_ls (blob, bdf, pcie_rc) <0 )break ;
drivers/pci/pcie_layerscape_gen4.c +5 -5
@@ -191,13 +191,13 @@ static int ls_pcie_g4_addr_valid(struct ls_pcie_g4 *pcie, pci_dev_t bdf)if (!pcie->enabled)return -ENXIO ; -if (PCI_BUS (bdf) < bus->seq) +if (PCI_BUS (bdf) <dev_seq (bus))return -EINVAL ; -if ((PCI_BUS (bdf) > bus->seq) && (!ls_pcie_g4_link_up (pcie))) +if ((PCI_BUS (bdf) >dev_seq (bus)) && (!ls_pcie_g4_link_up (pcie)))return -EINVAL ; -if (PCI_BUS (bdf) <= (bus->seq +1 ) && (PCI_DEV (bdf) >0 )) +if (PCI_BUS (bdf) <= (dev_seq (bus) +1 ) && (PCI_DEV (bdf) >0 ))return -EINVAL ;return 0 ;
@@ -209,7 +209,7 @@ void *ls_pcie_g4_conf_address(struct ls_pcie_g4 *pcie, pci_dev_t bdf,struct udevice *bus = pcie->bus;u32 target; -if (PCI_BUS (bdf) == bus->seq) { +if (PCI_BUS (bdf) ==dev_seq (bus)) {if (offset <INDIRECT_ADDR_BNDRY ) {ccsr_set_page (pcie,0 );return pcie->ccsr + offset;
@@ -219,7 +219,7 @@ void *ls_pcie_g4_conf_address(struct ls_pcie_g4 *pcie, pci_dev_t bdf,return pcie->ccsr +OFFSET_TO_PAGE_ADDR (offset); } - target =PAB_TARGET_BUS (PCI_BUS (bdf) - bus->seq) | + target =PAB_TARGET_BUS (PCI_BUS (bdf) -dev_seq (bus)) |PAB_TARGET_DEV (PCI_DEV (bdf)) |PAB_TARGET_FUNC (PCI_FUNC (bdf));
drivers/pci/pcie_layerscape_gen4_fixup.c +1 -1
@@ -166,7 +166,7 @@ static void fdt_fixup_pcie_ls_gen4(void *blob) }/* the DT fixup must be relative to the hose first_busno */ - bdf =dm_pci_get_bdf (dev) -PCI_BDF (bus->seq,0 ,0 ); + bdf =dm_pci_get_bdf (dev) -PCI_BDF (dev_seq (bus),0 ,0 );/* map PCI b.d.f to streamID in LUT */ ls_pcie_g4_lut_set_mapping (pcie, index, bdf >>8 , streamid);/* update msi-map in device tree */
drivers/pci/pcie_layerscape_rc.c +6 -6
@@ -130,13 +130,13 @@ static int ls_pcie_addr_valid(struct ls_pcie_rc *pcie_rc, pci_dev_t bdf)if (!pcie_rc->enabled)return -ENXIO ; -if (PCI_BUS (bdf) < bus->seq) +if (PCI_BUS (bdf) <dev_seq (bus))return -EINVAL ; -if ((PCI_BUS (bdf) > bus->seq) && (!ls_pcie_link_up (pcie))) +if ((PCI_BUS (bdf) >dev_seq (bus)) && (!ls_pcie_link_up (pcie)))return -EINVAL ; -if (PCI_BUS (bdf) <= (bus->seq +1 ) && (PCI_DEV (bdf) >0 )) +if (PCI_BUS (bdf) <= (dev_seq (bus) +1 ) && (PCI_DEV (bdf) >0 ))return -EINVAL ;return 0 ;
@@ -152,16 +152,16 @@ int ls_pcie_conf_address(const struct udevice *bus, pci_dev_t bdf,if (ls_pcie_addr_valid (pcie_rc, bdf))return -EINVAL ; -if (PCI_BUS (bdf) == bus->seq) { +if (PCI_BUS (bdf) ==dev_seq (bus)) { *paddress = pcie->dbi + offset;return 0 ; } - busdev =PCIE_ATU_BUS (PCI_BUS (bdf) - bus->seq) | + busdev =PCIE_ATU_BUS (PCI_BUS (bdf) -dev_seq (bus)) |PCIE_ATU_DEV (PCI_DEV (bdf)) |PCIE_ATU_FUNC (PCI_FUNC (bdf)); -if (PCI_BUS (bdf) == bus->seq +1 ) { +if (PCI_BUS (bdf) ==dev_seq (bus) +1 ) {ls_pcie_cfg0_set_busdev (pcie_rc, busdev); *paddress = pcie_rc->cfg0 + offset; }else {
drivers/pci/pcie_mediatek.c +1 -1
@@ -261,7 +261,7 @@ static struct mtk_pcie_port *mtk_pcie_find_port(const struct udevice *bus,return NULL ; } -while (dev->parent->seq !=0 ) +while (dev_seq (dev->parent) !=0 ) dev = dev->parent; pplat =dev_get_parent_plat (dev);
drivers/pci/pcie_rockchip.c +3 -3
@@ -373,7 +373,7 @@ static int rockchip_pcie_init_port(struct udevice *dev)/* Configure Address Translation. */ ret =rockchip_pcie_atr_init (priv);if (ret) { -dev_err (dev,"PCIE-%d: ATR init failed\n" , dev->seq); +dev_err (dev,"PCIE-%d: ATR init failed\n" ,dev_seq (dev)); goto err_power_off_phy; }
@@ -528,7 +528,7 @@ static int rockchip_pcie_probe(struct udevice *dev)struct pci_controller *hose =dev_get_uclass_priv (ctlr);int ret; - priv->first_busno = dev->seq; + priv->first_busno =dev_seq (dev); priv->dev = dev; ret =rockchip_pcie_parse_dt (dev);
@@ -544,7 +544,7 @@ static int rockchip_pcie_probe(struct udevice *dev)return ret;dev_info (dev,"PCIE-%d: Link up (Bus%d)\n" , - dev->seq, hose->first_busno); +dev_seq (dev), hose->first_busno);return 0 ; }
drivers/serial/serial_mcf.c +1 -1
@@ -85,7 +85,7 @@ static int coldfire_serial_probe(struct udevice *dev) {struct coldfire_serial_plat *plat = dev->plat; - plat->port = dev->seq; + plat->port =dev_seq (dev);return mcf_serial_init_common ((uart_t *)plat->base, plat->port, plat->baudrate);
drivers/serial/serial_s5p.c +1 -1
@@ -187,7 +187,7 @@ static int s5p_serial_of_to_plat(struct udevice *dev) plat->reg = (struct s5p_uart *)addr; plat->port_id =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"id" , dev->seq); +"id" ,dev_seq (dev));return 0 ; }
drivers/spi/altera_spi.c +1 -1
@@ -98,7 +98,7 @@ static int altera_spi_xfer(struct udevice *dev, unsigned int bitlen,uint32_t reg, data, start;debug ("%s: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n" , __func__, - bus->seq, slave_plat->cs, bitlen, bytes, flags); +dev_seq (bus), slave_plat->cs, bitlen, bytes, flags);if (bitlen ==0 ) goto done;
drivers/spi/cf_spi.c +6 -6
@@ -240,7 +240,7 @@ static int coldfire_spi_set_speed(struct udevice *bus, uint max_hz) cfspi->baudrate = max_hz;/* Read current setup */ - bus_setup =readl (&dspi->ctar[bus->seq]); + bus_setup =readl (&dspi->ctar[dev_seq (bus)]); tmp = (prescaler[3 ] * scaler[15 ]);/* Maximum and minimum baudrate it can handle */
@@ -294,7 +294,7 @@ static int coldfire_spi_set_speed(struct udevice *bus, uint max_hz) bus_setup &= ~(DSPI_CTAR_PBR (0x03 ) |DSPI_CTAR_BR (0x0f )); bus_setup |= (DSPI_CTAR_PBR (best_i) |DSPI_CTAR_BR (best_j)); -writel (bus_setup, &dspi->ctar[bus->seq]); +writel (bus_setup, &dspi->ctar[dev_seq (bus)]);return 0 ; }
@@ -318,7 +318,7 @@ static int coldfire_spi_set_mode(struct udevice *bus, uint mode)if (cfspi->mode &SPI_MODE_MOD ) {if ((cfspi->mode &SPI_MODE_XFER_SZ_MASK ) ==0 ) bus_setup |= -readl (&dspi->ctar[bus->seq]) &MCF_FRM_SZ_16BIT ; +readl (&dspi->ctar[dev_seq (bus)]) &MCF_FRM_SZ_16BIT ;else bus_setup |= ((cfspi->mode &SPI_MODE_XFER_SZ_MASK ) >>1 );
@@ -329,14 +329,14 @@ static int coldfire_spi_set_mode(struct udevice *bus, uint mode) bus_setup |= (cfspi->mode &SPI_MODE_DLY_SCA_MASK ) >>4 ; }else { bus_setup |= - (readl (&dspi->ctar[bus->seq]) &MCF_CTAR_MODE_MASK ); + (readl (&dspi->ctar[dev_seq (bus)]) &MCF_CTAR_MODE_MASK ); } cfspi->charbit = - ((readl (&dspi->ctar[bus->seq]) &MCF_FRM_SZ_16BIT ) == + ((readl (&dspi->ctar[dev_seq (bus)]) &MCF_FRM_SZ_16BIT ) ==MCF_FRM_SZ_16BIT ) ?16 :8 ; -setbits_be32 (&dspi->ctar[bus->seq], bus_setup); +setbits_be32 (&dspi->ctar[dev_seq (bus)], bus_setup);return 0 ; }
drivers/spi/fsl_dspi.c +3 -3
@@ -511,7 +511,7 @@ static int fsl_dspi_probe(struct udevice *bus)DSPI_MCR_CRXF |DSPI_MCR_CTXF ;fsl_dspi_init_mcr (priv, mcr_cfg_val); -debug ("%s probe done, bus-num %d.\n" , bus->name, bus->seq); +debug ("%s probe done, bus-num %d.\n" , bus->name,dev_seq (bus));return 0 ; }
@@ -527,7 +527,7 @@ static int fsl_dspi_claim_bus(struct udevice *dev) priv =dev_get_priv (bus);/* processor special preparation work */ -cpu_dspi_claim_bus (bus->seq, slave_plat->cs); +cpu_dspi_claim_bus (dev_seq (bus), slave_plat->cs);/* configure transfer mode */ fsl_dspi_cfg_ctar_mode (priv, slave_plat->cs, priv->mode);
@@ -559,7 +559,7 @@ static int fsl_dspi_release_bus(struct udevice *dev)dspi_halt (priv,1 );/* processor special release work */ -cpu_dspi_release_bus (bus->seq, slave_plat->cs); +cpu_dspi_release_bus (dev_seq (bus), slave_plat->cs);return 0 ; }
drivers/spi/fsl_espi.c +1 -1
@@ -527,7 +527,7 @@ static int fsl_espi_probe(struct udevice *bus) fsl->max_transfer_length =ESPI_MAX_DATA_TRANSFER_LEN ; fsl->speed_hz = plat->speed_hz; -debug ("%s probe done, bus-num %d.\n" , bus->name, bus->seq); +debug ("%s probe done, bus-num %d.\n" , bus->name,dev_seq (bus));return 0 ; }
drivers/spi/octeon_spi.c +1 -1
@@ -593,7 +593,7 @@ static int octeon_spi_probe(struct udevice *dev)if (ret)return ret; -debug ("SPI bus %s %d at %p\n" , dev->name, dev->seq, priv->base); +debug ("SPI bus %s %d at %p\n" , dev->name,dev_seq (dev), priv->base);return 0 ; }
drivers/spi/pic32_spi.c +2 -2
@@ -247,7 +247,7 @@ static int pic32_spi_xfer(struct udevice *slave, unsigned int bitlen, slave_plat =dev_get_parent_plat (slave);debug ("spi_xfer: bus:%i cs:%i flags:%lx\n" , - bus->seq, slave_plat->cs, flags); +dev_seq (bus), slave_plat->cs, flags);debug ("msg tx %p, rx %p submitted of %d byte(s)\n" , tx_buf, rx_buf, len);
@@ -384,7 +384,7 @@ static int pic32_spi_probe(struct udevice *bus)fdt_size_t size;int ret; -debug ("%s: %d, bus: %i\n" , __func__, __LINE__, bus->seq); +debug ("%s: %d, bus: %i\n" , __func__, __LINE__,dev_seq (bus)); addr =fdtdec_get_addr_size (gd->fdt_blob, node,"reg" , &size);if (addr ==FDT_ADDR_T_NONE )return -EINVAL ;
drivers/spi/sandbox_spi.c +1 -1
@@ -72,7 +72,7 @@ static int sandbox_spi_xfer(struct udevice *slave, unsigned int bitlen,return -EINVAL ; } - busnum = bus->seq; + busnum =dev_seq (bus); cs =spi_chip_select (slave);if (busnum >=CONFIG_SANDBOX_SPI_MAX_BUS || cs >=CONFIG_SANDBOX_SPI_MAX_CS ) {
drivers/spi/tegra114_spi.c +1 -1
@@ -231,7 +231,7 @@ static int tegra114_spi_xfer(struct udevice *dev, unsigned int bitlen,int ret;debug ("%s: slave %u:%u dout %p din %p bitlen %u\n" , - __func__, bus->seq,spi_chip_select (dev), dout, din, bitlen); + __func__,dev_seq (bus),spi_chip_select (dev), dout, din, bitlen);if (bitlen %8 )return -1 ; num_bytes = bitlen /8 ;
drivers/spi/tegra20_sflash.c +1 -1
@@ -217,7 +217,7 @@ static int tegra20_sflash_xfer(struct udevice *dev, unsigned int bitlen,int ret;debug ("%s: slave %u:%u dout %p din %p bitlen %u\n" , - __func__, bus->seq,spi_chip_select (dev), dout, din, bitlen); + __func__,dev_seq (bus),spi_chip_select (dev), dout, din, bitlen);if (bitlen %8 )return -1 ; num_bytes = bitlen /8 ;
drivers/spi/tegra20_slink.c +1 -1
@@ -211,7 +211,7 @@ static int tegra30_spi_xfer(struct udevice *dev, unsigned int bitlen,int ret;debug ("%s: slave %u:%u dout %p din %p bitlen %u\n" , - __func__, bus->seq,spi_chip_select (dev), dout, din, bitlen); + __func__,dev_seq (bus),spi_chip_select (dev), dout, din, bitlen);if (bitlen %8 )return -1 ; num_bytes = bitlen /8 ;
drivers/spi/tegra210_qspi.c +1 -1
@@ -223,7 +223,7 @@ static int tegra210_qspi_xfer(struct udevice *dev, unsigned int bitlen,int num_bytes, tm, ret;debug ("%s: slave %u:%u dout %p din %p bitlen %u\n" , - __func__, bus->seq,spi_chip_select (dev), dout, din, bitlen); + __func__,dev_seq (bus),spi_chip_select (dev), dout, din, bitlen);if (bitlen %8 )return -1 ; num_bytes = bitlen /8 ;
drivers/spi/xilinx_spi.c +1 -1
@@ -255,7 +255,7 @@ static int xilinx_spi_xfer(struct udevice *dev, unsigned int bitlen,int ret;debug ("spi_xfer: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n" , - bus->seq, slave_plat->cs, bitlen, bytes, flags); +dev_seq (bus), slave_plat->cs, bitlen, bytes, flags);if (bitlen ==0 ) goto done;
drivers/spi/zynq_qspi.c +1 -1
@@ -568,7 +568,7 @@ static int zynq_qspi_xfer(struct udevice *dev, unsigned int bitlen, priv->len = bitlen /8 ;debug ("zynq_qspi_xfer: bus:%i cs:%i bitlen:%i len:%i flags:%lx\n" , - bus->seq, slave_plat->cs, bitlen, priv->len, flags); +dev_seq (bus), slave_plat->cs, bitlen, priv->len, flags);/* * Festering sore.
drivers/spi/zynq_spi.c +1 -1
@@ -242,7 +242,7 @@ static int zynq_spi_xfer(struct udevice *dev, unsigned int bitlen,u32 ts, status;debug ("spi_xfer: bus:%i cs:%i bitlen:%i len:%i flags:%lx\n" , - bus->seq, slave_plat->cs, bitlen, len, flags); +dev_seq (bus), slave_plat->cs, bitlen, len, flags);if (bitlen %8 ) {debug ("spi_xfer: Non byte aligned SPI transfer\n" );
drivers/usb/gadget/max3420_udc.c +1 -1
@@ -821,7 +821,7 @@ static int max3420_udc_probe(struct udevice *dev)struct max3420_udc *udc =dev_get_priv (dev);struct dm_spi_slave_plat *slave_pdata;struct udevice *bus = dev->parent; -int busnum = bus->seq; +int busnum =dev_seq (bus);unsigned int cs;uint speed, mode;struct udevice *spid;
drivers/usb/host/ehci-mx5.c +1 -1
@@ -321,7 +321,7 @@ static int ehci_usb_probe(struct udevice *dev)mdelay (1 ); priv->ehci = ehci; - priv->portnr = dev->seq; + priv->portnr =dev_seq (dev); priv->init_type = type; ret = device_get_supply_regulator(dev, "vbus-supply",
drivers/usb/host/ehci-mx6.c +1 -1
@@ -596,7 +596,7 @@ static int ehci_usb_probe(struct udevice *dev) } priv->ehci = ehci; - priv->portnr = dev->seq; + priv->portnr =dev_seq (dev); priv->init_type = type;#if CONFIG_IS_ENABLED (DM_REGULATOR )
drivers/usb/host/ehci-omap.c +1 -1
@@ -383,7 +383,7 @@ static int omap_ehci_probe(struct udevice *dev)struct ehci_hcor *hcor; priv->ehci =dev_read_addr_ptr (dev); - priv->portnr = dev->seq; + priv->portnr =dev_seq (dev); priv->init_type = plat->init_type; hccr = (struct ehci_hccr *)&priv->ehci->hccapbase;
drivers/usb/host/ehci-vf.c +1 -1
@@ -222,7 +222,7 @@ static int vf_usb_of_to_plat(struct udevice *dev)int node =dev_of_offset (dev);const char *mode; - priv->portnr = dev->seq; + priv->portnr =dev_seq (dev); priv->ehci =dev_read_addr_ptr (dev); mode =fdt_getprop (dt_blob, node,"dr_mode" ,NULL );
drivers/usb/host/usb-sandbox.c +1 -1
@@ -23,7 +23,7 @@ static void usbmon_trace(struct udevice *bus, ulong pipe, type = (pipe &USB_PIPE_TYPE_MASK ) >>USB_PIPE_TYPE_SHIFT ;debug ("0 0 S %c%c:%d:%03ld:%ld" , types[type], pipe &USB_DIR_IN ?'i' :'o' , - bus->seq, +dev_seq (bus), (pipe &USB_PIPE_DEV_MASK ) >>USB_PIPE_DEV_SHIFT , (pipe &USB_PIPE_EP_MASK ) >>USB_PIPE_EP_SHIFT );if (setup) {
drivers/usb/host/usb-uclass.c +1 -1
@@ -701,7 +701,7 @@ int usb_scan_device(struct udevice *parent, int port,return ret; ret =usb_find_and_bind_driver (parent, &udev->descriptor, iface, - udev->controller_dev->seq, +dev_seq (udev->controller_dev), udev->devnum, port, &dev);if (ret)return ret;
drivers/video/vidconsole-uclass.c +2 -2
@@ -606,9 +606,9 @@ static int vidconsole_post_probe(struct udevice *dev)if (!priv->tab_width_frac) priv->tab_width_frac =VID_TO_POS (priv->x_charsize) *8 ; -if (dev->seq) { +if (dev_seq (dev)) {snprintf (sdev->name,sizeof (sdev->name),"vidconsole%d" , - dev->seq); +dev_seq (dev)); }else {strcpy (sdev->name,"vidconsole" ); }
drivers/virtio/virtio-uclass.c +1 -1
@@ -240,7 +240,7 @@ static int virtio_uclass_post_probe(struct udevice *udev) }snprintf (dev_name,sizeof (dev_name),"%s#%d" , - virtio_drv_name[uc_priv->device], udev->seq); + virtio_drv_name[uc_priv->device],dev_seq (udev)); str =strdup (dev_name);if (!str)return -ENOMEM ;
drivers/watchdog/ast_wdt.c +1 -1
@@ -113,7 +113,7 @@ static const struct udevice_id ast_wdt_ids[] = {static int ast_wdt_probe (struct udevice *dev) { -debug ("%s() wdt%u\n" , __func__, dev->seq); +debug ("%s() wdt%u\n" , __func__,dev_seq (dev));ast_wdt_stop (dev);return 0 ;
drivers/watchdog/at91sam9_wdt.c +1 -1
@@ -108,7 +108,7 @@ static int at91_wdt_probe(struct udevice *dev)if (!priv->regs)return -EINVAL ; -debug ("%s: Probing wdt%u\n" , __func__, dev->seq); +debug ("%s: Probing wdt%u\n" , __func__,dev_seq (dev));return 0 ; }
drivers/watchdog/cdns_wdt.c +1 -1
@@ -223,7 +223,7 @@ static int cdns_wdt_stop(struct udevice *dev)*/ static int cdns_wdt_probe (struct udevice *dev) { -debug ("%s: Probing wdt%u\n" , __func__, dev->seq); +debug ("%s: Probing wdt%u\n" , __func__,dev_seq (dev));return 0 ; }
drivers/watchdog/omap_wdt.c +1 -1
@@ -242,7 +242,7 @@ static int omap3_wdt_probe(struct udevice *dev)return -EINVAL ; priv->wdt_trgr_pattern =0x1234 ; -debug ("%s: Probing wdt%u\n" , __func__, dev->seq); +debug ("%s: Probing wdt%u\n" , __func__,dev_seq (dev));return 0 ; }
drivers/watchdog/orion_wdt.c +1 -1
@@ -158,7 +158,7 @@ static int orion_wdt_probe(struct udevice *dev)struct orion_wdt_priv *priv =dev_get_priv (dev);int ret; -debug ("%s: Probing wdt%u\n" , __func__, dev->seq); +debug ("%s: Probing wdt%u\n" , __func__,dev_seq (dev));orion_wdt_stop (dev); ret =clk_get_by_name (dev,"fixed" , &priv->clk);
drivers/watchdog/sbsa_gwdt.c +1 -1
@@ -88,7 +88,7 @@ static int sbsa_gwdt_expire_now(struct udevice *dev, ulong flags)static int sbsa_gwdt_probe (struct udevice *dev) { -debug ("%s: Probing wdt%u (sbsa-gwdt)\n" , __func__, dev->seq); +debug ("%s: Probing wdt%u (sbsa-gwdt)\n" , __func__,dev_seq (dev));return 0 ; }
drivers/watchdog/sp805_wdt.c +1 -1
@@ -105,7 +105,7 @@ static int sp805_wdt_expire_now(struct udevice *dev, ulong flags)static int sp805_wdt_probe (struct udevice *dev) { -debug ("%s: Probing wdt%u (sp805-wdt)\n" , __func__, dev->seq); +debug ("%s: Probing wdt%u (sp805-wdt)\n" , __func__,dev_seq (dev));return 0 ; }
drivers/watchdog/tangier_wdt.c +1 -1
@@ -80,7 +80,7 @@ static const struct udevice_id tangier_wdt_ids[] = {static int tangier_wdt_probe (struct udevice *dev) { -debug ("%s: Probing wdt%u\n" , __func__, dev->seq); +debug ("%s: Probing wdt%u\n" , __func__,dev_seq (dev));return 0 ; }
drivers/watchdog/xilinx_tb_wdt.c +1 -1
@@ -85,7 +85,7 @@ static int xlnx_wdt_start(struct udevice *dev, u64 timeout, ulong flags)static int xlnx_wdt_probe (struct udevice *dev) { -debug ("%s: Probing wdt%u\n" , __func__, dev->seq); +debug ("%s: Probing wdt%u\n" , __func__,dev_seq (dev));return 0 ; }
drivers/watchdog/xilinx_wwdt.c +1 -1
@@ -128,7 +128,7 @@ static int xlnx_wwdt_probe(struct udevice *dev)struct xlnx_wwdt_plat *plat =dev_get_plat (dev);struct xlnx_wwdt_priv *wdt =dev_get_priv (dev); -dev_dbg (dev,"%s: Probing wdt%u\n" , __func__, dev->seq); +dev_dbg (dev,"%s: Probing wdt%u\n" , __func__,dev_seq (dev)); ret =regmap_init_mem (dev_ofnode (dev), &wdt->regs);if (ret) {
include/dm/device.h +5 -0
@@ -182,6 +182,11 @@ static inline bool dev_has_of_node(struct udevice *dev)return ofnode_valid (dev->node); } +static inline int dev_seq (const struct udevice *dev) +{ +return dev->seq; +} +/** * struct udevice_id - Lists the compatible strings supported by a driver * @compatible: Compatible string
include/pci.h +1 -1
@@ -934,7 +934,7 @@ struct dm_pci_ops {* PCI buses must support reading and writing configuration values * so that the bus can be scanned and its devices configured. * -* Normally PCI_BUS(@bdf) is the same as @bus->seq, but not always. +* Normally PCI_BUS(@bdf) is the same as @dev_seq(bus), but not always. * If bridges exist it is possible to use the top-level bus to * access a sub-bus. In that case @bus will be the top-level bus * and PCI_BUS(bdf) will be a different (higher) value
include/spi.h +1 -1
@@ -116,7 +116,7 @@ enum spi_polarity {* claimed. * @bus: ID of the bus that the slave is attached to. For * driver model this is the sequence number of the SPI -* bus (bus->seq) so does not need to be stored +* bus (dev_seq(bus)) so does not need to be stored * @cs: ID of the chip select connected to the slave. * @mode: SPI mode to use for this slave (see SPI mode flags) * @wordlen: Size of SPI word in number of bits
lib/efi_loader/efi_device_path.c +2 -2
@@ -624,7 +624,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) DEVICE_PATH_SUB_TYPE_MSG_SD :DEVICE_PATH_SUB_TYPE_MSG_MMC ; sddp->dp.length =sizeof (*sddp); - sddp->slot_number = dev->seq; + sddp->slot_number =dev_seq (dev); return &sddp[1]; }#endif
@@ -677,7 +677,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) DEVICE_PATH_SUB_TYPE_MSG_SD :DEVICE_PATH_SUB_TYPE_MSG_MMC ; sddp->dp.length =sizeof (*sddp); - sddp->slot_number = dev->seq; + sddp->slot_number =dev_seq (dev);return &sddp[1 ]; }
net/eth-uclass.c +10 -9
@@ -137,7 +137,7 @@ struct udevice *eth_get_dev_by_name(const char *devname)continue ;/* Check for the name or the sequence number to match */ if (strcmp (it->name, devname) ==0 || - (endp > startp && it->seq == seq)) + (endp > startp &&dev_seq (it) == seq))return it; }
@@ -189,7 +189,7 @@ void eth_halt_state_only(void)int eth_get_dev_index (void ) {if (eth_get_dev ()) -return eth_get_dev ()->seq; +return dev_seq (eth_get_dev ());return -1 ; }
@@ -202,7 +202,7 @@ static int eth_write_hwaddr(struct udevice *dev)return -EINVAL ;/* seq is valid since the device is active */ -if (eth_get_ops (dev)->write_hwaddr && !eth_mac_skip (dev->seq)) { +if (eth_get_ops (dev)->write_hwaddr && !eth_mac_skip (dev_seq (dev))) { pdata = dev->plat;if (!is_valid_ethaddr (pdata->enetaddr)) { printf("\nError: %s address %pM illegal value\n",
@@ -434,11 +434,11 @@ int eth_initialize(void)bootstage_mark (BOOTSTAGE_ID_NET_ETH_INIT ); do { - if (dev->seq != -1) { + if (dev_seq(dev) != -1) { if (num_devices) printf(", "); - printf("eth%d: %s", dev->seq, dev->name); + printf("eth%d: %s", dev_seq(dev), dev->name); if (ethprime && dev == prime_dev) printf(" [PRIME]");
@@ -446,7 +446,7 @@ int eth_initialize(void)eth_write_hwaddr (dev); -if (dev->seq !=-1 ) +if (dev_seq (dev) !=-1 ) num_devices++;uclass_next_device_check (&dev); }while (dev);
@@ -547,7 +547,7 @@ static int eth_post_probe(struct udevice *dev)eth_get_ops (dev)->read_rom_hwaddr (dev); } -eth_env_get_enetaddr_by_index ("eth" , dev->seq, env_enetaddr); +eth_env_get_enetaddr_by_index ("eth" ,dev_seq (dev), env_enetaddr);if (!is_zero_ethaddr (env_enetaddr)) {if (!is_zero_ethaddr (pdata->enetaddr) &&memcmp (pdata->enetaddr, env_enetaddr,ARP_HLEN )) {
@@ -562,13 +562,14 @@ static int eth_post_probe(struct udevice *dev)/* Override the ROM MAC address */ memcpy (pdata->enetaddr, env_enetaddr,ARP_HLEN ); }else if (is_valid_ethaddr (pdata->enetaddr)) { -eth_env_set_enetaddr_by_index ("eth" , dev->seq, pdata->enetaddr); +eth_env_set_enetaddr_by_index ("eth" ,dev_seq (dev), + pdata->enetaddr); }else if (is_zero_ethaddr (pdata->enetaddr) || !is_valid_ethaddr (pdata->enetaddr)) {#ifdef CONFIG_NET_RANDOM_ETHADDR net_random_ethaddr (pdata->enetaddr);printf ("\nWarning: %s (eth%d) using random MAC address - %pM\n" , - dev->name, dev->seq, pdata->enetaddr); + dev->name,dev_seq (dev), pdata->enetaddr);#else printf ("\nError: %s address not set.\n" , dev->name);
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 2/28 dm: Avoid accessing seq directly
At present various drivers etc. access the device's 'seq' member directly. This makes it harder to change the meaning of that member. Change access to go through a function instead.
The drivers/i2c/lpc32xx_i2c.c file is left unchanged for now.
---
(no changes since v1)
arch/arm/include/asm/mach-imx/mxc_i2c.h | 2 +- arch/x86/cpu/broadwell/cpu_full.c | 2 +- arch/x86/cpu/ivybridge/model_206ax.c | 2 +- board/xilinx/versal/board.c | 12 ++++---- board/xilinx/zynqmp/zynqmp.c | 12 ++++---- cmd/axi.c | 4 +-- cmd/cpu.c | 2 +- cmd/i2c.c | 4 +-- cmd/misc.c | 2 +- cmd/osd.c | 4 +-- cmd/pci.c | 7 +++-- cmd/pmic.c | 4 +-- cmd/remoteproc.c | 2 +- cmd/w1.c | 4 +-- drivers/core/device.c | 2 +- drivers/core/dump.c | 4 +-- drivers/core/uclass.c | 6 ++-- drivers/gpio/octeon_gpio.c | 2 +- drivers/i2c/ast_i2c.c | 4 +-- drivers/i2c/davinci_i2c.c | 2 +- drivers/i2c/exynos_hs_i2c.c | 2 +- drivers/i2c/i2c-gpio.c | 2 +- drivers/i2c/imx_lpi2c.c | 12 ++++---- drivers/i2c/lpc32xx_i2c.c | 6 +++- drivers/i2c/mxc_i2c.c | 10 +++---- drivers/i2c/nx_i2c.c | 2 +- drivers/i2c/octeon_i2c.c | 2 +- drivers/i2c/s3c24x0_i2c.c | 2 +- drivers/i2c/tegra_i2c.c | 5 ++-- drivers/mmc/fsl_esdhc_imx.c | 4 +-- drivers/mtd/spi/sandbox.c | 4 +-- 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 | 2 +- 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 | 36 ++++++++++++------------ drivers/pci/pci_auto.c | 6 ++-- 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/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 | 6 ++-- drivers/spi/fsl_espi.c | 2 +- drivers/spi/octeon_spi.c | 2 +- drivers/spi/pic32_spi.c | 4 +-- drivers/spi/sandbox_spi.c | 2 +- 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 | 2 +- drivers/usb/host/ehci-omap.c | 2 +- drivers/usb/host/ehci-vf.c | 2 +- drivers/usb/host/usb-sandbox.c | 2 +- drivers/usb/host/usb-uclass.c | 2 +- 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 | 5 ++++ include/pci.h | 2 +- include/spi.h | 2 +- lib/efi_loader/efi_device_path.c | 4 +-- net/eth-uclass.c | 19 +++++++------ 98 files changed, 211 insertions(+), 197 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 3/28 dm: core: Update uclass_find_next_free_req_seq() args
In reply to Simon GlassAt present this is passed a uclass ID and it has to do a lookup. The callers all have the uclass pointer, except for the I2C uclass where the code will soon be deleted.
Update the argument to a uclass * instead of an ID since it is more efficient.
---
(no changes since v1)
drivers/core/device.c | 4 ++-- drivers/core/uclass.c | 8 +------- drivers/i2c/designware_i2c_pci.c | 8 +++++++- include/dm/uclass-internal.h | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-)
drivers/core/device.c +2 -2
@@ -89,10 +89,10 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,#if CONFIG_IS_ENABLED (OF_PRIOR_STAGE )if (dev->req_seq ==-1 ) dev->req_seq = -uclass_find_next_free_req_seq (drv->id); +uclass_find_next_free_req_seq (uc);#endif }else { - dev->req_seq =uclass_find_next_free_req_seq (drv->id); + dev->req_seq =uclass_find_next_free_req_seq (uc); } }
drivers/core/uclass.c +1 -7
@@ -272,17 +272,11 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,return -ENODEV ; } -int uclass_find_next_free_req_seq (enum uclass_id id) +int uclass_find_next_free_req_seq (struct uclass *uc) { -struct uclass *uc;struct udevice *dev; -int ret;int max =-1 ; - ret =uclass_get (id, &uc); -if (ret) -return ret; -list_for_each_entry (dev, &uc->dev_head, uclass_node) {if ((dev->req_seq !=-1 ) && (dev->req_seq > max)) max = dev->req_seq;
drivers/i2c/designware_i2c_pci.c +7 -1
@@ -90,7 +90,9 @@ static int designware_i2c_pci_probe(struct udevice *dev)static int designware_i2c_pci_bind (struct udevice *dev) { +struct uclass *uc;char name[20 ]; +int ret;if (dev_of_valid (dev))return 0 ;
@@ -108,7 +110,11 @@ static int designware_i2c_pci_bind(struct udevice *dev)* be possible. We cannot use static data in drivers since they may be * used in SPL or before relocation. */ - dev->req_seq =uclass_find_next_free_req_seq (UCLASS_I2C ); + ret =uclass_get (UCLASS_I2C , &uc); +if (ret) +return ret; + + dev->req_seq =uclass_find_next_free_req_seq (uc);sprintf (name,"i2c_designware#%u" , dev->req_seq);device_set_name (dev, name);
include/dm/uclass-internal.h +2 -2
@@ -19,10 +19,10 @@* maximum req_seq of the uclass + 1. * This allows assiging req_seq number in the binding order. * -* @id: Id number of the uclass +* @uc: uclass to check * @return The next free req_seq number */ -int uclass_find_next_free_req_seq (enum uclass_id id); +int uclass_find_next_free_req_seq (struct uclass *uc);/** * uclass_get_device_tail() - handle the end of a get_device call
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 3/28 dm: core: Update uclass_find_next_free_req_seq() args
At present this is passed a uclass ID and it has to do a lookup. The callers all have the uclass pointer, except for the I2C uclass where the code will soon be deleted.
Update the argument to a uclass * instead of an ID since it is more efficient.
---
(no changes since v1)
drivers/core/device.c | 4 ++-- drivers/core/uclass.c | 8 +------- drivers/i2c/designware_i2c_pci.c | 8 +++++++- include/dm/uclass-internal.h | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 4/28 dm: core: Add a new sequence number for devices
In reply to Simon GlassAt 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 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. 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).
Add a new 'sqq' member, the bind-time sequence number. It operates in parallel to the old values for now. All devices get a valid sqq value, i.e. it is never -1.
Drop an #ifdef while we are here.
---
(no changes since v2)
Changes in v2:
- Give all devices a sequence number
- Drop uclass_alloc_all_seqs() and GD_FLG_DM_NO_SEQ flag
drivers/core/device.c | 22 ++++++++++++++++------ drivers/core/root.c | 8 +++++--- include/dm/device.h | 8 ++++++++ 3 files changed, 29 insertions(+), 9 deletions(-)
drivers/core/device.c +16 -6
@@ -41,6 +41,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,struct udevice *dev;struct uclass *uc;int size, ret =0 ; +bool auto_seq = true;if (devp) *devp =NULL ;
@@ -73,6 +74,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv, dev->seq =-1 ; dev->req_seq =-1 ; + dev->sqq =-1 ;if (CONFIG_IS_ENABLED (DM_SEQ_ALIAS ) && (uc->uc_drv->flags &DM_UC_FLAG_SEQ_ALIAS )) {/*
@@ -84,17 +86,25 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,*/ if (CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA )) { -if (uc->uc_drv->name &&ofnode_valid (node)) +if (uc->uc_drv->name &&ofnode_valid (node)) { +dev_read_alias_seq (dev, &dev->sqq);dev_read_alias_seq (dev, &dev->req_seq); -#if CONFIG_IS_ENABLED (OF_PRIOR_STAGE ) -if (dev->req_seq ==-1 ) - dev->req_seq = -uclass_find_next_free_req_seq (uc); -#endif + auto_seq = false; + } +if (CONFIG_IS_ENABLED (OF_PRIOR_STAGE )) { +if (dev->req_seq ==-1 ) { + auto_seq = true; + dev->req_seq = +uclass_find_next_free_req_seq ( + uc); + } + } }else { dev->req_seq =uclass_find_next_free_req_seq (uc); } } +if (auto_seq) + dev->sqq =uclass_find_next_free_req_seq (uc);if (drv->plat_auto) {bool alloc = !plat;
drivers/core/root.c +5 -3
@@ -311,22 +311,24 @@ int dm_init_and_scan(bool pre_reloc_only) ret =dm_scan_plat (pre_reloc_only);if (ret) {debug ("dm_scan_plat() failed: %d\n" , ret); -return ret; + goto fail; }if (CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA )) { ret =dm_extended_scan (pre_reloc_only);if (ret) {debug ("dm_extended_scan() failed: %d\n" , ret); -return ret; + goto fail; } } ret =dm_scan_other (pre_reloc_only);if (ret) -return ret; + goto fail;return 0 ; +fail: +return ret; }#ifdef CONFIG_ACPIGEN
include/dm/device.h +8 -0
@@ -131,6 +131,13 @@ enum {* @child_head: List of children of this device * @sibling_node: Next device in list of all devices * @flags: Flags for this device DM_FLAG_... +* @sqq: Allocated sequence number for this device (-1 = none). This is set up +* when the device is bound and is unique within the device's uclass. If the +* device has an alias in the devicetree then that is used to set the sequence +* number. Otherwise, the next available number is used. Sequence numbers are +* used by certain commands that need device to be numbered (e.g. 'mmc dev') +* +* The following two fields are deprecated: * @req_seq: Requested sequence number for this device (-1 = any) * @seq: Allocated sequence number for this device (-1 = none). This is set up * when the device is probed and will be unique within the device's uclass.
@@ -156,6 +163,7 @@ struct udevice {struct list_head child_head;struct list_head sibling_node;uint32_t flags; +int sqq;int req_seq;int seq;#ifdef CONFIG_DEVRES
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 4/28 dm: core: Add a new sequence number for devices
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 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. 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).
Add a new 'sqq' member, the bind-time sequence number. It operates in parallel to the old values for now. All devices get a valid sqq value, i.e. it is never -1.
Drop an #ifdef while we are here.
---
(no changes since v2)
Changes in v2:
- Give all devices a sequence number
- Drop uclass_alloc_all_seqs() and GD_FLG_DM_NO_SEQ flag
drivers/core/device.c | 22 ++++++++++++++++------ drivers/core/root.c | 8 +++++--- include/dm/device.h | 8 ++++++++ 3 files changed, 29 insertions(+), 9 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 5/28 dm: test: Check all devices have a sequence numbers
In reply to Simon GlassAdd a test that the new sequence numbers work as expected. Every device should get one.
---
(no changes since v2)
Changes in v2:
- Drop the GD_FLG_DM_NO_SEQ flag
test/dm/core.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
test/dm/core.c +19 -0
@@ -1066,3 +1066,22 @@ static int dm_test_inactive_child(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_inactive_child,UT_TESTF_SCAN_PDATA ); + +/* Make sure all bound devices have a sequence number */ +static int dm_test_all_have_seq (struct unit_test_state *uts) +{ +struct udevice *dev; +struct uclass *uc; + +list_for_each_entry (uc, &gd->uclass_root, sibling_node) { +list_for_each_entry (dev, &uc->dev_head, uclass_node) { +if (dev->sqq ==-1 ) +printf ("Device '%s' has no seq (%d)\n" , + dev->name, dev->sqq); +ut_assert (dev->sqq !=-1 ); + } + } + +return 0 ; +} +DM_TEST (dm_test_all_have_seq,UT_TESTF_SCAN_PDATA );
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 5/28 dm: test: Check all devices have a sequence numbers
Add a test that the new sequence numbers work as expected. Every device should get one.
---
(no changes since v2)
Changes in v2:
- Drop the GD_FLG_DM_NO_SEQ flag
test/dm/core.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
Applied to u-boot-dm/next, thanks!
PATCH v3 6/28 dm: core: Switch binding to use new sequence numbers
In reply to Simon GlassUpdate the core logic to use the new approach. For now the old code is left as is. Update one test so it still passes.
---
(no changes since v1)
drivers/core/device.c | 5 +---- test/dm/bus.c | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/core/device.c +1 -4
@@ -661,12 +661,9 @@ int device_find_child_by_seq(const struct udevice *parent, int seq_or_req_seq,struct udevice *dev; *devp =NULL ; -if (seq_or_req_seq ==-1 ) -return -ENODEV ;list_for_each_entry (dev, &parent->child_head, sibling_node) { -if ((find_req_seq ? dev->req_seq :dev_seq (dev)) == - seq_or_req_seq) { +if (dev->sqq == seq_or_req_seq) { *devp = dev;return 0 ; }
test/dm/bus.c +2 -1
@@ -159,9 +159,10 @@ static int dm_test_bus_children_funcs(struct unit_test_state *uts)ut_asserteq (-ENODEV ,device_find_child_by_seq (bus,-1 , true, &dev));ut_assertok (device_find_child_by_seq (bus,0 , true, &dev));ut_assert (!(dev->flags &DM_FLAG_ACTIVATED )); -ut_asserteq (-ENODEV ,device_find_child_by_seq (bus,0 , false, &dev)); +ut_asserteq (0 ,device_find_child_by_seq (bus,0 , false, &dev));ut_assertok (device_get_child_by_seq (bus,0 , &dev));ut_assert (dev->flags &DM_FLAG_ACTIVATED ); +ut_asserteq (0 ,device_find_child_by_seq (bus,0 , false, &dev));/* There is no device with sequence number 2 */ ut_asserteq (-ENODEV ,device_find_child_by_seq (bus,2 , false, &dev));
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 6/28 dm: core: Switch binding to use new sequence numbers
Update the core logic to use the new approach. For now the old code is left as is. Update one test so it still passes.
---
(no changes since v1)
drivers/core/device.c | 5 +---- test/dm/bus.c | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 7/28 dm: Fix return value in dev_read_alias_seq()
In reply to Simon GlassThis should return 0 on success but currently does not. Fix it.
---
(no changes since v1)
drivers/core/read.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/core/read.c +3 -1
@@ -281,8 +281,10 @@ int dev_read_alias_seq(const struct udevice *dev, int *devnump)if (ofnode_is_np (node)) { ret =of_alias_get_id (ofnode_to_np (node), uc_name); -if (ret >=0 ) +if (ret >=0 ) { *devnump = ret; + ret =0 ; + } }else {#if CONFIG_IS_ENABLED (OF_CONTROL ) ret = fdtdec_get_alias_seq(gd->fdt_blob, uc_name,
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 7/28 dm: Fix return value in dev_read_alias_seq()
This should return 0 on success but currently does not. Fix it.
---
(no changes since v1)
drivers/core/read.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 8/28 dm: test: Drop assumptions of no sequence numbers
In reply to Simon GlassDrop code in a few tests which assumes that sequence numbers are only valid when a device is probed.
---
(no changes since v1)
test/dm/blk.c | 3 --- test/dm/i2c.c | 3 --- test/dm/spi.c | 3 --- 3 files changed, 9 deletions(-)
test/dm/blk.c +0 -3
@@ -19,9 +19,6 @@ static int dm_test_blk_base(struct unit_test_state *uts) {struct udevice *blk1, *blk3, *dev; -/* Make sure there are no block devices */ -ut_asserteq (-ENODEV ,uclass_get_device_by_seq (UCLASS_BLK ,0 , &dev)); -/* Create two, one the parent of the other */ ut_assertok (blk_create_device (gd->dm_root,"sandbox_host_blk" ,"test" ,IF_TYPE_HOST ,1 ,512 ,2 , &blk1));
test/dm/i2c.c +0 -3
@@ -28,9 +28,6 @@ static int dm_test_i2c_find(struct unit_test_state *uts)struct udevice *bus, *dev;const int no_chip =0x10 ; -ut_asserteq (-ENODEV ,uclass_find_device_by_seq (UCLASS_I2C , busnum, - false, &bus)); -/* * The post_bind() method will bind devices to chip selects. Check * this then remove the emulation and the slave device.
test/dm/spi.c +0 -3
@@ -26,9 +26,6 @@ static int dm_test_spi_find(struct unit_test_state *uts)struct spi_cs_info info;ofnode node; -ut_asserteq (-ENODEV ,uclass_find_device_by_seq (UCLASS_SPI , busnum, - false, &bus)); -/* * The post_bind() method will bind devices to chip selects. Check * this then remove the emulation and the slave device.
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 8/28 dm: test: Drop assumptions of no sequence numbers
Drop code in a few tests which assumes that sequence numbers are only valid when a device is probed.
---
(no changes since v1)
test/dm/blk.c | 3 --- test/dm/i2c.c | 3 --- test/dm/spi.c | 3 --- 3 files changed, 9 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 9/28 octeon: Don't attempt to set the sequence number
In reply to Simon GlassSeveral Octeon drivers operate by setting the sequence number of their device. This should not be needed with the new sequence number setup. Also it is not permitted. Drop it.
---
(no changes since v1)
drivers/i2c/octeon_i2c.c | 1 - drivers/mmc/octeontx_hsmmc.c | 2 -- drivers/net/octeontx/smi.c | 1 - 3 files changed, 4 deletions(-)
drivers/i2c/octeon_i2c.c +0 -1
@@ -791,7 +791,6 @@ static int octeon_i2c_probe(struct udevice *dev)pci_dev_t bdf =dm_pci_get_bdf (dev);debug ("TWSI PCI device: %x\n" , bdf); - dev->req_seq =PCI_FUNC (bdf); twsi->base =dm_pci_map_bar (dev,PCI_BASE_ADDRESS_0 ,PCI_REGION_MEM );
drivers/mmc/octeontx_hsmmc.c +0 -2
@@ -3731,7 +3731,6 @@ U_BOOT_DRIVER(octeontx_hsmmc_slot) = {*/ static int octeontx_mmc_host_probe (struct udevice *dev) { -pci_dev_t bdf =dm_pci_get_bdf (dev);struct octeontx_mmc_host *host =dev_get_priv (dev);union mio_emm_int emm_int;u8 rev;
@@ -3757,7 +3756,6 @@ static int octeontx_mmc_host_probe(struct udevice *dev)return -1 ; } host->node = dev->node; - dev->req_seq =PCI_FUNC (bdf); host->last_slotid =-1 ;if (otx_is_platform (PLATFORM_ASIM )) host->is_asim = true;
drivers/net/octeontx/smi.c +0 -1
@@ -319,7 +319,6 @@ int octeontx_smi_probe(struct udevice *dev)pci_dev_t bdf =dm_pci_get_bdf (dev);debug ("SMI PCI device: %x\n" , bdf); - dev->req_seq =PCI_FUNC (bdf);if (!dm_pci_map_bar (dev,PCI_BASE_ADDRESS_0 ,PCI_REGION_MEM )) {printf ("Failed to map PCI region for bdf %x\n" , bdf);return -1 ;
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 9/28 octeon: Don't attempt to set the sequence number
Several Octeon drivers operate by setting the sequence number of their device. This should not be needed with the new sequence number setup. Also it is not permitted. Drop it.
---
(no changes since v1)
drivers/i2c/octeon_i2c.c | 1 - drivers/mmc/octeontx_hsmmc.c | 2 -- drivers/net/octeontx/smi.c | 1 - 3 files changed, 4 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 10/28 i2c: Update for new sequence numbers
In reply to Simon GlassUse the new sequence number in all cases. Drop the logic to check for a valid number in designware_i2c, since it will always be valid.
Also drop the numbering in the uclass, since we can rely on driver model giving us the right sequence numbers.
---
(no changes since v2)
Changes in v2:
- Drop special numbering in the i2c uclass
drivers/i2c/designware_i2c_pci.c | 22 +---------------- drivers/i2c/i2c-uclass.c | 39 +----------------------------- drivers/i2c/i2c-versatile.c | 5 ---- drivers/i2c/intel_i2c.c | 12 +-------- drivers/i2c/muxes/i2c-mux-uclass.c | 4 +-- drivers/i2c/mvtwsi.c | 6 ++--- 6 files changed, 8 insertions(+), 80 deletions(-)
drivers/i2c/designware_i2c_pci.c +1 -21
@@ -90,32 +90,12 @@ static int designware_i2c_pci_probe(struct udevice *dev)static int designware_i2c_pci_bind (struct udevice *dev) { -struct uclass *uc;char name[20 ]; -int ret;if (dev_of_valid (dev))return 0 ; -/* -* Create a unique device name for PCI type devices -* ToDo: -* Setting req_seq in the driver is probably not recommended. -* But without a DT alias the number is not configured. And -* using this driver is impossible for PCIe I2C devices. -* This can be removed, once a better (correct) way for this -* is found and implemented. -* -* TODO(sjg at chromium.org): Perhaps if uclasses had platdata this would -* be possible. We cannot use static data in drivers since they may be -* used in SPL or before relocation. -*/ - ret =uclass_get (UCLASS_I2C , &uc); -if (ret) -return ret; - - dev->req_seq =uclass_find_next_free_req_seq (uc); -sprintf (name,"i2c_designware#%u" , dev->req_seq); +sprintf (name,"i2c_designware#%u" ,dev_seq (dev));device_set_name (dev, name);return 0 ;
drivers/i2c/i2c-uclass.c +1 -38
@@ -686,27 +686,11 @@ static int i2c_child_post_bind(struct udevice *dev)#endif } -struct i2c_priv { -int max_id; -}; -static int i2c_post_bind (struct udevice *dev) { -struct uclass *class = dev->uclass; -struct i2c_priv *priv = class->priv;int ret =0 ; -/* Just for sure */ -if (!priv) -return -ENOMEM ; - -debug ("%s: %s, req_seq=%d\n" , __func__, dev->name, dev->req_seq); - -/* if there is no alias ID, use the first free */ -if (dev->req_seq ==-1 ) - dev->req_seq = ++priv->max_id; - -debug ("%s: %s, new req_seq=%d\n" , __func__, dev->name, dev->req_seq); +debug ("%s: %s, seq=%d\n" , __func__, dev->name,dev_seq (dev));#if CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA ) ret =dm_scan_fdt_dev (dev);
@@ -714,32 +698,11 @@ static int i2c_post_bind(struct udevice *dev)return ret; } -int i2c_uclass_init (struct uclass *class) -{ -struct i2c_priv *priv = class->priv; - -/* Just for sure */ -if (!priv) -return -ENOMEM ; - -/* Get the last allocated alias. */ -if (CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA )) - priv->max_id =dev_read_alias_highest_id ("i2c" ); -else - priv->max_id =-1 ; - -debug ("%s: highest alias id is %d\n" , __func__, priv->max_id); - -return 0 ; -} -UCLASS_DRIVER (i2c) = { .id =UCLASS_I2C , .name ="i2c" , .flags =DM_UC_FLAG_SEQ_ALIAS , .post_bind = i2c_post_bind, - .init = i2c_uclass_init, - .priv_auto =sizeof (struct i2c_priv ), .pre_probe = i2c_pre_probe, .post_probe = i2c_post_probe, .per_device_auto =sizeof (struct dm_i2c_bus ),
drivers/i2c/i2c-versatile.c +0 -5
@@ -252,11 +252,6 @@ static int versatile_i2c_probe(struct udevice *dev) priv->base = (phys_addr_t )dev_read_addr (dev); priv->delay =25 ;/* 25us * 4 = 100kHz */ -/* -* U-Boot still doesn't assign automatically -* sequence numbers to devices -*/ - dev->req_seq =1 ;return 0 ; }
drivers/i2c/intel_i2c.c +1 -11
@@ -269,21 +269,11 @@ static int intel_i2c_probe(struct udevice *dev)static int intel_i2c_bind (struct udevice *dev) { - static int num_cards __attribute__ ((section(".data")));char name[20 ];/* Create a unique device name for PCI type devices */ if (device_is_on_pci_bus (dev)) { -/* -* ToDo: -* Setting req_seq in the driver is probably not recommended. -* But without a DT alias the number is not configured. And -* using this driver is impossible for PCIe I2C devices. -* This can be removed, once a better (correct) way for this -* is found and implemented. -*/ - dev->req_seq = num_cards; -sprintf (name,"intel_i2c#%u" , num_cards++); +sprintf (name,"intel_i2c#%u" ,dev_seq (dev));device_set_name (dev, name); }
drivers/i2c/muxes/i2c-mux-uclass.c +2 -2
@@ -87,8 +87,8 @@ static int i2c_mux_post_bind(struct udevice *mux) ret =device_bind_driver_to_node (mux,"i2c_mux_bus_drv" , full_name, node, &dev); -debug (" - bind ret=%d, %s, req_seq %d\n" , ret, - dev ? dev->name :NULL , dev->req_seq); +debug (" - bind ret=%d, %s, seq %d\n" , ret, + dev ? dev->name :NULL ,dev_seq (dev));if (ret)return ret; }
drivers/i2c/mvtwsi.c +3 -3
@@ -823,9 +823,9 @@ static int mvtwsi_i2c_bind(struct udevice *bus)struct mvtwsi_registers *twsi =dev_read_addr_ptr (bus);/* Disable the hidden slave in i2c0 of these platforms */ -if ((IS_ENABLED (CONFIG_ARMADA_38X ) ||IS_ENABLED (CONFIG_ARCH_KIRKWOOD ) - ||IS_ENABLED (CONFIG_ARMADA_8K )) - && bus->req_seq ==0 ) +if ((IS_ENABLED (CONFIG_ARMADA_38X ) || +IS_ENABLED (CONFIG_ARCH_KIRKWOOD ) || +IS_ENABLED (CONFIG_ARMADA_8K )) && !dev_seq (bus))twsi_disable_i2c_slave (twsi);return 0 ;
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 10/28 i2c: Update for new sequence numbers
Use the new sequence number in all cases. Drop the logic to check for a valid number in designware_i2c, since it will always be valid.
Also drop the numbering in the uclass, since we can rely on driver model giving us the right sequence numbers.
---
(no changes since v2)
Changes in v2:
- Drop special numbering in the i2c uclass
drivers/i2c/designware_i2c_pci.c | 22 +---------------- drivers/i2c/i2c-uclass.c | 39 +----------------------------- drivers/i2c/i2c-versatile.c | 5 ---- drivers/i2c/intel_i2c.c | 12 +-------- drivers/i2c/muxes/i2c-mux-uclass.c | 4 +-- drivers/i2c/mvtwsi.c | 6 ++--- 6 files changed, 8 insertions(+), 80 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 11/28 net: Update to use new sequence numbers
In reply to Simon GlassChecking for seq == -1 is effectively checking that the device is activated. The new sequence numbers are never -1 for a bound device, so update the check.
Also drop the note about valid sequence numbers so it is accurate with the new approach.
---
(no changes since v1)
drivers/net/dwc_eth_qos.c | 2 +- net/eth-uclass.c | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/net/dwc_eth_qos.c +1 -1
@@ -1155,7 +1155,7 @@ static int eqos_read_rom_hwaddr(struct udevice *dev)struct eth_pdata *pdata =dev_get_plat (dev);#ifdef CONFIG_ARCH_IMX8M -imx_get_mac_from_fuse (dev->req_seq, pdata->enetaddr); +imx_get_mac_from_fuse (dev_seq (dev), pdata->enetaddr);#endif return !is_valid_ethaddr (pdata->enetaddr); }
net/eth-uclass.c +2 -5
@@ -126,9 +126,6 @@ struct udevice *eth_get_dev_by_name(const char *devname) uclass_foreach_dev(it, uc) {/* -* We need the seq to be valid, so try to probe it. -* If the probe fails, the seq will not match since it will be -* -1 instead of what we are looking for. * We don't care about errors from probe here. Either they won't * match an alias or it will match a literal name and we'll pick * up the error when we try to probe again in eth_set_dev().
@@ -434,7 +431,7 @@ int eth_initialize(void)bootstage_mark (BOOTSTAGE_ID_NET_ETH_INIT ); do { - if (dev_seq(dev) != -1) { + if (device_active(dev)) { if (num_devices) printf(", ");
@@ -446,7 +443,7 @@ int eth_initialize(void)eth_write_hwaddr (dev); -if (dev_seq (dev) !=-1 ) +if (device_active (dev)) num_devices++;uclass_next_device_check (&dev); }while (dev);
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 11/28 net: Update to use new sequence numbers
Checking for seq == -1 is effectively checking that the device is activated. The new sequence numbers are never -1 for a bound device, so update the check.
Also drop the note about valid sequence numbers so it is accurate with the new approach.
---
(no changes since v1)
drivers/net/dwc_eth_qos.c | 2 +- net/eth-uclass.c | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 12/28 dm: core: Allow manual sequence numbering
In reply to Simon GlassSome buses have their own rules which require assigning sequence numbers with a bus-specific algorithm. For example, PCI requires that sub-buses are numbered higher than their parent buses, meaning effectively that parent buses must be numbered only after all of their child buses have been numbered.
Add a uclass flag to indicate that driver model should not assign sequence numbers. In this case, the uclass must do it.
---
(no changes since v2)
Changes in v2:
- Add new patch to allow manual sequence numbering
drivers/core/device.c | 2 +- include/dm/uclass.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/core/device.c +1 -1
@@ -103,7 +103,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv, dev->req_seq =uclass_find_next_free_req_seq (uc); } } -if (auto_seq) +if (auto_seq && !(uc->uc_drv->flags &DM_UC_FLAG_NO_AUTO_SEQ )) dev->sqq =uclass_find_next_free_req_seq (uc);if (drv->plat_auto) {
include/dm/uclass.h +3 -0
@@ -44,6 +44,9 @@ struct udevice;/* Members of this uclass sequence themselves with aliases */ #define DM_UC_FLAG_SEQ_ALIAS (1 << 0) +/* Members of this uclass without aliases don't get a sequence number */ +#define DM_UC_FLAG_NO_AUTO_SEQ (1 << 1) +/* Same as DM_FLAG_ALLOC_PRIV_DMA */ #define DM_UC_FLAG_ALLOC_PRIV_DMA (1 << 5)
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 12/28 dm: core: Allow manual sequence numbering
Some buses have their own rules which require assigning sequence numbers with a bus-specific algorithm. For example, PCI requires that sub-buses are numbered higher than their parent buses, meaning effectively that parent buses must be numbered only after all of their child buses have been numbered.
Add a uclass flag to indicate that driver model should not assign sequence numbers. In this case, the uclass must do it.
---
(no changes since v2)
Changes in v2:
- Add new patch to allow manual sequence numbering
drivers/core/device.c | 2 +- include/dm/uclass.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 13/28 pci: Update to use new sequence numbers
In reply to Simon GlassNow that we know the sequence number at bind time, there is no need for special-case code in dm_pci_hose_probe_bus().
Note: the PCI_CAP_ID_EA code may need a look, but there are no test failures so I have left it as is.
---
Changes in v3:
- Update PCI to use manual sequence numbering
Changes in v2:
- Use the sequence number directly instead of max bus
drivers/pci/pci-uclass.c | 45 ++++++++++++++++++++++++---------------- drivers/pci/pci_auto.c | 10 ++++----- 2 files changed, 32 insertions(+), 23 deletions(-)
drivers/pci/pci-uclass.c +27 -18
@@ -14,6 +14,7 @@#include <asm/io.h> #include <dm/device-internal.h> #include <dm/lists.h> +#include <dm/uclass-internal.h> #if defined(CONFIG_X86 ) && defined(CONFIG_HAVE_FSP )#include <asm/fsp/fsp_support.h> #endif
@@ -544,7 +545,7 @@ int pci_auto_config_devices(struct udevice *bus)continue ; ret =dm_pciauto_config_device (dev);if (ret <0 ) -return ret; +return log_msg_ret ("auto" , ret); max_bus = ret; sub_bus =max (sub_bus, max_bus);
@@ -554,7 +555,7 @@ int pci_auto_config_devices(struct udevice *bus) }debug ("%s: done\n" , __func__); -return sub_bus; +return log_msg_ret ("sub" , sub_bus); } int pci_generic_mmap_write_config(
@@ -641,17 +642,9 @@ int dm_pci_hose_probe_bus(struct udevice *bus)if (ret) {debug ("%s: Cannot probe bus %s: %d\n" , __func__, bus->name, ret); -return ret; +return log_msg_ret ("probe" , ret); } -if (!ea_pos) { -if (sub_bus !=dev_seq (bus)) { -debug ("%s: Internal error, bus '%s' got seq %d, expected %d\n" , - __func__, bus->name,dev_seq (bus), sub_bus); -return -EPIPE ; - } - sub_bus =pci_get_bus_max (); - }dm_pciauto_postscan_setup_bridge (bus, sub_bus);return sub_bus;
@@ -714,7 +707,7 @@ static int pci_find_and_bind_driver(struct udevice *parent,if (ofnode_valid (node) && !ofnode_is_available (node)) {debug ("%s: Ignoring disabled device\n" , __func__); -return -EPERM ; +return log_msg_ret ("dis" , -EPERM ); } start = ll_entry_start(struct pci_driver_entry, pci_driver_entry);
@@ -740,7 +733,7 @@ static int pci_find_and_bind_driver(struct udevice *parent,*/ if (!(gd->flags &GD_FLG_RELOC ) && !(drv->flags &DM_FLAG_PRE_RELOC )) -return -EPERM ; +return log_msg_ret ("pre" , -EPERM );/* * We could pass the descriptor to the driver as
@@ -768,7 +761,7 @@ static int pci_find_and_bind_driver(struct udevice *parent,* limited (ie: using Cache As RAM). */ if (!(gd->flags &GD_FLG_RELOC ) && !bridge) -return -EPERM ; +return log_msg_ret ("notbr" , -EPERM );/* Bind a generic driver so that the device can be used */ sprintf(name, "pci_%x:%x.%x", dev_seq(parent), PCI_DEV(bdf),
@@ -1009,11 +1002,26 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,static int pci_uclass_pre_probe (struct udevice *bus) {struct pci_controller *hose; +struct uclass *uc; +int ret;debug ("%s, bus=%d/%s, parent=%s\n" , __func__,dev_seq (bus), bus->name, bus->parent->name); hose = bus->uclass_priv; +/* +* Set the sequence number, if device_bind() doesn't. We want control +* of this so that numbers are allocated as devices are probed. That +* ensures that sub-bus numbered is correct (sub-buses must get numbers +* higher than their parents) +*/ +if (dev_seq (bus) ==-1 ) { + ret =uclass_get (UCLASS_PCI , &uc); +if (ret) +return ret; + bus->sqq =uclass_find_next_free_req_seq (uc); + } +/* For bridges, use the top-level PCI controller */ if (!device_is_on_pci_bus (bus)) { hose->ctlr = bus;
@@ -1024,6 +1032,7 @@ static int pci_uclass_pre_probe(struct udevice *bus) parent_hose =dev_get_uclass_priv (bus->parent); hose->ctlr = parent_hose->bus; } + hose->bus = bus; hose->first_busno =dev_seq (bus); hose->last_busno =dev_seq (bus);
@@ -1044,14 +1053,14 @@ static int pci_uclass_post_probe(struct udevice *bus)debug ("%s: probing bus %d\n" , __func__,dev_seq (bus)); ret =pci_bind_bus_devices (bus);if (ret) -return ret; +return log_msg_ret ("bind" , ret);if (CONFIG_IS_ENABLED (PCI_PNP ) &&ll_boot_init () && (!hose->skip_auto_config_until_reloc || (gd->flags &GD_FLG_RELOC ))) { ret =pci_auto_config_devices (bus);if (ret <0 ) -return log_msg_ret ("pci auto-config" , ret); +return log_msg_ret ("cfg" , ret); }#if defined(CONFIG_X86 ) && defined(CONFIG_HAVE_FSP )
@@ -1071,7 +1080,7 @@ static int pci_uclass_post_probe(struct udevice *bus)if ((gd->flags &GD_FLG_RELOC ) &&dev_seq (bus) ==0 &&ll_boot_init ()) { ret =fsp_init_phase_pci ();if (ret) -return ret; +return log_msg_ret ("fsp" , ret); }#endif
@@ -1791,7 +1800,7 @@ int pci_sriov_get_totalvfs(struct udevice *pdev)UCLASS_DRIVER (pci) = { .id =UCLASS_PCI , .name ="pci" , - .flags =DM_UC_FLAG_SEQ_ALIAS , + .flags =DM_UC_FLAG_SEQ_ALIAS |DM_UC_FLAG_NO_AUTO_SEQ , .post_bind = dm_scan_fdt_dev, .pre_probe = pci_uclass_pre_probe, .post_probe = pci_uclass_post_probe,
drivers/pci/pci_auto.c +5 -5
@@ -321,7 +321,7 @@ int dm_pciauto_config_device(struct udevice *dev)bool enum_only = false;struct udevice *ctlr =pci_get_controller (dev);struct pci_controller *ctlr_hose =dev_get_uclass_priv (ctlr); -int n; +int ret;#ifdef CONFIG_PCI_ENUM_ONLY enum_only = true;
@@ -341,10 +341,10 @@ int dm_pciauto_config_device(struct udevice *dev)dm_pciauto_setup_device (dev,2 , pci_mem, pci_prefetch, pci_io, enum_only); - n =dm_pci_hose_probe_bus (dev); -if (n <0 ) -return n; - sub_bus = (unsigned int )n; + ret =dm_pci_hose_probe_bus (dev); +if (ret <0 ) +return log_msg_ret ("probe" , ret); + sub_bus = ret;break ;case PCI_CLASS_BRIDGE_CARDBUS :
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 13/28 pci: Update to use new sequence numbers
Now that we know the sequence number at bind time, there is no need for special-case code in dm_pci_hose_probe_bus().
Note: the PCI_CAP_ID_EA code may need a look, but there are no test failures so I have left it as is.
---
Changes in v3:
- Update PCI to use manual sequence numbering
Changes in v2:
- Use the sequence number directly instead of max bus
drivers/pci/pci-uclass.c | 45 ++++++++++++++++++++++++---------------- drivers/pci/pci_auto.c | 10 ++++----- 2 files changed, 32 insertions(+), 23 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 13/28 pci: Update to use new sequence numbers
Quoted 13 lines · Simon Glass
Now that we know the sequence number at bind time, there is no need for special-case code in
dm_pci_hose_probe_bus().Note: the
PCI_CAP_ID_EAcode may need a look, but there are no test failures so I have left it as is.Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Update PCI to use manual sequence numbering
Quoted 8 lines
Changes in v2:
- Use the sequence number directly instead of max busdrivers/pci/pci-uclass.c | 45 ++++++++++++++++++++++++---------------- drivers/pci/pci_auto.c | 10 ++++----- 2 files changed, 32 insertions(+), 23 deletions(-)Applied to u-boot-dm/next, thanks!
Hi Simon,
I have a (not yet submitted) pending patch to migrate the gwventana board to DM_PCI / DM_ETH that this particular patch broke and I'm trying to understand why.
The Gateworks Ventana boards have a PCIe switch where the downstream PERST#'s are GPIO's off the switch and a e1000 PCIe GBe device is on one of those downstream ports. For non-dm PCI I have a 'board_pci_fixup_dev' function that allows board support to configure the switch's GPIO and toggle downstream PERST# during enumeration. When I add this function to dm_pci I end up getting a data abort when the e1000 driver tries to initialize (after PCI enumeration).
Any idea what is causing this and what I need to do to work around it? Nothing in my patch deals with device sequence numbers.
Additionally I feel like the best way to add support for the custom downstream PCI switch reset requirements is to add a UCLASS_PCI driver for the switch in my board support but when I attempted that solution I run into an issue where pci read/write's cause a prefetch abort because I need to use imx_pcie_dm_{read,write}_config instead of the default ops. I'm not quite sure how to get hold of the ops for the imx controller to set this up properly. Furthermore if I do end up with that solution I later need to be able to walk the PCI bus to perform various dt fixups on pci device nodes - do you have an example of how I could walk the bus using DM_PCI?
Best regards,
Tim
PATCH v3 13/28 pci: Update to use new sequence numbers
Hi Tim,
Quoted 30 lines · Tim Harvey
Quoted 13 lines · Simon Glass
Now that we know the sequence number at bind time, there is no need for special-case code in
dm_pci_hose_probe_bus().Note: the
PCI_CAP_ID_EAcode may need a look, but there are no test failures so I have left it as is.Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Update PCI to use manual sequence numberingQuoted 8 lines
Changes in v2:
- Use the sequence number directly instead of max busdrivers/pci/pci-uclass.c | 45 ++++++++++++++++++++++++---------------- drivers/pci/pci_auto.c | 10 ++++----- 2 files changed, 32 insertions(+), 23 deletions(-)Applied to u-boot-dm/next, thanks!
Hi Simon,
I have a (not yet submitted) pending patch to migrate the gwventana board to
DM_PCI/DM_ETHthat this particular patch broke and I'm trying to understand why.
Quoted 7 lines
The Gateworks Ventana boards have a PCIe switch where the downstream PERST#'s are GPIO's off the switch and a e1000 PCIe GBe device is on one of those downstream ports. For non-dm PCI I have a '
board_pci_fixup_dev' function that allows board support to configure the switch's GPIO and toggle downstream PERST# during enumeration. When I add this function todm_pciI end up getting a data abort when the e1000 driver tries to initialize (after PCI enumeration).
Firstly, I think I did the PCI conversion about 6 years ago so it is not fresh in my memory.
Quoted 3 lines
Any idea what is causing this and what I need to do to work around it? Nothing in my patch deals with device sequence numbers.
An abort presumably indicates that the memory is not there, so perhaps the e1000 is still in reset, or has been set up to appear at a different address?
You should be abe to use 'pci hdr 0.4.0' or whatever to look at the BARs and make sure they are value with 'md', etc.
Quoted 6 lines
Additionally I feel like the best way to add support for the custom downstream PCI switch reset requirements is to add a
UCLASS_PCIdriver for the switch in my board support but when I attempted that solution I run into an issue where pci read/write's cause a prefetch abort because I need to use imx_pcie_dm_{read,write}_config instead of the default ops. I'm not quite sure how to get hold of the ops for the imx
If you write a PCI driver then you can provide the access operations yourself....see drivers/pci for some examples. I suggest you add subnodes to the devicetree and specify the compatible string of your PCI switch so it picks up the right driver.
Quoted 4 lines
controller to set this up properly. Furthermore if I do end up with that solution I later need to be able to walk the PCI bus to perform various dt fixups on pci device nodes - do you have an example of how I could walk the bus using
DM_PCI?
Do you mean a breadth-first search? It is something like:
struct udevice *dev;
static void do_something(struct udevice *parent)
{
device_foreach_child_probe(dev, parent) {
do_something((dev);}
...
struct udevice *bus;
int ret;
ret = uclass_first_device_err(UCLASS_PCI, &bus);
if (ret)
return log_msg_ret("pci", ret);do_something(bus);
Quoted 4 lines
Best regards,
Tim
Regards,
Simon
PATCH v3 13/28 pci: Update to use new sequence numbers
Quoted 46 lines · Simon Glass
Hi Tim,
Quoted 30 lines · Tim Harvey
Quoted 13 lines · Simon Glass
Now that we know the sequence number at bind time, there is no need for special-case code in
dm_pci_hose_probe_bus().Note: the
PCI_CAP_ID_EAcode may need a look, but there are no test failures so I have left it as is.Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Update PCI to use manual sequence numberingQuoted 8 lines
Changes in v2:
- Use the sequence number directly instead of max busdrivers/pci/pci-uclass.c | 45 ++++++++++++++++++++++++---------------- drivers/pci/pci_auto.c | 10 ++++----- 2 files changed, 32 insertions(+), 23 deletions(-)Applied to u-boot-dm/next, thanks!
Hi Simon,
I have a (not yet submitted) pending patch to migrate the gwventana board to
DM_PCI/DM_ETHthat this particular patch broke and I'm trying to understand why.Quoted 7 lines
The Gateworks Ventana boards have a PCIe switch where the downstream PERST#'s are GPIO's off the switch and a e1000 PCIe GBe device is on one of those downstream ports. For non-dm PCI I have a '
board_pci_fixup_dev' function that allows board support to configure the switch's GPIO and toggle downstream PERST# during enumeration. When I add this function todm_pciI end up getting a data abort when the e1000 driver tries to initialize (after PCI enumeration).Firstly, I think I did the PCI conversion about 6 years ago so it is not fresh in my memory.
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
Any idea what is causing this and what I need to do to work around it? Nothing in my patch deals with device sequence numbers.
An abort presumably indicates that the memory is not there, so perhaps the e1000 is still in reset, or has been set up to appear at a different address?
Simon,
It does appear that everything downstream from the switch is inaccessible 'after' enumeration and I've verified that PERST# both upstream and downstream is in the correct state and never gets asserted again.
The issue appears to be related to the PCI_CAP_ID_EA code and per your commit log it sounds like you were not sure if that was correct. Adding back in the following resolves the issue for me:
drivers/pci/pci-uclass.c +3 -0
@@ -646,6 +646,15 @@ int dm_pci_hose_probe_bus(struct udevice *bus)return log_msg_ret ("probe" , ret); } +if (!ea_pos) { +if (sub_bus !=dev_seq (bus)) { + debug("%s: Internal error, bus '%s' got seq
%d, expected %d\n",
+ __func__, bus->name,dev_seq(bus), sub_bus);
+ return -EPIPE;
+ }
+ sub_bus = pci_get_bus_max();
+ }
+
dm_pciauto_postscan_setup_bridge(bus, sub_bus);
return sub_bus;Adding some debugging it appears that the devices I have downstream from the bridge have 'ea_os = 0'.
Does the above let you know what's going on?
Tim
Quoted 47 lines
You should be abe to use 'pci hdr 0.4.0' or whatever to look at the BARs and make sure they are value with 'md', etc.
Quoted 6 lines
Additionally I feel like the best way to add support for the custom downstream PCI switch reset requirements is to add a
UCLASS_PCIdriver for the switch in my board support but when I attempted that solution I run into an issue where pci read/write's cause a prefetch abort because I need to use imx_pcie_dm_{read,write}_config instead of the default ops. I'm not quite sure how to get hold of the ops for the imxIf you write a PCI driver then you can provide the access operations yourself....see
drivers/pcifor some examples. I suggest you add subnodes to the devicetree and specify the compatible string of your PCI switch so it picks up the right driver.Quoted 4 lines
controller to set this up properly. Furthermore if I do end up with that solution I later need to be able to walk the PCI bus to perform various dt fixups on pci device nodes - do you have an example of how I could walk the bus using
DM_PCI?Do you mean a breadth-first search? It is something like:
struct udevice *dev;
static void
do_something(struct udevice *parent){ device_foreach_child_probe(dev, parent) { do_something((dev); }...
struct udevice *bus;
int ret;ret =
uclass_first_device_err(UCLASS_PCI, &bus);
if (ret)
returnlog_msg_ret("pci", ret);do_something(bus);Quoted 4 lines
Best regards,
Tim
Regards,
Simon
PATCH v3 13/28 pci: Update to use new sequence numbers
Hi Tim,
Quoted 89 lines · On Thu, 15 Apr 2021, 12:29 Tim Harvey, <[email protected]> wrote:
Quoted 8 lines · Simon Glass
Hi Tim,
Quoted 4 lines · Tim Harvey
Quoted 2 lines · Simon Glass
Now that we know the sequence number at bind time, there is no need
for
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
special-case code in
dm_pci_hose_probe_bus().Note: the
PCI_CAP_ID_EAcode may need a look, but there are no test failures so I have left it as is.Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Changes in v3:
- Update PCI to use manual sequence numberingChanges in v2:
- Use the sequence number directly instead of max busdrivers/pci/pci-uclass.c | 45++++++++++++++++++++++++----------------
Quoted 23 lines
Quoted 11 lines
Quoted 4 lines
drivers/pci/pci_auto.c | 10 ++++----- 2 files changed, 32 insertions(+), 23 deletions(-)Applied to u-boot-dm/next, thanks!
Hi Simon,
I have a (not yet submitted) pending patch to migrate the gwventana board to
DM_PCI/DM_ETHthat this particular patch broke and I'm trying to understand why.Quoted 7 lines
The Gateworks Ventana boards have a PCIe switch where the downstream PERST#'s are GPIO's off the switch and a e1000 PCIe GBe device is on one of those downstream ports. For non-dm PCI I have a '
board_pci_fixup_dev' function that allows board support to configure the switch's GPIO and toggle downstream PERST# during enumeration. When I add this function todm_pciI end up getting a data abort when the e1000 driver tries to initialize (after PCI enumeration).Firstly, I think I did the PCI conversion about 6 years ago so it is not fresh in my memory.
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
Any idea what is causing this and what I need to do to work around it? Nothing in my patch deals with device sequence numbers.
An abort presumably indicates that the memory is not there, so perhaps the e1000 is still in reset, or has been set up to appear at a different address?
Simon,
It does appear that everything downstream from the switch is inaccessible 'after' enumeration and I've verified that PERST# both upstream and downstream is in the correct state and never gets asserted again.
The issue appears to be related to the
PCI_CAP_ID_EAcode and per your commit log it sounds like you were not sure if that was correct. Adding back in the following resolves the issue for me:drivers/pci/pci-uclass.c +9
-0@@ -646,6 +646,15 @@ int dm_pci_hose_probe_bus(struct udevice *bus)return log_msg_ret ("probe" , ret); } +if (!ea_pos) { +if (sub_bus !=dev_seq (bus)) { + debug("%s: Internal error, bus '%s' got seq %d, expected %d\n", + __func__, bus->name,dev_seq (bus), sub_bus); +return -EPIPE ; + } + sub_bus =pci_get_bus_max (); + } +dm_pciauto_postscan_setup_bridge (bus, sub_bus);
Quoted 7 lines
return sub_bus;Adding some debugging it appears that the devices I have downstream from the bridge have '
ea_os= 0'.Does the above let you know what's going on?
Maybe,but I think someone just sent a patch for it.can you check the mailing list?
Regards,
Simon
Quoted 54 lines
Tim
Quoted 47 lines
You should be abe to use 'pci hdr 0.4.0' or whatever to look at the BARs and make sure they are value with 'md', etc.
Quoted 6 lines
Additionally I feel like the best way to add support for the custom downstream PCI switch reset requirements is to add a
UCLASS_PCIdriver for the switch in my board support but when I attempted that solution I run into an issue where pci read/write's cause a prefetch abort because I need to use imx_pcie_dm_{read,write}_config instead of the default ops. I'm not quite sure how to get hold of the ops for the imxIf you write a PCI driver then you can provide the access operations yourself....see
drivers/pcifor some examples. I suggest you add subnodes to the devicetree and specify the compatible string of your PCI switch so it picks up the right driver.Quoted 4 lines
controller to set this up properly. Furthermore if I do end up with that solution I later need to be able to walk the PCI bus to perform various dt fixups on pci device nodes - do you have an example of how I could walk the bus using
DM_PCI?Do you mean a breadth-first search? It is something like:
struct udevice *dev;
static void
do_something(struct udevice *parent){ device_foreach_child_probe(dev, parent) { do_something((dev); }...
struct udevice *bus;
int ret;ret =
uclass_first_device_err(UCLASS_PCI, &bus);
if (ret)
returnlog_msg_ret("pci", ret);do_something(bus);Quoted 4 lines
Best regards,
Tim
Regards,
Simon
PATCH v3 14/28 spi: Update for new sequence numbers
In reply to Simon GlassUse the new sequence number in all cases. Drop the rockchip case because the sequence number should be 0 anyway, and assigning to the sequence number is not permitted.
---
(no changes since v1)
drivers/spi/fsl_dspi.c | 2 +- drivers/spi/rk_spi.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/spi/fsl_dspi.c +1 -1
@@ -569,7 +569,7 @@ static int fsl_dspi_release_bus(struct udevice *dev)*/ static int fsl_dspi_bind (struct udevice *bus) { -debug ("%s assigned req_seq %d.\n" , bus->name, bus->req_seq); +debug ("%s assigned seq %d.\n" , bus->name,dev_seq (bus));return 0 ; }
drivers/spi/rk_spi.c +0 -1
@@ -186,7 +186,6 @@ static int conv_of_plat(struct udevice *dev) ret =clk_get_by_driver_info (dev, dtplat->clocks, &priv->clk);if (ret <0 )return ret; - dev->req_seq =0 ;return 0 ; }
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 14/28 spi: Update for new sequence numbers
Use the new sequence number in all cases. Drop the rockchip case because the sequence number should be 0 anyway, and assigning to the sequence number is not permitted.
---
(no changes since v1)
drivers/spi/fsl_dspi.c | 2 +- drivers/spi/rk_spi.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 15/28 usb: ehci-mx6: Drop assignment of sequence number
In reply to Simon GlassThis hack cannot work in the new sequence-numbering scheme. Remove it while we wait for the maintainer to complete DM conversion as noted in the existing comment.
---
(no changes since v1)
drivers/usb/host/ehci-mx6.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/usb/host/ehci-mx6.c +9 -3
@@ -569,10 +569,16 @@ static int ehci_usb_bind(struct udevice *dev)* With these changes in place, the ad-hoc indexing goes away and * the driver is fully converted to DT probing. */ -u32 controller_spacing =is_mx7 () ?0x10000 :0x200 ; -fdt_addr_t addr =devfdt_get_addr_index (dev,0 ); - dev->req_seq = (addr -USB_BASE_ADDR ) / controller_spacing; +/* +* FIXME: This cannot work with the new sequence numbers. +* Please complete the DM conversion. +* +* u32 controller_spacing = is_mx7() ? 0x10000 : 0x200; +* fdt_addr_t addr = devfdt_get_addr_index(dev, 0); +* +* dev->req_seq = (addr - USB_BASE_ADDR) / controller_spacing; +*/ return 0 ; }
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 15/28 usb: ehci-mx6: Drop assignment of sequence number
This hack cannot work in the new sequence-numbering scheme. Remove it while we wait for the maintainer to complete DM conversion as noted in the existing comment.
---
(no changes since v1)
drivers/usb/host/ehci-mx6.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 15/28 usb: ehci-mx6: Drop assignment of sequence number
Quoted 5 lines · Simon Glass
This hack cannot work in the new sequence-numbering scheme. Remove it while we wait for the maintainer to complete DM conversion as noted in the existing comment.
Signed-off-by Simon Glass <[email protected]>
Quoted 8 lines
---
(no changes since v1)
drivers/usb/host/ehci-mx6.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)Applied to u-boot-dm/next, thanks!
Note that this broke USB on iMX6, iMX7 and iMX8M, which are all commonly used embedded platforms. It was difficult to spot this USB patch hidden between all the other dm patches. Also, it seems this didn't get reviewed/acked by any NXP maintainer. Frankly, this is not good. I'm adding NXP on CC.
PATCH v3 15/28 usb: ehci-mx6: Drop assignment of sequence number
Quoted 13 lines · Marek Vasut
Quoted 12 lines · Simon Glass
This hack cannot work in the new sequence-numbering scheme. Remove it while we wait for the maintainer to complete DM conversion as noted in the existing comment.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
drivers/usb/host/ehci-mx6.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
Quoted 7 lines
Quoted 1 line
Applied to u-boot-dm/next, thanks!
Note that this broke USB on iMX6, iMX7 and iMX8M, which are all commonly used embedded platforms. It was difficult to spot this USB patch hidden between all the other dm patches. Also, it seems this didn't get reviewed/acked by any NXP maintainer. Frankly, this is not good. I'm adding NXP on CC.
And the "gonna start deleting stuff" deadline for DM_USB is after v2021.07 not after v2021.04.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210331/22b97a2f/attachment.sig>
PATCH v3 15/28 usb: ehci-mx6: Drop assignment of sequence number
Hi Marek,
Quoted 15 lines · Tom Rini
Quoted 13 lines · Marek Vasut
Quoted 12 lines · Simon Glass
This hack cannot work in the new sequence-numbering scheme. Remove it while we wait for the maintainer to complete DM conversion as noted in the existing comment.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
drivers/usb/host/ehci-mx6.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Applied to u-boot-dm/next, thanks!
Note that this broke USB on iMX6, iMX7 and iMX8M, which are all commonly used embedded platforms. It was difficult to spot this USB patch hidden between all the other dm patches. Also, it seems this didn't get reviewed/acked by any NXP maintainer. Frankly, this is not good. I'm adding NXP on CC.
I agree, but perhaps for different reasons. The migration deadline was over 18 months ago and patch was (presumably?) copied to the right maintainers, at least the first time. Having said that, I don't see an entry for this driver, so it might have just been going on git history?
It worries me that on such an important platform, the migration has stalled for so long. It might be worth doing an audit of what else is there.
Quoted 6 lines
And the "gonna start deleting stuff" deadline for
DM_USBis after v2021.07 not after v2021.04.--
Tom
Regards,
Simon
-------------- next part --------------
-----BEGIN PGP SIGNATURE-----
iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmBkzTUACgkQFHw5/5Y0 tywqUwv8Cz7rqux8ggHo19a9ANx77HZ8/0Hp43EMNWMbTsVFqfmE1EXK0bzgA1z9 E9XoBfsgWrTxj5/SDaC5n9tKS4Jd4DKXWCM7OscdhDdTnXXPm/F7Y93y2Dn5gJJW d5p4NDMTf058sJ47YN/O6Ag30Q+DKhQCLC5i5WO0gEyDnRaQXFL0MaVqm3QPiDi8 SBWEh7JYfuthEI7surYHygqIW19zA/fcau5MXmcedMws+VN/Cjr9pfypZu8TYSdg H8g651zwu/4o/Q2+/iX6ASx1m3BOq1HU3gTChLHjz1RSdjRByuLB16pSxMqXP8wE WLqrdW6XeqybrTt0wTUG++FdONbfKEfSjQ6QC1Hn6nF+OXvP1DiWa6PmV0KU8vRw zpUlkEAaInxZKLkdnqfqqwi43uSQMCrmLS8mBcsi/U6CP6mDi+G75B/41sWrbvHG ubXdVoR2Z4hVAGNqwp9SZ8LCmZ84wbkJ1ybdughvRDMqnG43G7EfBRAXzyjgKj9N wDQjQxyj
=GMjc
-----END PGP SIGNATURE-----
PATCH v3 16/28 usb: Update for new sequence numbers
In reply to Simon GlassUse the new sequence number in all cases. Since all devices are assigned a number when bound, this hack should not be needed.
---
(no changes since v1)
drivers/usb/host/ehci-vf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/usb/host/ehci-vf.c +2 -4
@@ -296,16 +296,14 @@ static const struct ehci_ops vf_ehci_ops = {static int vf_usb_bind (struct udevice *dev) { -static int num_controllers; -/* * Without this hack, if we return ENODEV for USB Controller 0, on * probe for the next controller, USB Controller 1 will be given a * sequence number of 0. This conflicts with our requirement of * sequence numbers while initialising the peripherals. +* +* FIXME: Check that this still works OK with the new sequence numbers */ - dev->req_seq = num_controllers; - num_controllers++;return 0 ; }
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 16/28 usb: Update for new sequence numbers
Use the new sequence number in all cases. Since all devices are assigned a number when bound, this hack should not be needed.
---
(no changes since v1)
drivers/usb/host/ehci-vf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 17/28 x86: Drop unnecessary mp_init logic
In reply to Simon GlassNow that sequence numbers are set up when devices are bound, this code is not needed. Also, we should use dev_seq() instead of req_seq. Update the whole file accordingly.
Also fix up APL cpu while we are here.
---
(no changes since v1)
arch/x86/cpu/apollolake/cpu.c | 2 +- arch/x86/cpu/mp_init.c | 23 +++++++---------------- arch/x86/include/asm/mp.h | 2 +- 3 files changed, 9 insertions(+), 18 deletions(-)
arch/x86/cpu/apollolake/cpu.c +1 -1
@@ -63,7 +63,7 @@ static int apl_get_info(const struct udevice *dev, struct cpu_info *info)static int acpi_cpu_fill_ssdt (const struct udevice *dev,struct acpi_ctx *ctx) { -uint core_id = dev->req_seq; +uint core_id =dev_seq (dev);int cores_per_package;int ret;
arch/x86/cpu/mp_init.c +7 -16
@@ -87,7 +87,7 @@ DECLARE_GLOBAL_DATA_PTR;* intel,apic-id = <2>; * }; * -* Here the 'reg' property is the CPU number and then is placed in dev->req_seq +* Here the 'reg' property is the CPU number and then is placed in dev_seq(cpu) * so that we can index into ap_callbacks[] using that. The APIC ID is different * and may not be sequential (it typically is if hyperthreading is supported). *
@@ -135,7 +135,7 @@ struct mp_flight_plan {* * @func: Function to run * @arg: Argument to pass to the function -* @logical_cpu_number: Either a CPU number (i.e. dev->req_seq) or a special +* @logical_cpu_number: Either a CPU number (i.e. dev_seq(cpu) or a special * value like MP_SELECT_BSP. It tells the AP whether it should process this * callback */
@@ -152,7 +152,7 @@ static struct mp_flight_plan mp_info;* ap_callbacks - Callback mailbox array * * Array of callback, one entry for each available CPU, indexed by the CPU -* number, which is dev->req_seq. The entry for the main CPU is never used. +* number, which is dev_seq(cpu). The entry for the main CPU is never used. * When this is NULL, there is no pending work for the CPU to run. When * non-NULL it points to the mp_callback structure. This is shared between all * CPUs, so should only be written by the main CPU.
@@ -562,7 +562,7 @@ static int get_bsp(struct udevice **devp, int *cpu_countp)if (cpu_countp) *cpu_countp = ret; -return dev->req_seq >=0 ? dev->req_seq :0 ; +return dev_seq (dev) >=0 ?dev_seq (dev) :0 ; }/**
@@ -614,7 +614,7 @@ static void store_callback(struct mp_callback **slot, struct mp_callback *val)static int run_ap_work (struct mp_callback *callback,struct udevice *bsp,int num_cpus,uint expire_ms) { -int cur_cpu = bsp->req_seq; +int cur_cpu =dev_seq (bsp);int num_aps = num_cpus -1 ;/* number of non-BSPs to get this message */ int cpus_accepted;ulong start;
@@ -679,7 +679,7 @@ static int ap_wait_for_instruction(struct udevice *cpu, void *unused)if (!IS_ENABLED (CONFIG_SMP_AP_WORK ))return 0 ; - per_cpu_slot = &ap_callbacks[cpu->req_seq]; + per_cpu_slot = &ap_callbacks[dev_seq (cpu)];while (1 ) {struct mp_callback *cb =read_callback (per_cpu_slot);
@@ -694,7 +694,7 @@ static int ap_wait_for_instruction(struct udevice *cpu, void *unused)mfence ();if (lcb.logical_cpu_number ==MP_SELECT_ALL || lcb.logical_cpu_number ==MP_SELECT_APS || - cpu->req_seq == lcb.logical_cpu_number) +dev_seq (cpu) == lcb.logical_cpu_number) lcb.func (lcb.arg);/* Indicate we are finished */
@@ -839,7 +839,6 @@ int mp_init(void)int num_aps, num_cpus;atomic_t *ap_count;struct udevice *cpu; -struct uclass *uc;int ret;if (IS_ENABLED (CONFIG_QFW )) {
@@ -848,14 +847,6 @@ int mp_init(void)return ret; } -/* -* Multiple APs are brought up simultaneously and they may get the same -* seq num in the uclass_resolve_seq() during device_probe(). To avoid -* this, set req_seq to the reg number in the device tree in advance. -*/ -uclass_id_foreach_dev (UCLASS_CPU , cpu, uc) - cpu->req_seq = dev_read_u32_default(cpu, "reg", -1); - ret =get_bsp (&cpu, &num_cpus);if (ret <0 ) {debug ("Cannot init boot CPU: err=%d\n" , ret);
arch/x86/include/asm/mp.h +1 -1
@@ -114,7 +114,7 @@ typedef void (*mp_run_func)(void *arg);* Running on anything other than the boot CPU is only supported if * CONFIG_SMP_AP_WORK is enabled * -* @cpu_select: CPU to run on (its dev->req_seq value), or MP_SELECT_ALL for +* @cpu_select: CPU to run on (its dev_seq() value), or MP_SELECT_ALL for * all, or MP_SELECT_BSP for BSP * @func: Function to run * @arg: Argument to pass to the function
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 17/28 x86: Drop unnecessary mp_init logic
Now that sequence numbers are set up when devices are bound, this code is not needed. Also, we should use dev_seq() instead of req_seq. Update the whole file accordingly.
Also fix up APL cpu while we are here.
---
(no changes since v1)
arch/x86/cpu/apollolake/cpu.c | 2 +- arch/x86/cpu/mp_init.c | 23 +++++++---------------- arch/x86/include/asm/mp.h | 2 +- 3 files changed, 9 insertions(+), 18 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 18/28 x86: Simplify acpi_device_infer_name()
In reply to Simon GlassThere is no-longer any need to check if sequence numbers are valid, since this is ensured by driver model. Drop the unwanted logic.
---
(no changes since v1)
lib/acpi/acpi_device.c | 27 +++------------------------ test/dm/acpi.c | 6 +----- 2 files changed, 4 insertions(+), 29 deletions(-)
lib/acpi/acpi_device.c +3 -24
@@ -784,16 +784,6 @@ static const char *acpi_name_from_id(enum uclass_id id) } } -static int acpi_check_seq (const struct udevice *dev) -{ -if (dev->req_seq ==-1 ) { -log_warning ("Device '%s' has no seq\n" , dev->name); -return log_msg_ret ("no seq" , -ENXIO ); - } - -return dev->req_seq; -} -/* If you change this function, add test cases to dm_test_acpi_get_name() */ int acpi_device_infer_name (const struct udevice *dev,char *out_name) {
@@ -826,29 +816,18 @@ int acpi_device_infer_name(const struct udevice *dev, char *out_name) } }if (!name) { -int num; -switch (id) {/* DSDT: acpi/lpss.asl */ case UCLASS_SERIAL : - num =acpi_check_seq (dev); -if (num <0 ) -return num; -sprintf (out_name,"URT%d" , num); +sprintf (out_name,"URT%d" ,dev_seq (dev)); name = out_name;break ;case UCLASS_I2C : - num =acpi_check_seq (dev); -if (num <0 ) -return num; -sprintf (out_name,"I2C%d" , num); +sprintf (out_name,"I2C%d" ,dev_seq (dev)); name = out_name;break ;case UCLASS_SPI : - num =acpi_check_seq (dev); -if (num <0 ) -return num; -sprintf (out_name,"SPI%d" , num); +sprintf (out_name,"SPI%d" ,dev_seq (dev)); name = out_name;break ;default :
test/dm/acpi.c +1 -5
@@ -123,7 +123,7 @@ UCLASS_DRIVER(testacpi) = {static int dm_test_acpi_get_name (struct unit_test_state *uts) {char name[ACPI_NAME_MAX ]; -struct udevice *dev, *dev2, *i2c, *spi, *serial, *timer, *sound; +struct udevice *dev, *dev2, *i2c, *spi, *timer, *sound;struct udevice *pci, *root;/* Test getting the name from the driver */
@@ -146,10 +146,6 @@ static int dm_test_acpi_get_name(struct unit_test_state *uts)ut_assertok (acpi_get_name (spi, name));ut_asserteq_str ("SPI0" , name); -/* The uart has no sequence number, so this should fail */ -ut_assertok (uclass_first_device (UCLASS_SERIAL , &serial)); -ut_asserteq (-ENXIO ,acpi_get_name (serial, name)); -/* ACPI doesn't know about the timer */ ut_assertok (uclass_first_device (UCLASS_TIMER , &timer));ut_asserteq (-ENOENT ,acpi_get_name (timer, name));
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 18/28 x86: Simplify acpi_device_infer_name()
There is no-longer any need to check if sequence numbers are valid, since this is ensured by driver model. Drop the unwanted logic.
---
(no changes since v1)
lib/acpi/acpi_device.c | 27 +++------------------------ test/dm/acpi.c | 6 +----- 2 files changed, 4 insertions(+), 29 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 19/28 gpio: Update for new sequence numbers
In reply to Simon GlassUse the dev_seq() sequence number in all cases.
---
(no changes since v1)
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/vybrid_gpio.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpio/imx_rgpio2p.c +1 -1
@@ -183,7 +183,7 @@ static int imx_rgpio2p_bind(struct udevice *dev)return -ENOMEM ; plat->regs = (struct gpio_regs *)addr; - plat->bank_index = dev->req_seq; + plat->bank_index =dev_seq (dev); dev->plat = plat;return 0 ;
drivers/gpio/iproc_gpio.c +1 -1
@@ -252,7 +252,7 @@ static int iproc_gpio_of_to_plat(struct udevice *dev)return ret; } -snprintf (name,sizeof (name),"GPIO%d" , dev->req_seq); +snprintf (name,sizeof (name),"GPIO%d" ,dev_seq (dev)); plat->name =strdup (name);if (!plat->name)return -ENOMEM ;
drivers/gpio/mvebu_gpio.c +1 -1
@@ -92,7 +92,7 @@ static int mvebu_gpio_probe(struct udevice *dev) priv->regs =dev_read_addr_ptr (dev); uc_priv->gpio_count =MVEBU_GPIOS_PER_BANK ; - priv->name[0 ] ='A' + dev->req_seq; + priv->name[0 ] ='A' +dev_seq (dev); uc_priv->bank_name = priv->name;return 0 ;
drivers/gpio/mxc_gpio.c +1 -1
@@ -318,7 +318,7 @@ static int mxc_gpio_of_to_plat(struct udevice *dev) plat->regs = (struct gpio_regs *)addr; } - plat->bank_index = dev->req_seq; + plat->bank_index =dev_seq (dev);return 0 ; }
drivers/gpio/vybrid_gpio.c +1 -1
@@ -114,7 +114,7 @@ static int vybrid_gpio_odata_to_plat(struct udevice *dev)return -EINVAL ; plat->base = base_addr; - plat->chip = dev->req_seq; + plat->chip =dev_seq (dev); plat->port_name =fdt_get_name (gd->fdt_blob,dev_of_offset (dev),NULL );return 0 ;
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 19/28 gpio: Update for new sequence numbers
Use the dev_seq() sequence number in all cases.
---
(no changes since v1)
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/vybrid_gpio.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 20/28 pinctrl: Update for new sequence numbers
In reply to Simon GlassUse the dev_seq() sequence number in all cases.
---
(no changes since v1)
drivers/pinctrl/exynos/pinctrl-exynos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/exynos/pinctrl-exynos.c +1 -1
@@ -133,7 +133,7 @@ int exynos_pinctrl_probe(struct udevice *dev) priv->base = base; priv->pin_ctrl = (struct samsung_pin_ctrl *)dev_get_driver_data (dev) + - dev->req_seq; +dev_seq (dev);return 0 ; }
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 20/28 pinctrl: Update for new sequence numbers
Use the dev_seq() sequence number in all cases.
---
(no changes since v1)
drivers/pinctrl/exynos/pinctrl-exynos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 21/28 dm: Switch over to use new sequence number for dev_seq()
In reply to Simon GlassUpdate this function to use the new sequence number and fix up the test that deals with this.
---
(no changes since v2)
Changes in v2:
- Adjust the tests to handle the new allocation scheme
- Drop the networking changes which are no-longer needed
arch/sandbox/dts/test.dts | 2 +- drivers/core/uclass.c | 6 ++-- include/dm/device.h | 2 +- test/dm/test-fdt.c | 65 ++++++++++++++++++++++----------------- 4 files changed, 40 insertions(+), 35 deletions(-)
arch/sandbox/dts/test.dts +1 -1
@@ -33,7 +33,7 @@ testfdt6 = "/e-test"; testbus3 = "/some-bus"; testfdt0 = "/some-bus/c-test at 0"; - testfdt1 = "/some-bus/c-test at 1"; + testfdt12 = "/some-bus/c-test at 1"; testfdt3 = "/b-test"; testfdt5 = "/some-bus/c-test at 5"; testfdt8 = "/a-test";
drivers/core/uclass.c +2 -4
@@ -306,8 +306,7 @@ int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq, uclass_foreach_dev(dev, uc) {log_debug (" - %d %d '%s'\n" , dev->req_seq,dev_seq (dev), dev->name); -if ((find_req_seq ? dev->req_seq :dev_seq (dev)) == - seq_or_req_seq) { +if (dev_seq (dev) == seq_or_req_seq) { *devp = dev;log_debug (" - found\n" );return 0 ;
@@ -692,8 +691,7 @@ int uclass_resolve_seq(struct udevice *dev)assert (dev_seq (dev) ==-1 ); ret =uclass_find_device_by_seq (uc_drv->id, dev->req_seq, false, &dup);if (!ret) { -dm_warn ("Device '%s': seq %d is in use by '%s'\n" , - dev->name, dev->req_seq, dup->name); +/* Do nothing here for now */ }else if (ret == -ENODEV ) {/* Our requested sequence number is available */ if (dev->req_seq !=-1 )
include/dm/device.h +1 -1
@@ -192,7 +192,7 @@ static inline bool dev_has_of_node(struct udevice *dev)static inline int dev_seq (const struct udevice *dev) { -return dev->seq; +return dev->sqq; }/**
test/dm/test-fdt.c +36 -29
93 lines not on this page · raw message
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 21/28 dm: Switch over to use new sequence number for dev_seq()
Update this function to use the new sequence number and fix up the test that deals with this.
---
(no changes since v2)
Changes in v2:
- Adjust the tests to handle the new allocation scheme
- Drop the networking changes which are no-longer needed
arch/sandbox/dts/test.dts | 2 +- drivers/core/uclass.c | 6 ++-- include/dm/device.h | 2 +- test/dm/test-fdt.c | 65 ++++++++++++++++++++++----------------- 4 files changed, 40 insertions(+), 35 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 22/28 dm: test: Add a test for DM_UC_FLAG_NO_AUTO_SEQ
In reply to Simon GlassCheck that this flag operates as expected. This patch is not earlier in this series since is uses the new behaviour of dev_seq().
---
Changes in v3:
- Add new patch to test DM_UC_FLAG_NO_AUTO_SEQ
arch/sandbox/dts/test.dts | 13 ++++++++++++ include/dm/uclass-id.h | 1 + test/dm/test-fdt.c | 42 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+)
arch/sandbox/dts/test.dts +13 -0
@@ -37,6 +37,7 @@ testfdt3 = "/b-test"; testfdt5 = "/some-bus/c-test at 5"; testfdt8 = "/a-test"; + testfdtm1 = &testfdtm1; fdt-dummy0 = "/translation-test at 8000/dev at 0,0"; fdt-dummy1 = "/translation-test at 8000/dev at 1,100"; fdt-dummy2 = "/translation-test at 8000/dev at 2,200";
@@ -917,6 +918,18 @@ idle-state = <0xabcd>; }; + testfdtm0 { + compatible = "denx,u-boot-fdtm-test"; + }; + + testfdtm1: testfdtm1 { + compatible = "denx,u-boot-fdtm-test"; + }; + + testfdtm2 { + compatible = "denx,u-boot-fdtm-test"; + }; + timer at 0 { compatible = "sandbox,timer"; clock-frequency = <1000000>;
include/dm/uclass-id.h +1 -0
@@ -16,6 +16,7 @@ enum uclass_id {UCLASS_DEMO ,UCLASS_TEST ,UCLASS_TEST_FDT , +UCLASS_TEST_FDT_MANUAL ,UCLASS_TEST_BUS ,UCLASS_TEST_PROBE , UCLASS_TEST_DUMMY,
test/dm/test-fdt.c +42 -0
54 lines not on this page · raw message
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 22/28 dm: test: Add a test for DM_UC_FLAG_NO_AUTO_SEQ
Check that this flag operates as expected. This patch is not earlier in this series since is uses the new behaviour of dev_seq().
---
Changes in v3:
- Add new patch to test DM_UC_FLAG_NO_AUTO_SEQ
arch/sandbox/dts/test.dts | 13 ++++++++++++ include/dm/uclass-id.h | 1 + test/dm/test-fdt.c | 42 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+)
Applied to u-boot-dm/next, thanks!
PATCH v3 23/28 dm: Drop uclass_resolve_seq()
In reply to Simon GlassThis function is not needed anymore. Drop it.
---
(no changes since v1)
drivers/core/device.c | 8 -------- drivers/core/uclass.c | 39 --------------------------------------- include/dm/uclass.h | 15 --------------- 3 files changed, 62 deletions(-)
drivers/core/device.c +0 -8
@@ -421,7 +421,6 @@ int device_probe(struct udevice *dev) {const struct driver *drv;int ret; -int seq;if (!dev)return -EINVAL ;
@@ -452,13 +451,6 @@ int device_probe(struct udevice *dev)return 0 ; } - seq =uclass_resolve_seq (dev); -if (seq <0 ) { - ret = seq; - goto fail; - } - dev->seq = seq; - dev->flags |=DM_FLAG_ACTIVATED ;/*
drivers/core/uclass.c +0 -39
@@ -680,45 +680,6 @@ int uclass_unbind_device(struct udevice *dev) }#endif -int uclass_resolve_seq (struct udevice *dev) -{ -struct uclass *uc = dev->uclass; -struct uclass_driver *uc_drv = uc->uc_drv; -struct udevice *dup; -int seq =0 ; -int ret; - -assert (dev_seq (dev) ==-1 ); - ret =uclass_find_device_by_seq (uc_drv->id, dev->req_seq, false, &dup); -if (!ret) { -/* Do nothing here for now */ - }else if (ret == -ENODEV ) { -/* Our requested sequence number is available */ -if (dev->req_seq !=-1 ) -return dev->req_seq; - }else { -return ret; - } - -if (CONFIG_IS_ENABLED (OF_CONTROL ) &&CONFIG_IS_ENABLED (DM_SEQ_ALIAS ) && - (uc_drv->flags &DM_UC_FLAG_SEQ_ALIAS )) { -/* -* dev_read_alias_highest_id() will return -1 if there no -* alias. Thus we can always add one. -*/ - seq =dev_read_alias_highest_id (uc_drv->name) +1 ; - } - -for (; seq <DM_MAX_SEQ ; seq++) { - ret =uclass_find_device_by_seq (uc_drv->id, seq, false, &dup); -if (ret == -ENODEV ) -break ; -if (ret) -return ret; - } -return seq; -} -int uclass_pre_probe_device (struct udevice *dev) {struct uclass_driver *uc_drv;
include/dm/uclass.h +0 -15
@@ -368,21 +368,6 @@ int uclass_next_device_check(struct udevice **devp);int uclass_first_device_drvdata (enum uclass_id id,ulong driver_data,struct udevice **devp); -/** -* uclass_resolve_seq() - Resolve a device's sequence number -* -* On entry dev->seq is -1, and dev->req_seq may be -1 (to allocate a -* sequence number automatically, or >= 0 to select a particular number. -* If the requested sequence number is in use, then this device will -* be allocated another one. -* -* Note that the device's seq value is not changed by this function. -* -* @dev: Device for which to allocate sequence number -* @return sequence number allocated, or -ve on error -*/ -int uclass_resolve_seq (struct udevice *dev); -/** * uclass_id_foreach_dev() - Helper function to iteration through devices *
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 23/28 dm: Drop uclass_resolve_seq()
This function is not needed anymore. Drop it.
---
(no changes since v1)
drivers/core/device.c | 8 -------- drivers/core/uclass.c | 39 --------------------------------------- include/dm/uclass.h | 15 --------------- 3 files changed, 62 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 24/28 dm: Drop the unused arg in uclass_find_device_by_seq()
In reply to Simon GlassNow that there is only one sequence number (rather than both requested and assigned ones) we can simplify this function. Also update its caller to simplify the logic.
---
(no changes since v1)
arch/arm/mach-k3/am6_init.c | 2 +- arch/arm/mach-k3/j721e_init.c | 2 +- arch/arm/mach-k3/sysfw-loader.c | 2 +- drivers/core/device.c | 16 ++++------ drivers/core/uclass.c | 22 +++++--------- drivers/spi/spi-uclass.c | 4 +-- drivers/usb/host/usb-uclass.c | 4 +-- include/dm/device.h | 18 ++++-------- include/dm/uclass-internal.h | 18 ++++-------- net/eth-uclass.c | 2 +- test/dm/bus.c | 16 +++++----- test/dm/test-fdt.c | 52 ++++++++++++++++----------------- 12 files changed, 64 insertions(+), 94 deletions(-)
arch/arm/mach-k3/am6_init.c +1 -1
@@ -208,7 +208,7 @@ void board_init_f(ulong dummy)* firmware (SYSFW) image for various purposes and SYSFW depends on us * to initialize its pin settings. */ - ret =uclass_find_device_by_seq (UCLASS_SERIAL ,0 , true, &dev); + ret =uclass_find_device_by_seq (UCLASS_SERIAL ,0 , &dev);if (!ret)pinctrl_select_state (dev,"default" );
arch/arm/mach-k3/j721e_init.c +1 -1
@@ -167,7 +167,7 @@ void board_init_f(ulong dummy)* firmware (SYSFW) image for various purposes and SYSFW depends on us * to initialize its pin settings. */ - ret =uclass_find_device_by_seq (UCLASS_SERIAL ,0 , true, &dev); + ret =uclass_find_device_by_seq (UCLASS_SERIAL ,0 , &dev);if (!ret)pinctrl_select_state (dev,"default" );
arch/arm/mach-k3/sysfw-loader.c +1 -1
@@ -223,7 +223,7 @@ static void *k3_sysfw_get_spi_addr(void)int ret; ret =uclass_find_device_by_seq (UCLASS_SPI ,CONFIG_SF_DEFAULT_BUS , - true, &dev); + &dev);if (ret)return NULL ;
drivers/core/device.c +5 -11
@@ -647,15 +647,15 @@ int device_get_child_count(const struct udevice *parent)return count; } -int device_find_child_by_seq (const struct udevice *parent,int seq_or_req_seq, -bool find_req_seq,struct udevice **devp) +int device_find_child_by_seq (const struct udevice *parent,int seq, +struct udevice **devp) {struct udevice *dev; *devp =NULL ;list_for_each_entry (dev, &parent->child_head, sibling_node) { -if (dev->sqq == seq_or_req_seq) { +if (dev->sqq == seq) { *devp = dev;return 0 ; }
@@ -671,14 +671,8 @@ int device_get_child_by_seq(const struct udevice *parent, int seq,int ret; *devp =NULL ; - ret =device_find_child_by_seq (parent, seq, false, &dev); -if (ret == -ENODEV ) { -/* -* We didn't find it in probed devices. See if there is one -* that will request this seq if probed. -*/ - ret =device_find_child_by_seq (parent, seq, true, &dev); - } + ret =device_find_child_by_seq (parent, seq, &dev); +return device_get_device_tail (dev, ret, devp); }
drivers/core/uclass.c +7 -15
@@ -288,25 +288,23 @@ int uclass_find_next_free_req_seq(struct uclass *uc)return max +1 ; } -int uclass_find_device_by_seq (enum uclass_id id,int seq_or_req_seq, -bool find_req_seq,struct udevice **devp) +int uclass_find_device_by_seq (enum uclass_id id,int seq,struct udevice **devp) {struct uclass *uc;struct udevice *dev;int ret; *devp =NULL ; -log_debug ("%d %d\n" , find_req_seq, seq_or_req_seq); -if (seq_or_req_seq ==-1 ) +log_debug ("%d\n" , seq); +if (seq ==-1 )return -ENODEV ; ret =uclass_get (id, &uc);if (ret)return ret; uclass_foreach_dev(dev, uc) { -log_debug (" - %d %d '%s'\n" , - dev->req_seq,dev_seq (dev), dev->name); -if (dev_seq (dev) == seq_or_req_seq) { +log_debug (" - %d '%s'\n" , dev->sqq, dev->name); +if (dev->sqq == seq) { *devp = dev;log_debug (" - found\n" );return 0 ;
@@ -466,14 +464,8 @@ int uclass_get_device_by_seq(enum uclass_id id, int seq, struct udevice **devp)int ret; *devp =NULL ; - ret =uclass_find_device_by_seq (id, seq, false, &dev); -if (ret == -ENODEV ) { -/* -* We didn't find it in probed devices. See if there is one -* that will request this seq if probed. -*/ - ret =uclass_find_device_by_seq (id, seq, true, &dev); - } + ret =uclass_find_device_by_seq (id, seq, &dev); +return uclass_get_device_tail (dev, ret, devp); }
drivers/spi/spi-uclass.c +2 -2
@@ -273,7 +273,7 @@ int spi_cs_is_valid(unsigned int busnum, unsigned int cs)struct udevice *bus;int ret; - ret =uclass_find_device_by_seq (UCLASS_SPI , busnum, false, &bus); + ret =uclass_find_device_by_seq (UCLASS_SPI , busnum, &bus);if (ret) {debug ("%s: No bus %d\n" , __func__, busnum);return ret;
@@ -302,7 +302,7 @@ int spi_find_bus_and_cs(int busnum, int cs, struct udevice **busp,struct udevice *bus, *dev;int ret; - ret =uclass_find_device_by_seq (UCLASS_SPI , busnum, false, &bus); + ret =uclass_find_device_by_seq (UCLASS_SPI , busnum, &bus);if (ret) {debug ("%s: No bus %d\n" , __func__, busnum);return ret;
drivers/usb/host/usb-uclass.c +2 -2
@@ -394,7 +394,7 @@ int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp)int ret;/* Find the old device and remove it */ - ret =uclass_find_device_by_seq (UCLASS_USB ,0 , true, &dev); + ret =uclass_find_device_by_seq (UCLASS_USB ,0 , &dev);if (ret)return ret; ret =device_remove (dev,DM_REMOVE_NORMAL );
@@ -417,7 +417,7 @@ int usb_remove_ehci_gadget(struct ehci_ctrl **ctlrp)int ret;/* Find the old device and remove it */ - ret =uclass_find_device_by_seq (UCLASS_USB ,0 , true, &dev); + ret =uclass_find_device_by_seq (UCLASS_USB ,0 , &dev);if (ret)return ret; ret =device_remove (dev,DM_REMOVE_NORMAL );
include/dm/device.h +5 -13
@@ -452,24 +452,16 @@ int device_get_child_count(const struct udevice *parent);/** * device_find_child_by_seq() - Find a child device based on a sequence * -* This searches for a device with the given seq or req_seq. -* -* For seq, if an active device has this sequence it will be returned. -* If there is no such device then this will return -ENODEV. -* -* For req_seq, if a device (whether activated or not) has this req_seq -* value, that device will be returned. This is a strong indication that -* the device will receive that sequence when activated. +* This searches for a device with the given seq. * * @parent: Parent device -* @seq_or_req_seq: Sequence number to find (0=first) -* @find_req_seq: true to find req_seq, false to find seq +* @seq: Sequence number to find (0=first) * @devp: Returns pointer to device (there is only one per for each seq). * Set to NULL if none is found -* @return 0 if OK, -ve on error +* @return 0 if OK, -ENODEV if not found */ -int device_find_child_by_seq (const struct udevice *parent,int seq_or_req_seq, -bool find_req_seq,struct udevice **devp); +int device_find_child_by_seq (const struct udevice *parent,int seq, +struct udevice **devp);/** * device_get_child_by_seq() - Get a child device based on a sequence
include/dm/uclass-internal.h +5 -13
@@ -103,25 +103,17 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,/** * uclass_find_device_by_seq() - Find uclass device based on ID and sequence * -* This searches for a device with the given seq or req_seq. -* -* For seq, if an active device has this sequence it will be returned. -* If there is no such device then this will return -ENODEV. -* -* For req_seq, if a device (whether activated or not) has this req_seq -* value, that device will be returned. This is a strong indication that -* the device will receive that sequence when activated. +* This searches for a device with the given seq. * * The device is NOT probed, it is merely returned. * * @id: ID to look up -* @seq_or_req_seq: Sequence number to find (0=first) -* @find_req_seq: true to find req_seq, false to find seq +* @seq: Sequence number to find (0=first) * @devp: Returns pointer to device (there is only one per for each seq) -* @return 0 if OK, -ve on error +* @return 0 if OK, -ENODEV if not found */ -int uclass_find_device_by_seq (enum uclass_id id,int seq_or_req_seq, -bool find_req_seq,struct udevice **devp); +int uclass_find_device_by_seq (enum uclass_id id,int seq, +struct udevice **devp);/** * uclass_find_device_by_of_offset() - Find a uclass device by device tree node
net/eth-uclass.c +1 -1
@@ -232,7 +232,7 @@ static int on_ethaddr(const char *name, const char *value, enum env_op op,/* look for an index after "eth" */ index =simple_strtoul (name +3 ,NULL ,10 ); - retval =uclass_find_device_by_seq (UCLASS_ETH , index, false, &dev); + retval =uclass_find_device_by_seq (UCLASS_ETH , index, &dev);if (!retval) {struct eth_pdata *pdata = dev->plat;switch (op) {
test/dm/bus.c +8 -8
@@ -156,17 +156,17 @@ static int dm_test_bus_children_funcs(struct unit_test_state *uts)ut_asserteq_str ("c-test at 5" , dev->name);/* Device with sequence number 0 should be accessible */ -ut_asserteq (-ENODEV ,device_find_child_by_seq (bus,-1 , true, &dev)); -ut_assertok (device_find_child_by_seq (bus,0 , true, &dev)); +ut_asserteq (-ENODEV ,device_find_child_by_seq (bus,-1 , &dev)); +ut_assertok (device_find_child_by_seq (bus,0 , &dev));ut_assert (!(dev->flags &DM_FLAG_ACTIVATED )); -ut_asserteq (0 ,device_find_child_by_seq (bus,0 , false, &dev)); +ut_asserteq (0 ,device_find_child_by_seq (bus,0 , &dev));ut_assertok (device_get_child_by_seq (bus,0 , &dev));ut_assert (dev->flags &DM_FLAG_ACTIVATED ); -ut_asserteq (0 ,device_find_child_by_seq (bus,0 , false, &dev)); +ut_asserteq (0 ,device_find_child_by_seq (bus,0 , &dev));/* There is no device with sequence number 2 */ -ut_asserteq (-ENODEV ,device_find_child_by_seq (bus,2 , false, &dev)); -ut_asserteq (-ENODEV ,device_find_child_by_seq (bus,2 , true, &dev)); +ut_asserteq (-ENODEV ,device_find_child_by_seq (bus,2 , &dev)); +ut_asserteq (-ENODEV ,device_find_child_by_seq (bus,2 , &dev));ut_asserteq (-ENODEV ,device_get_child_by_seq (bus,2 , &dev));/* Looking for something that is not a child */
@@ -220,7 +220,7 @@ static int dm_test_bus_children_iterators(struct unit_test_state *uts)ut_asserteq_ptr (dev,NULL );/* Move to the next child without using device_find_first_child() */ -ut_assertok (device_find_child_by_seq (bus,5 , true, &dev)); +ut_assertok (device_find_child_by_seq (bus,5 , &dev));ut_asserteq_str ("c-test at 5" , dev->name);ut_assertok (device_find_next_child (&dev));ut_asserteq_str ("c-test at 0" , dev->name);
@@ -245,7 +245,7 @@ static int test_bus_parent_data(struct unit_test_state *uts)ut_assertok (uclass_get_device (UCLASS_TEST_BUS ,0 , &bus));/* Check that parent data is allocated */ -ut_assertok (device_find_child_by_seq (bus,0 , true, &dev)); +ut_assertok (device_find_child_by_seq (bus,0 , &dev));ut_asserteq_ptr (NULL ,dev_get_parent_priv (dev));ut_assertok (device_get_child_by_seq (bus,0 , &dev)); parent_data =dev_get_parent_priv (dev);
test/dm/test-fdt.c +26 -26
156 lines not on this page · raw message
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 24/28 dm: Drop the unused arg in uclass_find_device_by_seq()
Now that there is only one sequence number (rather than both requested and assigned ones) we can simplify this function. Also update its caller to simplify the logic.
---
(no changes since v1)
arch/arm/mach-k3/am6_init.c | 2 +- arch/arm/mach-k3/j721e_init.c | 2 +- arch/arm/mach-k3/sysfw-loader.c | 2 +- drivers/core/device.c | 16 ++++------ drivers/core/uclass.c | 22 +++++--------- drivers/spi/spi-uclass.c | 4 +-- drivers/usb/host/usb-uclass.c | 4 +-- include/dm/device.h | 18 ++++-------- include/dm/uclass-internal.h | 18 ++++-------- net/eth-uclass.c | 2 +- test/dm/bus.c | 16 +++++----- test/dm/test-fdt.c | 52 ++++++++++++++++----------------- 12 files changed, 64 insertions(+), 94 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 25/28 dm: core: Update uclass_find_next_free_req_seq() for new scheme
In reply to Simon GlassThis function current deals with req_seq which is deprecated. Update it to use the new sequence numbers, putting them above existing aliases. Rename the function to make this clear.
---
(no changes since v2)
Changes in v2:
- Update for new logic
- Adjust commit message
- Drop pointless check for max == -1
drivers/core/device.c | 8 ++------ drivers/core/uclass.c | 19 +++++++++++++------ drivers/pci/pci-uclass.c | 2 +- include/dm/uclass-internal.h | 17 ++++++++++------- 4 files changed, 26 insertions(+), 20 deletions(-)
drivers/core/device.c +2 -6
@@ -93,18 +93,14 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv, }if (CONFIG_IS_ENABLED (OF_PRIOR_STAGE )) {if (dev->req_seq ==-1 ) { - auto_seq = true; dev->req_seq = -uclass_find_next_free_req_seq ( - uc); +uclass_find_next_free_seq (uc); } } - }else { - dev->req_seq =uclass_find_next_free_req_seq (uc); } }if (auto_seq && !(uc->uc_drv->flags &DM_UC_FLAG_NO_AUTO_SEQ )) - dev->sqq =uclass_find_next_free_req_seq (uc); + dev->sqq =uclass_find_next_free_seq (uc);if (drv->plat_auto) {bool alloc = !plat;
drivers/core/uclass.c +13 -6
@@ -272,18 +272,25 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,return -ENODEV ; } -int uclass_find_next_free_req_seq (struct uclass *uc) +int uclass_find_next_free_seq (struct uclass *uc) {struct udevice *dev;int max =-1 ; +/* If using aliases, start with the highest alias value */ +if (CONFIG_IS_ENABLED (DM_SEQ_ALIAS ) && + (uc->uc_drv->flags &DM_UC_FLAG_SEQ_ALIAS )) + max =dev_read_alias_highest_id (uc->uc_drv->name); + +/* Avoid conflict with existing devices */ list_for_each_entry (dev, &uc->dev_head, uclass_node) { -if ((dev->req_seq !=-1 ) && (dev->req_seq > max)) - max = dev->req_seq; +if (dev->sqq > max) + max = dev->sqq; } - -if (max ==-1 ) -return 0 ; +/* +* At this point, max will be -1 if there are no existing aliases or +* devices +*/ return max +1 ; }
drivers/pci/pci-uclass.c +1 -1
@@ -1019,7 +1019,7 @@ static int pci_uclass_pre_probe(struct udevice *bus) ret =uclass_get (UCLASS_PCI , &uc);if (ret)return ret; - bus->sqq =uclass_find_next_free_req_seq (uc); + bus->sqq =uclass_find_next_free_seq (uc); }/* For bridges, use the top-level PCI controller */
include/dm/uclass-internal.h +10 -7
@@ -12,17 +12,20 @@#include <dm/ofnode.h> /** -* uclass_find_next_free_req_seq() - Get the next free req_seq number +* uclass_find_next_free_seq() - Get the next free sequence number * -* This returns the next free req_seq number. This is useful only if -* OF_CONTROL is not used. The next free req_seq number is simply the -* maximum req_seq of the uclass + 1. -* This allows assiging req_seq number in the binding order. +* This returns the next free sequence number. This is useful only if +* OF_CONTROL is not used. The next free sequence number is simply the +* maximum sequence number used by all devices in the uclass + 1. The value +* returned is always greater than the largest alias, if DM_SEQ_ALIAS is enabled +* and the uclass has the DM_UC_FLAG_SEQ_ALIAS flag. +* +* This allows assigning the sequence number in the binding order. * * @uc: uclass to check -* @return The next free req_seq number +* @return The next free sequence number */ -int uclass_find_next_free_req_seq (struct uclass *uc); +int uclass_find_next_free_seq (struct uclass *uc);/** * uclass_get_device_tail() - handle the end of a get_device call
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 25/28 dm: core: Update uclass_find_next_free_req_seq() for new scheme
This function current deals with req_seq which is deprecated. Update it to use the new sequence numbers, putting them above existing aliases. Rename the function to make this clear.
---
(no changes since v2)
Changes in v2:
- Update for new logic
- Adjust commit message
- Drop pointless check for max == -1
drivers/core/device.c | 8 ++------ drivers/core/uclass.c | 19 +++++++++++++------ drivers/pci/pci-uclass.c | 2 +- include/dm/uclass-internal.h | 17 ++++++++++------- 4 files changed, 26 insertions(+), 20 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 26/28 cmd: Drop use of old sequence numbers in commands
In reply to Simon GlassSeveral commands use sequence numbers. Update them to use the new ones.
---
(no changes since v1)
cmd/axi.c | 4 ++-- cmd/i2c.c | 2 +- cmd/osd.c | 4 ++-- drivers/core/dump.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-)
cmd/axi.c +2 -2
@@ -33,9 +33,9 @@ static void show_bus(struct udevice *bus) {struct udevice *dev; -printf ("Bus %d:\t%s" , bus->req_seq, bus->name); +printf ("Bus %d:\t%s" ,dev_seq (bus), bus->name);if (device_active (bus)) -printf (" (active %d)" ,dev_seq (bus)); +printf (" (active)" );printf ("\n" ); for (device_find_first_child(bus, &dev); dev;
cmd/i2c.c +1 -1
@@ -1700,7 +1700,7 @@ static void show_bus(struct udevice *bus) {struct udevice *dev; -printf ("Bus %d:\t%s" , bus->req_seq, bus->name); +printf ("Bus %d:\t%s" ,dev_seq (bus), bus->name);if (device_active (bus))printf (" (active %d)" ,dev_seq (bus));printf ("\n" );
cmd/osd.c +2 -2
@@ -75,9 +75,9 @@ static int osd_get_osd_cur(struct udevice **osdp)*/ static void show_osd (struct udevice *osd) { -printf ("OSD %d:\t%s" , osd->req_seq, osd->name); +printf ("OSD %d:\t%s" ,dev_seq (osd), osd->name);if (device_active (osd)) -printf (" (active %d)" ,dev_seq (osd)); +printf (" (active)" );printf ("\n" ); }
drivers/core/dump.c +2 -2
@@ -67,8 +67,8 @@ static void dm_display_line(struct udevice *dev, int index)printf ("%-3i %c %s @ %08lx" , index, dev->flags &DM_FLAG_ACTIVATED ?'*' :' ' , dev->name, (ulong )map_to_sysmem (dev)); -if (dev_seq (dev) !=-1 || dev->req_seq !=-1 ) -printf (", seq %d, (req %d)" ,dev_seq (dev), dev->req_seq); +if (dev->sqq !=-1 ) +printf (", seq %d" ,dev_seq (dev));puts ("\n" ); }
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 26/28 cmd: Drop use of old sequence numbers in commands
Several commands use sequence numbers. Update them to use the new ones.
---
(no changes since v1)
cmd/axi.c | 4 ++-- cmd/i2c.c | 2 +- cmd/osd.c | 4 ++-- drivers/core/dump.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 27/28 dm: core: Drop seq and req_seq
In reply to Simon GlassNow that migration to the new sequence numbers is complete, drop the old fields. Add a test that covers the new behaviour.
Also drop the check for OF_PRIOR_STAGE since we always assign sequence numbers now.
---
(no changes since v2)
Changes in v2:
- Adjust the tests to handle the new allocation scheme
- Simplify the logic so auto_seq is positive
drivers/core/device-remove.c | 1 - drivers/core/device.c | 17 ++-------------- include/dm/device.h | 9 +-------- test/dm/test-fdt.c | 39 ++++++++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 24 deletions(-)
drivers/core/device-remove.c +0 -1
@@ -207,7 +207,6 @@ int device_remove(struct udevice *dev, uint flags)if (flags_remove (flags, drv->flags)) {device_free (dev); - dev->seq =-1 ; dev->flags &= ~DM_FLAG_ACTIVATED ; }
drivers/core/device.c +2 -15
@@ -72,30 +72,18 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv, dev->driver = drv; dev->uclass = uc; - dev->seq =-1 ; - dev->req_seq =-1 ; dev->sqq =-1 ;if (CONFIG_IS_ENABLED (DM_SEQ_ALIAS ) && (uc->uc_drv->flags &DM_UC_FLAG_SEQ_ALIAS )) {/* * Some devices, such as a SPI bus, I2C bus and serial ports * are numbered using aliases. -* -* This is just a 'requested' sequence, and will be -* resolved (and ->seq updated) when the device is probed. */ if (CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA )) {if (uc->uc_drv->name &&ofnode_valid (node)) { -dev_read_alias_seq (dev, &dev->sqq); -dev_read_alias_seq (dev, &dev->req_seq); - auto_seq = false; - } -if (CONFIG_IS_ENABLED (OF_PRIOR_STAGE )) { -if (dev->req_seq ==-1 ) { - dev->req_seq = -uclass_find_next_free_seq (uc); - } +if (!dev_read_alias_seq (dev, &dev->sqq)) + auto_seq = false; } } }
@@ -509,7 +497,6 @@ fail_uclass: fail: dev->flags &= ~DM_FLAG_ACTIVATED ; - dev->seq =-1 ;device_free (dev);return ret;
include/dm/device.h +1 -8
@@ -131,16 +131,11 @@ enum {* @child_head: List of children of this device * @sibling_node: Next device in list of all devices * @flags: Flags for this device DM_FLAG_... -* @sqq: Allocated sequence number for this device (-1 = none). This is set up +* @seq: Allocated sequence number for this device (-1 = none). This is set up * when the device is bound and is unique within the device's uclass. If the * device has an alias in the devicetree then that is used to set the sequence * number. Otherwise, the next available number is used. Sequence numbers are * used by certain commands that need device to be numbered (e.g. 'mmc dev') -* -* The following two fields are deprecated: -* @req_seq: Requested sequence number for this device (-1 = any) -* @seq: Allocated sequence number for this device (-1 = none). This is set up -* when the device is probed and will be unique within the device's uclass. * @devres_head: List of memory allocations associated with this device. * When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will * add to this list. Memory so-allocated will be freed
@@ -164,8 +159,6 @@ struct udevice {struct list_head sibling_node;uint32_t flags;int sqq; -int req_seq; -int seq;#ifdef CONFIG_DEVRES struct list_head devres_head;#endif
test/dm/test-fdt.c +39 -0
@@ -441,6 +441,45 @@ static int dm_test_fdt_uclass_seq_manual(struct unit_test_state *uts) }DM_TEST (dm_test_fdt_uclass_seq_manual,UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT ); +static int dm_test_fdt_uclass_seq_more (struct unit_test_state *uts) +{ +struct udevice *dev; +ofnode node; + +/* Check creating a device with an alias */ + node =ofnode_path ("/some-bus/c-test at 1" ); +ut_assertok (device_bind (dm_root (),DM_GET_DRIVER (testfdt_drv), +"c-test at 1" ,NULL , node, &dev)); +ut_asserteq (12 ,dev_seq (dev)); +ut_assertok (uclass_get_device_by_seq (UCLASS_TEST_FDT ,12 , &dev)); +ut_asserteq_str ("c-test at 1" , dev->name); + +/* +* Now bind a device without an alias. It should not get the next +* sequence number after all aliases, and existing bound devices. The +* last alias is 12, so we have: +* +* 13 d-test +* 14 f-test +* 15 g-test +* 16 h-test +* 17 another-test +* 18 chosen-test +* +* So next available is 19 +*/ +ut_assertok (device_bind (dm_root (),DM_GET_DRIVER (testfdt_drv), +"fred" ,NULL ,ofnode_null (), &dev)); +ut_asserteq (19 ,dev_seq (dev)); + +ut_assertok (device_bind (dm_root (),DM_GET_DRIVER (testfdt_drv), +"fred2" ,NULL ,ofnode_null (), &dev)); +ut_asserteq (20 ,dev_seq (dev)); + +return 0 ; +} +DM_TEST (dm_test_fdt_uclass_seq_more,UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT ); +/* Test that we can find a device by device tree offset */ static int dm_test_fdt_offset (struct unit_test_state *uts) {
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 27/28 dm: core: Drop seq and req_seq
Now that migration to the new sequence numbers is complete, drop the old fields. Add a test that covers the new behaviour.
Also drop the check for OF_PRIOR_STAGE since we always assign sequence numbers now.
---
(no changes since v2)
Changes in v2:
- Adjust the tests to handle the new allocation scheme
- Simplify the logic so auto_seq is positive
drivers/core/device-remove.c | 1 - drivers/core/device.c | 17 ++-------------- include/dm/device.h | 9 +-------- test/dm/test-fdt.c | 39 ++++++++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 24 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v3 28/28 dm: Update documentation for new sequence numbers
In reply to Simon GlassUpdate the driver model documention to describe how sequence numbers now work.
---
(no changes since v2)
Changes in v2:
- 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()
doc/driver-model/design.rst | 59 ++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 24 deletions(-)
doc/driver-model/design.rst +35 -24
@@ -515,11 +515,23 @@ cases. While it might be tempting to automatically renumber the devices where there are gaps in the sequence, this can lead to confusion and is not the way that U-Boot works. -Each device can request a sequence number. If none is required then the -device will be automatically allocated the next available sequence number. +Where a device gets its sequence number is controlled by the DM_SEQ_ALIAS +Kconfig option, which can have a different value in U-Boot proper and SPL. +If this option is not set, aliases are ignored. -To specify the sequence number in the device tree an alias is typically -used. Make sure that the uclass has the DM_UC_FLAG_SEQ_ALIAS flag set. +Even if CONFIG_DM_SEQ_ALIAS is enabled, the uclass must still have the +DM_UC_FLAG_SEQ_ALIAS flag set, for its devices to be sequenced by aliases. + +With those options set, devices with an alias (e.g. "serial2") will get that +sequence number (e.g. 2). Other devices get the next available number after all +aliases and all existing numbers. This means that if there is just a single +alias "serial2", unaliased serial devices will be assigned 3 or more, with 0 and +1 being unused. + +If CONFIG_DM_SEQ_ALIAS or DM_UC_FLAG_SEQ_ALIAS are not set, all devices will get +sequence numbers in a simple ordering starting from 0. To find the next number +to allocate, driver model scans through to find the maximum existing number, +then uses the next one. It does not attempt to fill in gaps. .. code-block:: none
@@ -546,12 +558,18 @@ More commonly you can use node references, which expand to the full path: The alias resolves to the same string in this case, but this version is easier to read. -Device sequence numbers are resolved when a device is probed. Before then -the sequence number is only a request which may or may not be honoured, -depending on what other devices have been probed. However the numbering is -entirely under the control of the board author so a conflict is generally -an error. +Device sequence numbers are resolved when a device is bound and the number does +not change for the life of the device. + +There are some situations where the uclass must allocate sequence numbers, +since a strictly increase sequence (with devicetree nodes bound first) is not +suitable. An example of this is the PCI bus. In this case, you can set the +uclass DM_UC_FLAG_NO_AUTO_SEQ flag. With this flag set, only devices with an +alias will be assigned a number by driver model. The rest is left to the uclass +to sort out, e.g. when enumerating the bus. +Note that changing the sequence number for a device (e.g. in a driver) is not +permitted. If it is felt to be necessary, ask on the mailing list. Bus Drivers -----------
@@ -673,6 +691,10 @@ plat will be NULL, but of_offset will be the offset of the device tree node that caused the device to be created. The uclass is set correctly for the device. +The device's sequence number is assigned, either the requested one or the next +available one (after all aliases are processed) if nothing particular is +requested. + The device's bind() method is permitted to perform simple actions, but should not scan the device tree node, not initialise hardware, nor set up structures or allocate memory. All of these tasks should be left for
@@ -780,11 +802,7 @@ as above and then following these steps (see device_probe()): This means (for example) that an I2C driver will require that its bus be activated. - 2. The device's sequence number is assigned, either the requested one - (assuming no conflicts) or the next available one if there is a conflict - or nothing particular is requested. - - 4. The device's probe() method is called. This should do anything that + 2. The device's probe() method is called. This should do anything that is required by the device to get it going. This could include checking that the hardware is actually present, setting up clocks for the hardware and setting up hardware registers to initial values. The code
@@ -799,9 +817,9 @@ as above and then following these steps (see device_probe()): allocate the priv space here yourself. The same applies also to plat_auto. Remember to free them in the remove() method. - 5. The device is marked 'activated' + 3. The device is marked 'activated' - 10. The uclass's post_probe() method is called, if one exists. This may + 4. The uclass's post_probe() method is called, if one exists. This may cause the uclass to do some housekeeping to record the device as activated and 'known' by the uclass.
@@ -850,14 +868,7 @@ remove it. This performs the probe steps in reverse: or preferably of_to_plat()) and the deallocation in remove() are the responsibility of the driver author. - 5. The device sequence number is set to -1, meaning that it no longer - has an allocated sequence. If the device is later reactivated and that - sequence number is still free, it may well receive the name sequence - number again. But from this point, the sequence number previously used - by this device will no longer exist (think of SPI bus 2 being removed - and bus 2 is no longer available for use). - - 6. The device is marked inactive. Note that it is still bound, so the + 5. The device is marked inactive. Note that it is still bound, so the device structure itself is not freed at this point. Should the device be activated again, then the cycle starts again at step 2 above.
Signature · 1 line
2.29.2.684.gfbc64c5ab5-goog
PATCH v3 28/28 dm: Update documentation for new sequence numbers
Update the driver model documention to describe how sequence numbers now work.
---
(no changes since v2)
Changes in v2:
- 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()
doc/driver-model/design.rst | 59 ++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 24 deletions(-)
Applied to u-boot-dm/next, thanks!
v3 cover dm: Change the way sequence numbers are implemented
In reply to Simon GlassAm 2020-12-17 05:20, schrieb Simon Glass:
Quoted 80 lines
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 flagDM_UC_FLAG_SEQ_ALIASis 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_SEQflag. 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 testDM_UC_FLAG_NO_AUTO_SEQChanges in v2:
- Give all devices a sequence number
- Dropuclass_alloc_all_seqs()andGD_FLG_DM_NO_SEQflag
- Drop theGD_FLG_DM_NO_SEQflag
- 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
Quoted 8 lines
- 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 soauto_seqis positive
- Update the docs to indicate all devices get a sequence number
- Update the docs to explain how aliases reserve sequence numbers
- Drop commit changingefi_uc_destroy()
-michael